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