@unbrained/pm-cli 2026.7.5 → 2026.7.7
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/CHANGELOG.md +42 -0
- package/dist/cli/commands/annotation-command.d.ts +1 -0
- package/dist/cli/commands/annotation-command.js +29 -2
- package/dist/cli/commands/annotation-command.js.map +1 -1
- package/dist/cli/commands/comments.js +3 -4
- package/dist/cli/commands/comments.js.map +1 -1
- package/dist/cli/commands/extension/bundled-catalog.d.ts +3 -0
- package/dist/cli/commands/extension/bundled-catalog.js +38 -28
- package/dist/cli/commands/extension/bundled-catalog.js.map +1 -1
- package/dist/cli/commands/extension/install-sources.js +81 -18
- package/dist/cli/commands/extension/install-sources.js.map +1 -1
- package/dist/cli/commands/health.js +9 -5
- package/dist/cli/commands/health.js.map +1 -1
- package/dist/cli/commands/learnings.js +5 -3
- package/dist/cli/commands/learnings.js.map +1 -1
- package/dist/cli/commands/notes.js +5 -3
- package/dist/cli/commands/notes.js.map +1 -1
- package/dist/cli/commands/reindex.js +4 -3
- package/dist/cli/commands/reindex.js.map +1 -1
- package/dist/cli/commands/search.js +3 -3
- package/dist/cli/commands/search.js.map +1 -1
- package/dist/cli/commands/test.d.ts +9 -0
- package/dist/cli/commands/test.js +144 -105
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/extension-command-help.js +10 -2
- package/dist/cli/extension-command-help.js.map +1 -1
- package/dist/cli/register-list-query.d.ts +1 -1
- package/dist/cli/register-list-query.js +18 -27
- package/dist/cli/register-list-query.js.map +1 -1
- package/dist/cli/register-operations.d.ts +0 -8
- package/dist/cli/register-operations.js +41 -46
- package/dist/cli/register-operations.js.map +1 -1
- package/dist/cli/register-setup.js +113 -13
- package/dist/cli/register-setup.js.map +1 -1
- package/dist/cli/registration-helpers.d.ts +5 -1
- package/dist/cli/registration-helpers.js +14 -2
- package/dist/cli/registration-helpers.js.map +1 -1
- package/dist/cli-bundle/chunks/append-F7WPGIQL.js +11 -0
- package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js → append-PVCTBVJG.js} +8 -9
- package/dist/cli-bundle/chunks/{chunk-PPE4YUQM.js → chunk-2APXX4TZ.js} +17 -28
- package/dist/cli-bundle/chunks/chunk-2APXX4TZ.js.map +1 -0
- package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js → chunk-2LEJGRQ7.js} +3 -12
- package/dist/cli-bundle/chunks/{docs-S6UTOTO5.js.map → chunk-2LEJGRQ7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js → chunk-2TILG6F2.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js → chunk-3G6UMXT3.js} +6 -8
- package/dist/cli-bundle/chunks/{chunk-S5AYOUT5.js.map → chunk-3G6UMXT3.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js → chunk-3TYOW6RR.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js → chunk-3X542TEY.js} +7 -7
- package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js → chunk-42LXP4VO.js} +14 -21
- package/dist/cli-bundle/chunks/{history-repair-EVTO6LIH.js.map → chunk-42LXP4VO.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-5J2XPTAD.js → chunk-43SIHQND.js} +36 -15
- package/dist/cli-bundle/chunks/chunk-43SIHQND.js.map +7 -0
- package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js → chunk-43UQN754.js} +12 -19
- package/dist/cli-bundle/chunks/{history-repair-4N6SDVHK.js.map → chunk-43UQN754.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js → chunk-43YSKY75.js} +4 -6
- package/dist/cli-bundle/chunks/{chunk-OWTIRHX4.js.map → chunk-43YSKY75.js.map} +1 -1
- package/dist/cli-bundle/chunks/{notes-72YXN5JX.js → chunk-4BKDAEDF.js} +6 -13
- package/dist/cli-bundle/chunks/{notes-72YXN5JX.js.map → chunk-4BKDAEDF.js.map} +2 -2
- package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js → chunk-4IQKDKGE.js} +18 -32
- package/dist/cli-bundle/chunks/{close-many-AP4MWU36.js.map → chunk-4IQKDKGE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js → chunk-4MZOKTI2.js} +6 -8
- package/dist/cli-bundle/chunks/{chunk-ZCJAA3JK.js.map → chunk-4MZOKTI2.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js → chunk-52NS7JDP.js} +14 -20
- package/dist/cli-bundle/chunks/{chunk-IJ6CO3JV.js.map → chunk-52NS7JDP.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js → chunk-565WYS5W.js} +12 -16
- package/dist/cli-bundle/chunks/{chunk-T3F4DF23.js.map → chunk-565WYS5W.js.map} +1 -1
- package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js → chunk-5FIQ4EX3.js} +13 -19
- package/dist/cli-bundle/chunks/{copy-OTJOWFL6.js.map → chunk-5FIQ4EX3.js.map} +1 -1
- package/dist/cli-bundle/chunks/{config-V57QD47V.js → chunk-6G6O3OPQ.js} +259 -41
- package/dist/cli-bundle/chunks/chunk-6G6O3OPQ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js → chunk-6LCJRGPD.js} +9 -13
- package/dist/cli-bundle/chunks/{chunk-K3AGVXSF.js.map → chunk-6LCJRGPD.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js → chunk-6UQCNWFV.js} +6 -8
- package/dist/cli-bundle/chunks/{chunk-7MDXZAZS.js.map → chunk-6UQCNWFV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-LEKT4K7I.js → chunk-6XTSYPPO.js} +1216 -387
- package/dist/cli-bundle/chunks/chunk-6XTSYPPO.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-7ML7JONU.js +5434 -0
- package/dist/cli-bundle/chunks/chunk-7ML7JONU.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js → chunk-7PNQA24K.js} +30 -36
- package/dist/cli-bundle/chunks/{chunk-TSPKZRRW.js.map → chunk-7PNQA24K.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js → chunk-7VQ3JJN5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js → chunk-7Y5N34HX.js} +8 -12
- package/dist/cli-bundle/chunks/{chunk-BFVHCAOO.js.map → chunk-7Y5N34HX.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js → chunk-AGAVEDIE.js} +7 -7
- package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js → chunk-AJUON7E6.js} +3 -3
- package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js → chunk-ARKHKYYS.js} +16 -30
- package/dist/cli-bundle/chunks/{close-many-OMZIGZB4.js.map → chunk-ARKHKYYS.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-7EQNAZX2.js → chunk-C5ACVMOI.js} +99 -51
- package/dist/cli-bundle/chunks/chunk-C5ACVMOI.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js → chunk-CJQM7O7R.js} +16 -20
- package/dist/cli-bundle/chunks/{chunk-PJ3A56YF.js.map → chunk-CJQM7O7R.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js → chunk-D2DCTFTL.js} +7 -9
- package/dist/cli-bundle/chunks/{chunk-WISPVC2E.js.map → chunk-D2DCTFTL.js.map} +1 -1
- package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js → chunk-DDDWVPID.js} +7 -11
- package/dist/cli-bundle/chunks/{append-CZGUZ45Q.js.map → chunk-DDDWVPID.js.map} +1 -1
- package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js → chunk-DG6BSXZ7.js} +6 -13
- package/dist/cli-bundle/chunks/{learnings-2HTPZNGZ.js.map → chunk-DG6BSXZ7.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js → chunk-DR2V5OIV.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js → chunk-E3LWJUGF.js} +4 -6
- package/dist/cli-bundle/chunks/{chunk-YQMMMONE.js.map → chunk-E3LWJUGF.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js → chunk-E3YQFSFE.js} +6 -10
- package/dist/cli-bundle/chunks/{chunk-D3UCE7RW.js.map → chunk-E3YQFSFE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js → chunk-EDO7VXSO.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FDBARR33.js → chunk-EIUBK2LT.js} +12 -18
- package/dist/cli-bundle/chunks/{chunk-FDBARR33.js.map → chunk-EIUBK2LT.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js → chunk-EMXPI36L.js} +14 -20
- package/dist/cli-bundle/chunks/{chunk-HBYZDSK5.js.map → chunk-EMXPI36L.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-4OFLJHX6.js → chunk-EOUVR7JN.js} +13 -8
- package/dist/cli-bundle/chunks/chunk-EOUVR7JN.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js → chunk-EVEPHNXJ.js} +4 -4
- package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js → chunk-F6MT7KKE.js} +6 -10
- package/dist/cli-bundle/chunks/{deps-L2FPIAD3.js.map → chunk-F6MT7KKE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js → chunk-F6YC2A6X.js} +7 -11
- package/dist/cli-bundle/chunks/{chunk-FGQKEDE4.js.map → chunk-F6YC2A6X.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-FILL6BB2.js +5514 -0
- package/dist/cli-bundle/chunks/chunk-FILL6BB2.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js → chunk-FN6SB4HU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js +5359 -0
- package/dist/cli-bundle/chunks/chunk-GH73UOSJ.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-JLA7EVYV.js → chunk-GLS6VMWI.js} +37 -16
- package/dist/cli-bundle/chunks/chunk-GLS6VMWI.js.map +1 -0
- package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js → chunk-GPIDUMMN.js} +10 -17
- package/dist/cli-bundle/chunks/{files-JPU3FNJ7.js.map → chunk-GPIDUMMN.js.map} +1 -1
- package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js → chunk-GTM5HQL4.js} +15 -21
- package/dist/cli-bundle/chunks/{history-compact-3F6VELO7.js.map → chunk-GTM5HQL4.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js → chunk-H2SMKL2N.js} +8 -8
- package/dist/cli-bundle/chunks/{chunk-S4APD35C.js → chunk-HHEWQXPD.js} +6 -6
- package/dist/cli-bundle/chunks/chunk-HHEWQXPD.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js → chunk-HX6QXV5P.js} +2 -2
- package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js → chunk-I74FMIWA.js} +11 -17
- package/dist/cli-bundle/chunks/{copy-LEE6P6EM.js.map → chunk-I74FMIWA.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js +804 -0
- package/dist/cli-bundle/chunks/chunk-IDIBF4E2.js.map +7 -0
- package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js → chunk-II7R6KD4.js} +9 -13
- package/dist/cli-bundle/chunks/{comments-SAG5LSKL.js.map → chunk-II7R6KD4.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-J2VGADNG.js +10320 -0
- package/dist/cli-bundle/chunks/chunk-J2VGADNG.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js → chunk-J7BOLHAV.js} +5 -7
- package/dist/cli-bundle/chunks/{chunk-Y76TWC45.js.map → chunk-J7BOLHAV.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js → chunk-KTGJ2CBU.js} +4 -6
- package/dist/cli-bundle/chunks/{chunk-QHZO65XW.js.map → chunk-KTGJ2CBU.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js → chunk-LCFJ7XAM.js} +32 -2
- package/dist/cli-bundle/chunks/{chunk-5VVUKE3U.js.map → chunk-LCFJ7XAM.js.map} +3 -3
- package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js → chunk-LZQU6XJG.js} +28 -34
- package/dist/cli-bundle/chunks/{chunk-YMABYTNG.js.map → chunk-LZQU6XJG.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js → chunk-M62RO3XK.js} +10 -14
- package/dist/cli-bundle/chunks/{chunk-3Y4OESPP.js.map → chunk-M62RO3XK.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js → chunk-MCEUKJKW.js} +9 -11
- package/dist/cli-bundle/chunks/{chunk-YPPVU5GX.js.map → chunk-MCEUKJKW.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-T5Y3QSNF.js → chunk-MHNMCDWR.js} +1447 -86
- package/dist/cli-bundle/chunks/chunk-MHNMCDWR.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js → chunk-MRFWUSVA.js} +4 -6
- package/dist/cli-bundle/chunks/{chunk-HJE4JTKQ.js.map → chunk-MRFWUSVA.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js → chunk-N6ZHDLUY.js} +6 -8
- package/dist/cli-bundle/chunks/{chunk-P3VRG72Q.js.map → chunk-N6ZHDLUY.js.map} +1 -1
- package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js → chunk-NWWL22C7.js} +8 -12
- package/dist/cli-bundle/chunks/{delete-HQKGRNRZ.js.map → chunk-NWWL22C7.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js → chunk-P3MJJW7P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js → chunk-PDXJXEZJ.js} +2 -2
- package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js → chunk-Q64AYQYW.js} +9 -13
- package/dist/cli-bundle/chunks/{append-NSQBCXZJ.js.map → chunk-Q64AYQYW.js.map} +1 -1
- package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js → chunk-QDABF2RB.js} +26 -47
- package/dist/cli-bundle/chunks/{update-many-SLLAMHT7.js.map → chunk-QDABF2RB.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-NBFCNJ7Q.js → chunk-QFBSP3NI.js} +529 -46
- package/dist/cli-bundle/chunks/chunk-QFBSP3NI.js.map +1 -0
- package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js → chunk-RB3KLPAH.js} +11 -16
- package/dist/cli-bundle/chunks/{focus-LFZ6IDBR.js.map → chunk-RB3KLPAH.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-YSAH5FY5.js → chunk-RY7PTTUB.js} +94 -53
- package/dist/cli-bundle/chunks/chunk-RY7PTTUB.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-WVSGSZ6J.js → chunk-S547WBYG.js} +1477 -86
- package/dist/cli-bundle/chunks/chunk-S547WBYG.js.map +7 -0
- package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js → chunk-S5BNGFN5.js} +24 -45
- package/dist/cli-bundle/chunks/{update-many-DC7X3EWM.js.map → chunk-S5BNGFN5.js.map} +1 -1
- package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js → chunk-S6VC2A2K.js} +9 -14
- package/dist/cli-bundle/chunks/{focus-WNMYCVYA.js.map → chunk-S6VC2A2K.js.map} +1 -1
- package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js → chunk-SIM5JDON.js} +7 -14
- package/dist/cli-bundle/chunks/{learnings-YBIHY3D6.js.map → chunk-SIM5JDON.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-ZD34OFFQ.js → chunk-SY75LYXR.js} +12 -7
- package/dist/cli-bundle/chunks/chunk-SY75LYXR.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-TT42JUMF.js → chunk-TEISGNSH.js} +7 -7
- package/dist/cli-bundle/chunks/chunk-TEISGNSH.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js → chunk-TEKZOS7M.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js → chunk-TGUK6XN6.js} +14 -18
- package/dist/cli-bundle/chunks/{chunk-4QQ6PM7M.js.map → chunk-TGUK6XN6.js.map} +1 -1
- package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js → chunk-TNC6MZUD.js} +10 -21
- package/dist/cli-bundle/chunks/{plan-R4NDQ27E.js.map → chunk-TNC6MZUD.js.map} +1 -1
- package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js +10498 -0
- package/dist/cli-bundle/chunks/chunk-TZLYO4PP.js.map +7 -0
- package/dist/cli-bundle/chunks/{chunk-YD5FML7K.js → chunk-UO7XAZK6.js} +27 -4
- package/dist/cli-bundle/chunks/chunk-UO7XAZK6.js.map +1 -0
- package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js → chunk-V5ZWKJNY.js} +5 -14
- package/dist/cli-bundle/chunks/{docs-6CRCSVKK.js.map → chunk-V5ZWKJNY.js.map} +1 -1
- package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js → chunk-VGO73OCK.js} +7 -14
- package/dist/cli-bundle/chunks/{notes-NJ7IQJX4.js.map → chunk-VGO73OCK.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js → chunk-VLEA2UTQ.js} +2 -2
- package/dist/cli-bundle/chunks/{files-6P57MRKL.js → chunk-W5HXHC7C.js} +8 -15
- package/dist/cli-bundle/chunks/{files-6P57MRKL.js.map → chunk-W5HXHC7C.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js → chunk-WCWVEXGA.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-X47MKQXU.js +6690 -0
- package/dist/cli-bundle/chunks/chunk-X47MKQXU.js.map +7 -0
- package/dist/cli-bundle/chunks/{delete-62JQTYT4.js → chunk-XBX5CBRQ.js} +6 -10
- package/dist/cli-bundle/chunks/{delete-62JQTYT4.js.map → chunk-XBX5CBRQ.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-MTTXDAK4.js → chunk-XC3X7BQR.js} +541 -44
- package/dist/cli-bundle/chunks/chunk-XC3X7BQR.js.map +7 -0
- package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js → chunk-XHCVAZGM.js} +17 -23
- package/dist/cli-bundle/chunks/{history-compact-656Y2TN4.js.map → chunk-XHCVAZGM.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js → chunk-XPMXPR7K.js} +7 -9
- package/dist/cli-bundle/chunks/{chunk-ZAHXPXVY.js.map → chunk-XPMXPR7K.js.map} +1 -1
- package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js → chunk-XS2TMNXR.js} +8 -12
- package/dist/cli-bundle/chunks/{deps-55FTG6Z5.js.map → chunk-XS2TMNXR.js.map} +1 -1
- package/dist/cli-bundle/chunks/{plan-XWY5T67S.js → chunk-XXIYUTLK.js} +12 -23
- package/dist/cli-bundle/chunks/{plan-XWY5T67S.js.map → chunk-XXIYUTLK.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-7QH7DHUB.js → chunk-XZWL7VNE.js} +1220 -398
- package/dist/cli-bundle/chunks/chunk-XZWL7VNE.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js +6624 -0
- package/dist/cli-bundle/chunks/chunk-Y5IKRUEM.js.map +1 -0
- package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js → chunk-Y7KYVCZM.js} +12 -18
- package/dist/cli-bundle/chunks/{chunk-ABRA3BHY.js.map → chunk-Y7KYVCZM.js.map} +1 -1
- package/dist/cli-bundle/chunks/{chunk-UI5BJ6DO.js → chunk-YCVWWIKY.js} +17 -28
- package/dist/cli-bundle/chunks/chunk-YCVWWIKY.js.map +7 -0
- package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js +780 -0
- package/dist/cli-bundle/chunks/chunk-YH5NBDFA.js.map +1 -0
- package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js +5509 -0
- package/dist/cli-bundle/chunks/chunk-YNCFP5AR.js.map +7 -0
- package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js → chunk-YPD7SQ5P.js} +8 -12
- package/dist/cli-bundle/chunks/{comments-MIW5MZOX.js.map → chunk-YPD7SQ5P.js.map} +2 -2
- package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js → chunk-YPMZMKN7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js → chunk-YTD5GICJ.js} +4 -4
- package/dist/cli-bundle/chunks/{config-DJJKZB5R.js → chunk-ZNEG2UDO.js} +264 -39
- package/dist/cli-bundle/chunks/{config-DJJKZB5R.js.map → chunk-ZNEG2UDO.js.map} +4 -4
- package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js → chunk-ZO7CLOY2.js} +3 -3
- package/dist/cli-bundle/chunks/{close-3YRR3XY6.js → close-3YYQ5OG2.js} +5 -9
- package/dist/cli-bundle/chunks/close-Z3Q4U7TS.js +12 -0
- package/dist/cli-bundle/chunks/close-many-3L2RXH3M.js +22 -0
- package/dist/cli-bundle/chunks/close-many-D366FTIG.js +26 -0
- package/dist/cli-bundle/chunks/comments-54XDJNFE.js +17 -0
- package/dist/cli-bundle/chunks/comments-HGHC2PN6.js +13 -0
- package/dist/cli-bundle/chunks/copy-44RT5GDW.js +13 -0
- package/dist/cli-bundle/chunks/copy-UGMUGHZA.js +9 -0
- package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js → create-4GWJWPXG.js} +9 -14
- package/dist/cli-bundle/chunks/create-AZXCUYKP.js +25 -0
- package/dist/cli-bundle/chunks/delete-Y6SXIQ4X.js +10 -0
- package/dist/cli-bundle/chunks/delete-YQ2VPXNF.js +14 -0
- package/dist/cli-bundle/chunks/deps-BU5EBJDU.js +17 -0
- package/dist/cli-bundle/chunks/deps-FMANWFRP.js +13 -0
- package/dist/cli-bundle/chunks/docs-OQBSJNIA.js +18 -0
- package/dist/cli-bundle/chunks/docs-VNPBZXEL.js +14 -0
- package/dist/cli-bundle/chunks/files-72HZEBOE.js +18 -0
- package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js → files-HTSB2KJG.js} +13 -13
- package/dist/cli-bundle/chunks/focus-FOG4ALC2.js +14 -0
- package/dist/cli-bundle/chunks/focus-SUTMKXGX.js +10 -0
- package/dist/cli-bundle/chunks/history-compact-M6IFAMBP.js +25 -0
- package/dist/cli-bundle/chunks/history-compact-NEXRPP2O.js +21 -0
- package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js → history-redact-NQX3OGZP.js} +7 -11
- package/dist/cli-bundle/chunks/history-redact-WQJBZ3PX.js +17 -0
- package/dist/cli-bundle/chunks/history-repair-CBHMHAJO.js +19 -0
- package/dist/cli-bundle/chunks/history-repair-NHOJG7WO.js +23 -0
- package/dist/cli-bundle/chunks/learnings-M64NTSOR.js +13 -0
- package/dist/cli-bundle/chunks/learnings-T63JGKKN.js +17 -0
- package/dist/cli-bundle/chunks/notes-73WE2UV2.js +13 -0
- package/dist/cli-bundle/chunks/notes-U7L6HQQ2.js +17 -0
- package/dist/cli-bundle/chunks/plan-OSCNYFGC.js +24 -0
- package/dist/cli-bundle/chunks/plan-OSCNYFGC.js.map +7 -0
- package/dist/cli-bundle/chunks/plan-TN537L24.js +28 -0
- package/dist/cli-bundle/chunks/plan-TN537L24.js.map +1 -0
- package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js +37 -0
- package/dist/cli-bundle/chunks/profile-MHAMXMHQ.js.map +1 -0
- package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js +33 -0
- package/dist/cli-bundle/chunks/profile-TIGLAKJ7.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-list-query-5H66WFYF.js → register-list-query-OHXD7G5N.js} +41 -33
- package/dist/cli-bundle/chunks/register-list-query-OHXD7G5N.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-list-query-FB3FNDLZ.js → register-list-query-ZCRABAPN.js} +42 -34
- package/dist/cli-bundle/chunks/register-list-query-ZCRABAPN.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js → register-mutation-P3G4XP6Q.js} +36 -41
- package/dist/cli-bundle/chunks/{register-mutation-UJO23C7R.js.map → register-mutation-P3G4XP6Q.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js → register-mutation-XX4H56PE.js} +34 -39
- package/dist/cli-bundle/chunks/{register-mutation-Z2ETYHKS.js.map → register-mutation-XX4H56PE.js.map} +1 -1
- package/dist/cli-bundle/chunks/{register-operations-A3XAM5J7.js → register-operations-V6PIYEDU.js} +80 -52
- package/dist/cli-bundle/chunks/register-operations-V6PIYEDU.js.map +1 -0
- package/dist/cli-bundle/chunks/{register-operations-SG7HBSUP.js → register-operations-V6VKTG54.js} +79 -51
- package/dist/cli-bundle/chunks/register-operations-V6VKTG54.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-setup-K6U3NVY5.js → register-setup-6RVAWT6W.js} +129 -31
- package/dist/cli-bundle/chunks/register-setup-6RVAWT6W.js.map +7 -0
- package/dist/cli-bundle/chunks/{register-setup-I45OGJUV.js → register-setup-6YVUSQYD.js} +130 -32
- package/dist/cli-bundle/chunks/register-setup-6YVUSQYD.js.map +1 -0
- package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js → restore-HC3YSWF7.js} +7 -11
- package/dist/cli-bundle/chunks/restore-HC3YSWF7.js.map +1 -0
- package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js +15 -0
- package/dist/cli-bundle/chunks/restore-LFAMMRYZ.js.map +7 -0
- package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js → schema-DAGSYO6E.js} +6 -10
- package/dist/cli-bundle/chunks/schema-DAGSYO6E.js.map +7 -0
- package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js → schema-UBXJCQAC.js} +6 -10
- package/dist/cli-bundle/chunks/schema-UBXJCQAC.js.map +1 -0
- package/dist/cli-bundle/chunks/update-CJGG5WMV.js +21 -0
- package/dist/cli-bundle/chunks/update-CJGG5WMV.js.map +7 -0
- package/dist/cli-bundle/chunks/update-LKD64AFP.js +25 -0
- package/dist/cli-bundle/chunks/update-LKD64AFP.js.map +1 -0
- package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js +31 -0
- package/dist/cli-bundle/chunks/update-many-G4SM7BHC.js.map +7 -0
- package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js +35 -0
- package/dist/cli-bundle/chunks/update-many-VLIV3D7R.js.map +1 -0
- package/dist/cli-bundle/main.js +29 -31
- package/dist/cli-bundle/main.js.map +2 -2
- package/dist/cli-bundle/sdk-runtime.js +136 -54
- package/dist/cli-bundle/sdk-testing.js +7 -8
- package/dist/cli-bundle/sdk.js +132 -84
- package/dist/cli-bundle/sdk.js.map +2 -2
- package/dist/core/history/drift-scan.js +3 -8
- package/dist/core/history/drift-scan.js.map +1 -1
- package/dist/core/output/mutation-projection.js +11 -5
- package/dist/core/output/mutation-projection.js.map +1 -1
- package/dist/core/search/cache.js +3 -3
- package/dist/core/search/cache.js.map +1 -1
- package/dist/core/search/semantic-defaults.d.ts +2 -0
- package/dist/core/search/semantic-defaults.js +11 -4
- package/dist/core/search/semantic-defaults.js.map +1 -1
- package/dist/core/search/vector-stores.d.ts +1 -1
- package/dist/core/search/vector-stores.js +33 -7
- package/dist/core/search/vector-stores.js.map +1 -1
- package/dist/mcp/server.d.ts +22 -50
- package/dist/mcp/server.js +62 -916
- package/dist/mcp/server.js.map +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +7 -7
- package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +9 -7
- package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
- package/dist/sdk/index.d.ts +4 -2
- package/dist/sdk/index.js +4 -4
- package/dist/sdk/index.js.map +1 -1
- package/dist/sdk/runtime.d.ts +312 -5
- package/dist/sdk/runtime.js +1391 -26
- package/dist/sdk/runtime.js.map +1 -1
- package/dist/sdk/start-task-status.d.ts +13 -0
- package/dist/sdk/start-task-status.js +19 -0
- package/dist/sdk/start-task-status.js.map +1 -0
- package/dist/sdk/workspace-contracts-cache.d.ts +17 -0
- package/dist/sdk/workspace-contracts-cache.js +36 -0
- package/dist/sdk/workspace-contracts-cache.js.map +1 -0
- package/docs/COMMANDS.md +10 -1
- package/docs/RELEASING.md +3 -1
- package/docs/SDK.md +81 -0
- package/docs/TESTING.md +3 -0
- package/docs/examples/sdk-app-embedding/run-embedded-pm.mjs +16 -2
- package/docs/examples/sdk-contract-consumer/inspect-contracts.mjs +16 -1
- package/package.json +1 -1
- package/dist/cli-bundle/chunks/activity-4XQIDNM5.js +0 -18
- package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js +0 -375
- package/dist/cli-bundle/chunks/aggregate-EQX2RGB7.js.map +0 -7
- package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js +0 -372
- package/dist/cli-bundle/chunks/aggregate-PEGZGJXD.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-37E72CNS.js +0 -217
- package/dist/cli-bundle/chunks/chunk-37E72CNS.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js +0 -1961
- package/dist/cli-bundle/chunks/chunk-3PL6LEKP.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js +0 -1749
- package/dist/cli-bundle/chunks/chunk-3U3VEWK6.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4BU75MF4.js +0 -87
- package/dist/cli-bundle/chunks/chunk-4BU75MF4.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js +0 -822
- package/dist/cli-bundle/chunks/chunk-4LRVSBO6.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-4OFLJHX6.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-53BTLLAF.js +0 -2181
- package/dist/cli-bundle/chunks/chunk-53BTLLAF.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-57C2RLW5.js +0 -1704
- package/dist/cli-bundle/chunks/chunk-57C2RLW5.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js +0 -2330
- package/dist/cli-bundle/chunks/chunk-5B3X4Y22.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5J2XPTAD.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js +0 -995
- package/dist/cli-bundle/chunks/chunk-5JZ7APJU.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js +0 -819
- package/dist/cli-bundle/chunks/chunk-75U6M5ZD.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-7C2O74AE.js +0 -23
- package/dist/cli-bundle/chunks/chunk-7C2O74AE.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-7EQNAZX2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-7QH7DHUB.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js +0 -530
- package/dist/cli-bundle/chunks/chunk-BVEUCSH2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js +0 -275
- package/dist/cli-bundle/chunks/chunk-DC3QJQWI.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js +0 -231
- package/dist/cli-bundle/chunks/chunk-DRBV5UC2.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js +0 -2184
- package/dist/cli-bundle/chunks/chunk-E2FUG6GD.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js +0 -1615
- package/dist/cli-bundle/chunks/chunk-EZFKWSC7.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-FJRKQREY.js +0 -228
- package/dist/cli-bundle/chunks/chunk-FJRKQREY.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js +0 -3237
- package/dist/cli-bundle/chunks/chunk-GIWXVMZ3.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-HK72NWAD.js +0 -1570
- package/dist/cli-bundle/chunks/chunk-HK72NWAD.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js +0 -3206
- package/dist/cli-bundle/chunks/chunk-JFCVQXZX.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-JINYH2DB.js +0 -371
- package/dist/cli-bundle/chunks/chunk-JINYH2DB.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-JLA7EVYV.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-K32L7HZO.js +0 -76
- package/dist/cli-bundle/chunks/chunk-K32L7HZO.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js +0 -79
- package/dist/cli-bundle/chunks/chunk-KDZ6K25I.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-KL22PY6L.js +0 -915
- package/dist/cli-bundle/chunks/chunk-KL22PY6L.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js +0 -218
- package/dist/cli-bundle/chunks/chunk-KLG4ZULO.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-LEKT4K7I.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js +0 -1858
- package/dist/cli-bundle/chunks/chunk-MNZ7DRNC.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-MTTXDAK4.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js +0 -520
- package/dist/cli-bundle/chunks/chunk-MZ7VNEVY.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js +0 -1041
- package/dist/cli-bundle/chunks/chunk-N7X4WP6L.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-NBFCNJ7Q.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js +0 -20
- package/dist/cli-bundle/chunks/chunk-NNHHXJB2.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-OBA2WH65.js +0 -918
- package/dist/cli-bundle/chunks/chunk-OBA2WH65.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js +0 -1985
- package/dist/cli-bundle/chunks/chunk-OESSOFJ4.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js +0 -238
- package/dist/cli-bundle/chunks/chunk-OK5NXCZB.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-P5YORJRH.js +0 -1977
- package/dist/cli-bundle/chunks/chunk-P5YORJRH.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js +0 -1031
- package/dist/cli-bundle/chunks/chunk-PPAJG4GB.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-PPE4YUQM.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-QZ342C63.js +0 -220
- package/dist/cli-bundle/chunks/chunk-QZ342C63.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js +0 -368
- package/dist/cli-bundle/chunks/chunk-R2EMWY7Q.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-S4APD35C.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js +0 -1149
- package/dist/cli-bundle/chunks/chunk-STPSZ2XY.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-T4MX77AK.js +0 -272
- package/dist/cli-bundle/chunks/chunk-T4MX77AK.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-T5Y3QSNF.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-TT42JUMF.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-UHKX7I75.js +0 -165
- package/dist/cli-bundle/chunks/chunk-UHKX7I75.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-UI5BJ6DO.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-US3T3W5J.js +0 -1932
- package/dist/cli-bundle/chunks/chunk-US3T3W5J.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js +0 -175
- package/dist/cli-bundle/chunks/chunk-UZRDBL6W.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js +0 -84
- package/dist/cli-bundle/chunks/chunk-VY3VQ22F.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js +0 -1868
- package/dist/cli-bundle/chunks/chunk-VZIYHZDX.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-WVSGSZ6J.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js +0 -1152
- package/dist/cli-bundle/chunks/chunk-XQCG2JGW.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-YD5FML7K.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-YSAH5FY5.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js +0 -1005
- package/dist/cli-bundle/chunks/chunk-YZIR4R3U.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js +0 -215
- package/dist/cli-bundle/chunks/chunk-Z2CRRZYF.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ZD34OFFQ.js.map +0 -7
- package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js +0 -2306
- package/dist/cli-bundle/chunks/chunk-ZJB3UV5U.js.map +0 -1
- package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js +0 -241
- package/dist/cli-bundle/chunks/chunk-ZVDL32GJ.js.map +0 -7
- package/dist/cli-bundle/chunks/claim-4DROPSIS.js +0 -144
- package/dist/cli-bundle/chunks/claim-4DROPSIS.js.map +0 -1
- package/dist/cli-bundle/chunks/claim-VX54TV5U.js +0 -147
- package/dist/cli-bundle/chunks/claim-VX54TV5U.js.map +0 -7
- package/dist/cli-bundle/chunks/close-OB2Y4QP5.js +0 -16
- package/dist/cli-bundle/chunks/config-V57QD47V.js.map +0 -1
- package/dist/cli-bundle/chunks/context-4OQGIPSO.js +0 -45
- package/dist/cli-bundle/chunks/context-WLA6IAWE.js +0 -49
- package/dist/cli-bundle/chunks/contracts-HXJLKCRI.js +0 -12
- package/dist/cli-bundle/chunks/create-WKOZKPQR.js +0 -30
- package/dist/cli-bundle/chunks/eval-N6UHFWVO.js +0 -288
- package/dist/cli-bundle/chunks/eval-N6UHFWVO.js.map +0 -7
- package/dist/cli-bundle/chunks/eval-PHOTWYHI.js +0 -278
- package/dist/cli-bundle/chunks/eval-PHOTWYHI.js.map +0 -1
- package/dist/cli-bundle/chunks/extension-NBAH62ML.js +0 -40
- package/dist/cli-bundle/chunks/extension-ZF6ZZPOU.js +0 -44
- package/dist/cli-bundle/chunks/gc-AETFKZ44.js +0 -398
- package/dist/cli-bundle/chunks/gc-AETFKZ44.js.map +0 -7
- package/dist/cli-bundle/chunks/gc-RLBP4QVN.js +0 -388
- package/dist/cli-bundle/chunks/gc-RLBP4QVN.js.map +0 -1
- package/dist/cli-bundle/chunks/get-NH2MPBCI.js +0 -283
- package/dist/cli-bundle/chunks/get-NH2MPBCI.js.map +0 -1
- package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js +0 -286
- package/dist/cli-bundle/chunks/get-P4ZQXCPZ.js.map +0 -7
- package/dist/cli-bundle/chunks/health-3GVPMQBL.js +0 -1612
- package/dist/cli-bundle/chunks/health-3GVPMQBL.js.map +0 -1
- package/dist/cli-bundle/chunks/health-DNTM72GJ.js +0 -1615
- package/dist/cli-bundle/chunks/health-DNTM72GJ.js.map +0 -7
- package/dist/cli-bundle/chunks/history-RYKLC72X.js +0 -20
- package/dist/cli-bundle/chunks/history-SGPYRAFT.js +0 -24
- package/dist/cli-bundle/chunks/history-redact-4H3FCKF3.js +0 -21
- package/dist/cli-bundle/chunks/init-RPIPQUNV.js +0 -32
- package/dist/cli-bundle/chunks/init-SKQAESQS.js +0 -28
- package/dist/cli-bundle/chunks/list-64LHZ3HM.js +0 -32
- package/dist/cli-bundle/chunks/list-7LXBTEKI.js +0 -36
- package/dist/cli-bundle/chunks/next-7ODPAQ4U.js +0 -306
- package/dist/cli-bundle/chunks/next-7ODPAQ4U.js.map +0 -7
- package/dist/cli-bundle/chunks/next-ODJUM4ZM.js +0 -303
- package/dist/cli-bundle/chunks/next-ODJUM4ZM.js.map +0 -1
- package/dist/cli-bundle/chunks/profile-XQWEQKS3.js +0 -397
- package/dist/cli-bundle/chunks/profile-XQWEQKS3.js.map +0 -1
- package/dist/cli-bundle/chunks/profile-YRDHLMRO.js +0 -400
- package/dist/cli-bundle/chunks/profile-YRDHLMRO.js.map +0 -7
- package/dist/cli-bundle/chunks/register-list-query-5H66WFYF.js.map +0 -7
- package/dist/cli-bundle/chunks/register-list-query-FB3FNDLZ.js.map +0 -1
- package/dist/cli-bundle/chunks/register-operations-A3XAM5J7.js.map +0 -1
- package/dist/cli-bundle/chunks/register-operations-SG7HBSUP.js.map +0 -7
- package/dist/cli-bundle/chunks/register-setup-I45OGJUV.js.map +0 -1
- package/dist/cli-bundle/chunks/register-setup-K6U3NVY5.js.map +0 -7
- package/dist/cli-bundle/chunks/restore-PXOFL6AM.js +0 -19
- package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js +0 -91
- package/dist/cli-bundle/chunks/scheduling-shortcuts-SSC4MYWQ.js.map +0 -7
- package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js +0 -88
- package/dist/cli-bundle/chunks/scheduling-shortcuts-ULRG7MNP.js.map +0 -1
- package/dist/cli-bundle/chunks/search-3S72CTD6.js +0 -38
- package/dist/cli-bundle/chunks/search-WNUNBQXO.js +0 -34
- package/dist/cli-bundle/chunks/stats-IJYTRQGV.js +0 -250
- package/dist/cli-bundle/chunks/stats-IJYTRQGV.js.map +0 -7
- package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js +0 -240
- package/dist/cli-bundle/chunks/stats-L2D5Y2O5.js.map +0 -1
- package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js +0 -309
- package/dist/cli-bundle/chunks/telemetry-L2CVOKVN.js.map +0 -7
- package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js +0 -306
- package/dist/cli-bundle/chunks/telemetry-QBYWQA76.js.map +0 -1
- package/dist/cli-bundle/chunks/test-DQ2QFJ7W.js +0 -45
- package/dist/cli-bundle/chunks/test-W7QBLVJS.js +0 -41
- package/dist/cli-bundle/chunks/test-all-636NTRTT.js +0 -434
- package/dist/cli-bundle/chunks/test-all-636NTRTT.js.map +0 -1
- package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js +0 -437
- package/dist/cli-bundle/chunks/test-all-DWYK3RG6.js.map +0 -7
- package/dist/cli-bundle/chunks/test-runs-245OINZR.js +0 -28
- package/dist/cli-bundle/chunks/test-runs-ZRD4GCTT.js +0 -24
- package/dist/cli-bundle/chunks/update-SFLZPJXX.js +0 -30
- package/dist/cli-bundle/chunks/update-SJZ6S77U.js +0 -26
- package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js +0 -290
- package/dist/cli-bundle/chunks/upgrade-HFFXLZJA.js.map +0 -7
- package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js +0 -287
- package/dist/cli-bundle/chunks/upgrade-UYQKM7RF.js.map +0 -1
- package/dist/cli-bundle/chunks/validate-PA4FDTOV.js +0 -2143
- package/dist/cli-bundle/chunks/validate-PA4FDTOV.js.map +0 -7
- package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js +0 -2105
- package/dist/cli-bundle/chunks/validate-Z7L75YEJ.js.map +0 -1
- /package/dist/cli-bundle/chunks/{activity-4XQIDNM5.js.map → append-F7WPGIQL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{activity-YKAKZTZ4.js.map → append-PVCTBVJG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-T3ABIMGW.js.map → chunk-2TILG6F2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RCT3YJOK.js.map → chunk-3TYOW6RR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-3JZNEQBA.js.map → chunk-3X542TEY.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YOF5VPKM.js.map → chunk-7VQ3JJN5.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-P5TFTLWW.js.map → chunk-AGAVEDIE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-YFIE7YK6.js.map → chunk-AJUON7E6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-7WYXBPYQ.js.map → chunk-DR2V5OIV.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-PDXT6Q55.js.map → chunk-EDO7VXSO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-FUM6UMY4.js.map → chunk-EVEPHNXJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-RX3HQSYG.js.map → chunk-FN6SB4HU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-DLQ4ZTCU.js.map → chunk-H2SMKL2N.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-C3PMDWGX.js.map → chunk-HX6QXV5P.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-N6DNM2FA.js.map → chunk-P3MJJW7P.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-5JE6SMYS.js.map → chunk-PDXJXEZJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-AAEQMOC6.js.map → chunk-TEKZOS7M.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-NER3KUUS.js.map → chunk-VLEA2UTQ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-ZMD35NYG.js.map → chunk-WCWVEXGA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-T35XLYZF.js.map → chunk-YPMZMKN7.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-R3ZBLGTC.js.map → chunk-YTD5GICJ.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{chunk-EEY54JMF.js.map → chunk-ZO7CLOY2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-3YRR3XY6.js.map → close-3YYQ5OG2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{close-OB2Y4QP5.js.map → close-Z3Q4U7TS.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{context-4OQGIPSO.js.map → close-many-3L2RXH3M.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{context-WLA6IAWE.js.map → close-many-D366FTIG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{contracts-OJEXMKVW.js.map → comments-54XDJNFE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{contracts-HXJLKCRI.js.map → comments-HGHC2PN6.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-XWWQFQ6S.js.map → copy-44RT5GDW.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{create-WKOZKPQR.js.map → copy-UGMUGHZA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{extension-ZF6ZZPOU.js.map → create-4GWJWPXG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{extension-NBAH62ML.js.map → create-AZXCUYKP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-RYKLC72X.js.map → delete-Y6SXIQ4X.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-SGPYRAFT.js.map → delete-YQ2VPXNF.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-54ICFKXM.js.map → deps-BU5EBJDU.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{history-redact-4H3FCKF3.js.map → deps-FMANWFRP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{init-RPIPQUNV.js.map → docs-OQBSJNIA.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{init-SKQAESQS.js.map → docs-VNPBZXEL.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{list-64LHZ3HM.js.map → files-72HZEBOE.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{list-7LXBTEKI.js.map → files-HTSB2KJG.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-YJ2ET6AT.js.map → focus-FOG4ALC2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{restore-PXOFL6AM.js.map → focus-SUTMKXGX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-Y6DXXK2F.js.map → history-compact-M6IFAMBP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{schema-2PUXCZ25.js.map → history-compact-NEXRPP2O.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{search-3S72CTD6.js.map → history-redact-NQX3OGZP.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{search-WNUNBQXO.js.map → history-redact-WQJBZ3PX.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-W7QBLVJS.js.map → history-repair-CBHMHAJO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-DQ2QFJ7W.js.map → history-repair-NHOJG7WO.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-runs-ZRD4GCTT.js.map → learnings-M64NTSOR.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{test-runs-245OINZR.js.map → learnings-T63JGKKN.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-SJZ6S77U.js.map → notes-73WE2UV2.js.map} +0 -0
- /package/dist/cli-bundle/chunks/{update-SFLZPJXX.js.map → notes-U7L6HQQ2.js.map} +0 -0
|
@@ -1,3237 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
buildExtensionDescribeResult
|
|
3
|
-
} from "./chunk-KDZ6K25I.js";
|
|
4
|
-
import {
|
|
5
|
-
PM_PACKAGE_RESOURCE_KINDS,
|
|
6
|
-
collectPackageExtensionDirectories,
|
|
7
|
-
readPmPackageManifest
|
|
8
|
-
} from "./chunk-ZVDL32GJ.js";
|
|
9
|
-
import {
|
|
10
|
-
scaffoldExtensionProject
|
|
11
|
-
} from "./chunk-E2FUG6GD.js";
|
|
12
|
-
import {
|
|
13
|
-
splitCommaList
|
|
14
|
-
} from "./chunk-5HIZDR5A.js";
|
|
15
|
-
import {
|
|
16
|
-
normalizeExtensionNameForMatch,
|
|
17
|
-
normalizeManagedDirectoryName,
|
|
18
|
-
normalizeStringList,
|
|
19
|
-
parseExtensionManifest,
|
|
20
|
-
validateExtensionDirectory
|
|
21
|
-
} from "./chunk-R3ZBLGTC.js";
|
|
22
|
-
import {
|
|
23
|
-
ensureTypeFolderScaffold
|
|
24
|
-
} from "./chunk-4QQ6PM7M.js";
|
|
25
|
-
import {
|
|
26
|
-
nowIso
|
|
27
|
-
} from "./chunk-DRBV5UC2.js";
|
|
28
|
-
import {
|
|
29
|
-
PmCliError,
|
|
30
|
-
readSettings,
|
|
31
|
-
writeSettings
|
|
32
|
-
} from "./chunk-P5YORJRH.js";
|
|
33
|
-
import {
|
|
34
|
-
EXIT_CODE,
|
|
35
|
-
EXTENSION_CAPABILITY_CONTRACT,
|
|
36
|
-
KNOWN_EXTENSION_CAPABILITIES,
|
|
37
|
-
activateExtensions,
|
|
38
|
-
isPathWithinDirectory,
|
|
39
|
-
levenshteinDistanceWithinLimit,
|
|
40
|
-
loadExtensions,
|
|
41
|
-
nextExtensionReloadToken,
|
|
42
|
-
parseLegacyExtensionCapabilityAliasWarning,
|
|
43
|
-
parseUnknownExtensionCapabilityWarning,
|
|
44
|
-
pathExists,
|
|
45
|
-
reconcileExtensionCapabilityUsage,
|
|
46
|
-
resolveExtensionRoots,
|
|
47
|
-
resolveGlobalPmRoot,
|
|
48
|
-
resolvePmPackageRootFromModule,
|
|
49
|
-
resolvePmRoot
|
|
50
|
-
} from "./chunk-5VVUKE3U.js";
|
|
51
|
-
|
|
52
|
-
// dist/cli/commands/extension.js
|
|
53
|
-
import { execFile as execFile2 } from "node:child_process";
|
|
54
|
-
import fs4 from "node:fs/promises";
|
|
55
|
-
import os2 from "node:os";
|
|
56
|
-
import path4 from "node:path";
|
|
57
|
-
import { promisify as promisify2 } from "node:util";
|
|
58
|
-
|
|
59
|
-
// dist/cli/commands/extension/managed-state.js
|
|
60
|
-
import fs from "node:fs/promises";
|
|
61
|
-
import path from "node:path";
|
|
62
|
-
!(function() {
|
|
63
|
-
try {
|
|
64
|
-
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
65
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "0874e784-e274-5edd-8fbf-26d94a6c4a32");
|
|
66
|
-
} catch (e2) {
|
|
67
|
-
}
|
|
68
|
-
})();
|
|
69
|
-
var MANAGED_EXTENSION_STATE_FILENAME = ".managed-extensions.json";
|
|
70
|
-
var MANAGED_EXTENSION_STATE_VERSION = 1;
|
|
71
|
-
function resolveManagedExtensionStatePath(extensionsRoot) {
|
|
72
|
-
return path.join(extensionsRoot, MANAGED_EXTENSION_STATE_FILENAME);
|
|
73
|
-
}
|
|
74
|
-
function createEmptyManagedExtensionState() {
|
|
75
|
-
return {
|
|
76
|
-
version: MANAGED_EXTENSION_STATE_VERSION,
|
|
77
|
-
updated_at: nowIso(),
|
|
78
|
-
entries: []
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function sortManagedEntries(entries) {
|
|
82
|
-
return [...entries].sort((left, right) => {
|
|
83
|
-
const byScope = left.scope.localeCompare(right.scope);
|
|
84
|
-
if (byScope !== 0) {
|
|
85
|
-
return byScope;
|
|
86
|
-
}
|
|
87
|
-
const byName = left.name.localeCompare(right.name);
|
|
88
|
-
if (byName !== 0) {
|
|
89
|
-
return byName;
|
|
90
|
-
}
|
|
91
|
-
return left.directory.localeCompare(right.directory);
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
function managedExtensionSourcesEquivalent(left, right) {
|
|
95
|
-
if (left.kind !== right.kind || left.input !== right.input || left.location !== right.location) {
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
if (left.kind === "npm" && right.kind === "npm") {
|
|
99
|
-
return left.package === right.package && left.version === right.version;
|
|
100
|
-
}
|
|
101
|
-
if (left.kind === "github" && right.kind === "github") {
|
|
102
|
-
return left.repository === right.repository && left.ref === right.ref && left.subpath === right.subpath && left.commit === right.commit;
|
|
103
|
-
}
|
|
104
|
-
if (left.kind === "builtin" && right.kind === "builtin") {
|
|
105
|
-
return left.name === right.name;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
function optionalString(value) {
|
|
110
|
-
return typeof value === "string" ? value : void 0;
|
|
111
|
-
}
|
|
112
|
-
function hasRequiredManagedRecordFields(entry) {
|
|
113
|
-
return typeof entry.name === "string" && entry.name.trim().length > 0 && typeof entry.directory === "string" && entry.directory.trim().length > 0 && (entry.scope === "project" || entry.scope === "global") && typeof entry.manifest_version === "string" && typeof entry.manifest_entry === "string" && Array.isArray(entry.capabilities) && entry.capabilities.every((value) => typeof value === "string") && typeof entry.installed_at === "string" && typeof entry.updated_at === "string";
|
|
114
|
-
}
|
|
115
|
-
function normalizeManagedSource(raw) {
|
|
116
|
-
if (typeof raw !== "object" || raw === null) {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
const source = raw;
|
|
120
|
-
if (source.kind !== "local" && source.kind !== "github" && source.kind !== "npm" && source.kind !== "builtin" || typeof source.input !== "string" || typeof source.location !== "string") {
|
|
121
|
-
return null;
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
kind: source.kind,
|
|
125
|
-
input: source.input,
|
|
126
|
-
location: source.location,
|
|
127
|
-
name: optionalString(source.name),
|
|
128
|
-
package: optionalString(source.package),
|
|
129
|
-
version: optionalString(source.version),
|
|
130
|
-
repository: optionalString(source.repository),
|
|
131
|
-
owner: optionalString(source.owner),
|
|
132
|
-
repo: optionalString(source.repo),
|
|
133
|
-
ref: optionalString(source.ref),
|
|
134
|
-
subpath: optionalString(source.subpath),
|
|
135
|
-
commit: optionalString(source.commit)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function normalizeManagedRecord(raw) {
|
|
139
|
-
if (typeof raw !== "object" || raw === null) {
|
|
140
|
-
return null;
|
|
141
|
-
}
|
|
142
|
-
const entry = raw;
|
|
143
|
-
if (!hasRequiredManagedRecordFields(entry)) {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
const source = normalizeManagedSource(entry.source);
|
|
147
|
-
if (!source) {
|
|
148
|
-
return null;
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
name: entry.name.trim(),
|
|
152
|
-
directory: entry.directory.trim(),
|
|
153
|
-
scope: entry.scope,
|
|
154
|
-
manifest_version: entry.manifest_version,
|
|
155
|
-
manifest_entry: entry.manifest_entry,
|
|
156
|
-
capabilities: normalizeStringList(entry.capabilities),
|
|
157
|
-
installed_at: entry.installed_at,
|
|
158
|
-
updated_at: entry.updated_at,
|
|
159
|
-
source,
|
|
160
|
-
last_update_check_at: optionalString(entry.last_update_check_at),
|
|
161
|
-
last_update_remote_commit: optionalString(entry.last_update_remote_commit),
|
|
162
|
-
update_available: typeof entry.update_available === "boolean" || entry.update_available === null ? entry.update_available : void 0,
|
|
163
|
-
update_error: optionalString(entry.update_error)
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
function normalizeManagedState(raw) {
|
|
167
|
-
if (typeof raw !== "object" || raw === null) {
|
|
168
|
-
return null;
|
|
169
|
-
}
|
|
170
|
-
const candidate = raw;
|
|
171
|
-
if (candidate.version !== MANAGED_EXTENSION_STATE_VERSION || !Array.isArray(candidate.entries)) {
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
const entries = [];
|
|
175
|
-
for (const rawEntry of candidate.entries) {
|
|
176
|
-
const record = normalizeManagedRecord(rawEntry);
|
|
177
|
-
if (record) {
|
|
178
|
-
entries.push(record);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
version: MANAGED_EXTENSION_STATE_VERSION,
|
|
183
|
-
updated_at: optionalString(candidate.updated_at) ?? nowIso(),
|
|
184
|
-
entries: sortManagedEntries(entries)
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
async function readManagedExtensionState(extensionsRoot) {
|
|
188
|
-
const statePath = resolveManagedExtensionStatePath(extensionsRoot);
|
|
189
|
-
const fallback = createEmptyManagedExtensionState();
|
|
190
|
-
try {
|
|
191
|
-
const raw = await fs.readFile(statePath, "utf8");
|
|
192
|
-
const parsed = JSON.parse(raw);
|
|
193
|
-
const normalized = normalizeManagedState(parsed);
|
|
194
|
-
if (!normalized) {
|
|
195
|
-
throw new PmCliError(`Managed extension state file "${statePath}" has an invalid schema. Repair or remove it before mutating extension state.`, EXIT_CODE.GENERIC_FAILURE);
|
|
196
|
-
}
|
|
197
|
-
return {
|
|
198
|
-
path: statePath,
|
|
199
|
-
state: normalized,
|
|
200
|
-
warnings: []
|
|
201
|
-
};
|
|
202
|
-
} catch (error) {
|
|
203
|
-
if (error instanceof PmCliError) {
|
|
204
|
-
throw error;
|
|
205
|
-
}
|
|
206
|
-
if (typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT") {
|
|
207
|
-
return {
|
|
208
|
-
path: statePath,
|
|
209
|
-
state: fallback,
|
|
210
|
-
warnings: []
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
throw new PmCliError(`Managed extension state file "${statePath}" could not be read. Repair or remove it before mutating extension state.`, EXIT_CODE.GENERIC_FAILURE);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
async function writeManagedExtensionState(extensionsRoot, state) {
|
|
217
|
-
const statePath = resolveManagedExtensionStatePath(extensionsRoot);
|
|
218
|
-
const normalized = {
|
|
219
|
-
version: MANAGED_EXTENSION_STATE_VERSION,
|
|
220
|
-
updated_at: nowIso(),
|
|
221
|
-
entries: sortManagedEntries(state.entries)
|
|
222
|
-
};
|
|
223
|
-
await fs.mkdir(extensionsRoot, { recursive: true });
|
|
224
|
-
await fs.writeFile(statePath, `${JSON.stringify(normalized, null, 2)}
|
|
225
|
-
`, "utf8");
|
|
226
|
-
}
|
|
227
|
-
function upsertManagedEntry(state, entry) {
|
|
228
|
-
const updatedEntries = state.entries.filter((candidate) => normalizeExtensionNameForMatch(candidate.name) !== normalizeExtensionNameForMatch(entry.name) && normalizeExtensionNameForMatch(candidate.directory) !== normalizeExtensionNameForMatch(entry.directory));
|
|
229
|
-
updatedEntries.push(entry);
|
|
230
|
-
return {
|
|
231
|
-
...state,
|
|
232
|
-
updated_at: nowIso(),
|
|
233
|
-
entries: sortManagedEntries(updatedEntries)
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// dist/cli/commands/extension/install-sources.js
|
|
238
|
-
import { execFile } from "node:child_process";
|
|
239
|
-
import fs2 from "node:fs/promises";
|
|
240
|
-
import os from "node:os";
|
|
241
|
-
import path2 from "node:path";
|
|
242
|
-
import { fileURLToPath } from "node:url";
|
|
243
|
-
import { promisify } from "node:util";
|
|
244
|
-
!(function() {
|
|
245
|
-
try {
|
|
246
|
-
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
247
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "eab3d475-6769-535e-96a9-6bc5153c9627");
|
|
248
|
-
} catch (e2) {
|
|
249
|
-
}
|
|
250
|
-
})();
|
|
251
|
-
var execFileAsync = promisify(execFile);
|
|
252
|
-
var PM_CLI_PACKAGE_NAME = "@unbrained/pm-cli";
|
|
253
|
-
function parseGithubPathSpec(pathSpec, input, refOverride) {
|
|
254
|
-
const segments = pathSpec.split("/").map((segment) => segment.trim()).filter((segment) => segment.length > 0);
|
|
255
|
-
if (segments.length < 2) {
|
|
256
|
-
return null;
|
|
257
|
-
}
|
|
258
|
-
const owner = segments[0];
|
|
259
|
-
const repo = segments[1].replace(/\.git$/i, "");
|
|
260
|
-
if (owner.length === 0 || repo.length === 0) {
|
|
261
|
-
return null;
|
|
262
|
-
}
|
|
263
|
-
const tail = segments.slice(2);
|
|
264
|
-
let ref;
|
|
265
|
-
let subpath;
|
|
266
|
-
if (tail[0] === "tree" && tail.length >= 2) {
|
|
267
|
-
ref = tail[1];
|
|
268
|
-
subpath = tail.slice(2).join("/");
|
|
269
|
-
} else if (tail.length > 0) {
|
|
270
|
-
subpath = tail.join("/");
|
|
271
|
-
}
|
|
272
|
-
if (typeof refOverride === "string" && refOverride.trim().length > 0) {
|
|
273
|
-
ref = refOverride.trim();
|
|
274
|
-
}
|
|
275
|
-
return {
|
|
276
|
-
kind: "github",
|
|
277
|
-
input,
|
|
278
|
-
owner,
|
|
279
|
-
repo,
|
|
280
|
-
repository: `https://github.com/${owner}/${repo}.git`,
|
|
281
|
-
ref,
|
|
282
|
-
subpath: subpath && subpath.length > 0 ? subpath : void 0
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
function parseExtensionInstallSource(input, options = {}) {
|
|
286
|
-
const normalizedInput = input.trim();
|
|
287
|
-
if (normalizedInput.length === 0) {
|
|
288
|
-
throw new PmCliError("Extension source is required for --install.", EXIT_CODE.USAGE);
|
|
289
|
-
}
|
|
290
|
-
const refOverride = typeof options.ref === "string" && options.ref.trim().length > 0 ? options.ref.trim() : void 0;
|
|
291
|
-
if (normalizedInput.startsWith("npm:")) {
|
|
292
|
-
const spec = normalizedInput.slice("npm:".length).trim();
|
|
293
|
-
if (spec.length === 0) {
|
|
294
|
-
throw new PmCliError('npm package source must include a package spec after "npm:".', EXIT_CODE.USAGE);
|
|
295
|
-
}
|
|
296
|
-
if (options.forceGithub) {
|
|
297
|
-
throw new PmCliError('Options "--gh/--github" cannot be combined with npm: package sources.', EXIT_CODE.USAGE);
|
|
298
|
-
}
|
|
299
|
-
if (refOverride) {
|
|
300
|
-
throw new PmCliError('Option "--ref" cannot be combined with npm: package sources.', EXIT_CODE.USAGE);
|
|
301
|
-
}
|
|
302
|
-
return {
|
|
303
|
-
kind: "npm",
|
|
304
|
-
input: normalizedInput,
|
|
305
|
-
spec
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
const maybeGithubByUrl = (() => {
|
|
309
|
-
try {
|
|
310
|
-
const parsed = new URL(normalizedInput);
|
|
311
|
-
if (parsed.hostname !== "github.com") {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
const pathSpec = parsed.pathname.replace(/^\/+/, "");
|
|
315
|
-
return parseGithubPathSpec(pathSpec, normalizedInput, refOverride);
|
|
316
|
-
} catch {
|
|
317
|
-
return null;
|
|
318
|
-
}
|
|
319
|
-
})();
|
|
320
|
-
if (maybeGithubByUrl) {
|
|
321
|
-
return maybeGithubByUrl;
|
|
322
|
-
}
|
|
323
|
-
const strippedDomainInput = normalizedInput.startsWith("github.com/") ? normalizedInput.slice("github.com/".length) : null;
|
|
324
|
-
if (strippedDomainInput) {
|
|
325
|
-
const parsed = parseGithubPathSpec(strippedDomainInput, normalizedInput, refOverride);
|
|
326
|
-
if (!parsed) {
|
|
327
|
-
throw new PmCliError(`Invalid GitHub source "${normalizedInput}".`, EXIT_CODE.USAGE);
|
|
328
|
-
}
|
|
329
|
-
return parsed;
|
|
330
|
-
}
|
|
331
|
-
if (options.forceGithub) {
|
|
332
|
-
const parsed = parseGithubPathSpec(normalizedInput, normalizedInput, refOverride);
|
|
333
|
-
if (!parsed) {
|
|
334
|
-
throw new PmCliError(`Invalid GitHub shorthand "${normalizedInput}".`, EXIT_CODE.USAGE);
|
|
335
|
-
}
|
|
336
|
-
return parsed;
|
|
337
|
-
}
|
|
338
|
-
if (/^https?:\/\//i.test(normalizedInput)) {
|
|
339
|
-
throw new PmCliError(`Unsupported extension source URL "${normalizedInput}". Supported remote source host: github.com.`, EXIT_CODE.USAGE);
|
|
340
|
-
}
|
|
341
|
-
return {
|
|
342
|
-
kind: "local",
|
|
343
|
-
input: normalizedInput,
|
|
344
|
-
absolute_path: path2.resolve(process.cwd(), normalizedInput)
|
|
345
|
-
};
|
|
346
|
-
}
|
|
347
|
-
async function runGitCommand(args, execRunner = execFileAsync) {
|
|
348
|
-
try {
|
|
349
|
-
const result = await execRunner("git", args, { encoding: "utf8" });
|
|
350
|
-
return (result.stdout ?? "").trim();
|
|
351
|
-
} catch (error) {
|
|
352
|
-
const stderr = typeof error === "object" && error !== null && "stderr" in error ? String(error.stderr) : "";
|
|
353
|
-
const message = stderr.trim().length > 0 ? stderr.trim() : error instanceof Error ? error.message : String(error);
|
|
354
|
-
throw new PmCliError(`Git command failed: git ${args.join(" ")}
|
|
355
|
-
${message}`, EXIT_CODE.GENERIC_FAILURE);
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
function resolveNpmCommandName(platform = process.platform) {
|
|
359
|
-
return platform === "win32" ? "npm.cmd" : "npm";
|
|
360
|
-
}
|
|
361
|
-
function shouldRunNpmCommandInShell(platform = process.platform) {
|
|
362
|
-
return platform === "win32";
|
|
363
|
-
}
|
|
364
|
-
async function runNpmCommand(args, cwd, execRunner = execFileAsync) {
|
|
365
|
-
const npmCommand = resolveNpmCommandName();
|
|
366
|
-
try {
|
|
367
|
-
const result = await execRunner(npmCommand, args, { cwd, encoding: "utf8", shell: shouldRunNpmCommandInShell() });
|
|
368
|
-
return (result.stdout ?? "").trim();
|
|
369
|
-
} catch (error) {
|
|
370
|
-
const stderr = typeof error === "object" && error !== null && "stderr" in error ? String(error.stderr) : "";
|
|
371
|
-
const message = stderr.trim().length > 0 ? stderr.trim() : error instanceof Error ? error.message : String(error);
|
|
372
|
-
throw new PmCliError(`npm command failed: ${npmCommand} ${args.join(" ")}
|
|
373
|
-
${message}`, EXIT_CODE.GENERIC_FAILURE);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
function npmPackageNameFromSpec(spec) {
|
|
377
|
-
const trimmed = spec.trim();
|
|
378
|
-
const withoutAlias = trimmed.includes("@file:") ? trimmed.slice(0, trimmed.lastIndexOf("@file:")) : trimmed;
|
|
379
|
-
if (withoutAlias.startsWith("@")) {
|
|
380
|
-
const scoped = withoutAlias.match(/^(@[^/@\s]+\/[^/@\s]+)/);
|
|
381
|
-
return scoped?.[1] ?? withoutAlias;
|
|
382
|
-
}
|
|
383
|
-
const unscoped = withoutAlias.match(/^([^/@\s]+)/);
|
|
384
|
-
return unscoped?.[1] ?? withoutAlias;
|
|
385
|
-
}
|
|
386
|
-
function isNpmNotFoundError(error) {
|
|
387
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
388
|
-
const normalized = message.toLowerCase();
|
|
389
|
-
return normalized.includes("npm err! code e404") || normalized.includes("404 not found") || normalized.includes("is not in this registry");
|
|
390
|
-
}
|
|
391
|
-
function isNpmPackNotFoundError(error) {
|
|
392
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
393
|
-
const normalized = message.toLowerCase();
|
|
394
|
-
return isNpmNotFoundError(error) || normalized.includes("not found");
|
|
395
|
-
}
|
|
396
|
-
function isFirstPartyPmPackageName(packageName) {
|
|
397
|
-
const normalized = packageName.trim().toLowerCase();
|
|
398
|
-
return normalized.startsWith("@unbrained/pm-") || normalized.startsWith("pm-");
|
|
399
|
-
}
|
|
400
|
-
function buildNpmNotFoundRecovery(spec) {
|
|
401
|
-
const packageName = npmPackageNameFromSpec(spec);
|
|
402
|
-
const isFirstPartyPackage = isFirstPartyPmPackageName(packageName);
|
|
403
|
-
const repoName = packageName.replace(/^.*\//, "");
|
|
404
|
-
const githubSource = isFirstPartyPackage ? `github.com/unbraind/${repoName}` : void 0;
|
|
405
|
-
const nextBestCommand = githubSource ? `pm install --project ${githubSource}` : void 0;
|
|
406
|
-
return {
|
|
407
|
-
message: isFirstPartyPackage ? `npm package "${spec}" was not found in the registry. If this is an unpublished first-party pm package, install its GitHub repository instead.` : `npm package "${spec}" was not found in the registry.`,
|
|
408
|
-
context: {
|
|
409
|
-
code: "npm_package_not_found",
|
|
410
|
-
required: "Use an install source that exists, or publish the npm package before installing it with npm:<name>.",
|
|
411
|
-
why: "Classifying npm 404s avoids repeated registry retries and gives agents a deterministic fallback path.",
|
|
412
|
-
examples: nextBestCommand ? [nextBestCommand, `pm package catalog --project --json`] : [`npm view ${packageName}`, `pm package catalog --project --json`],
|
|
413
|
-
nextSteps: nextBestCommand ? [
|
|
414
|
-
`Try ${nextBestCommand} if the repository exists.`,
|
|
415
|
-
"Use pm package catalog --project --json to inspect bundled package aliases before installing."
|
|
416
|
-
] : [
|
|
417
|
-
`Verify ${packageName} exists in the npm registry and that you have access to it.`,
|
|
418
|
-
"Use pm package catalog --project --json to inspect bundled package aliases before installing."
|
|
419
|
-
],
|
|
420
|
-
recovery: {
|
|
421
|
-
attempted_command: `pm install --project npm:${spec}`,
|
|
422
|
-
normalized_args: ["install", "--project", `npm:${spec}`],
|
|
423
|
-
...githubSource && nextBestCommand ? {
|
|
424
|
-
fallback_candidates: [
|
|
425
|
-
{
|
|
426
|
-
source: githubSource,
|
|
427
|
-
command: nextBestCommand,
|
|
428
|
-
reason: "canonical first-party GitHub repository fallback for unpublished pm packages"
|
|
429
|
-
}
|
|
430
|
-
],
|
|
431
|
-
next_best_command: nextBestCommand
|
|
432
|
-
} : {}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
};
|
|
436
|
-
}
|
|
437
|
-
function wrapNpmPackResolutionError(spec, error) {
|
|
438
|
-
if (!isNpmPackNotFoundError(error)) {
|
|
439
|
-
return null;
|
|
440
|
-
}
|
|
441
|
-
const recovery = buildNpmNotFoundRecovery(spec);
|
|
442
|
-
return new PmCliError(recovery.message, EXIT_CODE.NOT_FOUND, recovery.context);
|
|
443
|
-
}
|
|
444
|
-
async function resolveLocalNpmPackagePath(spec) {
|
|
445
|
-
if (path2.isAbsolute(spec) || spec.startsWith(".") || spec.startsWith("..")) {
|
|
446
|
-
const absolutePath = path2.resolve(process.cwd(), spec);
|
|
447
|
-
return await pathExists(absolutePath) ? absolutePath : null;
|
|
448
|
-
}
|
|
449
|
-
try {
|
|
450
|
-
const parsed = new URL(spec);
|
|
451
|
-
if (parsed.protocol === "file:") {
|
|
452
|
-
const absolutePath = fileURLToPath(parsed);
|
|
453
|
-
return await pathExists(absolutePath) ? absolutePath : null;
|
|
454
|
-
}
|
|
455
|
-
} catch {
|
|
456
|
-
}
|
|
457
|
-
if (!/^[a-z][a-z0-9+.-]*:/i.test(spec)) {
|
|
458
|
-
const absolutePath = path2.resolve(process.cwd(), spec);
|
|
459
|
-
if (await pathExists(absolutePath)) {
|
|
460
|
-
return absolutePath;
|
|
461
|
-
}
|
|
462
|
-
}
|
|
463
|
-
return null;
|
|
464
|
-
}
|
|
465
|
-
async function resolveNpmPackSpec(spec) {
|
|
466
|
-
const localPath = await resolveLocalNpmPackagePath(spec);
|
|
467
|
-
if (localPath) {
|
|
468
|
-
return localPath;
|
|
469
|
-
}
|
|
470
|
-
const localFileAlias = normalizeNpmLocalFileAliasSpec(spec);
|
|
471
|
-
if (localFileAlias !== spec) {
|
|
472
|
-
return localFileAlias;
|
|
473
|
-
}
|
|
474
|
-
if (/^[a-z][a-z0-9+.-]*:/i.test(spec)) {
|
|
475
|
-
return spec;
|
|
476
|
-
}
|
|
477
|
-
return spec;
|
|
478
|
-
}
|
|
479
|
-
function normalizeNpmLocalFileAliasSpec(spec, cwd = process.cwd()) {
|
|
480
|
-
const marker = "@file:";
|
|
481
|
-
const markerIndex = spec.lastIndexOf(marker);
|
|
482
|
-
if (markerIndex <= 0) {
|
|
483
|
-
return spec;
|
|
484
|
-
}
|
|
485
|
-
const packageName = spec.slice(0, markerIndex);
|
|
486
|
-
const target = spec.slice(markerIndex + marker.length);
|
|
487
|
-
if (packageName.trim().length === 0 || target.trim().length === 0) {
|
|
488
|
-
return spec;
|
|
489
|
-
}
|
|
490
|
-
if (target.startsWith("//") && !target.startsWith("///")) {
|
|
491
|
-
return spec;
|
|
492
|
-
}
|
|
493
|
-
if (!target.startsWith("/")) {
|
|
494
|
-
return `${packageName}@${path2.resolve(cwd, target)}`;
|
|
495
|
-
}
|
|
496
|
-
let decodedPath;
|
|
497
|
-
try {
|
|
498
|
-
decodedPath = decodeURIComponent(new URL(`file:${target}`).pathname);
|
|
499
|
-
} catch {
|
|
500
|
-
return spec;
|
|
501
|
-
}
|
|
502
|
-
const nativePath = /^\/[A-Za-z]:/.test(decodedPath) ? decodedPath.slice(1) : decodedPath;
|
|
503
|
-
return `${packageName}@${nativePath}`;
|
|
504
|
-
}
|
|
505
|
-
function parsePackedNpmPackage(stdout, packDirectory) {
|
|
506
|
-
try {
|
|
507
|
-
const parsed = JSON.parse(stdout);
|
|
508
|
-
const first = Array.isArray(parsed) ? parsed[0] : void 0;
|
|
509
|
-
if (first && typeof first.filename === "string" && first.filename.trim().length > 0) {
|
|
510
|
-
return {
|
|
511
|
-
tarball: path2.resolve(packDirectory, first.filename),
|
|
512
|
-
package: typeof first.name === "string" ? first.name : void 0,
|
|
513
|
-
version: typeof first.version === "string" ? first.version : void 0
|
|
514
|
-
};
|
|
515
|
-
}
|
|
516
|
-
} catch {
|
|
517
|
-
}
|
|
518
|
-
const lastLine = stdout.split(/\r?\n/).map((line) => line.trim()).filter((line) => line.length > 0).at(-1);
|
|
519
|
-
if (!lastLine) {
|
|
520
|
-
throw new PmCliError("npm pack did not report a tarball filename.", EXIT_CODE.GENERIC_FAILURE);
|
|
521
|
-
}
|
|
522
|
-
return {
|
|
523
|
-
tarball: path2.resolve(packDirectory, lastLine)
|
|
524
|
-
};
|
|
525
|
-
}
|
|
526
|
-
async function resolveNpmSourceDirectory(source) {
|
|
527
|
-
return resolveNpmSourceDirectoryWithRunner(source, runNpmCommand);
|
|
528
|
-
}
|
|
529
|
-
async function resolveNpmSourceDirectoryWithRunner(source, npmRunner) {
|
|
530
|
-
const localPackageRoot = await resolveLocalNpmPackagePath(source.spec);
|
|
531
|
-
if (localPackageRoot) {
|
|
532
|
-
const packageJsonPath = path2.join(localPackageRoot, "package.json");
|
|
533
|
-
const packageJson = await pathExists(packageJsonPath) ? JSON.parse(await fs2.readFile(packageJsonPath, "utf8")) : {};
|
|
534
|
-
return {
|
|
535
|
-
directory: await resolvePackageExtensionDirectory(localPackageRoot, source.input),
|
|
536
|
-
package: typeof packageJson.name === "string" ? packageJson.name : void 0,
|
|
537
|
-
version: typeof packageJson.version === "string" ? packageJson.version : void 0,
|
|
538
|
-
cleanup: async () => {
|
|
539
|
-
}
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
const tempRoot = await fs2.mkdtemp(path2.join(os.tmpdir(), "pm-npm-package-source-"));
|
|
543
|
-
const packDirectory = path2.join(tempRoot, "pack");
|
|
544
|
-
const extractDirectory = path2.join(tempRoot, "extract");
|
|
545
|
-
await fs2.mkdir(packDirectory, { recursive: true });
|
|
546
|
-
await fs2.mkdir(extractDirectory, { recursive: true });
|
|
547
|
-
try {
|
|
548
|
-
const packSpec = await resolveNpmPackSpec(source.spec);
|
|
549
|
-
const packStdout = await npmRunner(["pack", packSpec, "--json", "--pack-destination", packDirectory]);
|
|
550
|
-
const packed = parsePackedNpmPackage(packStdout, packDirectory);
|
|
551
|
-
await execFileAsync("tar", ["-xzf", packed.tarball, "-C", extractDirectory], { encoding: "utf8" });
|
|
552
|
-
const packageRoot = path2.join(extractDirectory, "package");
|
|
553
|
-
await installNpmPackageRuntimeDependencies(packageRoot);
|
|
554
|
-
const directory = await resolvePackageExtensionDirectory(packageRoot, source.input);
|
|
555
|
-
return {
|
|
556
|
-
directory,
|
|
557
|
-
package: packed.package,
|
|
558
|
-
version: packed.version,
|
|
559
|
-
cleanup: async () => {
|
|
560
|
-
await fs2.rm(tempRoot, { recursive: true, force: true });
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
} catch (error) {
|
|
564
|
-
await fs2.rm(tempRoot, { recursive: true, force: true });
|
|
565
|
-
const wrappedError = wrapNpmPackResolutionError(source.spec, error);
|
|
566
|
-
if (wrappedError) {
|
|
567
|
-
throw wrappedError;
|
|
568
|
-
}
|
|
569
|
-
throw error;
|
|
570
|
-
}
|
|
571
|
-
}
|
|
572
|
-
async function installNpmPackageRuntimeDependencies(packageRoot) {
|
|
573
|
-
const packageJsonPath = path2.join(packageRoot, "package.json");
|
|
574
|
-
if (!await pathExists(packageJsonPath)) {
|
|
575
|
-
return;
|
|
576
|
-
}
|
|
577
|
-
let parsed;
|
|
578
|
-
try {
|
|
579
|
-
parsed = JSON.parse(await fs2.readFile(packageJsonPath, "utf8"));
|
|
580
|
-
} catch {
|
|
581
|
-
return;
|
|
582
|
-
}
|
|
583
|
-
if (typeof parsed !== "object" || parsed === null) {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
const manifest = parsed;
|
|
587
|
-
const dependencySpecs = runtimeDependencyInstallSpecs(manifest);
|
|
588
|
-
const shouldLinkHostedPmCli = hasHostedPmCliDependency(manifest);
|
|
589
|
-
if (dependencySpecs.length === 0 && !shouldLinkHostedPmCli) {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
const runtimeOnlyManifest = { ...parsed };
|
|
593
|
-
delete runtimeOnlyManifest.devDependencies;
|
|
594
|
-
const installManifest = { ...runtimeOnlyManifest };
|
|
595
|
-
removeHostedPmCliDependency(installManifest);
|
|
596
|
-
await fs2.writeFile(packageJsonPath, `${JSON.stringify(installManifest, null, 2)}
|
|
597
|
-
`, "utf8");
|
|
598
|
-
try {
|
|
599
|
-
await Promise.all([
|
|
600
|
-
fs2.rm(path2.join(packageRoot, "package-lock.json"), { force: true }),
|
|
601
|
-
fs2.rm(path2.join(packageRoot, "npm-shrinkwrap.json"), { force: true })
|
|
602
|
-
]);
|
|
603
|
-
if (dependencySpecs.length > 0) {
|
|
604
|
-
await runNpmCommand([
|
|
605
|
-
"install",
|
|
606
|
-
"--ignore-scripts",
|
|
607
|
-
"--no-audit",
|
|
608
|
-
"--fund=false",
|
|
609
|
-
"--package-lock=false",
|
|
610
|
-
"--no-save",
|
|
611
|
-
"--omit=peer",
|
|
612
|
-
...dependencySpecs
|
|
613
|
-
], packageRoot);
|
|
614
|
-
}
|
|
615
|
-
if (shouldLinkHostedPmCli) {
|
|
616
|
-
await linkHostedPmCliDependency(packageRoot);
|
|
617
|
-
}
|
|
618
|
-
} finally {
|
|
619
|
-
await fs2.writeFile(packageJsonPath, `${JSON.stringify(runtimeOnlyManifest, null, 2)}
|
|
620
|
-
`, "utf8");
|
|
621
|
-
}
|
|
622
|
-
}
|
|
623
|
-
function hasHostedPmCliDependency(manifest) {
|
|
624
|
-
for (const dependencyMap of [manifest.dependencies, manifest.optionalDependencies, manifest.peerDependencies]) {
|
|
625
|
-
if (typeof dependencyMap === "object" && dependencyMap !== null && PM_CLI_PACKAGE_NAME in dependencyMap) {
|
|
626
|
-
return true;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
return false;
|
|
630
|
-
}
|
|
631
|
-
function removeHostedPmCliDependency(manifest) {
|
|
632
|
-
for (const field of ["dependencies", "optionalDependencies", "peerDependencies"]) {
|
|
633
|
-
const dependencyMap = manifest[field];
|
|
634
|
-
if (typeof dependencyMap !== "object" || dependencyMap === null) {
|
|
635
|
-
continue;
|
|
636
|
-
}
|
|
637
|
-
const nextMap = { ...dependencyMap };
|
|
638
|
-
delete nextMap[PM_CLI_PACKAGE_NAME];
|
|
639
|
-
if (Object.keys(nextMap).length === 0) {
|
|
640
|
-
delete manifest[field];
|
|
641
|
-
} else {
|
|
642
|
-
manifest[field] = nextMap;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
}
|
|
646
|
-
async function linkHostedPmCliDependency(packageRoot) {
|
|
647
|
-
const hostPackageRoot = resolvePmPackageRootFromModule(import.meta.url, ["../../../.."]);
|
|
648
|
-
const [scope, packageName] = PM_CLI_PACKAGE_NAME.split("/");
|
|
649
|
-
const scopedDirectory = path2.join(packageRoot, "node_modules", scope);
|
|
650
|
-
const linkPath = path2.join(scopedDirectory, packageName);
|
|
651
|
-
await fs2.mkdir(scopedDirectory, { recursive: true });
|
|
652
|
-
await fs2.rm(linkPath, { recursive: true, force: true });
|
|
653
|
-
await fs2.symlink(hostPackageRoot, linkPath, resolveDirectorySymlinkType(process.platform));
|
|
654
|
-
}
|
|
655
|
-
function resolveDirectorySymlinkType(platform) {
|
|
656
|
-
return platform === "win32" ? "junction" : "dir";
|
|
657
|
-
}
|
|
658
|
-
function runtimeDependencyInstallSpecs(manifest) {
|
|
659
|
-
const specs = /* @__PURE__ */ new Map();
|
|
660
|
-
for (const dependencyMap of [manifest.dependencies, manifest.optionalDependencies, manifest.peerDependencies]) {
|
|
661
|
-
if (typeof dependencyMap !== "object" || dependencyMap === null) {
|
|
662
|
-
continue;
|
|
663
|
-
}
|
|
664
|
-
for (const [name, version] of Object.entries(dependencyMap)) {
|
|
665
|
-
if (name === PM_CLI_PACKAGE_NAME || typeof version !== "string" || version.trim().length === 0 || specs.has(name)) {
|
|
666
|
-
continue;
|
|
667
|
-
}
|
|
668
|
-
specs.set(name, `${name}@${version.trim()}`);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
return [...specs.values()];
|
|
672
|
-
}
|
|
673
|
-
async function resolvePackageExtensionDirectory(packageRoot, sourceLabel) {
|
|
674
|
-
const discovered = await collectPackageExtensionDirectories(packageRoot);
|
|
675
|
-
if (discovered.length === 1) {
|
|
676
|
-
return discovered[0];
|
|
677
|
-
}
|
|
678
|
-
if (discovered.length > 1) {
|
|
679
|
-
const choices = discovered.map((entry) => path2.relative(packageRoot, entry).replaceAll(path2.sep, "/")).sort((left, right) => left.localeCompare(right));
|
|
680
|
-
throw new PmCliError(`Package source "${sourceLabel}" contains multiple extension manifests. Provide an explicit extension path. Candidates: ${choices.join(", ")}`, EXIT_CODE.USAGE);
|
|
681
|
-
}
|
|
682
|
-
throw new PmCliError(`Unable to locate a pm extension manifest in package source "${sourceLabel}". Package installs currently activate only extension resources, so add package.json pm.extensions or an extensions/ directory. Metadata-only resources like pm.docs/pm.examples are catalog metadata and do not activate commands.`, EXIT_CODE.USAGE);
|
|
683
|
-
}
|
|
684
|
-
async function resolveGithubSourceDirectory(cloneDirectory, source) {
|
|
685
|
-
const candidatePaths = [];
|
|
686
|
-
if (source.subpath) {
|
|
687
|
-
candidatePaths.push(source.subpath);
|
|
688
|
-
candidatePaths.push(path2.posix.join(".agents/pm/extensions", source.subpath));
|
|
689
|
-
candidatePaths.push(path2.posix.join(".custom/pm-extensions", source.subpath));
|
|
690
|
-
candidatePaths.push(path2.posix.join(".custom/pm-extension", source.subpath));
|
|
691
|
-
}
|
|
692
|
-
for (const candidate of candidatePaths) {
|
|
693
|
-
const absolute = path2.resolve(cloneDirectory, candidate);
|
|
694
|
-
if (!isPathWithinDirectory(cloneDirectory, absolute)) {
|
|
695
|
-
continue;
|
|
696
|
-
}
|
|
697
|
-
if (await pathExists(path2.join(absolute, "manifest.json"))) {
|
|
698
|
-
return { directory: absolute, resolved_subpath: candidate };
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
if (await pathExists(path2.join(cloneDirectory, "manifest.json"))) {
|
|
702
|
-
return { directory: cloneDirectory, resolved_subpath: "." };
|
|
703
|
-
}
|
|
704
|
-
const discoveredDirectory = await resolvePackageExtensionDirectory(cloneDirectory, source.input);
|
|
705
|
-
return {
|
|
706
|
-
directory: discoveredDirectory,
|
|
707
|
-
resolved_subpath: path2.relative(cloneDirectory, discoveredDirectory).replaceAll(path2.sep, "/")
|
|
708
|
-
};
|
|
709
|
-
}
|
|
710
|
-
async function resolveInstallSource(source) {
|
|
711
|
-
if (source.kind === "local") {
|
|
712
|
-
let localStats;
|
|
713
|
-
try {
|
|
714
|
-
localStats = await fs2.stat(source.absolute_path);
|
|
715
|
-
} catch {
|
|
716
|
-
throw new PmCliError(`Local extension source does not exist: "${source.absolute_path}".`, EXIT_CODE.NOT_FOUND);
|
|
717
|
-
}
|
|
718
|
-
if (!localStats.isDirectory()) {
|
|
719
|
-
throw new PmCliError(`Local extension source must be a directory: "${source.absolute_path}".`, EXIT_CODE.USAGE);
|
|
720
|
-
}
|
|
721
|
-
const directory = await resolvePackageExtensionDirectory(source.absolute_path, source.input);
|
|
722
|
-
return {
|
|
723
|
-
source,
|
|
724
|
-
directory
|
|
725
|
-
};
|
|
726
|
-
}
|
|
727
|
-
if (source.kind === "npm") {
|
|
728
|
-
const resolved = await resolveNpmSourceDirectory(source);
|
|
729
|
-
return {
|
|
730
|
-
source,
|
|
731
|
-
directory: resolved.directory,
|
|
732
|
-
cleanup: resolved.cleanup,
|
|
733
|
-
resolved_subpath: path2.relative(path2.dirname(resolved.directory), resolved.directory).replaceAll(path2.sep, "/"),
|
|
734
|
-
npm_package: resolved.package,
|
|
735
|
-
npm_version: resolved.version
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
const cloneDirectory = await fs2.mkdtemp(path2.join(os.tmpdir(), "pm-extension-source-"));
|
|
739
|
-
const cloneArgs = ["clone", "--depth", "1"];
|
|
740
|
-
if (source.ref) {
|
|
741
|
-
cloneArgs.push("--branch", source.ref);
|
|
742
|
-
}
|
|
743
|
-
cloneArgs.push(source.repository, cloneDirectory);
|
|
744
|
-
try {
|
|
745
|
-
await runGitCommand(cloneArgs);
|
|
746
|
-
const commit = await runGitCommand(["-C", cloneDirectory, "rev-parse", "HEAD"]);
|
|
747
|
-
const resolved = await resolveGithubSourceDirectory(cloneDirectory, source);
|
|
748
|
-
return {
|
|
749
|
-
source,
|
|
750
|
-
directory: resolved.directory,
|
|
751
|
-
resolved_subpath: resolved.resolved_subpath,
|
|
752
|
-
commit,
|
|
753
|
-
cleanup: async () => {
|
|
754
|
-
await fs2.rm(cloneDirectory, { recursive: true, force: true });
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
} catch (error) {
|
|
758
|
-
await fs2.rm(cloneDirectory, { recursive: true, force: true });
|
|
759
|
-
throw error;
|
|
760
|
-
}
|
|
761
|
-
}
|
|
762
|
-
async function areDirectoriesEquivalent(left, right) {
|
|
763
|
-
if (!await pathExists(left) || !await pathExists(right)) {
|
|
764
|
-
return false;
|
|
765
|
-
}
|
|
766
|
-
const [leftRealPath, rightRealPath] = await Promise.all([fs2.realpath(left), fs2.realpath(right)]);
|
|
767
|
-
return leftRealPath === rightRealPath;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
// dist/cli/commands/extension/bundled-catalog.js
|
|
771
|
-
import fs3 from "node:fs/promises";
|
|
772
|
-
import path3 from "node:path";
|
|
773
|
-
!(function() {
|
|
774
|
-
try {
|
|
775
|
-
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
776
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "ce7070ac-9aa5-56b7-b6dd-80ff19b24553");
|
|
777
|
-
} catch (e2) {
|
|
778
|
-
}
|
|
779
|
-
})();
|
|
780
|
-
var PM_PACKAGE_ROOT_ENV = "PM_CLI_PACKAGE_ROOT";
|
|
781
|
-
var LEGACY_BUNDLED_PACKAGE_ALIASES = {
|
|
782
|
-
beads: {
|
|
783
|
-
package_directory: "pm-beads",
|
|
784
|
-
legacy_extension_directory: "beads"
|
|
785
|
-
},
|
|
786
|
-
todos: {
|
|
787
|
-
package_directory: "pm-todos",
|
|
788
|
-
legacy_extension_directory: "todos"
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
var BUNDLED_PACKAGE_INSTALL_ALL_TARGETS = /* @__PURE__ */ new Set(["*", "all"]);
|
|
792
|
-
function resolvePackageRootCandidates() {
|
|
793
|
-
const candidates = [];
|
|
794
|
-
const envRoot = process.env[PM_PACKAGE_ROOT_ENV];
|
|
795
|
-
if (typeof envRoot === "string" && envRoot.trim().length > 0) {
|
|
796
|
-
candidates.push(path3.resolve(envRoot.trim()));
|
|
797
|
-
}
|
|
798
|
-
candidates.push(resolvePmPackageRootFromModule(import.meta.url, ["../../../.."]));
|
|
799
|
-
return [...new Set(candidates)];
|
|
800
|
-
}
|
|
801
|
-
async function resolveBundledExtensionAliasSource(input) {
|
|
802
|
-
const normalized = input.trim().toLowerCase();
|
|
803
|
-
const packageRoot = await resolveBundledPackageRoot(normalized);
|
|
804
|
-
if (packageRoot) {
|
|
805
|
-
return packageRoot;
|
|
806
|
-
}
|
|
807
|
-
const alias = LEGACY_BUNDLED_PACKAGE_ALIASES[normalized];
|
|
808
|
-
if (!alias) {
|
|
809
|
-
return null;
|
|
810
|
-
}
|
|
811
|
-
for (const packageRoot2 of resolvePackageRootCandidates()) {
|
|
812
|
-
const legacyExtensionPath = path3.join(packageRoot2, ".agents", "pm", "extensions", alias.legacy_extension_directory);
|
|
813
|
-
if (await pathExists(path3.join(legacyExtensionPath, "manifest.json"))) {
|
|
814
|
-
return legacyExtensionPath;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
return null;
|
|
818
|
-
}
|
|
819
|
-
function isBundledPackageInstallAllTarget(input) {
|
|
820
|
-
return BUNDLED_PACKAGE_INSTALL_ALL_TARGETS.has(input.trim().toLowerCase());
|
|
821
|
-
}
|
|
822
|
-
function derivePackageAlias(packageDirectory) {
|
|
823
|
-
return packageDirectory.replace(/^pm-/i, "").trim().toLowerCase();
|
|
824
|
-
}
|
|
825
|
-
async function collectBundledPackageEntries() {
|
|
826
|
-
const entriesByAlias = /* @__PURE__ */ new Map();
|
|
827
|
-
for (const packageRoot of resolvePackageRootCandidates()) {
|
|
828
|
-
const packagesRoot = path3.join(packageRoot, "packages");
|
|
829
|
-
if (!await pathExists(packagesRoot)) {
|
|
830
|
-
continue;
|
|
831
|
-
}
|
|
832
|
-
const entries = await fs3.readdir(packagesRoot, { withFileTypes: true });
|
|
833
|
-
for (const entry of entries) {
|
|
834
|
-
if (!entry.isDirectory() || !entry.name.startsWith("pm-")) {
|
|
835
|
-
continue;
|
|
836
|
-
}
|
|
837
|
-
const candidateRoot = path3.join(packagesRoot, entry.name);
|
|
838
|
-
if (!await pathExists(path3.join(candidateRoot, "package.json"))) {
|
|
839
|
-
continue;
|
|
840
|
-
}
|
|
841
|
-
const manifest = await readPmPackageManifest(candidateRoot);
|
|
842
|
-
const aliases = manifest.aliases && manifest.aliases.length > 0 ? manifest.aliases : [derivePackageAlias(entry.name)];
|
|
843
|
-
for (const alias of aliases) {
|
|
844
|
-
const normalizedAlias = alias.trim().toLowerCase();
|
|
845
|
-
if (normalizedAlias.length === 0 || entriesByAlias.has(normalizedAlias)) {
|
|
846
|
-
continue;
|
|
847
|
-
}
|
|
848
|
-
entriesByAlias.set(normalizedAlias, {
|
|
849
|
-
alias: normalizedAlias,
|
|
850
|
-
package_directory: entry.name,
|
|
851
|
-
package_root: candidateRoot
|
|
852
|
-
});
|
|
853
|
-
}
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
for (const [alias, legacy] of Object.entries(LEGACY_BUNDLED_PACKAGE_ALIASES)) {
|
|
857
|
-
if (entriesByAlias.has(alias)) {
|
|
858
|
-
continue;
|
|
859
|
-
}
|
|
860
|
-
for (const packageRoot of resolvePackageRootCandidates()) {
|
|
861
|
-
const packagePath = path3.join(packageRoot, "packages", legacy.package_directory);
|
|
862
|
-
if (await pathExists(path3.join(packagePath, "package.json"))) {
|
|
863
|
-
entriesByAlias.set(alias, {
|
|
864
|
-
alias,
|
|
865
|
-
package_directory: legacy.package_directory,
|
|
866
|
-
package_root: packagePath
|
|
867
|
-
});
|
|
868
|
-
break;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
return [...entriesByAlias.values()].sort((left, right) => left.alias.localeCompare(right.alias));
|
|
873
|
-
}
|
|
874
|
-
async function listBundledPackageAliases() {
|
|
875
|
-
return (await collectBundledPackageEntries()).map((entry) => entry.alias);
|
|
876
|
-
}
|
|
877
|
-
async function resolveBundledPackageRoot(alias) {
|
|
878
|
-
const normalized = alias.trim().toLowerCase();
|
|
879
|
-
const entry = (await collectBundledPackageEntries()).find((candidate) => candidate.alias === normalized);
|
|
880
|
-
return entry?.package_root ?? null;
|
|
881
|
-
}
|
|
882
|
-
async function resolveBundledPackageNpmName(alias) {
|
|
883
|
-
const packageRoot = await resolveBundledPackageRoot(alias);
|
|
884
|
-
if (!packageRoot) {
|
|
885
|
-
return null;
|
|
886
|
-
}
|
|
887
|
-
const manifest = await readPmPackageManifest(packageRoot);
|
|
888
|
-
return manifest.package_name ?? null;
|
|
889
|
-
}
|
|
890
|
-
async function resolveBundledAliasManifestName(input) {
|
|
891
|
-
const bundledAliasSource = await resolveBundledExtensionAliasSource(input);
|
|
892
|
-
if (!bundledAliasSource) {
|
|
893
|
-
return null;
|
|
894
|
-
}
|
|
895
|
-
try {
|
|
896
|
-
const extensionDirectories = await collectPackageExtensionDirectories(bundledAliasSource);
|
|
897
|
-
if (extensionDirectories.length !== 1) {
|
|
898
|
-
return null;
|
|
899
|
-
}
|
|
900
|
-
const validated = await validateExtensionDirectory(extensionDirectories[0]);
|
|
901
|
-
return validated.manifest.name;
|
|
902
|
-
} catch {
|
|
903
|
-
return null;
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
function buildBundledCatalogLinks(manifest) {
|
|
907
|
-
return {
|
|
908
|
-
docs: manifest.catalog?.links?.docs ?? manifest.package_homepage,
|
|
909
|
-
npm: manifest.catalog?.links?.npm ?? (manifest.package_name && manifest.package_private !== true ? `https://www.npmjs.com/package/${encodeURIComponent(manifest.package_name)}` : void 0),
|
|
910
|
-
repository: manifest.catalog?.links?.repository ?? manifest.package_repository_url,
|
|
911
|
-
report: manifest.catalog?.links?.report ?? manifest.package_bugs_url
|
|
912
|
-
};
|
|
913
|
-
}
|
|
914
|
-
function buildBundledCatalogPackageEntry(manifest, bundledEntry, scope, installedBuiltinAliases, installedLocations) {
|
|
915
|
-
const installScopeFlag = scope === "global" ? "--global" : "--project";
|
|
916
|
-
const metadataOnlyResources = Object.fromEntries(PM_PACKAGE_RESOURCE_KINDS.filter((resourceKind) => resourceKind !== "extensions").map((resourceKind) => [resourceKind, manifest.resources[resourceKind] ?? []]).filter(([, entries]) => Array.isArray(entries) && entries.length > 0));
|
|
917
|
-
return {
|
|
918
|
-
alias: bundledEntry.alias,
|
|
919
|
-
bundled: true,
|
|
920
|
-
available: true,
|
|
921
|
-
installed: installedBuiltinAliases.has(bundledEntry.alias) || installedLocations.has(path3.resolve(bundledEntry.package_root)),
|
|
922
|
-
install_target: bundledEntry.alias,
|
|
923
|
-
install_command: `pm install ${bundledEntry.alias} ${installScopeFlag}`,
|
|
924
|
-
package_name: manifest.package_name,
|
|
925
|
-
package_version: manifest.package_version,
|
|
926
|
-
description: manifest.catalog?.summary ?? manifest.package_description,
|
|
927
|
-
keywords: manifest.package_keywords ?? [],
|
|
928
|
-
resources: manifest.resources,
|
|
929
|
-
installable_resources: {
|
|
930
|
-
extensions: manifest.resources.extensions ?? []
|
|
931
|
-
},
|
|
932
|
-
metadata_only_resources: metadataOnlyResources,
|
|
933
|
-
catalog: {
|
|
934
|
-
display_name: manifest.catalog?.display_name,
|
|
935
|
-
category: manifest.catalog?.category,
|
|
936
|
-
tags: manifest.catalog?.tags ?? manifest.package_keywords ?? [],
|
|
937
|
-
links: buildBundledCatalogLinks(manifest),
|
|
938
|
-
media: manifest.catalog?.media
|
|
939
|
-
}
|
|
940
|
-
};
|
|
941
|
-
}
|
|
942
|
-
async function buildBundledPackageCatalog(scope, global2, options = {}) {
|
|
943
|
-
const roots = resolveExtensionRoots(resolvePmRoot(process.cwd(), global2.path), process.cwd());
|
|
944
|
-
const selectedRoot = scope === "global" ? roots.global : roots.project;
|
|
945
|
-
const managedStateRead = await readManagedExtensionState(selectedRoot);
|
|
946
|
-
const installedLocations = new Set(managedStateRead.state.entries.filter((entry) => entry.scope === scope).filter((entry) => entry.source.kind !== "builtin").map((entry) => path3.resolve(entry.source.location)));
|
|
947
|
-
const installedBuiltinAliases = new Set(managedStateRead.state.entries.filter((entry) => entry.scope === scope && entry.source.kind === "builtin").flatMap((entry) => [entry.source.name, entry.source.input, entry.source.location]).filter((value) => typeof value === "string" && value.trim().length > 0).map((value) => value.trim().toLowerCase()));
|
|
948
|
-
const packages = [];
|
|
949
|
-
for (const bundledEntry of await collectBundledPackageEntries()) {
|
|
950
|
-
const manifest = await readPmPackageManifest(bundledEntry.package_root);
|
|
951
|
-
packages.push(buildBundledCatalogPackageEntry(manifest, bundledEntry, scope, installedBuiltinAliases, installedLocations));
|
|
952
|
-
}
|
|
953
|
-
const fields = parsePackageCatalogFields(options.fields);
|
|
954
|
-
const outputPackages = fields ? packages.map((entry) => projectPackageCatalogEntry(entry, fields)) : packages;
|
|
955
|
-
return {
|
|
956
|
-
total: outputPackages.length,
|
|
957
|
-
scope,
|
|
958
|
-
installable_resource_kinds: ["extensions"],
|
|
959
|
-
metadata_only_resource_kinds: PM_PACKAGE_RESOURCE_KINDS.filter((resourceKind) => resourceKind !== "extensions"),
|
|
960
|
-
packages: outputPackages
|
|
961
|
-
};
|
|
962
|
-
}
|
|
963
|
-
var PACKAGE_CATALOG_FIELD_KEYS = /* @__PURE__ */ new Set([
|
|
964
|
-
"alias",
|
|
965
|
-
"bundled",
|
|
966
|
-
"available",
|
|
967
|
-
"installed",
|
|
968
|
-
"install_target",
|
|
969
|
-
"install_command",
|
|
970
|
-
"package_name",
|
|
971
|
-
"package_version",
|
|
972
|
-
"description",
|
|
973
|
-
"keywords",
|
|
974
|
-
"resources",
|
|
975
|
-
"installable_resources",
|
|
976
|
-
"metadata_only_resources",
|
|
977
|
-
"catalog",
|
|
978
|
-
"category",
|
|
979
|
-
"display_name"
|
|
980
|
-
]);
|
|
981
|
-
function parsePackageCatalogFields(raw) {
|
|
982
|
-
if (raw === void 0) {
|
|
983
|
-
return void 0;
|
|
984
|
-
}
|
|
985
|
-
const fields = splitCommaList(raw);
|
|
986
|
-
if (fields.length === 0) {
|
|
987
|
-
throw new PmCliError("Package catalog --fields requires a comma-separated list of field names", EXIT_CODE.USAGE);
|
|
988
|
-
}
|
|
989
|
-
const unknown = fields.filter((field) => !PACKAGE_CATALOG_FIELD_KEYS.has(field));
|
|
990
|
-
if (unknown.length > 0) {
|
|
991
|
-
throw new PmCliError(`Unknown package catalog --fields value(s): ${unknown.join(", ")}`, EXIT_CODE.USAGE, {
|
|
992
|
-
examples: [
|
|
993
|
-
"pm package list --project --fields alias,installed,install_command",
|
|
994
|
-
"pm package catalog --project --fields alias,package_name,category"
|
|
995
|
-
]
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
return fields;
|
|
999
|
-
}
|
|
1000
|
-
function projectPackageCatalogEntry(entry, fields) {
|
|
1001
|
-
const projected = {};
|
|
1002
|
-
for (const field of fields) {
|
|
1003
|
-
if (field === "category") {
|
|
1004
|
-
projected[field] = entry.catalog?.category ?? null;
|
|
1005
|
-
} else if (field === "display_name") {
|
|
1006
|
-
projected[field] = entry.catalog?.display_name ?? null;
|
|
1007
|
-
} else {
|
|
1008
|
-
projected[field] = entry[field] ?? null;
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
return projected;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
// dist/cli/commands/extension/doctor.js
|
|
1015
|
-
!(function() {
|
|
1016
|
-
try {
|
|
1017
|
-
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
1018
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "ae517a2b-6ef0-52a1-8b5c-bf4e18e874ea");
|
|
1019
|
-
} catch (e2) {
|
|
1020
|
-
}
|
|
1021
|
-
})();
|
|
1022
|
-
function addRuntimePath(pathsByExtension, extensionName, pathValue) {
|
|
1023
|
-
const normalizedName = normalizeExtensionNameForMatch(extensionName);
|
|
1024
|
-
const normalizedPath = pathValue.trim();
|
|
1025
|
-
if (normalizedName.length === 0 || normalizedPath.length === 0) {
|
|
1026
|
-
return;
|
|
1027
|
-
}
|
|
1028
|
-
const existing = pathsByExtension.get(normalizedName) ?? /* @__PURE__ */ new Set();
|
|
1029
|
-
existing.add(normalizedPath);
|
|
1030
|
-
pathsByExtension.set(normalizedName, existing);
|
|
1031
|
-
}
|
|
1032
|
-
function collectRuntimeActivationPaths(activationResult) {
|
|
1033
|
-
const commandPathsByExtension = /* @__PURE__ */ new Map();
|
|
1034
|
-
const actionPathsByExtension = /* @__PURE__ */ new Map();
|
|
1035
|
-
for (const registration of activationResult.registrations.commands) {
|
|
1036
|
-
addRuntimePath(commandPathsByExtension, registration.name, registration.command);
|
|
1037
|
-
addRuntimePath(actionPathsByExtension, registration.name, registration.action);
|
|
1038
|
-
}
|
|
1039
|
-
for (const handler of activationResult.commands.handlers) {
|
|
1040
|
-
addRuntimePath(commandPathsByExtension, handler.name, handler.command);
|
|
1041
|
-
}
|
|
1042
|
-
for (const override of activationResult.commands.overrides) {
|
|
1043
|
-
addRuntimePath(commandPathsByExtension, override.name, override.command);
|
|
1044
|
-
}
|
|
1045
|
-
return { commandPathsByExtension, actionPathsByExtension };
|
|
1046
|
-
}
|
|
1047
|
-
function sortedRuntimePaths(values) {
|
|
1048
|
-
if (!values || values.size === 0) {
|
|
1049
|
-
return void 0;
|
|
1050
|
-
}
|
|
1051
|
-
return [...values].sort((left, right) => left.localeCompare(right));
|
|
1052
|
-
}
|
|
1053
|
-
function resolveDoctorActivationStatus(params) {
|
|
1054
|
-
const { enabled, normalizedName, loadedNames, loadFailedNames, activationFailedNames } = params;
|
|
1055
|
-
if (!enabled) {
|
|
1056
|
-
return { runtime_active: false, activation_status: "not_loaded" };
|
|
1057
|
-
}
|
|
1058
|
-
if (loadFailedNames.has(normalizedName) || activationFailedNames.has(normalizedName)) {
|
|
1059
|
-
return { runtime_active: false, activation_status: "failed" };
|
|
1060
|
-
}
|
|
1061
|
-
if (loadedNames.has(normalizedName)) {
|
|
1062
|
-
return { runtime_active: true, activation_status: "ok" };
|
|
1063
|
-
}
|
|
1064
|
-
return { runtime_active: false, activation_status: "not_loaded" };
|
|
1065
|
-
}
|
|
1066
|
-
function applyDoctorRuntimeActivationState(extensions, loadResult, activationResult) {
|
|
1067
|
-
const loadedNames = new Set(loadResult.loaded.map((entry) => normalizeExtensionNameForMatch(entry.name)));
|
|
1068
|
-
const loadFailedNames = new Set(loadResult.failed.map((entry) => normalizeExtensionNameForMatch(entry.name)));
|
|
1069
|
-
const activationFailedNames = new Set(activationResult.failed.map((entry) => normalizeExtensionNameForMatch(entry.name)));
|
|
1070
|
-
const { commandPathsByExtension, actionPathsByExtension } = collectRuntimeActivationPaths(activationResult);
|
|
1071
|
-
return extensions.map((entry) => {
|
|
1072
|
-
const normalizedName = normalizeExtensionNameForMatch(entry.name);
|
|
1073
|
-
const commandPaths = sortedRuntimePaths(commandPathsByExtension.get(normalizedName));
|
|
1074
|
-
const actionPaths = sortedRuntimePaths(actionPathsByExtension.get(normalizedName));
|
|
1075
|
-
const runtimeMetadata = {
|
|
1076
|
-
...commandPaths ? { command_paths: commandPaths } : {},
|
|
1077
|
-
...actionPaths ? { action_paths: actionPaths } : {}
|
|
1078
|
-
};
|
|
1079
|
-
const activationStatus = resolveDoctorActivationStatus({
|
|
1080
|
-
enabled: entry.enabled,
|
|
1081
|
-
normalizedName,
|
|
1082
|
-
loadedNames,
|
|
1083
|
-
loadFailedNames,
|
|
1084
|
-
activationFailedNames
|
|
1085
|
-
});
|
|
1086
|
-
return {
|
|
1087
|
-
...entry,
|
|
1088
|
-
...activationStatus,
|
|
1089
|
-
...runtimeMetadata
|
|
1090
|
-
};
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
function summarizePolicyWarnings(warnings) {
|
|
1094
|
-
let warningCount = 0;
|
|
1095
|
-
let violationCount = 0;
|
|
1096
|
-
let blockedCount = 0;
|
|
1097
|
-
for (const warning of warnings) {
|
|
1098
|
-
if (!warning.startsWith("extension_policy_")) {
|
|
1099
|
-
continue;
|
|
1100
|
-
}
|
|
1101
|
-
warningCount += 1;
|
|
1102
|
-
if (warning.startsWith("extension_policy_violation_")) {
|
|
1103
|
-
violationCount += 1;
|
|
1104
|
-
continue;
|
|
1105
|
-
}
|
|
1106
|
-
if (warning.startsWith("extension_policy_blocked_")) {
|
|
1107
|
-
blockedCount += 1;
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
|
-
return {
|
|
1111
|
-
warning_count: warningCount,
|
|
1112
|
-
violation_count: violationCount,
|
|
1113
|
-
blocked_count: blockedCount
|
|
1114
|
-
};
|
|
1115
|
-
}
|
|
1116
|
-
function lifecycleFlagCommand(options, action) {
|
|
1117
|
-
return options.vocabulary === "package" ? `pm package --${action}` : `pm extension --${action}`;
|
|
1118
|
-
}
|
|
1119
|
-
var REGISTRATION_COLLISION_WARNING_CODES = /* @__PURE__ */ new Set([
|
|
1120
|
-
"extension_command_handler_collision",
|
|
1121
|
-
"extension_command_override_collision",
|
|
1122
|
-
"extension_command_override_handler_overlap",
|
|
1123
|
-
"extension_parser_override_collision",
|
|
1124
|
-
"extension_preflight_override_collision",
|
|
1125
|
-
"extension_renderer_collision",
|
|
1126
|
-
"extension_service_override_collision"
|
|
1127
|
-
]);
|
|
1128
|
-
function isRegistrationCollisionWarning(warning) {
|
|
1129
|
-
return REGISTRATION_COLLISION_WARNING_CODES.has(warningCode(warning));
|
|
1130
|
-
}
|
|
1131
|
-
function isExtensionLayer(value) {
|
|
1132
|
-
return value === "project" || value === "global";
|
|
1133
|
-
}
|
|
1134
|
-
function parseRegistrationCollisionWarning(warning) {
|
|
1135
|
-
const parts = warning.split(":");
|
|
1136
|
-
const code = parts[0];
|
|
1137
|
-
if (!code || !REGISTRATION_COLLISION_WARNING_CODES.has(code)) {
|
|
1138
|
-
return null;
|
|
1139
|
-
}
|
|
1140
|
-
const winnerLayer = parts.at(-4);
|
|
1141
|
-
const winnerName = parts.at(-3)?.trim();
|
|
1142
|
-
const displacedLayer = parts.at(-2);
|
|
1143
|
-
const displacedName = parts.at(-1)?.trim();
|
|
1144
|
-
if (!isExtensionLayer(winnerLayer) || !isExtensionLayer(displacedLayer) || !winnerName || !displacedName) {
|
|
1145
|
-
return null;
|
|
1146
|
-
}
|
|
1147
|
-
return {
|
|
1148
|
-
code,
|
|
1149
|
-
surface: parts.slice(1, -4).join(":") || "global",
|
|
1150
|
-
winner: { layer: winnerLayer, name: winnerName },
|
|
1151
|
-
displaced: { layer: displacedLayer, name: displacedName }
|
|
1152
|
-
};
|
|
1153
|
-
}
|
|
1154
|
-
function collectRegistrationCollisionExtensionNames(warnings) {
|
|
1155
|
-
const names = /* @__PURE__ */ new Set();
|
|
1156
|
-
for (const warning of warnings) {
|
|
1157
|
-
const parsed = parseRegistrationCollisionWarning(warning);
|
|
1158
|
-
if (!parsed) {
|
|
1159
|
-
continue;
|
|
1160
|
-
}
|
|
1161
|
-
names.add(parsed.winner.name);
|
|
1162
|
-
names.add(parsed.displaced.name);
|
|
1163
|
-
}
|
|
1164
|
-
return [...names].sort((left, right) => left.localeCompare(right));
|
|
1165
|
-
}
|
|
1166
|
-
function buildRegistrationCollisionRemediation(warnings, commands) {
|
|
1167
|
-
const registrationCollisionWarnings = warnings.filter(isRegistrationCollisionWarning);
|
|
1168
|
-
if (registrationCollisionWarnings.length === 0) {
|
|
1169
|
-
return null;
|
|
1170
|
-
}
|
|
1171
|
-
const collisionNames = collectRegistrationCollisionExtensionNames(registrationCollisionWarnings);
|
|
1172
|
-
const collisionNameText = collisionNames.length > 0 ? ` Conflicting extensions: ${collisionNames.join(", ")}.` : "";
|
|
1173
|
-
return `Extension registration collisions or handler/override overlaps detected.${collisionNameText} Single-winner surfaces can hide earlier package behavior. Deactivate one conflicting package with ${commands.deactivate}, or scope registration surfaces in extensions.policy.extension_overrides, then rerun ${commands.doctor}.`;
|
|
1174
|
-
}
|
|
1175
|
-
function buildRegistrationCollisionPlan(scope, warnings, extensions, options) {
|
|
1176
|
-
const collisions = warnings.map((warning) => parseRegistrationCollisionWarning(warning)).filter((entry) => entry !== null).sort((left, right) => `${left.code}:${left.surface}:${left.winner.name}:${left.displaced.name}`.localeCompare(`${right.code}:${right.surface}:${right.winner.name}:${right.displaced.name}`));
|
|
1177
|
-
if (collisions.length === 0) {
|
|
1178
|
-
return void 0;
|
|
1179
|
-
}
|
|
1180
|
-
const scopeFlag = scope === "global" ? "--global" : "--project";
|
|
1181
|
-
const deactivatePrefix = lifecycleFlagCommand(options, "deactivate");
|
|
1182
|
-
const doctorCommand = `${lifecycleFlagCommand(options, "doctor")} ${scopeFlag} --detail deep --trace`;
|
|
1183
|
-
const extensionByName = new Map(extensions.map((entry) => [normalizeExtensionNameForMatch(entry.name), entry]));
|
|
1184
|
-
const affectedByName = /* @__PURE__ */ new Map();
|
|
1185
|
-
for (const collision of collisions) {
|
|
1186
|
-
for (const name of [collision.winner.name, collision.displaced.name]) {
|
|
1187
|
-
const normalizedName = normalizeExtensionNameForMatch(name);
|
|
1188
|
-
affectedByName.set(normalizedName, (affectedByName.get(normalizedName) ?? 0) + 1);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
const remediationCandidates = [...affectedByName.entries()].map(([normalizedName, affectedCollisions]) => {
|
|
1192
|
-
const extension = extensionByName.get(normalizedName);
|
|
1193
|
-
const extensionName = extension?.name ?? normalizedName;
|
|
1194
|
-
const commandPaths = extension?.command_paths ?? [];
|
|
1195
|
-
const actionPaths = extension?.action_paths ?? [];
|
|
1196
|
-
return {
|
|
1197
|
-
action: "deactivate",
|
|
1198
|
-
extension: extensionName,
|
|
1199
|
-
command: `${deactivatePrefix} ${extensionName} ${scopeFlag}`,
|
|
1200
|
-
affected_collisions: affectedCollisions,
|
|
1201
|
-
feature_loss: {
|
|
1202
|
-
command_paths: [...commandPaths].sort((left, right) => left.localeCompare(right)),
|
|
1203
|
-
action_paths: [...actionPaths].sort((left, right) => left.localeCompare(right))
|
|
1204
|
-
}
|
|
1205
|
-
};
|
|
1206
|
-
}).sort((left, right) => {
|
|
1207
|
-
const affectedDelta = right.affected_collisions - left.affected_collisions;
|
|
1208
|
-
if (affectedDelta !== 0) {
|
|
1209
|
-
return affectedDelta;
|
|
1210
|
-
}
|
|
1211
|
-
const leftSurfaceCount = left.feature_loss.command_paths.length + left.feature_loss.action_paths.length;
|
|
1212
|
-
const rightSurfaceCount = right.feature_loss.command_paths.length + right.feature_loss.action_paths.length;
|
|
1213
|
-
if (leftSurfaceCount !== rightSurfaceCount) {
|
|
1214
|
-
return leftSurfaceCount - rightSurfaceCount;
|
|
1215
|
-
}
|
|
1216
|
-
return left.extension.localeCompare(right.extension);
|
|
1217
|
-
});
|
|
1218
|
-
return {
|
|
1219
|
-
status: "conflicts_detected",
|
|
1220
|
-
collision_count: collisions.length,
|
|
1221
|
-
extension_count: affectedByName.size,
|
|
1222
|
-
next_best_command: doctorCommand,
|
|
1223
|
-
collisions,
|
|
1224
|
-
remediation_candidates: remediationCandidates
|
|
1225
|
-
};
|
|
1226
|
-
}
|
|
1227
|
-
function classifyDoctorLoadFailureWarnings(loadFailures) {
|
|
1228
|
-
const warnings = [];
|
|
1229
|
-
for (const failure of loadFailures) {
|
|
1230
|
-
const normalizedError = failure.error.toLowerCase();
|
|
1231
|
-
if (normalizedError.includes("cannot find package '@unbrained/pm-cli'") || normalizedError.includes('cannot find module "@unbrained/pm-cli"') || normalizedError.includes("cannot find module '@unbrained/pm-cli'")) {
|
|
1232
|
-
warnings.push(`extension_load_failed_sdk_dependency_missing:${failure.name}`);
|
|
1233
|
-
}
|
|
1234
|
-
if (normalizedError.includes("cannot use import statement outside a module") || normalizedError.includes("to load an es module") || normalizedError.includes("must use import to load es module")) {
|
|
1235
|
-
warnings.push(`extension_load_failed_module_mode_mismatch:${failure.name}`);
|
|
1236
|
-
}
|
|
1237
|
-
}
|
|
1238
|
-
return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
|
|
1239
|
-
}
|
|
1240
|
-
function classifyDoctorActivationFailureWarnings(activationFailures = []) {
|
|
1241
|
-
const failures = Array.isArray(activationFailures) ? activationFailures : [];
|
|
1242
|
-
const warnings = [];
|
|
1243
|
-
for (const failure of failures) {
|
|
1244
|
-
if (!failure || typeof failure.name !== "string") {
|
|
1245
|
-
continue;
|
|
1246
|
-
}
|
|
1247
|
-
const missingCapability = failure.trace?.missing_capability ?? failure.trace?.capability;
|
|
1248
|
-
if (typeof missingCapability === "string" && missingCapability.trim().length > 0) {
|
|
1249
|
-
warnings.push(`extension_capability_missing:${failure.name}:${missingCapability.trim().toLowerCase()}`);
|
|
1250
|
-
}
|
|
1251
|
-
}
|
|
1252
|
-
return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
|
|
1253
|
-
}
|
|
1254
|
-
function classifyUnusedCapabilityWarnings(loadResult, activationResult) {
|
|
1255
|
-
const warnings = [];
|
|
1256
|
-
for (const entry of reconcileExtensionCapabilityUsage(loadResult.loaded, activationResult)) {
|
|
1257
|
-
for (const capability of entry.unused) {
|
|
1258
|
-
warnings.push(`extension_capability_unused:${entry.layer}:${entry.name}:${capability}`);
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
|
|
1262
|
-
}
|
|
1263
|
-
var TRIAGE_REMEDIATION_RULES = [
|
|
1264
|
-
{
|
|
1265
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_manifest_")),
|
|
1266
|
-
build: (ctx) => `Run ${lifecycleFlagCommand(ctx.options, "explore")} ${ctx.scopeFlag} to inspect discovered manifests and directories.`
|
|
1267
|
-
},
|
|
1268
|
-
{
|
|
1269
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_capability_unknown:")),
|
|
1270
|
-
build: () => `Unknown extension capabilities detected. Allowed capabilities: ${KNOWN_EXTENSION_CAPABILITIES.join(", ")}. Review extension_capability_unknown warning details for suggested replacements.`
|
|
1271
|
-
},
|
|
1272
|
-
{
|
|
1273
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_capability_legacy_alias:")),
|
|
1274
|
-
build: () => "Legacy extension capability aliases were auto-remapped to canonical capabilities. Update manifests to canonical names (migration/validation -> schema)."
|
|
1275
|
-
},
|
|
1276
|
-
{
|
|
1277
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_capability_missing:")),
|
|
1278
|
-
build: (ctx) => `Extension activation failed because code registered a surface missing from manifest capabilities. Run ${lifecycleFlagCommand(ctx.options, "doctor")} ${ctx.scopeFlag} --detail deep --trace and add the reported missing_capability to manifest.json before publishing.`
|
|
1279
|
-
},
|
|
1280
|
-
{
|
|
1281
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_capability_unused:")),
|
|
1282
|
-
build: (ctx) => `Extension manifests declare capabilities that are never registered against. Remove each reported unused capability from manifest.json to keep least privilege, or add the matching registration. Run ${lifecycleFlagCommand(ctx.options, "doctor")} ${ctx.scopeFlag} --detail deep --trace for per-extension registration counts.`
|
|
1283
|
-
},
|
|
1284
|
-
{
|
|
1285
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_command_definition_legacy_handler_alias:")),
|
|
1286
|
-
build: () => "Extension command definitions using legacy handler were auto-remapped. Update command definitions to use run: (context) => ... for forward compatibility."
|
|
1287
|
-
},
|
|
1288
|
-
{
|
|
1289
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_output_service_override_global:") || warning.startsWith("extension_output_renderer_override_global:")),
|
|
1290
|
-
build: () => "Global output service/renderer overrides are active. For output_format, return context.payload/null/undefined unless the extension owns the command. For renderers, return null for unrelated payloads so pm falls back to native rendering."
|
|
1291
|
-
},
|
|
1292
|
-
{
|
|
1293
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_schema_narrow_activation:")),
|
|
1294
|
-
build: () => "A package registers custom item types/fields (a GLOBAL schema contribution) but also declares narrow activation.commands, so it never activates for built-in commands like pm create <type> and the custom type silently fails to register. Remove activation.commands from manifest.json so pm activates the package for every command, or \u2014 if the schema is intentionally command-scoped \u2014 knowingly ignore this advisory."
|
|
1295
|
-
},
|
|
1296
|
-
{
|
|
1297
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_load_failed_sdk_dependency_missing:")),
|
|
1298
|
-
build: (ctx) => `Detected extension load failures caused by missing SDK dependency resolution. Ensure extension package dependencies include "@unbrained/pm-cli" and reinstall dependencies before running ${lifecycleFlagCommand(ctx.options, "doctor")} ${ctx.scopeFlag}.`
|
|
1299
|
-
},
|
|
1300
|
-
{
|
|
1301
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_load_failed_module_mode_mismatch:")),
|
|
1302
|
-
build: (ctx) => `Detected extension module-mode mismatches. For ESM-based extension entries/imports, set package.json "type": "module" or use an explicit .mjs entry and rerun ${lifecycleFlagCommand(ctx.options, "doctor")} ${ctx.scopeFlag}.`
|
|
1303
|
-
},
|
|
1304
|
-
{
|
|
1305
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_pm_min_version_") || warning.startsWith("extension_pm_max_version_")),
|
|
1306
|
-
build: (ctx) => `Extension pm version-bound warnings detected. Align each package manifest's pm_min_version/pm_max_version with the installed pm CLI version (see the warning's required/allowed=...:current=... details), or upgrade/downgrade the pm CLI to satisfy the declared bounds, then rerun ${lifecycleFlagCommand(ctx.options, "doctor")} ${ctx.scopeFlag}.`
|
|
1307
|
-
},
|
|
1308
|
-
{
|
|
1309
|
-
matches: (_warnings, ctx) => ctx.updateCheckFailedTotal > 0,
|
|
1310
|
-
build: (ctx) => `Run ${lifecycleFlagCommand(ctx.options, "manage")} ${ctx.scopeFlag} after validating network and repository access.`
|
|
1311
|
-
},
|
|
1312
|
-
{
|
|
1313
|
-
matches: (warnings) => warnings.some((warning) => warning.startsWith("extension_manager_state_")),
|
|
1314
|
-
build: (ctx) => `Review and repair ${ctx.scope} managed extension state file if schema/read warnings persist.`
|
|
1315
|
-
},
|
|
1316
|
-
{
|
|
1317
|
-
matches: (_warnings, ctx) => ctx.policyWarningCount > 0,
|
|
1318
|
-
build: () => "Extension governance policy warnings detected. Review settings.extensions.policy mode and allow/block lists to confirm intended capabilities and registration surfaces."
|
|
1319
|
-
}
|
|
1320
|
-
];
|
|
1321
|
-
function buildExtensionTriageRemediation(params) {
|
|
1322
|
-
const { normalizedWarnings, options, scope, scopeFlag, updateCheckFailedTotal, policyWarningCount, updateHealthPartial, skippedUnmanagedTotal, skippedNonGithubTotal, updateAvailableTotal } = params;
|
|
1323
|
-
const remediation = [];
|
|
1324
|
-
const ctx = { options, scope, scopeFlag, updateCheckFailedTotal, policyWarningCount };
|
|
1325
|
-
if (normalizedWarnings.length > 0) {
|
|
1326
|
-
const registrationCollisionRemediation = buildRegistrationCollisionRemediation(normalizedWarnings, {
|
|
1327
|
-
deactivate: `${lifecycleFlagCommand(options, "deactivate")} <name> ${scopeFlag}`,
|
|
1328
|
-
doctor: `${lifecycleFlagCommand(options, "doctor")} ${scopeFlag} --detail deep --trace`
|
|
1329
|
-
});
|
|
1330
|
-
if (registrationCollisionRemediation) {
|
|
1331
|
-
remediation.push(registrationCollisionRemediation);
|
|
1332
|
-
}
|
|
1333
|
-
for (const rule of TRIAGE_REMEDIATION_RULES) {
|
|
1334
|
-
if (rule.matches(normalizedWarnings, ctx)) {
|
|
1335
|
-
remediation.push(rule.build(ctx));
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
}
|
|
1339
|
-
if (updateHealthPartial) {
|
|
1340
|
-
remediation.push(`Update-check coverage is partial because unmanaged extensions need adoption. Adopt existing installs via ${lifecycleFlagCommand(options, "manage")} ${scopeFlag} --fix-managed-state (or ${lifecycleFlagCommand(options, "adopt-all")} ${scopeFlag}, ${lifecycleFlagCommand(options, "adopt")} <name> ${scopeFlag}, or reinstall via ${lifecycleFlagCommand(options, "install")} ${scopeFlag} <source>).`);
|
|
1341
|
-
} else if (skippedUnmanagedTotal > 0) {
|
|
1342
|
-
remediation.push(`Loaded unmanaged extensions are currently treated as informational. Use ${lifecycleFlagCommand(options, "manage")} ${scopeFlag} --fix-managed-state to adopt them for update checks.`);
|
|
1343
|
-
}
|
|
1344
|
-
if (skippedNonGithubTotal > 0) {
|
|
1345
|
-
remediation.push(`Non-GitHub managed extensions are skipped by update checks. Use doctor output for non-update diagnostics.`);
|
|
1346
|
-
}
|
|
1347
|
-
if (updateAvailableTotal > 0) {
|
|
1348
|
-
remediation.push(`Update available managed extensions via ${lifecycleFlagCommand(options, "install")} ${scopeFlag} <source>.`);
|
|
1349
|
-
}
|
|
1350
|
-
if (remediation.length === 0) {
|
|
1351
|
-
remediation.push(`No immediate action required. Re-run ${lifecycleFlagCommand(options, "manage")} ${scopeFlag} after extension changes.`);
|
|
1352
|
-
}
|
|
1353
|
-
return remediation;
|
|
1354
|
-
}
|
|
1355
|
-
function buildExtensionTriageSummary(scope, warnings, extensions, options = {}) {
|
|
1356
|
-
const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
|
|
1357
|
-
const managedTotal = extensions.filter((entry) => entry.managed).length;
|
|
1358
|
-
const enabledTotal = extensions.filter((entry) => entry.enabled).length;
|
|
1359
|
-
const activeTotal = extensions.filter((entry) => entry.active).length;
|
|
1360
|
-
const updateAvailableTotal = extensions.filter((entry) => entry.update_available === true).length;
|
|
1361
|
-
const unmanagedExtensions = extensions.filter((entry) => entry.managed === false);
|
|
1362
|
-
const unmanagedExpectedExtensions = unmanagedExtensions.filter((entry) => isExpectedUnmanagedExtension(entry)).map((entry) => entry.name).sort((left, right) => left.localeCompare(right));
|
|
1363
|
-
const unmanagedActionRequiredExtensions = unmanagedExtensions.filter((entry) => !isExpectedUnmanagedExtension(entry)).map((entry) => entry.name).sort((left, right) => left.localeCompare(right));
|
|
1364
|
-
const updateCheckStatusTotals = {
|
|
1365
|
-
checked: 0,
|
|
1366
|
-
skipped_unmanaged: 0,
|
|
1367
|
-
skipped_non_github: 0,
|
|
1368
|
-
failed: 0,
|
|
1369
|
-
not_checked: 0
|
|
1370
|
-
};
|
|
1371
|
-
for (const entry of extensions) {
|
|
1372
|
-
updateCheckStatusTotals[entry.update_check_status] += 1;
|
|
1373
|
-
}
|
|
1374
|
-
const updateCheckFailedTotal = updateCheckStatusTotals.failed;
|
|
1375
|
-
const skippedUnmanagedTotal = updateCheckStatusTotals.skipped_unmanaged;
|
|
1376
|
-
const skippedNonGithubTotal = updateCheckStatusTotals.skipped_non_github;
|
|
1377
|
-
const updateHealthPartial = unmanagedActionRequiredExtensions.length > 0;
|
|
1378
|
-
const updateHealthCoverage = updateHealthPartial ? "partial" : "full";
|
|
1379
|
-
const partialCoverageWarnings = updateHealthPartial ? [`extension_update_health_partial_coverage:skipped_unmanaged:${unmanagedActionRequiredExtensions.length}`] : [];
|
|
1380
|
-
const effectiveWarnings = [.../* @__PURE__ */ new Set([...normalizedWarnings, ...partialCoverageWarnings])].sort((left, right) => left.localeCompare(right));
|
|
1381
|
-
const warningCodes = [...new Set(effectiveWarnings.map((value) => warningCode(value)))].sort((left, right) => left.localeCompare(right));
|
|
1382
|
-
const policyWarnings = summarizePolicyWarnings(effectiveWarnings);
|
|
1383
|
-
const scopeFlag = scope === "global" ? "--global" : "--project";
|
|
1384
|
-
const collisionPlan = buildRegistrationCollisionPlan(scope, normalizedWarnings, extensions, options);
|
|
1385
|
-
const remediation = buildExtensionTriageRemediation({
|
|
1386
|
-
normalizedWarnings,
|
|
1387
|
-
options,
|
|
1388
|
-
scope,
|
|
1389
|
-
scopeFlag,
|
|
1390
|
-
updateCheckFailedTotal,
|
|
1391
|
-
policyWarningCount: policyWarnings.warning_count,
|
|
1392
|
-
updateHealthPartial,
|
|
1393
|
-
skippedUnmanagedTotal,
|
|
1394
|
-
skippedNonGithubTotal,
|
|
1395
|
-
updateAvailableTotal
|
|
1396
|
-
});
|
|
1397
|
-
return {
|
|
1398
|
-
status: effectiveWarnings.length === 0 ? "ok" : "warn",
|
|
1399
|
-
warning_count: effectiveWarnings.length,
|
|
1400
|
-
warning_codes: warningCodes,
|
|
1401
|
-
warnings: effectiveWarnings,
|
|
1402
|
-
policy_warning_count: policyWarnings.warning_count,
|
|
1403
|
-
policy_violation_count: policyWarnings.violation_count,
|
|
1404
|
-
policy_blocked_count: policyWarnings.blocked_count,
|
|
1405
|
-
total_extensions: extensions.length,
|
|
1406
|
-
managed_total: managedTotal,
|
|
1407
|
-
enabled_total: enabledTotal,
|
|
1408
|
-
active_total: activeTotal,
|
|
1409
|
-
update_available_total: updateAvailableTotal,
|
|
1410
|
-
update_health_coverage: updateHealthCoverage,
|
|
1411
|
-
update_health_partial: updateHealthPartial,
|
|
1412
|
-
unmanaged_loaded_extension_count: unmanagedExtensions.length,
|
|
1413
|
-
unmanaged_loaded_extensions: unmanagedExtensions.map((entry) => entry.name).sort((left, right) => left.localeCompare(right)),
|
|
1414
|
-
unmanaged_expected_extension_count: unmanagedExpectedExtensions.length,
|
|
1415
|
-
unmanaged_expected_extensions: unmanagedExpectedExtensions,
|
|
1416
|
-
unmanaged_action_required_extension_count: unmanagedActionRequiredExtensions.length,
|
|
1417
|
-
unmanaged_action_required_extensions: unmanagedActionRequiredExtensions,
|
|
1418
|
-
update_check_status_totals: updateCheckStatusTotals,
|
|
1419
|
-
update_check_failed_total: updateCheckFailedTotal,
|
|
1420
|
-
top_warnings: effectiveWarnings.slice(0, 8),
|
|
1421
|
-
remediation,
|
|
1422
|
-
...collisionPlan ? { collision_plan: collisionPlan } : {}
|
|
1423
|
-
};
|
|
1424
|
-
}
|
|
1425
|
-
function parseDoctorDetailMode(raw) {
|
|
1426
|
-
if (!raw || raw.trim().length === 0) {
|
|
1427
|
-
return "summary";
|
|
1428
|
-
}
|
|
1429
|
-
const normalized = raw.trim().toLowerCase();
|
|
1430
|
-
if (normalized === "summary" || normalized === "deep") {
|
|
1431
|
-
return normalized;
|
|
1432
|
-
}
|
|
1433
|
-
throw new PmCliError(`Invalid --detail value "${raw}". Expected summary or deep.`, EXIT_CODE.USAGE);
|
|
1434
|
-
}
|
|
1435
|
-
function warningCode(value) {
|
|
1436
|
-
const normalized = value.trim();
|
|
1437
|
-
const separator = normalized.indexOf(":");
|
|
1438
|
-
if (separator === -1) {
|
|
1439
|
-
return normalized;
|
|
1440
|
-
}
|
|
1441
|
-
return normalized.slice(0, separator);
|
|
1442
|
-
}
|
|
1443
|
-
function collectUnknownCapabilityGuidance(warnings) {
|
|
1444
|
-
const seen = /* @__PURE__ */ new Set();
|
|
1445
|
-
const guidance = [];
|
|
1446
|
-
for (const warning of warnings) {
|
|
1447
|
-
const parsedDetails = (() => {
|
|
1448
|
-
const unknownWarning = parseUnknownExtensionCapabilityWarning(warning);
|
|
1449
|
-
if (unknownWarning) {
|
|
1450
|
-
return [unknownWarning];
|
|
1451
|
-
}
|
|
1452
|
-
return parseLegacyExtensionCapabilityAliasWarning(warning);
|
|
1453
|
-
})();
|
|
1454
|
-
for (const parsed of parsedDetails) {
|
|
1455
|
-
const key = `${parsed.layer}:${parsed.name}:${parsed.capability}`;
|
|
1456
|
-
if (seen.has(key)) {
|
|
1457
|
-
continue;
|
|
1458
|
-
}
|
|
1459
|
-
seen.add(key);
|
|
1460
|
-
guidance.push(parsed);
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
return guidance;
|
|
1464
|
-
}
|
|
1465
|
-
function buildCapabilityContractMetadata() {
|
|
1466
|
-
return {
|
|
1467
|
-
version: EXTENSION_CAPABILITY_CONTRACT.version,
|
|
1468
|
-
capabilities: [...EXTENSION_CAPABILITY_CONTRACT.capabilities],
|
|
1469
|
-
legacy_aliases: { ...EXTENSION_CAPABILITY_CONTRACT.legacy_aliases }
|
|
1470
|
-
};
|
|
1471
|
-
}
|
|
1472
|
-
function isExpectedUnmanagedExtension(entry) {
|
|
1473
|
-
const normalizedName = normalizeExtensionNameForMatch(entry.name);
|
|
1474
|
-
const normalizedDirectory = normalizeExtensionNameForMatch(entry.directory);
|
|
1475
|
-
if (normalizedName.startsWith("builtin-")) {
|
|
1476
|
-
return true;
|
|
1477
|
-
}
|
|
1478
|
-
return normalizedDirectory === "beads" || normalizedDirectory === "todos";
|
|
1479
|
-
}
|
|
1480
|
-
function buildDoctorConsistencySummary(scope, installedExtensions, loadedExtensions, failedLoads, disabledByFlag) {
|
|
1481
|
-
if (scope !== "project" || disabledByFlag) {
|
|
1482
|
-
return {
|
|
1483
|
-
warnings: [],
|
|
1484
|
-
summary: {
|
|
1485
|
-
active_project_count: 0,
|
|
1486
|
-
loaded_project_count: 0,
|
|
1487
|
-
active_project_names: [],
|
|
1488
|
-
loaded_project_names: [],
|
|
1489
|
-
missing_active_project_names: []
|
|
1490
|
-
}
|
|
1491
|
-
};
|
|
1492
|
-
}
|
|
1493
|
-
const activeProjectNames = [
|
|
1494
|
-
...new Set(installedExtensions.filter((entry) => entry.active).map((entry) => normalizeExtensionNameForMatch(entry.name)))
|
|
1495
|
-
].sort((left, right) => left.localeCompare(right));
|
|
1496
|
-
const loadedProjectNames = [
|
|
1497
|
-
...new Set(loadedExtensions.filter((entry) => entry.layer === "project").map((entry) => normalizeExtensionNameForMatch(entry.name)))
|
|
1498
|
-
].sort((left, right) => left.localeCompare(right));
|
|
1499
|
-
const failedLoadNames = new Set(failedLoads.map((entry) => normalizeExtensionNameForMatch(entry.name)));
|
|
1500
|
-
const missingActiveProjectNames = activeProjectNames.filter((name) => !loadedProjectNames.includes(name) && !failedLoadNames.has(name)).sort((left, right) => left.localeCompare(right));
|
|
1501
|
-
const warnings = missingActiveProjectNames.length > 0 ? [`extension_doctor_consistency_active_not_loaded:${missingActiveProjectNames.join(",")}`] : [];
|
|
1502
|
-
return {
|
|
1503
|
-
warnings,
|
|
1504
|
-
summary: {
|
|
1505
|
-
active_project_count: activeProjectNames.length,
|
|
1506
|
-
loaded_project_count: loadedProjectNames.length,
|
|
1507
|
-
active_project_names: activeProjectNames,
|
|
1508
|
-
loaded_project_names: loadedProjectNames,
|
|
1509
|
-
missing_active_project_names: missingActiveProjectNames
|
|
1510
|
-
}
|
|
1511
|
-
};
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
// dist/cli/commands/extension.js
|
|
1515
|
-
!(function() {
|
|
1516
|
-
try {
|
|
1517
|
-
var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
|
|
1518
|
-
n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3ff8a83f-729e-576a-8830-d52097bd0d34");
|
|
1519
|
-
} catch (e2) {
|
|
1520
|
-
}
|
|
1521
|
-
})();
|
|
1522
|
-
var execFileAsync2 = promisify2(execFile2);
|
|
1523
|
-
var EXTENSION_INSTALL_COPY_ATTEMPTS = 3;
|
|
1524
|
-
var EXTENSION_INSTALL_LOCK_ATTEMPTS = 120;
|
|
1525
|
-
var EXTENSION_INSTALL_LOCK_DELAY_MS = 250;
|
|
1526
|
-
var EXTENSION_INSTALL_LOCK_STALE_MS = 12e4;
|
|
1527
|
-
var LIFECYCLE_ACTION_TARGETS = [
|
|
1528
|
-
["install", "install", "--install"],
|
|
1529
|
-
["uninstall", "uninstall", "--uninstall"],
|
|
1530
|
-
["explore", "explore", "--explore"],
|
|
1531
|
-
["list", "explore", "--explore"],
|
|
1532
|
-
["manage", "manage", "--manage"],
|
|
1533
|
-
["describe", "describe", "--describe"],
|
|
1534
|
-
["reload", "reload", "--reload"],
|
|
1535
|
-
["doctor", "doctor", "--doctor"],
|
|
1536
|
-
["catalog", "catalog", "--catalog"],
|
|
1537
|
-
["init", "init", "--init"],
|
|
1538
|
-
["scaffold", "init", "--scaffold"],
|
|
1539
|
-
["adopt", "adopt", "--adopt"],
|
|
1540
|
-
["adopt-all", "adopt-all", "--adopt-all"],
|
|
1541
|
-
["activate", "activate", "--activate"],
|
|
1542
|
-
["deactivate", "deactivate", "--deactivate"]
|
|
1543
|
-
];
|
|
1544
|
-
var LIFECYCLE_ACTION_FLAG_HINT = LIFECYCLE_ACTION_TARGETS.map(([, , flag]) => flag).filter((flag, index, flags) => flags.indexOf(flag) === index).join(", ");
|
|
1545
|
-
var LIFECYCLE_ACTION_FLAGS = {
|
|
1546
|
-
install: "--install",
|
|
1547
|
-
uninstall: "--uninstall",
|
|
1548
|
-
explore: "--explore",
|
|
1549
|
-
manage: "--manage",
|
|
1550
|
-
describe: "--describe",
|
|
1551
|
-
reload: "--reload",
|
|
1552
|
-
doctor: "--doctor",
|
|
1553
|
-
catalog: "--catalog",
|
|
1554
|
-
adopt: "--adopt",
|
|
1555
|
-
"adopt-all": "--adopt-all",
|
|
1556
|
-
activate: "--activate",
|
|
1557
|
-
deactivate: "--deactivate",
|
|
1558
|
-
init: "--init"
|
|
1559
|
-
};
|
|
1560
|
-
var NATIVE_OUTPUT_MARKER = "__pm_native_output";
|
|
1561
|
-
function buildExtensionPolicyDetails(policy) {
|
|
1562
|
-
const overrides = (policy.extension_overrides ?? []).map((override) => ({
|
|
1563
|
-
name: override.name.trim(),
|
|
1564
|
-
disabled: override.disabled === true ? true : void 0,
|
|
1565
|
-
require_trusted: override.require_trusted === true ? true : void 0,
|
|
1566
|
-
require_provenance: override.require_provenance === true ? true : void 0,
|
|
1567
|
-
sandbox_profile: override.sandbox_profile,
|
|
1568
|
-
allowed_capabilities: normalizeStringList(override.allowed_capabilities ?? []),
|
|
1569
|
-
blocked_capabilities: normalizeStringList(override.blocked_capabilities ?? []),
|
|
1570
|
-
allowed_surfaces: normalizeStringList(override.allowed_surfaces ?? []),
|
|
1571
|
-
blocked_surfaces: normalizeStringList(override.blocked_surfaces ?? []),
|
|
1572
|
-
allowed_commands: normalizeStringList(override.allowed_commands ?? []),
|
|
1573
|
-
blocked_commands: normalizeStringList(override.blocked_commands ?? []),
|
|
1574
|
-
allowed_actions: normalizeStringList(override.allowed_actions ?? []),
|
|
1575
|
-
blocked_actions: normalizeStringList(override.blocked_actions ?? []),
|
|
1576
|
-
allowed_services: normalizeStringList(override.allowed_services ?? []),
|
|
1577
|
-
blocked_services: normalizeStringList(override.blocked_services ?? [])
|
|
1578
|
-
})).filter((override) => override.name.length > 0).sort((left, right) => left.name.localeCompare(right.name));
|
|
1579
|
-
return {
|
|
1580
|
-
mode: policy.mode,
|
|
1581
|
-
trust_mode: policy.trust_mode,
|
|
1582
|
-
require_provenance: policy.require_provenance === true,
|
|
1583
|
-
trusted_extensions: normalizeStringList(policy.trusted_extensions ?? []),
|
|
1584
|
-
default_sandbox_profile: policy.default_sandbox_profile ?? "none",
|
|
1585
|
-
allowed_extensions: normalizeStringList(policy.allowed_extensions ?? []),
|
|
1586
|
-
blocked_extensions: normalizeStringList(policy.blocked_extensions ?? []),
|
|
1587
|
-
allowed_capabilities: normalizeStringList(policy.allowed_capabilities ?? []),
|
|
1588
|
-
blocked_capabilities: normalizeStringList(policy.blocked_capabilities ?? []),
|
|
1589
|
-
allowed_surfaces: normalizeStringList(policy.allowed_surfaces ?? []),
|
|
1590
|
-
blocked_surfaces: normalizeStringList(policy.blocked_surfaces ?? []),
|
|
1591
|
-
allowed_commands: normalizeStringList(policy.allowed_commands ?? []),
|
|
1592
|
-
blocked_commands: normalizeStringList(policy.blocked_commands ?? []),
|
|
1593
|
-
allowed_actions: normalizeStringList(policy.allowed_actions ?? []),
|
|
1594
|
-
blocked_actions: normalizeStringList(policy.blocked_actions ?? []),
|
|
1595
|
-
allowed_services: normalizeStringList(policy.allowed_services ?? []),
|
|
1596
|
-
blocked_services: normalizeStringList(policy.blocked_services ?? []),
|
|
1597
|
-
extension_overrides: overrides.map((override) => ({
|
|
1598
|
-
name: override.name,
|
|
1599
|
-
...override.disabled === true ? { disabled: true } : {},
|
|
1600
|
-
...override.require_trusted === true ? { require_trusted: true } : {},
|
|
1601
|
-
...override.require_provenance === true ? { require_provenance: true } : {},
|
|
1602
|
-
...override.sandbox_profile ? { sandbox_profile: override.sandbox_profile } : {},
|
|
1603
|
-
...override.allowed_capabilities.length > 0 ? { allowed_capabilities: override.allowed_capabilities } : {},
|
|
1604
|
-
...override.blocked_capabilities.length > 0 ? { blocked_capabilities: override.blocked_capabilities } : {},
|
|
1605
|
-
...override.allowed_surfaces.length > 0 ? { allowed_surfaces: override.allowed_surfaces } : {},
|
|
1606
|
-
...override.blocked_surfaces.length > 0 ? { blocked_surfaces: override.blocked_surfaces } : {},
|
|
1607
|
-
...override.allowed_commands.length > 0 ? { allowed_commands: override.allowed_commands } : {},
|
|
1608
|
-
...override.blocked_commands.length > 0 ? { blocked_commands: override.blocked_commands } : {},
|
|
1609
|
-
...override.allowed_actions.length > 0 ? { allowed_actions: override.allowed_actions } : {},
|
|
1610
|
-
...override.blocked_actions.length > 0 ? { blocked_actions: override.blocked_actions } : {},
|
|
1611
|
-
...override.allowed_services.length > 0 ? { allowed_services: override.allowed_services } : {},
|
|
1612
|
-
...override.blocked_services.length > 0 ? { blocked_services: override.blocked_services } : {}
|
|
1613
|
-
}))
|
|
1614
|
-
};
|
|
1615
|
-
}
|
|
1616
|
-
function isRetriableExtensionInstallCopyError(error) {
|
|
1617
|
-
if (typeof error !== "object" || error === null || !("code" in error)) {
|
|
1618
|
-
return false;
|
|
1619
|
-
}
|
|
1620
|
-
const code = error.code;
|
|
1621
|
-
return code === "EEXIST" || code === "ENOTEMPTY" || code === "ENOENT";
|
|
1622
|
-
}
|
|
1623
|
-
function isErrnoCode(error, code) {
|
|
1624
|
-
return typeof error === "object" && error !== null && "code" in error && error.code === code;
|
|
1625
|
-
}
|
|
1626
|
-
function sleep(ms) {
|
|
1627
|
-
return new Promise((resolve) => {
|
|
1628
|
-
setTimeout(resolve, ms);
|
|
1629
|
-
});
|
|
1630
|
-
}
|
|
1631
|
-
async function ensureExtensionModuleTypeMarker(destinationDirectory) {
|
|
1632
|
-
const markerPath = path4.join(destinationDirectory, "package.json");
|
|
1633
|
-
if (await pathExists(markerPath)) {
|
|
1634
|
-
return;
|
|
1635
|
-
}
|
|
1636
|
-
await fs4.writeFile(markerPath, `${JSON.stringify({ type: "module" }, null, 2)}
|
|
1637
|
-
`, "utf8");
|
|
1638
|
-
}
|
|
1639
|
-
async function copyExtensionDirectoryForInstall(sourceDirectory, destinationDirectory, copyDirectory = fs4.cp) {
|
|
1640
|
-
for (let attempt = 1; attempt <= EXTENSION_INSTALL_COPY_ATTEMPTS; attempt += 1) {
|
|
1641
|
-
try {
|
|
1642
|
-
if (await pathExists(destinationDirectory)) {
|
|
1643
|
-
await fs4.rm(destinationDirectory, { recursive: true, force: true });
|
|
1644
|
-
}
|
|
1645
|
-
await copyExtensionDirectoryWithoutSelfNesting(sourceDirectory, destinationDirectory, copyDirectory);
|
|
1646
|
-
return;
|
|
1647
|
-
} catch (error) {
|
|
1648
|
-
if (!isRetriableExtensionInstallCopyError(error) || attempt === EXTENSION_INSTALL_COPY_ATTEMPTS) {
|
|
1649
|
-
throw error;
|
|
1650
|
-
}
|
|
1651
|
-
await sleep(EXTENSION_INSTALL_LOCK_DELAY_MS);
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
async function copyExtensionDirectoryWithoutSelfNesting(sourceDirectory, destinationDirectory, copyDirectory) {
|
|
1656
|
-
const resolvedSource = path4.resolve(sourceDirectory);
|
|
1657
|
-
const resolvedDestination = path4.resolve(destinationDirectory);
|
|
1658
|
-
if (resolvedSource === resolvedDestination) {
|
|
1659
|
-
return;
|
|
1660
|
-
}
|
|
1661
|
-
if (!isPathWithinDirectory(resolvedSource, resolvedDestination)) {
|
|
1662
|
-
await copyDirectory(sourceDirectory, destinationDirectory, { recursive: true, force: true });
|
|
1663
|
-
return;
|
|
1664
|
-
}
|
|
1665
|
-
const stagingRoot = await fs4.mkdtemp(path4.join(os2.tmpdir(), "pm-extension-copy-"));
|
|
1666
|
-
const stagedDirectory = path4.join(stagingRoot, "extension");
|
|
1667
|
-
try {
|
|
1668
|
-
await copyDirectory(sourceDirectory, stagedDirectory, { recursive: true, force: true });
|
|
1669
|
-
await copyDirectory(stagedDirectory, destinationDirectory, { recursive: true, force: true });
|
|
1670
|
-
} finally {
|
|
1671
|
-
await fs4.rm(stagingRoot, { recursive: true, force: true });
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
async function withExtensionInstallLock(settingsRoot, destinationDirectoryName, run, options) {
|
|
1675
|
-
const lockRoot = path4.join(settingsRoot, "runtime", "extension-install-locks");
|
|
1676
|
-
const lockPath = path4.join(lockRoot, `${destinationDirectoryName}.lock`);
|
|
1677
|
-
await fs4.mkdir(lockRoot, { recursive: true });
|
|
1678
|
-
const attempts = Math.max(1, Math.floor(options?.attempts ?? EXTENSION_INSTALL_LOCK_ATTEMPTS));
|
|
1679
|
-
const delayMs = Math.max(0, Math.floor(options?.delay_ms ?? EXTENSION_INSTALL_LOCK_DELAY_MS));
|
|
1680
|
-
const staleMs = Math.max(0, Math.floor(options?.stale_ms ?? EXTENSION_INSTALL_LOCK_STALE_MS));
|
|
1681
|
-
let acquired = false;
|
|
1682
|
-
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
1683
|
-
try {
|
|
1684
|
-
await fs4.mkdir(lockPath);
|
|
1685
|
-
acquired = true;
|
|
1686
|
-
await fs4.writeFile(path4.join(lockPath, "owner.json"), `${JSON.stringify({ pid: process.pid, created_at: nowIso(), destination: destinationDirectoryName }, null, 2)}
|
|
1687
|
-
`, "utf8");
|
|
1688
|
-
break;
|
|
1689
|
-
} catch (error) {
|
|
1690
|
-
if (!isErrnoCode(error, "EEXIST")) {
|
|
1691
|
-
throw error;
|
|
1692
|
-
}
|
|
1693
|
-
let stat = null;
|
|
1694
|
-
try {
|
|
1695
|
-
stat = await fs4.stat(lockPath);
|
|
1696
|
-
} catch {
|
|
1697
|
-
stat = null;
|
|
1698
|
-
}
|
|
1699
|
-
if (stat && Date.now() - stat.mtimeMs > staleMs) {
|
|
1700
|
-
await fs4.rm(lockPath, { recursive: true, force: true });
|
|
1701
|
-
continue;
|
|
1702
|
-
}
|
|
1703
|
-
await sleep(delayMs);
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
if (!acquired) {
|
|
1707
|
-
throw new PmCliError(`Timed out waiting for extension install lock for "${destinationDirectoryName}".`, EXIT_CODE.CONFLICT);
|
|
1708
|
-
}
|
|
1709
|
-
try {
|
|
1710
|
-
return await run();
|
|
1711
|
-
} finally {
|
|
1712
|
-
await fs4.rm(lockPath, { recursive: true, force: true }).catch(() => void 0);
|
|
1713
|
-
}
|
|
1714
|
-
}
|
|
1715
|
-
async function resolveInstalledExtensionCandidate(installed, extensionTarget) {
|
|
1716
|
-
const lookupValues = [extensionTarget];
|
|
1717
|
-
const bundledAliasManifestName = await resolveBundledAliasManifestName(extensionTarget);
|
|
1718
|
-
if (bundledAliasManifestName) {
|
|
1719
|
-
lookupValues.push(bundledAliasManifestName);
|
|
1720
|
-
}
|
|
1721
|
-
const normalizedLookups = [...new Set(lookupValues.map((value) => normalizeExtensionNameForMatch(value)).filter((value) => value.length > 0))];
|
|
1722
|
-
for (const lookup of normalizedLookups) {
|
|
1723
|
-
const byName = installed.find((entry) => normalizeExtensionNameForMatch(entry.name) === lookup);
|
|
1724
|
-
if (byName) {
|
|
1725
|
-
return byName;
|
|
1726
|
-
}
|
|
1727
|
-
const byDirectory = installed.find((entry) => normalizeExtensionNameForMatch(entry.directory) === lookup);
|
|
1728
|
-
if (byDirectory) {
|
|
1729
|
-
return byDirectory;
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
return void 0;
|
|
1733
|
-
}
|
|
1734
|
-
function isExtensionEnabled(settings, name) {
|
|
1735
|
-
const normalizedName = name.trim();
|
|
1736
|
-
const enabled = new Set(normalizeStringList(settings.extensions.enabled));
|
|
1737
|
-
const disabled = new Set(normalizeStringList(settings.extensions.disabled));
|
|
1738
|
-
if (disabled.has(normalizedName)) {
|
|
1739
|
-
return false;
|
|
1740
|
-
}
|
|
1741
|
-
if (enabled.size === 0) {
|
|
1742
|
-
return true;
|
|
1743
|
-
}
|
|
1744
|
-
return enabled.has(normalizedName);
|
|
1745
|
-
}
|
|
1746
|
-
function ensureActivated(settings, name) {
|
|
1747
|
-
const normalizedName = name.trim();
|
|
1748
|
-
const enabled = new Set(normalizeStringList(settings.extensions.enabled));
|
|
1749
|
-
const disabled = new Set(normalizeStringList(settings.extensions.disabled));
|
|
1750
|
-
const previousEnabled = [...enabled];
|
|
1751
|
-
const previousDisabled = [...disabled];
|
|
1752
|
-
disabled.delete(normalizedName);
|
|
1753
|
-
if (enabled.size > 0) {
|
|
1754
|
-
enabled.add(normalizedName);
|
|
1755
|
-
}
|
|
1756
|
-
settings.extensions.enabled = [...enabled].sort((left, right) => left.localeCompare(right));
|
|
1757
|
-
settings.extensions.disabled = [...disabled].sort((left, right) => left.localeCompare(right));
|
|
1758
|
-
return settings.extensions.enabled.join("\0") !== previousEnabled.join("\0") || settings.extensions.disabled.join("\0") !== previousDisabled.join("\0");
|
|
1759
|
-
}
|
|
1760
|
-
function ensureDeactivated(settings, name) {
|
|
1761
|
-
const normalizedName = name.trim();
|
|
1762
|
-
const enabled = new Set(normalizeStringList(settings.extensions.enabled));
|
|
1763
|
-
const disabled = new Set(normalizeStringList(settings.extensions.disabled));
|
|
1764
|
-
const previousEnabled = [...enabled];
|
|
1765
|
-
const previousDisabled = [...disabled];
|
|
1766
|
-
enabled.delete(normalizedName);
|
|
1767
|
-
disabled.add(normalizedName);
|
|
1768
|
-
settings.extensions.enabled = [...enabled].sort((left, right) => left.localeCompare(right));
|
|
1769
|
-
settings.extensions.disabled = [...disabled].sort((left, right) => left.localeCompare(right));
|
|
1770
|
-
return settings.extensions.enabled.join("\0") !== previousEnabled.join("\0") || settings.extensions.disabled.join("\0") !== previousDisabled.join("\0");
|
|
1771
|
-
}
|
|
1772
|
-
function clearExtensionState(settings, name) {
|
|
1773
|
-
const normalizedName = name.trim();
|
|
1774
|
-
const enabled = new Set(normalizeStringList(settings.extensions.enabled));
|
|
1775
|
-
const disabled = new Set(normalizeStringList(settings.extensions.disabled));
|
|
1776
|
-
const previousEnabled = [...enabled];
|
|
1777
|
-
const previousDisabled = [...disabled];
|
|
1778
|
-
enabled.delete(normalizedName);
|
|
1779
|
-
disabled.delete(normalizedName);
|
|
1780
|
-
settings.extensions.enabled = [...enabled].sort((left, right) => left.localeCompare(right));
|
|
1781
|
-
settings.extensions.disabled = [...disabled].sort((left, right) => left.localeCompare(right));
|
|
1782
|
-
return settings.extensions.enabled.join("\0") !== previousEnabled.join("\0") || settings.extensions.disabled.join("\0") !== previousDisabled.join("\0");
|
|
1783
|
-
}
|
|
1784
|
-
function suggestLifecycleActionTarget(target) {
|
|
1785
|
-
const normalizedTarget = target.trim().toLowerCase();
|
|
1786
|
-
const exactMatch = LIFECYCLE_ACTION_TARGETS.find(([candidate]) => candidate === normalizedTarget);
|
|
1787
|
-
if (exactMatch) {
|
|
1788
|
-
return { action: exactMatch[1], flag: exactMatch[2] };
|
|
1789
|
-
}
|
|
1790
|
-
const maxDistance = normalizedTarget.length <= 4 ? 1 : 2;
|
|
1791
|
-
let nearest = null;
|
|
1792
|
-
for (const [candidate, action, flag] of LIFECYCLE_ACTION_TARGETS) {
|
|
1793
|
-
const distance = levenshteinDistanceWithinLimit(normalizedTarget, candidate, maxDistance);
|
|
1794
|
-
if (distance === null) {
|
|
1795
|
-
continue;
|
|
1796
|
-
}
|
|
1797
|
-
if (nearest === null) {
|
|
1798
|
-
nearest = { action, flag, distance };
|
|
1799
|
-
continue;
|
|
1800
|
-
}
|
|
1801
|
-
if (distance < nearest.distance) {
|
|
1802
|
-
nearest = { action, flag, distance };
|
|
1803
|
-
}
|
|
1804
|
-
}
|
|
1805
|
-
return nearest === null ? null : { action: nearest.action, flag: nearest.flag };
|
|
1806
|
-
}
|
|
1807
|
-
function buildUnknownLifecycleActionError(target, options) {
|
|
1808
|
-
const noun = options.vocabulary === "package" ? "package" : "extension";
|
|
1809
|
-
const suggestion = suggestLifecycleActionTarget(target);
|
|
1810
|
-
if (!suggestion) {
|
|
1811
|
-
return new PmCliError(`One action flag is required. Use one of: ${LIFECYCLE_ACTION_FLAG_HINT}. Bare \`pm package\` and \`pm extension\` default to --explore.`, EXIT_CODE.USAGE);
|
|
1812
|
-
}
|
|
1813
|
-
const command = `pm ${noun} ${suggestion.flag}`;
|
|
1814
|
-
return new PmCliError(`Unknown ${noun} lifecycle action "${target}". Did you mean "${suggestion.flag}"?`, EXIT_CODE.USAGE, {
|
|
1815
|
-
code: "unknown_lifecycle_action",
|
|
1816
|
-
required: `Use one of: ${LIFECYCLE_ACTION_FLAG_HINT}.`,
|
|
1817
|
-
examples: [command, `pm ${noun} --help`],
|
|
1818
|
-
recovery: {
|
|
1819
|
-
attempted_command: `pm ${noun} ${target}`,
|
|
1820
|
-
suggested_retry: command,
|
|
1821
|
-
fallback_candidates: [
|
|
1822
|
-
{
|
|
1823
|
-
source: "lifecycle_action",
|
|
1824
|
-
command,
|
|
1825
|
-
reason: `nearest lifecycle action for "${target}"`
|
|
1826
|
-
}
|
|
1827
|
-
]
|
|
1828
|
-
}
|
|
1829
|
-
});
|
|
1830
|
-
}
|
|
1831
|
-
var EXTENSION_ACTION_FLAG_SELECTORS = [
|
|
1832
|
-
["install", "install"],
|
|
1833
|
-
["uninstall", "uninstall"],
|
|
1834
|
-
["explore", "explore"],
|
|
1835
|
-
["manage", "manage"],
|
|
1836
|
-
["describe", "describe"],
|
|
1837
|
-
["reload", "reload"],
|
|
1838
|
-
["doctor", "doctor"],
|
|
1839
|
-
["catalog", "catalog"],
|
|
1840
|
-
["init", "init"],
|
|
1841
|
-
["scaffold", "init"],
|
|
1842
|
-
["adopt", "adopt"],
|
|
1843
|
-
["adoptAll", "adopt-all"],
|
|
1844
|
-
["activate", "activate"],
|
|
1845
|
-
["deactivate", "deactivate"]
|
|
1846
|
-
];
|
|
1847
|
-
function resolveImplicitActionFromTarget(normalizedTarget) {
|
|
1848
|
-
if (normalizedTarget === "doctor") {
|
|
1849
|
-
return "doctor";
|
|
1850
|
-
}
|
|
1851
|
-
if (normalizedTarget === "reload") {
|
|
1852
|
-
return "reload";
|
|
1853
|
-
}
|
|
1854
|
-
if (normalizedTarget === "catalog") {
|
|
1855
|
-
return "catalog";
|
|
1856
|
-
}
|
|
1857
|
-
if (normalizedTarget === "init" || normalizedTarget === "scaffold") {
|
|
1858
|
-
return "init";
|
|
1859
|
-
}
|
|
1860
|
-
if (normalizedTarget === "explore") {
|
|
1861
|
-
return "explore";
|
|
1862
|
-
}
|
|
1863
|
-
if (normalizedTarget === "manage") {
|
|
1864
|
-
return "manage";
|
|
1865
|
-
}
|
|
1866
|
-
if (normalizedTarget === "list" || normalizedTarget === "") {
|
|
1867
|
-
return "explore";
|
|
1868
|
-
}
|
|
1869
|
-
return null;
|
|
1870
|
-
}
|
|
1871
|
-
function resolveAction(target, options) {
|
|
1872
|
-
const selected = [
|
|
1873
|
-
...new Set(EXTENSION_ACTION_FLAG_SELECTORS.filter(([flag]) => options[flag] === true).map(([, mappedAction]) => mappedAction))
|
|
1874
|
-
];
|
|
1875
|
-
if (selected.length === 0) {
|
|
1876
|
-
if (target === void 0) {
|
|
1877
|
-
return "explore";
|
|
1878
|
-
}
|
|
1879
|
-
const implicitAction = resolveImplicitActionFromTarget(target.trim().toLowerCase());
|
|
1880
|
-
if (implicitAction) {
|
|
1881
|
-
return implicitAction;
|
|
1882
|
-
}
|
|
1883
|
-
throw buildUnknownLifecycleActionError(target, options);
|
|
1884
|
-
}
|
|
1885
|
-
if (selected.length > 1) {
|
|
1886
|
-
throw new PmCliError("Extension action flags are mutually exclusive.", EXIT_CODE.USAGE);
|
|
1887
|
-
}
|
|
1888
|
-
return selected[0];
|
|
1889
|
-
}
|
|
1890
|
-
function resolveScope(options) {
|
|
1891
|
-
const projectLike = options.project === true || options.local === true;
|
|
1892
|
-
const global2 = options.global === true;
|
|
1893
|
-
if (projectLike && global2) {
|
|
1894
|
-
throw new PmCliError('Options "--project/--local" and "--global" are mutually exclusive.', EXIT_CODE.USAGE);
|
|
1895
|
-
}
|
|
1896
|
-
return global2 ? "global" : "project";
|
|
1897
|
-
}
|
|
1898
|
-
function resolveUpdateCheckResolution(managedEntry) {
|
|
1899
|
-
if (!managedEntry) {
|
|
1900
|
-
return {
|
|
1901
|
-
status: "skipped_unmanaged",
|
|
1902
|
-
reason: "extension_not_managed"
|
|
1903
|
-
};
|
|
1904
|
-
}
|
|
1905
|
-
if (managedEntry.source.kind !== "github") {
|
|
1906
|
-
return {
|
|
1907
|
-
status: "skipped_non_github",
|
|
1908
|
-
reason: `managed_source_kind_${managedEntry.source.kind}`
|
|
1909
|
-
};
|
|
1910
|
-
}
|
|
1911
|
-
const updateError = typeof managedEntry.update_error === "string" ? managedEntry.update_error.trim() : "";
|
|
1912
|
-
if (updateError.length > 0) {
|
|
1913
|
-
return {
|
|
1914
|
-
status: "failed",
|
|
1915
|
-
reason: updateError
|
|
1916
|
-
};
|
|
1917
|
-
}
|
|
1918
|
-
if (typeof managedEntry.last_update_check_at === "string" && managedEntry.last_update_check_at.trim().length > 0) {
|
|
1919
|
-
if (managedEntry.update_available === true) {
|
|
1920
|
-
return {
|
|
1921
|
-
status: "checked",
|
|
1922
|
-
reason: "update_available"
|
|
1923
|
-
};
|
|
1924
|
-
}
|
|
1925
|
-
if (managedEntry.update_available === false) {
|
|
1926
|
-
return {
|
|
1927
|
-
status: "checked",
|
|
1928
|
-
reason: "up_to_date"
|
|
1929
|
-
};
|
|
1930
|
-
}
|
|
1931
|
-
return {
|
|
1932
|
-
status: "checked",
|
|
1933
|
-
reason: "checked_without_commit_baseline"
|
|
1934
|
-
};
|
|
1935
|
-
}
|
|
1936
|
-
return {
|
|
1937
|
-
status: "not_checked",
|
|
1938
|
-
reason: "no_update_check_recorded"
|
|
1939
|
-
};
|
|
1940
|
-
}
|
|
1941
|
-
function buildInstalledExtensionSummary(identity, scope, managedEntry, updateCheck) {
|
|
1942
|
-
return {
|
|
1943
|
-
name: identity.name,
|
|
1944
|
-
directory: identity.directory,
|
|
1945
|
-
version: identity.version,
|
|
1946
|
-
entry: identity.entry,
|
|
1947
|
-
scope,
|
|
1948
|
-
active: identity.enabled,
|
|
1949
|
-
enabled: identity.enabled,
|
|
1950
|
-
runtime_active: null,
|
|
1951
|
-
activation_status: "unknown",
|
|
1952
|
-
managed: Boolean(managedEntry),
|
|
1953
|
-
source: managedEntry?.source,
|
|
1954
|
-
update_available: managedEntry?.update_available,
|
|
1955
|
-
last_update_check_at: managedEntry?.last_update_check_at,
|
|
1956
|
-
last_update_remote_commit: managedEntry?.last_update_remote_commit,
|
|
1957
|
-
update_error: managedEntry?.update_error,
|
|
1958
|
-
update_check_status: updateCheck.status,
|
|
1959
|
-
update_check_reason: updateCheck.reason
|
|
1960
|
-
};
|
|
1961
|
-
}
|
|
1962
|
-
async function listInstalledExtensions(extensionsRoot, scope, settings, state) {
|
|
1963
|
-
if (!await pathExists(extensionsRoot)) {
|
|
1964
|
-
return {
|
|
1965
|
-
extensions: [],
|
|
1966
|
-
warnings: []
|
|
1967
|
-
};
|
|
1968
|
-
}
|
|
1969
|
-
const entries = await fs4.readdir(extensionsRoot, { withFileTypes: true });
|
|
1970
|
-
const directories = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort((left, right) => left.localeCompare(right));
|
|
1971
|
-
const managedByName = /* @__PURE__ */ new Map();
|
|
1972
|
-
const managedByDirectory = /* @__PURE__ */ new Map();
|
|
1973
|
-
for (const managedEntry of state.entries) {
|
|
1974
|
-
managedByName.set(normalizeExtensionNameForMatch(managedEntry.name), managedEntry);
|
|
1975
|
-
managedByDirectory.set(normalizeExtensionNameForMatch(managedEntry.directory), managedEntry);
|
|
1976
|
-
}
|
|
1977
|
-
const warnings = [];
|
|
1978
|
-
const summaries = [];
|
|
1979
|
-
for (const directoryName of directories) {
|
|
1980
|
-
const extensionDirectory = path4.join(extensionsRoot, directoryName);
|
|
1981
|
-
const manifestPath = path4.join(extensionDirectory, "manifest.json");
|
|
1982
|
-
if (!await pathExists(manifestPath)) {
|
|
1983
|
-
warnings.push(`extension_manifest_missing:${scope}:${directoryName}`);
|
|
1984
|
-
const managedEntry2 = managedByDirectory.get(normalizeExtensionNameForMatch(directoryName));
|
|
1985
|
-
summaries.push(buildInstalledExtensionSummary({
|
|
1986
|
-
name: managedEntry2?.name ?? directoryName,
|
|
1987
|
-
directory: directoryName,
|
|
1988
|
-
version: managedEntry2?.manifest_version ?? "unknown",
|
|
1989
|
-
entry: managedEntry2?.manifest_entry ?? "unknown",
|
|
1990
|
-
enabled: managedEntry2 ? isExtensionEnabled(settings, managedEntry2.name) : false
|
|
1991
|
-
}, scope, managedEntry2, resolveUpdateCheckResolution(managedEntry2)));
|
|
1992
|
-
continue;
|
|
1993
|
-
}
|
|
1994
|
-
let rawManifest;
|
|
1995
|
-
try {
|
|
1996
|
-
rawManifest = JSON.parse(await fs4.readFile(manifestPath, "utf8"));
|
|
1997
|
-
} catch {
|
|
1998
|
-
warnings.push(`extension_manifest_invalid_json:${scope}:${directoryName}`);
|
|
1999
|
-
continue;
|
|
2000
|
-
}
|
|
2001
|
-
const manifest = parseExtensionManifest(rawManifest);
|
|
2002
|
-
if (!manifest) {
|
|
2003
|
-
warnings.push(`extension_manifest_invalid:${scope}:${directoryName}`);
|
|
2004
|
-
continue;
|
|
2005
|
-
}
|
|
2006
|
-
const managedEntry = managedByName.get(normalizeExtensionNameForMatch(manifest.name)) ?? managedByDirectory.get(normalizeExtensionNameForMatch(directoryName));
|
|
2007
|
-
summaries.push(buildInstalledExtensionSummary({
|
|
2008
|
-
name: manifest.name,
|
|
2009
|
-
directory: directoryName,
|
|
2010
|
-
version: manifest.version,
|
|
2011
|
-
entry: manifest.entry,
|
|
2012
|
-
enabled: isExtensionEnabled(settings, manifest.name)
|
|
2013
|
-
}, scope, managedEntry, resolveUpdateCheckResolution(managedEntry)));
|
|
2014
|
-
}
|
|
2015
|
-
return {
|
|
2016
|
-
extensions: summaries.sort((left, right) => left.name.localeCompare(right.name)),
|
|
2017
|
-
warnings: warnings.sort((left, right) => left.localeCompare(right))
|
|
2018
|
-
};
|
|
2019
|
-
}
|
|
2020
|
-
function summarizeRuntimeCommandPathsForExtension(extensionName, installed) {
|
|
2021
|
-
const normalizedName = normalizeExtensionNameForMatch(extensionName);
|
|
2022
|
-
const entry = installed.find((candidate) => normalizeExtensionNameForMatch(candidate.name) === normalizedName);
|
|
2023
|
-
return {
|
|
2024
|
-
command_paths: [...entry?.command_paths ?? []].sort((left, right) => left.localeCompare(right)),
|
|
2025
|
-
action_paths: [...entry?.action_paths ?? []].sort((left, right) => left.localeCompare(right))
|
|
2026
|
-
};
|
|
2027
|
-
}
|
|
2028
|
-
function resolveCommandDiscoveryPackageName(extensionName, source) {
|
|
2029
|
-
if (typeof source.package === "string" && source.package.trim().length > 0) {
|
|
2030
|
-
return source.package.trim();
|
|
2031
|
-
}
|
|
2032
|
-
if (source.kind === "builtin" && typeof source.name === "string" && source.name.trim().length > 0) {
|
|
2033
|
-
return source.name.trim();
|
|
2034
|
-
}
|
|
2035
|
-
return extensionName;
|
|
2036
|
-
}
|
|
2037
|
-
function buildInstallCommandDiscovery(extensionName, source, commandSummary) {
|
|
2038
|
-
const helpCommands = commandSummary.command_paths.map((commandPath) => `pm ${commandPath} --help`);
|
|
2039
|
-
return {
|
|
2040
|
-
package_name: resolveCommandDiscoveryPackageName(extensionName, source),
|
|
2041
|
-
extension_name: extensionName,
|
|
2042
|
-
command_paths: commandSummary.command_paths,
|
|
2043
|
-
action_paths: commandSummary.action_paths,
|
|
2044
|
-
help_commands: helpCommands,
|
|
2045
|
-
next_steps: commandSummary.command_paths.length > 0 ? helpCommands : ["Run pm package doctor --project --detail deep if expected package commands are missing."]
|
|
2046
|
-
};
|
|
2047
|
-
}
|
|
2048
|
-
function summarizeActivationFailureForDiagnostics(failure) {
|
|
2049
|
-
const trace = failure.trace ? {
|
|
2050
|
-
method: failure.trace.method,
|
|
2051
|
-
registration_index: failure.trace.registration_index,
|
|
2052
|
-
expected_schema: failure.trace.expected_schema,
|
|
2053
|
-
...failure.trace.command ? { command: failure.trace.command } : {},
|
|
2054
|
-
...failure.trace.capability ? { capability: failure.trace.capability } : {},
|
|
2055
|
-
...failure.trace.missing_capability ? { missing_capability: failure.trace.missing_capability } : {},
|
|
2056
|
-
...failure.trace.hint ? { hint: failure.trace.hint } : {}
|
|
2057
|
-
} : void 0;
|
|
2058
|
-
return {
|
|
2059
|
-
layer: failure.layer,
|
|
2060
|
-
name: failure.name,
|
|
2061
|
-
entry_path: failure.entry_path,
|
|
2062
|
-
error: failure.error,
|
|
2063
|
-
...failure.trace?.missing_capability ? { missing_capability: failure.trace.missing_capability } : {},
|
|
2064
|
-
...failure.trace?.hint ? { hint: failure.trace.hint } : {},
|
|
2065
|
-
...trace ? { trace } : {}
|
|
2066
|
-
};
|
|
2067
|
-
}
|
|
2068
|
-
function collectActivationFailureDiagnostics(failures) {
|
|
2069
|
-
return failures.map((failure) => summarizeActivationFailureForDiagnostics(failure)).sort((left, right) => `${left.layer}:${left.name}`.localeCompare(`${right.layer}:${right.name}`));
|
|
2070
|
-
}
|
|
2071
|
-
function findActivationFailureByName(extensionName, failures, layer) {
|
|
2072
|
-
const normalizedName = normalizeExtensionNameForMatch(extensionName);
|
|
2073
|
-
return failures.find((failure) => (layer === void 0 || failure.layer === layer) && normalizeExtensionNameForMatch(failure.name) === normalizedName);
|
|
2074
|
-
}
|
|
2075
|
-
function resolveInstallRuntimeActivationStatus(extensionName, scope, runtimeInstalled, installActivationFailure) {
|
|
2076
|
-
const runtimeInstalledExtension = runtimeInstalled.find((entry) => entry.scope === scope && normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(extensionName));
|
|
2077
|
-
return runtimeInstalledExtension?.activation_status ?? (installActivationFailure ? "failed" : "unknown");
|
|
2078
|
-
}
|
|
2079
|
-
async function probeRuntimeCommandPathsForInstall(pmRoot, settings, refreshedInstalled, global2) {
|
|
2080
|
-
const loadResult = await loadExtensions({
|
|
2081
|
-
pmRoot,
|
|
2082
|
-
settings,
|
|
2083
|
-
cwd: process.cwd(),
|
|
2084
|
-
noExtensions: global2.noExtensions === true,
|
|
2085
|
-
reload_token: nextExtensionReloadToken(),
|
|
2086
|
-
cache_bust: true
|
|
2087
|
-
});
|
|
2088
|
-
const activationResult = await activateExtensions({
|
|
2089
|
-
...loadResult,
|
|
2090
|
-
loaded: loadResult.loaded
|
|
2091
|
-
});
|
|
2092
|
-
return {
|
|
2093
|
-
installed: applyDoctorRuntimeActivationState(refreshedInstalled, loadResult, activationResult),
|
|
2094
|
-
warnings: [...loadResult.warnings, ...activationResult.warnings],
|
|
2095
|
-
activation_failures: collectActivationFailureDiagnostics(activationResult.failed),
|
|
2096
|
-
item_type_registrations: activationResult.registrations.item_types
|
|
2097
|
-
};
|
|
2098
|
-
}
|
|
2099
|
-
async function checkGithubUpdate(source, gitCommandRunner = runGitCommand) {
|
|
2100
|
-
const checkedAt = nowIso();
|
|
2101
|
-
if (source.kind !== "github" || !source.repository) {
|
|
2102
|
-
return {
|
|
2103
|
-
checked_at: checkedAt,
|
|
2104
|
-
available: null,
|
|
2105
|
-
error: "not_a_github_managed_source"
|
|
2106
|
-
};
|
|
2107
|
-
}
|
|
2108
|
-
try {
|
|
2109
|
-
const ref = source.ref && source.ref.trim().length > 0 ? source.ref.trim() : "HEAD";
|
|
2110
|
-
const output = await gitCommandRunner(["ls-remote", source.repository, ref]);
|
|
2111
|
-
const firstLine = output.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0);
|
|
2112
|
-
if (!firstLine) {
|
|
2113
|
-
return {
|
|
2114
|
-
checked_at: checkedAt,
|
|
2115
|
-
available: null,
|
|
2116
|
-
error: "no_remote_reference_found"
|
|
2117
|
-
};
|
|
2118
|
-
}
|
|
2119
|
-
const [remoteCommit] = firstLine.split(/\s+/);
|
|
2120
|
-
if (typeof remoteCommit !== "string" || remoteCommit.length === 0) {
|
|
2121
|
-
return {
|
|
2122
|
-
checked_at: checkedAt,
|
|
2123
|
-
available: null,
|
|
2124
|
-
error: "invalid_remote_reference"
|
|
2125
|
-
};
|
|
2126
|
-
}
|
|
2127
|
-
if (typeof source.commit === "string" && source.commit.trim().length > 0) {
|
|
2128
|
-
return {
|
|
2129
|
-
checked_at: checkedAt,
|
|
2130
|
-
remote_commit: remoteCommit,
|
|
2131
|
-
available: remoteCommit !== source.commit.trim()
|
|
2132
|
-
};
|
|
2133
|
-
}
|
|
2134
|
-
return {
|
|
2135
|
-
checked_at: checkedAt,
|
|
2136
|
-
remote_commit: remoteCommit,
|
|
2137
|
-
available: null,
|
|
2138
|
-
error: "missing_installed_commit"
|
|
2139
|
-
};
|
|
2140
|
-
} catch (error) {
|
|
2141
|
-
return {
|
|
2142
|
-
checked_at: checkedAt,
|
|
2143
|
-
available: null,
|
|
2144
|
-
error: error instanceof Error ? error.message : String(error)
|
|
2145
|
-
};
|
|
2146
|
-
}
|
|
2147
|
-
}
|
|
2148
|
-
async function adoptUnmanagedExtensions(extensionsRoot, scope, installedExtensions, state) {
|
|
2149
|
-
const unmanagedCandidates = installedExtensions.filter((entry) => !entry.managed);
|
|
2150
|
-
const sortedCandidates = [...unmanagedCandidates].sort((left, right) => {
|
|
2151
|
-
const byName = left.name.localeCompare(right.name);
|
|
2152
|
-
if (byName !== 0) {
|
|
2153
|
-
return byName;
|
|
2154
|
-
}
|
|
2155
|
-
return left.directory.localeCompare(right.directory);
|
|
2156
|
-
});
|
|
2157
|
-
let nextState = state;
|
|
2158
|
-
const adoptedEntries = [];
|
|
2159
|
-
for (const candidate of sortedCandidates) {
|
|
2160
|
-
const extensionDirectory = path4.join(extensionsRoot, candidate.directory);
|
|
2161
|
-
const validated = await validateExtensionDirectory(extensionDirectory);
|
|
2162
|
-
const now = nowIso();
|
|
2163
|
-
const sourceRecord = {
|
|
2164
|
-
kind: "local",
|
|
2165
|
-
input: candidate.name,
|
|
2166
|
-
location: extensionDirectory
|
|
2167
|
-
};
|
|
2168
|
-
nextState = upsertManagedEntry(nextState, {
|
|
2169
|
-
name: validated.manifest.name,
|
|
2170
|
-
directory: candidate.directory,
|
|
2171
|
-
scope,
|
|
2172
|
-
manifest_version: validated.manifest.version,
|
|
2173
|
-
manifest_entry: validated.manifest.entry,
|
|
2174
|
-
capabilities: [...validated.manifest.capabilities],
|
|
2175
|
-
installed_at: now,
|
|
2176
|
-
updated_at: now,
|
|
2177
|
-
source: sourceRecord
|
|
2178
|
-
});
|
|
2179
|
-
adoptedEntries.push({
|
|
2180
|
-
name: validated.manifest.name,
|
|
2181
|
-
directory: candidate.directory,
|
|
2182
|
-
version: validated.manifest.version,
|
|
2183
|
-
entry: validated.manifest.entry,
|
|
2184
|
-
source: sourceRecord
|
|
2185
|
-
});
|
|
2186
|
-
}
|
|
2187
|
-
if (adoptedEntries.length > 0) {
|
|
2188
|
-
await writeManagedExtensionState(extensionsRoot, nextState);
|
|
2189
|
-
}
|
|
2190
|
-
return {
|
|
2191
|
-
state: nextState,
|
|
2192
|
-
adopted_entries: adoptedEntries,
|
|
2193
|
-
unmanaged_candidates: sortedCandidates,
|
|
2194
|
-
already_managed_count: installedExtensions.length - unmanagedCandidates.length
|
|
2195
|
-
};
|
|
2196
|
-
}
|
|
2197
|
-
function resolveExtensionRootsForScope(scope, global2) {
|
|
2198
|
-
const pmRoot = resolvePmRoot(process.cwd(), global2.path);
|
|
2199
|
-
const roots = resolveExtensionRoots(pmRoot, process.cwd());
|
|
2200
|
-
const settingsRoot = scope === "global" ? resolveGlobalPmRoot(process.cwd()) : pmRoot;
|
|
2201
|
-
const selectedRoot = scope === "global" ? roots.global : roots.project;
|
|
2202
|
-
return {
|
|
2203
|
-
pm_root: pmRoot,
|
|
2204
|
-
scope,
|
|
2205
|
-
settings_root: settingsRoot,
|
|
2206
|
-
selected_root: selectedRoot,
|
|
2207
|
-
roots
|
|
2208
|
-
};
|
|
2209
|
-
}
|
|
2210
|
-
function resolveGithubOption(options) {
|
|
2211
|
-
if (typeof options.gh === "string" && typeof options.github === "string" && options.gh.trim() !== options.github.trim()) {
|
|
2212
|
-
throw new PmCliError('Options "--gh" and "--github" must match when both are provided.', EXIT_CODE.USAGE);
|
|
2213
|
-
}
|
|
2214
|
-
if (typeof options.gh === "string" && options.gh.trim().length > 0) {
|
|
2215
|
-
return options.gh.trim();
|
|
2216
|
-
}
|
|
2217
|
-
if (typeof options.github === "string" && options.github.trim().length > 0) {
|
|
2218
|
-
return options.github.trim();
|
|
2219
|
-
}
|
|
2220
|
-
return void 0;
|
|
2221
|
-
}
|
|
2222
|
-
function getLifecycleActionFlag(action) {
|
|
2223
|
-
return LIFECYCLE_ACTION_FLAGS[action];
|
|
2224
|
-
}
|
|
2225
|
-
function requireTarget(target, action, options = {}) {
|
|
2226
|
-
const normalized = target?.trim();
|
|
2227
|
-
if (!normalized) {
|
|
2228
|
-
if (action === "init") {
|
|
2229
|
-
throw new PmCliError('Action "init" requires a scaffold target path (for example: pm package init ./my-package or pm extension init ./my-extension).', EXIT_CODE.USAGE);
|
|
2230
|
-
}
|
|
2231
|
-
const noun = options.vocabulary === "package" ? "package" : "extension";
|
|
2232
|
-
const targetName = action === "install" ? "source" : "name";
|
|
2233
|
-
const targetLabel = `${noun} ${targetName}`;
|
|
2234
|
-
const actionFlag = getLifecycleActionFlag(action);
|
|
2235
|
-
const commandTarget = `<${targetName}>`;
|
|
2236
|
-
const command = `pm ${noun} ${actionFlag} ${commandTarget}`;
|
|
2237
|
-
throw new PmCliError(`Action "${action}" requires ${targetLabel} input.`, EXIT_CODE.USAGE, {
|
|
2238
|
-
code: "missing_lifecycle_target",
|
|
2239
|
-
required: `Provide a ${targetName} target for ${action}.`,
|
|
2240
|
-
examples: [`pm ${noun} ${action} ${commandTarget}`, command, `pm ${noun} --help`],
|
|
2241
|
-
recovery: {
|
|
2242
|
-
attempted_command: `pm ${noun} ${action}`,
|
|
2243
|
-
suggested_retry: command,
|
|
2244
|
-
fallback_candidates: [
|
|
2245
|
-
{
|
|
2246
|
-
source: "lifecycle_action",
|
|
2247
|
-
command,
|
|
2248
|
-
reason: `flag-form ${action} command with required ${targetName} target`
|
|
2249
|
-
}
|
|
2250
|
-
]
|
|
2251
|
-
}
|
|
2252
|
-
});
|
|
2253
|
-
}
|
|
2254
|
-
return normalized;
|
|
2255
|
-
}
|
|
2256
|
-
function collectGlobalOutputOverrideDoctorWarnings(activationResult) {
|
|
2257
|
-
const warnings = [];
|
|
2258
|
-
for (const entry of activationResult.services.overrides) {
|
|
2259
|
-
if (entry.service !== "output_format") {
|
|
2260
|
-
continue;
|
|
2261
|
-
}
|
|
2262
|
-
warnings.push(`extension_output_service_override_global:${entry.service}:${entry.layer}:${entry.name}`);
|
|
2263
|
-
}
|
|
2264
|
-
for (const entry of activationResult.renderers.overrides) {
|
|
2265
|
-
warnings.push(`extension_output_renderer_override_global:${entry.format}:${entry.layer}:${entry.name}`);
|
|
2266
|
-
}
|
|
2267
|
-
return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
|
|
2268
|
-
}
|
|
2269
|
-
function collectSchemaNarrowActivationDoctorWarnings(loadResult, activationResult) {
|
|
2270
|
-
const schemaContributors = /* @__PURE__ */ new Set();
|
|
2271
|
-
for (const entry of activationResult.registrations.item_types) {
|
|
2272
|
-
if (entry.types.length > 0) {
|
|
2273
|
-
schemaContributors.add(`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`);
|
|
2274
|
-
}
|
|
2275
|
-
}
|
|
2276
|
-
for (const entry of activationResult.registrations.item_fields) {
|
|
2277
|
-
if (entry.fields.length > 0) {
|
|
2278
|
-
schemaContributors.add(`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`);
|
|
2279
|
-
}
|
|
2280
|
-
}
|
|
2281
|
-
const warnings = [];
|
|
2282
|
-
for (const extension of loadResult.loaded) {
|
|
2283
|
-
if ((extension.activation?.commands ?? []).length === 0) {
|
|
2284
|
-
continue;
|
|
2285
|
-
}
|
|
2286
|
-
if (schemaContributors.has(`${extension.layer}:${normalizeExtensionNameForMatch(extension.name)}`)) {
|
|
2287
|
-
warnings.push(`extension_schema_narrow_activation:${extension.layer}:${extension.name}`);
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
|
|
2291
|
-
}
|
|
2292
|
-
function assertExtensionActionOptionScope(action, options) {
|
|
2293
|
-
const guards = [
|
|
2294
|
-
{
|
|
2295
|
-
triggered: options.strictExit === true || options.failOnWarn === true,
|
|
2296
|
-
allowed: action === "doctor",
|
|
2297
|
-
message: "--strict-exit and --fail-on-warn are only valid with --doctor."
|
|
2298
|
-
},
|
|
2299
|
-
{ triggered: options.trace === true, allowed: action === "doctor", message: "--trace is only valid with --doctor." },
|
|
2300
|
-
{ triggered: options.watch === true, allowed: action === "reload", message: "--watch is only valid with --reload." },
|
|
2301
|
-
{
|
|
2302
|
-
triggered: options.runtimeProbe === true,
|
|
2303
|
-
allowed: action === "manage",
|
|
2304
|
-
message: "--runtime-probe is only valid with --manage."
|
|
2305
|
-
},
|
|
2306
|
-
{
|
|
2307
|
-
triggered: options.fixManagedState === true,
|
|
2308
|
-
allowed: action === "manage" || action === "doctor",
|
|
2309
|
-
message: "--fix-managed-state is only valid with --manage or --doctor."
|
|
2310
|
-
},
|
|
2311
|
-
{
|
|
2312
|
-
triggered: options.capability !== void 0,
|
|
2313
|
-
allowed: action === "init",
|
|
2314
|
-
message: "--capability is only valid with --init/--scaffold."
|
|
2315
|
-
},
|
|
2316
|
-
{
|
|
2317
|
-
triggered: options.declarative === true,
|
|
2318
|
-
allowed: action === "init",
|
|
2319
|
-
message: "--declarative is only valid with --init/--scaffold."
|
|
2320
|
-
}
|
|
2321
|
-
];
|
|
2322
|
-
for (const guard of guards) {
|
|
2323
|
-
if (guard.triggered && !guard.allowed) {
|
|
2324
|
-
throw new PmCliError(guard.message, EXIT_CODE.USAGE);
|
|
2325
|
-
}
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
function resolveNormalizedExtensionTarget(target, action, options) {
|
|
2329
|
-
const normalizedInput = target?.trim().toLowerCase();
|
|
2330
|
-
if (action === "doctor" && normalizedInput === "doctor") {
|
|
2331
|
-
return void 0;
|
|
2332
|
-
}
|
|
2333
|
-
if (action === "reload" && normalizedInput === "reload") {
|
|
2334
|
-
return void 0;
|
|
2335
|
-
}
|
|
2336
|
-
if (action === "catalog" && normalizedInput === "catalog") {
|
|
2337
|
-
return void 0;
|
|
2338
|
-
}
|
|
2339
|
-
const inferredInitAlias = action === "init" && options.init !== true && options.scaffold !== true && (normalizedInput === "init" || normalizedInput === "scaffold");
|
|
2340
|
-
if (inferredInitAlias) {
|
|
2341
|
-
return void 0;
|
|
2342
|
-
}
|
|
2343
|
-
return target;
|
|
2344
|
-
}
|
|
2345
|
-
async function runExtension(target, options, global2) {
|
|
2346
|
-
const action = resolveAction(target, options);
|
|
2347
|
-
assertExtensionActionOptionScope(action, options);
|
|
2348
|
-
const normalizedTarget = resolveNormalizedExtensionTarget(target, action, options);
|
|
2349
|
-
const scope = resolveScope(options);
|
|
2350
|
-
const resolvedRoots = resolveExtensionRootsForScope(scope, global2);
|
|
2351
|
-
const warnings = [];
|
|
2352
|
-
const withResult = (details) => {
|
|
2353
|
-
const result = {
|
|
2354
|
-
ok: true,
|
|
2355
|
-
action,
|
|
2356
|
-
scope,
|
|
2357
|
-
roots: action === "catalog" && typeof options.fields === "string" && options.fields.trim().length > 0 ? {
|
|
2358
|
-
project: "project",
|
|
2359
|
-
global: "global",
|
|
2360
|
-
selected: scope,
|
|
2361
|
-
settings_root: "project"
|
|
2362
|
-
} : {
|
|
2363
|
-
project: resolvedRoots.roots.project,
|
|
2364
|
-
global: resolvedRoots.roots.global,
|
|
2365
|
-
selected: resolvedRoots.selected_root,
|
|
2366
|
-
settings_root: resolvedRoots.settings_root
|
|
2367
|
-
},
|
|
2368
|
-
warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),
|
|
2369
|
-
details
|
|
2370
|
-
};
|
|
2371
|
-
if (action === "doctor") {
|
|
2372
|
-
Object.defineProperty(result, NATIVE_OUTPUT_MARKER, {
|
|
2373
|
-
value: true,
|
|
2374
|
-
enumerable: false,
|
|
2375
|
-
configurable: false
|
|
2376
|
-
});
|
|
2377
|
-
}
|
|
2378
|
-
return result;
|
|
2379
|
-
};
|
|
2380
|
-
const ctx = {
|
|
2381
|
-
action,
|
|
2382
|
-
normalizedTarget,
|
|
2383
|
-
scope,
|
|
2384
|
-
resolvedRoots,
|
|
2385
|
-
warnings,
|
|
2386
|
-
options,
|
|
2387
|
-
global: global2,
|
|
2388
|
-
withResult
|
|
2389
|
-
};
|
|
2390
|
-
return EXTENSION_ACTION_HANDLERS[action](ctx);
|
|
2391
|
-
}
|
|
2392
|
-
async function runExtensionInitAction(ctx) {
|
|
2393
|
-
const { action, normalizedTarget, options, withResult } = ctx;
|
|
2394
|
-
const githubOption = resolveGithubOption(options);
|
|
2395
|
-
if (githubOption !== void 0 || typeof options.ref === "string" && options.ref.trim().length > 0) {
|
|
2396
|
-
throw new PmCliError('Action "init" does not accept --gh/--github/--ref options.', EXIT_CODE.USAGE);
|
|
2397
|
-
}
|
|
2398
|
-
const scaffoldTarget = requireTarget(normalizedTarget, action, options);
|
|
2399
|
-
const scaffold = await scaffoldExtensionProject(scaffoldTarget, options.vocabulary ?? "extension", options.capability, options.declarative === true);
|
|
2400
|
-
const quotedTargetPath = JSON.stringify(scaffold.target_path);
|
|
2401
|
-
const quotedShellTargetPath = JSON.stringify(scaffold.target_path.replace(/\\/g, "/"));
|
|
2402
|
-
return withResult({
|
|
2403
|
-
scaffolded: scaffold.created_directory || scaffold.files.some((entry) => entry.status === "created"),
|
|
2404
|
-
extension: {
|
|
2405
|
-
name: scaffold.extension_name,
|
|
2406
|
-
command: scaffold.command_name
|
|
2407
|
-
},
|
|
2408
|
-
capability: scaffold.capability,
|
|
2409
|
-
style: scaffold.style,
|
|
2410
|
-
target_path: scaffold.target_path,
|
|
2411
|
-
created_directory: scaffold.created_directory,
|
|
2412
|
-
files: scaffold.files,
|
|
2413
|
-
next_steps: [
|
|
2414
|
-
// Extensions are authored AND loaded as TypeScript (ADR pm-2c28 / pm-m1uz):
|
|
2415
|
-
// the manifest entry is ./index.ts and pm strips types on load (Node
|
|
2416
|
-
// >=22.18), so there is no compile/build step — install dependencies, then
|
|
2417
|
-
// install the scaffold directly.
|
|
2418
|
-
...options.vocabulary === "package" ? [`Install dependencies: cd ${quotedShellTargetPath}, then run "npm install"`] : [
|
|
2419
|
-
`Install type-check dependencies: cd ${quotedShellTargetPath}, then run "npm install -D typescript @types/node @unbrained/pm-cli"`
|
|
2420
|
-
],
|
|
2421
|
-
`Install the scaffold: ${options.vocabulary === "package" ? "pm install --project" : "pm extension --install --project"} ${quotedTargetPath}`,
|
|
2422
|
-
`Smoke-test command path: pm ${scaffold.command_name}`,
|
|
2423
|
-
...options.vocabulary === "package" ? [`Validate the package: cd ${quotedShellTargetPath}, then run "npm run typecheck" and "npm test"`] : [`Type-check the source (optional): cd ${quotedShellTargetPath}, then run "npx tsc --noEmit"`],
|
|
2424
|
-
`Run diagnostics: ${options.vocabulary === "package" ? "pm package doctor" : "pm extension --doctor"} --project --detail summary`
|
|
2425
|
-
]
|
|
2426
|
-
});
|
|
2427
|
-
}
|
|
2428
|
-
async function runExtensionReloadAction(ctx) {
|
|
2429
|
-
const { normalizedTarget, resolvedRoots, warnings, options, global: global2, withResult } = ctx;
|
|
2430
|
-
if (normalizedTarget !== void 0) {
|
|
2431
|
-
throw new PmCliError('Action "reload" does not accept a target argument.', EXIT_CODE.USAGE);
|
|
2432
|
-
}
|
|
2433
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2434
|
-
const reloadToken = nextExtensionReloadToken();
|
|
2435
|
-
const reloaded = await loadExtensions({
|
|
2436
|
-
pmRoot: resolvedRoots.settings_root,
|
|
2437
|
-
settings,
|
|
2438
|
-
cwd: process.cwd(),
|
|
2439
|
-
noExtensions: global2.noExtensions,
|
|
2440
|
-
reload_token: reloadToken,
|
|
2441
|
-
cache_bust: true
|
|
2442
|
-
});
|
|
2443
|
-
warnings.push(...reloaded.warnings);
|
|
2444
|
-
const activation = await activateExtensions(reloaded);
|
|
2445
|
-
warnings.push(...activation.warnings);
|
|
2446
|
-
const details = {
|
|
2447
|
-
reload: {
|
|
2448
|
-
token: reloadToken,
|
|
2449
|
-
cache_bust: true,
|
|
2450
|
-
watch: options.watch === true
|
|
2451
|
-
},
|
|
2452
|
-
loaded_count: reloaded.loaded.length,
|
|
2453
|
-
failed_count: reloaded.failed.length,
|
|
2454
|
-
activated_count: Math.max(0, reloaded.loaded.length - activation.failed.length),
|
|
2455
|
-
activation_failed_count: activation.failed.length,
|
|
2456
|
-
loaded_extensions: reloaded.loaded.map((entry) => ({
|
|
2457
|
-
name: entry.name,
|
|
2458
|
-
layer: entry.layer,
|
|
2459
|
-
version: entry.version
|
|
2460
|
-
})),
|
|
2461
|
-
failed_extensions: reloaded.failed.map((entry) => ({
|
|
2462
|
-
name: entry.name,
|
|
2463
|
-
layer: entry.layer,
|
|
2464
|
-
error: entry.error
|
|
2465
|
-
})),
|
|
2466
|
-
activation_failures: activation.failed.map((entry) => ({
|
|
2467
|
-
name: entry.name,
|
|
2468
|
-
layer: entry.layer,
|
|
2469
|
-
error: entry.error
|
|
2470
|
-
}))
|
|
2471
|
-
};
|
|
2472
|
-
if (options.watch === true) {
|
|
2473
|
-
warnings.push("extension_reload_watch_hint:watch_mode_requested_non_interactive_single_pass_only");
|
|
2474
|
-
}
|
|
2475
|
-
return withResult(details);
|
|
2476
|
-
}
|
|
2477
|
-
async function runExtensionCatalogAction(ctx) {
|
|
2478
|
-
const { normalizedTarget, scope, options, global: global2, withResult } = ctx;
|
|
2479
|
-
if (typeof normalizedTarget === "string" && normalizedTarget.length > 0 && normalizedTarget !== "catalog") {
|
|
2480
|
-
throw new PmCliError('Action "catalog" does not accept a package target.', EXIT_CODE.USAGE);
|
|
2481
|
-
}
|
|
2482
|
-
return withResult(await buildBundledPackageCatalog(scope, global2, options));
|
|
2483
|
-
}
|
|
2484
|
-
function buildInstallManagedSource(bundledAliasName, bundledPackageName, installSource, resolvedSource) {
|
|
2485
|
-
if (bundledAliasName) {
|
|
2486
|
-
return {
|
|
2487
|
-
kind: "builtin",
|
|
2488
|
-
input: bundledAliasName,
|
|
2489
|
-
location: bundledAliasName,
|
|
2490
|
-
name: bundledAliasName,
|
|
2491
|
-
...bundledPackageName === null ? {} : { package: bundledPackageName }
|
|
2492
|
-
};
|
|
2493
|
-
}
|
|
2494
|
-
if (installSource.kind === "local") {
|
|
2495
|
-
return {
|
|
2496
|
-
kind: "local",
|
|
2497
|
-
input: installSource.input,
|
|
2498
|
-
location: installSource.absolute_path
|
|
2499
|
-
};
|
|
2500
|
-
}
|
|
2501
|
-
if (installSource.kind === "npm") {
|
|
2502
|
-
return {
|
|
2503
|
-
kind: "npm",
|
|
2504
|
-
input: installSource.input,
|
|
2505
|
-
location: resolvedSource.resolved_subpath ?? ".",
|
|
2506
|
-
package: resolvedSource.npm_package,
|
|
2507
|
-
version: resolvedSource.npm_version
|
|
2508
|
-
};
|
|
2509
|
-
}
|
|
2510
|
-
return {
|
|
2511
|
-
kind: "github",
|
|
2512
|
-
input: installSource.input,
|
|
2513
|
-
location: resolvedSource.resolved_subpath ?? installSource.subpath ?? ".",
|
|
2514
|
-
repository: installSource.repository,
|
|
2515
|
-
owner: installSource.owner,
|
|
2516
|
-
repo: installSource.repo,
|
|
2517
|
-
ref: installSource.ref,
|
|
2518
|
-
subpath: resolvedSource.resolved_subpath ?? installSource.subpath,
|
|
2519
|
-
commit: resolvedSource.commit
|
|
2520
|
-
};
|
|
2521
|
-
}
|
|
2522
|
-
async function performExtensionInstallUnderLock(ctx, input) {
|
|
2523
|
-
const { scope, resolvedRoots, warnings, global: global2, withResult } = ctx;
|
|
2524
|
-
const { validated, destinationDirectoryName, bundledAliasName, bundledPackageName, installSource, resolvedSource } = input;
|
|
2525
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2526
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
2527
|
-
warnings.push(...managedStateRead.warnings);
|
|
2528
|
-
const destinationDirectory = path4.join(resolvedRoots.selected_root, destinationDirectoryName);
|
|
2529
|
-
const destinationExists = await pathExists(destinationDirectory);
|
|
2530
|
-
const installInPlace = await areDirectoriesEquivalent(validated.directory, destinationDirectory);
|
|
2531
|
-
await fs4.mkdir(resolvedRoots.selected_root, { recursive: true });
|
|
2532
|
-
if (!installInPlace) {
|
|
2533
|
-
await copyExtensionDirectoryForInstall(validated.directory, destinationDirectory);
|
|
2534
|
-
}
|
|
2535
|
-
await ensureExtensionModuleTypeMarker(destinationDirectory);
|
|
2536
|
-
const sourceRecord = buildInstallManagedSource(bundledAliasName, bundledPackageName, installSource, resolvedSource);
|
|
2537
|
-
const now = nowIso();
|
|
2538
|
-
const existingManagedEntry = managedStateRead.state.entries.find((entry) => normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(validated.manifest.name));
|
|
2539
|
-
const sourceUnchanged = existingManagedEntry !== void 0 && existingManagedEntry.manifest_version === validated.manifest.version && managedExtensionSourcesEquivalent(existingManagedEntry.source, sourceRecord);
|
|
2540
|
-
const managedState = upsertManagedEntry(managedStateRead.state, {
|
|
2541
|
-
name: validated.manifest.name,
|
|
2542
|
-
directory: destinationDirectoryName,
|
|
2543
|
-
scope,
|
|
2544
|
-
manifest_version: validated.manifest.version,
|
|
2545
|
-
manifest_entry: validated.manifest.entry,
|
|
2546
|
-
capabilities: [...validated.manifest.capabilities],
|
|
2547
|
-
installed_at: existingManagedEntry?.installed_at ?? now,
|
|
2548
|
-
updated_at: sourceUnchanged ? existingManagedEntry.updated_at : now,
|
|
2549
|
-
source: sourceRecord
|
|
2550
|
-
});
|
|
2551
|
-
await writeManagedExtensionState(resolvedRoots.selected_root, managedState);
|
|
2552
|
-
const activationChanged = ensureActivated(settings, validated.manifest.name);
|
|
2553
|
-
if (activationChanged) {
|
|
2554
|
-
await writeSettings(resolvedRoots.settings_root, settings, "settings:write");
|
|
2555
|
-
}
|
|
2556
|
-
const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
|
|
2557
|
-
warnings.push(...refreshedInstalled.warnings);
|
|
2558
|
-
const runtimeProbe = await probeRuntimeCommandPathsForInstall(resolvedRoots.pm_root, settings, refreshedInstalled.extensions, global2);
|
|
2559
|
-
warnings.push(...runtimeProbe.warnings);
|
|
2560
|
-
const installedItemTypeDefinitions = runtimeProbe.item_type_registrations.filter((entry) => normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(validated.manifest.name)).flatMap((entry) => entry.types.map((type) => ({ name: type.name, folder: type.folder })));
|
|
2561
|
-
if (scope === "project" && installedItemTypeDefinitions.length > 0) {
|
|
2562
|
-
await ensureTypeFolderScaffold(resolvedRoots.pm_root, installedItemTypeDefinitions, warnings, "install:type-folder");
|
|
2563
|
-
}
|
|
2564
|
-
const commandSummary = summarizeRuntimeCommandPathsForExtension(validated.manifest.name, runtimeProbe.installed);
|
|
2565
|
-
const installActivationFailure = findActivationFailureByName(validated.manifest.name, runtimeProbe.activation_failures, scope);
|
|
2566
|
-
const runtimeActivationStatus = resolveInstallRuntimeActivationStatus(validated.manifest.name, scope, runtimeProbe.installed, installActivationFailure);
|
|
2567
|
-
return withResult({
|
|
2568
|
-
extension: {
|
|
2569
|
-
name: validated.manifest.name,
|
|
2570
|
-
version: validated.manifest.version,
|
|
2571
|
-
entry: validated.manifest.entry,
|
|
2572
|
-
capabilities: validated.manifest.capabilities,
|
|
2573
|
-
directory: destinationDirectoryName
|
|
2574
|
-
},
|
|
2575
|
-
source: sourceRecord,
|
|
2576
|
-
destination_path: destinationDirectory,
|
|
2577
|
-
overwritten: destinationExists && !installInPlace,
|
|
2578
|
-
installed_in_place: installInPlace,
|
|
2579
|
-
activated: true,
|
|
2580
|
-
settings_changed: activationChanged,
|
|
2581
|
-
runtime_activation_status: runtimeActivationStatus,
|
|
2582
|
-
command_paths: commandSummary.command_paths,
|
|
2583
|
-
action_paths: commandSummary.action_paths,
|
|
2584
|
-
command_discovery: buildInstallCommandDiscovery(validated.manifest.name, sourceRecord, commandSummary),
|
|
2585
|
-
activation_diagnostics: {
|
|
2586
|
-
failed_count: runtimeProbe.activation_failures.length,
|
|
2587
|
-
failed: runtimeProbe.activation_failures,
|
|
2588
|
-
installed_extension_failed: installActivationFailure ?? null
|
|
2589
|
-
}
|
|
2590
|
-
});
|
|
2591
|
-
}
|
|
2592
|
-
async function runExtensionInstallAction(ctx) {
|
|
2593
|
-
const { action, normalizedTarget, resolvedRoots, warnings, options, global: global2, withResult } = ctx;
|
|
2594
|
-
const githubOption = resolveGithubOption(options);
|
|
2595
|
-
const explicitSourceInput = githubOption ?? requireTarget(normalizedTarget, action, options);
|
|
2596
|
-
if (typeof githubOption !== "string" && isBundledPackageInstallAllTarget(explicitSourceInput)) {
|
|
2597
|
-
if (typeof options.ref === "string" && options.ref.trim().length > 0) {
|
|
2598
|
-
throw new PmCliError('Action "install all" does not accept --ref.', EXIT_CODE.USAGE);
|
|
2599
|
-
}
|
|
2600
|
-
const aliases = await listBundledPackageAliases();
|
|
2601
|
-
const packages = [];
|
|
2602
|
-
for (const alias of aliases) {
|
|
2603
|
-
packages.push({
|
|
2604
|
-
alias,
|
|
2605
|
-
result: await runExtension(alias, { ...options, install: true }, global2)
|
|
2606
|
-
});
|
|
2607
|
-
}
|
|
2608
|
-
for (const entry of packages) {
|
|
2609
|
-
warnings.push(...entry.result.warnings);
|
|
2610
|
-
}
|
|
2611
|
-
return withResult({
|
|
2612
|
-
installed_all: true,
|
|
2613
|
-
installed_count: packages.length,
|
|
2614
|
-
packages: packages.map((entry) => ({
|
|
2615
|
-
alias: entry.alias,
|
|
2616
|
-
ok: entry.result.ok,
|
|
2617
|
-
extension: entry.result.details.extension,
|
|
2618
|
-
source: entry.result.details.source,
|
|
2619
|
-
destination_path: entry.result.details.destination_path,
|
|
2620
|
-
activated: entry.result.details.activated,
|
|
2621
|
-
settings_changed: entry.result.details.settings_changed,
|
|
2622
|
-
command_paths: entry.result.details.command_paths,
|
|
2623
|
-
action_paths: entry.result.details.action_paths,
|
|
2624
|
-
command_discovery: entry.result.details.command_discovery,
|
|
2625
|
-
warnings: entry.result.warnings
|
|
2626
|
-
}))
|
|
2627
|
-
});
|
|
2628
|
-
}
|
|
2629
|
-
const bundledAliasSource = typeof githubOption === "string" ? null : await resolveBundledExtensionAliasSource(explicitSourceInput);
|
|
2630
|
-
const bundledAliasName = bundledAliasSource === null ? null : explicitSourceInput.trim().toLowerCase();
|
|
2631
|
-
const bundledPackageName = bundledAliasName === null ? null : await resolveBundledPackageNpmName(bundledAliasName);
|
|
2632
|
-
const sourceInput = bundledAliasSource ?? explicitSourceInput;
|
|
2633
|
-
const installSource = parseExtensionInstallSource(sourceInput, {
|
|
2634
|
-
forceGithub: typeof githubOption === "string",
|
|
2635
|
-
ref: options.ref
|
|
2636
|
-
});
|
|
2637
|
-
const resolvedSource = await resolveInstallSource(installSource);
|
|
2638
|
-
try {
|
|
2639
|
-
const validated = await validateExtensionDirectory(resolvedSource.directory);
|
|
2640
|
-
const destinationDirectoryName = normalizeManagedDirectoryName(validated.manifest.name);
|
|
2641
|
-
return await withExtensionInstallLock(resolvedRoots.settings_root, destinationDirectoryName, () => performExtensionInstallUnderLock(ctx, {
|
|
2642
|
-
validated,
|
|
2643
|
-
destinationDirectoryName,
|
|
2644
|
-
bundledAliasName,
|
|
2645
|
-
bundledPackageName,
|
|
2646
|
-
installSource,
|
|
2647
|
-
resolvedSource
|
|
2648
|
-
}));
|
|
2649
|
-
} finally {
|
|
2650
|
-
if (resolvedSource.cleanup) {
|
|
2651
|
-
await resolvedSource.cleanup();
|
|
2652
|
-
}
|
|
2653
|
-
}
|
|
2654
|
-
}
|
|
2655
|
-
async function runExtensionAdoptAllAction(ctx) {
|
|
2656
|
-
const { normalizedTarget, scope, resolvedRoots, warnings, options, withResult } = ctx;
|
|
2657
|
-
if (normalizedTarget !== void 0) {
|
|
2658
|
-
throw new PmCliError('Action "adopt-all" does not accept a target argument.', EXIT_CODE.USAGE);
|
|
2659
|
-
}
|
|
2660
|
-
const githubOption = resolveGithubOption(options);
|
|
2661
|
-
if (githubOption !== void 0 || typeof options.ref === "string" && options.ref.trim().length > 0) {
|
|
2662
|
-
throw new PmCliError('Action "adopt-all" does not accept --gh/--github/--ref options.', EXIT_CODE.USAGE);
|
|
2663
|
-
}
|
|
2664
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2665
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
2666
|
-
warnings.push(...managedStateRead.warnings);
|
|
2667
|
-
const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
|
|
2668
|
-
warnings.push(...installed.warnings);
|
|
2669
|
-
const adoption = await adoptUnmanagedExtensions(resolvedRoots.selected_root, scope, installed.extensions, managedStateRead.state);
|
|
2670
|
-
const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, adoption.state);
|
|
2671
|
-
warnings.push(...refreshedInstalled.warnings);
|
|
2672
|
-
const triage = buildExtensionTriageSummary(scope, warnings, refreshedInstalled.extensions, options);
|
|
2673
|
-
warnings.push(...triage.warnings);
|
|
2674
|
-
const adoptedDetails = adoption.adopted_entries.map((entry) => {
|
|
2675
|
-
const refreshedEntry = refreshedInstalled.extensions.find((candidate) => normalizeExtensionNameForMatch(candidate.name) === normalizeExtensionNameForMatch(entry.name) && normalizeExtensionNameForMatch(candidate.directory) === normalizeExtensionNameForMatch(entry.directory)) ?? /* c8 ignore next 3 -- fallback only matters if a manifest renames between adopt and refresh */
|
|
2676
|
-
refreshedInstalled.extensions.find((candidate) => normalizeExtensionNameForMatch(candidate.directory) === normalizeExtensionNameForMatch(entry.directory));
|
|
2677
|
-
return {
|
|
2678
|
-
...entry,
|
|
2679
|
-
update_check_status: refreshedEntry?.update_check_status ?? null,
|
|
2680
|
-
update_check_reason: refreshedEntry?.update_check_reason ?? null
|
|
2681
|
-
};
|
|
2682
|
-
});
|
|
2683
|
-
return withResult({
|
|
2684
|
-
adopted_all: adoptedDetails.length > 0,
|
|
2685
|
-
adopted_count: adoptedDetails.length,
|
|
2686
|
-
already_managed_count: adoption.already_managed_count,
|
|
2687
|
-
extensions: adoptedDetails,
|
|
2688
|
-
triage,
|
|
2689
|
-
warning_codes: triage.warning_codes,
|
|
2690
|
-
update_health_partial: triage.update_health_partial,
|
|
2691
|
-
update_health_coverage: triage.update_health_coverage
|
|
2692
|
-
});
|
|
2693
|
-
}
|
|
2694
|
-
async function runExtensionAdoptAction(ctx) {
|
|
2695
|
-
const { action, normalizedTarget, scope, resolvedRoots, warnings, options, withResult } = ctx;
|
|
2696
|
-
const extensionTarget = requireTarget(normalizedTarget, action, options);
|
|
2697
|
-
const githubOption = resolveGithubOption(options);
|
|
2698
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2699
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
2700
|
-
warnings.push(...managedStateRead.warnings);
|
|
2701
|
-
const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
|
|
2702
|
-
warnings.push(...installed.warnings);
|
|
2703
|
-
const candidate = await resolveInstalledExtensionCandidate(installed.extensions, extensionTarget);
|
|
2704
|
-
if (!candidate) {
|
|
2705
|
-
throw new PmCliError(`Installed extension "${extensionTarget}" was not found in ${scope} scope.`, EXIT_CODE.NOT_FOUND);
|
|
2706
|
-
}
|
|
2707
|
-
if (candidate.managed) {
|
|
2708
|
-
return withResult({
|
|
2709
|
-
adopted: false,
|
|
2710
|
-
already_managed: true,
|
|
2711
|
-
extension: {
|
|
2712
|
-
name: candidate.name,
|
|
2713
|
-
directory: candidate.directory
|
|
2714
|
-
}
|
|
2715
|
-
});
|
|
2716
|
-
}
|
|
2717
|
-
const extensionDirectory = path4.join(resolvedRoots.selected_root, candidate.directory);
|
|
2718
|
-
const validated = await validateExtensionDirectory(extensionDirectory);
|
|
2719
|
-
const now = nowIso();
|
|
2720
|
-
const sourceRecord = githubOption === void 0 ? {
|
|
2721
|
-
kind: "local",
|
|
2722
|
-
input: extensionTarget,
|
|
2723
|
-
location: extensionDirectory
|
|
2724
|
-
} : (() => {
|
|
2725
|
-
const parsed = parseExtensionInstallSource(githubOption, {
|
|
2726
|
-
forceGithub: true,
|
|
2727
|
-
ref: options.ref
|
|
2728
|
-
});
|
|
2729
|
-
if (parsed.kind !== "github") {
|
|
2730
|
-
throw new PmCliError(`Invalid GitHub shorthand "${githubOption}".`, EXIT_CODE.USAGE);
|
|
2731
|
-
}
|
|
2732
|
-
return {
|
|
2733
|
-
kind: "github",
|
|
2734
|
-
input: parsed.input,
|
|
2735
|
-
location: parsed.subpath ?? ".",
|
|
2736
|
-
repository: parsed.repository,
|
|
2737
|
-
owner: parsed.owner,
|
|
2738
|
-
repo: parsed.repo,
|
|
2739
|
-
ref: parsed.ref,
|
|
2740
|
-
subpath: parsed.subpath
|
|
2741
|
-
};
|
|
2742
|
-
})();
|
|
2743
|
-
const managedState = upsertManagedEntry(managedStateRead.state, {
|
|
2744
|
-
name: validated.manifest.name,
|
|
2745
|
-
directory: candidate.directory,
|
|
2746
|
-
scope,
|
|
2747
|
-
manifest_version: validated.manifest.version,
|
|
2748
|
-
manifest_entry: validated.manifest.entry,
|
|
2749
|
-
capabilities: [...validated.manifest.capabilities],
|
|
2750
|
-
installed_at: now,
|
|
2751
|
-
updated_at: now,
|
|
2752
|
-
source: sourceRecord
|
|
2753
|
-
});
|
|
2754
|
-
await writeManagedExtensionState(resolvedRoots.selected_root, managedState);
|
|
2755
|
-
const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
|
|
2756
|
-
warnings.push(...refreshedInstalled.warnings);
|
|
2757
|
-
const refreshedEntry = refreshedInstalled.extensions.find((entry) => normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(validated.manifest.name)) ?? refreshedInstalled.extensions.find((entry) => normalizeExtensionNameForMatch(entry.directory) === normalizeExtensionNameForMatch(candidate.directory));
|
|
2758
|
-
return withResult({
|
|
2759
|
-
adopted: true,
|
|
2760
|
-
extension: {
|
|
2761
|
-
name: validated.manifest.name,
|
|
2762
|
-
directory: candidate.directory,
|
|
2763
|
-
version: validated.manifest.version,
|
|
2764
|
-
entry: validated.manifest.entry
|
|
2765
|
-
},
|
|
2766
|
-
source: sourceRecord,
|
|
2767
|
-
update_check_status: refreshedEntry?.update_check_status ?? null,
|
|
2768
|
-
update_check_reason: refreshedEntry?.update_check_reason ?? null
|
|
2769
|
-
});
|
|
2770
|
-
}
|
|
2771
|
-
async function runExtensionUninstallAction(ctx) {
|
|
2772
|
-
const { action, normalizedTarget, scope, resolvedRoots, warnings, options, withResult } = ctx;
|
|
2773
|
-
const extensionTarget = requireTarget(normalizedTarget, action, options);
|
|
2774
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2775
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
2776
|
-
warnings.push(...managedStateRead.warnings);
|
|
2777
|
-
const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
|
|
2778
|
-
warnings.push(...installed.warnings);
|
|
2779
|
-
const candidate = await resolveInstalledExtensionCandidate(installed.extensions, extensionTarget);
|
|
2780
|
-
if (!candidate) {
|
|
2781
|
-
throw new PmCliError(`Installed extension "${extensionTarget}" was not found in ${scope} scope.`, EXIT_CODE.NOT_FOUND);
|
|
2782
|
-
}
|
|
2783
|
-
const destinationDirectory = path4.join(resolvedRoots.selected_root, candidate.directory);
|
|
2784
|
-
await fs4.rm(destinationDirectory, { recursive: true, force: true });
|
|
2785
|
-
const updatedState = {
|
|
2786
|
-
...managedStateRead.state,
|
|
2787
|
-
updated_at: nowIso(),
|
|
2788
|
-
/* c8 ignore start -- uninstall filter keeps both name+directory guards for legacy managed-state migrations */
|
|
2789
|
-
entries: managedStateRead.state.entries.filter((entry) => normalizeExtensionNameForMatch(entry.name) !== normalizeExtensionNameForMatch(candidate.name) && normalizeExtensionNameForMatch(entry.directory) !== normalizeExtensionNameForMatch(candidate.directory))
|
|
2790
|
-
/* c8 ignore stop */
|
|
2791
|
-
};
|
|
2792
|
-
await writeManagedExtensionState(resolvedRoots.selected_root, updatedState);
|
|
2793
|
-
const stateChanged = clearExtensionState(settings, candidate.name);
|
|
2794
|
-
if (stateChanged) {
|
|
2795
|
-
await writeSettings(resolvedRoots.settings_root, settings, "settings:write");
|
|
2796
|
-
}
|
|
2797
|
-
return withResult({
|
|
2798
|
-
removed: true,
|
|
2799
|
-
extension: {
|
|
2800
|
-
name: candidate.name,
|
|
2801
|
-
directory: candidate.directory
|
|
2802
|
-
},
|
|
2803
|
-
destination_path: destinationDirectory,
|
|
2804
|
-
settings_changed: stateChanged
|
|
2805
|
-
});
|
|
2806
|
-
}
|
|
2807
|
-
async function runExtensionActivateDeactivateAction(ctx) {
|
|
2808
|
-
const { action, normalizedTarget, scope, resolvedRoots, warnings, options, withResult } = ctx;
|
|
2809
|
-
const extensionTarget = requireTarget(normalizedTarget, action, options);
|
|
2810
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2811
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
2812
|
-
warnings.push(...managedStateRead.warnings);
|
|
2813
|
-
const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
|
|
2814
|
-
warnings.push(...installed.warnings);
|
|
2815
|
-
const candidate = await resolveInstalledExtensionCandidate(installed.extensions, extensionTarget);
|
|
2816
|
-
if (!candidate) {
|
|
2817
|
-
throw new PmCliError(`Installed extension "${extensionTarget}" was not found in ${scope} scope.`, EXIT_CODE.NOT_FOUND);
|
|
2818
|
-
}
|
|
2819
|
-
const settingsChanged = action === "activate" ? ensureActivated(settings, candidate.name) : ensureDeactivated(settings, candidate.name);
|
|
2820
|
-
if (settingsChanged) {
|
|
2821
|
-
await writeSettings(resolvedRoots.settings_root, settings, "settings:write");
|
|
2822
|
-
}
|
|
2823
|
-
return withResult({
|
|
2824
|
-
extension: {
|
|
2825
|
-
name: candidate.name,
|
|
2826
|
-
directory: candidate.directory
|
|
2827
|
-
},
|
|
2828
|
-
active: action === "activate",
|
|
2829
|
-
settings_changed: settingsChanged,
|
|
2830
|
-
settings: {
|
|
2831
|
-
enabled: [...settings.extensions.enabled],
|
|
2832
|
-
disabled: [...settings.extensions.disabled]
|
|
2833
|
-
}
|
|
2834
|
-
});
|
|
2835
|
-
}
|
|
2836
|
-
function buildDoctorRemediation(baseRemediation, loadFailureCount, activationFailureCount, vocabulary, managedStateFix) {
|
|
2837
|
-
return [
|
|
2838
|
-
...new Set([
|
|
2839
|
-
...baseRemediation,
|
|
2840
|
-
/* c8 ignore start -- vocabulary-specific remediation branches are copy-only variants */
|
|
2841
|
-
...loadFailureCount > 0 ? [
|
|
2842
|
-
vocabulary === "package" ? "Run pm package explore --project and pm package explore --global to inspect load failures." : "Run pm extension --explore --project and pm extension --explore --global to inspect load failures."
|
|
2843
|
-
] : [],
|
|
2844
|
-
...activationFailureCount > 0 ? [
|
|
2845
|
-
vocabulary === "package" ? "Review activation failures in pm package doctor --detail deep output." : "Review activation failures in pm extension --doctor --detail deep output."
|
|
2846
|
-
] : [],
|
|
2847
|
-
/* c8 ignore stop */
|
|
2848
|
-
...managedStateFix && managedStateFix.adopted_entries.length > 0 ? [`Managed-state fix adopted ${managedStateFix.adopted_entries.length} extension(s).`] : []
|
|
2849
|
-
].map((entry) => entry.trim()).filter((entry) => entry.length > 0))
|
|
2850
|
-
];
|
|
2851
|
-
}
|
|
2852
|
-
async function runExtensionDoctorAction(ctx) {
|
|
2853
|
-
const { normalizedTarget, scope, resolvedRoots, warnings, options, global: global2, withResult } = ctx;
|
|
2854
|
-
if (normalizedTarget && normalizedTarget.trim().length > 0) {
|
|
2855
|
-
throw new PmCliError('Action "doctor" does not accept a target argument.', EXIT_CODE.USAGE);
|
|
2856
|
-
}
|
|
2857
|
-
const detailMode = parseDoctorDetailMode(options.detail);
|
|
2858
|
-
const includeTrace = options.trace === true;
|
|
2859
|
-
if (includeTrace && detailMode !== "deep") {
|
|
2860
|
-
throw new PmCliError("--trace requires --detail deep with --doctor.", EXIT_CODE.USAGE);
|
|
2861
|
-
}
|
|
2862
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
2863
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
2864
|
-
warnings.push(...managedStateRead.warnings);
|
|
2865
|
-
const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
|
|
2866
|
-
warnings.push(...installed.warnings);
|
|
2867
|
-
let managedState = managedStateRead.state;
|
|
2868
|
-
const managedStateFix = options.fixManagedState === true ? await adoptUnmanagedExtensions(resolvedRoots.selected_root, scope, installed.extensions, managedStateRead.state) : null;
|
|
2869
|
-
if (managedStateFix) {
|
|
2870
|
-
managedState = managedStateFix.state;
|
|
2871
|
-
}
|
|
2872
|
-
const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
|
|
2873
|
-
warnings.push(...refreshedInstalled.warnings);
|
|
2874
|
-
const loadResult = await loadExtensions({
|
|
2875
|
-
pmRoot: resolvedRoots.pm_root,
|
|
2876
|
-
settings,
|
|
2877
|
-
cwd: process.cwd(),
|
|
2878
|
-
noExtensions: global2.noExtensions === true
|
|
2879
|
-
});
|
|
2880
|
-
const activationResult = await activateExtensions({
|
|
2881
|
-
...loadResult,
|
|
2882
|
-
loaded: loadResult.loaded
|
|
2883
|
-
});
|
|
2884
|
-
warnings.push(...loadResult.warnings);
|
|
2885
|
-
warnings.push(...classifyDoctorLoadFailureWarnings(loadResult.failed));
|
|
2886
|
-
warnings.push(...activationResult.warnings);
|
|
2887
|
-
warnings.push(...classifyDoctorActivationFailureWarnings(activationResult.failed));
|
|
2888
|
-
warnings.push(...classifyUnusedCapabilityWarnings(loadResult, activationResult));
|
|
2889
|
-
warnings.push(...collectGlobalOutputOverrideDoctorWarnings(activationResult));
|
|
2890
|
-
warnings.push(...collectSchemaNarrowActivationDoctorWarnings(loadResult, activationResult));
|
|
2891
|
-
const runtimeInstalledExtensions = applyDoctorRuntimeActivationState(refreshedInstalled.extensions, loadResult, activationResult);
|
|
2892
|
-
const doctorConsistency = buildDoctorConsistencySummary(scope, runtimeInstalledExtensions, loadResult.loaded.map((entry) => ({ layer: entry.layer, name: entry.name })), loadResult.failed.map((entry) => ({ name: entry.name })), loadResult.disabled_by_flag);
|
|
2893
|
-
warnings.push(...doctorConsistency.warnings);
|
|
2894
|
-
const updateCheckWarnings = runtimeInstalledExtensions.filter((entry) => entry.update_check_status === "failed").map((entry) => `extension_update_check_failed:${entry.name}`);
|
|
2895
|
-
warnings.push(...updateCheckWarnings);
|
|
2896
|
-
const triage = buildExtensionTriageSummary(scope, warnings, runtimeInstalledExtensions, options);
|
|
2897
|
-
warnings.push(...triage.warnings);
|
|
2898
|
-
const normalizedWarnings = [...triage.warnings];
|
|
2899
|
-
const policySummary = {
|
|
2900
|
-
mode: loadResult.policy.mode,
|
|
2901
|
-
trust_mode: loadResult.policy.trust_mode,
|
|
2902
|
-
require_provenance: loadResult.policy.require_provenance,
|
|
2903
|
-
default_sandbox_profile: loadResult.policy.default_sandbox_profile,
|
|
2904
|
-
// Honest trust model (ADR pm-6ef3): keep this caveat to one concise line.
|
|
2905
|
-
sandbox_enforcement: "advisory: sandbox_profile/permissions are declaration-based load gates, not runtime isolation (ADR pm-6ef3)",
|
|
2906
|
-
trusted_extensions_count: loadResult.policy.trusted_extensions.length,
|
|
2907
|
-
allowed_extensions_count: loadResult.policy.allowed_extensions.length,
|
|
2908
|
-
blocked_extensions_count: loadResult.policy.blocked_extensions.length,
|
|
2909
|
-
allowed_capabilities_count: loadResult.policy.allowed_capabilities.length,
|
|
2910
|
-
blocked_capabilities_count: loadResult.policy.blocked_capabilities.length,
|
|
2911
|
-
allowed_surfaces_count: loadResult.policy.allowed_surfaces.length,
|
|
2912
|
-
blocked_surfaces_count: loadResult.policy.blocked_surfaces.length,
|
|
2913
|
-
allowed_commands_count: loadResult.policy.allowed_commands.length,
|
|
2914
|
-
blocked_commands_count: loadResult.policy.blocked_commands.length,
|
|
2915
|
-
allowed_actions_count: loadResult.policy.allowed_actions.length,
|
|
2916
|
-
blocked_actions_count: loadResult.policy.blocked_actions.length,
|
|
2917
|
-
allowed_services_count: loadResult.policy.allowed_services.length,
|
|
2918
|
-
blocked_services_count: loadResult.policy.blocked_services.length,
|
|
2919
|
-
extension_override_count: loadResult.policy.extension_overrides.length
|
|
2920
|
-
};
|
|
2921
|
-
const capabilityGuidance = collectUnknownCapabilityGuidance(normalizedWarnings);
|
|
2922
|
-
const capabilityContract = buildCapabilityContractMetadata();
|
|
2923
|
-
const warningCodes = triage.warning_codes;
|
|
2924
|
-
const remediation = buildDoctorRemediation(triage.remediation, loadResult.failed.length, activationResult.failed.length, options.vocabulary, managedStateFix);
|
|
2925
|
-
const summary = {
|
|
2926
|
-
status: triage.status,
|
|
2927
|
-
scope,
|
|
2928
|
-
warning_count: triage.warning_count,
|
|
2929
|
-
warning_codes: warningCodes,
|
|
2930
|
-
total_extensions: runtimeInstalledExtensions.length,
|
|
2931
|
-
managed_total: runtimeInstalledExtensions.filter((entry) => entry.managed).length,
|
|
2932
|
-
enabled_total: runtimeInstalledExtensions.filter((entry) => entry.enabled).length,
|
|
2933
|
-
active_total: runtimeInstalledExtensions.filter((entry) => entry.active).length,
|
|
2934
|
-
unmanaged_loaded_extension_count: triage.unmanaged_loaded_extension_count,
|
|
2935
|
-
unmanaged_action_required_extension_count: triage.unmanaged_action_required_extension_count,
|
|
2936
|
-
unmanaged_expected_extension_count: triage.unmanaged_expected_extension_count,
|
|
2937
|
-
runtime_active_total: runtimeInstalledExtensions.filter((entry) => entry.runtime_active === true).length,
|
|
2938
|
-
activation_status_totals: {
|
|
2939
|
-
ok: runtimeInstalledExtensions.filter((entry) => entry.activation_status === "ok").length,
|
|
2940
|
-
failed: runtimeInstalledExtensions.filter((entry) => entry.activation_status === "failed").length,
|
|
2941
|
-
not_loaded: runtimeInstalledExtensions.filter((entry) => entry.activation_status === "not_loaded").length,
|
|
2942
|
-
unknown: runtimeInstalledExtensions.filter((entry) => entry.activation_status === "unknown").length
|
|
2943
|
-
},
|
|
2944
|
-
unknown_capability_count: capabilityGuidance.length,
|
|
2945
|
-
capability_contract_version: capabilityContract.version,
|
|
2946
|
-
update_available_total: runtimeInstalledExtensions.filter((entry) => entry.update_available === true).length,
|
|
2947
|
-
update_health_coverage: triage.update_health_coverage,
|
|
2948
|
-
update_health_partial: triage.update_health_partial,
|
|
2949
|
-
update_check_failed_total: runtimeInstalledExtensions.filter((entry) => entry.update_check_status === "failed").length,
|
|
2950
|
-
load_failure_count: loadResult.failed.length,
|
|
2951
|
-
activation_failure_count: activationResult.failed.length,
|
|
2952
|
-
blocking_failure_count: loadResult.failed.length + activationResult.failed.length,
|
|
2953
|
-
has_blocking_failures: loadResult.failed.length + activationResult.failed.length > 0,
|
|
2954
|
-
consistency_warning_count: doctorConsistency.warnings.length,
|
|
2955
|
-
trace_enabled: includeTrace,
|
|
2956
|
-
policy: policySummary,
|
|
2957
|
-
remediation
|
|
2958
|
-
};
|
|
2959
|
-
const managedStateFixSummary = managedStateFix ? {
|
|
2960
|
-
requested: true,
|
|
2961
|
-
applied: managedStateFix.adopted_entries.length > 0,
|
|
2962
|
-
adopted_count: managedStateFix.adopted_entries.length,
|
|
2963
|
-
already_managed_count: managedStateFix.already_managed_count,
|
|
2964
|
-
adopted_extensions: managedStateFix.adopted_entries.map((entry) => entry.name)
|
|
2965
|
-
} : {
|
|
2966
|
-
requested: false,
|
|
2967
|
-
applied: false,
|
|
2968
|
-
adopted_count: 0,
|
|
2969
|
-
already_managed_count: refreshedInstalled.extensions.filter((entry) => entry.managed).length,
|
|
2970
|
-
adopted_extensions: []
|
|
2971
|
-
};
|
|
2972
|
-
const details = {
|
|
2973
|
-
mode: detailMode,
|
|
2974
|
-
summary,
|
|
2975
|
-
triage,
|
|
2976
|
-
trace_enabled: includeTrace,
|
|
2977
|
-
capability_contract: capabilityContract,
|
|
2978
|
-
capability_guidance: capabilityGuidance,
|
|
2979
|
-
managed_state_fix: managedStateFixSummary,
|
|
2980
|
-
policy: loadResult.policy
|
|
2981
|
-
};
|
|
2982
|
-
if (detailMode === "deep") {
|
|
2983
|
-
const activationFailedDetails = includeTrace ? activationResult.failed : activationResult.failed.map((entry) => {
|
|
2984
|
-
const { trace: _trace, ...rest } = entry;
|
|
2985
|
-
return rest;
|
|
2986
|
-
});
|
|
2987
|
-
details.deep = {
|
|
2988
|
-
warnings: normalizedWarnings,
|
|
2989
|
-
warning_codes: warningCodes,
|
|
2990
|
-
capability_contract: capabilityContract,
|
|
2991
|
-
capability_guidance: capabilityGuidance,
|
|
2992
|
-
trace_enabled: includeTrace,
|
|
2993
|
-
managed_state: {
|
|
2994
|
-
path: managedStateRead.path,
|
|
2995
|
-
count: managedState.entries.length,
|
|
2996
|
-
entries: managedState.entries
|
|
2997
|
-
},
|
|
2998
|
-
installed_extensions: runtimeInstalledExtensions,
|
|
2999
|
-
load: {
|
|
3000
|
-
roots: loadResult.roots,
|
|
3001
|
-
policy: loadResult.policy,
|
|
3002
|
-
warnings: loadResult.warnings,
|
|
3003
|
-
failed: loadResult.failed,
|
|
3004
|
-
loaded: loadResult.loaded.map((entry) => ({
|
|
3005
|
-
layer: entry.layer,
|
|
3006
|
-
directory: entry.directory,
|
|
3007
|
-
name: entry.name,
|
|
3008
|
-
version: entry.version,
|
|
3009
|
-
entry: entry.entry,
|
|
3010
|
-
priority: entry.priority
|
|
3011
|
-
}))
|
|
3012
|
-
},
|
|
3013
|
-
activation: {
|
|
3014
|
-
failed: activationFailedDetails,
|
|
3015
|
-
warnings: activationResult.warnings,
|
|
3016
|
-
hook_counts: activationResult.hook_counts,
|
|
3017
|
-
registration_counts: activationResult.registration_counts,
|
|
3018
|
-
parser_override_count: activationResult.parser_override_count,
|
|
3019
|
-
preflight_override_count: activationResult.preflight_override_count,
|
|
3020
|
-
service_override_count: activationResult.service_override_count,
|
|
3021
|
-
renderer_override_count: activationResult.renderer_override_count
|
|
3022
|
-
},
|
|
3023
|
-
consistency: doctorConsistency.summary
|
|
3024
|
-
};
|
|
3025
|
-
if (includeTrace) {
|
|
3026
|
-
details.deep.trace = {
|
|
3027
|
-
activation_failures: activationResult.failed.filter((entry) => entry.trace !== void 0).map((entry) => ({
|
|
3028
|
-
layer: entry.layer,
|
|
3029
|
-
name: entry.name,
|
|
3030
|
-
entry_path: entry.entry_path,
|
|
3031
|
-
error: entry.error,
|
|
3032
|
-
method: entry.trace?.method,
|
|
3033
|
-
command: entry.trace?.command,
|
|
3034
|
-
capability: entry.trace?.capability,
|
|
3035
|
-
missing_capability: entry.trace?.missing_capability,
|
|
3036
|
-
registration_index: entry.trace?.registration_index,
|
|
3037
|
-
expected_schema: entry.trace?.expected_schema,
|
|
3038
|
-
hint: entry.trace?.hint,
|
|
3039
|
-
received: entry.trace?.received
|
|
3040
|
-
}))
|
|
3041
|
-
};
|
|
3042
|
-
}
|
|
3043
|
-
}
|
|
3044
|
-
return withResult(details);
|
|
3045
|
-
}
|
|
3046
|
-
async function runExtensionDescribeAction(ctx) {
|
|
3047
|
-
const { normalizedTarget, scope, resolvedRoots, warnings, options, global: global2, withResult } = ctx;
|
|
3048
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
3049
|
-
const loadResult = await loadExtensions({
|
|
3050
|
-
pmRoot: resolvedRoots.pm_root,
|
|
3051
|
-
settings,
|
|
3052
|
-
cwd: process.cwd(),
|
|
3053
|
-
noExtensions: global2.noExtensions === true
|
|
3054
|
-
});
|
|
3055
|
-
const activationResult = await activateExtensions(loadResult);
|
|
3056
|
-
warnings.push(...loadResult.warnings);
|
|
3057
|
-
warnings.push(...activationResult.warnings);
|
|
3058
|
-
const describeResult = buildExtensionDescribeResult(normalizedTarget, loadResult, activationResult);
|
|
3059
|
-
if (normalizedTarget !== void 0 && describeResult.extensions.length === 0) {
|
|
3060
|
-
const noun = options.vocabulary === "package" ? "package" : "extension";
|
|
3061
|
-
const loadedNames = [
|
|
3062
|
-
...new Set(loadResult.loaded.map((entry) => options.vocabulary === "package" && typeof entry.source_package === "string" && entry.source_package.trim().length > 0 ? entry.source_package.trim() : entry.name))
|
|
3063
|
-
].sort((left, right) => left.localeCompare(right));
|
|
3064
|
-
const loadedHint = loadedNames.length > 0 ? ` Loaded ${noun} names: ${loadedNames.join(", ")}.` : "";
|
|
3065
|
-
throw new PmCliError(`No loaded ${noun} named "${normalizedTarget}" was found in ${scope} scope.${loadedHint} Run pm ${noun} explore to list discovered ${noun}s.`, EXIT_CODE.NOT_FOUND);
|
|
3066
|
-
}
|
|
3067
|
-
return withResult({
|
|
3068
|
-
target: describeResult.target,
|
|
3069
|
-
total: describeResult.total,
|
|
3070
|
-
extensions: describeResult.extensions,
|
|
3071
|
-
union: describeResult.union
|
|
3072
|
-
});
|
|
3073
|
-
}
|
|
3074
|
-
async function runExtensionExploreManageAction(ctx) {
|
|
3075
|
-
const { action, scope, resolvedRoots, warnings, options, global: global2, withResult } = ctx;
|
|
3076
|
-
const settings = await readSettings(resolvedRoots.settings_root);
|
|
3077
|
-
const configuredPolicy = buildExtensionPolicyDetails(settings.extensions.policy);
|
|
3078
|
-
const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
|
|
3079
|
-
warnings.push(...managedStateRead.warnings);
|
|
3080
|
-
const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
|
|
3081
|
-
warnings.push(...installed.warnings);
|
|
3082
|
-
let managedState = managedStateRead.state;
|
|
3083
|
-
const managedStateFix = action === "manage" && options.fixManagedState === true ? await adoptUnmanagedExtensions(resolvedRoots.selected_root, scope, installed.extensions, managedStateRead.state) : null;
|
|
3084
|
-
if (managedStateFix) {
|
|
3085
|
-
managedState = managedStateFix.state;
|
|
3086
|
-
}
|
|
3087
|
-
if (action === "manage") {
|
|
3088
|
-
const updates = await Promise.all(managedState.entries.map(async (entry) => {
|
|
3089
|
-
if (entry.source.kind !== "github") {
|
|
3090
|
-
return entry;
|
|
3091
|
-
}
|
|
3092
|
-
const updateStatus = await checkGithubUpdate(entry.source);
|
|
3093
|
-
return {
|
|
3094
|
-
...entry,
|
|
3095
|
-
last_update_check_at: updateStatus.checked_at,
|
|
3096
|
-
last_update_remote_commit: updateStatus.remote_commit,
|
|
3097
|
-
update_available: updateStatus.available,
|
|
3098
|
-
update_error: updateStatus.error
|
|
3099
|
-
};
|
|
3100
|
-
}));
|
|
3101
|
-
managedState = {
|
|
3102
|
-
...managedState,
|
|
3103
|
-
updated_at: nowIso(),
|
|
3104
|
-
entries: sortManagedEntries(updates)
|
|
3105
|
-
};
|
|
3106
|
-
await writeManagedExtensionState(resolvedRoots.selected_root, managedState);
|
|
3107
|
-
}
|
|
3108
|
-
const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
|
|
3109
|
-
warnings.push(...refreshedInstalled.warnings);
|
|
3110
|
-
if (action === "manage") {
|
|
3111
|
-
const updateWarnings = refreshedInstalled.extensions.filter((entry) => entry.update_check_status === "failed").map((entry) => `extension_update_check_failed:${entry.name}`);
|
|
3112
|
-
warnings.push(...updateWarnings);
|
|
3113
|
-
}
|
|
3114
|
-
let runtimeProbeSummary;
|
|
3115
|
-
let runtimeInstalledExtensions = refreshedInstalled.extensions;
|
|
3116
|
-
let runtimeActivationFailures;
|
|
3117
|
-
if (action === "explore" || options.runtimeProbe === true) {
|
|
3118
|
-
const loadResult = await loadExtensions({
|
|
3119
|
-
pmRoot: resolvedRoots.pm_root,
|
|
3120
|
-
settings,
|
|
3121
|
-
cwd: process.cwd(),
|
|
3122
|
-
noExtensions: global2.noExtensions === true
|
|
3123
|
-
});
|
|
3124
|
-
const activationResult = await activateExtensions({
|
|
3125
|
-
...loadResult,
|
|
3126
|
-
loaded: loadResult.loaded
|
|
3127
|
-
});
|
|
3128
|
-
warnings.push(...loadResult.warnings);
|
|
3129
|
-
warnings.push(...activationResult.warnings);
|
|
3130
|
-
runtimeInstalledExtensions = applyDoctorRuntimeActivationState(refreshedInstalled.extensions, loadResult, activationResult);
|
|
3131
|
-
runtimeActivationFailures = collectActivationFailureDiagnostics(activationResult.failed);
|
|
3132
|
-
runtimeProbeSummary = {
|
|
3133
|
-
requested: true,
|
|
3134
|
-
executed: true,
|
|
3135
|
-
reason: action === "explore" ? "explore_defaults_to_runtime_probe" : "runtime_probe_requested",
|
|
3136
|
-
load_failure_count: loadResult.failed.length,
|
|
3137
|
-
activation_failure_count: activationResult.failed.length,
|
|
3138
|
-
warning_count: [.../* @__PURE__ */ new Set([...loadResult.warnings, ...activationResult.warnings])].length,
|
|
3139
|
-
policy: loadResult.policy
|
|
3140
|
-
};
|
|
3141
|
-
} else if (action === "manage") {
|
|
3142
|
-
runtimeProbeSummary = {
|
|
3143
|
-
requested: false,
|
|
3144
|
-
executed: false
|
|
3145
|
-
};
|
|
3146
|
-
}
|
|
3147
|
-
const triage = buildExtensionTriageSummary(scope, warnings, runtimeInstalledExtensions, options);
|
|
3148
|
-
warnings.push(...triage.warnings);
|
|
3149
|
-
const details = {
|
|
3150
|
-
total: runtimeInstalledExtensions.length,
|
|
3151
|
-
managed_total: runtimeInstalledExtensions.filter((entry) => entry.managed).length,
|
|
3152
|
-
enabled_total: runtimeInstalledExtensions.filter((entry) => entry.enabled).length,
|
|
3153
|
-
active_total: runtimeInstalledExtensions.filter((entry) => entry.active).length,
|
|
3154
|
-
extensions: runtimeInstalledExtensions,
|
|
3155
|
-
triage,
|
|
3156
|
-
policy: configuredPolicy
|
|
3157
|
-
};
|
|
3158
|
-
if (runtimeActivationFailures !== void 0) {
|
|
3159
|
-
details.activation_diagnostics = {
|
|
3160
|
-
failed_count: runtimeActivationFailures.length,
|
|
3161
|
-
failed: runtimeActivationFailures
|
|
3162
|
-
};
|
|
3163
|
-
}
|
|
3164
|
-
if (action === "explore") {
|
|
3165
|
-
details.runtime_probe = runtimeProbeSummary;
|
|
3166
|
-
}
|
|
3167
|
-
if (action === "manage") {
|
|
3168
|
-
details.runtime_probe = runtimeProbeSummary;
|
|
3169
|
-
details.managed_state_fix = managedStateFix !== null ? {
|
|
3170
|
-
requested: true,
|
|
3171
|
-
applied: managedStateFix.adopted_entries.length > 0,
|
|
3172
|
-
adopted_count: managedStateFix.adopted_entries.length,
|
|
3173
|
-
adopted_extensions: managedStateFix.adopted_entries.map((entry) => entry.name),
|
|
3174
|
-
already_managed_count: managedStateFix.already_managed_count
|
|
3175
|
-
} : {
|
|
3176
|
-
requested: false,
|
|
3177
|
-
applied: false,
|
|
3178
|
-
adopted_count: 0,
|
|
3179
|
-
adopted_extensions: [],
|
|
3180
|
-
already_managed_count: runtimeInstalledExtensions.filter((entry) => entry.managed).length
|
|
3181
|
-
};
|
|
3182
|
-
}
|
|
3183
|
-
return withResult(details);
|
|
3184
|
-
}
|
|
3185
|
-
var EXTENSION_ACTION_HANDLERS = {
|
|
3186
|
-
init: runExtensionInitAction,
|
|
3187
|
-
install: runExtensionInstallAction,
|
|
3188
|
-
uninstall: runExtensionUninstallAction,
|
|
3189
|
-
explore: runExtensionExploreManageAction,
|
|
3190
|
-
manage: runExtensionExploreManageAction,
|
|
3191
|
-
describe: runExtensionDescribeAction,
|
|
3192
|
-
reload: runExtensionReloadAction,
|
|
3193
|
-
doctor: runExtensionDoctorAction,
|
|
3194
|
-
catalog: runExtensionCatalogAction,
|
|
3195
|
-
adopt: runExtensionAdoptAction,
|
|
3196
|
-
"adopt-all": runExtensionAdoptAllAction,
|
|
3197
|
-
activate: runExtensionActivateDeactivateAction,
|
|
3198
|
-
deactivate: runExtensionActivateDeactivateAction
|
|
3199
|
-
};
|
|
3200
|
-
var _testOnly = {
|
|
3201
|
-
adoptUnmanagedExtensions,
|
|
3202
|
-
buildExtensionPolicyDetails,
|
|
3203
|
-
buildInstallCommandDiscovery,
|
|
3204
|
-
checkGithubUpdate,
|
|
3205
|
-
clearExtensionState,
|
|
3206
|
-
collectActivationFailureDiagnostics,
|
|
3207
|
-
findActivationFailureByName,
|
|
3208
|
-
resolveInstallRuntimeActivationStatus,
|
|
3209
|
-
collectGlobalOutputOverrideDoctorWarnings,
|
|
3210
|
-
collectSchemaNarrowActivationDoctorWarnings,
|
|
3211
|
-
copyExtensionDirectoryWithoutSelfNesting,
|
|
3212
|
-
isErrnoCode,
|
|
3213
|
-
isRetriableExtensionInstallCopyError,
|
|
3214
|
-
listInstalledExtensions,
|
|
3215
|
-
requireTarget,
|
|
3216
|
-
resolveAction,
|
|
3217
|
-
resolveCommandDiscoveryPackageName,
|
|
3218
|
-
resolveGithubOption,
|
|
3219
|
-
resolveInstalledExtensionCandidate,
|
|
3220
|
-
resolveScope,
|
|
3221
|
-
resolveUpdateCheckResolution,
|
|
3222
|
-
withExtensionInstallLock
|
|
3223
|
-
};
|
|
3224
|
-
|
|
3225
|
-
export {
|
|
3226
|
-
resolveManagedExtensionStatePath,
|
|
3227
|
-
readManagedExtensionState,
|
|
3228
|
-
writeManagedExtensionState,
|
|
3229
|
-
parseExtensionInstallSource,
|
|
3230
|
-
buildRegistrationCollisionRemediation,
|
|
3231
|
-
collectUnknownCapabilityGuidance,
|
|
3232
|
-
buildCapabilityContractMetadata,
|
|
3233
|
-
copyExtensionDirectoryForInstall,
|
|
3234
|
-
runExtension,
|
|
3235
|
-
_testOnly
|
|
3236
|
-
};
|
|
3237
|
-
//# sourceMappingURL=chunk-GIWXVMZ3.js.map
|