@rpamis/comet 0.4.0-beta.18 → 0.4.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/assets/manifest.json +3 -1
- package/assets/skills/comet/scripts/comet-archive.mjs +121 -121
- package/assets/skills/comet/scripts/comet-entry-runtime.mjs +84 -84
- package/assets/skills/comet/scripts/comet-guard.mjs +152 -152
- package/assets/skills/comet/scripts/comet-handoff.mjs +123 -123
- package/assets/skills/comet/scripts/comet-hook-guard.mjs +75 -75
- package/assets/skills/comet/scripts/comet-hook-router.mjs +91 -91
- package/assets/skills/comet/scripts/comet-intent.mjs +6 -6
- package/assets/skills/comet/scripts/comet-resume-probe.mjs +79 -79
- package/assets/skills/comet/scripts/comet-runtime.mjs +169 -169
- package/assets/skills/comet/scripts/comet-state.mjs +88 -88
- package/assets/skills/comet/scripts/comet-yaml-validate.mjs +97 -97
- package/assets/skills/comet-build/SKILL.md +21 -6
- package/assets/skills/comet-design/SKILL.md +2 -2
- package/assets/skills/comet-native/SKILL.md +7 -7
- package/assets/skills/comet-native/reference/artifacts.md +3 -3
- package/assets/skills/comet-native/reference/clarification.md +1 -1
- package/assets/skills/comet-native/reference/commands.md +3 -3
- package/assets/skills/comet-native/scripts/comet-native-archive.mjs +114 -113
- package/assets/skills/comet-native/scripts/comet-native-doctor.mjs +123 -123
- package/assets/skills/comet-native/scripts/comet-native-hook-guard.mjs +88 -88
- package/assets/skills/comet-native/scripts/comet-native-init.mjs +116 -116
- package/assets/skills/comet-native/scripts/comet-native-new.mjs +100 -100
- package/assets/skills/comet-native/scripts/comet-native-next.mjs +118 -118
- package/assets/skills/comet-native/scripts/comet-native-root.mjs +95 -95
- package/assets/skills/comet-native/scripts/comet-native-runtime.mjs +145 -144
- package/assets/skills/comet-native/scripts/comet-native-select.mjs +101 -101
- package/assets/skills/comet-native/scripts/comet-native-show.mjs +83 -83
- package/assets/skills/comet-native/scripts/comet-native-spec.mjs +87 -87
- package/assets/skills/comet-native/scripts/comet-native-status.mjs +98 -98
- package/assets/skills/comet-review/SKILL.md +121 -0
- package/assets/skills/comet-review/agents/openai.yaml +5 -0
- package/assets/skills-zh/comet-build/SKILL.md +21 -6
- package/assets/skills-zh/comet-design/SKILL.md +2 -2
- package/assets/skills-zh/comet-native/SKILL.md +7 -7
- package/assets/skills-zh/comet-native/reference/artifacts.md +3 -3
- package/assets/skills-zh/comet-native/reference/clarification.md +1 -1
- package/assets/skills-zh/comet-native/reference/commands.md +3 -3
- package/assets/skills-zh/comet-review/SKILL.md +121 -0
- package/assets/skills-zh/comet-review/agents/openai.yaml +5 -0
- package/dist/app/commands/init.d.ts.map +1 -1
- package/dist/app/commands/init.js +5 -9
- 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 +5 -9
- package/dist/app/commands/update.js.map +1 -1
- package/dist/domains/comet-classic/classic-command-context.d.ts +9 -0
- package/dist/domains/comet-classic/classic-command-context.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-command-context.js +10 -0
- package/dist/domains/comet-classic/classic-command-context.js.map +1 -1
- package/dist/domains/comet-classic/classic-guard.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-guard.js +2 -2
- package/dist/domains/comet-classic/classic-guard.js.map +1 -1
- package/dist/domains/comet-classic/classic-handoff.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-handoff.js +44 -6
- package/dist/domains/comet-classic/classic-handoff.js.map +1 -1
- package/dist/domains/comet-classic/classic-hook-guard.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-hook-guard.js +2 -1
- package/dist/domains/comet-classic/classic-hook-guard.js.map +1 -1
- package/dist/domains/comet-classic/classic-intent-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-intent-command.js +2 -1
- package/dist/domains/comet-classic/classic-intent-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-resume-probe-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-resume-probe-command.js +4 -3
- package/dist/domains/comet-classic/classic-resume-probe-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-runtime-run.d.ts +6 -0
- package/dist/domains/comet-classic/classic-runtime-run.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-runtime-run.js +58 -9
- package/dist/domains/comet-classic/classic-runtime-run.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 +8 -5
- package/dist/domains/comet-classic/classic-state-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-validate-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-validate-command.js +2 -2
- package/dist/domains/comet-classic/classic-validate-command.js.map +1 -1
- package/dist/domains/comet-classic/classic-workspace-command.d.ts.map +1 -1
- package/dist/domains/comet-classic/classic-workspace-command.js +3 -3
- package/dist/domains/comet-classic/classic-workspace-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 +4 -1
- package/dist/domains/comet-entry/hook-adapter.js.map +1 -1
- package/dist/domains/comet-native/native-archive-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-archive-command.js +2 -0
- package/dist/domains/comet-native/native-archive-command.js.map +1 -1
- package/dist/domains/comet-native/native-atomic-file.d.ts.map +1 -1
- package/dist/domains/comet-native/native-atomic-file.js +17 -10
- package/dist/domains/comet-native/native-atomic-file.js.map +1 -1
- package/dist/domains/comet-native/native-children.d.ts +18 -2
- package/dist/domains/comet-native/native-children.d.ts.map +1 -1
- package/dist/domains/comet-native/native-children.js +73 -8
- package/dist/domains/comet-native/native-children.js.map +1 -1
- package/dist/domains/comet-native/native-cli-help.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-help.js +10 -4
- package/dist/domains/comet-native/native-cli-help.js.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.d.ts.map +1 -1
- package/dist/domains/comet-native/native-cli-shared.js +18 -5
- package/dist/domains/comet-native/native-cli-shared.js.map +1 -1
- package/dist/domains/comet-native/native-hook-guard.d.ts.map +1 -1
- package/dist/domains/comet-native/native-hook-guard.js +15 -2
- package/dist/domains/comet-native/native-hook-guard.js.map +1 -1
- package/dist/domains/comet-native/native-next-command.d.ts.map +1 -1
- package/dist/domains/comet-native/native-next-command.js +94 -15
- package/dist/domains/comet-native/native-next-command.js.map +1 -1
- package/dist/domains/comet-native/native-portable-continuation.d.ts +19 -7
- package/dist/domains/comet-native/native-portable-continuation.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-continuation.js +115 -72
- package/dist/domains/comet-native/native-portable-continuation.js.map +1 -1
- package/dist/domains/comet-native/native-portable-migration-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-migration-runtime.js +9 -4
- package/dist/domains/comet-native/native-portable-migration-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-portable-runtime.d.ts +14 -1
- package/dist/domains/comet-native/native-portable-runtime.d.ts.map +1 -1
- package/dist/domains/comet-native/native-portable-runtime.js +59 -1
- package/dist/domains/comet-native/native-portable-runtime.js.map +1 -1
- package/dist/domains/comet-native/native-pull-request-finish.d.ts +35 -0
- package/dist/domains/comet-native/native-pull-request-finish.d.ts.map +1 -0
- package/dist/domains/comet-native/native-pull-request-finish.js +282 -0
- package/dist/domains/comet-native/native-pull-request-finish.js.map +1 -0
- package/dist/domains/comet-native/native-status-discovery.d.ts.map +1 -1
- package/dist/domains/comet-native/native-status-discovery.js +24 -6
- package/dist/domains/comet-native/native-status-discovery.js.map +1 -1
- package/dist/domains/comet-native/native-workspace-finish.d.ts +6 -0
- package/dist/domains/comet-native/native-workspace-finish.d.ts.map +1 -1
- package/dist/domains/comet-native/native-workspace-finish.js +86 -35
- package/dist/domains/comet-native/native-workspace-finish.js.map +1 -1
- package/dist/domains/dashboard/web/assets/{abnfDiagram-N423BO3Z-B5cFR6hS.js → abnfDiagram-N423BO3Z-BYya6ofk.js} +1 -1
- package/dist/domains/dashboard/web/assets/{arc-CVQDtMsu.js → arc-DJbo4TD3.js} +1 -1
- package/dist/domains/dashboard/web/assets/{architectureDiagram-T3A2C74G-C0v0kULK.js → architectureDiagram-T3A2C74G-D8uZ2IB-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{blockDiagram-VBNYF7ZC-DpHLuxu4.js → blockDiagram-VBNYF7ZC-B16BVj-r.js} +1 -1
- package/dist/domains/dashboard/web/assets/{c4Diagram-5PPSVZJV-BHnFxUs1.js → c4Diagram-5PPSVZJV-ayV208_D.js} +1 -1
- package/dist/domains/dashboard/web/assets/channel-CEsrvmig.js +1 -0
- package/dist/domains/dashboard/web/assets/{chunk-2GRJ4B5K-CGC9gh5n.js → chunk-2GRJ4B5K-Bn5o8p3H.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-2Q5K7J3B-l4puLU_O.js → chunk-2Q5K7J3B-BnF1SI6B.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-5RXB4S5H-ls9jQHZc.js → chunk-5RXB4S5H-ETnma053.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-5VM5RSS4-BVavmTEq.js → chunk-5VM5RSS4-Cuvy639H.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-6Q2QTUOP-Dungt2g9.js → chunk-6Q2QTUOP-DOXBzl73.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-GF5L2VYU-BidXO_ZP.js → chunk-GF5L2VYU-CfREXlEl.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-JWPE2WC7-57L5Up5X.js → chunk-JWPE2WC7-DWIdpYTb.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-KBJHAD2P-C5u5vbwr.js → chunk-KBJHAD2P-BnqPcfZB.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-RYQCIY6F-CvLz21I2.js → chunk-RYQCIY6F-DdJ00fZz.js} +1 -1
- package/dist/domains/dashboard/web/assets/{chunk-XXDRQBXY-D5nJpckG.js → chunk-XXDRQBXY-BVDhdJyW.js} +1 -1
- package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-CKFe0hg4.js +1 -0
- package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-CKFe0hg4.js +1 -0
- package/dist/domains/dashboard/web/assets/{cose-bilkent-JH36ORCC-Dp0JAGyE.js → cose-bilkent-JH36ORCC-C-nglwHC.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefin-VYW2F7L2-EjC54l1g.js → cynefin-VYW2F7L2-C8TMmrbP.js} +1 -1
- package/dist/domains/dashboard/web/assets/{cynefinDiagram-MW4NZA55-CpYrW3w3.js → cynefinDiagram-MW4NZA55-C3pnQnjg.js} +1 -1
- package/dist/domains/dashboard/web/assets/{dagre-VZM6K2ZE-h5K39rCk.js → dagre-VZM6K2ZE-DY7UWiPI.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-7IWD3JNH-CKQj9O4H.js → diagram-7IWD3JNH-voTyDkQ5.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-B4RE2ZJO-DXRIYcnW.js → diagram-B4RE2ZJO-B3VkUMck.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-LBJQPF4R-wWutQYmv.js → diagram-LBJQPF4R-BdJzPkv8.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-Q27KOJAE-EgXLJQYi.js → diagram-Q27KOJAE-Bsq0anZx.js} +1 -1
- package/dist/domains/dashboard/web/assets/{diagram-UB23O5K3-CsQRXDQZ.js → diagram-UB23O5K3-CBaKRbcu.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ebnfDiagram-BXEA7PRR-gm328Eho.js → ebnfDiagram-BXEA7PRR-Bl9Bm5wa.js} +1 -1
- package/dist/domains/dashboard/web/assets/{erDiagram-JOGREHBK-BbbMVUx_.js → erDiagram-JOGREHBK-DjOZzfKI.js} +1 -1
- package/dist/domains/dashboard/web/assets/{flowDiagram-UKHOOZJN-1Y7scCns.js → flowDiagram-UKHOOZJN-C21e4siK.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ganttDiagram-PKOTCBZU-BAoBqczv.js → ganttDiagram-PKOTCBZU-Bs62uy6-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{gitGraphDiagram-DS77QQ5N-CMUAyEzl.js → gitGraphDiagram-DS77QQ5N-DQY_Ba00.js} +1 -1
- package/dist/domains/dashboard/web/assets/{index-CCApJ0Yr.js → index-BLv71GRj.js} +1 -1
- package/dist/domains/dashboard/web/assets/{index-DWdm_XBi.js → index-Be4r99N4.js} +3 -3
- package/dist/domains/dashboard/web/assets/index-ByVYiA6g.css +1 -0
- package/dist/domains/dashboard/web/assets/{infoDiagram-6WML65LV-BaCdtYYC.js → infoDiagram-6WML65LV-CNgNNG9l.js} +1 -1
- package/dist/domains/dashboard/web/assets/{ishikawaDiagram-WSZJBQD7-DQQlNnjU.js → ishikawaDiagram-WSZJBQD7-D9k1fTO1.js} +1 -1
- package/dist/domains/dashboard/web/assets/{journeyDiagram-NVQOT4AX-DW9wUMqn.js → journeyDiagram-NVQOT4AX-CHijUnPl.js} +1 -1
- package/dist/domains/dashboard/web/assets/{kanban-definition-27J2QSJJ-C_ITaZ0q.js → kanban-definition-27J2QSJJ-DfWlntDq.js} +1 -1
- package/dist/domains/dashboard/web/assets/{linear-DXOo6ZRT.js → linear-o6hemX-z.js} +1 -1
- package/dist/domains/dashboard/web/assets/{mermaid.core-ol-0NI97.js → mermaid.core-B1DoOsPD.js} +4 -4
- package/dist/domains/dashboard/web/assets/{mindmap-definition-FAOFIHXS-CHF_HOLV.js → mindmap-definition-FAOFIHXS-COMQF9Yy.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pegDiagram-VL7TDLO6-wQEvkNF8.js → pegDiagram-VL7TDLO6-C_21n7Ps.js} +1 -1
- package/dist/domains/dashboard/web/assets/{pieDiagram-7S7Q4E2Y-C3H3kiIP.js → pieDiagram-7S7Q4E2Y-D3EmoYDY.js} +1 -1
- package/dist/domains/dashboard/web/assets/{quadrantDiagram-CIZ2JOQS-S0FdVzJb.js → quadrantDiagram-CIZ2JOQS-C3fGdiMa.js} +1 -1
- package/dist/domains/dashboard/web/assets/{railroadDiagram-AXF67PYL-DCDXDaVg.js → railroadDiagram-AXF67PYL-mIsjemD-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{requirementDiagram-LRYGKXZP-BW8J4gO_.js → requirementDiagram-LRYGKXZP-D_UMpS5e.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sankeyDiagram-W5VNT64P-DQQBmLoy.js → sankeyDiagram-W5VNT64P-D1MwyMF6.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sequenceDiagram-SI44F4Z6-2tDcli0Y.js → sequenceDiagram-SI44F4Z6-B8jp1RxX.js} +1 -1
- package/dist/domains/dashboard/web/assets/{sizeCapture-X5ZJPWSS-4sEZLBKb.js → sizeCapture-X5ZJPWSS-BKioI1Ql.js} +1 -1
- package/dist/domains/dashboard/web/assets/{stateDiagram-OKZ733FA-OgPb8pyR.js → stateDiagram-OKZ733FA-B7l8_CDo.js} +1 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-BIxuwbeV.js +1 -0
- package/dist/domains/dashboard/web/assets/{swimlanes-SLNWSIFB-DR7lwtxd.js → swimlanes-SLNWSIFB-951PRLYp.js} +2 -2
- package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-CEo6cGsy.js +8 -0
- package/dist/domains/dashboard/web/assets/{timeline-definition-Z64GVDOM-DNIJVlQV.js → timeline-definition-Z64GVDOM-CeyA2KbI.js} +1 -1
- package/dist/domains/dashboard/web/assets/{vennDiagram-T6HMQDX7-CClhw4QZ.js → vennDiagram-T6HMQDX7-BHe0TZJV.js} +1 -1
- package/dist/domains/dashboard/web/assets/{wardleyDiagram-T6FBY63Y-DzR3aFPS.js → wardleyDiagram-T6FBY63Y-CWqdSzJ-.js} +1 -1
- package/dist/domains/dashboard/web/assets/{xychartDiagram-ELKLHX3M-DZhq0ZRj.js → xychartDiagram-ELKLHX3M-DCKiZVPV.js} +1 -1
- package/dist/domains/dashboard/web/index.html +2 -2
- package/dist/domains/dashboard/workspace.d.ts +3 -0
- package/dist/domains/dashboard/workspace.d.ts.map +1 -1
- package/dist/domains/dashboard/workspace.js +23 -2
- package/dist/domains/dashboard/workspace.js.map +1 -1
- package/dist/domains/integrations/openspec.d.ts +1 -1
- package/dist/domains/integrations/openspec.d.ts.map +1 -1
- package/dist/domains/integrations/openspec.js +43 -84
- package/dist/domains/integrations/openspec.js.map +1 -1
- package/dist/domains/integrations/superpowers.d.ts +10 -1
- package/dist/domains/integrations/superpowers.d.ts.map +1 -1
- package/dist/domains/integrations/superpowers.js +73 -4
- package/dist/domains/integrations/superpowers.js.map +1 -1
- package/dist/domains/skill/platform-inspect.d.ts.map +1 -1
- package/dist/domains/skill/platform-inspect.js +3 -3
- package/dist/domains/skill/platform-inspect.js.map +1 -1
- package/dist/domains/skill/platform-install.d.ts +3 -1
- package/dist/domains/skill/platform-install.d.ts.map +1 -1
- package/dist/domains/skill/platform-install.js +15 -9
- package/dist/domains/skill/platform-install.js.map +1 -1
- package/dist/domains/skill/project-instructions.d.ts.map +1 -1
- package/dist/domains/skill/project-instructions.js +6 -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 +39 -29
- package/dist/domains/skill/uninstall.js.map +1 -1
- package/dist/domains/workflow-contract/contained-atomic-write.d.ts.map +1 -1
- package/dist/domains/workflow-contract/contained-atomic-write.js +18 -10
- package/dist/domains/workflow-contract/contained-atomic-write.js.map +1 -1
- package/dist/domains/workflow-contract/project-config.d.ts +4 -2
- package/dist/domains/workflow-contract/project-config.d.ts.map +1 -1
- package/dist/domains/workflow-contract/project-config.js +132 -0
- package/dist/domains/workflow-contract/project-config.js.map +1 -1
- package/dist/domains/workflow-contract/types.d.ts +9 -0
- package/dist/domains/workflow-contract/types.d.ts.map +1 -1
- package/dist/platform/fs/strip-bom.d.ts +10 -0
- package/dist/platform/fs/strip-bom.d.ts.map +1 -0
- package/dist/platform/fs/strip-bom.js +12 -0
- package/dist/platform/fs/strip-bom.js.map +1 -0
- package/dist/platform/install/platforms.d.ts +11 -0
- package/dist/platform/install/platforms.d.ts.map +1 -1
- package/dist/platform/install/platforms.js +36 -0
- package/dist/platform/install/platforms.js.map +1 -1
- package/dist/platform/process/external-command.d.ts +1 -0
- package/dist/platform/process/external-command.d.ts.map +1 -1
- package/dist/platform/process/external-command.js +2 -1
- package/dist/platform/process/external-command.js.map +1 -1
- package/eval/local/tests/conftest.py +18 -3
- package/eval/local/tests/scaffold/test_conftest_helpers.py +57 -0
- package/package.json +11 -26
- package/dist/domains/dashboard/web/assets/channel-eM0x3m1G.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-JCYQIIEL-CEFhao2K.js +0 -1
- package/dist/domains/dashboard/web/assets/classDiagram-v2-OCEON4UE-CEFhao2K.js +0 -1
- package/dist/domains/dashboard/web/assets/index-DhhbseFJ.css +0 -1
- package/dist/domains/dashboard/web/assets/stateDiagram-v2-UEYNNEHI-CiDNPr4P.js +0 -1
- package/dist/domains/dashboard/web/assets/swimlanesDiagram-ULZ7WXOC-DggHFP9q.js +0 -8
- package/eval/local/tasks/comet-native-interrupted-transition/environment/.comet/config.yaml +0 -6
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __cometCreateRequire } from 'module';
|
|
3
3
|
const require = __cometCreateRequire(import.meta.url);
|
|
4
|
-
var
|
|
5
|
-
`)}};
|
|
6
|
-
`)?
|
|
4
|
+
var Qu=Object.create;var Ao=Object.defineProperty;var Zu=Object.getOwnPropertyDescriptor;var ed=Object.getOwnPropertyNames;var td=Object.getPrototypeOf,id=Object.prototype.hasOwnProperty;var Ci=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,i)=>(typeof require<"u"?require:t)[i]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var g=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(i){throw t=0,i}};var rd=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ed(t))!id.call(e,n)&&n!==i&&Ao(e,n,{get:()=>t[n],enumerable:!(r=Zu(t,n))||r.enumerable});return e};var Et=(e,t,i)=>(i=e!=null?Qu(td(e)):{},rd(t||!e||!e.__esModule?Ao(i,"default",{value:e,enumerable:!0}):i,e));var P=g(B=>{"use strict";var cn=Symbol.for("yaml.alias"),_o=Symbol.for("yaml.document"),Ai=Symbol.for("yaml.map"),To=Symbol.for("yaml.pair"),ln=Symbol.for("yaml.scalar"),_i=Symbol.for("yaml.seq"),ge=Symbol.for("yaml.node.type"),nd=e=>!!e&&typeof e=="object"&&e[ge]===cn,ad=e=>!!e&&typeof e=="object"&&e[ge]===_o,od=e=>!!e&&typeof e=="object"&&e[ge]===Ai,sd=e=>!!e&&typeof e=="object"&&e[ge]===To,Io=e=>!!e&&typeof e=="object"&&e[ge]===ln,cd=e=>!!e&&typeof e=="object"&&e[ge]===_i;function jo(e){if(e&&typeof e=="object")switch(e[ge]){case Ai:case _i:return!0}return!1}function ld(e){if(e&&typeof e=="object")switch(e[ge]){case cn:case Ai:case ln:case _i:return!0}return!1}var ud=e=>(Io(e)||jo(e))&&!!e.anchor;B.ALIAS=cn;B.DOC=_o;B.MAP=Ai;B.NODE_TYPE=ge;B.PAIR=To;B.SCALAR=ln;B.SEQ=_i;B.hasAnchor=ud;B.isAlias=nd;B.isCollection=jo;B.isDocument=ad;B.isMap=od;B.isNode=ld;B.isPair=sd;B.isScalar=Io;B.isSeq=cd});var Pt=g(un=>{"use strict";var D=P(),V=Symbol("break visit"),$o=Symbol("skip children"),le=Symbol("remove node");function Ti(e,t){let i=Oo(t);D.isDocument(e)?tt(null,e.contents,i,Object.freeze([e]))===le&&(e.contents=null):tt(null,e,i,Object.freeze([]))}Ti.BREAK=V;Ti.SKIP=$o;Ti.REMOVE=le;function tt(e,t,i,r){let n=Ho(e,t,i,r);if(D.isNode(n)||D.isPair(n))return Do(e,r,n),tt(e,n,i,r);if(typeof n!="symbol"){if(D.isCollection(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){let o=tt(a,t.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===V)return V;o===le&&(t.items.splice(a,1),a-=1)}}}else if(D.isPair(t)){r=Object.freeze(r.concat(t));let a=tt("key",t.key,i,r);if(a===V)return V;a===le&&(t.key=null);let o=tt("value",t.value,i,r);if(o===V)return V;o===le&&(t.value=null)}}return n}async function Ii(e,t){let i=Oo(t);D.isDocument(e)?await it(null,e.contents,i,Object.freeze([e]))===le&&(e.contents=null):await it(null,e,i,Object.freeze([]))}Ii.BREAK=V;Ii.SKIP=$o;Ii.REMOVE=le;async function it(e,t,i,r){let n=await Ho(e,t,i,r);if(D.isNode(n)||D.isPair(n))return Do(e,r,n),it(e,n,i,r);if(typeof n!="symbol"){if(D.isCollection(t)){r=Object.freeze(r.concat(t));for(let a=0;a<t.items.length;++a){let o=await it(a,t.items[a],i,r);if(typeof o=="number")a=o-1;else{if(o===V)return V;o===le&&(t.items.splice(a,1),a-=1)}}}else if(D.isPair(t)){r=Object.freeze(r.concat(t));let a=await it("key",t.key,i,r);if(a===V)return V;a===le&&(t.key=null);let o=await it("value",t.value,i,r);if(o===V)return V;o===le&&(t.value=null)}}return n}function Oo(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Ho(e,t,i,r){if(typeof i=="function")return i(e,t,r);if(D.isMap(t))return i.Map?.(e,t,r);if(D.isSeq(t))return i.Seq?.(e,t,r);if(D.isPair(t))return i.Pair?.(e,t,r);if(D.isScalar(t))return i.Scalar?.(e,t,r);if(D.isAlias(t))return i.Alias?.(e,t,r)}function Do(e,t,i){let r=t[t.length-1];if(D.isCollection(r))r.items[e]=i;else if(D.isPair(r))e==="key"?r.key=i:r.value=i;else if(D.isDocument(r))r.contents=i;else{let n=D.isAlias(r)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}un.visit=Ti;un.visitAsync=Ii});var dn=g(Lo=>{"use strict";var Bo=P(),dd=Pt(),fd={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},hd=e=>e.replace(/[!,[\]{}]/g,t=>fd[t]),Rt=class e{constructor(t,i){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,i)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,i){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let r=t.trim().split(/[ \t]+/),n=r.shift();switch(n){case"%TAG":{if(r.length!==2&&(i(0,"%TAG directive should contain exactly two parts"),r.length<2))return!1;let[a,o]=r;return this.tags[a]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,r.length!==1)return i(0,"%YAML directive should contain exactly one part"),!1;let[a]=r;if(a==="1.1"||a==="1.2")return this.yaml.version=a,!0;{let o=/^\d+\.\d+$/.test(a);return i(6,`Unsupported YAML version ${a}`,o),!1}}default:return i(0,`Unknown directive ${n}`,!0),!1}}tagName(t,i){if(t==="!")return"!";if(t[0]!=="!")return i(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(i(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&i("Verbatim tags must end with a >"),o)}let[,r,n]=t.match(/^(.*!)([^!]*)$/s);n||i(`The ${t} tag has no suffix`);let a=this.tags[r];if(a)try{return a+decodeURIComponent(n)}catch(o){return i(String(o)),null}return r==="!"?t:(i(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[i,r]of Object.entries(this.tags))if(t.startsWith(r))return i+hd(t.substring(r.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let i=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],r=Object.entries(this.tags),n;if(t&&r.length>0&&Bo.isNode(t.contents)){let a={};dd.visit(t.contents,(o,s)=>{Bo.isNode(s)&&s.tag&&(a[s.tag]=!0)}),n=Object.keys(a)}else n=[];for(let[a,o]of r)a==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(s=>s.startsWith(o)))&&i.push(`%TAG ${a} ${o}`);return i.join(`
|
|
5
|
+
`)}};Rt.defaultYaml={explicit:!1,version:"1.2"};Rt.defaultTags={"!!":"tag:yaml.org,2002:"};Lo.Directives=Rt});var ji=g(xt=>{"use strict";var Mo=P(),pd=Pt();function md(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let i=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(i)}return!0}function Fo(e){let t=new Set;return pd.visit(e,{Value(i,r){r.anchor&&t.add(r.anchor)}}),t}function qo(e,t){for(let i=1;;++i){let r=`${e}${i}`;if(!t.has(r))return r}}function vd(e,t){let i=[],r=new Map,n=null;return{onAnchor:a=>{i.push(a),n??(n=Fo(e));let o=qo(t,n);return n.add(o),o},setAnchors:()=>{for(let a of i){let o=r.get(a);if(typeof o=="object"&&o.anchor&&(Mo.isScalar(o.node)||Mo.isCollection(o.node)))o.node.anchor=o.anchor;else{let s=new Error("Failed to resolve repeated object (this should not happen)");throw s.source=a,s}}},sourceObjects:r}}xt.anchorIsValid=md;xt.anchorNames=Fo;xt.createNodeAnchors=vd;xt.findNewAnchor=qo});var fn=g(Vo=>{"use strict";function Ct(e,t,i,r){if(r&&typeof r=="object")if(Array.isArray(r))for(let n=0,a=r.length;n<a;++n){let o=r[n],s=Ct(e,r,String(n),o);s===void 0?delete r[n]:s!==o&&(r[n]=s)}else if(r instanceof Map)for(let n of Array.from(r.keys())){let a=r.get(n),o=Ct(e,r,n,a);o===void 0?r.delete(n):o!==a&&r.set(n,o)}else if(r instanceof Set)for(let n of Array.from(r)){let a=Ct(e,r,n,n);a===void 0?r.delete(n):a!==n&&(r.delete(n),r.add(a))}else for(let[n,a]of Object.entries(r)){let o=Ct(e,r,n,a);o===void 0?delete r[n]:o!==a&&(r[n]=o)}return e.call(t,i,r)}Vo.applyReviver=Ct});var ke=g(zo=>{"use strict";var gd=P();function Wo(e,t,i){if(Array.isArray(e))return e.map((r,n)=>Wo(r,String(n),i));if(e&&typeof e.toJSON=="function"){if(!i||!gd.hasAnchor(e))return e.toJSON(t,i);let r={aliasCount:0,count:1,res:void 0};i.anchors.set(e,r),i.onCreate=a=>{r.res=a,delete i.onCreate};let n=e.toJSON(t,i);return i.onCreate&&i.onCreate(n),n}return typeof e=="bigint"&&!i?.keep?Number(e):e}zo.toJS=Wo});var $i=g(Go=>{"use strict";var wd=fn(),Jo=P(),yd=ke(),hn=class{constructor(t){Object.defineProperty(this,Jo.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:i,maxAliasCount:r,onAnchor:n,reviver:a}={}){if(!Jo.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},s=yd.toJS(this,"",o);if(typeof n=="function")for(let{count:c,res:l}of o.anchors.values())n(l,c);return typeof a=="function"?wd.applyReviver(a,{"":s},"",s):s}};Go.NodeBase=hn});var At=g(Uo=>{"use strict";var Nd=ji(),bd=Pt(),rt=P(),kd=$i(),Sd=ke(),pn=class extends kd.NodeBase{constructor(t){super(rt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,i){if(i?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let r;i?.aliasResolveCache?r=i.aliasResolveCache:(r=[],bd.visit(t,{Node:(a,o)=>{(rt.isAlias(o)||rt.hasAnchor(o))&&r.push(o)}}),i&&(i.aliasResolveCache=r));let n;for(let a of r){if(a===this)break;a.anchor===this.source&&(n=a)}return n}toJSON(t,i){if(!i)return{source:this.source};let{anchors:r,doc:n,maxAliasCount:a}=i,o=this.resolve(n,i);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let s=r.get(o);if(s||(Sd.toJS(o,null,i),s=r.get(o)),s?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(a>=0&&(s.count+=1,s.aliasCount===0&&(s.aliasCount=Oi(n,o,r)),s.count*s.aliasCount>a)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return s.res}toString(t,i,r){let n=`*${this.source}`;if(t){if(Nd.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let a=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(a)}if(t.implicitKey)return`${n} `}return n}};function Oi(e,t,i){if(rt.isAlias(t)){let r=t.resolve(e),n=i&&r&&i.get(r);return n?n.count*n.aliasCount:0}else if(rt.isCollection(t)){let r=0;for(let n of t.items){let a=Oi(e,n,i);a>r&&(r=a)}return r}else if(rt.isPair(t)){let r=Oi(e,t.key,i),n=Oi(e,t.value,i);return Math.max(r,n)}return 1}Uo.Alias=pn});var j=g(mn=>{"use strict";var Ed=P(),Pd=$i(),Rd=ke(),xd=e=>!e||typeof e!="function"&&typeof e!="object",Se=class extends Pd.NodeBase{constructor(t){super(Ed.SCALAR),this.value=t}toJSON(t,i){return i?.keep?this.value:Rd.toJS(this.value,t,i)}toString(){return String(this.value)}};Se.BLOCK_FOLDED="BLOCK_FOLDED";Se.BLOCK_LITERAL="BLOCK_LITERAL";Se.PLAIN="PLAIN";Se.QUOTE_DOUBLE="QUOTE_DOUBLE";Se.QUOTE_SINGLE="QUOTE_SINGLE";mn.Scalar=Se;mn.isScalarValue=xd});var _t=g(Yo=>{"use strict";var Cd=At(),qe=P(),Ko=j(),Ad="tag:yaml.org,2002:";function _d(e,t,i){if(t){let r=i.filter(a=>a.tag===t),n=r.find(a=>!a.format)??r[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return i.find(r=>r.identify?.(e)&&!r.format)}function Td(e,t,i){if(qe.isDocument(e)&&(e=e.contents),qe.isNode(e))return e;if(qe.isPair(e)){let d=i.schema[qe.MAP].createNode?.(i.schema,null,i);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:n,onTagObj:a,schema:o,sourceObjects:s}=i,c;if(r&&e&&typeof e=="object"){if(c=s.get(e),c)return c.anchor??(c.anchor=n(e)),new Cd.Alias(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith("!!")&&(t=Ad+t.slice(2));let l=_d(e,t,o.tags);if(!l){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new Ko.Scalar(e);return c&&(c.node=d),d}l=e instanceof Map?o[qe.MAP]:Symbol.iterator in Object(e)?o[qe.SEQ]:o[qe.MAP]}a&&(a(l),delete i.onTagObj);let u=l?.createNode?l.createNode(i.schema,e,i):typeof l?.nodeClass?.from=="function"?l.nodeClass.from(i.schema,e,i):new Ko.Scalar(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}Yo.createNode=Td});var Di=g(Hi=>{"use strict";var Id=_t(),ue=P(),jd=$i();function vn(e,t,i){let r=i;for(let n=t.length-1;n>=0;--n){let a=t[n];if(typeof a=="number"&&Number.isInteger(a)&&a>=0){let o=[];o[a]=r,r=o}else r=new Map([[a,r]])}return Id.createNode(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var Xo=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,gn=class extends jd.NodeBase{constructor(t,i){super(t),Object.defineProperty(this,"schema",{value:i,configurable:!0,enumerable:!1,writable:!0})}clone(t){let i=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(i.schema=t),i.items=i.items.map(r=>ue.isNode(r)||ue.isPair(r)?r.clone(t):r),this.range&&(i.range=this.range.slice()),i}addIn(t,i){if(Xo(t))this.add(i);else{let[r,...n]=t,a=this.get(r,!0);if(ue.isCollection(a))a.addIn(n,i);else if(a===void 0&&this.schema)this.set(r,vn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}deleteIn(t){let[i,...r]=t;if(r.length===0)return this.delete(i);let n=this.get(i,!0);if(ue.isCollection(n))return n.deleteIn(r);throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}getIn(t,i){let[r,...n]=t,a=this.get(r,!0);return n.length===0?!i&&ue.isScalar(a)?a.value:a:ue.isCollection(a)?a.getIn(n,i):void 0}hasAllNullValues(t){return this.items.every(i=>{if(!ue.isPair(i))return!1;let r=i.value;return r==null||t&&ue.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(t){let[i,...r]=t;if(r.length===0)return this.has(i);let n=this.get(i,!0);return ue.isCollection(n)?n.hasIn(r):!1}setIn(t,i){let[r,...n]=t;if(n.length===0)this.set(r,i);else{let a=this.get(r,!0);if(ue.isCollection(a))a.setIn(n,i);else if(a===void 0&&this.schema)this.set(r,vn(this.schema,n,i));else throw new Error(`Expected YAML collection at ${r}. Remaining path: ${n}`)}}};Hi.Collection=gn;Hi.collectionFromPath=vn;Hi.isEmptyPath=Xo});var Tt=g(Bi=>{"use strict";var $d=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function wn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Od=(e,t,i)=>e.endsWith(`
|
|
6
|
+
`)?wn(i,t):i.includes(`
|
|
7
7
|
`)?`
|
|
8
|
-
`+
|
|
9
|
-
`)i===
|
|
8
|
+
`+wn(i,t):(e.endsWith(" ")?"":" ")+i;Bi.indentComment=wn;Bi.lineComment=Od;Bi.stringifyComment=$d});var Zo=g(It=>{"use strict";var Hd="flow",yn="block",Li="quoted";function Dd(e,t,i="flow",{indentAtStart:r,lineWidth:n=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!n||n<0)return e;n<a&&(a=0);let c=Math.max(1+a,1+n-t.length);if(e.length<=c)return e;let l=[],u={},d=n-t.length;typeof r=="number"&&(r>n-Math.max(2,a)?l.push(0):d=n-r);let f,p,v=!1,h=-1,m=-1,w=-1;i===yn&&(h=Qo(e,h,t.length),h!==-1&&(d=h+c));for(let b;b=e[h+=1];){if(i===Li&&b==="\\"){switch(m=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}w=h}if(b===`
|
|
9
|
+
`)i===yn&&(h=Qo(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(b===" "&&p&&p!==" "&&p!==`
|
|
10
10
|
`&&p!==" "){let k=e[h+1];k&&k!==" "&&k!==`
|
|
11
|
-
`&&k!==" "&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(i===
|
|
12
|
-
${t}${e.slice(0,S)}`:(i===
|
|
13
|
-
${t}${e.slice(k+1,S)}`)}return y}function
|
|
14
|
-
`);r=t,n=t+1,a=e[n]}return r}
|
|
15
|
-
`){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function
|
|
11
|
+
`&&k!==" "&&(f=h)}if(h>=d)if(f)l.push(f),d=f+c,f=void 0;else if(i===Li){for(;p===" "||p===" ";)p=b,b=e[h+=1],v=!0;let k=h>w+1?h-2:m-1;if(u[k])return e;l.push(k),u[k]=!0,d=k+c,f=void 0}else v=!0}p=b}if(v&&s&&s(),l.length===0)return e;o&&o();let y=e.slice(0,l[0]);for(let b=0;b<l.length;++b){let k=l[b],S=l[b+1]||e.length;k===0?y=`
|
|
12
|
+
${t}${e.slice(0,S)}`:(i===Li&&u[k]&&(y+=`${e[k]}\\`),y+=`
|
|
13
|
+
${t}${e.slice(k+1,S)}`)}return y}function Qo(e,t,i){let r=t,n=t+1,a=e[n];for(;a===" "||a===" ";)if(t<n+i)a=e[++t];else{do a=e[++t];while(a&&a!==`
|
|
14
|
+
`);r=t,n=t+1,a=e[n]}return r}It.FOLD_BLOCK=yn;It.FOLD_FLOW=Hd;It.FOLD_QUOTED=Li;It.foldFlowLines=Dd});var $t=g(es=>{"use strict";var te=j(),Ee=Zo(),Fi=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),qi=e=>/^(%|---|\.\.\.)/m.test(e);function Bd(e,t,i){if(!t||t<0)return!1;let r=t-i,n=e.length;if(n<=r)return!1;for(let a=0,o=0;a<n;++a)if(e[a]===`
|
|
15
|
+
`){if(a-o>r)return!0;if(o=a+1,n-o<=r)return!1}return!0}function jt(e,t){let i=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return i;let{implicitKey:r}=t,n=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(qi(e)?" ":""),o="",s=0;for(let c=0,l=i[c];l;l=i[++c])if(l===" "&&i[c+1]==="\\"&&i[c+2]==="n"&&(o+=i.slice(s,c)+"\\ ",c+=1,s=c,l="\\"),l==="\\")switch(i[c+1]){case"u":{o+=i.slice(s,c);let u=i.substr(c+2,4);switch(u){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:u.substr(0,2)==="00"?o+="\\x"+u.substr(2):o+=i.substr(c,6)}c+=5,s=c+1}break;case"n":if(r||i[c+2]==='"'||i.length<n)c+=1;else{for(o+=i.slice(s,c)+`
|
|
16
16
|
|
|
17
17
|
`;i[c+2]==="\\"&&i[c+3]==="n"&&i[c+4]!=='"';)o+=`
|
|
18
|
-
`,c+=2;o+=a,i[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+i.slice(s):i,r?o:
|
|
19
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
20
|
-
${i}`)+"'";return t.implicitKey?r:
|
|
18
|
+
`,c+=2;o+=a,i[c+2]===" "&&(o+="\\"),c+=1,s=c+1}break;default:c+=1}return o=s?o+i.slice(s):i,r?o:Ee.foldFlowLines(o,a,Ee.FOLD_QUOTED,Fi(t,!1))}function Nn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
19
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return jt(e,t);let i=t.indent||(qi(e)?" ":""),r="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
20
|
+
${i}`)+"'";return t.implicitKey?r:Ee.foldFlowLines(r,i,Ee.FOLD_FLOW,Fi(t,!1))}function nt(e,t){let{singleQuote:i}=t.options,r;if(i===!1)r=jt;else{let n=e.includes('"'),a=e.includes("'");n&&!a?r=Nn:a&&!n?r=jt:r=i?Nn:jt}return r(e,t)}var bn;try{bn=new RegExp(`(^|(?<!
|
|
21
21
|
))
|
|
22
22
|
+(?!
|
|
23
|
-
|$)`,"g")}catch{
|
|
23
|
+
|$)`,"g")}catch{bn=/\n+(?!\n|$)/g}function Mi({comment:e,type:t,value:i},r,n,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(i))return nt(i,r);let l=r.indent||(r.forceBlockIndent||qi(i)?" ":""),u=o==="literal"?!0:o==="folded"||t===te.Scalar.BLOCK_FOLDED?!1:t===te.Scalar.BLOCK_LITERAL?!0:!Bd(i,c,l.length);if(!i)return u?`|
|
|
24
24
|
`:`>
|
|
25
25
|
`;let d,f;for(f=i.length;f>0;--f){let S=i[f-1];if(S!==`
|
|
26
26
|
`&&S!==" "&&S!==" ")break}let p=i.substring(f),v=p.indexOf(`
|
|
27
27
|
`);v===-1?d="-":i===p||v!==p.length-1?(d="+",a&&a()):d="",p&&(i=i.slice(0,-p.length),p[p.length-1]===`
|
|
28
|
-
`&&(p=p.slice(0,-1)),p=p.replace(
|
|
28
|
+
`&&(p=p.slice(0,-1)),p=p.replace(bn,`$&${l}`));let h=!1,m,w=-1;for(m=0;m<i.length;++m){let S=i[m];if(S===" ")h=!0;else if(S===`
|
|
29
29
|
`)w=m;else break}let y=i.substring(0,w<m?w+1:m);y&&(i=i.substring(y.length),y=y.replace(/\n+/g,`$&${l}`));let k=(h?l?"2":"1":"")+d;if(e&&(k+=" "+s(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!u){let S=i.replace(/\n+/g,`
|
|
30
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,A=
|
|
30
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${l}`),E=!1,A=Fi(r,!0);o!=="folded"&&t!==te.Scalar.BLOCK_FOLDED&&(A.onOverflow=()=>{E=!0});let N=Ee.foldFlowLines(`${y}${S}${p}`,l,Ee.FOLD_BLOCK,A);if(!E)return`>${k}
|
|
31
31
|
${l}${N}`}return i=i.replace(/\n+/g,`$&${l}`),`|${k}
|
|
32
|
-
${l}${y}${i}${p}`}function
|
|
33
|
-
`)||u&&/[[\]{},]/.test(a))return
|
|
34
|
-
`)?
|
|
35
|
-
`))return
|
|
36
|
-
${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:v}=t.doc.schema;if(v.some(f)||p?.some(f))return
|
|
37
|
-
${t.indent}${s}`:s}
|
|
38
|
-
${s}:`):(m=`${m}:`,f&&(m+=
|
|
32
|
+
${l}${y}${i}${p}`}function Ld(e,t,i,r){let{type:n,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
|
|
33
|
+
`)||u&&/[[\]{},]/.test(a))return nt(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
|
|
34
|
+
`)?nt(a,t):Mi(e,t,i,r);if(!s&&!u&&n!==te.Scalar.PLAIN&&a.includes(`
|
|
35
|
+
`))return Mi(e,t,i,r);if(qi(a)){if(c==="")return t.forceBlockIndent=!0,Mi(e,t,i,r);if(s&&c===l)return nt(a,t)}let d=a.replace(/\n+/g,`$&
|
|
36
|
+
${c}`);if(o){let f=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:p,tags:v}=t.doc.schema;if(v.some(f)||p?.some(f))return nt(a,t)}return s?d:Ee.foldFlowLines(d,c,Ee.FOLD_FLOW,Fi(t,!1))}function Md(e,t,i,r){let{implicitKey:n,inFlow:a}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==te.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=te.Scalar.QUOTE_DOUBLE);let c=u=>{switch(u){case te.Scalar.BLOCK_FOLDED:case te.Scalar.BLOCK_LITERAL:return n||a?nt(o.value,t):Mi(o,t,i,r);case te.Scalar.QUOTE_DOUBLE:return jt(o.value,t);case te.Scalar.QUOTE_SINGLE:return Nn(o.value,t);case te.Scalar.PLAIN:return Ld(o,t,i,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:u,defaultStringType:d}=t.options,f=n&&u||d;if(l=c(f),l===null)throw new Error(`Unsupported default string type ${f}`)}return l}es.stringifyString=Md});var Ot=g(kn=>{"use strict";var Fd=ji(),Pe=P(),qd=Tt(),Vd=$t();function Wd(e,t){let i=Object.assign({blockQuote:!0,commentString:qd.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(i.collectionStyle){case"block":r=!1;break;case"flow":r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:i.flowCollectionPadding?" ":"",indent:"",indentStep:typeof i.indent=="number"?" ".repeat(i.indent):" ",inFlow:r,options:i}}function zd(e,t){if(t.tag){let n=e.filter(a=>a.tag===t.tag);if(n.length>0)return n.find(a=>a.format===t.format)??n[0]}let i,r;if(Pe.isScalar(t)){r=t.value;let n=e.filter(a=>a.identify?.(r));if(n.length>1){let a=n.filter(o=>o.test);a.length>0&&(n=a)}i=n.find(a=>a.format===t.format)??n.find(a=>!a.format)}else r=t,i=e.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 Jd(e,t,{anchors:i,doc:r}){if(!r.directives)return"";let n=[],a=(Pe.isScalar(e)||Pe.isCollection(e))&&e.anchor;a&&Fd.anchorIsValid(a)&&(i.add(a),n.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(r.directives.tagString(o)),n.join(" ")}function Gd(e,t,i,r){if(Pe.isPair(e))return e.toString(t,i,r);if(Pe.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,a=Pe.isNode(e)?e:t.doc.createNode(e,{onTagObj:c=>n=c});n??(n=zd(t.doc.schema.tags,a));let o=Jd(a,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof n.stringify=="function"?n.stringify(a,t,i,r):Pe.isScalar(a)?Vd.stringifyString(a,t,i,r):a.toString(t,i,r);return o?Pe.isScalar(a)||s[0]==="{"||s[0]==="["?`${o} ${s}`:`${o}
|
|
37
|
+
${t.indent}${s}`:s}kn.createStringifyContext=Wd;kn.stringify=Gd});var ns=g(rs=>{"use strict";var we=P(),ts=j(),is=Ot(),Ht=Tt();function Ud({key:e,value:t},i,r,n){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=i,f=we.isNode(e)&&e.comment||null;if(d){if(f)throw new Error("With simple keys, key nodes cannot have comments");if(we.isCollection(e)||!we.isNode(e)&&typeof e=="object"){let A="With simple keys, collection cannot be used as a key value";throw new Error(A)}}let p=!d&&(!e||f&&t==null&&!i.inFlow||we.isCollection(e)||(we.isScalar(e)?e.type===ts.Scalar.BLOCK_FOLDED||e.type===ts.Scalar.BLOCK_LITERAL:typeof e=="object"));i=Object.assign({},i,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let v=!1,h=!1,m=is.stringify(e,i,()=>v=!0,()=>h=!0);if(!p&&!i.inFlow&&m.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(i.inFlow){if(a||t==null)return v&&r&&r(),m===""?"?":p?`? ${m}`:m}else if(a&&!d||t==null&&p)return m=`? ${m}`,f&&!v?m+=Ht.lineComment(m,i.indent,l(f)):h&&n&&n(),m;v&&(f=null),p?(f&&(m+=Ht.lineComment(m,i.indent,l(f))),m=`? ${m}
|
|
38
|
+
${s}:`):(m=`${m}:`,f&&(m+=Ht.lineComment(m,i.indent,l(f))));let w,y,b;we.isNode(t)?(w=!!t.spaceBefore,y=t.commentBefore,b=t.comment):(w=!1,y=null,b=null,t&&typeof t=="object"&&(t=o.createNode(t))),i.implicitKey=!1,!p&&!f&&we.isScalar(t)&&(i.indentAtStart=m.length+1),h=!1,!u&&c.length>=2&&!i.inFlow&&!p&&we.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(i.indent=i.indent.substring(2));let k=!1,S=is.stringify(t,i,()=>k=!0,()=>h=!0),E=" ";if(f||w||y){if(E=w?`
|
|
39
39
|
`:"",y){let A=l(y);E+=`
|
|
40
|
-
${
|
|
40
|
+
${Ht.indentComment(A,i.indent)}`}S===""&&!i.inFlow?E===`
|
|
41
41
|
`&&b&&(E=`
|
|
42
42
|
|
|
43
43
|
`):E+=`
|
|
44
44
|
${i.indent}`}else if(!p&&we.isCollection(t)){let A=S[0],N=S.indexOf(`
|
|
45
|
-
`),O=N!==-1,
|
|
45
|
+
`),O=N!==-1,be=i.inFlow??t.flow??t.items.length===0;if(O||!be){let et=!1;if(O&&(A==="&"||A==="!")){let H=S.indexOf(" ");A==="&"&&H!==-1&&H<N&&S[H+1]==="!"&&(H=S.indexOf(" ",H+1)),(H===-1||N<H)&&(et=!0)}et||(E=`
|
|
46
46
|
${i.indent}`)}}else(S===""||S[0]===`
|
|
47
|
-
`)&&(E="");return m+=E+S,i.inFlow?k&&r&&r():b&&!k?m+=
|
|
47
|
+
`)&&(E="");return m+=E+S,i.inFlow?k&&r&&r():b&&!k?m+=Ht.lineComment(m,i.indent,l(b)):h&&n&&n(),m}rs.stringifyPair=Ud});var En=g(Sn=>{"use strict";var as=Ci("process");function Kd(e,...t){e==="debug"&&console.log(...t)}function Yd(e,t){(e==="debug"||e==="warn")&&(typeof as.emitWarning=="function"?as.emitWarning(t):console.warn(t))}Sn.debug=Kd;Sn.warn=Yd});var Gi=g(Ji=>{"use strict";var zi=P(),os=j(),Vi="<<",Wi={identify:e=>e===Vi||typeof e=="symbol"&&e.description===Vi,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new os.Scalar(Symbol(Vi)),{addToJSMap:ss}),stringify:()=>Vi},Xd=(e,t)=>(Wi.identify(t)||zi.isScalar(t)&&(!t.type||t.type===os.Scalar.PLAIN)&&Wi.identify(t.value))&&e?.doc.schema.tags.some(i=>i.tag===Wi.tag&&i.default);function ss(e,t,i){let r=cs(e,i);if(zi.isSeq(r))for(let n of r.items)Pn(e,t,n);else if(Array.isArray(r))for(let n of r)Pn(e,t,n);else Pn(e,t,r)}function Pn(e,t,i){let r=cs(e,i);if(!zi.isMap(r))throw new Error("Merge sources must be maps or map aliases");let n=r.toJSON(null,e,Map);for(let[a,o]of n)t instanceof Map?t.has(a)||t.set(a,o):t instanceof Set?t.add(a):Object.prototype.hasOwnProperty.call(t,a)||Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function cs(e,t){return e&&zi.isAlias(t)?t.resolve(e.doc,e):t}Ji.addMergeToJSMap=ss;Ji.isMergeKey=Xd;Ji.merge=Wi});var xn=g(ds=>{"use strict";var Qd=En(),ls=Gi(),Zd=Ot(),us=P(),Rn=ke();function ef(e,t,{key:i,value:r}){if(us.isNode(i)&&i.addToJSMap)i.addToJSMap(e,t,r);else if(ls.isMergeKey(e,i))ls.addMergeToJSMap(e,t,r);else{let n=Rn.toJS(i,"",e);if(t instanceof Map)t.set(n,Rn.toJS(r,n,e));else if(t instanceof Set)t.add(n);else{let a=tf(i,n,e),o=Rn.toJS(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function tf(e,t,i){if(t===null)return"";if(typeof t!="object")return String(t);if(us.isNode(e)&&i?.doc){let r=Zd.createStringifyContext(i.doc,{});r.anchors=new Set;for(let a of i.anchors.keys())r.anchors.add(a.anchor);r.inFlow=!0,r.inStringifyKey=!0;let n=e.toString(r);if(!i.mapKeyWarned){let a=JSON.stringify(n);a.length>40&&(a=a.substring(0,36)+'..."'),Qd.warn(i.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${a}. Set mapAsMap: true to use object keys.`),i.mapKeyWarned=!0}return n}return JSON.stringify(t)}ds.addPairToJSMap=ef});var Re=g(Cn=>{"use strict";var fs=_t(),rf=ns(),nf=xn(),Ui=P();function af(e,t,i){let r=fs.createNode(e,void 0,i),n=fs.createNode(t,void 0,i);return new Ki(r,n)}var Ki=class e{constructor(t,i=null){Object.defineProperty(this,Ui.NODE_TYPE,{value:Ui.PAIR}),this.key=t,this.value=i}clone(t){let{key:i,value:r}=this;return Ui.isNode(i)&&(i=i.clone(t)),Ui.isNode(r)&&(r=r.clone(t)),new e(i,r)}toJSON(t,i){let r=i?.mapAsMap?new Map:{};return nf.addPairToJSMap(i,r,this)}toString(t,i,r){return t?.doc?rf.stringifyPair(this,t,i,r):JSON.stringify(this)}};Cn.Pair=Ki;Cn.createPair=af});var An=g(ps=>{"use strict";var Ve=P(),hs=Ot(),Yi=Tt();function of(e,t,i){return(t.inFlow??e.flow?cf:sf)(e,t,i)}function sf({comment:e,items:t},i,{blockItemPrefix:r,flowChars:n,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=i,u=Object.assign({},i,{indent:a,type:null}),d=!1,f=[];for(let v=0;v<t.length;++v){let h=t[v],m=null;if(Ve.isNode(h))!d&&h.spaceBefore&&f.push(""),Xi(i,f,h.commentBefore,d),h.comment&&(m=h.comment);else if(Ve.isPair(h)){let y=Ve.isNode(h.key)?h.key:null;y&&(!d&&y.spaceBefore&&f.push(""),Xi(i,f,y.commentBefore,d))}d=!1;let w=hs.stringify(h,u,()=>m=null,()=>d=!0);m&&(w+=Yi.lineComment(w,a,l(m))),d&&m&&(d=!1),f.push(r+w)}let p;if(f.length===0)p=n.start+n.end;else{p=f[0];for(let v=1;v<f.length;++v){let h=f[v];p+=h?`
|
|
48
48
|
${c}${h}`:`
|
|
49
49
|
`}}return e?(p+=`
|
|
50
|
-
`+
|
|
51
|
-
`)),v<e.length-1?w+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(l||(l=d.reduce((y,b)=>y+b.length+2,2)+(w.length+2)>t.options.lineWidth)),l&&(w+=",")),m&&(w+=
|
|
50
|
+
`+Yi.indentComment(l(e),c),s&&s()):d&&o&&o(),p}function cf({items:e},t,{flowChars:i,itemIndent:r}){let{indent:n,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let v=0;v<e.length;++v){let h=e[v],m=null;if(Ve.isNode(h))h.spaceBefore&&d.push(""),Xi(t,d,h.commentBefore,!1),h.comment&&(m=h.comment);else if(Ve.isPair(h)){let y=Ve.isNode(h.key)?h.key:null;y&&(y.spaceBefore&&d.push(""),Xi(t,d,y.commentBefore,!1),y.comment&&(l=!0));let b=Ve.isNode(h.value)?h.value:null;b?(b.comment&&(m=b.comment),b.commentBefore&&(l=!0)):h.value==null&&y?.comment&&(m=y.comment)}m&&(l=!0);let w=hs.stringify(h,c,()=>m=null);l||(l=d.length>u||w.includes(`
|
|
51
|
+
`)),v<e.length-1?w+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(l||(l=d.reduce((y,b)=>y+b.length+2,2)+(w.length+2)>t.options.lineWidth)),l&&(w+=",")),m&&(w+=Yi.lineComment(w,r,s(m))),d.push(w),u=d.length}let{start:f,end:p}=i;if(d.length===0)return f+p;if(!l){let v=d.reduce((h,m)=>h+m.length+2,2);l=t.options.lineWidth>0&&v>t.options.lineWidth}if(l){let v=f;for(let h of d)v+=h?`
|
|
52
52
|
${a}${n}${h}`:`
|
|
53
53
|
`;return`${v}
|
|
54
|
-
${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function
|
|
55
|
-
`:" ")}return
|
|
54
|
+
${n}${p}`}else return`${f}${o}${d.join(" ")}${o}${p}`}function Xi({indent:e,options:{commentString:t}},i,r,n){if(r&&n&&(r=r.replace(/^\n+/,"")),r){let a=Yi.indentComment(t(r),e);i.push(a.trimStart())}}ps.stringifyCollection=of});var Ce=g(Tn=>{"use strict";var lf=An(),uf=xn(),df=Di(),xe=P(),Qi=Re(),ff=j();function Dt(e,t){let i=xe.isScalar(t)?t.value:t;for(let r of e)if(xe.isPair(r)&&(r.key===t||r.key===i||xe.isScalar(r.key)&&r.key.value===i))return r}var _n=class extends df.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(xe.MAP,t),this.items=[]}static from(t,i,r){let{keepUndefined:n,replacer:a}=r,o=new this(t),s=(c,l)=>{if(typeof a=="function")l=a.call(i,c,l);else if(Array.isArray(a)&&!a.includes(c))return;(l!==void 0||n)&&o.items.push(Qi.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 t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,i){let r;xe.isPair(t)?r=t:!t||typeof t!="object"||!("key"in t)?r=new Qi.Pair(t,t?.value):r=new Qi.Pair(t.key,t.value);let n=Dt(this.items,r.key),a=this.schema?.sortMapEntries;if(n){if(!i)throw new Error(`Key ${r.key} already set`);xe.isScalar(n.value)&&ff.isScalarValue(r.value)?n.value.value=r.value:n.value=r.value}else if(a){let o=this.items.findIndex(s=>a(r,s)<0);o===-1?this.items.push(r):this.items.splice(o,0,r)}else this.items.push(r)}delete(t){let i=Dt(this.items,t);return i?this.items.splice(this.items.indexOf(i),1).length>0:!1}get(t,i){let n=Dt(this.items,t)?.value;return(!i&&xe.isScalar(n)?n.value:n)??void 0}has(t){return!!Dt(this.items,t)}set(t,i){this.add(new Qi.Pair(t,i),!0)}toJSON(t,i,r){let n=r?new r:i?.mapAsMap?new Map:{};i?.onCreate&&i.onCreate(n);for(let a of this.items)uf.addPairToJSMap(i,n,a);return n}toString(t,i,r){if(!t)return JSON.stringify(this);for(let n of this.items)if(!xe.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),lf.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:r,onComment:i})}};Tn.YAMLMap=_n;Tn.findPair=Dt});var at=g(vs=>{"use strict";var hf=P(),ms=Ce(),pf={collection:"map",default:!0,nodeClass:ms.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return hf.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,i)=>ms.YAMLMap.from(e,t,i)};vs.map=pf});var Ae=g(gs=>{"use strict";var mf=_t(),vf=An(),gf=Di(),er=P(),wf=j(),yf=ke(),In=class extends gf.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(er.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let i=Zi(t);return typeof i!="number"?!1:this.items.splice(i,1).length>0}get(t,i){let r=Zi(t);if(typeof r!="number")return;let n=this.items[r];return!i&&er.isScalar(n)?n.value:n}has(t){let i=Zi(t);return typeof i=="number"&&i<this.items.length}set(t,i){let r=Zi(t);if(typeof r!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[r];er.isScalar(n)&&wf.isScalarValue(i)?n.value=i:this.items[r]=i}toJSON(t,i){let r=[];i?.onCreate&&i.onCreate(r);let n=0;for(let a of this.items)r.push(yf.toJS(a,String(n++),i));return r}toString(t,i,r){return t?vf.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:r,onComment:i}):JSON.stringify(this)}static from(t,i,r){let{replacer:n}=r,a=new this(t);if(i&&Symbol.iterator in Object(i)){let o=0;for(let s of i){if(typeof n=="function"){let c=i instanceof Set?s:String(o++);s=n.call(i,c,s)}a.items.push(mf.createNode(s,void 0,r))}}return a}};function Zi(e){let t=er.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}gs.YAMLSeq=In});var ot=g(ys=>{"use strict";var Nf=P(),ws=Ae(),bf={collection:"seq",default:!0,nodeClass:ws.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Nf.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,i)=>ws.YAMLSeq.from(e,t,i)};ys.seq=bf});var Bt=g(Ns=>{"use strict";var kf=$t(),Sf={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,i,r){return t=Object.assign({actualString:!0},t),kf.stringifyString(e,t,i,r)}};Ns.string=Sf});var tr=g(Ss=>{"use strict";var bs=j(),ks={identify:e=>e==null,createNode:()=>new bs.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new bs.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&ks.test.test(e)?e:t.options.nullStr};Ss.nullTag=ks});var jn=g(Ps=>{"use strict";var Ef=j(),Es={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Ef.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},i){if(e&&Es.test.test(e)){let r=e[0]==="t"||e[0]==="T";if(t===r)return e}return t?i.options.trueStr:i.options.falseStr}};Ps.boolTag=Es});var st=g(Rs=>{"use strict";function Pf({format:e,minFractionDigits:t,tag:i,value:r}){if(typeof r=="bigint")return String(r);let n=typeof r=="number"?r:Number(r);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let a=Object.is(r,-0)?"-0":JSON.stringify(r);if(!e&&t&&(!i||i==="tag:yaml.org,2002:float")&&/^-?\d/.test(a)&&!a.includes("e")){let o=a.indexOf(".");o<0&&(o=a.length,a+=".");let s=t-(a.length-o-1);for(;s-- >0;)a+="0"}return a}Rs.stringifyNumber=Pf});var On=g(ir=>{"use strict";var Rf=j(),$n=st(),xf={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:$n.stringifyNumber},Cf={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():$n.stringifyNumber(e)}},Af={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Rf.Scalar(parseFloat(e)),i=e.indexOf(".");return i!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-i-1),t},stringify:$n.stringifyNumber};ir.float=Af;ir.floatExp=Cf;ir.floatNaN=xf});var Dn=g(nr=>{"use strict";var xs=st(),rr=e=>typeof e=="bigint"||Number.isInteger(e),Hn=(e,t,i,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),i);function Cs(e,t,i){let{value:r}=e;return rr(r)&&r>=0?i+r.toString(t):xs.stringifyNumber(e)}var _f={identify:e=>rr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,i)=>Hn(e,2,8,i),stringify:e=>Cs(e,8,"0o")},Tf={identify:rr,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,i)=>Hn(e,0,10,i),stringify:xs.stringifyNumber},If={identify:e=>rr(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,i)=>Hn(e,2,16,i),stringify:e=>Cs(e,16,"0x")};nr.int=Tf;nr.intHex=If;nr.intOct=_f});var _s=g(As=>{"use strict";var jf=at(),$f=tr(),Of=ot(),Hf=Bt(),Df=jn(),Bn=On(),Ln=Dn(),Bf=[jf.map,Of.seq,Hf.string,$f.nullTag,Df.boolTag,Ln.intOct,Ln.int,Ln.intHex,Bn.floatNaN,Bn.floatExp,Bn.float];As.schema=Bf});var js=g(Is=>{"use strict";var Lf=j(),Mf=at(),Ff=ot();function Ts(e){return typeof e=="bigint"||Number.isInteger(e)}var ar=({value:e})=>JSON.stringify(e),qf=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:ar},{identify:e=>e==null,createNode:()=>new Lf.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:ar},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:ar},{identify:Ts,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:i})=>i?BigInt(e):parseInt(e,10),stringify:({value:e})=>Ts(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:ar}],Vf={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Wf=[Mf.map,Ff.seq].concat(qf,Vf);Is.schema=Wf});var Fn=g($s=>{"use strict";var Lt=Ci("buffer"),Mn=j(),zf=$t(),Jf={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Lt.Buffer=="function")return Lt.Buffer.from(e,"base64");if(typeof atob=="function"){let i=atob(e.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 t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:i},r,n,a){if(!i)return"";let o=i,s;if(typeof Lt.Buffer=="function")s=o instanceof Lt.Buffer?o.toString("base64"):Lt.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let l=0;l<o.length;++l)c+=String.fromCharCode(o[l]);s=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Mn.Scalar.BLOCK_LITERAL),t!==Mn.Scalar.QUOTE_DOUBLE){let c=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),l=Math.ceil(s.length/c),u=new Array(l);for(let d=0,f=0;d<l;++d,f+=c)u[d]=s.substr(f,c);s=u.join(t===Mn.Scalar.BLOCK_LITERAL?`
|
|
55
|
+
`:" ")}return zf.stringifyString({comment:e,type:t,value:s},r,n,a)}};$s.binary=Jf});var cr=g(sr=>{"use strict";var or=P(),qn=Re(),Gf=j(),Uf=Ae();function Os(e,t){if(or.isSeq(e))for(let i=0;i<e.items.length;++i){let r=e.items[i];if(!or.isPair(r)){if(or.isMap(r)){r.items.length>1&&t("Each pair must have its own sequence indicator");let n=r.items[0]||new qn.Pair(new Gf.Scalar(null));if(r.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${r.commentBefore}
|
|
56
56
|
${n.key.commentBefore}`:r.commentBefore),r.comment){let a=n.value??n.key;a.comment=a.comment?`${r.comment}
|
|
57
|
-
${a.comment}`:r.comment}r=n}e.items[i]=nr.isPair(r)?r:new Fn.Pair(r)}}else t("Expected a sequence for this tag");return e}function Os(e,t,i){let{replacer:r}=i,n=new Jf.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof r=="function"&&(o=r.call(t,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(Fn.createPair(s,c,i))}return n}var Gf={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:$s,createNode:Os};ar.createPairs=Os;ar.pairs=Gf;ar.resolvePairs=$s});var Wn=g(qn=>{"use strict";var Hs=P(),Vn=be(),Lt=xe(),Uf=Ce(),Ds=or(),Ve=class e extends Uf.YAMLSeq{constructor(){super(),this.add=Lt.YAMLMap.prototype.add.bind(this),this.delete=Lt.YAMLMap.prototype.delete.bind(this),this.get=Lt.YAMLMap.prototype.get.bind(this),this.has=Lt.YAMLMap.prototype.has.bind(this),this.set=Lt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,i){if(!i)return super.toJSON(t);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(Hs.isPair(n)?(a=Vn.toJS(n.key,"",i),o=Vn.toJS(n.value,a,i)):a=Vn.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(t,i,r){let n=Ds.createPairs(t,i,r),a=new this;return a.items=n.items,a}};Ve.tag="tag:yaml.org,2002:omap";var Kf={collection:"seq",identify:e=>e instanceof Map,nodeClass:Ve,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let i=Ds.resolvePairs(e,t),r=[];for(let{key:n}of i.items)Hs.isScalar(n)&&(r.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new Ve,i)},createNode:(e,t,i)=>Ve.from(e,t,i)};qn.YAMLOMap=Ve;qn.omap=Kf});var Vs=g(zn=>{"use strict";var Bs=j();function Ls({value:e,source:t},i){return t&&(e?Ms:Fs).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}var Ms={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Bs.Scalar(!0),stringify:Ls},Fs={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Bs.Scalar(!1),stringify:Ls};zn.falseTag=Fs;zn.trueTag=Ms});var qs=g(sr=>{"use strict";var Yf=j(),Jn=at(),Xf={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Jn.stringifyNumber},Qf={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Jn.stringifyNumber(e)}},Zf={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Yf.Scalar(parseFloat(e.replace(/_/g,""))),i=e.indexOf(".");if(i!==-1){let r=e.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(t.minFractionDigits=r.length)}return t},stringify:Jn.stringifyNumber};sr.float=Zf;sr.floatExp=Qf;sr.floatNaN=Xf});var zs=g(Ft=>{"use strict";var Ws=at(),Mt=e=>typeof e=="bigint"||Number.isInteger(e);function cr(e,t,i,{intAsBigInt:r}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),r){switch(i){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,i);return n==="-"?-1*a:a}function Gn(e,t,i){let{value:r}=e;if(Mt(r)){let n=r.toString(t);return r<0?"-"+i+n.substr(1):i+n}return Ws.stringifyNumber(e)}var eh={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,i)=>cr(e,2,2,i),stringify:e=>Gn(e,2,"0b")},th={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,i)=>cr(e,1,8,i),stringify:e=>Gn(e,8,"0")},ih={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,i)=>cr(e,0,10,i),stringify:Ws.stringifyNumber},rh={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,i)=>cr(e,2,16,i),stringify:e=>Gn(e,16,"0x")};Ft.int=ih;Ft.intBin=eh;Ft.intHex=rh;Ft.intOct=th});var Kn=g(Un=>{"use strict";var dr=P(),lr=Pe(),ur=xe(),qe=class e extends ur.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let i;dr.isPair(t)?i=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?i=new lr.Pair(t.key,null):i=new lr.Pair(t,null),ur.findPair(this.items,i.key)||this.items.push(i)}get(t,i){let r=ur.findPair(this.items,t);return!i&&dr.isPair(r)?dr.isScalar(r.key)?r.key.value:r.key:r}set(t,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=ur.findPair(this.items,t);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new lr.Pair(t))}toJSON(t,i){return super.toJSON(t,i,Set)}toString(t,i,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(t,i,r){let{replacer:n}=r,a=new this(t);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(lr.createPair(o,null,r));return a}};qe.tag="tag:yaml.org,2002:set";var nh={collection:"map",identify:e=>e instanceof Set,nodeClass:qe,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,i)=>qe.from(e,t,i),resolve(e,t){if(dr.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new qe,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Un.YAMLSet=qe;Un.set=nh});var Xn=g(fr=>{"use strict";var ah=at();function Yn(e,t){let i=e[0],r=i==="-"||i==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),a=r.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return i==="-"?n(-1)*a:a}function Js(e){let{value:t}=e,i=o=>o;if(typeof t=="bigint")i=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return ah.stringifyNumber(e);let r="";t<0&&(r="-",t*=i(-1));let n=i(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var oh={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:i})=>Yn(e,i),stringify:Js},sh={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Yn(e,!1),stringify:Js},Gs={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Gs.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,a||0,o||0,s||0,c),u=t[8];if(u&&u!=="Z"){let d=Yn(u,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};fr.floatTime=sh;fr.intTime=oh;fr.timestamp=Gs});var Ys=g(Ks=>{"use strict";var ch=rt(),lh=Zi(),uh=nt(),dh=Dt(),fh=Mn(),Us=Vs(),Qn=qs(),hr=zs(),hh=zi(),ph=Wn(),mh=or(),vh=Kn(),Zn=Xn(),gh=[ch.map,uh.seq,dh.string,lh.nullTag,Us.trueTag,Us.falseTag,hr.intBin,hr.intOct,hr.int,hr.intHex,Qn.floatNaN,Qn.floatExp,Qn.float,fh.binary,hh.merge,ph.omap,mh.pairs,vh.set,Zn.intTime,Zn.floatTime,Zn.timestamp];Ks.schema=gh});var oc=g(ia=>{"use strict";var ec=rt(),wh=Zi(),tc=nt(),yh=Dt(),Nh=In(),ea=$n(),ta=Hn(),bh=As(),kh=Is(),ic=Mn(),Vt=zi(),rc=Wn(),nc=or(),Xs=Ys(),ac=Kn(),pr=Xn(),Qs=new Map([["core",bh.schema],["failsafe",[ec.map,tc.seq,yh.string]],["json",kh.schema],["yaml11",Xs.schema],["yaml-1.1",Xs.schema]]),Zs={binary:ic.binary,bool:Nh.boolTag,float:ea.float,floatExp:ea.floatExp,floatNaN:ea.floatNaN,floatTime:pr.floatTime,int:ta.int,intHex:ta.intHex,intOct:ta.intOct,intTime:pr.intTime,map:ec.map,merge:Vt.merge,null:wh.nullTag,omap:rc.omap,pairs:nc.pairs,seq:tc.seq,set:ac.set,timestamp:pr.timestamp},Sh={"tag:yaml.org,2002:binary":ic.binary,"tag:yaml.org,2002:merge":Vt.merge,"tag:yaml.org,2002:omap":rc.omap,"tag:yaml.org,2002:pairs":nc.pairs,"tag:yaml.org,2002:set":ac.set,"tag:yaml.org,2002:timestamp":pr.timestamp};function Eh(e,t,i){let r=Qs.get(t);if(r&&!e)return i&&!r.includes(Vt.merge)?r.concat(Vt.merge):r.slice();let n=r;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(Qs.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return i&&(n=n.concat(Vt.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?Zs[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(Zs).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}ia.coreKnownTags=Sh;ia.getTags=Eh});var aa=g(sc=>{"use strict";var ra=P(),Ph=rt(),Rh=nt(),xh=Dt(),mr=oc(),Ch=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,na=class e{constructor({compat:t,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?mr.getTags(t,"compat"):t?mr.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?mr.coreKnownTags:{},this.tags=mr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,ra.MAP,{value:Ph.map}),Object.defineProperty(this,ra.SCALAR,{value:xh.string}),Object.defineProperty(this,ra.SEQ,{value:Rh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Ch:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};sc.Schema=na});var lc=g(cc=>{"use strict";var Ah=P(),oa=$t(),qt=_t();function _h(e,t){let i=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(i.push(c),r=!0):e.directives.docStart&&(r=!0)}r&&i.push("---");let n=oa.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){i.length!==1&&i.unshift("");let c=a(e.commentBefore);i.unshift(qt.indentComment(c,""))}let o=!1,s=null;if(e.contents){if(Ah.isNode(e.contents)){if(e.contents.spaceBefore&&r&&i.push(""),e.contents.commentBefore){let u=a(e.contents.commentBefore);i.push(qt.indentComment(u,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let c=s?void 0:()=>o=!0,l=oa.stringify(e.contents,n,()=>s=null,c);s&&(l+=qt.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(oa.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=a(e.comment);c.includes(`
|
|
58
|
-
`)?(i.push("..."),i.push(
|
|
57
|
+
${a.comment}`:r.comment}r=n}e.items[i]=or.isPair(r)?r:new qn.Pair(r)}}else t("Expected a sequence for this tag");return e}function Hs(e,t,i){let{replacer:r}=i,n=new Uf.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let a=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof r=="function"&&(o=r.call(t,String(a++),o));let s,c;if(Array.isArray(o))if(o.length===2)s=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let l=Object.keys(o);if(l.length===1)s=l[0],c=o[s];else throw new TypeError(`Expected tuple with one key, not ${l.length} keys`)}else s=o;n.items.push(qn.createPair(s,c,i))}return n}var Kf={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Os,createNode:Hs};sr.createPairs=Hs;sr.pairs=Kf;sr.resolvePairs=Os});var zn=g(Wn=>{"use strict";var Ds=P(),Vn=ke(),Mt=Ce(),Yf=Ae(),Bs=cr(),We=class e extends Yf.YAMLSeq{constructor(){super(),this.add=Mt.YAMLMap.prototype.add.bind(this),this.delete=Mt.YAMLMap.prototype.delete.bind(this),this.get=Mt.YAMLMap.prototype.get.bind(this),this.has=Mt.YAMLMap.prototype.has.bind(this),this.set=Mt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,i){if(!i)return super.toJSON(t);let r=new Map;i?.onCreate&&i.onCreate(r);for(let n of this.items){let a,o;if(Ds.isPair(n)?(a=Vn.toJS(n.key,"",i),o=Vn.toJS(n.value,a,i)):a=Vn.toJS(n,"",i),r.has(a))throw new Error("Ordered maps must not include duplicate keys");r.set(a,o)}return r}static from(t,i,r){let n=Bs.createPairs(t,i,r),a=new this;return a.items=n.items,a}};We.tag="tag:yaml.org,2002:omap";var Xf={collection:"seq",identify:e=>e instanceof Map,nodeClass:We,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let i=Bs.resolvePairs(e,t),r=[];for(let{key:n}of i.items)Ds.isScalar(n)&&(r.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):r.push(n.value));return Object.assign(new We,i)},createNode:(e,t,i)=>We.from(e,t,i)};Wn.YAMLOMap=We;Wn.omap=Xf});var Vs=g(Jn=>{"use strict";var Ls=j();function Ms({value:e,source:t},i){return t&&(e?Fs:qs).test.test(t)?t:e?i.options.trueStr:i.options.falseStr}var Fs={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ls.Scalar(!0),stringify:Ms},qs={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ls.Scalar(!1),stringify:Ms};Jn.falseTag=qs;Jn.trueTag=Fs});var Ws=g(lr=>{"use strict";var Qf=j(),Gn=st(),Zf={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Gn.stringifyNumber},eh={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Gn.stringifyNumber(e)}},th={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Qf.Scalar(parseFloat(e.replace(/_/g,""))),i=e.indexOf(".");if(i!==-1){let r=e.substring(i+1).replace(/_/g,"");r[r.length-1]==="0"&&(t.minFractionDigits=r.length)}return t},stringify:Gn.stringifyNumber};lr.float=th;lr.floatExp=eh;lr.floatNaN=Zf});var Js=g(qt=>{"use strict";var zs=st(),Ft=e=>typeof e=="bigint"||Number.isInteger(e);function ur(e,t,i,{intAsBigInt:r}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),r){switch(i){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let a=parseInt(e,i);return n==="-"?-1*a:a}function Un(e,t,i){let{value:r}=e;if(Ft(r)){let n=r.toString(t);return r<0?"-"+i+n.substr(1):i+n}return zs.stringifyNumber(e)}var ih={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,i)=>ur(e,2,2,i),stringify:e=>Un(e,2,"0b")},rh={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,i)=>ur(e,1,8,i),stringify:e=>Un(e,8,"0")},nh={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,i)=>ur(e,0,10,i),stringify:zs.stringifyNumber},ah={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,i)=>ur(e,2,16,i),stringify:e=>Un(e,16,"0x")};qt.int=nh;qt.intBin=ih;qt.intHex=ah;qt.intOct=rh});var Yn=g(Kn=>{"use strict";var hr=P(),dr=Re(),fr=Ce(),ze=class e extends fr.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let i;hr.isPair(t)?i=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?i=new dr.Pair(t.key,null):i=new dr.Pair(t,null),fr.findPair(this.items,i.key)||this.items.push(i)}get(t,i){let r=fr.findPair(this.items,t);return!i&&hr.isPair(r)?hr.isScalar(r.key)?r.key.value:r.key:r}set(t,i){if(typeof i!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof i}`);let r=fr.findPair(this.items,t);r&&!i?this.items.splice(this.items.indexOf(r),1):!r&&i&&this.items.push(new dr.Pair(t))}toJSON(t,i){return super.toJSON(t,i,Set)}toString(t,i,r){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),i,r);throw new Error("Set items must all have null values")}static from(t,i,r){let{replacer:n}=r,a=new this(t);if(i&&Symbol.iterator in Object(i))for(let o of i)typeof n=="function"&&(o=n.call(i,o,o)),a.items.push(dr.createPair(o,null,r));return a}};ze.tag="tag:yaml.org,2002:set";var oh={collection:"map",identify:e=>e instanceof Set,nodeClass:ze,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,i)=>ze.from(e,t,i),resolve(e,t){if(hr.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new ze,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Kn.YAMLSet=ze;Kn.set=oh});var Qn=g(pr=>{"use strict";var sh=st();function Xn(e,t){let i=e[0],r=i==="-"||i==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),a=r.replace(/_/g,"").split(":").reduce((o,s)=>o*n(60)+n(s),n(0));return i==="-"?n(-1)*a:a}function Gs(e){let{value:t}=e,i=o=>o;if(typeof t=="bigint")i=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return sh.stringifyNumber(e);let r="";t<0&&(r="-",t*=i(-1));let n=i(60),a=[t%n];return t<60?a.unshift(0):(t=(t-a[0])/n,a.unshift(t%n),t>=60&&(t=(t-a[0])/n,a.unshift(t))),r+a.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var ch={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:i})=>Xn(e,i),stringify:Gs},lh={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Xn(e,!1),stringify:Gs},Us={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Us.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,i,r,n,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,l=Date.UTC(i,r-1,n,a||0,o||0,s||0,c),u=t[8];if(u&&u!=="Z"){let d=Xn(u,!1);Math.abs(d)<30&&(d*=60),l-=6e4*d}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};pr.floatTime=lh;pr.intTime=ch;pr.timestamp=Us});var Xs=g(Ys=>{"use strict";var uh=at(),dh=tr(),fh=ot(),hh=Bt(),ph=Fn(),Ks=Vs(),Zn=Ws(),mr=Js(),mh=Gi(),vh=zn(),gh=cr(),wh=Yn(),ea=Qn(),yh=[uh.map,fh.seq,hh.string,dh.nullTag,Ks.trueTag,Ks.falseTag,mr.intBin,mr.intOct,mr.int,mr.intHex,Zn.floatNaN,Zn.floatExp,Zn.float,ph.binary,mh.merge,vh.omap,gh.pairs,wh.set,ea.intTime,ea.floatTime,ea.timestamp];Ys.schema=yh});var sc=g(ra=>{"use strict";var tc=at(),Nh=tr(),ic=ot(),bh=Bt(),kh=jn(),ta=On(),ia=Dn(),Sh=_s(),Eh=js(),rc=Fn(),Vt=Gi(),nc=zn(),ac=cr(),Qs=Xs(),oc=Yn(),vr=Qn(),Zs=new Map([["core",Sh.schema],["failsafe",[tc.map,ic.seq,bh.string]],["json",Eh.schema],["yaml11",Qs.schema],["yaml-1.1",Qs.schema]]),ec={binary:rc.binary,bool:kh.boolTag,float:ta.float,floatExp:ta.floatExp,floatNaN:ta.floatNaN,floatTime:vr.floatTime,int:ia.int,intHex:ia.intHex,intOct:ia.intOct,intTime:vr.intTime,map:tc.map,merge:Vt.merge,null:Nh.nullTag,omap:nc.omap,pairs:ac.pairs,seq:ic.seq,set:oc.set,timestamp:vr.timestamp},Ph={"tag:yaml.org,2002:binary":rc.binary,"tag:yaml.org,2002:merge":Vt.merge,"tag:yaml.org,2002:omap":nc.omap,"tag:yaml.org,2002:pairs":ac.pairs,"tag:yaml.org,2002:set":oc.set,"tag:yaml.org,2002:timestamp":vr.timestamp};function Rh(e,t,i){let r=Zs.get(t);if(r&&!e)return i&&!r.includes(Vt.merge)?r.concat(Vt.merge):r.slice();let n=r;if(!n)if(Array.isArray(e))n=[];else{let a=Array.from(Zs.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${a} or define customTags array`)}if(Array.isArray(e))for(let a of e)n=n.concat(a);else typeof e=="function"&&(n=e(n.slice()));return i&&(n=n.concat(Vt.merge)),n.reduce((a,o)=>{let s=typeof o=="string"?ec[o]:o;if(!s){let c=JSON.stringify(o),l=Object.keys(ec).map(u=>JSON.stringify(u)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${l}`)}return a.includes(s)||a.push(s),a},[])}ra.coreKnownTags=Ph;ra.getTags=Rh});var oa=g(cc=>{"use strict";var na=P(),xh=at(),Ch=ot(),Ah=Bt(),gr=sc(),_h=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,aa=class e{constructor({compat:t,customTags:i,merge:r,resolveKnownTags:n,schema:a,sortMapEntries:o,toStringDefaults:s}){this.compat=Array.isArray(t)?gr.getTags(t,"compat"):t?gr.getTags(null,t):null,this.name=typeof a=="string"&&a||"core",this.knownTags=n?gr.coreKnownTags:{},this.tags=gr.getTags(i,this.name,r),this.toStringOptions=s??null,Object.defineProperty(this,na.MAP,{value:xh.map}),Object.defineProperty(this,na.SCALAR,{value:Ah.string}),Object.defineProperty(this,na.SEQ,{value:Ch.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?_h:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};cc.Schema=aa});var uc=g(lc=>{"use strict";var Th=P(),sa=Ot(),Wt=Tt();function Ih(e,t){let i=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(i.push(c),r=!0):e.directives.docStart&&(r=!0)}r&&i.push("---");let n=sa.createStringifyContext(e,t),{commentString:a}=n.options;if(e.commentBefore){i.length!==1&&i.unshift("");let c=a(e.commentBefore);i.unshift(Wt.indentComment(c,""))}let o=!1,s=null;if(e.contents){if(Th.isNode(e.contents)){if(e.contents.spaceBefore&&r&&i.push(""),e.contents.commentBefore){let u=a(e.contents.commentBefore);i.push(Wt.indentComment(u,""))}n.forceBlockIndent=!!e.comment,s=e.contents.comment}let c=s?void 0:()=>o=!0,l=sa.stringify(e.contents,n,()=>s=null,c);s&&(l+=Wt.lineComment(l,"",a(s))),(l[0]==="|"||l[0]===">")&&i[i.length-1]==="---"?i[i.length-1]=`--- ${l}`:i.push(l)}else i.push(sa.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let c=a(e.comment);c.includes(`
|
|
58
|
+
`)?(i.push("..."),i.push(Wt.indentComment(c,""))):i.push(`... ${c}`)}else i.push("...");else{let c=e.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||s)&&i[i.length-1]!==""&&i.push(""),i.push(Wt.indentComment(a(c),"")))}return i.join(`
|
|
59
59
|
`)+`
|
|
60
|
-
`}
|
|
60
|
+
`}lc.stringifyDocument=Ih});var zt=g(dc=>{"use strict";var jh=At(),ct=Di(),K=P(),$h=Re(),Oh=ke(),Hh=oa(),Dh=uc(),ca=ji(),Bh=fn(),Lh=_t(),la=dn(),ua=class e{constructor(t,i,r){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,K.NODE_TYPE,{value:K.DOC});let n=null;typeof i=="function"||Array.isArray(i)?n=i:r===void 0&&i&&(r=i,i=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},r);this.options=a;let{version:o}=a;r?._directives?(this.directives=r._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new la.Directives({version:o}),this.setSchema(o,r),this.contents=t===void 0?null:this.createNode(t,n,r)}clone(){let t=Object.create(e.prototype,{[K.NODE_TYPE]:{value:K.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=K.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){lt(this.contents)&&this.contents.add(t)}addIn(t,i){lt(this.contents)&&this.contents.addIn(t,i)}createAlias(t,i){if(!t.anchor){let r=ca.anchorNames(this);t.anchor=!i||r.has(i)?ca.findNewAnchor(i||"a",r):i}return new jh.Alias(t.anchor)}createNode(t,i,r){let n;if(typeof i=="function")t=i.call({"":t},"",t),n=i;else if(Array.isArray(i)){let m=y=>typeof y=="number"||y instanceof String||y instanceof Number,w=i.filter(m).map(String);w.length>0&&(i=i.concat(w)),n=i}else r===void 0&&i&&(r=i,i=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:c,onTagObj:l,tag:u}=r??{},{onAnchor:d,setAnchors:f,sourceObjects:p}=ca.createNodeAnchors(this,o||"a"),v={aliasDuplicateObjects:a??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:l,replacer:n,schema:this.schema,sourceObjects:p},h=Lh.createNode(t,u,v);return s&&K.isCollection(h)&&(h.flow=!0),f(),h}createPair(t,i,r={}){let n=this.createNode(t,null,r),a=this.createNode(i,null,r);return new $h.Pair(n,a)}delete(t){return lt(this.contents)?this.contents.delete(t):!1}deleteIn(t){return ct.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):lt(this.contents)?this.contents.deleteIn(t):!1}get(t,i){return K.isCollection(this.contents)?this.contents.get(t,i):void 0}getIn(t,i){return ct.isEmptyPath(t)?!i&&K.isScalar(this.contents)?this.contents.value:this.contents:K.isCollection(this.contents)?this.contents.getIn(t,i):void 0}has(t){return K.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return ct.isEmptyPath(t)?this.contents!==void 0:K.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,i){this.contents==null?this.contents=ct.collectionFromPath(this.schema,[t],i):lt(this.contents)&&this.contents.set(t,i)}setIn(t,i){ct.isEmptyPath(t)?this.contents=i:this.contents==null?this.contents=ct.collectionFromPath(this.schema,Array.from(t),i):lt(this.contents)&&this.contents.setIn(t,i)}setSchema(t,i={}){typeof t=="number"&&(t=String(t));let r;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new la.Directives({version:"1.1"}),r={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new la.Directives({version:t}),r={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,r=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(i.schema instanceof Object)this.schema=i.schema;else if(r)this.schema=new Hh.Schema(Object.assign(r,i));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:i,mapAsMap:r,maxAliasCount:n,onAnchor:a,reviver:o}={}){let s={anchors:new Map,doc:this,keep:!t,mapAsMap:r===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},c=Oh.toJS(this.contents,i??"",s);if(typeof a=="function")for(let{count:l,res:u}of s.anchors.values())a(u,l);return typeof o=="function"?Bh.applyReviver(o,{"":c},"",c):c}toJSON(t,i){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:i})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let i=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${i}`)}return Dh.stringifyDocument(this,t)}};function lt(e){if(K.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}dc.Document=ua});var Ut=g(Gt=>{"use strict";var Jt=class extends Error{constructor(t,i,r,n){super(),this.name=t,this.code=r,this.message=n,this.pos=i}},da=class extends Jt{constructor(t,i,r){super("YAMLParseError",t,i,r)}},fa=class extends Jt{constructor(t,i,r){super("YAMLWarning",t,i,r)}},Mh=(e,t)=>i=>{if(i.pos[0]===-1)return;i.linePos=i.pos.map(s=>t.linePos(s));let{line:r,col:n}=i.linePos[0];i.message+=` at line ${r}, column ${n}`;let a=n-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,"");if(a>=60&&o.length>80){let s=Math.min(a-39,o.length-79);o="…"+o.substring(s),a-=s-1}if(o.length>80&&(o=o.substring(0,79)+"…"),r>1&&/^ *$/.test(o.substring(0,a))){let s=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);s.length>80&&(s=s.substring(0,79)+`…
|
|
61
61
|
`),o=s+o}if(/[^ ]/.test(o)){let s=1,c=i.linePos[1];c?.line===r&&c.col>n&&(s=Math.max(1,Math.min(c.col-n,80-a)));let l=" ".repeat(a)+"^".repeat(s);i.message+=`:
|
|
62
62
|
|
|
63
63
|
${o}
|
|
64
64
|
${l}
|
|
65
|
-
`}};
|
|
66
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let i of t.start)if(i.type==="newline")return!0;if(t.sep){for(let i of t.sep)if(i.type==="newline")return!0}if(
|
|
67
|
-
`+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||
|
|
68
|
-
`+b.comment:y.comment=b.comment);let k=new
|
|
69
|
-
`+E.comment:l.comment=E.comment),d=E.end;continue}!o&&i.options.strict&&
|
|
70
|
-
`+A:N.comment=A,E.comment=E.comment.substring(A.length+1)}}if(!o&&!k&&!E.found){let A=S?e(i,S,E,n):t(i,E.end,k,null,E,n);l.items.push(A),d=A.range[2],
|
|
71
|
-
`+O.comment:N.comment=O.comment);let
|
|
72
|
-
`+m.comment:l.comment=m.comment),l.range=[r.offset,h,m.offset]}else l.range=[r.offset,h,h];return l}
|
|
65
|
+
`}};Gt.YAMLError=Jt;Gt.YAMLParseError=da;Gt.YAMLWarning=fa;Gt.prettifyError=Mh});var Kt=g(fc=>{"use strict";function Fh(e,{flow:t,indicator:i,next:r,offset:n,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d="",f="",p=!1,v=!1,h=null,m=null,w=null,y=null,b=null,k=null,S=null;for(let N of e)switch(v&&(N.type!=="space"&&N.type!=="newline"&&N.type!=="comma"&&a(N.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),v=!1),h&&(l&&N.type!=="comment"&&N.type!=="newline"&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),N.type){case"space":!t&&(i!=="doc-start"||r?.type!=="flow-collection")&&N.source.includes(" ")&&(h=N),u=!0;break;case"comment":{u||a(N,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let O=N.source.substring(1)||" ";d?d+=f+O:d=O,f="",l=!1;break}case"newline":l?d?d+=N.source:(!k||i!=="seq-item-ind")&&(c=!0):f+=N.source,l=!0,p=!0,(m||w)&&(y=N),u=!0;break;case"anchor":m&&a(N,"MULTIPLE_ANCHORS","A node can have at most one anchor"),N.source.endsWith(":")&&a(N.offset+N.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),m=N,S??(S=N.offset),l=!1,u=!1,v=!0;break;case"tag":{w&&a(N,"MULTIPLE_TAGS","A node can have at most one tag"),w=N,S??(S=N.offset),l=!1,u=!1,v=!0;break}case i:(m||w)&&a(N,"BAD_PROP_ORDER",`Anchors and tags must be after the ${N.source} indicator`),k&&a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.source} in ${t??"collection"}`),k=N,l=i==="seq-item-ind"||i==="explicit-key-ind",u=!1;break;case"comma":if(t){b&&a(N,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),b=N,l=!1,u=!1;break}default:a(N,"UNEXPECTED_TOKEN",`Unexpected ${N.type} token`),l=!1,u=!1}let E=e[e.length-1],A=E?E.offset+E.source.length:n;return v&&r&&r.type!=="space"&&r.type!=="newline"&&r.type!=="comma"&&(r.type!=="scalar"||r.source!=="")&&a(r.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(l&&h.indent<=o||r?.type==="block-map"||r?.type==="block-seq")&&a(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:b,found:k,spaceBefore:c,comment:d,hasNewline:p,anchor:m,tag:w,newlineAfterProp:y,end:A,start:S??A}}fc.resolveProps=Fh});var wr=g(hc=>{"use strict";function ha(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
66
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let i of t.start)if(i.type==="newline")return!0;if(t.sep){for(let i of t.sep)if(i.type==="newline")return!0}if(ha(t.key)||ha(t.value))return!0}return!1;default:return!0}}hc.containsNewline=ha});var pa=g(pc=>{"use strict";var qh=wr();function Vh(e,t,i){if(t?.type==="flow-collection"){let r=t.end[0];r.indent===e&&(r.source==="]"||r.source==="}")&&qh.containsNewline(t)&&i(r,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}pc.flowIndentCheck=Vh});var ma=g(vc=>{"use strict";var mc=P();function Wh(e,t,i){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let n=typeof r=="function"?r:(a,o)=>a===o||mc.isScalar(a)&&mc.isScalar(o)&&a.value===o.value;return t.some(a=>n(a.key,i))}vc.mapIncludes=Wh});var kc=g(bc=>{"use strict";var gc=Re(),zh=Ce(),wc=Kt(),Jh=wr(),yc=pa(),Gh=ma(),Nc="All mapping items must start at the same column";function Uh({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=a?.nodeClass??zh.YAMLMap,s=new o(i.schema);i.atRoot&&(i.atRoot=!1);let c=r.offset,l=null;for(let u of r.items){let{start:d,key:f,sep:p,value:v}=u,h=wc.resolveProps(d,{indicator:"explicit-key-ind",next:f??p?.[0],offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0}),m=!h.found;if(m){if(f&&(f.type==="block-seq"?n(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in f&&f.indent!==r.indent&&n(c,"BAD_INDENT",Nc)),!h.anchor&&!h.tag&&!p){l=h.end,h.comment&&(s.comment?s.comment+=`
|
|
67
|
+
`+h.comment:s.comment=h.comment);continue}(h.newlineAfterProp||Jh.containsNewline(f))&&n(f??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==r.indent&&n(c,"BAD_INDENT",Nc);i.atKey=!0;let w=h.end,y=f?e(i,f,h,n):t(i,w,d,null,h,n);i.schema.compat&&yc.flowIndentCheck(r.indent,f,n),i.atKey=!1,Gh.mapIncludes(i,s.items,y)&&n(w,"DUPLICATE_KEY","Map keys must be unique");let b=wc.resolveProps(p??[],{indicator:"map-value-ind",next:v,offset:y.range[2],onError:n,parentIndent:r.indent,startOnNewline:!f||f.type==="block-scalar"});if(c=b.end,b.found){m&&(v?.type==="block-map"&&!b.hasNewline&&n(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),i.options.strict&&h.start<b.found.offset-1024&&n(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let k=v?e(i,v,b,n):t(i,c,p,null,b,n);i.schema.compat&&yc.flowIndentCheck(r.indent,v,n),c=k.range[2];let S=new gc.Pair(y,k);i.options.keepSourceTokens&&(S.srcToken=u),s.items.push(S)}else{m&&n(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),b.comment&&(y.comment?y.comment+=`
|
|
68
|
+
`+b.comment:y.comment=b.comment);let k=new gc.Pair(y);i.options.keepSourceTokens&&(k.srcToken=u),s.items.push(k)}}return l&&l<c&&n(l,"IMPOSSIBLE","Map comment with trailing content"),s.range=[r.offset,c,l??c],s}bc.resolveBlockMap=Uh});var Ec=g(Sc=>{"use strict";var Kh=Ae(),Yh=Kt(),Xh=pa();function Qh({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=a?.nodeClass??Kh.YAMLSeq,s=new o(i.schema);i.atRoot&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let c=r.offset,l=null;for(let{start:u,value:d}of r.items){let f=Yh.resolveProps(u,{indicator:"seq-item-ind",next:d,offset:c,onError:n,parentIndent:r.indent,startOnNewline:!0});if(!f.found)if(f.anchor||f.tag||d)d?.type==="block-seq"?n(f.end,"BAD_INDENT","All sequence items must start at the same column"):n(c,"MISSING_CHAR","Sequence item without - indicator");else{l=f.end,f.comment&&(s.comment=f.comment);continue}let p=d?e(i,d,f,n):t(i,f.end,u,null,f,n);i.schema.compat&&Xh.flowIndentCheck(r.indent,d,n),c=p.range[2],s.items.push(p)}return s.range=[r.offset,c,l??c],s}Sc.resolveBlockSeq=Qh});var ut=g(Pc=>{"use strict";function Zh(e,t,i,r){let n="";if(e){let a=!1,o="";for(let s of e){let{source:c,type:l}=s;switch(l){case"space":a=!0;break;case"comment":{i&&!a&&r(s,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let u=c.substring(1)||" ";n?n+=o+u:n=u,o="";break}case"newline":n&&(o+=c),a=!0;break;default:r(s,"UNEXPECTED_TOKEN",`Unexpected ${l} at node end`)}t+=c.length}}return{comment:n,offset:t}}Pc.resolveEnd=Zh});var Ac=g(Cc=>{"use strict";var ep=P(),tp=Re(),Rc=Ce(),ip=Ae(),rp=ut(),xc=Kt(),np=wr(),ap=ma(),va="Block collections are not allowed within flow collections",ga=e=>e&&(e.type==="block-map"||e.type==="block-seq");function op({composeNode:e,composeEmptyNode:t},i,r,n,a){let o=r.start.source==="{",s=o?"flow map":"flow sequence",c=a?.nodeClass??(o?Rc.YAMLMap:ip.YAMLSeq),l=new c(i.schema);l.flow=!0;let u=i.atRoot;u&&(i.atRoot=!1),i.atKey&&(i.atKey=!1);let d=r.offset+r.start.source.length;for(let m=0;m<r.items.length;++m){let w=r.items[m],{start:y,key:b,sep:k,value:S}=w,E=xc.resolveProps(y,{flow:s,indicator:"explicit-key-ind",next:b??k?.[0],offset:d,onError:n,parentIndent:r.indent,startOnNewline:!1});if(!E.found){if(!E.anchor&&!E.tag&&!k&&!S){m===0&&E.comma?n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`):m<r.items.length-1&&n(E.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${s}`),E.comment&&(l.comment?l.comment+=`
|
|
69
|
+
`+E.comment:l.comment=E.comment),d=E.end;continue}!o&&i.options.strict&&np.containsNewline(b)&&n(b,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(m===0)E.comma&&n(E.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${s}`);else if(E.comma||n(E.start,"MISSING_CHAR",`Missing , between ${s} items`),E.comment){let A="";e:for(let N of y)switch(N.type){case"comma":case"space":break;case"comment":A=N.source.substring(1);break e;default:break e}if(A){let N=l.items[l.items.length-1];ep.isPair(N)&&(N=N.value??N.key),N.comment?N.comment+=`
|
|
70
|
+
`+A:N.comment=A,E.comment=E.comment.substring(A.length+1)}}if(!o&&!k&&!E.found){let A=S?e(i,S,E,n):t(i,E.end,k,null,E,n);l.items.push(A),d=A.range[2],ga(S)&&n(A.range,"BLOCK_IN_FLOW",va)}else{i.atKey=!0;let A=E.end,N=b?e(i,b,E,n):t(i,A,y,null,E,n);ga(b)&&n(N.range,"BLOCK_IN_FLOW",va),i.atKey=!1;let O=xc.resolveProps(k??[],{flow:s,indicator:"map-value-ind",next:S,offset:N.range[2],onError:n,parentIndent:r.indent,startOnNewline:!1});if(O.found){if(!o&&!E.found&&i.options.strict){if(k)for(let H of k){if(H===O.found)break;if(H.type==="newline"){n(H,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}E.start<O.found.offset-1024&&n(O.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else S&&("source"in S&&S.source?.[0]===":"?n(S,"MISSING_CHAR",`Missing space after : in ${s}`):n(O.start,"MISSING_CHAR",`Missing , or : between ${s} items`));let be=S?e(i,S,O,n):O.found?t(i,O.end,k,null,O,n):null;be?ga(S)&&n(be.range,"BLOCK_IN_FLOW",va):O.comment&&(N.comment?N.comment+=`
|
|
71
|
+
`+O.comment:N.comment=O.comment);let et=new tp.Pair(N,be);if(i.options.keepSourceTokens&&(et.srcToken=w),o){let H=l;ap.mapIncludes(i,H.items,N)&&n(A,"DUPLICATE_KEY","Map keys must be unique"),H.items.push(et)}else{let H=new Rc.YAMLMap(i.schema);H.flow=!0,H.items.push(et);let Co=(be??N).range;H.range=[N.range[0],Co[1],Co[2]],l.items.push(H)}d=be?be.range[2]:O.end}}let f=o?"}":"]",[p,...v]=r.end,h=d;if(p?.source===f)h=p.offset+p.source.length;else{let m=s[0].toUpperCase()+s.substring(1),w=u?`${m} must end with a ${f}`:`${m} in block collection must be sufficiently indented and end with a ${f}`;n(d,u?"MISSING_CHAR":"BAD_INDENT",w),p&&p.source.length!==1&&v.unshift(p)}if(v.length>0){let m=rp.resolveEnd(v,h,i.options.strict,n);m.comment&&(l.comment?l.comment+=`
|
|
72
|
+
`+m.comment:l.comment=m.comment),l.range=[r.offset,h,m.offset]}else l.range=[r.offset,h,h];return l}Cc.resolveFlowCollection=op});var Tc=g(_c=>{"use strict";var sp=P(),cp=j(),lp=Ce(),up=Ae(),dp=kc(),fp=Ec(),hp=Ac();function wa(e,t,i,r,n,a){let o=i.type==="block-map"?dp.resolveBlockMap(e,t,i,r,a):i.type==="block-seq"?fp.resolveBlockSeq(e,t,i,r,a):hp.resolveFlowCollection(e,t,i,r,a),s=o.constructor;return n==="!"||n===s.tagName?(o.tag=s.tagName,o):(n&&(o.tag=n),o)}function pp(e,t,i,r,n){let a=r.tag,o=a?t.directives.tagName(a.source,f=>n(a,"TAG_RESOLVE_FAILED",f)):null;if(i.type==="block-seq"){let{anchor:f,newlineAfterProp:p}=r,v=f&&a?f.offset>a.offset?f:a:f??a;v&&(!p||p.offset<v.offset)&&n(v,"MISSING_CHAR","Missing newline after block sequence props")}let s=i.type==="block-map"?"map":i.type==="block-seq"?"seq":i.start.source==="{"?"map":"seq";if(!a||!o||o==="!"||o===lp.YAMLMap.tagName&&s==="map"||o===up.YAMLSeq.tagName&&s==="seq")return wa(e,t,i,n,o);let c=t.schema.tags.find(f=>f.tag===o&&f.collection===s);if(!c){let f=t.schema.knownTags[o];if(f?.collection===s)t.schema.tags.push(Object.assign({},f,{default:!1})),c=f;else return f?n(a,"BAD_COLLECTION_TYPE",`${f.tag} used for ${s} collection, but expects ${f.collection??"scalar"}`,!0):n(a,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),wa(e,t,i,n,o)}let l=wa(e,t,i,n,o,c),u=c.resolve?.(l,f=>n(a,"TAG_RESOLVE_FAILED",f),t.options)??l,d=sp.isNode(u)?u:new cp.Scalar(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}_c.composeCollection=pp});var Na=g(Ic=>{"use strict";var ya=j();function mp(e,t,i){let r=t.offset,n=vp(t,e.options.strict,i);if(!n)return{value:"",type:null,comment:"",range:[r,r,r]};let a=n.mode===">"?ya.Scalar.BLOCK_FOLDED:ya.Scalar.BLOCK_LITERAL,o=t.source?gp(t.source):[],s=o.length;for(let h=o.length-1;h>=0;--h){let m=o[h][1];if(m===""||m==="\r")s=h;else break}if(s===0){let h=n.chomp==="+"&&o.length>0?`
|
|
73
73
|
`.repeat(Math.max(1,o.length-1)):"",m=r+n.length;return t.source&&(m+=t.source.length),{value:h,type:a,comment:n.comment,range:[r,m,m]}}let c=t.indent+n.indent,l=t.offset+n.length,u=0;for(let h=0;h<s;++h){let[m,w]=o[h];if(w===""||w==="\r")n.indent===0&&m.length>c&&(c=m.length);else{m.length<c&&i(l+m.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(c=m.length),u=h,c===0&&!e.atRoot&&i(l,"BAD_INDENT","Block scalar values in collections must be indented");break}l+=m.length+w.length+1}for(let h=o.length-1;h>=s;--h)o[h][0].length>c&&(s=h+1);let d="",f="",p=!1;for(let h=0;h<u;++h)d+=o[h][0].slice(c)+`
|
|
74
|
-
`;for(let h=u;h<s;++h){let[m,w]=o[h];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}a===
|
|
74
|
+
`;for(let h=u;h<s;++h){let[m,w]=o[h];l+=m.length+w.length+1;let y=w[w.length-1]==="\r";if(y&&(w=w.slice(0,-1)),w&&m.length<c){let k=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;i(l-w.length-(y?2:1),"BAD_INDENT",k),m=""}a===ya.Scalar.BLOCK_LITERAL?(d+=f+m.slice(c)+w,f=`
|
|
75
75
|
`):m.length>c||w[0]===" "?(f===" "?f=`
|
|
76
76
|
`:!p&&f===`
|
|
77
77
|
`&&(f=`
|
|
@@ -84,66 +84,66 @@ ${l}
|
|
|
84
84
|
`+o[h][0].slice(c);d[d.length-1]!==`
|
|
85
85
|
`&&(d+=`
|
|
86
86
|
`);break;default:d+=`
|
|
87
|
-
`}let v=r+n.length+t.source.length;return{value:d,type:a,comment:n.comment,range:[r,v,v]}}function
|
|
87
|
+
`}let v=r+n.length+t.source.length;return{value:d,type:a,comment:n.comment,range:[r,v,v]}}function vp({offset:e,props:t},i,r){if(t[0].type!=="block-scalar-header")return r(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],a=n[0],o=0,s="",c=-1;for(let f=1;f<n.length;++f){let p=n[f];if(!s&&(p==="-"||p==="+"))s=p;else{let v=Number(p);!o&&v?o=v:c===-1&&(c=e+f)}}c!==-1&&r(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let l=!1,u="",d=n.length;for(let f=1;f<t.length;++f){let p=t[f];switch(p.type){case"space":l=!0;case"newline":d+=p.source.length;break;case"comment":i&&!l&&r(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=p.source.length,u=p.source.substring(1);break;case"error":r(p,"UNEXPECTED_TOKEN",p.message),d+=p.source.length;break;default:{let v=`Unexpected token in block scalar header: ${p.type}`;r(p,"UNEXPECTED_TOKEN",v);let h=p.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function gp(e){let t=e.split(/\n( *)/),i=t[0],r=i.match(/^( *)/),a=[r?.[1]?[r[1],i.slice(r[1].length)]:["",i]];for(let o=1;o<t.length;o+=2)a.push([t[o],t[o+1]]);return a}Ic.resolveBlockScalar=mp});var ka=g($c=>{"use strict";var ba=j(),wp=ut();function yp(e,t,i){let{offset:r,type:n,source:a,end:o}=e,s,c,l=(f,p,v)=>i(r+f,p,v);switch(n){case"scalar":s=ba.Scalar.PLAIN,c=Np(a,l);break;case"single-quoted-scalar":s=ba.Scalar.QUOTE_SINGLE,c=bp(a,l);break;case"double-quoted-scalar":s=ba.Scalar.QUOTE_DOUBLE,c=kp(a,l);break;default:return i(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=wp.resolveEnd(o,u,t,i);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function Np(e,t){let i="";switch(e[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 ${e[0]}`;break}case"@":case"`":{i=`reserved character ${e[0]}`;break}}return i&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${i}`),jc(e)}function bp(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),jc(e.slice(1,-1)).replace(/''/g,"'")}function jc(e){let t,i;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
88
88
|
`,"sy"),i=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
89
89
|
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,i=/[ \t]*(.*?)[ \t]*\r?\n/sy}let r=t.exec(e);if(!r)return e;let n=r[1],a=" ",o=t.lastIndex;for(i.lastIndex=o;r=i.exec(e);)r[1]===""?a===`
|
|
90
90
|
`?n+=a:a=`
|
|
91
|
-
`:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),n+a+(r?.[1]??"")}function
|
|
91
|
+
`:(n+=a+r[1],a=" "),o=i.lastIndex;let s=/[ \t]*(.*)/sy;return s.lastIndex=o,r=s.exec(e),n+a+(r?.[1]??"")}function kp(e,t){let i="";for(let r=1;r<e.length-1;++r){let n=e[r];if(!(n==="\r"&&e[r+1]===`
|
|
92
92
|
`))if(n===`
|
|
93
|
-
`){let{fold:a,offset:o}=
|
|
93
|
+
`){let{fold:a,offset:o}=Sp(e,r);i+=a,r=o}else if(n==="\\"){let a=e[++r],o=Ep[a];if(o)i+=o;else if(a===`
|
|
94
94
|
`)for(a=e[r+1];a===" "||a===" ";)a=e[++r+1];else if(a==="\r"&&e[r+1]===`
|
|
95
|
-
`)for(a=e[++r+1];a===" "||a===" ";)a=e[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=
|
|
95
|
+
`)for(a=e[++r+1];a===" "||a===" ";)a=e[++r+1];else if(a==="x"||a==="u"||a==="U"){let s=a==="x"?2:a==="u"?4:8;i+=Pp(e,r+1,s,t),r+=s}else{let s=e.substr(r-1,2);t(r-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),i+=s}}else if(n===" "||n===" "){let a=r,o=e[r+1];for(;o===" "||o===" ";)o=e[++r+1];o!==`
|
|
96
96
|
`&&!(o==="\r"&&e[r+2]===`
|
|
97
|
-
`)&&(i+=r>a?e.slice(a,r+1):n)}else i+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),i}function
|
|
97
|
+
`)&&(i+=r>a?e.slice(a,r+1):n)}else i+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),i}function Sp(e,t){let i="",r=e[t+1];for(;(r===" "||r===" "||r===`
|
|
98
98
|
`||r==="\r")&&!(r==="\r"&&e[t+2]!==`
|
|
99
99
|
`);)r===`
|
|
100
100
|
`&&(i+=`
|
|
101
|
-
`),t+=1,r=e[t+1];return i||(i=" "),{fold:i,offset:t}}var
|
|
102
|
-
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
101
|
+
`),t+=1,r=e[t+1];return i||(i=" "),{fold:i,offset:t}}var Ep={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
102
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Pp(e,t,i,r){let n=e.substr(t,i),o=n.length===i&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;try{return String.fromCodePoint(o)}catch{let s=e.substr(t-2,i+2);return r(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${s}`),s}}$c.resolveFlowScalar=yp});var Dc=g(Hc=>{"use strict";var Je=P(),Oc=j(),Rp=Na(),xp=ka();function Cp(e,t,i,r){let{value:n,type:a,comment:o,range:s}=t.type==="block-scalar"?Rp.resolveBlockScalar(e,t,r):xp.resolveFlowScalar(t,e.options.strict,r),c=i?e.directives.tagName(i.source,d=>r(i,"TAG_RESOLVE_FAILED",d)):null,l;e.options.stringKeys&&e.atKey?l=e.schema[Je.SCALAR]:c?l=Ap(e.schema,n,c,i,r):t.type==="scalar"?l=_p(e,n,t,r):l=e.schema[Je.SCALAR];let u;try{let d=l.resolve(n,f=>r(i??t,"TAG_RESOLVE_FAILED",f),e.options);u=Je.isScalar(d)?d:new Oc.Scalar(d)}catch(d){let f=d instanceof Error?d.message:String(d);r(i??t,"TAG_RESOLVE_FAILED",f),u=new Oc.Scalar(n)}return u.range=s,u.source=n,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function Ap(e,t,i,r,n){if(i==="!")return e[Je.SCALAR];let a=[];for(let s of e.tags)if(!s.collection&&s.tag===i)if(s.default&&s.test)a.push(s);else return s;for(let s of a)if(s.test?.test(t))return s;let o=e.knownTags[i];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${i}`,i!=="tag:yaml.org,2002:str"),e[Je.SCALAR])}function _p({atKey:e,directives:t,schema:i},r,n,a){let o=i.tags.find(s=>(s.default===!0||e&&s.default==="key")&&s.test?.test(r))||i[Je.SCALAR];if(i.compat){let s=i.compat.find(c=>c.default&&c.test?.test(r))??i[Je.SCALAR];if(o.tag!==s.tag){let c=t.tagString(o.tag),l=t.tagString(s.tag),u=`Value may be parsed as either ${c} or ${l}`;a(n,"TAG_RESOLVE_FAILED",u,!0)}}return o}Hc.composeScalar=Cp});var Lc=g(Bc=>{"use strict";function Tp(e,t,i){if(t){i??(i=t.length);for(let r=i-1;r>=0;--r){let n=t[r];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++r];n?.type==="space";)e+=n.source.length,n=t[++r];break}}return e}Bc.emptyScalarPosition=Tp});var qc=g(Ea=>{"use strict";var Ip=At(),jp=P(),$p=Tc(),Mc=Dc(),Op=ut(),Hp=Lc(),Dp={composeNode:Fc,composeEmptyNode:Sa};function Fc(e,t,i,r){let n=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=i,l,u=!0;switch(t.type){case"alias":l=Bp(e,t,r),(s||c)&&r(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":l=Mc.composeScalar(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{l=$p.composeCollection(Dp,e,t,i,r),s&&(l.anchor=s.source.substring(1))}catch(d){let f=d instanceof Error?d.message:String(d);r(t,"RESOURCE_EXHAUSTION",f)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;r(t,"UNEXPECTED_TOKEN",d),u=!1}}return l??(l=Sa(e,t.offset,void 0,null,i,r)),s&&l.anchor===""&&r(s,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!jp.isScalar(l)||typeof l.value!="string"||l.tag&&l.tag!=="tag:yaml.org,2002:str")&&r(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),a&&(l.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function Sa(e,t,i,r,{spaceBefore:n,comment:a,anchor:o,tag:s,end:c},l){let u={type:"scalar",offset:Hp.emptyScalarPosition(t,i,r),indent:-1,source:""},d=Mc.composeScalar(e,u,s,l);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&l(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),a&&(d.comment=a,d.range[2]=c),d}function Bp({options:e},{offset:t,source:i,end:r},n){let a=new Ip.Alias(i.substring(1));a.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),a.source.endsWith(":")&&n(t+i.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+i.length,s=Op.resolveEnd(r,o,e.strict,n);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}Ea.composeEmptyNode=Sa;Ea.composeNode=Fc});var zc=g(Wc=>{"use strict";var Lp=zt(),Vc=qc(),Mp=ut(),Fp=Kt();function qp(e,t,{offset:i,start:r,value:n,end:a},o){let s=Object.assign({_directives:t},e),c=new Lp.Document(void 0,s),l={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},u=Fp.resolveProps(r,{indicator:"doc-start",next:n??a?.[0],offset:i,onError:o,parentIndent:0,startOnNewline:!0});u.found&&(c.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!u.hasNewline&&o(u.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=n?Vc.composeNode(l,n,u,o):Vc.composeEmptyNode(l,u.end,r,null,u,o);let d=c.contents.range[2],f=Mp.resolveEnd(a,d,!1,o);return f.comment&&(c.comment=f.comment),c.range=[i,d,f.offset],c}Wc.composeDoc=qp});var Ra=g(Uc=>{"use strict";var Vp=Ci("process"),Wp=dn(),zp=zt(),Yt=Ut(),Jc=P(),Jp=zc(),Gp=ut();function Xt(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:i}=e;return[t,t+(typeof i=="string"?i.length:1)]}function Gc(e){let t="",i=!1,r=!1;for(let n=0;n<e.length;++n){let a=e[n];switch(a[0]){case"#":t+=(t===""?"":r?`
|
|
103
103
|
|
|
104
104
|
`:`
|
|
105
|
-
`)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:t,afterEmptyLine:r}}var
|
|
106
|
-
${r}`:r;else if(n||t.directives.docStart||!a)t.commentBefore=r;else if(
|
|
105
|
+
`)+(a.substring(1)||" "),i=!0,r=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),i=!1;break;default:i||(r=!0),i=!1}}return{comment:t,afterEmptyLine:r}}var Pa=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(i,r,n,a)=>{let o=Xt(i);a?this.warnings.push(new Yt.YAMLWarning(o,r,n)):this.errors.push(new Yt.YAMLParseError(o,r,n))},this.directives=new Wp.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,i){let{comment:r,afterEmptyLine:n}=Gc(this.prelude);if(r){let a=t.contents;if(i)t.comment=t.comment?`${t.comment}
|
|
106
|
+
${r}`:r;else if(n||t.directives.docStart||!a)t.commentBefore=r;else if(Jc.isCollection(a)&&!a.flow&&a.items.length>0){let o=a.items[0];Jc.isPair(o)&&(o=o.key);let s=o.commentBefore;o.commentBefore=s?`${r}
|
|
107
107
|
${s}`:r}else{let o=a.commentBefore;a.commentBefore=o?`${r}
|
|
108
|
-
${o}`:r}}if(i){for(let a=0;a<this.errors.length;++a)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
109
|
-
${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.push(new
|
|
108
|
+
${o}`:r}}if(i){for(let a=0;a<this.errors.length;++a)t.errors.push(this.errors[a]);for(let a=0;a<this.warnings.length;++a)t.warnings.push(this.warnings[a])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Gc(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,i=!1,r=-1){for(let n of t)yield*this.next(n);yield*this.end(i,r)}*next(t){switch(Vp.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(i,r,n)=>{let a=Xt(t);a[0]+=i,this.onError(a,"BAD_DIRECTIVE",r,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let i=Jp.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!i.directives.docStart&&this.onError(t,"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(t.source);break;case"error":{let i=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,r=new Yt.YAMLParseError(Xt(t),"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 Yt.YAMLParseError(Xt(t),"UNEXPECTED_TOKEN",r));break}this.doc.directives.docEnd=!0;let i=Gp.resolveEnd(t.end,t.offset+t.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 Yt.YAMLParseError(Xt(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,i=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let r=Object.assign({_directives:this.directives},this.options),n=new zp.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}}};Uc.Composer=Pa});var Xc=g(yr=>{"use strict";var Up=Na(),Kp=ka(),Yp=Ut(),Kc=$t();function Xp(e,t=!0,i){if(e){let r=(n,a,o)=>{let s=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(i)i(s,a,o);else throw new Yp.YAMLParseError([s,s+1],a,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Kp.resolveFlowScalar(e,t,r);case"block-scalar":return Up.resolveBlockScalar({options:{strict:t}},e,r)}}return null}function Qp(e,t){let{implicitKey:i=!1,indent:r,inFlow:n=!1,offset:a=-1,type:o="PLAIN"}=t,s=Kc.stringifyString({type:o,value:e},{implicitKey:i,indent:r>0?" ".repeat(r):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:r,source:`
|
|
110
110
|
`}];switch(s[0]){case"|":case">":{let l=s.indexOf(`
|
|
111
111
|
`),u=s.substring(0,l),d=s.substring(l+1)+`
|
|
112
|
-
`,f=[{type:"block-scalar-header",offset:a,indent:r,source:u}];return
|
|
113
|
-
`}),{type:"block-scalar",offset:a,indent:r,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:r,source:s,end:c};default:return{type:"scalar",offset:a,indent:r,source:s,end:c}}}function
|
|
112
|
+
`,f=[{type:"block-scalar-header",offset:a,indent:r,source:u}];return Yc(f,c)||f.push({type:"newline",offset:-1,indent:r,source:`
|
|
113
|
+
`}),{type:"block-scalar",offset:a,indent:r,props:f,source:d}}case'"':return{type:"double-quoted-scalar",offset:a,indent:r,source:s,end:c};case"'":return{type:"single-quoted-scalar",offset:a,indent:r,source:s,end:c};default:return{type:"scalar",offset:a,indent:r,source:s,end:c}}}function Zp(e,t,i={}){let{afterKey:r=!1,implicitKey:n=!1,inFlow:a=!1,type:o}=i,s="indent"in e?e.indent:null;if(r&&typeof s=="number"&&(s+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let l=e.props[0];if(l.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=l.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=Kc.stringifyString({type:o,value:t},{implicitKey:n||s===null,indent:s!==null&&s>0?" ".repeat(s):"",inFlow:a,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":em(e,c);break;case'"':xa(e,c,"double-quoted-scalar");break;case"'":xa(e,c,"single-quoted-scalar");break;default:xa(e,c,"scalar")}}function em(e,t){let i=t.indexOf(`
|
|
114
114
|
`),r=t.substring(0,i),n=t.substring(i+1)+`
|
|
115
|
-
`;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=r,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:r}];
|
|
116
|
-
`});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function
|
|
117
|
-
`};delete e.items,Object.assign(e,{type:i,source:t,end:[n]});break}default:{let r="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:i,indent:r,source:t,end:n})}}}
|
|
115
|
+
`;if(e.type==="block-scalar"){let a=e.props[0];if(a.type!=="block-scalar-header")throw new Error("Invalid block scalar header");a.source=r,e.source=n}else{let{offset:a}=e,o="indent"in e?e.indent:-1,s=[{type:"block-scalar-header",offset:a,indent:o,source:r}];Yc(s,"end"in e?e.end:void 0)||s.push({type:"newline",offset:-1,indent:o,source:`
|
|
116
|
+
`});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:s,source:n})}}function Yc(e,t){if(t)for(let i of t)switch(i.type){case"space":case"comment":e.push(i);break;case"newline":return e.push(i),!0}return!1}function xa(e,t,i){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=i,e.source=t;break;case"block-scalar":{let r=e.props.slice(1),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let a of r)a.offset+=n;delete e.props,Object.assign(e,{type:i,source:t,end:r});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
117
|
+
`};delete e.items,Object.assign(e,{type:i,source:t,end:[n]});break}default:{let r="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(a=>a.type==="space"||a.type==="comment"||a.type==="newline"):[];for(let a of Object.keys(e))a!=="type"&&a!=="offset"&&delete e[a];Object.assign(e,{type:i,indent:r,source:t,end:n})}}}yr.createScalarToken=Qp;yr.resolveAsScalar=Xp;yr.setScalarValue=Zp});var Zc=g(Qc=>{"use strict";var tm=e=>"type"in e?br(e):Nr(e);function br(e){switch(e.type){case"block-scalar":{let t="";for(let i of e.props)t+=br(i);return t+e.source}case"block-map":case"block-seq":{let t="";for(let i of e.items)t+=Nr(i);return t}case"flow-collection":{let t=e.start.source;for(let i of e.items)t+=Nr(i);for(let i of e.end)t+=i.source;return t}case"document":{let t=Nr(e);if(e.end)for(let i of e.end)t+=i.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let i of e.end)t+=i.source;return t}}}function Nr({start:e,key:t,sep:i,value:r}){let n="";for(let a of e)n+=a.source;if(t&&(n+=br(t)),i)for(let a of i)n+=a.source;return r&&(n+=br(r)),n}Qc.stringify=tm});var rl=g(il=>{"use strict";var Ca=Symbol("break visit"),im=Symbol("skip children"),el=Symbol("remove item");function Ge(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),tl(Object.freeze([]),e,t)}Ge.BREAK=Ca;Ge.SKIP=im;Ge.REMOVE=el;Ge.itemAtPath=(e,t)=>{let i=e;for(let[r,n]of t){let a=i?.[r];if(a&&"items"in a)i=a.items[n];else return}return i};Ge.parentCollection=(e,t)=>{let i=Ge.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],n=i?.[r];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function tl(e,t,i){let r=i(t,e);if(typeof r=="symbol")return r;for(let n of["key","value"]){let a=t[n];if(a&&"items"in a){for(let o=0;o<a.items.length;++o){let s=tl(Object.freeze(e.concat([[n,o]])),a.items[o],i);if(typeof s=="number")o=s-1;else{if(s===Ca)return Ca;s===el&&(a.items.splice(o,1),o-=1)}}typeof r=="function"&&n==="key"&&(r=r(t,e))}}return typeof r=="function"?r(t,e):r}il.visit=Ge});var kr=g(W=>{"use strict";var Aa=Xc(),rm=Zc(),nm=rl(),_a="\uFEFF",Ta="",Ia="",ja="",am=e=>!!e&&"items"in e,om=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function sm(e){switch(e){case _a:return"<BOM>";case Ta:return"<DOC>";case Ia:return"<FLOW_END>";case ja:return"<SCALAR>";default:return JSON.stringify(e)}}function cm(e){switch(e){case _a:return"byte-order-mark";case Ta:return"doc-mode";case Ia:return"flow-error-end";case ja: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(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}W.createScalarToken=
|
|
120
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
121
|
-
\r `)
|
|
119
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}W.createScalarToken=Aa.createScalarToken;W.resolveAsScalar=Aa.resolveAsScalar;W.setScalarValue=Aa.setScalarValue;W.stringify=rm.stringify;W.visit=nm.visit;W.BOM=_a;W.DOCUMENT=Ta;W.FLOW_END=Ia;W.SCALAR=ja;W.isCollection=am;W.isScalar=om;W.prettyToken=sm;W.tokenType=cm});var Ha=g(al=>{"use strict";var Qt=kr();function ie(e){switch(e){case void 0:case" ":case`
|
|
120
|
+
`:case"\r":case" ":return!0;default:return!1}}var nl=new Set("0123456789ABCDEFabcdef"),lm=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Sr=new Set(",[]{}"),um=new Set(` ,[]{}
|
|
121
|
+
\r `),$a=e=>!e||um.has(e),Oa=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,i=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!i;let r=this.next??"stream";for(;r&&(i||this.hasChars(1));)r=yield*this.parseNext(r)}atLineEnd(){let t=this.pos,i=this.buffer[t];for(;i===" "||i===" ";)i=this.buffer[++t];return!i||i==="#"||i===`
|
|
122
122
|
`?!0:i==="\r"?this.buffer[t+1]===`
|
|
123
123
|
`:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let i=this.buffer[t];if(this.indentNext>0){let r=0;for(;i===" ";)i=this.buffer[++r+t];if(i==="\r"){let n=this.buffer[r+t+1];if(n===`
|
|
124
124
|
`||!n&&!this.atEnd)return t+r+1}return i===`
|
|
125
|
-
`||r>=this.indentNext||!i&&!this.atEnd?t+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(t,3);if((r==="---"||r==="...")&&
|
|
126
|
-
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===
|
|
125
|
+
`||r>=this.indentNext||!i&&!this.atEnd?t+r:-1}if(i==="-"||i==="."){let r=this.buffer.substr(t,3);if((r==="---"||r==="...")&&ie(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
|
|
126
|
+
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===Qt.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let i=t.length,r=t.indexOf("#");for(;r!==-1;){let a=t[r-1];if(a===" "||a===" "){i=r-1;break}else r=t.indexOf("#",r+1)}for(;;){let a=t[i-1];if(a===" "||a===" ")i-=1;else break}let n=(yield*this.pushCount(i))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let i=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-i),yield*this.pushNewline(),"stream"}return yield Qt.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let i=this.peek(3);if((i==="---"||i==="...")&&ie(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&&!ie(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,i]=this.peek(2);if(!i&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&ie(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 t=this.getLine();if(t===null)return this.setNext("doc");let i=yield*this.pushIndicators();switch(t[i]){case"#":yield*this.pushCount(t.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($a),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return i+=yield*this.parseBlockScalarHeader(),i+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-i),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,i,r=-1;do t=yield*this.pushNewline(),t>0?(i=yield*this.pushSpaces(!1),this.indentValue=r=i):i=0,i+=yield*this.pushSpaces(!0);while(t+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("..."))&&ie(n[3]))&&!(r===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Qt.FLOW_END,yield*this.parseLineStart();let a=0;for(;n[a]===",";)a+=yield*this.pushCount(1),a+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(a+=yield*this.pushIndicators(),n[a]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-a),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil($a),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||ie(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),i=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;i!==-1&&this.buffer[i+1]==="'";)i=this.buffer.indexOf("'",i+2);else for(;i!==-1;){let a=0;for(;this.buffer[i-1-a]==="\\";)a+=1;if(a%2===0)break;i=this.buffer.indexOf('"',i+1)}let r=this.buffer.substring(0,i),n=r.indexOf(`
|
|
127
127
|
`,this.pos);if(n!==-1){for(;n!==-1;){let a=this.continueScalar(n+1);if(a===-1)break;n=r.indexOf(`
|
|
128
|
-
`,a)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let i=this.buffer[++t];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=>
|
|
128
|
+
`,a)}n!==-1&&(i=n-(r[n-1]==="\r"?2:1))}if(i===-1){if(!this.atEnd)return this.setNext("quoted-scalar");i=this.buffer.length}return yield*this.pushToIndex(i+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let i=this.buffer[++t];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=>ie(i)||i==="#")}*parseBlockScalar(){let t=this.pos-1,i=0,r;e:for(let a=this.pos;r=this.buffer[a];++a)switch(r){case" ":i+=1;break;case`
|
|
129
129
|
`:t=a,i=0;break;case"\r":{let o=this.buffer[a+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
130
130
|
`)break}default:break e}if(!r&&!this.atEnd)return this.setNext("block-scalar");if(i>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=i:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let a=this.continueScalar(t+1);if(a===-1)break;t=this.buffer.indexOf(`
|
|
131
131
|
`,a)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(r=this.buffer[n];r===" ";)r=this.buffer[++n];if(r===" "){for(;r===" "||r===" "||r==="\r"||r===`
|
|
132
132
|
`;)r=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let a=t-1,o=this.buffer[a];o==="\r"&&(o=this.buffer[--a]);let s=a;for(;o===" ";)o=this.buffer[--a];if(o===`
|
|
133
|
-
`&&a>=this.pos&&a+1+i>s)t=a;else break}while(!0);return yield
|
|
133
|
+
`&&a>=this.pos&&a+1+i>s)t=a;else break}while(!0);return yield Qt.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,i=this.pos-1,r=this.pos-1,n;for(;n=this.buffer[++r];)if(n===":"){let a=this.buffer[r+1];if(ie(a)||t&&Sr.has(a))break;i=r}else if(ie(n)){let a=this.buffer[r+1];if(n==="\r"&&(a===`
|
|
134
134
|
`?(r+=1,n=`
|
|
135
|
-
`,a=this.buffer[r+1]):i=r),a==="#"||t&&
|
|
136
|
-
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(t&&
|
|
135
|
+
`,a=this.buffer[r+1]):i=r),a==="#"||t&&Sr.has(a))break;if(n===`
|
|
136
|
+
`){let o=this.continueScalar(r+1);if(o===-1)break;r=Math.max(r,o-2)}}else{if(t&&Sr.has(n))break;i=r}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Qt.SCALAR,yield*this.pushToIndex(i+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,i){let r=this.buffer.slice(this.pos,t);return r?(yield r,this.pos+=r.length,r.length):(i&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil($a),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let i=this.flowLevel>0,r=this.charAt(1);if(ie(r)||i&&Sr.has(r)){i?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,i=this.buffer[t];for(;!ie(i)&&i!==">";)i=this.buffer[++t];return yield*this.pushToIndex(i===">"?t+1:t,!1)}else{let t=this.pos+1,i=this.buffer[t];for(;i;)if(lm.has(i))i=this.buffer[++t];else if(i==="%"&&nl.has(this.buffer[t+1])&&nl.has(this.buffer[t+2]))i=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
|
|
137
137
|
`?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`
|
|
138
|
-
`?yield*this.pushCount(2):0}*pushSpaces(t){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||t&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(t){let i=this.pos,r=this.buffer[i];for(;!t(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};
|
|
138
|
+
`?yield*this.pushCount(2):0}*pushSpaces(t){let i=this.pos-1,r;do r=this.buffer[++i];while(r===" "||t&&r===" ");let n=i-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=i),n}*pushUntil(t){let i=this.pos,r=this.buffer[i];for(;!t(r);)r=this.buffer[++i];return yield*this.pushToIndex(i,!1)}};al.Lexer=Oa});var Ba=g(ol=>{"use strict";var Da=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let i=0,r=this.lineStarts.length;for(;i<r;){let a=i+r>>1;this.lineStarts[a]<t?i=a+1:r=a}if(this.lineStarts[i]===t)return{line:i+1,col:1};if(i===0)return{line:0,col:t};let n=this.lineStarts[i-1];return{line:i,col:t-n+1}}}};ol.LineCounter=Da});var Ma=g(dl=>{"use strict";var dm=Ci("process"),sl=kr(),fm=Ha();function _e(e,t){for(let i=0;i<e.length;++i)if(e[i].type===t)return!0;return!1}function cl(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function ul(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function Er(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function dt(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Pr(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let i=0;i<t.length;++i)e.push(t[i])}function ll(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!_e(t.start,"explicit-key-ind")&&!_e(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,ul(t.value)?t.value.end?Pr(t.value.end,t.sep):t.value.end=t.sep:Pr(t.start,t.sep),delete t.sep)}var La=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new fm.Lexer,this.onNewLine=t}*parse(t,i=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let r of this.lexer.lex(t,i))yield*this.next(r);i||(yield*this.end())}*next(t){if(this.source=t,dm.env.LOG_TOKENS&&console.log("|",sl.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let i=sl.tokenType(t);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+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let r=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:r,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let i=t??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"&&ll(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&&cl(n.start)===-1&&(i.indent===0||n.start.every(a=>a.type!=="comment"||a.indent<i.indent))&&(r.type==="document"?r.end=n.start:r.items.push({start:n.start}),i.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{cl(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let i=Er(this.peek(2)),r=dt(i),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let 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(t){let i=t.items[t.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):t.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)t.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){
|
|
140
|
+
`,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let i=t.items[t.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):t.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)t.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Pr(n,i.start),n.push(this.sourceToken),t.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let r=!this.onKeyLine&&this.indent===t.indent,n=r&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind",a=[];if(n&&i.sep&&!i.value){let o=[];for(let s=0;s<i.sep.length;++s){let c=i.sep[s];switch(c.type){case"newline":o.push(s);break;case"space":break;case"comment":c.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(a=i.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||i.value?(a.push(this.sourceToken),t.items.push({start:a}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):n||i.value?(a.push(this.sourceToken),t.items.push({start:a,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)t.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:a,key:null,sep:[this.sourceToken]}]});else if(ul(i.key)&&!_e(i.sep,"newline")){let o=dt(i.start),s=i.key,c=i.sep;c.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:s,sep:c}]})}else a.length>0?i.sep=i.sep.concat(a,this.sourceToken):i.sep.push(this.sourceToken);else if(_e(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{let o=dt(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||n?t.items.push({start:a,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 o=this.flowScalar(this.type);n||i.value?(t.items.push({start:a,key:o,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(o):(Object.assign(i,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.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&&t.items.push({start:a});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let i=t.items[t.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):t.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Pr(n,i.start),n.push(this.sourceToken),t.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=t.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;i.value||_e(i.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>t.indent){let r=this.startBlockValue(t);if(r){this.stack.push(r);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let i=t.items[t.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(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?t.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?t.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?t.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?t.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":t.end.push(this.sourceToken);return}let r=this.startBlockValue(t);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===t.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=Er(r),a=dt(n);ll(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let s={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:a,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=s}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let i=this.source.indexOf(`
|
|
141
141
|
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
|
|
142
|
-
`,i)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=
|
|
142
|
+
`,i)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let i=Er(t),r=dt(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=Er(t),r=dt(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,i){return this.type!=="comment"||this.indent<=i?!1:t.every(r=>r.type==="newline"||r.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};dl.Parser=La});var vl=g(ei=>{"use strict";var fl=Ra(),hm=zt(),Zt=Ut(),pm=En(),mm=P(),vm=Ba(),hl=Ma();function pl(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new vm.LineCounter||null,prettyErrors:t}}function gm(e,t={}){let{lineCounter:i,prettyErrors:r}=pl(t),n=new hl.Parser(i?.addNewLine),a=new fl.Composer(t),o=Array.from(a.compose(n.parse(e)));if(r&&i)for(let s of o)s.errors.forEach(Zt.prettifyError(e,i)),s.warnings.forEach(Zt.prettifyError(e,i));return o.length>0?o:Object.assign([],{empty:!0},a.streamInfo())}function ml(e,t={}){let{lineCounter:i,prettyErrors:r}=pl(t),n=new hl.Parser(i?.addNewLine),a=new fl.Composer(t),o=null;for(let s of a.compose(n.parse(e),!0,e.length))if(!o)o=s;else if(o.options.logLevel!=="silent"){o.errors.push(new Zt.YAMLParseError(s.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return r&&i&&(o.errors.forEach(Zt.prettifyError(e,i)),o.warnings.forEach(Zt.prettifyError(e,i))),o}function wm(e,t,i){let r;typeof t=="function"?r=t:i===void 0&&t&&typeof t=="object"&&(i=t);let n=ml(e,i);if(!n)return null;if(n.warnings.forEach(a=>pm.warn(n.options.logLevel,a)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:r},i))}function ym(e,t,i){let r=null;if(typeof t=="function"||Array.isArray(t)?r=t:i===void 0&&t&&(i=t),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(e===void 0){let{keepUndefined:n}=i??t??{};if(!n)return}return mm.isDocument(e)&&!r?e.toString(i):new hm.Document(e,r,i).toString(i)}ei.parse=wm;ei.parseAllDocuments=gm;ei.parseDocument=ml;ei.stringify=ym});var ft=g(x=>{"use strict";var Nm=Ra(),bm=zt(),km=oa(),Fa=Ut(),Sm=At(),Te=P(),Em=Re(),Pm=j(),Rm=Ce(),xm=Ae(),Cm=kr(),Am=Ha(),_m=Ba(),Tm=Ma(),Rr=vl(),gl=Pt();x.Composer=Nm.Composer;x.Document=bm.Document;x.Schema=km.Schema;x.YAMLError=Fa.YAMLError;x.YAMLParseError=Fa.YAMLParseError;x.YAMLWarning=Fa.YAMLWarning;x.Alias=Sm.Alias;x.isAlias=Te.isAlias;x.isCollection=Te.isCollection;x.isDocument=Te.isDocument;x.isMap=Te.isMap;x.isNode=Te.isNode;x.isPair=Te.isPair;x.isScalar=Te.isScalar;x.isSeq=Te.isSeq;x.Pair=Em.Pair;x.Scalar=Pm.Scalar;x.YAMLMap=Rm.YAMLMap;x.YAMLSeq=xm.YAMLSeq;x.CST=Cm;x.Lexer=Am.Lexer;x.LineCounter=_m.LineCounter;x.Parser=Tm.Parser;x.parse=Rr.parse;x.parseAllDocuments=Rr.parseAllDocuments;x.parseDocument=Rr.parseDocument;x.stringify=Rr.stringify;x.visit=gl.visit;x.visitAsync=gl.visitAsync});import cv from"path";var ti=Et(ft(),1);import ht from"path";var ii=64*1024,Cr=1024,Ar=64,Va=5,Im=12e4,wl=6e5,jm=[".agents/skills/**",".amazonq/skills/**",".augment/skills/**",".bob/skills/**",".claude/skills/**",".cline/skills/**",".codebuddy/skills/**",".workbuddy/skills/**",".continue/skills/**",".cospec/skills/**",".crush/skills/**",".cursor/skills/**",".factory/skills/**",".forge/skills/**",".gemini/skills/**",".github/skills/**",".grok/skills/**",".iflow/skills/**",".junie/skills/**",".kilocode/skills/**",".kimi-code/skills/**",".kiro/skills/**",".lingma/skills/**",".mimocode/skills/**",".opencode/skills/**",".pi/skills/**",".qoder/skills/**",".qwen/skills/**",".roo/skills/**",".trae-cn/skills/**",".trae/skills/**",".windsurf/skills/**",".zcode/skills/**"],$m=["**/.idea/**","**/.vscode/**",".codex/skills/**","**/node_modules/**","**/.next/**","**/.nuxt/**","**/.output/**","**/.svelte-kit/**","**/.vite/**","**/.parcel-cache/**","**/.turbo/**","**/.nx/cache/**","**/dist/**","**/build/**","**/out/**","**/coverage/**","**/.nyc_output/**","**/target/**","**/.gradle/**","**/.cxx/**","**/.externalNativeBuild/**","**/captures/**","**/__pycache__/**","**/.pytest_cache/**","**/.mypy_cache/**","**/.ruff_cache/**","**/.tox/**","**/.nox/**","**/.venv/**","**/venv/**","**/obj/**","**/CMakeFiles/**","**/cmake-build-*/**","**/.cache/**","**/tmp/**","**/temp/**","**/logs/**","**/*.tsbuildinfo","**/*.log","**/.DS_Store","**/Thumbs.db"],Om=[...jm,...$m].sort((e,t)=>e.localeCompare(t,"en"));var G={include:["**/*"],exclude:[...Om],max_files:1e4,max_total_bytes:256*1024*1024,max_duration_ms:6e4},xr={en:{schema:"# Configuration schema used by Comet. Do not edit this value.",default_workflow:"# Default workflow entered by /comet. Must also appear in workflows.",workflows:"# Workflows enabled in this project: native, classic, or both.",ambient_resume:`# Enables automatic recovery through the read-only Ambient Resume probe for both Native and Classic. Set false to disable it.
|
|
143
143
|
# ambient_resume: true | false`,hook:"# Hook write policy shared by Native and Classic. Paths are project-relative.","hook.allow_paths":"# Project-relative directories allowed during guarded phases. Use one path per list item; empty by default.",native:"# Native workflow settings. They do not change Classic state or behavior.","native.artifact_root":"# Root directory where Native stores Comet specs and changes. Runtime data stays under .comet.","native.language":`# Artifact language used by Native workflow documents.
|
|
144
144
|
# language: en | zh-CN`,"native.clarification_mode":`# Controls how Native asks clarifying questions: batch asks every currently answerable question per round (default), sequential asks one at a time.
|
|
145
145
|
# clarification_mode: batch | sequential`,"native.archive_confirmation":`# Controls whether Native archives automatically after a successful preview or waits for explicit user confirmation.
|
|
146
|
-
# archive_confirmation: automatic | required`,"native.max_verify_failures":"# Maximum failed Verify outcomes allowed for one confirmed acceptance target before Native stops the completion loop.","native.snapshot":"# Controls the auditable project scope and bounded work used by Native content snapshots.","native.snapshot.include":"# Selects the project-relative paths included in Native snapshots. Patterns use / and support *, **, and ?.","native.snapshot.exclude":"# Removes paths from the included scope. Exclusions are bound into each new change baseline.","native.snapshot.max_files":"# Bounds the number of files captured by one snapshot. Increase it for large monorepos.","native.snapshot.max_total_bytes":"# Bounds the total file content hashed by one snapshot. Content is streamed and does not depend on Git hashes.","native.snapshot.max_duration_ms":"# Bounds snapshot capture time in milliseconds. Increase it together with the byte budget on slower or larger repositories.",classic:"# Classic workflow settings. They do not change Native state or behavior.","classic.artifact_layout":`# Selects the Classic artifact layout. The default is docs; update preserves detected root-level legacy artifacts.
|
|
146
|
+
# archive_confirmation: automatic | required`,"native.max_verify_failures":"# Maximum failed Verify outcomes allowed for one confirmed acceptance target before Native stops the completion loop.","native.finish":"# Optional repository-owned finish providers. Native keeps commit, push, generic remote verification, and recovery ownership.","native.snapshot":"# Controls the auditable project scope and bounded work used by Native content snapshots.","native.snapshot.include":"# Selects the project-relative paths included in Native snapshots. Patterns use / and support *, **, and ?.","native.snapshot.exclude":"# Removes paths from the included scope. Exclusions are bound into each new change baseline.","native.snapshot.max_files":"# Bounds the number of files captured by one snapshot. Increase it for large monorepos.","native.snapshot.max_total_bytes":"# Bounds the total file content hashed by one snapshot. Content is streamed and does not depend on Git hashes.","native.snapshot.max_duration_ms":"# Bounds snapshot capture time in milliseconds. Increase it together with the byte budget on slower or larger repositories.",classic:"# Classic workflow settings. They do not change Native state or behavior.","classic.artifact_layout":`# Selects the Classic artifact layout. The default is docs; update preserves detected root-level legacy artifacts.
|
|
147
147
|
# artifact_layout: legacy | docs`,"classic.language":`# Artifact language used by Classic workflow documents.
|
|
148
148
|
# language: en | zh-CN`,"classic.context_compression":`# Controls beta context compression for new Classic changes.
|
|
149
149
|
# context_compression: off | beta`,"classic.review_mode":`# Sets the default review depth for new Classic changes.
|
|
@@ -152,39 +152,39 @@ ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.pus
|
|
|
152
152
|
# ambient_resume: true | false`,hook:"# Native 和 Classic 共享的 Hook 写入策略;路径必须是项目相对路径。","hook.allow_paths":"# 在受保护阶段允许写入的项目相对目录;每项填写一个目录,默认为空。",native:"# Native 工作流配置,不会改变 Classic 的状态或行为。","native.artifact_root":"# Native 规格和 change 的存放根目录;运行时数据始终位于 .comet。","native.language":`# Native 工作流文档使用的产物语言。
|
|
153
153
|
# 可选值:en | zh-CN`,"native.clarification_mode":`# Native 提问澄清问题的方式:batch 每轮一次提出当前所有可回答的问题(默认),sequential 每轮只问一个。
|
|
154
154
|
# 可选值:batch | sequential`,"native.archive_confirmation":`# Native 归档检查成功后自动归档,或等待用户明确确认。
|
|
155
|
-
# 可选值:automatic | required`,"native.max_verify_failures":"# 同一个已确认验收目标最多允许的 Verify 失败次数;达到上限后停止完成循环。","native.snapshot":"# Native 内容快照使用的可审计项目范围与有界工作预算。","native.snapshot.include":"# Native 快照纳入的项目相对路径;模式使用 /,支持 *、** 和 ?。","native.snapshot.exclude":"# 从纳入范围中排除路径;新 change 会把排除策略绑定到 baseline。","native.snapshot.max_files":"# 单次快照最多捕获的文件数;大型 monorepo 可按需提高。","native.snapshot.max_total_bytes":"# 单次快照最多哈希的文件内容总字节数;内容采用流式读取,不依赖 Git hash。","native.snapshot.max_duration_ms":"# 单次快照的最长执行时间(毫秒);较慢或更大的仓库应与字节预算一并提高。",classic:"# Classic 工作流配置,不会改变 Native 的状态或行为。","classic.artifact_layout":`# Classic 产物布局;默认使用 docs,update 检测到根目录 legacy 产物时予以保留。
|
|
155
|
+
# 可选值:automatic | required`,"native.max_verify_failures":"# 同一个已确认验收目标最多允许的 Verify 失败次数;达到上限后停止完成循环。","native.finish":"# 可选的仓库自有收尾 provider;提交、推送、通用远端核验和恢复仍由 Native 负责。","native.snapshot":"# Native 内容快照使用的可审计项目范围与有界工作预算。","native.snapshot.include":"# Native 快照纳入的项目相对路径;模式使用 /,支持 *、** 和 ?。","native.snapshot.exclude":"# 从纳入范围中排除路径;新 change 会把排除策略绑定到 baseline。","native.snapshot.max_files":"# 单次快照最多捕获的文件数;大型 monorepo 可按需提高。","native.snapshot.max_total_bytes":"# 单次快照最多哈希的文件内容总字节数;内容采用流式读取,不依赖 Git hash。","native.snapshot.max_duration_ms":"# 单次快照的最长执行时间(毫秒);较慢或更大的仓库应与字节预算一并提高。",classic:"# Classic 工作流配置,不会改变 Native 的状态或行为。","classic.artifact_layout":`# Classic 产物布局;默认使用 docs,update 检测到根目录 legacy 产物时予以保留。
|
|
156
156
|
# 可选值:legacy | docs`,"classic.language":`# Classic 工作流文档使用的产物语言。
|
|
157
157
|
# 可选值:en | zh-CN`,"classic.context_compression":`# 新建 Classic change 是否启用 beta 上下文压缩。
|
|
158
158
|
# 可选值:off | beta`,"classic.review_mode":`# 新建 Classic change 默认使用的审查深度。
|
|
159
159
|
# 可选值:off | standard | thorough`,"classic.auto_transition":`# Classic 阶段通过后是否自动进入下一阶段。
|
|
160
|
-
# 可选值:true | false`}};function
|
|
161
|
-
`)){let o=
|
|
160
|
+
# 可选值:true | false`}};function Nl(e,t){return xr[t][e]}function Hm(e,t,i){let r=/^(\s*)([a-z_]+):/u.exec(e);if(!r)return null;let n=r[1].length,a=r[2];if(n===0&&a in xr.en)return a;if(n===2&&t){let o=`${t}.${a}`;if(o in xr.en)return o}if(n===2&&t===null&&a==="hook")return"hook";if(n===2&&t==="hook"&&a==="allow_paths")return"hook.allow_paths";if(n===4&&t==="native"&&i==="snapshot"){let o=`native.snapshot.${a}`;if(o in xr.en)return o}return null}function ri(e,t){let i=[],r=null,n=null;for(let a of(0,ti.stringify)(e).trimEnd().split(`
|
|
161
|
+
`)){let o=Hm(a,r,n);if(o){let s=a.match(/^\s*/u)?.[0]??"";for(let c of Nl(o,t).split(`
|
|
162
162
|
`))i.push(`${s}${c}`)}i.push(a),/^[a-z_]+:/u.test(a)?(a.startsWith("native:")?r="native":a.startsWith("classic:")?r="classic":a.startsWith("hook:")?r="hook":r=null,n=null):/^ {2}[a-z_]+:/u.test(a)&&r==="native"&&(n=a.startsWith(" snapshot:")?"snapshot":null)}return i.push(""),i.join(`
|
|
163
|
-
`)}function $m(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim();if(i.length===0||Rr.posix.isAbsolute(i)||Rr.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return r}function Je(e){let t=$m(e,"native.artifact_root");return t.length===0?".":t.join("/")}function yl(e,t="docs"){let i=e??t;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function Ar(e,t,i=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim().replaceAll("\\","/");if(r.length===0||Rr.posix.isAbsolute(r)||Rr.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be relative to its declared path base`);let n=r.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(r))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function ft(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function Nl(e,t,i){let r=e??t;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function qa(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>xr)throw new Error(`${t} exceeds ${xr} characters`);let i=0;for(let r=0;r<e.length;r+=1)e[r]==="?"?i+=1:e[r]==="*"&&(i+=1,e[r+1]==="*"&&(r+=1));if(i>Cr)throw new Error(`${t} contains more than ${Cr} wildcard tokens`);return e}function gl(e,t,i){if(e===void 0)return[...i];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(r=>qa(r,t)))].sort((r,n)=>r.localeCompare(n,"en"))}function Fa(e,t,i){let r=e??t;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Om(e){if(e===void 0)return{...G,include:[...G.include],exclude:[...G.exclude]};let t=ft(e,"native.snapshot");return{include:gl(t.include,"native.snapshot.include",G.include),exclude:gl(t.exclude,"native.snapshot.exclude",G.exclude),max_files:Fa(t.max_files,G.max_files,"native.snapshot.max_files"),max_total_bytes:Fa(t.max_total_bytes,G.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:Fa(t.max_duration_ms,G.max_duration_ms,"native.snapshot.max_duration_ms")}}function Hm(e){if(e===void 0)return;let t=ft(e,"native.pending_root_move"),i=t.id,r=t.from_artifact_root,n=t.to_artifact_root,a=t.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(t.cleanup!==void 0){let s=ft(t.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,u=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:u}}return{id:i,fromArtifactRoot:Je(r),toArtifactRoot:Je(n),stage:a,...o?{cleanup:o}:{}}}function Dm(e,t={}){let i=ft(e,"native"),r=i.artifact_root??(t.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=i.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=i.max_verify_failures??Va;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Hm(i.pending_root_move);return{artifact_root:Je(r),language:Nl(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Om(i.snapshot),...s?{pending_root_move:s}:{}}}function Bm(e){let t=ft(e,"classic"),i=t.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=t.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:yl(t.artifact_layout),language:Nl(t.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Lm(e){let i=ft(e,"hook").allow_paths??[];if(!Array.isArray(i))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(i.map((r,n)=>Ar(r,`hook.allow_paths[${n}]`)))]}}function Mm(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function Fm(e,t,i,r,n,a){let o=e.schema!==void 0;if(!(o||e.default_workflow!==void 0||e.workflows!==void 0||!a.allowPartialProject&&e.native!==void 0)||a.allowPartialProject&&!o)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let c=e.workflows??[e.default_workflow];if(!Array.isArray(c)||c.length===0||c.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let l=[...new Set(c)];if(!l.includes(e.default_workflow))throw new Error("workflows must include default_workflow");if(l.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:l,ambient_resume:n,...t?{hook:t}:{},...i?{native:i}:{},...r?{classic:r}:{}}}function ht(e,t={}){let i=(0,ei.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,a=Mm(n.ambient_resume),o=n.hook===void 0?void 0:Lm(n.hook),s=n.native===void 0?void 0:Dm(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),c=n.classic===void 0?void 0:Bm(n.classic),l=Fm(n,o,s,c,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:l,ambient_resume:a,...o?{hook:o}:{},...s?{native:s}:{},...c?{classic:c}:{}}}function bl(e){return{id:e.id,from_artifact_root:e.fromArtifactRoot,to_artifact_root:e.toArtifactRoot,stage:e.stage,...e.cleanup?{cleanup:{kind:e.cleanup.kind,state:e.cleanup.state,manifest_hash:e.cleanup.manifestHash}}:{}}}function kl(e){return{schema:e.schema,default_workflow:e.default_workflow,workflows:e.workflows??[e.default_workflow],ambient_resume:e.ambient_resume,...e.hook?{hook:{allow_paths:[...e.hook.allow_paths]}}:{},...e.native?{native:{artifact_root:e.native.artifact_root,language:e.native.language,clarification_mode:e.native.clarification_mode,archive_confirmation:e.native.archive_confirmation,max_verify_failures:e.native.max_verify_failures,...e.native.pending_root_move?{pending_root_move:bl(e.native.pending_root_move)}:{}}}:{},...e.classic?{classic:{artifact_layout:e.classic.artifact_layout,language:e.classic.language,context_compression:e.classic.context_compression,review_mode:e.classic.review_mode,auto_transition:e.classic.auto_transition}}:{}}}function dt(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ri(e,t){let i=kl(t),r=ht((0,ei.stringify)(i)).config;if(!r)throw new Error("Unsupported Comet project schema");let n={...e,schema:r.schema,default_workflow:r.default_workflow,workflows:r.workflows,ambient_resume:r.ambient_resume};if(r.hook&&(n.hook={...dt(e.hook),allow_paths:[...r.hook.allow_paths]}),r.native){let a=dt(e.native),o={...a,artifact_root:r.native.artifact_root,language:r.native.language,clarification_mode:r.native.clarification_mode,archive_confirmation:r.native.archive_confirmation,max_verify_failures:r.native.max_verify_failures};if(delete o.snapshot,r.native.pending_root_move){let s=dt(a.pending_root_move),c=bl(r.native.pending_root_move),l=dt(s.cleanup),u=dt(c.cleanup);o.pending_root_move={...s,...c,...c.cleanup?{cleanup:{...l,...u}}:{}}}else delete o.pending_root_move;n.native=o}return r.classic&&(n.classic={...dt(e.classic),artifact_layout:r.classic.artifact_layout,language:r.classic.language,context_compression:r.classic.context_compression,review_mode:r.classic.review_mode,auto_transition:r.classic.auto_transition}),n}function _r(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:Je(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Va,snapshot:{...G,include:[...G.include],exclude:[...G.exclude]}}}}import{createHash as qm}from"crypto";import{promises as jr}from"fs";import Ie from"path";import{constants as Tr,promises as Ge}from"fs";function Te(e){return e!==0&&e!==0n&&e!=="0"}function U(e,t){return Te(e.dev)&&Te(t.dev)&&Te(e.ino)&&Te(t.ino)}function T(e,t){let i=Te(e.dev)&&Te(t.dev);if(i&&e.dev!==t.dev)return!1;let r=Te(e.ino)&&Te(t.ino);return r&&e.ino!==t.ino?!1:i&&r?!0:e.birthtime===t.birthtime}var ne=class extends Error{reason;constructor(t,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=t}};function Wa(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function Sl(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function ni(e){return{dev:e.dev,ino:e.ino,birthtime:Wa(e)}}function Ir(e,t){let i=ni(e),r=ni(t);return U(i,r)?T(i,r):T(i,r)&&Wa(e)===Wa(t)&&Sl(e)===Sl(t)&&e.size===t.size}async function pt(e,t,i={}){if(!Number.isSafeInteger(t)||t<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,a=await Ge.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new ne("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new ne("too-large",`${r} exceeds ${t} bytes`);let o=await Ge.realpath(e);await i.verify?.("pre-open",{realPath:o,identity:ni(a)});let s=process.platform==="win32"?Tr.O_RDONLY:Tr.O_RDONLY|Tr.O_NOFOLLOW|Tr.O_NONBLOCK,c;try{c=await Ge.open(e,s)}catch(l){throw l.code==="ELOOP"?new ne("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),Ge.lstat(e,{bigint:n}),Ge.realpath(e)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!Ir(a,l)||!Ir(a,u))throw new ne("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:d,identity:ni(l)}),await i.hooks?.afterOpen?.();let f=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let y=t+1-p,{bytesRead:b}=await c.read(v,0,Math.min(v.length,y),null);if(b===0)break;if(p+=b,p>t)throw new ne("too-large",`${r} exceeds ${t} bytes`);f.push(Buffer.from(v.subarray(0,b)))}await i.hooks?.beforeFinalCheck?.();let[h,m,w]=await Promise.all([c.stat({bigint:n}),Ge.lstat(e,{bigint:n}),Ge.realpath(e)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!Ir(a,h)||!Ir(a,m))throw new ne("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:w,identity:ni(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:w}}finally{await c.close()}}function Vm(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function za(e,t){let i=Ie.relative(e,t);return i===""||!Ie.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Ie.sep}`)}async function El(e,t){let i=Ie.resolve(e),r=await jr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return jr.realpath(i)}async function Pl(e,t,i,r){let n=e;for(let a=0;a<i.length;a++){n=Ie.join(n,i[a]);let o;try{o=await jr.lstat(n)}catch(u){if(Vm(u))return{exists:!1,kind:"missing"};throw u}let s=Ie.relative(e,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=a===i.length-1;if(!c&&!o.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!o.isFile()||r.expected==="directory"&&!o.isDirectory()||r.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await jr.realpath(n);if(!za(t,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function mt(e,t,i){let r=Ar(t,i.label),n=Ie.resolve(e),a=await El(n,i.label),o=r.split("/"),s=Ie.resolve(n,...o);if(!za(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await Pl(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function je(e,t,i,r){let n=await mt(e,t,{label:r.label,expected:"file"});if(!n.exists){let o=new Error(`${r.label} does not exist`);throw o.code="ENOENT",o}let a=await El(n.projectRoot,r.label);return pt(n.target,i,{...r,verify:async(o,s)=>{if(!za(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await Pl(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var ai=".comet/config.yaml";function Ja(e,t){return e.exists===t.exists&&e.sha256===t.sha256}function Wm(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function $r(e,t={}){return(await oi(e,t)).document}async function Rl(e){try{return(await je(e,ai,ti,{label:ai})).bytes}catch(t){if(Wm(t))return null;throw t}}function xl(e){return e?{exists:!0,sha256:qm("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function Or(e){return xl(await Rl(e))}async function oi(e,t={}){let i=await Rl(e);return{document:i?ht(i.toString("utf8"),t):null,identity:xl(i)}}async function Ga(e){return(await $r(e))?.config??null}var PN=16*1024;async function Ua(e,t){if(!t)return;let i=await Or(e);if(!Ja(i,t))throw new Error("Project config changed before commit; rerun the operation")}import{randomUUID as Um}from"crypto";import{promises as M}from"fs";import ae from"path";function Ya(e,t){let i=ae.relative(e,t);return i===""||!ae.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ae.sep}`)}function Km(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Ka(e,t){let i={...e,birthtime:e.birthtimeMs},r={...t,birthtime:t.birthtimeMs};return U(i,r)?T(i,r):T(i,r)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function Cl(e){let t=await M.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await M.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function ci(e){for(let t of e){let i=await M.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Km(t,i)||await M.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function Ym(e,t){let i=ae.resolve(e),r=ae.resolve(t);if(!Ya(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await Cl(i)],a=ae.relative(i,r).split(ae.sep).filter(Boolean),o=i;for(let s of a){await ci(n),o=ae.join(o,s);try{await M.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await Cl(o);if(!Ya(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await ci(n),n}async function Xm(e){let t;try{t=await M.open(e,"r"),await t.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await t?.close()}}async function Al(e,t,i={}){let r=ae.dirname(e),n=i.containedRoot?await Ym(i.containedRoot,r):null;n||await M.mkdir(r,{recursive:!0});let a=ae.join(r,`.${ae.basename(e)}.${Um()}.tmp`),o,s;try{if(await i.beforeTemporaryOpen?.(),o=await M.open(a,"wx"),s=await o.stat(),n){let[c,l]=await Promise.all([M.lstat(a),M.realpath(a)]);if(await ci(n),!c.isFile()||c.isSymbolicLink()||!Ka(s,c)||!Ya(n[0].realPath,l))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),!Ka(s,await o.stat()))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await ci(n);let c=await M.lstat(a);if(!c.isFile()||c.isSymbolicLink()||!s||!Ka(c,s))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await M.link(a,e),await M.unlink(a)):await M.rename(a,e),await Xm(r)}catch(c){if(await o?.close(),!n)await M.rm(a,{force:!0});else try{await ci(n),await M.rm(a,{force:!0})}catch{}throw c}}async function z(e,t,i={}){await Al(e,t,i)}async function _l(e,t,i={}){await Al(e,t,i)}async function X(e,t,i={}){await z(e,JSON.stringify(t,null,2)+`
|
|
164
|
-
`,i)}import{existsSync as
|
|
165
|
-
`,"utf8"),await i.sync(),Ll(await i.stat({bigint:!0}))}finally{await i.close()}}async function dv(e,t){let i=await $(e.runtimeDir,e.locksDir);await Q.mkdir(i,{recursive:!0});let r=await $(e.runtimeDir,V.join(i,Bl));await Q.mkdir(r,{recursive:!0});let n=Ml(t),a=V.join(r,`.${n.id}.tmp`),o=V.join(r,`${n.id}.claim`);try{let s=await Fl(a,n);await Q.rename(a,o);let c=await Oe(o);if(!c||!eo(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await Q.rm(a,{force:!0})}}async function fv(e){let t=V.dirname(e.file),i=!1,r=V.basename(e.file);for(let n of await Q.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=V.join(t,n.name);if(V.resolve(a)!==V.resolve(e.file))try{let o=await Oe(a),s=lv(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await io(o,t);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function Vl(e){let t=await Oe(e.file);if(t){if(t.owner.id!==e.owner.id||!to(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await io(t,V.dirname(e.file))}}async function hv(e,t){let i=Date.now()+av;for(;;){let r=await dv(e,t);if(!await fv(r))return r;if(await Vl(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function pv(e){let t=Br.get(e)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=t.then(()=>r);return Br.set(e,n),await t,()=>{i(),Br.get(e)===n&&Br.delete(e)}}async function ql(e,t,i){let r=V.resolve(e.locksDir),n=Ol.getStore();if(n?.has(r))return i();let a=await pv(r);try{let o=await hv(e,t),s=new Map(n??[]);return s.set(r,o),await Ol.run(s,async()=>{try{return await i()}finally{await Vl(o)}})}finally{a()}}async function ui(e,t,i){return ql(e,`acquire ${t}`,async()=>{let r=await $(e.runtimeDir,e.locksDir);await Q.mkdir(r,{recursive:!0});let n=await $(e.runtimeDir,V.join(r,ov(t))),a=Ml(i),o=await Fl(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:r,owner:a,identity:o}})}async function di(e){await Oe(e.file)&&await ql({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${V.basename(e.file)}`,async()=>{let t=await Oe(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!to(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let i=V.join(e.locksDir,Bl);await io(t,i)})}function mv(e){try{return process.kill(e,0),!0}catch(t){let i=t.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}import{createHash as vv}from"node:crypto";import{constants as Lr,promises as R}from"node:fs";import _ from"node:path";function pe(e,t){let i=_.relative(e,t);return i===""||!_.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${_.sep}`)}function Wl(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function Mr(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function zl(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function wt(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Ke(e,t){let i=await R.lstat(e);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await R.realpath(e),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function fi(e,t,i){let r=_.resolve(e),n=_.resolve(t);if(!pe(r,n))throw new Error(`${i} is outside its managed root`);let a=[await Ke(r,i)],o=r;for(let s of _.relative(r,n).split(_.sep).filter(Boolean)){await L(a,i),o=_.join(o,s);let c=await Ke(o,i);if(!pe(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await L(a,i),a}async function L(e,t){for(let i of e){let r=await R.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!Mr(i,r)||await R.realpath(i.path)!==i.realPath)throw new Error(`${t} parent changed during I/O: ${i.path}`)}}async function gv(e,t,i){let r=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let o=t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>t)throw new Error(`${i} exceeds ${t} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function J(e){let t=Wl(e.maxBytes),i=_.resolve(e.file),r=await fi(e.root,_.dirname(i),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(u=>Ke(_.resolve(u),e.label)));await e.hooks?.afterParentChainCaptured?.(),await L(r,e.label);let a=await R.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=zl(a),s=await R.realpath(i);if(!pe(r[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(u=>pe(u.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let c=process.platform==="win32"?Lr.O_RDONLY:Lr.O_RDONLY|Lr.O_NOFOLLOW|Lr.O_NONBLOCK,l=await R.open(i,c);try{let u=await l.stat();await e.hooks?.afterOpen?.();let[d,f]=await Promise.all([R.lstat(i),R.realpath(i)]);if(await L(r,e.label),await L(n,e.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!wt(o,u)||!wt(o,d))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let p=await gv(l,t,e.label);await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),R.lstat(i),R.realpath(i)]);if(await L(r,e.label),await L(n,e.label),!h.isFile()||h.isSymbolicLink()||m!==s||!wt(o,v)||!wt(o,h))throw new Error(`${e.label} changed while reading`);return{bytes:p,hash:vv("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}async function Ye(e){let t=await fi(e.root,e.directory,e.label),i;if(e.maxEntries===void 0)i=await R.readdir(e.directory,{withFileTypes:!0});else{let r=Wl(e.maxEntries);i=[];let n=await R.opendir(e.directory);try{for await(let a of n)if(i.push(a),i.length>r)throw new Error(`${e.label} exceeds ${r} entries`)}finally{await n.close().catch(a=>{if(a.code!=="ERR_DIR_CLOSED")throw a})}}return await L(t,e.label),{entries:i,verify:()=>L(t,e.label)}}async function wv(e){let t=_.resolve(e.directory),i=_.resolve(e.quarantine);if(_.dirname(i)!==_.dirname(t)||!pe(_.resolve(e.root),i)||i===t)throw new Error(`${e.label} quarantine must be a distinct sibling inside its root`);let r=await fi(e.root,_.dirname(t),e.label),n=await Ke(t,e.label);if(!pe(r[0].realPath,n.realPath))throw new Error(`${e.label} resolves outside its managed root`);await e.beforeQuarantine?.(),await L(r,e.label);let a=await R.lstat(t);if(!a.isDirectory()||a.isSymbolicLink()||!Mr(n,a)||await R.realpath(t)!==n.realPath)throw new Error(`${e.label} changed before quarantine`);try{throw await R.lstat(i),new Error(`${e.label} quarantine path is occupied`)}catch(s){if(s.code!=="ENOENT")throw s}await R.rename(t,i),await L(r,e.label);let o=await R.lstat(i);if(!o.isDirectory()||o.isSymbolicLink()||!Mr(n,o))throw new Error(`${e.label} changed while quarantining`);await e.afterQuarantine?.(i);try{throw await R.lstat(t),new Error(`${e.label} path was recreated while quarantining`)}catch(s){if(s.code!=="ENOENT")throw s}return{quarantine:i,parentChain:r,identity:n}}async function Jl(e){await wv(e)}async function ro(e){let t=_.resolve(e.file),i=await fi(e.root,_.dirname(t),e.label),r=await R.lstat(t);if(!r.isFile()||r.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);let n=zl(r),a=await R.realpath(t);if(!pe(i[0].realPath,a))throw new Error(`${e.label} resolves outside its managed root`);let o=await J({root:e.root,file:t,maxBytes:e.maxBytes,label:e.label});if(o.hash!==e.expectedHash||o.size!==e.expectedSize)throw new Error(`${e.label} changed before removal`);let[s,c]=await Promise.all([R.lstat(t),R.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!wt(n,s)||c!==a)throw new Error(`${e.label} changed while verifying removal`);await e.beforeRemove?.(),await L(i,e.label);let[l,u]=await Promise.all([R.lstat(t),R.realpath(t)]);if(!l.isFile()||l.isSymbolicLink()||!wt(n,l)||u!==a)throw new Error(`${e.label} changed before removal`);await R.rm(t),await L(i,e.label)}async function no(e){let t=_.resolve(e.directory),i=await fi(e.root,_.dirname(t),e.label),r=await Ke(t,e.label);if(!pe(i[0].realPath,r.realPath))throw new Error(`${e.label} resolves outside its managed root`);await e.beforeRemove?.(),await L(i,e.label);let n=await R.lstat(t);if(!n.isDirectory()||n.isSymbolicLink()||!Mr(r,n)||await R.realpath(t)!==r.realPath)throw new Error(`${e.label} changed before removal`);await R.rmdir(t),await L(i,e.label)}async function hi(e){let t=_.resolve(e.root),i=_.resolve(e.directory);if(!pe(t,i))throw new Error(`${e.label} is outside its managed root`);let r=[await Ke(t,e.label)],n=t;for(let a of _.relative(t,i).split(_.sep).filter(Boolean)){await L(r,e.label),n=_.join(n,a);try{await R.mkdir(n)}catch(s){if(s.code!=="EEXIST")throw s}let o=await Ke(n,e.label);if(!pe(r[0].realPath,o.realPath))throw new Error(`${e.label} resolves outside its managed root: ${n}`);r.push(o)}await L(r,e.label)}async function pi(e){let t=await J({root:e.sourceRoot,file:e.source,maxBytes:e.maxBytes,label:e.label,hooks:e.hooks,forbiddenRoots:e.forbiddenRoots});if(e.expectedHash!==void 0&&t.hash!==e.expectedHash)throw new Error(`${e.label} content changed before copy`);await _l(e.target,t.bytes,{containedRoot:e.targetRoot,exclusive:e.exclusive,beforeCommit:async()=>{if(await e.hooks?.beforeTargetCommit?.(),e.expectedTargetHash===void 0)return;if(e.expectedTargetHash===null){try{await R.lstat(e.target)}catch(n){if(n.code==="ENOENT")return;throw n}throw new Error(`${e.label} target changed before commit`)}if((await J({root:e.targetRoot,file:e.target,maxBytes:e.maxBytes,label:`${e.label} existing target`})).hash!==e.expectedTargetHash)throw new Error(`${e.label} target changed before commit`)}});let i=await J({root:e.targetRoot,file:e.target,maxBytes:e.maxBytes,label:`${e.label} target`});if(i.hash!==t.hash||i.size!==t.size)throw new Error(`${e.label} target could not be verified`);return i}import{promises as Vr}from"fs";import ye from"path";import{TextDecoder as yv}from"util";var Nv=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),bv=new Set(["id","type","source","target","staged","backup"]),kv=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Sv=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]),Ev=new Set(["sequence","timestamp","type","operationId"]),Kl=new Set(["prepared","applying","committed","rolling-back","rolled-back"]),Yl=new Set(["prepared","operation-started","operation-completed","archive-finalization-started","archive-finalized","commit","rollback-started","rollback-completed"]),Pv=256*1024,Rv=1024*1024,Xl=16*1024,qr=1024,kb=64*1024*1024;var Ql=new yv("utf-8",{fatal:!0});function mi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function vi(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function Nt(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function ao(e,t){if(typeof e!="string"||e.length===0||ye.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function Fr(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function Gl(e,t){if(ao(e,t),e.includes("\\")||e!==ye.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function xv(e,t){let i=mi(e,`transaction operations[${t}]`);if(vi(i,bv,`transaction operations[${t}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${t}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);ao(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&ao(i[r],`transaction operation ${i.id} ${r}`);if(i.type==="write"){if(i.staged===void 0||i.source!==void 0)throw new Error(`write operation ${i.id} requires staged and forbids source`)}else if(i.type==="remove"){if(i.source!==void 0||i.staged!==void 0)throw new Error(`remove operation ${i.id} forbids source and staged`)}else if(i.source===void 0||i.staged!==void 0||i.backup!==void 0)throw new Error(`move operation ${i.id} requires source and forbids staged and backup`);return i}function Zl(e){let t=mi(e,"Native Archive transaction journal");if(vi(t,kv,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!Kl.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!Nt(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(Fr(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let i=t.operations.map((s,c)=>{let l=mi(s,`Archive transaction operations[${c}]`);if(vi(l,Sv,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);Gl(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&Gl(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&Fr(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(Fr(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);Fr(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),r=i.map(s=>s.id);if(new Set(r).size!==r.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${t.id}`,a=i.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.change}$`,"u").test(a[0].target)||i.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of i.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:i}}function oo(e){let t=mi(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return Zl(t);if(vi(t,Nv,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!Kl.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!ye.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!ye.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!Nt(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let i=t.operations.map(xv),r=i.map(n=>n.id);if(new Set(r).size!==r.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:i}}function eu(e,t){let i=mi(e,`Native transaction event at line ${t}`);if(vi(i,Ev,`Native transaction event at line ${t}`),i.sequence!==t)throw new Error(`Native transaction event sequence at line ${t} must be ${t}`);if(!Nt(i.timestamp))throw new Error(`Native transaction event timestamp at line ${t} is invalid`);if(typeof i.type!="string"||!Yl.has(i.type))throw new Error(`Native transaction event type at line ${t} is invalid`);let r=i.type==="operation-started"||i.type==="operation-completed";if(r&&(typeof i.operationId!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.operationId)||Buffer.byteLength(i.operationId,"utf8")>256)||!r&&i.operationId!==void 0)throw new Error(`Native transaction event operationId at line ${t} is invalid`);return{sequence:i.sequence,timestamp:i.timestamp,type:i.type,...typeof i.operationId=="string"?{operationId:i.operationId}:{}}}function Cv(e){if(e.length>24)return!1;let t="0000-00-00T00:00:00.000Z";for(let r=0;r<e.length;r+=1){let n=t[r],a=e[r];if(n==="0"){if(!/[0-9]/u.test(a))return!1}else if(a!==n)return!1}let i=[[5,2,1,12],[8,2,1,31],[11,2,0,23],[14,2,0,59],[17,2,0,59],[20,3,0,999]];for(let[r,n,a,o]of i){if(e.length<=r)continue;let s=e.slice(r,Math.min(r+n,e.length));if(!Array.from({length:o-a+1},(l,u)=>String(a+u).padStart(n,"0")).some(l=>l.startsWith(s)))return!1}return e.length>=10&&!Nt(`${e.slice(0,10)}T00:00:00.000Z`)?!1:e.length<24||Nt(e)}function yt(e,t){return e.length<t.length&&t.startsWith(e)}function Av(e){let t='","operationId":"';if(yt(e,t))return!0;if(!e.startsWith(t))return!1;let i=e.slice(t.length),r=i.indexOf('"');if(r===-1)return i.length===0||/^[a-z0-9][a-z0-9-]*$/u.test(i);let n=i.slice(0,r);return/^[a-z0-9][a-z0-9-]*$/u.test(n)?yt(i.slice(r),'"}'):!1}function _v(e,t){if(e.length===0||Buffer.byteLength(e,"utf8")>Xl)return!1;let i=`{"sequence":${t},"timestamp":"`;if(yt(e,i))return!0;if(!e.startsWith(i))return!1;let r=e.slice(i.length),n=r.slice(0,Math.min(24,r.length));if(!Cv(n))return!1;if(r.length<24)return!0;if(!Nt(n))return!1;let a='","type":"',o=r.slice(24);if(yt(o,a))return!0;if(!o.startsWith(a))return!1;let s=o.slice(a.length);for(let c of Yl){if(yt(s,c))return!0;if(!s.startsWith(c))continue;let l=s.slice(c.length);if(c==="operation-started"||c==="operation-completed"){if(Av(l))return!0}else if(yt(l,'"}'))return!0}return!1}function Tv(e,t){if(e.length===0)throw new Error("Blank transaction event line");if(Buffer.byteLength(e,"utf8")>Xl)throw new Error(`Native transaction event at line ${t} is too large`);return eu(JSON.parse(e),t)}function Iv(e){let t=e.split(`
|
|
166
|
-
`),i=t.at(-1)==="";if(i&&t.pop(),t.length>
|
|
163
|
+
`)}function Dm(e,t){if(typeof e!="string")throw new Error(`${t} must be a string`);let i=e.trim();if(i.length===0||ht.posix.isAbsolute(i)||ht.win32.isAbsolute(i)||/^(?:~|[\\/])/u.test(i))throw new Error(`${t} must be a project-relative path`);if(i===".")return[];let r=i.replaceAll("\\","/").split("/");if(r.some(n=>n===".."))throw new Error(`${t} must stay inside the project root`);if(r.some(n=>n===""||n==="."))throw new Error(`${t} must not contain empty or dot path segments`);return r}function Ue(e){let t=Dm(e,"native.artifact_root");return t.length===0?".":t.join("/")}function bl(e,t="docs"){let i=e??t;if(i!=="legacy"&&i!=="docs")throw new Error("classic.artifact_layout must be legacy or docs");return i}function _r(e,t,i=!1){if(typeof e!="string")throw new Error(`${t} must be a string`);let r=e.trim().replaceAll("\\","/");if(r.length===0||ht.posix.isAbsolute(r)||ht.win32.isAbsolute(r)||/^(?:~|[\\/])/u.test(r))throw new Error(`${t} must be relative to its declared path base`);let n=r.split("/");if(n.some(a=>a===".."))throw new Error(`${t} must stay inside its declared path base`);if(n.some(a=>a===""||a==="."))throw new Error(`${t} must not contain empty or dot path segments`);if(!i&&/[*?]/u.test(r))throw new Error(`${t} cannot contain wildcards`);return n.join("/")}function Ie(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be a mapping`);return e}function kl(e,t,i){let r=e??t;if(r!=="en"&&r!=="zh-CN")throw new Error(`${i} must be en or zh-CN`);return r}function Wa(e,t){if(typeof e!="string"||e.length===0||e.includes("\\")||e.includes("\0")||e.startsWith("/")||e.split("/").includes(".."))throw new Error(`${t} contains an unsafe pattern`);if(e.length>Cr)throw new Error(`${t} exceeds ${Cr} characters`);let i=0;for(let r=0;r<e.length;r+=1)e[r]==="?"?i+=1:e[r]==="*"&&(i+=1,e[r+1]==="*"&&(r+=1));if(i>Ar)throw new Error(`${t} contains more than ${Ar} wildcard tokens`);return e}function yl(e,t,i){if(e===void 0)return[...i];if(!Array.isArray(e))throw new Error(`${t} contains an unsafe pattern`);return[...new Set(e.map(r=>Wa(r,t)))].sort((r,n)=>r.localeCompare(n,"en"))}function qa(e,t,i){let r=e??t;if(!Number.isSafeInteger(r)||r<1)throw new Error(`${i} must be a positive integer`);return r}function Bm(e){if(e===void 0)return{...G,include:[...G.include],exclude:[...G.exclude]};let t=Ie(e,"native.snapshot");return{include:yl(t.include,"native.snapshot.include",G.include),exclude:yl(t.exclude,"native.snapshot.exclude",G.exclude),max_files:qa(t.max_files,G.max_files,"native.snapshot.max_files"),max_total_bytes:qa(t.max_total_bytes,G.max_total_bytes,"native.snapshot.max_total_bytes"),max_duration_ms:qa(t.max_duration_ms,G.max_duration_ms,"native.snapshot.max_duration_ms")}}function Lm(e){if(e===void 0)return;let t=Ie(e,"native.pending_root_move"),i=t.id,r=t.from_artifact_root,n=t.to_artifact_root,a=t.stage;if(typeof i!="string"||!/^[a-f0-9-]{8,}$/u.test(i))throw new Error("native.pending_root_move.id is invalid");if(typeof r!="string"||typeof n!="string")throw new Error("native.pending_root_move roots must be strings");if(a!=="copying"&&a!=="ready"&&a!=="switched")throw new Error("native.pending_root_move.stage is invalid");let o;if(t.cleanup!==void 0){let s=Ie(t.cleanup,"native.pending_root_move.cleanup"),c=s.kind,l=s.state,u=s.manifest_hash;if(c!=="forward-source"&&c!=="restart-staging"&&c!=="rollback-destination"&&c!=="rollback-staging")throw new Error("native.pending_root_move.cleanup.kind is invalid");if(l!=="prepared"&&l!=="quarantined"&&l!=="deleting")throw new Error("native.pending_root_move.cleanup.state is invalid");if(typeof u!="string"||!/^[a-f0-9]{64}$/u.test(u))throw new Error("native.pending_root_move.cleanup.manifest_hash is invalid");o={kind:c,state:l,manifestHash:u}}return{id:i,fromArtifactRoot:Ue(r),toArtifactRoot:Ue(n),stage:a,...o?{cleanup:o}:{}}}function Mm(e){if(e===void 0)return;let t=Ie(e,"native.finish");if(t.pull_request===void 0)return{};let i=Ie(t.pull_request,"native.finish.pull_request");if(i.provider!=="repository-command")throw new Error("native.finish.pull_request.provider must be repository-command");if(!Array.isArray(i.command)||i.command.length===0)throw new Error("native.finish.pull_request.command must be a non-empty array");if(i.command.length>64)throw new Error("native.finish.pull_request.command must contain at most 64 arguments");let r=i.command.map((a,o)=>{if(typeof a!="string"||a.trim().length===0||a.length>4096||/[\0\r\n]/u.test(a))throw new Error(`native.finish.pull_request.command[${o}] must be a non-empty single-line string of at most 4096 characters`);return a});if(ht.posix.isAbsolute(r[0])||ht.win32.isAbsolute(r[0]))throw new Error("native.finish.pull_request.command[0] must be a bare executable name or a project-relative path");let n=i.timeout_ms??Im;if(!Number.isSafeInteger(n)||n<1||n>wl)throw new Error(`native.finish.pull_request.timeout_ms must be an integer between 1 and ${wl}`);return{pull_request:{provider:"repository-command",command:r,timeout_ms:n}}}function Fm(e,t={}){let i=Ie(e,"native"),r=i.artifact_root??(t.allowMissingArtifactRoot?"docs":void 0);if(typeof r!="string")throw new Error("native.artifact_root must be a string");let n=i.clarification_mode??"batch";if(n!=="sequential"&&n!=="batch")throw new Error("native.clarification_mode must be sequential or batch");let a=i.archive_confirmation??"automatic";if(a!=="automatic"&&a!=="required")throw new Error("native.archive_confirmation must be automatic or required");let o=i.max_verify_failures??Va;if(!Number.isSafeInteger(o)||o<1)throw new Error("native.max_verify_failures must be a positive integer");let s=Lm(i.pending_root_move),c=Mm(i.finish);return{artifact_root:Ue(r),language:kl(i.language,"en","native.language"),clarification_mode:n,archive_confirmation:a,max_verify_failures:o,snapshot:Bm(i.snapshot),...c?{finish:c}:{},...s?{pending_root_move:s}:{}}}function qm(e){let t=Ie(e,"classic"),i=t.context_compression??"off";if(i!=="off"&&i!=="beta")throw new Error("classic.context_compression must be off or beta");let r=t.review_mode??"standard";if(r!=="off"&&r!=="standard"&&r!=="thorough")throw new Error("classic.review_mode must be off, standard, or thorough");let n=t.auto_transition??!0;if(typeof n!="boolean")throw new Error("classic.auto_transition must be true or false");return{artifact_layout:bl(t.artifact_layout),language:kl(t.language,"zh-CN","classic.language"),context_compression:i,review_mode:r,auto_transition:n}}function Vm(e){let i=Ie(e,"hook").allow_paths??[];if(!Array.isArray(i))throw new Error("hook.allow_paths must be an array");return{allow_paths:[...new Set(i.map((r,n)=>_r(r,`hook.allow_paths[${n}]`)))]}}function Wm(e){let t=e??!0;if(typeof t!="boolean")throw new Error("ambient_resume must be true or false");return t}function zm(e,t,i,r,n,a){let o=e.schema!==void 0;if(!(o||e.default_workflow!==void 0||e.workflows!==void 0||!a.allowPartialProject&&e.native!==void 0)||a.allowPartialProject&&!o)return null;if(e.schema!=="comet.project.v1")throw new Error("Unsupported Comet project schema");if(e.default_workflow!=="native"&&e.default_workflow!=="classic")throw new Error("default_workflow must be native or classic");let c=e.workflows??[e.default_workflow];if(!Array.isArray(c)||c.length===0||c.some(u=>u!=="native"&&u!=="classic"))throw new Error("workflows must contain native and/or classic");let l=[...new Set(c)];if(!l.includes(e.default_workflow))throw new Error("workflows must include default_workflow");if(l.includes("native")&&!i)throw new Error("native must be a mapping");return{schema:"comet.project.v1",default_workflow:e.default_workflow,workflows:l,ambient_resume:n,...t?{hook:t}:{},...i?{native:i}:{},...r?{classic:r}:{}}}function pt(e,t={}){let i=(0,ti.parseDocument)(e,{uniqueKeys:!0});if(i.errors.length>0)throw new Error(`Invalid .comet/config.yaml: ${i.errors[0].message}`);let r=i.toJS();if(r==null)return{value:{},config:null,ambient_resume:!0};if(typeof r!="object"||Array.isArray(r))throw new Error("Invalid .comet/config.yaml: root must be a mapping");let n=r,a=Wm(n.ambient_resume),o=n.hook===void 0?void 0:Vm(n.hook),s=n.native===void 0?void 0:Fm(n.native,{allowMissingArtifactRoot:t.allowMissingNativeFields}),c=n.classic===void 0?void 0:qm(n.classic),l=zm(n,o,s,c,a,{allowPartialProject:t.allowPartialProject??!1});return{value:n,config:l,ambient_resume:a,...o?{hook:o}:{},...s?{native:s}:{},...c?{classic:c}:{}}}function Sl(e){return{id:e.id,from_artifact_root:e.fromArtifactRoot,to_artifact_root:e.toArtifactRoot,stage:e.stage,...e.cleanup?{cleanup:{kind:e.cleanup.kind,state:e.cleanup.state,manifest_hash:e.cleanup.manifestHash}}:{}}}function El(e){return{schema:e.schema,default_workflow:e.default_workflow,workflows:e.workflows??[e.default_workflow],ambient_resume:e.ambient_resume,...e.hook?{hook:{allow_paths:[...e.hook.allow_paths]}}:{},...e.native?{native:{artifact_root:e.native.artifact_root,language:e.native.language,clarification_mode:e.native.clarification_mode,archive_confirmation:e.native.archive_confirmation,max_verify_failures:e.native.max_verify_failures,...e.native.finish?.pull_request?{finish:{pull_request:{provider:e.native.finish.pull_request.provider,command:[...e.native.finish.pull_request.command],timeout_ms:e.native.finish.pull_request.timeout_ms}}}:{},...e.native.pending_root_move?{pending_root_move:Sl(e.native.pending_root_move)}:{}}}:{},...e.classic?{classic:{artifact_layout:e.classic.artifact_layout,language:e.classic.language,context_compression:e.classic.context_compression,review_mode:e.classic.review_mode,auto_transition:e.classic.auto_transition}}:{}}}function ye(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}function ni(e,t){let i=El(t),r=pt((0,ti.stringify)(i)).config;if(!r)throw new Error("Unsupported Comet project schema");let n={...e,schema:r.schema,default_workflow:r.default_workflow,workflows:r.workflows,ambient_resume:r.ambient_resume};if(r.hook&&(n.hook={...ye(e.hook),allow_paths:[...r.hook.allow_paths]}),r.native){let a=ye(e.native),o={...a,artifact_root:r.native.artifact_root,language:r.native.language,clarification_mode:r.native.clarification_mode,archive_confirmation:r.native.archive_confirmation,max_verify_failures:r.native.max_verify_failures};if(r.native.finish?.pull_request){let s=ye(a.finish);o.finish={...s,pull_request:{...ye(s.pull_request),provider:r.native.finish.pull_request.provider,command:[...r.native.finish.pull_request.command],timeout_ms:r.native.finish.pull_request.timeout_ms}}}else{let s={...ye(a.finish)};delete s.pull_request,Object.keys(s).length>0?o.finish=s:delete o.finish}if(delete o.snapshot,r.native.pending_root_move){let s=ye(a.pending_root_move),c=Sl(r.native.pending_root_move),l=ye(s.cleanup),u=ye(c.cleanup);o.pending_root_move={...s,...c,...c.cleanup?{cleanup:{...l,...u}}:{}}}else delete o.pending_root_move;n.native=o}return r.classic&&(n.classic={...ye(e.classic),artifact_layout:r.classic.artifact_layout,language:r.classic.language,context_compression:r.classic.context_compression,review_mode:r.classic.review_mode,auto_transition:r.classic.auto_transition}),n}function Tr(e="docs",t="en"){return{schema:"comet.project.v1",default_workflow:"native",ambient_resume:!0,native:{artifact_root:Ue(e),language:t,clarification_mode:"batch",archive_confirmation:"automatic",max_verify_failures:Va,snapshot:{...G,include:[...G.include],exclude:[...G.exclude]}}}}import{createHash as Gm}from"crypto";import{promises as $r}from"fs";import $e from"path";import{constants as Ir,promises as Ke}from"fs";function je(e){return e!==0&&e!==0n&&e!=="0"}function de(e,t){return je(e.dev)&&je(t.dev)&&je(e.ino)&&je(t.ino)}function T(e,t){let i=je(e.dev)&&je(t.dev);if(i&&e.dev!==t.dev)return!1;let r=je(e.ino)&&je(t.ino);return r&&e.ino!==t.ino?!1:i&&r?!0:e.birthtime===t.birthtime}var re=class extends Error{reason;constructor(t,i,r){super(i,r),this.name="RaceSafeReadError",this.reason=t}};function za(e){return"birthtimeNs"in e&&typeof e.birthtimeNs=="bigint"?e.birthtimeNs:e.birthtimeMs}function Pl(e){return"ctimeNs"in e&&typeof e.ctimeNs=="bigint"?e.ctimeNs:e.ctimeMs}function ai(e){return{dev:e.dev,ino:e.ino,birthtime:za(e)}}function jr(e,t){let i=ai(e),r=ai(t);return de(i,r)?T(i,r):T(i,r)&&za(e)===za(t)&&Pl(e)===Pl(t)&&e.size===t.size}async function mt(e,t,i={}){if(!Number.isSafeInteger(t)||t<1)throw new Error("race-safe read byte limit must be a positive integer");let r=i.label??"file",n=i.bigint===!0,a=await Ke.lstat(e,{bigint:n});if(!a.isFile()||a.isSymbolicLink())throw new re("not-regular-file",`${r} must be a regular file`);if(BigInt(a.size)>BigInt(t))throw new re("too-large",`${r} exceeds ${t} bytes`);let o=await Ke.realpath(e);await i.verify?.("pre-open",{realPath:o,identity:ai(a)});let s=process.platform==="win32"?Ir.O_RDONLY:Ir.O_RDONLY|Ir.O_NOFOLLOW|Ir.O_NONBLOCK,c;try{c=await Ke.open(e,s)}catch(l){throw l.code==="ELOOP"?new re("not-regular-file",`${r} must be a regular file`,{cause:l}):l}try{let[l,u,d]=await Promise.all([c.stat({bigint:n}),Ke.lstat(e,{bigint:n}),Ke.realpath(e)]);if(!l.isFile()||!u.isFile()||u.isSymbolicLink()||d!==o||!jr(a,l)||!jr(a,u))throw new re("changed",`${r} changed while opening`);await i.verify?.("post-open",{realPath:d,identity:ai(l)}),await i.hooks?.afterOpen?.();let f=[],p=0,v=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let y=t+1-p,{bytesRead:b}=await c.read(v,0,Math.min(v.length,y),null);if(b===0)break;if(p+=b,p>t)throw new re("too-large",`${r} exceeds ${t} bytes`);f.push(Buffer.from(v.subarray(0,b)))}await i.hooks?.beforeFinalCheck?.();let[h,m,w]=await Promise.all([c.stat({bigint:n}),Ke.lstat(e,{bigint:n}),Ke.realpath(e)]);if(!m.isFile()||m.isSymbolicLink()||w!==o||!jr(a,h)||!jr(a,m))throw new re("changed",`${r} changed while reading`);return await i.verify?.("post-read",{realPath:w,identity:ai(h)}),{bytes:Buffer.concat(f,p),stat:h,realPath:w}}finally{await c.close()}}function Jm(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Ja(e,t){let i=$e.relative(e,t);return i===""||!$e.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${$e.sep}`)}async function Rl(e,t){let i=$e.resolve(e),r=await $r.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error(`${t} project root must be a real directory`);return $r.realpath(i)}async function xl(e,t,i,r){let n=e;for(let a=0;a<i.length;a++){n=$e.join(n,i[a]);let o;try{o=await $r.lstat(n)}catch(u){if(Jm(u))return{exists:!1,kind:"missing"};throw u}let s=$e.relative(e,n).replaceAll("\\","/");if(o.isSymbolicLink())throw new Error(`${r.label} crosses a symbolic link or junction at ${s}`);let c=a===i.length-1;if(!c&&!o.isDirectory())throw new Error(`${r.label} ancestor ${s} must be a real directory`);if(c&&(r.expected==="file"&&!o.isFile()||r.expected==="directory"&&!o.isDirectory()||r.expected==="any"&&!o.isFile()&&!o.isDirectory()))throw new Error(`${r.label} must be a real ${r.expected}`);let l=await $r.realpath(n);if(!Ja(t,l))throw new Error(`${r.label} resolves outside the project root`);if(c)return{exists:!0,kind:o.isFile()?"file":o.isDirectory()?"directory":"missing"}}return{exists:!0,kind:"directory"}}async function vt(e,t,i){let r=_r(t,i.label),n=$e.resolve(e),a=await Rl(n,i.label),o=r.split("/"),s=$e.resolve(n,...o);if(!Ja(n,s))throw new Error(`${i.label} must stay inside the project root`);let c=await xl(n,a,o,i);return{projectRoot:n,target:s,relative:r,exists:c.exists,kind:c.kind}}async function Oe(e,t,i,r){let n=await vt(e,t,{label:r.label,expected:"file"});if(!n.exists){let o=new Error(`${r.label} does not exist`);throw o.code="ENOENT",o}let a=await Rl(n.projectRoot,r.label);return mt(n.target,i,{...r,verify:async(o,s)=>{if(!Ja(a,s.realPath))throw new Error(`${r.label} resolves outside the project root`);await xl(n.projectRoot,a,n.relative.split("/"),{label:r.label,expected:"file"})}})}var oi=".comet/config.yaml";function Ga(e,t){return e.exists===t.exists&&e.sha256===t.sha256}function Um(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}async function Or(e,t={}){return(await si(e,t)).document}async function Cl(e){try{return(await Oe(e,oi,ii,{label:oi})).bytes}catch(t){if(Um(t))return null;throw t}}function Al(e){return e?{exists:!0,sha256:Gm("sha256").update(e).digest("hex")}:{exists:!1,sha256:null}}async function Hr(e){return Al(await Cl(e))}async function si(e,t={}){let i=await Cl(e);return{document:i?pt(i.toString("utf8"),t):null,identity:Al(i)}}async function Ua(e){return(await Or(e))?.config??null}var TN=16*1024;async function Ka(e,t){if(!t)return;let i=await Hr(e);if(!Ga(i,t))throw new Error("Project config changed before commit; rerun the operation")}import{randomUUID as Qm}from"crypto";import{promises as M}from"fs";import ne from"path";function Ya(e,t){let i=ne.relative(e,t);return i===""||!ne.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${ne.sep}`)}function Zm(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Xa(e,t){return T({dev:e.dev,ino:e.ino,birthtime:e.birthtimeMs},{dev:t.dev,ino:t.ino,birthtime:t.birthtimeMs})}function ev(e,t){return Xa(e,t)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function _l(e){let t=await M.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native atomic write parent must be a real directory: ${e}`);return{path:e,realPath:await M.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function li(e){for(let t of e){let i=await M.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Zm(t,i)||await M.realpath(t.path)!==t.realPath)throw new Error(`Native atomic write parent changed before commit: ${t.path}`)}}async function tv(e,t){let i=ne.resolve(e),r=ne.resolve(t);if(!Ya(i,r))throw new Error(`Native atomic write parent is outside its managed root: ${t}`);let n=[await _l(i)],a=ne.relative(i,r).split(ne.sep).filter(Boolean),o=i;for(let s of a){await li(n),o=ne.join(o,s);try{await M.mkdir(o)}catch(l){if(l.code!=="EEXIST")throw l}let c=await _l(o);if(!Ya(n[0].realPath,c.realPath))throw new Error(`Native atomic write parent resolves outside its managed root: ${o}`);n.push(c)}return await li(n),n}async function iv(e){let t;try{t=await M.open(e,"r"),await t.sync()}catch(i){let r=i.code;if(!["EACCES","EBADF","EINVAL","EISDIR","ENOTSUP","EPERM"].includes(r??""))throw i}finally{await t?.close()}}async function Tl(e,t,i={}){let r=ne.dirname(e),n=i.containedRoot?await tv(i.containedRoot,r):null;n||await M.mkdir(r,{recursive:!0});let a=ne.join(r,`.${ne.basename(e)}.${Qm()}.tmp`),o,s,c;try{if(await i.beforeTemporaryOpen?.(),o=await M.open(a,"wx"),s=await o.stat(),n){let[l,u]=await Promise.all([M.lstat(a),M.realpath(a)]);if(await li(n),!l.isFile()||l.isSymbolicLink()||!Xa(s,l)||!Ya(n[0].realPath,u))throw new Error("Native atomic write temporary file opened outside its managed parent")}if(typeof t=="string"?await o.writeFile(t,"utf8"):await o.writeFile(t),await o.sync(),c=await o.stat(),!Xa(s,c))throw new Error("Native atomic write temporary file changed while writing");if(await o.close(),o=void 0,await i.beforeCommit?.(),n){await li(n);let l=await M.lstat(a);if(!l.isFile()||l.isSymbolicLink()||!c||!ev(l,c))throw new Error("Native atomic write temporary file changed before commit")}i.exclusive?(await M.link(a,e),await M.unlink(a)):await M.rename(a,e),await iv(r)}catch(l){if(await o?.close(),!n)await M.rm(a,{force:!0});else try{await li(n),await M.rm(a,{force:!0})}catch{}throw l}}async function z(e,t,i={}){await Tl(e,t,i)}async function Il(e,t,i={}){await Tl(e,t,i)}async function Y(e,t,i={}){await z(e,JSON.stringify(t,null,2)+`
|
|
164
|
+
`,i)}import{existsSync as jl,promises as Ye}from"fs";import C from"path";import rv from"os";var Dr=".comet/config.yaml",nv=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;async function Qa(e){try{return await Ye.lstat(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function av(e){try{let t=await Ye.readFile(e,"utf8");return/^schema:\s*comet\.project\.v1\s*$/mu.test(t)}catch(t){if(t.code==="ENOENT")return!1;throw t}}function wt(e,t){let i=C.relative(e,t);return i===""||!C.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${C.sep}`)}async function gt(e){let t=[],i=e;for(;!await Qa(i);){let n=C.dirname(i);if(n===i)break;t.push(C.basename(i)),i=n}let r=await Ye.realpath(i);return C.resolve(r,...t.reverse())}async function Za(e){try{return(await Ye.lstat(e)).isSymbolicLink()}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function eo(e){let t=C.resolve(e);try{(await Ye.stat(t)).isDirectory()||(t=C.dirname(t))}catch(n){if(n.code!=="ENOENT")throw n}let i=t,r=C.resolve(rv.homedir());for(;;){if(!(t===r&&i!==r)){let o=C.join(t,...Dr.split("/")),s=t===i||await av(o);if(await Qa(o)&&s)return t}if(await Qa(C.join(t,".git")))return t;let a=C.dirname(t);if(a===t)return i;t=a}}function ui(e){return Ue(e)}async function ov(e,t){let i=ui(t),r=C.resolve(e,...i.split("/")),n=await Ye.realpath(e),a=await gt(r);if(!wt(n,a))throw new Error("native.artifact_root resolves outside the project root");return r}async function fe(e,t){let i=ui(t),r=await ov(e,i),n=C.join(r,"comet");if(await Za(n))throw new Error("The configured Native comet root must not be a symbolic link");let[a,o]=await Promise.all([gt(r),gt(n)]);if(!wt(a,o))throw new Error("The configured Native comet root resolves outside its artifact root");let s=C.resolve(e),c=C.join(s,".comet","runtime","native");if(await Za(c))throw new Error("The Native Runtime root must not be a symbolic link");let[l,u]=await Promise.all([Ye.realpath(s),gt(c)]);if(!wt(l,u))throw new Error("The Native Runtime root resolves outside the project root");return{projectRoot:s,configFile:C.join(e,...Dr.split("/")),artifactRoot:r,artifactRootRef:i,nativeRoot:n,specsDir:C.join(n,"specs"),changesDir:C.join(n,"changes"),archiveDir:C.join(n,"archive"),runtimeDir:c,changesRuntimeDir:C.join(c,"changes"),locksDir:C.join(c,"locks"),transactionsDir:C.join(c,"transactions")}}function $l(e){if(!nv.test(e))throw new Error(`Invalid Native change name: ${e}`)}function Br(e,t){$l(t);let i=C.join(e.changesRuntimeDir,t);if(!F(e.changesRuntimeDir,i))throw new Error("Native change Runtime path escaped");return i}function sv(e,t){$l(t);let i=C.join(e.changesDir,t,"runtime");if(!F(e.changesDir,i))throw new Error("Legacy Native change Runtime path escaped");return i}function he(e,t){let i=Br(e,t);if(jl(i))return i;let r=sv(e,t);return jl(r)?r:i}function ae(e,t){let i=C.resolve(t);if(F(e.runtimeDir,i))return e.runtimeDir;if(F(e.nativeRoot,i))return e.nativeRoot;throw new Error(`Path is outside Native document and Runtime roots: ${t}`)}function F(e,t){return wt(C.resolve(e),C.resolve(t))}async function $(e,t){let i=C.resolve(e),r=C.resolve(t);if(!wt(i,r))throw new Error(`Path is outside the Native root: ${t}`);if(await Za(i))throw new Error(`Native root must not be a symbolic link: ${e}`);let[n,a]=await Promise.all([gt(i),gt(r)]);if(!wt(n,a))throw new Error(`Path resolves outside the Native root: ${t}`);return r}function Ol(e="docs",t="en"){return Tr(e,t)}async function oe(e){let t=(await Or(e))?.config??null;return t?.native?t:null}async function He(e,t,i={}){let r=await si(e,{allowPartialProject:!0}),n=ni(r.document?.value??{},t),a=cv.join(e,...Dr.split("/"));await z(a,ri(n,t.native.language==="zh-CN"?"zh-CN":"en"),{containedRoot:e,beforeCommit:async()=>{await i.beforeCommit?.(),await Ka(e,r.identity)}})}import{createHash as Ig,randomUUID as jg}from"crypto";import{promises as Fe}from"fs";import I from"path";import{AsyncLocalStorage as lv}from"async_hooks";import{randomUUID as Bl}from"crypto";import{promises as X}from"fs";import Ll from"os";import q from"path";var Hl=16*1024,Ml=".coordinator",uv=5e3,Dl=new lv,Lr=new Map;function dv(e){if(!/^[a-z][a-z0-9-]*$/u.test(e))throw new Error(`Invalid Native lock name: ${e}`);return`${e}.lock`}function fv(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Invalid Native lock metadata: ${t}`);let i=e;if(typeof i.id!="string"||i.id.length===0||typeof i.pid!="number"||!Number.isSafeInteger(i.pid)||i.pid<1||typeof i.hostname!="string"||i.hostname.length===0||typeof i.createdAt!="string"||i.createdAt.length===0||typeof i.operation!="string"||i.operation.length===0)throw new Error(`Invalid Native lock metadata: ${t}`);return i}function Fl(e){return{device:e.dev.toString(),inode:e.ino.toString(),size:e.size.toString(),birthtimeNs:e.birthtimeNs.toString(),ctimeNs:e.ctimeNs.toString(),mtimeNs:e.mtimeNs.toString()}}function to(e,t){let i={dev:e.device,ino:e.inode,birthtime:e.birthtimeNs},r={dev:t.device,ino:t.inode,birthtime:t.birthtimeNs};return de(i,r)?T(i,r):T(i,r)&&e.size===t.size}function io(e,t){return to(e,t)&&e.size===t.size&&e.birthtimeNs===t.birthtimeNs&&e.ctimeNs===t.ctimeNs&&e.mtimeNs===t.mtimeNs}async function De(e){let t,i;try{let r=await mt(e,Hl,{bigint:!0,label:"Native lock"});t=r.bytes,i=r.stat}catch(r){if(r.code==="ENOENT")return null;throw r instanceof re?r.reason==="too-large"?new Error(`Native lock metadata exceeds ${Hl} bytes: ${e}`,{cause:r}):r.reason==="not-regular-file"?new Error(`Native lock must be a regular file: ${e}`,{cause:r}):new Error(`Native lock changed while reading: ${e}`,{cause:r}):r}return{file:e,owner:fv(JSON.parse(t.toString("utf8")),e),identity:Fl(i)}}async function hv(e){return(await De(e))?.owner??null}function pv(e){if(!e)return{status:"missing",owner:null,identity:null};if(e.owner.hostname!==Ll.hostname())return{status:"unknown",owner:e.owner,identity:e.identity};let t=Nv(e.owner.pid);return{status:t===!0?"active":t===!1?"stale":"unknown",owner:e.owner,identity:e.identity}}async function mv(e,t){try{await X.lstat(t);return}catch(i){if(i.code!=="ENOENT")throw i}try{await X.rename(e,t)}catch(i){if(i.code!=="ENOENT")throw i}}async function ro(e,t){let i=await De(e.file);if(!i)return"missing";if(i.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!io(i.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);await X.mkdir(t,{recursive:!0});let r=q.join(t,`${q.basename(e.file)}.${e.owner.id}.${Bl()}.removed`);try{await X.rename(e.file,r)}catch(a){if(a.code==="ENOENT")return"missing";throw a}let n=await De(r);if(!n||n.owner.id!==e.owner.id||!to(n.identity,e.identity))throw await mv(r,e.file),new Error(`Native lock changed before quarantine: ${e.file}`);return await X.rm(r,{force:!0}),"removed"}function ql(e){return{id:Bl(),pid:process.pid,hostname:Ll.hostname(),createdAt:new Date().toISOString(),operation:e}}async function Vl(e,t){let i;try{i=await X.open(e,"wx")}catch(r){if(r.code==="EEXIST"){let n=await hv(e);throw new Error(`Native lock is already held: ${e}${n?` by pid ${n.pid} for ${n.operation}`:""}`,{cause:r})}throw r}try{return await i.writeFile(JSON.stringify(t,null,2)+`
|
|
165
|
+
`,"utf8"),await i.sync(),Fl(await i.stat({bigint:!0}))}finally{await i.close()}}async function vv(e,t){let i=await $(e.runtimeDir,e.locksDir);await X.mkdir(i,{recursive:!0});let r=await $(e.runtimeDir,q.join(i,Ml));await X.mkdir(r,{recursive:!0});let n=ql(t),a=q.join(r,`.${n.id}.tmp`),o=q.join(r,`${n.id}.claim`);try{let s=await Vl(a,n);await X.rename(a,o);let c=await De(o);if(!c||!to(s,c.identity))throw new Error(`Native lock coordinator claim changed while publishing: ${o}`);return{file:o,nativeRoot:e.runtimeDir,locksDir:i,owner:n,identity:c.identity}}finally{await X.rm(a,{force:!0})}}async function gv(e){let t=q.dirname(e.file),i=!1,r=q.basename(e.file);for(let n of await X.readdir(t,{withFileTypes:!0})){if(!n.isFile()||n.isSymbolicLink()||!n.name.endsWith(".claim"))continue;let a=q.join(t,n.name);if(q.resolve(a)!==q.resolve(e.file))try{let o=await De(a),s=pv(o);if(s.status==="missing")continue;if(s.status==="stale"&&o){await ro(o,t);continue}n.name<r&&(i=!0)}catch{n.name<r&&(i=!0)}}return i}async function Wl(e){let t=await De(e.file);if(t){if(t.owner.id!==e.owner.id||!io(t.identity,e.identity))throw new Error(`Native lock coordinator ownership changed: ${e.file}`);await ro(t,q.dirname(e.file))}}async function wv(e,t){let i=Date.now()+uv;for(;;){let r=await vv(e,t);if(!await gv(r))return r;if(await Wl(r),Date.now()>=i)throw new Error(`Native lock coordinator is busy: ${e.locksDir}`);await new Promise(n=>setTimeout(n,2+Math.floor(Math.random()*7)))}}async function yv(e){let t=Lr.get(e)??Promise.resolve(),i,r=new Promise(a=>{i=a}),n=t.then(()=>r);return Lr.set(e,n),await t,()=>{i(),Lr.get(e)===n&&Lr.delete(e)}}async function zl(e,t,i){let r=q.resolve(e.locksDir),n=Dl.getStore();if(n?.has(r))return i();let a=await yv(r);try{let o=await wv(e,t),s=new Map(n??[]);return s.set(r,o),await Dl.run(s,async()=>{try{return await i()}finally{await Wl(o)}})}finally{a()}}async function di(e,t,i){return zl(e,`acquire ${t}`,async()=>{let r=await $(e.runtimeDir,e.locksDir);await X.mkdir(r,{recursive:!0});let n=await $(e.runtimeDir,q.join(r,dv(t))),a=ql(i),o=await Vl(n,a);return{file:n,nativeRoot:e.runtimeDir,locksDir:r,owner:a,identity:o}})}async function fi(e){await De(e.file)&&await zl({runtimeDir:e.nativeRoot,locksDir:e.locksDir},`release ${q.basename(e.file)}`,async()=>{let t=await De(e.file);if(!t)return;if(t.owner.id!==e.owner.id)throw new Error(`Native lock ownership changed: ${e.file}`);if(!io(t.identity,e.identity))throw new Error(`Native lock identity changed: ${e.file}`);let i=q.join(e.locksDir,Ml);await ro(t,i)})}function Nv(e){try{return process.kill(e,0),!0}catch(t){let i=t.code;return i==="ESRCH"?!1:i==="EPERM"?!0:null}}import{createHash as bv}from"node:crypto";import{constants as Mr,promises as R}from"node:fs";import _ from"node:path";function pe(e,t){let i=_.relative(e,t);return i===""||!_.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${_.sep}`)}function Jl(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native protected file byte limit must be a positive integer");return e}function Fr(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Gl(e){return{dev:e.dev,ino:e.ino,birthtimeMs:e.birthtimeMs,ctimeMs:e.ctimeMs,mtimeMs:e.mtimeMs,size:e.size}}function yt(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.mtimeMs===t.mtimeMs&&e.size===t.size}async function Xe(e,t){let i=await R.lstat(e);if(!i.isDirectory()||i.isSymbolicLink())throw new Error(`${t} parent must be a real directory: ${e}`);return{path:e,realPath:await R.realpath(e),dev:i.dev,ino:i.ino,birthtimeMs:i.birthtimeMs}}async function hi(e,t,i){let r=_.resolve(e),n=_.resolve(t);if(!pe(r,n))throw new Error(`${i} is outside its managed root`);let a=[await Xe(r,i)],o=r;for(let s of _.relative(r,n).split(_.sep).filter(Boolean)){await L(a,i),o=_.join(o,s);let c=await Xe(o,i);if(!pe(a[0].realPath,c.realPath))throw new Error(`${i} parent resolves outside its managed root: ${o}`);a.push(c)}return await L(a,i),a}async function L(e,t){for(let i of e){let r=await R.lstat(i.path);if(!r.isDirectory()||r.isSymbolicLink()||!Fr(i,r)||await R.realpath(i.path)!==i.realPath)throw new Error(`${t} parent changed during I/O: ${i.path}`)}}async function kv(e,t,i){let r=[],n=0,a=Buffer.allocUnsafe(Math.min(64*1024,t+1));for(;;){let o=t+1-n,{bytesRead:s}=await e.read(a,0,Math.min(a.length,o),null);if(s===0)break;if(n+=s,n>t)throw new Error(`${i} exceeds ${t} bytes`);r.push(Buffer.from(a.subarray(0,s)))}return Buffer.concat(r,n)}async function J(e){let t=Jl(e.maxBytes),i=_.resolve(e.file),r=await hi(e.root,_.dirname(i),e.label),n=await Promise.all((e.forbiddenRoots??[]).map(u=>Xe(_.resolve(u),e.label)));await e.hooks?.afterParentChainCaptured?.(),await L(r,e.label);let a=await R.lstat(i);if(!a.isFile()||a.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);if(a.size>t)throw new Error(`${e.label} exceeds ${t} bytes`);let o=Gl(a),s=await R.realpath(i);if(!pe(r[0].realPath,s))throw new Error(`${e.label} resolves outside its managed root`);if(n.some(u=>pe(u.realPath,s)))throw new Error(`${e.label} resolves inside an excluded root`);let c=process.platform==="win32"?Mr.O_RDONLY:Mr.O_RDONLY|Mr.O_NOFOLLOW|Mr.O_NONBLOCK,l=await R.open(i,c);try{let u=await l.stat();await e.hooks?.afterOpen?.();let[d,f]=await Promise.all([R.lstat(i),R.realpath(i)]);if(await L(r,e.label),await L(n,e.label),!u.isFile()||!d.isFile()||d.isSymbolicLink()||f!==s||!yt(o,u)||!yt(o,d))throw new Error(`${e.label} changed while opening`);await e.hooks?.beforeRead?.();let p=await kv(l,t,e.label);await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([l.stat(),R.lstat(i),R.realpath(i)]);if(await L(r,e.label),await L(n,e.label),!h.isFile()||h.isSymbolicLink()||m!==s||!yt(o,v)||!yt(o,h))throw new Error(`${e.label} changed while reading`);return{bytes:p,hash:bv("sha256").update(p).digest("hex"),size:p.length}}finally{await l.close()}}async function Qe(e){let t=await hi(e.root,e.directory,e.label),i;if(e.maxEntries===void 0)i=await R.readdir(e.directory,{withFileTypes:!0});else{let r=Jl(e.maxEntries);i=[];let n=await R.opendir(e.directory);try{for await(let a of n)if(i.push(a),i.length>r)throw new Error(`${e.label} exceeds ${r} entries`)}finally{await n.close().catch(a=>{if(a.code!=="ERR_DIR_CLOSED")throw a})}}return await L(t,e.label),{entries:i,verify:()=>L(t,e.label)}}async function Sv(e){let t=_.resolve(e.directory),i=_.resolve(e.quarantine);if(_.dirname(i)!==_.dirname(t)||!pe(_.resolve(e.root),i)||i===t)throw new Error(`${e.label} quarantine must be a distinct sibling inside its root`);let r=await hi(e.root,_.dirname(t),e.label),n=await Xe(t,e.label);if(!pe(r[0].realPath,n.realPath))throw new Error(`${e.label} resolves outside its managed root`);await e.beforeQuarantine?.(),await L(r,e.label);let a=await R.lstat(t);if(!a.isDirectory()||a.isSymbolicLink()||!Fr(n,a)||await R.realpath(t)!==n.realPath)throw new Error(`${e.label} changed before quarantine`);try{throw await R.lstat(i),new Error(`${e.label} quarantine path is occupied`)}catch(s){if(s.code!=="ENOENT")throw s}await R.rename(t,i),await L(r,e.label);let o=await R.lstat(i);if(!o.isDirectory()||o.isSymbolicLink()||!Fr(n,o))throw new Error(`${e.label} changed while quarantining`);await e.afterQuarantine?.(i);try{throw await R.lstat(t),new Error(`${e.label} path was recreated while quarantining`)}catch(s){if(s.code!=="ENOENT")throw s}return{quarantine:i,parentChain:r,identity:n}}async function Ul(e){await Sv(e)}async function no(e){let t=_.resolve(e.file),i=await hi(e.root,_.dirname(t),e.label),r=await R.lstat(t);if(!r.isFile()||r.isSymbolicLink())throw new Error(`${e.label} must be a regular file`);let n=Gl(r),a=await R.realpath(t);if(!pe(i[0].realPath,a))throw new Error(`${e.label} resolves outside its managed root`);let o=await J({root:e.root,file:t,maxBytes:e.maxBytes,label:e.label});if(o.hash!==e.expectedHash||o.size!==e.expectedSize)throw new Error(`${e.label} changed before removal`);let[s,c]=await Promise.all([R.lstat(t),R.realpath(t)]);if(!s.isFile()||s.isSymbolicLink()||!yt(n,s)||c!==a)throw new Error(`${e.label} changed while verifying removal`);await e.beforeRemove?.(),await L(i,e.label);let[l,u]=await Promise.all([R.lstat(t),R.realpath(t)]);if(!l.isFile()||l.isSymbolicLink()||!yt(n,l)||u!==a)throw new Error(`${e.label} changed before removal`);await R.rm(t),await L(i,e.label)}async function ao(e){let t=_.resolve(e.directory),i=await hi(e.root,_.dirname(t),e.label),r=await Xe(t,e.label);if(!pe(i[0].realPath,r.realPath))throw new Error(`${e.label} resolves outside its managed root`);await e.beforeRemove?.(),await L(i,e.label);let n=await R.lstat(t);if(!n.isDirectory()||n.isSymbolicLink()||!Fr(r,n)||await R.realpath(t)!==r.realPath)throw new Error(`${e.label} changed before removal`);await R.rmdir(t),await L(i,e.label)}async function pi(e){let t=_.resolve(e.root),i=_.resolve(e.directory);if(!pe(t,i))throw new Error(`${e.label} is outside its managed root`);let r=[await Xe(t,e.label)],n=t;for(let a of _.relative(t,i).split(_.sep).filter(Boolean)){await L(r,e.label),n=_.join(n,a);try{await R.mkdir(n)}catch(s){if(s.code!=="EEXIST")throw s}let o=await Xe(n,e.label);if(!pe(r[0].realPath,o.realPath))throw new Error(`${e.label} resolves outside its managed root: ${n}`);r.push(o)}await L(r,e.label)}async function mi(e){let t=await J({root:e.sourceRoot,file:e.source,maxBytes:e.maxBytes,label:e.label,hooks:e.hooks,forbiddenRoots:e.forbiddenRoots});if(e.expectedHash!==void 0&&t.hash!==e.expectedHash)throw new Error(`${e.label} content changed before copy`);await Il(e.target,t.bytes,{containedRoot:e.targetRoot,exclusive:e.exclusive,beforeCommit:async()=>{if(await e.hooks?.beforeTargetCommit?.(),e.expectedTargetHash===void 0)return;if(e.expectedTargetHash===null){try{await R.lstat(e.target)}catch(n){if(n.code==="ENOENT")return;throw n}throw new Error(`${e.label} target changed before commit`)}if((await J({root:e.targetRoot,file:e.target,maxBytes:e.maxBytes,label:`${e.label} existing target`})).hash!==e.expectedTargetHash)throw new Error(`${e.label} target changed before commit`)}});let i=await J({root:e.targetRoot,file:e.target,maxBytes:e.maxBytes,label:`${e.label} target`});if(i.hash!==t.hash||i.size!==t.size)throw new Error(`${e.label} target could not be verified`);return i}import{promises as Vr}from"fs";import Ne from"path";import{TextDecoder as Ev}from"util";var Pv=new Set(["schema","id","kind","status","projectRoot","nativeRoot","change","createdAt","operations"]),Rv=new Set(["id","type","source","target","staged","backup"]),xv=new Set(["schema","id","kind","status","change","createdAt","preflightHash","operations"]),Cv=new Set(["id","type","source","target","staged","backup","expectedSourceHash","expectedTargetHash","stagedHash"]),Av=new Set(["sequence","timestamp","type","operationId"]),Xl=new Set(["prepared","applying","committed","rolling-back","rolled-back"]),Ql=new Set(["prepared","operation-started","operation-completed","archive-finalization-started","archive-finalized","commit","rollback-started","rollback-completed"]),_v=256*1024,Tv=1024*1024,Zl=16*1024,Wr=1024,Cb=64*1024*1024;var eu=new Ev("utf-8",{fatal:!0});function vi(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`${t} must be an object`);return e}function gi(e,t,i){let r=Object.keys(e).filter(n=>!t.has(n));if(r.length>0)throw new Error(`${i} has unknown field(s): ${r.join(", ")}`)}function bt(e){if(typeof e!="string")return!1;let t=new Date(e);return!Number.isNaN(t.valueOf())&&t.toISOString()===e}function oo(e,t){if(typeof e!="string"||e.length===0||Ne.isAbsolute(e)||/^(?:[A-Za-z]:|~|[\\/])/u.test(e)||e.split(/[\\/]/u).includes(".."))throw new Error(`${t} must stay inside the Native root`)}function qr(e,t){if(typeof e!="string"||!/^[a-f0-9]{64}$/u.test(e))throw new Error(`${t} must be a SHA-256 hash`)}function Kl(e,t){if(oo(e,t),e.includes("\\")||e!==Ne.posix.normalize(e)||e.split("/").includes(".")||e.endsWith("/")||Buffer.byteLength(e,"utf8")>1024)throw new Error(`${t} must be a normalized Native-relative ref`)}function Iv(e,t){let i=vi(e,`transaction operations[${t}]`);if(gi(i,Rv,`transaction operations[${t}]`),typeof i.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.id))throw new Error(`transaction operations[${t}].id is invalid`);if(i.type!=="write"&&i.type!=="remove"&&i.type!=="move")throw new Error(`transaction operation ${i.id} has an invalid type`);oo(i.target,`transaction operation ${i.id} target`);for(let r of["source","staged","backup"])i[r]!==void 0&&oo(i[r],`transaction operation ${i.id} ${r}`);if(i.type==="write"){if(i.staged===void 0||i.source!==void 0)throw new Error(`write operation ${i.id} requires staged and forbids source`)}else if(i.type==="remove"){if(i.source!==void 0||i.staged!==void 0)throw new Error(`remove operation ${i.id} forbids source and staged`)}else if(i.source===void 0||i.staged!==void 0||i.backup!==void 0)throw new Error(`move operation ${i.id} requires source and forbids staged and backup`);return i}function tu(e){let t=vi(e,"Native Archive transaction journal");if(gi(t,xv,"Native Archive transaction journal"),t.schema!=="comet.native.transaction.v2")throw new Error("Unsupported Native Archive transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native Archive transaction id is invalid");if(t.kind!=="archive")throw new Error("Native v2 transaction kind must be archive");if(typeof t.status!="string"||!Xl.has(t.status))throw new Error("Native Archive transaction status is invalid");if(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change))throw new Error("Native Archive transaction change name is invalid");if(!bt(t.createdAt))throw new Error("Native Archive transaction createdAt is invalid");if(qr(t.preflightHash,"Native Archive transaction preflightHash"),!Array.isArray(t.operations)||t.operations.length>65)throw new Error("Native Archive transaction operations must be an array");let i=t.operations.map((s,c)=>{let l=vi(s,`Archive transaction operations[${c}]`);if(gi(l,Cv,`Archive transaction operations[${c}]`),typeof l.id!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(l.id))throw new Error(`Archive transaction operations[${c}].id is invalid`);if(l.type!=="write"&&l.type!=="remove"&&l.type!=="move")throw new Error(`Archive transaction operation ${l.id} has an invalid type`);Kl(l.target,`Archive transaction operation ${l.id} target`);for(let u of["source","staged","backup"])l[u]!==void 0&&Kl(l[u],`Archive transaction operation ${l.id} ${u}`);if(l.expectedTargetHash!==null&&qr(l.expectedTargetHash,`Archive transaction operation ${l.id} expectedTargetHash`),l.type==="write"){if(l.staged===void 0||l.source!==void 0||l.expectedSourceHash!==void 0)throw new Error(`Archive write operation ${l.id} requires staged and forbids source`);if(qr(l.stagedHash,`Archive write operation ${l.id} stagedHash`),l.expectedTargetHash===null!=(l.backup===void 0))throw new Error(`Archive write operation ${l.id} backup must match target existence`)}else if(l.type==="remove"){if(l.source!==void 0||l.staged!==void 0||l.stagedHash!==void 0||l.expectedSourceHash!==void 0||l.backup===void 0||l.expectedTargetHash===null)throw new Error(`Archive remove operation ${l.id} requires a bound target and backup`)}else{if(l.source===void 0||l.staged!==void 0||l.stagedHash!==void 0||l.backup!==void 0||l.expectedTargetHash!==null)throw new Error(`Archive move operation ${l.id} requires source and an absent target`);qr(l.expectedSourceHash,`Archive move operation ${l.id} expectedSourceHash`)}return l}),r=i.map(s=>s.id);if(new Set(r).size!==r.length)throw new Error("Native Archive transaction operation ids must be unique");let n=`runtime/transactions/${t.id}`,a=i.filter(s=>s.type==="move");if(a.length!==1||a[0].id!=="archive-change"||a[0].source!==`changes/${t.change}`||!new RegExp(`^archive/\\d{4}-\\d{2}-\\d{2}-${t.change}$`,"u").test(a[0].target)||i.at(-1)!==a[0])throw new Error("Native Archive transaction must end with its exact change move");let o=new Set;for(let s of i.slice(0,-1)){if(s.type==="move"||!/^specs\/[a-z][a-z0-9]*(?:-[a-z0-9]+)*\/spec\.md$/u.test(s.target)||o.has(s.target))throw new Error(`Native Archive transaction spec target is invalid: ${s.target}`);if(o.add(s.target),s.staged!==void 0&&!s.staged.startsWith(`${n}/staged/specs/`))throw new Error(`Native Archive transaction staged ref is invalid: ${s.staged}`);if(s.backup!==void 0&&!s.backup.startsWith(`${n}/backups/specs/`))throw new Error(`Native Archive transaction backup ref is invalid: ${s.backup}`)}return{schema:"comet.native.transaction.v2",id:t.id,kind:"archive",status:t.status,change:t.change,createdAt:t.createdAt,preflightHash:t.preflightHash,operations:i}}function so(e){let t=vi(e,"Native transaction journal");if(t.schema==="comet.native.transaction.v2")return tu(t);if(gi(t,Pv,"Native transaction journal"),t.schema!=="comet.native.transaction.v1")throw new Error("Unsupported Native transaction schema");if(typeof t.id!="string"||!/^[a-f0-9-]{8,}$/u.test(t.id))throw new Error("Native transaction id is invalid");if(t.kind!=="archive"&&t.kind!=="root-move")throw new Error("Native transaction kind is invalid");if(typeof t.status!="string"||!Xl.has(t.status))throw new Error("Native transaction status is invalid");if(typeof t.projectRoot!="string"||!Ne.isAbsolute(t.projectRoot)||typeof t.nativeRoot!="string"||!Ne.isAbsolute(t.nativeRoot))throw new Error("Native transaction roots must be absolute paths");if(t.change!==void 0&&(typeof t.change!="string"||!/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u.test(t.change)))throw new Error("Native transaction change name is invalid");if(!bt(t.createdAt))throw new Error("Native transaction createdAt is invalid");if(!Array.isArray(t.operations))throw new Error("Native transaction operations must be an array");let i=t.operations.map(Iv),r=i.map(n=>n.id);if(new Set(r).size!==r.length)throw new Error("Native transaction operation ids must be unique");return{schema:"comet.native.transaction.v1",id:t.id,kind:t.kind,status:t.status,projectRoot:t.projectRoot,nativeRoot:t.nativeRoot,...typeof t.change=="string"?{change:t.change}:{},createdAt:t.createdAt,operations:i}}function iu(e,t){let i=vi(e,`Native transaction event at line ${t}`);if(gi(i,Av,`Native transaction event at line ${t}`),i.sequence!==t)throw new Error(`Native transaction event sequence at line ${t} must be ${t}`);if(!bt(i.timestamp))throw new Error(`Native transaction event timestamp at line ${t} is invalid`);if(typeof i.type!="string"||!Ql.has(i.type))throw new Error(`Native transaction event type at line ${t} is invalid`);let r=i.type==="operation-started"||i.type==="operation-completed";if(r&&(typeof i.operationId!="string"||!/^[a-z0-9][a-z0-9-]*$/u.test(i.operationId)||Buffer.byteLength(i.operationId,"utf8")>256)||!r&&i.operationId!==void 0)throw new Error(`Native transaction event operationId at line ${t} is invalid`);return{sequence:i.sequence,timestamp:i.timestamp,type:i.type,...typeof i.operationId=="string"?{operationId:i.operationId}:{}}}function jv(e){if(e.length>24)return!1;let t="0000-00-00T00:00:00.000Z";for(let r=0;r<e.length;r+=1){let n=t[r],a=e[r];if(n==="0"){if(!/[0-9]/u.test(a))return!1}else if(a!==n)return!1}let i=[[5,2,1,12],[8,2,1,31],[11,2,0,23],[14,2,0,59],[17,2,0,59],[20,3,0,999]];for(let[r,n,a,o]of i){if(e.length<=r)continue;let s=e.slice(r,Math.min(r+n,e.length));if(!Array.from({length:o-a+1},(l,u)=>String(a+u).padStart(n,"0")).some(l=>l.startsWith(s)))return!1}return e.length>=10&&!bt(`${e.slice(0,10)}T00:00:00.000Z`)?!1:e.length<24||bt(e)}function Nt(e,t){return e.length<t.length&&t.startsWith(e)}function $v(e){let t='","operationId":"';if(Nt(e,t))return!0;if(!e.startsWith(t))return!1;let i=e.slice(t.length),r=i.indexOf('"');if(r===-1)return i.length===0||/^[a-z0-9][a-z0-9-]*$/u.test(i);let n=i.slice(0,r);return/^[a-z0-9][a-z0-9-]*$/u.test(n)?Nt(i.slice(r),'"}'):!1}function Ov(e,t){if(e.length===0||Buffer.byteLength(e,"utf8")>Zl)return!1;let i=`{"sequence":${t},"timestamp":"`;if(Nt(e,i))return!0;if(!e.startsWith(i))return!1;let r=e.slice(i.length),n=r.slice(0,Math.min(24,r.length));if(!jv(n))return!1;if(r.length<24)return!0;if(!bt(n))return!1;let a='","type":"',o=r.slice(24);if(Nt(o,a))return!0;if(!o.startsWith(a))return!1;let s=o.slice(a.length);for(let c of Ql){if(Nt(s,c))return!0;if(!s.startsWith(c))continue;let l=s.slice(c.length);if(c==="operation-started"||c==="operation-completed"){if($v(l))return!0}else if(Nt(l,'"}'))return!0}return!1}function Hv(e,t){if(e.length===0)throw new Error("Blank transaction event line");if(Buffer.byteLength(e,"utf8")>Zl)throw new Error(`Native transaction event at line ${t} is too large`);return iu(JSON.parse(e),t)}function Dv(e){let t=e.split(`
|
|
166
|
+
`),i=t.at(-1)==="";if(i&&t.pop(),t.length>Wr)throw new Error(`Native transaction event log exceeds ${Wr} events`);let r=[];for(let n=0;n<t.length;n+=1){let a=n+1,o=t[n],s=o.endsWith("\r")?o.slice(0,-1):o,c=!i&&n===t.length-1;try{r.push(Hv(s,a))}catch(l){if(c){let u=!1;try{JSON.parse(s),u=!0}catch{}if(!u&&Ov(s,a))break}throw new Error(`Invalid Native transaction event at line ${a}`,{cause:l})}}return r}function ru(e){return e.length===0?"":`${e.map(t=>JSON.stringify(t)).join(`
|
|
167
167
|
`)}
|
|
168
|
-
`}function jv(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return ye.join(e.transactionsDir,t)}function Wr(e,t){let i=jv(e,t);return{directory:i,journal:ye.join(i,"transaction.json"),events:ye.join(i,"events.jsonl"),staged:ye.join(i,"staged"),backups:ye.join(i,"backups")}}async function Xe(e,t){let i=Wr(e,t);return await Promise.all(Object.values(i).map(r=>$(e.runtimeDir,r))),i}async function iu(e,t,i={}){let r=await Xe(e,t);try{await Vr.lstat(r.events)}catch(n){if(n.code==="ENOENT")return{exists:!1,hash:null,size:0,events:[],canonicalSource:"",needsRepair:!1};throw n}try{let n=await J({root:e.runtimeDir,file:r.events,maxBytes:Rv,label:`Native transaction event log ${t}`,hooks:i.hooks}),a;try{a=Ql.decode(n.bytes)}catch(c){throw new Error(`Native transaction event log ${t} is not valid UTF-8`,{cause:c})}let o=Iv(a),s=tu(o);return{exists:!0,hash:n.hash,size:n.size,events:o,canonicalSource:s,needsRepair:a!==s}}catch(n){throw n.code==="ENOENT"?new Error(`Native transaction event log ${t} changed while reading`,{cause:n}):n}}async function Ul(e,t,i){let r=await iu(e,t);if(r.exists!==i.exists||r.hash!==i.hash||r.size!==i.size)throw new Error(`Native transaction event log ${t} changed before append`)}async function so(e,t,i,r){let n=await Xe(e,t),a=await iu(e,t),o=a.events.find(c=>c.type===i&&c.operationId===r);if(o)return a.needsRepair&&await z(n.events,a.canonicalSource,{containedRoot:e.runtimeDir,beforeCommit:()=>Ul(e,t,a)}),o;if(a.events.length>=qr)throw new Error(`Native transaction event log ${t} exceeds ${qr} events`);let s={sequence:a.events.length+1,timestamp:new Date().toISOString(),type:i,...r?{operationId:r}:{}};return eu(s,s.sequence),await Vr.mkdir(n.directory,{recursive:!0}),await z(n.events,tu([...a.events,s]),{containedRoot:e.runtimeDir,beforeCommit:()=>Ul(e,t,a)}),s}async function ru(e,t){if(t.schema!=="comet.native.transaction.v1")throw new Error("Native Archive v2 transactions require the content-bound transaction API");t=oo(t);let i=await Xe(e,t.id);await Vr.mkdir(i.staged,{recursive:!0}),await Vr.mkdir(i.backups,{recursive:!0}),await X(i.journal,t,{containedRoot:e.runtimeDir}),await so(e,t.id,"prepared")}async function gi(e,t,i={}){let r=await Xe(e,t),n=await J({root:e.runtimeDir,file:r.journal,maxBytes:Pv,label:`Native transaction journal ${t}`,hooks:i.hooks}),a=JSON.parse(Ql.decode(n.bytes)),o=oo(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}async function $v(e,t,i){if(t.schema!=="comet.native.transaction.v1")throw new Error("Native Archive v2 transactions require the content-bound transaction API");let r=oo({...t,status:i});return await X((await Xe(e,t.id)).journal,r,{containedRoot:e.runtimeDir}),r}async function co(e,t,i){if(t.schema!=="comet.native.transaction.v1")throw new Error("Native Archive v2 transactions require the content-bound transaction API");return await so(e,t.id,i),i==="commit"?$v(e,t,"committed"):t}import{createHash as Ng}from"node:crypto";import{promises as Qr}from"node:fs";import Be from"node:path";import{execFileSync as Ov}from"child_process";import Jr from"path";function zr(e,t){return Ov("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Hv(e,t){let i=Jr.normalize(e),r=Jr.normalize(t);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function He(e){try{let t=Jr.resolve(zr(e,["rev-parse","--show-toplevel"])),r=zr(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?Jr.resolve(r.slice(9)):t,a=null;try{a=zr(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Hv(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function lo(e,t){try{let i=zr(e,["rev-parse","--verify",`${t}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(i)?i:null}catch{return null}}import{createHash as Mv}from"node:crypto";import{promises as ce}from"node:fs";import Z from"node:path";import{TextDecoder as Fv}from"node:util";var Dv=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Bv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Lv(e){return e.toLowerCase().startsWith(".env")}function wi(e){let i=e.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Lv(r))?"environment-file":i.some(r=>Bv.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>Dv.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var Ur=1024*1024;function uo(e,t){let i=Z.relative(e,t);return i===""||!Z.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Z.sep}`)}function Vv(e){let t=Z.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||Z.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let i=e.toLowerCase(),r=wi(e);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${e}`);return e}function qv(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function Wv(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Gr(e,t){let i={...e,birthtime:e.birthtimeMs},r={...t,birthtime:t.birthtimeMs};return U(i,r)?T(i,r):T(i,r)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function nu(e){let t=await ce.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await ce.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function zv(e,t){let i=Z.resolve(e),r=Z.resolve(t);if(!uo(i,r))throw new Error("Native artifact path is outside its root");let n=[await nu(i)],a=i;for(let o of Z.relative(i,r).split(Z.sep).filter(Boolean)){a=Z.join(a,o);let s=await nu(a);if(!uo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function au(e){for(let t of e){let i=await ce.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Wv(t,i)||await ce.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function me(e){let t=Vv(e.ref),i=e.maxBytes===null?null:qv(e.maxBytes??Ur),r=Z.resolve(e.root,...t.split("/")),n=await zv(e.root,Z.dirname(r));await e.hooks?.afterParentChainCaptured?.();let a=await ce.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);let o=await ce.realpath(r);if(!uo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await ce.open(r,"r");try{let[c,l,u]=await Promise.all([s.stat(),ce.lstat(r),ce.realpath(r)]);if(await au(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Gr(a,c)||!Gr(c,l))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let b=i===null?p.length:i+1-f,k=await s.read(p,0,Math.min(p.length,b),null);if(k.bytesRead===0)break;if(f+=k.bytesRead,i!==null&&f>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);d.push(Buffer.from(p.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),ce.lstat(r),ce.realpath(r)]);if(await au(n),!h.isFile()||h.isSymbolicLink()||m!==o||!Gr(c,v)||!Gr(c,h))throw new Error(`Native artifact changed while reading: ${t}`);let w=Buffer.concat(d,f),y;try{y=new Fv("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:b})}return{ref:t,size:f,hash:e.includeHash===!1?null:Mv("sha256").update(w).digest("hex"),text:y}}finally{await s.close()}}var uu=St(ut(),1);import{createHash as Jv}from"crypto";function ee(e){return Jv("sha256").update(e).digest("hex")}var Gb={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var Ub=8*1024*1024;var Kb=64*1024,Yb=64*1024;var Xb={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},Qb={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var Zb=(1n<<256n)-1n;var Zv=St(ut(),1);var mk=4*1024*1024;var eg=null;function tg(e,t){let i=e;for(let r of t)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function ou(e,t){return(...i)=>{let r=eg;if(r===null)return t(...i);let n=tg(`async:${e}`,i),a=r.entries.get(n);if(a)return a.value;let o=t(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:o}),o}}var Nk=ou("hookWritePolicy",async e=>(await Ga(e))?.hook??{allow_paths:[]});var hS=256*1024;var RS={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 du=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],ZS=new Set(du),cg=new Set([...du,"minimum_runtime_version","revision"]),eE=new Set([...cg,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]);var Kr=class extends Error{constructor(i,r,n){super(`Native change ${i} revision conflict: expected ${r}, actual ${n}`);this.change=i;this.expectedRevision=r;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},yi=class extends Error{constructor(i,r){super(`Native working directory already contains active change${r.length===1?"":"s"} ${r.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=i;this.activeChanges=r;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},Yr=class extends Error{constructor(i,r,n,a,o,s=null,c=null){super(`Native change ${i} baseline is incomplete (${r} omitted entr${r===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=i;this.omittedCount=r;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},tE=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
|
|
169
|
-
`);var
|
|
170
|
-
${
|
|
171
|
-
${t}`).digest("hex")}async function
|
|
168
|
+
`}function Bv(e,t){if(!/^[a-f0-9-]{8,}$/u.test(t))throw new Error(`Invalid Native transaction id: ${t}`);return Ne.join(e.transactionsDir,t)}function zr(e,t){let i=Bv(e,t);return{directory:i,journal:Ne.join(i,"transaction.json"),events:Ne.join(i,"events.jsonl"),staged:Ne.join(i,"staged"),backups:Ne.join(i,"backups")}}async function Ze(e,t){let i=zr(e,t);return await Promise.all(Object.values(i).map(r=>$(e.runtimeDir,r))),i}async function nu(e,t,i={}){let r=await Ze(e,t);try{await Vr.lstat(r.events)}catch(n){if(n.code==="ENOENT")return{exists:!1,hash:null,size:0,events:[],canonicalSource:"",needsRepair:!1};throw n}try{let n=await J({root:e.runtimeDir,file:r.events,maxBytes:Tv,label:`Native transaction event log ${t}`,hooks:i.hooks}),a;try{a=eu.decode(n.bytes)}catch(c){throw new Error(`Native transaction event log ${t} is not valid UTF-8`,{cause:c})}let o=Dv(a),s=ru(o);return{exists:!0,hash:n.hash,size:n.size,events:o,canonicalSource:s,needsRepair:a!==s}}catch(n){throw n.code==="ENOENT"?new Error(`Native transaction event log ${t} changed while reading`,{cause:n}):n}}async function Yl(e,t,i){let r=await nu(e,t);if(r.exists!==i.exists||r.hash!==i.hash||r.size!==i.size)throw new Error(`Native transaction event log ${t} changed before append`)}async function co(e,t,i,r){let n=await Ze(e,t),a=await nu(e,t),o=a.events.find(c=>c.type===i&&c.operationId===r);if(o)return a.needsRepair&&await z(n.events,a.canonicalSource,{containedRoot:e.runtimeDir,beforeCommit:()=>Yl(e,t,a)}),o;if(a.events.length>=Wr)throw new Error(`Native transaction event log ${t} exceeds ${Wr} events`);let s={sequence:a.events.length+1,timestamp:new Date().toISOString(),type:i,...r?{operationId:r}:{}};return iu(s,s.sequence),await Vr.mkdir(n.directory,{recursive:!0}),await z(n.events,ru([...a.events,s]),{containedRoot:e.runtimeDir,beforeCommit:()=>Yl(e,t,a)}),s}async function au(e,t){if(t.schema!=="comet.native.transaction.v1")throw new Error("Native Archive v2 transactions require the content-bound transaction API");t=so(t);let i=await Ze(e,t.id);await Vr.mkdir(i.staged,{recursive:!0}),await Vr.mkdir(i.backups,{recursive:!0}),await Y(i.journal,t,{containedRoot:e.runtimeDir}),await co(e,t.id,"prepared")}async function wi(e,t,i={}){let r=await Ze(e,t),n=await J({root:e.runtimeDir,file:r.journal,maxBytes:_v,label:`Native transaction journal ${t}`,hooks:i.hooks}),a=JSON.parse(eu.decode(n.bytes)),o=so(a);if(o.id!==t)throw new Error(`Invalid Native transaction journal: ${t}`);return o}async function Lv(e,t,i){if(t.schema!=="comet.native.transaction.v1")throw new Error("Native Archive v2 transactions require the content-bound transaction API");let r=so({...t,status:i});return await Y((await Ze(e,t.id)).journal,r,{containedRoot:e.runtimeDir}),r}async function lo(e,t,i){if(t.schema!=="comet.native.transaction.v1")throw new Error("Native Archive v2 transactions require the content-bound transaction API");return await co(e,t.id,i),i==="commit"?Lv(e,t,"committed"):t}import{createHash as Pg}from"node:crypto";import{promises as Zr}from"node:fs";import Me from"node:path";import{execFileSync as Mv}from"child_process";import Gr from"path";function Jr(e,t){return Mv("git",["-C",e,...t],{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:1e4,windowsHide:!0}).trim()}function Fv(e,t){let i=Gr.normalize(e),r=Gr.normalize(t);return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function Be(e){try{let t=Gr.resolve(Jr(e,["rev-parse","--show-toplevel"])),r=Jr(e,["worktree","list","--porcelain","-z"]).split("\0").find(o=>o.startsWith("worktree ")),n=r?Gr.resolve(r.slice(9)):t,a=null;try{a=Jr(e,["symbolic-ref","--quiet","--short","HEAD"])||null}catch{}return{isGitWorktree:!0,isSecondaryWorktree:!Fv(t,n),currentWorktreeRoot:t,primaryWorktreeRoot:n,currentBranch:a}}catch{return{isGitWorktree:!1,isSecondaryWorktree:!1,currentWorktreeRoot:null,primaryWorktreeRoot:null,currentBranch:null}}}function uo(e,t){try{let i=Jr(e,["rev-parse","--verify",`${t}^{commit}`]).toLowerCase();return/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(i)?i:null}catch{return null}}import{createHash as zv}from"node:crypto";import{promises as se}from"node:fs";import Q from"node:path";import{TextDecoder as Jv}from"node:util";var qv=new Set([".cache",".git",".gradle",".gnupg",".mypy_cache",".next",".npm",".pnpm-store",".pytest_cache",".ssh",".turbo",".venv",".yarn","__pycache__","node_modules","venv"]),Vv=new Set([".git-credentials",".netrc",".npmrc",".pypirc","auth.json","credentials.json"]);function Wv(e){return e.toLowerCase().startsWith(".env")}function yi(e){let i=e.replaceAll("\\","/").split("/").filter(Boolean).map(r=>r.toLowerCase());return i.some(r=>Wv(r))?"environment-file":i.some(r=>Vv.has(r))?"credential-config":i.includes(".git")?"git-metadata":i.some(r=>qv.has(r))?"dependency-or-cache":i.join("/")===".comet/config.yaml"?"comet-config":i.join("/")===".comet/current-change.json"?"comet-selection":null}var Kr=1024*1024;function fo(e,t){let i=Q.relative(e,t);return i===""||!Q.isAbsolute(i)&&i!==".."&&!i.startsWith(`..${Q.sep}`)}function Gv(e){let t=Q.posix.normalize(e);if(e.length===0||e!==e.trim()||e.includes("\\")||Array.from(e).some(n=>{let a=n.codePointAt(0)??0;return a<=31||a===127})||Q.posix.isAbsolute(t)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes("..")||t!==e||t==="."||e.endsWith("/"))throw new Error(`Native artifact ref must be normalized and relative: ${e}`);let i=e.toLowerCase(),r=yi(e);if(r||i==="runtime"||i.startsWith("runtime/"))throw new Error(`Native artifact ref is excluded as sensitive (${r??"native-runtime"}): ${e}`);return e}function Uv(e){if(!Number.isSafeInteger(e)||e<1)throw new Error("Native artifact byte limit must be a positive integer");return e}function Kv(e,t){return T({...e,birthtime:e.birthtimeMs},{...t,birthtime:t.birthtimeMs})}function Ur(e,t){let i={...e,birthtime:e.birthtimeMs},r={...t,birthtime:t.birthtimeMs};return de(i,r)?T(i,r):T(i,r)&&e.birthtimeMs===t.birthtimeMs&&e.ctimeMs===t.ctimeMs&&e.size===t.size}async function ou(e){let t=await se.lstat(e);if(!t.isDirectory()||t.isSymbolicLink())throw new Error(`Native artifact parent must be a real directory: ${e}`);return{path:e,realPath:await se.realpath(e),dev:t.dev,ino:t.ino,birthtimeMs:t.birthtimeMs}}async function Yv(e,t){let i=Q.resolve(e),r=Q.resolve(t);if(!fo(i,r))throw new Error("Native artifact path is outside its root");let n=[await ou(i)],a=i;for(let o of Q.relative(i,r).split(Q.sep).filter(Boolean)){a=Q.join(a,o);let s=await ou(a);if(!fo(n[0].realPath,s.realPath))throw new Error(`Native artifact parent resolves outside its root: ${a}`);n.push(s)}return n}async function su(e){for(let t of e){let i=await se.lstat(t.path);if(!i.isDirectory()||i.isSymbolicLink()||!Kv(t,i)||await se.realpath(t.path)!==t.realPath)throw new Error(`Native artifact parent changed while reading: ${t.path}`)}}async function me(e){let t=Gv(e.ref),i=e.maxBytes===null?null:Uv(e.maxBytes??Kr),r=Q.resolve(e.root,...t.split("/")),n=await Yv(e.root,Q.dirname(r));await e.hooks?.afterParentChainCaptured?.();let a=await se.lstat(r);if(!a.isFile()||a.isSymbolicLink())throw new Error(`Native artifact must be a regular file: ${t}`);if(i!==null&&a.size>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);let o=await se.realpath(r);if(!fo(n[0].realPath,o))throw new Error(`Native artifact resolves outside its root: ${t}`);let s=await se.open(r,"r");try{let[c,l,u]=await Promise.all([s.stat(),se.lstat(r),se.realpath(r)]);if(await su(n),!c.isFile()||!l.isFile()||l.isSymbolicLink()||u!==o||!Ur(a,c)||!Ur(c,l))throw new Error(`Native artifact changed while opening: ${t}`);await e.hooks?.afterOpen?.();let d=[],f=0,p=Buffer.allocUnsafe(i===null?64*1024:Math.min(64*1024,i+1));for(;;){let b=i===null?p.length:i+1-f,k=await s.read(p,0,Math.min(p.length,b),null);if(k.bytesRead===0)break;if(f+=k.bytesRead,i!==null&&f>i)throw new Error(`Native artifact exceeds ${i} bytes: ${t}`);d.push(Buffer.from(p.subarray(0,k.bytesRead)))}await e.hooks?.beforeFinalCheck?.();let[v,h,m]=await Promise.all([s.stat(),se.lstat(r),se.realpath(r)]);if(await su(n),!h.isFile()||h.isSymbolicLink()||m!==o||!Ur(c,v)||!Ur(c,h))throw new Error(`Native artifact changed while reading: ${t}`);let w=Buffer.concat(d,f),y;try{y=new Jv("utf-8",{fatal:!0}).decode(w)}catch(b){throw new Error(`Native artifact is not valid UTF-8: ${t}`,{cause:b})}return{ref:t,size:f,hash:e.includeHash===!1?null:zv("sha256").update(w).digest("hex"),text:y}}finally{await s.close()}}var fu=Et(ft(),1);import{createHash as Xv}from"crypto";function Z(e){return Xv("sha256").update(e).digest("hex")}var Zb={maxFiles:1e4,maxFileBytes:5*1024*1024,maxTotalBytes:64*1024*1024,maxManifestBytes:1024*1024};var ek=8*1024*1024;var tk=64*1024,ik=64*1024;var rk={maxRecords:2e4,maxBytes:8*1024*1024,maxRecordBytes:64*1024},nk={maxNodes:2e4,maxBytes:8*1024*1024,maxPathBytes:64*1024};var ak=(1n<<256n)-1n;var ng=Et(ft(),1);var bk=4*1024*1024;var ag=null;function og(e,t){let i=e;for(let r of t)i+="\0"+(typeof r=="string"?r:JSON.stringify(r));return i}function cu(e,t){return(...i)=>{let r=ag;if(r===null)return t(...i);let n=og(`async:${e}`,i),a=r.entries.get(n);if(a)return a.value;let o=t(...i).catch(s=>{throw r.entries.delete(n),s});return r.entries.set(n,{value:o}),o}}var Rk=cu("hookWritePolicy",async e=>(await Ua(e))?.hook??{allow_paths:[]});var yS=256*1024;var IS={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 hu=["schema","name","language","phase","brief","approval","spec_changes","verification_result","verification_report","archived","created_at","run_id"],aE=new Set(hu),hg=new Set([...hu,"minimum_runtime_version","revision"]),oE=new Set([...hg,"approved_contract_hash","implementation_scope","verification_evidence","partial_allowance","verification_protocol"]);var Yr=class extends Error{constructor(i,r,n){super(`Native change ${i} revision conflict: expected ${r}, actual ${n}`);this.change=i;this.expectedRevision=r;this.actualRevision=n;this.name="NativeChangeRevisionConflictError"}change;expectedRevision;actualRevision;code="native-change-revision-conflict"},Ni=class extends Error{constructor(i,r){super(`Native working directory already contains active change${r.length===1?"":"s"} ${r.join(", ")}; create the new change in a separate worktree`);this.requestedIsolation=i;this.activeChanges=r;this.name="NativeWorkspaceIsolationRequiredError"}requestedIsolation;activeChanges;code="native-workspace-isolation-required"},Xr=class extends Error{constructor(i,r,n,a,o,s=null,c=null){super(`Native change ${i} baseline is incomplete (${r} omitted entr${r===1?"y":"ies"}). Adjust native.snapshot scope or resource budgets in .comet/config.yaml, then retry.`);this.change=i;this.omittedCount=r;this.omittedByReason=n;this.samplePaths=a;this.sampleTruncated=o;this.effectiveLimits=s;this.policyHash=c;this.name="NativeBaselineIncompleteError"}change;omittedCount;omittedByReason;samplePaths;sampleTruncated;effectiveLimits;policyHash;code="native-baseline-incomplete"},sE=["# Outcome","","# Scope","","# Non-goals","","# Acceptance examples","","# Constraints and invariants","","# Decisions","","# Open questions","","# Verification expectations",""].join(`
|
|
169
|
+
`);var cE=256*1024;import{createHash as pg}from"crypto";function ce(e){throw new TypeError(`Value is not valid canonical JSON: ${e}`)}function mg(e,t){t.has(e)&&ce("cyclic structures are not supported"),t.add(e);try{let i=Object.keys(e);for(let r=0;r<e.length;r+=1)Object.prototype.hasOwnProperty.call(e,r)||ce("sparse arrays are not supported");return(i.length!==e.length||i.some((r,n)=>r!==String(n)))&&ce("arrays must not have named enumerable properties"),Object.getOwnPropertySymbols(e).length>0&&ce("symbol properties are not supported"),`[${e.map(r=>mo(r,t)).join(",")}]`}finally{t.delete(e)}}function vg(e,t){let i=Object.getPrototypeOf(e);i!==Object.prototype&&i!==null&&ce("only plain objects are supported"),t.has(e)&&ce("cyclic structures are not supported"),Object.getOwnPropertySymbols(e).length>0&&ce("symbol properties are not supported"),t.add(e);try{let r=Object.getOwnPropertyDescriptors(e);return`{${Object.keys(e).sort().map(o=>{let s=r[o];return(!s||!("value"in s))&&ce("accessor properties are not supported"),`${JSON.stringify(o)}:${mo(s.value,t)}`}).join(",")}}`}finally{t.delete(e)}}function mo(e,t){if(e===null)return"null";switch(typeof e){case"boolean":return e?"true":"false";case"string":return JSON.stringify(e);case"number":return Number.isFinite(e)||ce("numbers must be finite"),JSON.stringify(Object.is(e,-0)?0:e);case"object":return Array.isArray(e)?mg(e,t):vg(e,t);case"bigint":case"function":case"symbol":case"undefined":return ce(`${typeof e} values are not supported`)}return ce("unsupported value type")}function vo(e){return mo(e,new Set)}function ee(e,t){if(e.length===0)throw new TypeError("Canonical hash tag must be non-empty");if(/[\r\n]/u.test(e))throw new TypeError("Canonical hash tag must not contain a line break");return pg("sha256").update(`${e}
|
|
170
|
+
${vo(t)}`).digest("hex")}var mE=Object.freeze({maxItems:16,maxTextBytes:512,maxContextItems:4,maxContextItemBytes:256,maxFailedCheckIds:16,maxSerializedBytes:32*1024}),pu=Object.freeze({maxCriteria:1024});var mu=Et(ft(),1);var yu="[a-z][a-z0-9]*(?:-[a-z0-9]+)*",DE=new RegExp(`^portable-archive-(${yu})\\.json$`,"u"),BE=new RegExp(`^portable-migration-(${yu})\\.json$`,"u");var bi=/^[a-f0-9]{64}$/u,Nu=/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u,Rg=16*1024,wo=process.platform;function Su(e,t){let i=Me.relative(e,t);return Me.isAbsolute(i)||i===".."||i.startsWith(`..${Me.sep}`)?null:i.replaceAll("\\","/")||"."}function Eu(e){return Array.from(e).some(t=>{let i=t.codePointAt(0)??0;return i<=31||i===127})}function Pu(e,t){if(e.length===0||Eu(e)||e.includes("\\")||Me.posix.isAbsolute(e)||/^(?:[A-Za-z]:|~)/u.test(e)||e.split("/").includes(".."))throw new Error(`${t} must be a portable project-relative path`);let i=Me.posix.normalize(e);if(i!==e||i===".."||i.startsWith("../"))throw new Error(`${t} must be a normalized project-relative path`);return i}function yo(e,t){return Pg("sha256").update(`${e}
|
|
171
|
+
${t}`).digest("hex")}async function bu(e,t){let i=await Zr.realpath(t),r=await Zr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=wo==="win32"?Me.normalize(i).toLowerCase():i;return yo(e,`${n}
|
|
172
172
|
${r.dev}
|
|
173
173
|
${r.ino}
|
|
174
|
-
${r.birthtimeMs}`)}async function
|
|
174
|
+
${r.birthtimeMs}`)}async function ku(e,t){let i=await Zr.realpath(t),r=await Zr.lstat(i);if(!r.isDirectory()||r.isSymbolicLink())throw new Error("Native workspace identity requires a real directory");let n=wo==="win32"?Me.normalize(i).toLowerCase():i;return yo(e,n)}function xg(e){if(typeof e!="string")throw new Error("Native workspace capturedAt is invalid");let t=new Date(e);if(!Number.isFinite(t.getTime())||t.toISOString()!==e)throw new Error("Native workspace capturedAt is invalid");return e}function go(e,t){if(e===null)return null;if(typeof e!="string"||e.length===0||e.trim()!==e||Eu(e))throw new Error(`${t} must be a non-empty branch name or null`);return e}function Ru(e){if(!new Set(["current","branch","worktree"]).has(e.isolation))throw new Error("Native workspace isolation must be current, branch, or worktree");if(go(e.changeBranch,"Native workspace change branch"),go(e.targetBranch,"Native workspace target branch"),(e.isolation==="branch"||e.isolation==="worktree")&&(e.changeBranch===null||e.targetBranch===null))throw new Error("Native isolated workspace requires change and target branches")}function Cg(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace Git provenance must be an object");let t=e,i=new Set(["provider","baseCommit","targetBranch","targetCommit"]),r=Object.keys(t).filter(n=>!i.has(n));if(r.length>0)throw new Error(`Native workspace Git provenance has unknown field(s): ${r.join(", ")}`);if(t.provider!=="git"||typeof t.baseCommit!="string"||!Nu.test(t.baseCommit)||typeof t.targetCommit!="string"||!Nu.test(t.targetCommit))throw new Error("Native workspace Git provenance is invalid");go(t.targetBranch,"Native workspace Git target branch")}function en(e){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native workspace identity must be an object");let t=e,i=new Set(["schema","capturedAt","capturedRevision","nativeRootRef","projectRootId","nativeRootId","projectRootPathId","nativeRootPathId","sessionHash","git","isolation","changeBranch","targetBranch","finish"]),r=Object.keys(t).filter(o=>!i.has(o));if(r.length>0)throw new Error(`Native workspace identity has unknown field(s): ${r.join(", ")}`);if(t.schema!=="comet.native.workspace.v2"&&t.schema!=="comet.native.workspace.v3")throw new Error("Unsupported Native workspace identity");if(!Number.isSafeInteger(t.capturedRevision)||t.capturedRevision<1||typeof t.nativeRootRef!="string"||!bi.test(String(t.projectRootId))||!bi.test(String(t.nativeRootId)))throw new Error("Native workspace identity is invalid");xg(t.capturedAt),Pu(t.nativeRootRef,"Native workspace root ref");let n=t.projectRootPathId!==void 0,a=t.nativeRootPathId!==void 0;if(n!==a)throw new Error("Native workspace path identities must be provided together");if(n&&!bi.test(String(t.projectRootPathId))||a&&!bi.test(String(t.nativeRootPathId)))throw new Error("Native workspace path identity is invalid");if(t.sessionHash!==void 0&&!bi.test(String(t.sessionHash)))throw new Error("Native workspace session hash is invalid");if(t.git!==void 0&&Cg(t.git),t.schema==="comet.native.workspace.v2"){if(t.isolation!==void 0||t.changeBranch!==void 0||t.targetBranch!==void 0||t.finish!==void 0)throw new Error("Native workspace v2 identity cannot contain a workspace binding");return}if(typeof t.isolation!="string"||t.changeBranch===void 0||t.targetBranch===void 0||t.finish===void 0)throw new Error("Native workspace v3 identity requires a workspace binding");if(Ru(t),t.finish!==null&&!new Set(["merge","push","pull-request","keep"]).has(t.finish))throw new Error("Native workspace finish must be merge, push, pull-request, keep, or null")}function xu(e,t){return Me.join(he(e,t),"workspace.json")}function Ag(e,t){let i=xu(e,t),r=ae(e,i),n=Su(r,i);if(!n||n===".")throw new Error("Native workspace file escaped its root");return{root:r,ref:Pu(n,"Native workspace file ref")}}async function _g(e,t){try{let i=Ag(e,t),r=await me({root:i.root,ref:i.ref,maxBytes:Rg});return JSON.parse(r.text)}catch(i){if(i.code==="ENOENT")return null;throw i}}async function Cu(e){if(!Number.isSafeInteger(e.revision)||e.revision<1)throw new Error("Native workspace revision must be a positive integer");let t=Su(e.paths.projectRoot,e.paths.nativeRoot);if(!t)throw new Error("Native root is outside the project root");let i=Be(e.paths.projectRoot),r=i.isGitWorktree?uo(e.paths.projectRoot,"HEAD"):null,n=e.binding?.targetBranch??i.currentBranch,a=n==null?null:uo(e.paths.projectRoot,n),o=r!==null&&n!==null&&n!==void 0&&a!==null?{provider:"git",baseCommit:r,targetBranch:n,targetCommit:a}:void 0,[s,c,l,u]=await Promise.all([bu("comet.native.workspace-project-root.v2",e.paths.projectRoot),bu("comet.native.workspace-native-root.v2",e.paths.nativeRoot),ku("comet.native.workspace-project-root-path.v2",e.paths.projectRoot),ku("comet.native.workspace-native-root-path.v2",e.paths.nativeRoot)]),d=(e.now??new Date).toISOString();if(e.finish&&!e.binding)throw new Error("Native workspace finish requires a workspace binding");e.binding&&Ru(e.binding);let f={capturedAt:d,capturedRevision:e.revision,nativeRootRef:t,projectRootId:s,nativeRootId:c,projectRootPathId:l,nativeRootPathId:u,...o?{git:o}:{},...e.sessionId?{sessionHash:yo("comet.native.workspace-session.v2",`${s}
|
|
175
175
|
${c}
|
|
176
|
-
${e.sessionId}`)}:{}},p=e.binding?{schema:"comet.native.workspace.v3",...f,...e.binding,finish:e.finish??null}:{schema:"comet.native.workspace.v2",...f};return
|
|
177
|
-
`}function Bg(e){return xg("sha256").update(e).digest("hex")}function Lg(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Native root-move cleanup manifest entry ${t} must be an object`);let i=e,r=Object.keys(i).sort(),n=i.type==="file"?["hash","ref","size","type"]:["ref","type"];if(JSON.stringify(r)!==JSON.stringify(n))throw new Error(`Native root-move cleanup manifest entry ${t} has invalid fields`);if(typeof i.ref!="string"||i.ref.length===0||i.ref.includes("\\")||I.posix.normalize(i.ref)!==i.ref||i.ref.startsWith("/")||i.ref.split("/").includes("..")||Buffer.byteLength(i.ref,"utf8")>4096)throw new Error(`Native root-move cleanup manifest entry ${t} has an invalid ref`);if(i.type==="directory")return{ref:i.ref,type:"directory"};if(i.type!=="file"||typeof i.size!="number"||!Number.isSafeInteger(i.size)||i.size<0||typeof i.hash!="string"||!/^[a-f0-9]{64}$/u.test(i.hash))throw new Error(`Native root-move cleanup manifest entry ${t} is invalid`);return{ref:i.ref,type:"file",size:i.size,hash:i.hash}}function Mg(e,t,i){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native root-move cleanup manifest must be an object");let r=e;if(JSON.stringify(Object.keys(r).sort())!==JSON.stringify(["entries","kind","schema","transactionId"])||r.schema!=="comet.native.root-move-cleanup.v1"||r.transactionId!==t||r.kind!==i||!Array.isArray(r.entries))throw new Error("Native root-move cleanup manifest binding is invalid");let n=r.entries.map(Lg);for(let a=0;a<n.length;a+=1){if(a>0&&n[a-1].ref.localeCompare(n[a].ref)>=0)throw new Error("Native root-move cleanup manifest refs must be unique and sorted");let o=I.posix.dirname(n[a].ref);if(o!=="."&&!n.some(s=>s.ref===o&&s.type==="directory"))throw new Error(`Native root-move cleanup manifest parent is missing: ${o}`)}return{schema:"comet.native.root-move-cleanup.v1",transactionId:t,kind:i,entries:n}}async function Fg(e){let t={schema:"comet.native.root-move-cleanup.v1",transactionId:e.id,kind:e.kind,entries:e.entries},i=Dg(t);if(Buffer.byteLength(i,"utf8")>_u)throw new Error("Native root-move cleanup manifest exceeds its byte budget");return await z(Tu(e.paths,e.id,e.kind),i,{containedRoot:e.paths.runtimeDir}),Bg(i)}async function Vg(e){let t=await J({root:e.paths.runtimeDir,file:Tu(e.paths,e.id,e.cleanup.kind),maxBytes:_u,label:`Native root-move cleanup manifest ${e.cleanup.kind}`});if(t.hash!==e.cleanup.manifestHash)throw new Error("Native root-move cleanup manifest hash changed");return Mg(JSON.parse(t.bytes.toString("utf8")),e.id,e.cleanup.kind)}async function yo(e){let t=await ki(e.quarantine,{rejectSymlinks:!0}),i=new Map(e.manifest.entries.map(r=>[r.ref,r]));for(let r of t){let n=i.get(r.ref);if(!n||JSON.stringify(n)!==JSON.stringify(r))throw new Error(`Native root-move cleanup quarantine differs from its bound manifest: ${r.ref}`)}if(e.exact&&t.length!==e.manifest.entries.length)throw new Error("Native root-move cleanup quarantine is incomplete before deletion");return t}function xu(e){return e.ref.split("/").length}async function qg(e){let i=[...await yo({quarantine:e.quarantine,manifest:e.manifest,exact:!1})].sort((n,a)=>xu(a)-xu(n)||(n.type===a.type?a.ref.localeCompare(n.ref):n.type==="file"?-1:1)),r=0;for(let n of i){let a=I.join(e.quarantine,...n.ref.split("/"));n.type==="file"?await ro({root:e.projectRoot,file:a,maxBytes:No,expectedHash:n.hash,expectedSize:n.size,label:`Native root-move cleanup file ${n.ref}`}):await no({root:e.projectRoot,directory:a,label:`Native root-move cleanup directory ${n.ref}`}),r+=1,await e.hooks?.afterRootMoveCleanupEntryRemoved?.(e.manifest.kind,n.ref,r)}await yo({quarantine:e.quarantine,manifest:e.manifest,exact:!1}),await no({root:e.projectRoot,directory:e.quarantine,label:`Native root-move cleanup quarantine ${e.manifest.kind}`})}function tn(e,t,i=e.native.artifact_root){return{...e,native:{...e.native,artifact_root:i,pending_root_move:t}}}function Wg(e){return{schema:"comet.native.transaction.v1",id:e.id,kind:"root-move",status:"prepared",projectRoot:e.paths.projectRoot,nativeRoot:e.paths.nativeRoot,createdAt:e.now.toISOString(),operations:[]}}async function Cu(e){let t=tn(e.config,{...e.pending,stage:e.stage},e.activeArtifactRoot);return await $e(e.projectRoot,t),t}async function bi(e){let t=e.config.native.pending_root_move;if(!t||t.id!==e.id)throw new Error(`Native root-move cleanup ${e.id} lost its pending configuration`);let i=tn(e.config,{id:t.id,fromArtifactRoot:t.fromArtifactRoot,toArtifactRoot:t.toArtifactRoot,stage:t.stage,...e.cleanup?{cleanup:e.cleanup}:{}},e.config.native.artifact_root);return await $e(e.projectRoot,i),i}async function Au(e){let t=e.config,i=t.native.pending_root_move;if(!i||i.id!==e.id)throw new Error(`Native root-move cleanup ${e.id} lost its pending configuration`);let r=i.cleanup;if(r&&r.kind!==e.kind)throw new Error(`Native root move has unfinished ${r.kind} cleanup; cannot start ${e.kind}`);let n=await K(e.target),a=await K(e.quarantine);if(n&&a)throw new Error(`Native root-move cleanup target and quarantine both exist: ${e.kind}`);if(!r){if(!n&&!a)return t;if(!n&&a)throw new Error(`Native root-move cleanup quarantine is not transaction-bound: ${e.kind}`);let s=await Fg({paths:e.stablePaths,id:e.id,kind:e.kind,entries:await ki(e.target,{rejectSymlinks:!0})});r={kind:e.kind,state:"prepared",manifestHash:s},t=await bi({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:r})}let o=await Vg({paths:e.stablePaths,id:e.id,cleanup:r});if(n=await K(e.target),a=await K(e.quarantine),n&&a)throw new Error(`Native root-move cleanup target and quarantine both exist: ${e.kind}`);if(n){if(r.state!=="prepared")throw new Error(`Native root-move cleanup target reappeared after quarantine: ${e.kind}`);await Jl({root:e.projectRoot,directory:e.target,quarantine:e.quarantine,label:e.label,beforeQuarantine:e.beforeQuarantine,afterQuarantine:e.afterQuarantine}),a=!0}if(!a){if(r.state!=="deleting")throw new Error(`Native root-move cleanup quarantine disappeared: ${e.kind}`);return bi({projectRoot:e.projectRoot,config:t,id:e.id})}return await yo({quarantine:e.quarantine,manifest:o,exact:r.state!=="deleting"}),r.state==="prepared"&&(r={...r,state:"quarantined"},t=await bi({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:r})),r.state==="quarantined"&&(r={...r,state:"deleting"},t=await bi({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:r})),await qg({projectRoot:e.projectRoot,quarantine:e.quarantine,manifest:o,hooks:e.hooks}),bi({projectRoot:e.projectRoot,config:t,id:e.id})}async function zg(e){let t=e.config,i=t.native.pending_root_move.stage;if(i==="copying"){if(!await K(e.sourcePaths.nativeRoot))throw new Error(`Native source root is missing: ${e.sourcePaths.nativeRoot}`);let s=Hg(e.staging);t=await Au({projectRoot:e.projectRoot,config:t,id:e.pending.id,kind:"restart-staging",stablePaths:e.sourcePaths,target:e.staging,quarantine:s,label:"Native root move stale staging removal",hooks:e.hooks}),await ki(e.sourcePaths.nativeRoot,{rejectSymlinks:!0,excludedFiles:new Set([I.resolve(e.lockFile)])}),await jg(e.sourcePaths.nativeRoot,e.staging,e.lockFile,e.destinationPaths.projectRoot),await en(e.sourcePaths.nativeRoot,e.staging,e.lockFile),t=await Cu({projectRoot:e.projectRoot,config:t,pending:e.pending,stage:"ready"}),i="ready",await e.hooks?.afterRootMoveStage?.("ready",e.journal)}if(i==="ready"){if(await K(e.destinationPaths.nativeRoot)){if(await K(e.staging))throw new Error(`Native destination is occupied: ${e.destinationPaths.nativeRoot}`);await en(e.sourcePaths.nativeRoot,e.destinationPaths.nativeRoot,e.lockFile)}else{if(!await K(e.staging))throw new Error("Native move staging tree is missing");await en(e.sourcePaths.nativeRoot,e.staging,e.lockFile),await Le.rename(e.staging,e.destinationPaths.nativeRoot)}t=await Cu({projectRoot:e.projectRoot,config:t,pending:e.pending,stage:"switched",activeArtifactRoot:e.pending.toArtifactRoot}),i="switched",await e.hooks?.afterRootMoveStage?.("switched",e.journal)}if(i!=="switched")throw new Error(`Unsupported Native root-move stage: ${i}`);if(!await K(e.destinationPaths.nativeRoot))throw new Error(`Native destination root is missing: ${e.destinationPaths.nativeRoot}`);let r=Og(e.sourcePaths,e.pending.id);!t.native.pending_root_move?.cleanup&&await K(e.sourcePaths.nativeRoot)&&await en(e.sourcePaths.nativeRoot,e.destinationPaths.nativeRoot,e.lockFile),t=await Au({projectRoot:e.projectRoot,config:t,id:e.pending.id,kind:"forward-source",stablePaths:e.destinationPaths,target:e.sourcePaths.nativeRoot,quarantine:r,label:"Native root move source removal",beforeQuarantine:()=>e.hooks?.beforeRootMoveSourceRemove?.(e.sourcePaths.nativeRoot),afterQuarantine:s=>e.hooks?.afterRootMoveSourceQuarantined?.(s),hooks:e.hooks}),await Tg(e.destinationPaths);let n=await gi(e.destinationPaths,e.pending.id);await co(e.destinationPaths,n,"commit");let a={artifact_root:t.native.artifact_root,language:t.native.language,clarification_mode:t.native.clarification_mode,archive_confirmation:t.native.archive_confirmation,max_verify_failures:t.native.max_verify_failures,snapshot:t.native.snapshot},o={...t,native:{...a,artifact_root:e.pending.toArtifactRoot}};return await $e(e.projectRoot,o),o}async function Iu(e){let t=await se(e.projectRoot)??jl("docs");if(t.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is already incomplete`);let i=li(e.toArtifactRoot);if(i===t.native.artifact_root)throw new Error(`Native artifact root is already ${i}`);let r=await fe(e.projectRoot,t.native.artifact_root),n=await fe(e.projectRoot,i);if(F(r.nativeRoot,n.nativeRoot)||F(n.nativeRoot,r.nativeRoot))throw new Error("Native source and destination roots must not overlap");if(!await K(r.nativeRoot))throw new Error(`Native source root does not exist: ${r.nativeRoot}`);if(await Ag(r),await K(n.nativeRoot))throw new Error(`Native destination is occupied: ${n.nativeRoot}`);let a=await ui(r,"root-move",`move root to ${i}`),o=Cg(),s={id:o,fromArtifactRoot:t.native.artifact_root,toArtifactRoot:i,stage:"copying"},c=Wg({id:o,paths:r,now:e.now??new Date}),l=$g(n,o);try{if(await _g(r,a.file),await Ig(r),await K(l))throw new Error(`Native move staging path is occupied: ${l}`);return await $e(e.projectRoot,tn(t,s)),await ru(r,c),await e.hooks?.afterRootMoveStage?.("copying",c),await zg({projectRoot:e.projectRoot,config:tn(t,s),pending:s,sourcePaths:r,destinationPaths:n,staging:l,journal:c,lockFile:a.file,hooks:e.hooks}),{fromNativeRoot:r.nativeRoot,toNativeRoot:n.nativeRoot,transactionId:o}}finally{await di(a)}}import So from"path";var Gg=["Outcome","Scope","Non-goals","Acceptance examples"],SP=[...Gg,"Constraints and invariants","Decisions","Open questions","Verification expectations"];var Ug=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});var ju=1024*1024;var Ou="scoped-text-safety",Kg=1,Yg=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var Xg="comet.native.checker-policy.v1";var MP=te(Xg,{policy:Ou,version:Kg,limits:Yg,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var Qg=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],FP=new Set(Qg);var tw=ju,nR=3*tw;var Hu={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},rw=ee("comet-native-runtime:v3:scope-reopen"),TR=[{skillVersion:"3",skillHash:ee("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:ee("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:ee("comet-native-runtime:v1")}];var Bu=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],dx=new Set(Bu),uw=new Set([...Bu,"minimum_runtime_version","revision"]),fx=new Set([...uw,"operation"]),hx=512*1024,dw=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),px=new Set([...dw,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var wx={maxAcceptanceCriteria:fu.maxCriteria};var Sx={maxSpecs:64,maxFileBytes:Ur,maxTotalBytes:4*1024*1024};import{execFile as kw}from"node:child_process";import{promisify as Sw}from"node:util";var Px=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");var Hx={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var rC=512*1024;var Pi=class extends Error{recovery;constructor(t,i){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var RC=64*1024;var xC=3600*1e3;var CC=Sw(kw);var rn=class extends Error{details;constructor(t){let i=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=t}};var hA={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var kA=16*1024*1024,SA=256*1024,EA=16*1024;var AA=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var IA=16*1024;var Tw=St(ut(),1);var $A=8*1024*1024;var ST=16*1024;var fI=16*1024*1024,nn=class extends Error{constructor(i,r,n,a){super(`Canonical spec conflict for ${i}: expected ${r??"(missing)"}, actual ${n??"(missing)"}`);this.capability=i;this.expectedHash=r;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},an=class extends Error{constructor(i,r=i.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${i.findingCodes.join(", ")}`){super(r);this.preflight=i;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var on=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};var Fu=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--help Show help without requiring an initialized project."],ko=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:Fu,output:"Human-readable text by default; use --json for a structured command envelope.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page.","--details Include acceptance, Spec, workspace, and report details."],output:"A v2 status page or one portable Loop projection with local execution availability and continuation.runnerAction; parent changes also expose children and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--confirmed|--return-to-build|--retry-verifier|--resolve-verifier-blocker]
|
|
178
|
-
comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm Shape
|
|
179
|
-
comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Inspect readiness without rerunning verification.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness plus continuation, or the completed Archive transaction and workspace finish result; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function
|
|
176
|
+
${e.sessionId}`)}:{}},p=e.binding?{schema:"comet.native.workspace.v3",...f,...e.binding,finish:e.finish??null}:{schema:"comet.native.workspace.v2",...f};return en(p),p}async function ho(e){let t=await Cu(e),i=xu(e.paths,e.name),r=ae(e.paths,i);return await $(r,i),await Y(i,t,{containedRoot:r}),t}async function kt(e,t){let i=await _g(e,t);return i===null||i&&typeof i=="object"&&!Array.isArray(i)&&i.schema==="comet.native.workspace.v1"?null:(en(i),i)}async function Qr(e){en(e.identity);let t=await Cu({paths:e.paths,name:"workspace-advisory",revision:e.identity.capturedRevision}),i=[],r=[];return t.nativeRootRef!==e.identity.nativeRootRef&&i.push("native-root-ref"),e.identity.projectRootPathId&&e.identity.nativeRootPathId?(t.projectRootPathId!==e.identity.projectRootPathId&&i.push("project-root-path"),t.nativeRootPathId!==e.identity.nativeRootPathId&&i.push("native-root-path")):(t.projectRootId!==e.identity.projectRootId&&i.push("project-root-legacy-identity"),t.nativeRootId!==e.identity.nativeRootId&&i.push("native-root-legacy-identity")),wo==="win32"&&i.length>0&&i.every(a=>a==="project-root-legacy-identity"||a==="native-root-legacy-identity")?r.push("workspace-inspection-unavailable"):i.length>0&&r.push("workspace-root-changed"),{state:r.length===0?"aligned":r.includes("workspace-root-changed")?"drifted":"unknown",findingCodes:r,driftComponents:i}}async function po(e){if(en(e.identity),e.identity.schema==="comet.native.workspace.v2")return{state:"legacy",code:"workspace-binding-legacy",message:"Legacy Native workspace metadata has no isolation binding"};if((await Qr(e)).state==="drifted")return{state:"drifted",code:"workspace-binding-root-changed",message:"Native change is being accessed from a different working directory"};let i=Be(e.paths.projectRoot);return e.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!==e.identity.changeBranch?{state:"drifted",code:"workspace-branch-changed",message:`Native change is bound to branch ${e.identity.changeBranch}, but the current branch is ${i.currentBranch??"detached HEAD"}`}:e.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"}}var bo=64*1024*1024,pP=256*1024,Iu=16*1024*1024;async function U(e){try{return await Fe.access(e),!0}catch(t){if(t.code==="ENOENT")return!1;throw t}}async function $g(e){let t;try{t=await Fe.readdir(e.transactionsDir,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")return;throw i}for(let i of t){if(!i.isDirectory()||i.isSymbolicLink())continue;let r;try{r=await wi(e,i.name)}catch(n){throw n.code==="ENOENT"?new Error(`Native transaction ${i.name} has no journal; run doctor before moving`,{cause:n}):n}if(r.status!=="committed"&&r.status!=="rolled-back")throw new Error(`Native transaction ${r.id} is unfinished; recover it before moving`)}}async function Og(e,t){for(let i of await Fe.readdir(e.locksDir,{withFileTypes:!0})){let r=I.join(e.locksDir,i.name);if(I.resolve(r)!==I.resolve(t)&&(i.isFile()||i.isSymbolicLink()))throw new Error(`Native lock must be diagnosed before moving the root: ${r}`)}}async function Hg(e){let t;try{t=await Fe.readdir(e.changesDir,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")return;throw i}for(let i of t.sort((r,n)=>r.name.localeCompare(n.name))){if(!i.isDirectory()||i.isSymbolicLink())continue;let r=await kt(e,i.name);if(r){await ho({paths:e,name:i.name,revision:r.capturedRevision,...r.schema==="comet.native.workspace.v3"?{binding:{isolation:r.isolation,changeBranch:r.changeBranch,targetBranch:r.targetBranch},...r.finish?{finish:r.finish}:{}}:{}});continue}}}async function Dg(e){let t;try{t=await Fe.readdir(e.changesDir,{withFileTypes:!0})}catch(i){if(i.code==="ENOENT")return;throw i}for(let i of t.sort((r,n)=>r.name.localeCompare(n.name)))if(!(!i.isDirectory()||i.isSymbolicLink()))try{let r=await kt(e,i.name);if(r?.schema==="comet.native.workspace.v3"){let n=await po({paths:e,identity:r});if(n.state!=="aligned")throw new Error(n.message??"workspace binding is not aligned")}else if(r){let n=await Qr({paths:e,identity:r});if(n.state!=="aligned")throw new Error(`legacy workspace ownership is ${n.state}`)}}catch(r){throw new Error(`Native workspace identity for ${i.name} must be aligned and repaired before moving the root`,{cause:r})}}async function Si(e,t){let i=[];async function r(n){let a=await Qe({root:e,directory:n,label:"Native root tree"}),o=a.entries;o.sort((s,c)=>s.name.localeCompare(c.name));for(let s of o){await a.verify();let c=I.join(n,s.name);if(t.excludedFiles?.has(I.resolve(c))){await a.verify();continue}let l=await Fe.lstat(c);if(s.isSymbolicLink()||l.isSymbolicLink()){if(t.rejectSymlinks)throw new Error(`Native root contains a symlink: ${c}`);await a.verify();continue}if(s.isDirectory()&&l.isDirectory())i.push({ref:I.relative(e,c).split(I.sep).join("/"),type:"directory"}),await r(c);else if(s.isFile()&&l.isFile()){let u=await J({root:e,file:c,maxBytes:bo,label:`Native root file ${I.relative(e,c)}`});i.push({ref:I.relative(e,c).split(I.sep).join("/"),type:"file",size:u.size,hash:u.hash})}else throw new Error(`Native root contains an unsupported file type: ${c}`);await a.verify()}}return await r(e),i.sort((n,a)=>n.ref.localeCompare(a.ref))}async function Bg(e,t,i,r){await pi({root:r,directory:t,label:"Native root move staging directory"});async function n(a,o){let s=await Qe({root:e,directory:a,label:"Native root move source directory"}),c=s.entries;for(let l of c){await s.verify();let u=I.join(a,l.name);if(I.resolve(u)===I.resolve(i)){await s.verify();continue}let d=await Fe.lstat(u);if(l.isSymbolicLink()||d.isSymbolicLink())throw new Error(`Native root contains a symlink: ${u}`);let f=I.join(o,l.name);if(l.isDirectory()&&d.isDirectory())await pi({root:r,directory:f,label:"Native root move staging directory"}),await n(u,f);else if(l.isFile()&&d.isFile())await mi({sourceRoot:e,source:u,targetRoot:r,target:f,maxBytes:bo,label:`Native root move file ${I.relative(e,u)}`,exclusive:!0,expectedTargetHash:null});else throw new Error(`Native root contains an unsupported file type: ${u}`);await s.verify()}}await n(e,t)}async function tn(e,t,i,r){let n=await Si(e,{rejectSymlinks:!0,excludedFiles:i?new Set([I.resolve(i)]):void 0}),a=await Si(t,{rejectSymlinks:!0,excludedFiles:r?new Set([I.resolve(r)]):void 0});if(JSON.stringify(n)!==JSON.stringify(a))throw new Error(`Native root copies differ; preserve both trees for manual recovery: ${e} and ${t}`)}function Lg(e,t){return I.join(e.artifactRoot,`.comet-native-move-${t}`)}function Mg(e,t){return I.join(e.artifactRoot,`.comet-native-source-${t}.removing`)}function Fg(e){return`${e}.removing`}function ju(e,t,i){return I.join(zr(e,t).directory,`root-move-cleanup-${i}.json`)}function qg(e){return JSON.stringify(e,null,2)+`
|
|
177
|
+
`}function Vg(e){return Ig("sha256").update(e).digest("hex")}function Wg(e,t){if(!e||typeof e!="object"||Array.isArray(e))throw new Error(`Native root-move cleanup manifest entry ${t} must be an object`);let i=e,r=Object.keys(i).sort(),n=i.type==="file"?["hash","ref","size","type"]:["ref","type"];if(JSON.stringify(r)!==JSON.stringify(n))throw new Error(`Native root-move cleanup manifest entry ${t} has invalid fields`);if(typeof i.ref!="string"||i.ref.length===0||i.ref.includes("\\")||I.posix.normalize(i.ref)!==i.ref||i.ref.startsWith("/")||i.ref.split("/").includes("..")||Buffer.byteLength(i.ref,"utf8")>4096)throw new Error(`Native root-move cleanup manifest entry ${t} has an invalid ref`);if(i.type==="directory")return{ref:i.ref,type:"directory"};if(i.type!=="file"||typeof i.size!="number"||!Number.isSafeInteger(i.size)||i.size<0||typeof i.hash!="string"||!/^[a-f0-9]{64}$/u.test(i.hash))throw new Error(`Native root-move cleanup manifest entry ${t} is invalid`);return{ref:i.ref,type:"file",size:i.size,hash:i.hash}}function zg(e,t,i){if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Native root-move cleanup manifest must be an object");let r=e;if(JSON.stringify(Object.keys(r).sort())!==JSON.stringify(["entries","kind","schema","transactionId"])||r.schema!=="comet.native.root-move-cleanup.v1"||r.transactionId!==t||r.kind!==i||!Array.isArray(r.entries))throw new Error("Native root-move cleanup manifest binding is invalid");let n=r.entries.map(Wg);for(let a=0;a<n.length;a+=1){if(a>0&&n[a-1].ref.localeCompare(n[a].ref)>=0)throw new Error("Native root-move cleanup manifest refs must be unique and sorted");let o=I.posix.dirname(n[a].ref);if(o!=="."&&!n.some(s=>s.ref===o&&s.type==="directory"))throw new Error(`Native root-move cleanup manifest parent is missing: ${o}`)}return{schema:"comet.native.root-move-cleanup.v1",transactionId:t,kind:i,entries:n}}async function Jg(e){let t={schema:"comet.native.root-move-cleanup.v1",transactionId:e.id,kind:e.kind,entries:e.entries},i=qg(t);if(Buffer.byteLength(i,"utf8")>Iu)throw new Error("Native root-move cleanup manifest exceeds its byte budget");return await z(ju(e.paths,e.id,e.kind),i,{containedRoot:e.paths.runtimeDir}),Vg(i)}async function Gg(e){let t=await J({root:e.paths.runtimeDir,file:ju(e.paths,e.id,e.cleanup.kind),maxBytes:Iu,label:`Native root-move cleanup manifest ${e.cleanup.kind}`});if(t.hash!==e.cleanup.manifestHash)throw new Error("Native root-move cleanup manifest hash changed");return zg(JSON.parse(t.bytes.toString("utf8")),e.id,e.cleanup.kind)}async function No(e){let t=await Si(e.quarantine,{rejectSymlinks:!0}),i=new Map(e.manifest.entries.map(r=>[r.ref,r]));for(let r of t){let n=i.get(r.ref);if(!n||JSON.stringify(n)!==JSON.stringify(r))throw new Error(`Native root-move cleanup quarantine differs from its bound manifest: ${r.ref}`)}if(e.exact&&t.length!==e.manifest.entries.length)throw new Error("Native root-move cleanup quarantine is incomplete before deletion");return t}function Au(e){return e.ref.split("/").length}async function Ug(e){let i=[...await No({quarantine:e.quarantine,manifest:e.manifest,exact:!1})].sort((n,a)=>Au(a)-Au(n)||(n.type===a.type?a.ref.localeCompare(n.ref):n.type==="file"?-1:1)),r=0;for(let n of i){let a=I.join(e.quarantine,...n.ref.split("/"));n.type==="file"?await no({root:e.projectRoot,file:a,maxBytes:bo,expectedHash:n.hash,expectedSize:n.size,label:`Native root-move cleanup file ${n.ref}`}):await ao({root:e.projectRoot,directory:a,label:`Native root-move cleanup directory ${n.ref}`}),r+=1,await e.hooks?.afterRootMoveCleanupEntryRemoved?.(e.manifest.kind,n.ref,r)}await No({quarantine:e.quarantine,manifest:e.manifest,exact:!1}),await ao({root:e.projectRoot,directory:e.quarantine,label:`Native root-move cleanup quarantine ${e.manifest.kind}`})}function rn(e,t,i=e.native.artifact_root){return{...e,native:{...e.native,artifact_root:i,pending_root_move:t}}}function Kg(e){return{schema:"comet.native.transaction.v1",id:e.id,kind:"root-move",status:"prepared",projectRoot:e.paths.projectRoot,nativeRoot:e.paths.nativeRoot,createdAt:e.now.toISOString(),operations:[]}}async function _u(e){let t=rn(e.config,{...e.pending,stage:e.stage},e.activeArtifactRoot);return await He(e.projectRoot,t),t}async function ki(e){let t=e.config.native.pending_root_move;if(!t||t.id!==e.id)throw new Error(`Native root-move cleanup ${e.id} lost its pending configuration`);let i=rn(e.config,{id:t.id,fromArtifactRoot:t.fromArtifactRoot,toArtifactRoot:t.toArtifactRoot,stage:t.stage,...e.cleanup?{cleanup:e.cleanup}:{}},e.config.native.artifact_root);return await He(e.projectRoot,i),i}async function Tu(e){let t=e.config,i=t.native.pending_root_move;if(!i||i.id!==e.id)throw new Error(`Native root-move cleanup ${e.id} lost its pending configuration`);let r=i.cleanup;if(r&&r.kind!==e.kind)throw new Error(`Native root move has unfinished ${r.kind} cleanup; cannot start ${e.kind}`);let n=await U(e.target),a=await U(e.quarantine);if(n&&a)throw new Error(`Native root-move cleanup target and quarantine both exist: ${e.kind}`);if(!r){if(!n&&!a)return t;if(!n&&a)throw new Error(`Native root-move cleanup quarantine is not transaction-bound: ${e.kind}`);let s=await Jg({paths:e.stablePaths,id:e.id,kind:e.kind,entries:await Si(e.target,{rejectSymlinks:!0})});r={kind:e.kind,state:"prepared",manifestHash:s},t=await ki({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:r})}let o=await Gg({paths:e.stablePaths,id:e.id,cleanup:r});if(n=await U(e.target),a=await U(e.quarantine),n&&a)throw new Error(`Native root-move cleanup target and quarantine both exist: ${e.kind}`);if(n){if(r.state!=="prepared")throw new Error(`Native root-move cleanup target reappeared after quarantine: ${e.kind}`);await Ul({root:e.projectRoot,directory:e.target,quarantine:e.quarantine,label:e.label,beforeQuarantine:e.beforeQuarantine,afterQuarantine:e.afterQuarantine}),a=!0}if(!a){if(r.state!=="deleting")throw new Error(`Native root-move cleanup quarantine disappeared: ${e.kind}`);return ki({projectRoot:e.projectRoot,config:t,id:e.id})}return await No({quarantine:e.quarantine,manifest:o,exact:r.state!=="deleting"}),r.state==="prepared"&&(r={...r,state:"quarantined"},t=await ki({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:r})),r.state==="quarantined"&&(r={...r,state:"deleting"},t=await ki({projectRoot:e.projectRoot,config:t,id:e.id,cleanup:r})),await Ug({projectRoot:e.projectRoot,quarantine:e.quarantine,manifest:o,hooks:e.hooks}),ki({projectRoot:e.projectRoot,config:t,id:e.id})}async function Yg(e){let t=e.config,i=t.native.pending_root_move.stage;if(i==="copying"){if(!await U(e.sourcePaths.nativeRoot))throw new Error(`Native source root is missing: ${e.sourcePaths.nativeRoot}`);let s=Fg(e.staging);t=await Tu({projectRoot:e.projectRoot,config:t,id:e.pending.id,kind:"restart-staging",stablePaths:e.sourcePaths,target:e.staging,quarantine:s,label:"Native root move stale staging removal",hooks:e.hooks}),await Si(e.sourcePaths.nativeRoot,{rejectSymlinks:!0,excludedFiles:new Set([I.resolve(e.lockFile)])}),await Bg(e.sourcePaths.nativeRoot,e.staging,e.lockFile,e.destinationPaths.projectRoot),await tn(e.sourcePaths.nativeRoot,e.staging,e.lockFile),t=await _u({projectRoot:e.projectRoot,config:t,pending:e.pending,stage:"ready"}),i="ready",await e.hooks?.afterRootMoveStage?.("ready",e.journal)}if(i==="ready"){if(await U(e.destinationPaths.nativeRoot)){if(await U(e.staging))throw new Error(`Native destination is occupied: ${e.destinationPaths.nativeRoot}`);await tn(e.sourcePaths.nativeRoot,e.destinationPaths.nativeRoot,e.lockFile)}else{if(!await U(e.staging))throw new Error("Native move staging tree is missing");await tn(e.sourcePaths.nativeRoot,e.staging,e.lockFile),await Fe.rename(e.staging,e.destinationPaths.nativeRoot)}t=await _u({projectRoot:e.projectRoot,config:t,pending:e.pending,stage:"switched",activeArtifactRoot:e.pending.toArtifactRoot}),i="switched",await e.hooks?.afterRootMoveStage?.("switched",e.journal)}if(i!=="switched")throw new Error(`Unsupported Native root-move stage: ${i}`);if(!await U(e.destinationPaths.nativeRoot))throw new Error(`Native destination root is missing: ${e.destinationPaths.nativeRoot}`);let r=Mg(e.sourcePaths,e.pending.id);!t.native.pending_root_move?.cleanup&&await U(e.sourcePaths.nativeRoot)&&await tn(e.sourcePaths.nativeRoot,e.destinationPaths.nativeRoot,e.lockFile),t=await Tu({projectRoot:e.projectRoot,config:t,id:e.pending.id,kind:"forward-source",stablePaths:e.destinationPaths,target:e.sourcePaths.nativeRoot,quarantine:r,label:"Native root move source removal",beforeQuarantine:()=>e.hooks?.beforeRootMoveSourceRemove?.(e.sourcePaths.nativeRoot),afterQuarantine:s=>e.hooks?.afterRootMoveSourceQuarantined?.(s),hooks:e.hooks}),await Hg(e.destinationPaths);let n=await wi(e.destinationPaths,e.pending.id);await lo(e.destinationPaths,n,"commit");let a={artifact_root:t.native.artifact_root,language:t.native.language,clarification_mode:t.native.clarification_mode,archive_confirmation:t.native.archive_confirmation,max_verify_failures:t.native.max_verify_failures,snapshot:t.native.snapshot},o={...t,native:{...a,artifact_root:e.pending.toArtifactRoot}};return await He(e.projectRoot,o),o}async function $u(e){let t=await oe(e.projectRoot)??Ol("docs");if(t.native.pending_root_move)throw new Error(`Native root move ${t.native.pending_root_move.id} is already incomplete`);let i=ui(e.toArtifactRoot);if(i===t.native.artifact_root)throw new Error(`Native artifact root is already ${i}`);let r=await fe(e.projectRoot,t.native.artifact_root),n=await fe(e.projectRoot,i);if(F(r.nativeRoot,n.nativeRoot)||F(n.nativeRoot,r.nativeRoot))throw new Error("Native source and destination roots must not overlap");if(!await U(r.nativeRoot))throw new Error(`Native source root does not exist: ${r.nativeRoot}`);if(await $g(r),await U(n.nativeRoot))throw new Error(`Native destination is occupied: ${n.nativeRoot}`);let a=await di(r,"root-move",`move root to ${i}`),o=jg(),s={id:o,fromArtifactRoot:t.native.artifact_root,toArtifactRoot:i,stage:"copying"},c=Kg({id:o,paths:r,now:e.now??new Date}),l=Lg(n,o);try{if(await Og(r,a.file),await Dg(r),await U(l))throw new Error(`Native move staging path is occupied: ${l}`);return await He(e.projectRoot,rn(t,s)),await au(r,c),await e.hooks?.afterRootMoveStage?.("copying",c),await Yg({projectRoot:e.projectRoot,config:rn(t,s),pending:s,sourcePaths:r,destinationPaths:n,staging:l,journal:c,lockFile:a.file,hooks:e.hooks}),{fromNativeRoot:r.nativeRoot,toNativeRoot:n.nativeRoot,transactionId:o}}finally{await fi(a)}}import xi from"path";import{realpathSync as Vw}from"fs";var Qg=["Outcome","Scope","Non-goals","Acceptance examples"],_P=[...Qg,"Constraints and invariants","Decisions","Open questions","Verification expectations"];var Zg=Object.freeze({maxChanges:32,maxSpecsPerChange:64,maxArtifactsPerChange:128,maxTotalSpecs:512,maxTotalArtifacts:1024,maxSignalsPerRelationship:8,maxRelationships:256,maxSerializedBytes:64*1024,maxNameBytes:128,maxCapabilityBytes:128,maxArtifactPathBytes:512});var Ou=1024*1024;var Du="scoped-text-safety",ew=1,tw=Object.freeze({maxFiles:256,maxFileBytes:2*1024*1024,maxTotalBytes:8*1024*1024,maxIssues:128});var iw="comet.native.checker-policy.v1";var GP=ee(iw,{policy:Du,version:ew,limits:tw,checks:["conflict-marker","space-before-tab","trailing-whitespace"],binaryHandling:"skip-and-count"});var rw=["contract-before-does-not-match-scope","implementation-before-does-not-match-scope","contract-changed-during-check","implementation-changed-during-check","contract-after-does-not-match-scope","implementation-after-does-not-match-scope"],UP=new Set(rw);var ow=Ou,dR=3*ow;var Bu={root:"/comet/native-runtime",packageKind:"runtime",definition:{apiVersion:"comet/v1alpha1",kind:"Skill",metadata:{name:"comet-native-runtime",version:"3",description:"Comet-owned state runtime for the Native workflow."},goal:{statement:"Advance a Native change only after its current guard passes.",inputs:[],outputs:[],success:["The Native change and Run state agree on the next phase."]},orchestration:{mode:"deterministic",entry:"shape",steps:[{id:"shape",action:{type:"checkpoint"},next:"build"},{id:"build",action:{type:"checkpoint"},next:"verify"},{id:"verify",action:{type:"checkpoint"},next:"archive"},{id:"archive",action:{type:"checkpoint"}}]},skills:[],agents:[],tools:[]},guardrails:{allowedSkills:[],allowedAgents:[],allowedTools:[],maxIterations:Number.MAX_SAFE_INTEGER,maxRetriesPerAction:2,confirmationRequiredFor:[]},evals:[]},cw=Z("comet-native-runtime:v3:scope-reopen"),BR=[{skillVersion:"3",skillHash:Z("comet-native-runtime:v3:semantic-repair-budget")},{skillVersion:"2",skillHash:Z("comet-native-runtime:v2:max-iterations-32")},{skillVersion:"1",skillHash:Z("comet-native-runtime:v1")}];var Mu=["schema","id","change","evidenceHash","createdAt","previousState","nextState","previousRun","nextRun","eventData"],wx=new Set(Mu),mw=new Set([...Mu,"minimum_runtime_version","revision"]),yx=new Set([...mw,"operation"]),Nx=512*1024,vw=new Set(["previousPhase","nextPhase","evidenceHash","summary","artifacts","noCodeReason","verificationResult"]),bx=new Set([...vw,"implementationScopeHash","repairScopeHash","repairStagnation","returnToBuild"]);var Px={maxAcceptanceCriteria:pu.maxCriteria};var _x={maxSpecs:64,maxFileBytes:Kr,maxTotalBytes:4*1024*1024};import{execFile as xw}from"node:child_process";import{promisify as Cw}from"node:util";var Ix=["$ProgressPreference = 'SilentlyContinue'","$encoded = $env:COMET_COMMAND_PAYLOAD","Remove-Item Env:COMET_COMMAND_PAYLOAD -ErrorAction SilentlyContinue","$json = [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String($encoded))","$payload = ConvertFrom-Json $json","$commandArgs = @($payload.arguments)","& $payload.command @commandArgs","if ($null -eq $LASTEXITCODE) { if ($?) { exit 0 } else { exit 1 } }","exit $LASTEXITCODE"].join("; ");var Vx={maxArtifacts:128,maxFileBytes:16*1024*1024,maxTotalBytes:64*1024*1024,maxDocumentBytes:256*1024};var uC=512*1024;var Ri=class extends Error{recovery;constructor(t,i){super(t),this.name="NativeReceiptScopeStaleError",this.recovery=i}};var jC=64*1024;var $C=3600*1e3;var OC=Cw(xw);var nn=class extends Error{details;constructor(t){let i=t.length===0?"Native verification receipt binding is invalid":`Native verification receipt binding is invalid (${t.length} receipt(s)): ${t.map(r=>`${r.ref}${r.acceptanceId?`[${r.acceptanceId}]`:""} -> ${r.mismatches.join("; ")}`).join(" | ")}`;super(i),this.name="NativeVerificationReceiptBindingError",this.details=t}};var NA={maxDepth:128,maxEntries:2e4,maxFileBytes:64*1024*1024,maxTotalBytes:256*1024*1024,maxManifestBytes:16*1024*1024,maxRefBytes:4*1024};var AA=16*1024*1024,_A=256*1024,TA=16*1024;var HA=Object.freeze({maxScopeChanges:128,maxAcceptanceEntries:64,maxUnresolvedReasons:32,maxReceipts:32});var LA=16*1024;var Hw=Et(ft(),1);var FA=8*1024*1024;var TT=16*1024;var NI=16*1024*1024,an=class extends Error{constructor(i,r,n,a){super(`Canonical spec conflict for ${i}: expected ${r??"(missing)"}, actual ${n??"(missing)"}`);this.capability=i;this.expectedHash=r;this.actualHash=n;this.canonicalPath=a;this.name="NativeSpecConflictError"}capability;expectedHash;actualHash;canonicalPath;code="native-spec-conflict"},on=class extends Error{constructor(i,r=i.ready?"Native Archive preflight no longer matches the expected hash":`Native Archive preflight is blocked: ${i.findingCodes.join(", ")}`){super(r);this.preflight=i;this.name="NativeArchivePreflightError"}preflight;code="native-archive-preflight"};var sn=class extends Error{constructor(i,r,n){super(i,n);this.preparation=r;this.name="NativeWorkspacePreparationError"}preparation};var Vu=["--project-root <path> Resolve the Native project from this working directory.","--json Emit the stable JSON command envelope.","--help Show help without requiring an initialized project."],So=Object.freeze({"":{usage:"comet native <command> [options]",purpose:"Create, inspect, recover, and archive portable Native changes through Runtime-enforced, skill-coordinated steps.",subcommands:["init Initialize Native project configuration.","root show Inspect the configured artifact root.","root move <artifact-root> Move the configured artifact root.","new <change-name> Create a change and prepare its workspace.","spec remove Record a complete capability removal intent.","show <change-name> Read formal artifacts and portable state.","status [<change-name>] Discover stable boundaries and Runner actions.","select <change-name> Select a change in its bound workspace.","next <change-name> Confirm or recover a stable workflow boundary.","archive <change-name> Preview and execute Archive plus workspace finish.","doctor [<change-name>] Diagnose, migrate, or rebuild local execution state."],options:Vu,output:"Human-readable text by default; use --json for a structured command envelope.",examples:["comet native status --json","comet native status my-change --details --json","comet native next --help"]},init:{usage:"comet native init [--root <artifact-root>] [--language en|zh-CN]",purpose:"Create or normalize .comet/config.yaml and the configured Native directories.",options:["--root <artifact-root> Project-relative artifact root; defaults to docs.","--language en|zh-CN Language for newly generated Native artifacts."],output:"The resolved project configuration and Native paths.",examples:["comet native init --root docs --language zh-CN"]},root:{usage:"comet native root <show|move> [arguments]",purpose:"Inspect or transactionally move the configured Native artifact root.",subcommands:["show Print the configured artifact root and resolved paths.","move <artifact-root> Move Native artifacts and update project configuration."],output:"The current root projection or the completed move result.",examples:["comet native root show","comet native root move artifacts/native"]},"root show":{usage:"comet native root show",purpose:"Print the configured Native artifact root and resolved paths.",output:"The configured artifact root and resolved Native paths."},"root move":{usage:"comet native root move <artifact-root>",purpose:"Transactionally move Native artifacts and update project configuration.",output:"The source, destination, and committed root-move transaction result.",examples:["comet native root move artifacts/native"]},new:{usage:"comet native new <change-name> [--language en|zh-CN] [--isolation current|branch|worktree] [--change-branch <branch>] [--target-branch <branch>] [--worktree-path <path>]",purpose:"Create a portable Native change and prepare the requested branch or linked worktree.",options:["--language en|zh-CN Artifact language; defaults to project configuration.","--isolation <kind> current, branch, or worktree; defaults to current.","--change-branch <branch> Change branch; defaults to comet/<change-name>.","--target-branch <branch> Local base branch; defaults to the current branch.","--worktree-path <path> Worktree directory; defaults to .worktrees/<change-name>."],output:"The portable state, workspace preparation result, and continuation with the next Runner action.",examples:["comet native new session-timeout --language zh-CN","comet native new session-timeout --isolation branch --target-branch main","comet native new session-timeout --isolation worktree --target-branch main"]},spec:{usage:"comet native spec remove <change-name> <capability>",purpose:"Record a capability removal; create and modify intents use complete proposed Spec files.",subcommands:["remove <change-name> <capability> Record a capability removal."],output:"The updated portable state and continuation."},"spec remove":{usage:"comet native spec remove <change-name> <capability>",purpose:"Record removal of a capability in the complete target specification.",output:"The updated portable state and continuation with the next Runner action."},show:{usage:"comet native show <change-name>",purpose:"Read formal artifacts and portable state for one Native change.",output:"The portable state, brief, complete proposed Specs, and continuation; legacy state is reported as migration-required."},status:{usage:"comet native status [<change-name>] [--cursor <token>] [--details]",purpose:"Discover portable stable boundaries, parent child readiness, or the exact next Runner action.",options:["--cursor <token> Continue a status-list page.","--details Include acceptance, Spec, workspace, and report details."],output:"A v2 status page or one portable Loop projection with local execution availability and continuation.runnerAction; parent changes also expose children and readyChildren.",examples:["comet native status --json","comet native status session-timeout --details --json"]},select:{usage:"comet native select <change-name>",purpose:"Select one Native change after validating its workspace binding.",output:"The selected change record."},next:{usage:`comet native next <change-name> --summary <text> [--confirmed|--accept-result|--revise-implementation|--revise-requirements|--retry-verifier|--resolve-verifier-blocker]
|
|
178
|
+
comet native next <change-name> --runner-input <json-file>`,purpose:"Confirm or recover an Agent boundary, advance parent child changes, or use one skill-coordinated JSON bridge for Builder handoff, check-plan dispatch, and Verifier response/error.",options:["--summary <text> Required transition or recovery summary.","--confirmed Confirm Shape or an explicitly degraded verifier-unavailable fallback before Archive.","--accept-result Accept the current skill-coordinated Verify result and make it archive-ready.","--revise-implementation Keep confirmed requirements unchanged and return Verify to Build for implementation revision.","--revise-requirements Return Verify to Shape when user-visible goals or acceptance criteria must change.","--retry-verifier Retry a blocked Verifier execution when the continuation allows it.","--resolve-verifier-blocker Resolve a semantic Verifier blocker without changing the candidate, then dispatch a new attempt.","--expected-state-version <n> Continuation-issued guard that rejects stale public transition decisions.","--expected-action <action> Continuation-issued guard that binds the public transition decision to its intended action.","--runner-input <file> Skill-coordinated JSON: builder-handoff, dispatch-verifier, verifier-response, verifier-execution-error, or verifier-unavailable. Identity/provider/execution/candidate fields are rejected."," builder-handoff fields: kind, summary, addressed_acceptance_ids, checks, known_limits."," dispatch-verifier fields: kind, checks (an explicitly resolved plan; [] is allowed)."," verifier-response fields: kind, response (request-checks or final-result)."," verifier-execution-error fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch."," verifier-unavailable fields: kind, summary, stateVersion, iteration, attempt, verifierExecutionRef copied from verifierDispatch; accepted only after the explicit Runtime check plan completed and passed."],output:"The portable state, explicit skill-coordinated label, Runtime-owned check results, complete verifierDispatch, bounded request-check response, continuation.runnerAction, and machine-readable continuation.inputOptions. This generic bridge is not trusted identity attestation: a passing result waits for explicit user confirmation before Archive.",examples:['comet native next session-timeout --summary "Shape confirmed" --confirmed','comet native next session-timeout --summary "Current result accepted" --accept-result','comet native next session-timeout --summary "Implementation needs revision" --revise-implementation','comet native next session-timeout --summary "Acceptance criteria changed" --revise-requirements','comet native next session-timeout --summary "Retry verifier infrastructure" --retry-verifier','comet native next session-timeout --summary "Retry semantic verification" --resolve-verifier-blocker',"comet native next session-timeout --runner-input <temporary-json-file>"]},archive:{usage:`comet native archive <change-name> --dry-run [--finish merge|push|pull-request|keep]
|
|
179
|
+
comet native archive <change-name> [--confirmed] [--serial-first <current-change>]`,purpose:"Preview or execute deterministic Archive after the portable state reaches archive-ready.",options:["--dry-run Inspect readiness without rerunning verification.","--finish <action> Persist merge, push, pull-request, or keep for an isolated workspace.","--serial-first <current-change> During execution only, confirm that this change archives before detected capability peers; the value must equal <change-name>.","--confirmed Confirm Archive when project policy requires it."],output:"Readiness plus continuation, or the completed Archive transaction and workspace finish result; Archive does not repeat verification."},doctor:{usage:"comet native doctor [<change-name>] [--repair]",purpose:"Inspect portable state, migrate a legacy active change, or rebuild its local execution overlay.",options:["--repair Apply deterministic migration or rebuild from the portable stable boundary."],output:"Health, migration or recovery details, and the continuation with the next Runner action."}});function ko(e,t){return`${e}:
|
|
180
180
|
${t.map(i=>` ${i}`).join(`
|
|
181
|
-
`)}`}function
|
|
182
|
-
${i.output}`),i.examples&&r.push("",
|
|
181
|
+
`)}`}function Mw(e){let t=e.filter(r=>r!=="--help");if(t.length===0)return"";let i=t.slice(0,2).join(" ");return So[i]||t.length>1&&So[t[0]]?.subcommands?i:t[0]}function Fw(e=[]){let t=Mw(e),i=So[t];if(!i)throw new Error(`Unknown Native help topic: ${t}`);let r=[`Usage: ${i.usage}`,"",i.purpose];i.subcommands&&r.push("",ko("Commands",i.subcommands));let n=t===""?i.options:[...i.options??[],...Vu];return n&&n.length>0&&r.push("",ko("Options",n)),r.push("",`Output:
|
|
182
|
+
${i.output}`),i.examples&&r.push("",ko("Examples",i.examples)),t===""&&r.push("","Run `comet native <command> --help` for command-specific details."),{topic:t,usage:`${r.join(`
|
|
183
183
|
`)}
|
|
184
|
-
`}}var
|
|
185
|
-
`}}function
|
|
186
|
-
`}:e.error?{exitCode:e.exitCode,stderr:e.error.message}:{exitCode:e.exitCode,stdout:e.text}}async function
|
|
187
|
-
`)}throw new ve(`Unknown root command: ${i}`)}function
|
|
188
|
-
`}}async function
|
|
184
|
+
`}}var qw=Fw().usage;var GI=10*1024*1024,ve=class extends Error{};function zu(e,t){let i=e.flatMap((r,n)=>r===t?[n]:[]);if(i.length>1)throw new ve(`${t} may only be provided once`);return i.length===0?!1:(e.splice(i[0],1),!0)}function Ju(e,t){let i=e.flatMap((a,o)=>a===t?[o]:[]);if(i.length>1)throw new ve(`${t} may only be provided once`);if(i.length===0)return;let r=i[0],n=e[r+1];if(n===void 0||n.startsWith("--"))throw new ve(`${t} requires a value`);return e.splice(r,2),n}function Po(e){if(e.length>0)throw new ve(`Unexpected argument: ${e[0]}`)}function Ro(e,t){let i=e.shift();if(!i||i.startsWith("--"))throw new ve(`${t} is required`);return i}function Eo(e,t){let i=xi.normalize(Wu(e)),r=xi.normalize(Wu(t));return process.platform==="win32"?i.toLowerCase()===r.toLowerCase():i===r}function Wu(e){let t=xi.resolve(e);try{return Vw.native(t)}catch{return t}}function Ww(e){let t=xi.resolve(e),i=Be(process.cwd());if(!i.isSecondaryWorktree||i.currentWorktreeRoot===null||i.primaryWorktreeRoot===null)return t;let r=Be(t);return!r.isGitWorktree||r.currentWorktreeRoot===null||r.primaryWorktreeRoot===null||!Eo(i.primaryWorktreeRoot,r.primaryWorktreeRoot)||Eo(i.currentWorktreeRoot,r.currentWorktreeRoot)?t:Eo(process.cwd(),i.currentWorktreeRoot)?xi.resolve(process.cwd()):i.currentWorktreeRoot}async function Gu(e){return e?Ww(e):eo(process.cwd())}function xo(e,t,i){return{command:e,exitCode:0,data:t,text:i??JSON.stringify(t,null,2)+`
|
|
185
|
+
`}}function Uu(e,t){if(t instanceof ve)return{command:e,exitCode:64,error:{code:"usage",message:t.message}};if(t instanceof an)return{command:e,exitCode:73,data:{capability:t.capability,expectedHash:t.expectedHash,actualHash:t.actualHash,canonicalPath:t.canonicalPath},error:{code:"conflict",message:t.message}};if(t instanceof on)return{command:e,exitCode:73,data:t.preflight,error:{code:"conflict",message:t.message}};if(t instanceof Yr)return{command:e,exitCode:73,data:{change:t.change,expectedRevision:t.expectedRevision,actualRevision:t.actualRevision,outcome:"revision-conflict"},error:{code:"conflict",message:t.message}};if(t instanceof Ni)return{command:e,exitCode:73,data:{requestedIsolation:t.requestedIsolation,activeChanges:t.activeChanges,requiredAction:"create-native-worktree"},error:{code:"workspace-isolation-required",message:t.message}};if(t instanceof sn)return{command:e,exitCode:73,data:{preparation:t.preparation},error:{code:"workspace-preparation-incomplete",message:t.message}};if(t instanceof Xr)return{command:e,exitCode:65,data:{change:t.change,complete:!1,omittedCount:t.omittedCount,omittedByReason:t.omittedByReason,samplePaths:t.samplePaths,sampleTruncated:t.sampleTruncated,effectiveLimits:t.effectiveLimits,policyHash:t.policyHash,configPath:".comet/config.yaml",supportedFixes:["increase native.snapshot.max_files, native.snapshot.max_total_bytes, or native.snapshot.max_duration_ms","add an explicit native.snapshot.exclude pattern for data outside implementation scope"],requiredAction:"resolve-native-baseline"},error:{code:"baseline-incomplete",message:t.message}};if(t instanceof nn)return{command:e,exitCode:65,data:{receiptBindingFailures:t.details},error:{code:"invalid-data",message:t.message}};if(t instanceof Ri)return{command:e,exitCode:65,data:t.recovery,error:{code:"implementation-scope-stale",message:t.message}};if(t instanceof Error){let i=t.code;if(i&&new Set(["EACCES","EPERM","EIO","EMFILE","ENFILE","ENOSPC","EROFS"]).has(i))return{command:e,exitCode:70,error:{code:"internal",message:t.message}};let r=/\b(lock|transaction|conflict|occupied|incomplete|recovery)\b/iu.test(t.message);return{command:e,exitCode:r?73:65,error:{code:r?"conflict":"invalid-data",message:t.message}}}return{command:e,exitCode:70,error:{code:"internal",message:String(t)}}}function Ku(e,t){return t?{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
|
|
186
|
+
`}:e.error?{exitCode:e.exitCode,stderr:e.error.message}:{exitCode:e.exitCode,stdout:e.text}}async function Yu(e,t){let i=Ro(e,"root subcommand");if(i==="show"){Po(e);let r=await oe(t);if(!r)throw new Error(".comet/config.yaml was not found");let n=await fe(t,r.native.artifact_root);return xo("root show",{projectRoot:t,artifactRoot:r.native.artifact_root,language:r.native.language,nativeRoot:n.nativeRoot,pendingRootMove:r.native.pending_root_move??null})}if(i==="move"){let r=Ro(e,"artifact root");Po(e);let n=await $u({projectRoot:t,toArtifactRoot:r});return xo("root move",n,`Moved Comet Native to ${n.toNativeRoot}
|
|
187
|
+
`)}throw new ve(`Unknown root command: ${i}`)}function zw(e){return{exitCode:e.exitCode,stdout:JSON.stringify({command:e.command,exitCode:e.exitCode,...e.data===void 0?{}:{data:e.data},...e.error===void 0?{}:{error:e.error}})+`
|
|
188
|
+
`}}async function Xu(e,t,i=process.argv.slice(2)){let r=i.indexOf("--"),n=r<0?[...i]:i.slice(0,r),a=r<0?[]:i.slice(r),o=n.includes("--json"),s,c;try{zu(n,"--json"),s=Ju(n,"--project-root");let u=[...n,...a],d=await Gu(s);c=await t(u,d)}catch(u){c=Uu(e,u)}let l=o?zw(c):Ku(c,!1);return l.stdout&&process.stdout.write(l.stdout),l.stderr&&process.stderr.write(l.stderr+(l.stderr.endsWith(`
|
|
189
189
|
`)?"":`
|
|
190
|
-
`)),l.exitCode}process.exitCode=await
|
|
190
|
+
`)),l.exitCode}process.exitCode=await Xu("root",Yu);
|