@unbrained/pm-cli 2026.7.14 → 2026.7.15

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 (708) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +14 -11
  4. package/dist/cli/argv-utils.d.ts +1 -4
  5. package/dist/cli/argv-utils.js +3 -13
  6. package/dist/cli/argv-utils.js.map +1 -1
  7. package/dist/cli/bootstrap-args.d.ts +6 -4
  8. package/dist/cli/bootstrap-args.js +51 -16
  9. package/dist/cli/bootstrap-args.js.map +1 -1
  10. package/dist/cli/bundle-integrity.d.ts +49 -0
  11. package/dist/cli/bundle-integrity.js +111 -0
  12. package/dist/cli/bundle-integrity.js.map +1 -0
  13. package/dist/cli/commands/completion.js +7 -2
  14. package/dist/cli/commands/completion.js.map +1 -1
  15. package/dist/cli/commands/config.d.ts +6 -163
  16. package/dist/cli/commands/config.js +4 -1133
  17. package/dist/cli/commands/config.js.map +1 -1
  18. package/dist/cli/commands/context.d.ts +2 -4
  19. package/dist/cli/commands/context.js +10 -85
  20. package/dist/cli/commands/context.js.map +1 -1
  21. package/dist/cli/commands/create.d.ts +1 -0
  22. package/dist/cli/commands/create.js +3 -2
  23. package/dist/cli/commands/create.js.map +1 -1
  24. package/dist/cli/commands/extension/describe.d.ts +2 -91
  25. package/dist/cli/commands/extension/describe.js +4 -142
  26. package/dist/cli/commands/extension/describe.js.map +1 -1
  27. package/dist/cli/commands/extension/scaffold.d.ts +2 -36
  28. package/dist/cli/commands/extension/scaffold.js +4 -2435
  29. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  30. package/dist/cli/commands/extension/shared.d.ts +2 -28
  31. package/dist/cli/commands/extension/shared.js +4 -130
  32. package/dist/cli/commands/extension/shared.js.map +1 -1
  33. package/dist/cli/commands/extension.d.ts +3 -400
  34. package/dist/cli/commands/extension.js +4 -2183
  35. package/dist/cli/commands/extension.js.map +1 -1
  36. package/dist/cli/commands/gc.d.ts +6 -56
  37. package/dist/cli/commands/gc.js +4 -270
  38. package/dist/cli/commands/gc.js.map +1 -1
  39. package/dist/cli/commands/get.d.ts +18 -5
  40. package/dist/cli/commands/get.js +117 -58
  41. package/dist/cli/commands/get.js.map +1 -1
  42. package/dist/cli/commands/health.d.ts +6 -184
  43. package/dist/cli/commands/health.js +4 -1747
  44. package/dist/cli/commands/health.js.map +1 -1
  45. package/dist/cli/commands/history-compact.d.ts +4 -139
  46. package/dist/cli/commands/history-compact.js +5 -510
  47. package/dist/cli/commands/history-compact.js.map +1 -1
  48. package/dist/cli/commands/history-redact.d.ts +8 -120
  49. package/dist/cli/commands/history-redact.js +6 -581
  50. package/dist/cli/commands/history-redact.js.map +1 -1
  51. package/dist/cli/commands/history-repair.d.ts +7 -89
  52. package/dist/cli/commands/history-repair.js +5 -257
  53. package/dist/cli/commands/history-repair.js.map +1 -1
  54. package/dist/cli/commands/history.d.ts +1 -2
  55. package/dist/cli/commands/history.js +6 -48
  56. package/dist/cli/commands/history.js.map +1 -1
  57. package/dist/cli/commands/index.d.ts +1 -0
  58. package/dist/cli/commands/index.js +3 -2
  59. package/dist/cli/commands/index.js.map +1 -1
  60. package/dist/cli/commands/init-agent-guidance.d.ts +6 -113
  61. package/dist/cli/commands/init-agent-guidance.js +4 -431
  62. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  63. package/dist/cli/commands/init.d.ts +6 -181
  64. package/dist/cli/commands/init.js +4 -690
  65. package/dist/cli/commands/init.js.map +1 -1
  66. package/dist/cli/commands/next.js +3 -3
  67. package/dist/cli/commands/next.js.map +1 -1
  68. package/dist/cli/commands/profile.d.ts +4 -174
  69. package/dist/cli/commands/profile.js +4 -425
  70. package/dist/cli/commands/profile.js.map +1 -1
  71. package/dist/cli/commands/restore.d.ts +4 -19
  72. package/dist/cli/commands/restore.js +9 -158
  73. package/dist/cli/commands/restore.js.map +1 -1
  74. package/dist/cli/commands/schema.d.ts +7 -507
  75. package/dist/cli/commands/schema.js +5 -1254
  76. package/dist/cli/commands/schema.js.map +1 -1
  77. package/dist/cli/commands/test.d.ts +2 -4
  78. package/dist/cli/commands/test.js +7 -97
  79. package/dist/cli/commands/test.js.map +1 -1
  80. package/dist/cli/commands/validate.d.ts +9 -249
  81. package/dist/cli/commands/validate.js +9 -2150
  82. package/dist/cli/commands/validate.js.map +1 -1
  83. package/dist/cli/extension-command-help.js +18 -4
  84. package/dist/cli/extension-command-help.js.map +1 -1
  85. package/dist/cli/extension-command-options.js +3 -3
  86. package/dist/cli/extension-command-options.js.map +1 -1
  87. package/dist/cli/help-content.js +7 -3
  88. package/dist/cli/help-content.js.map +1 -1
  89. package/dist/cli/main.js +20 -30
  90. package/dist/cli/main.js.map +1 -1
  91. package/dist/cli/register-list-query.js +4 -2
  92. package/dist/cli/register-list-query.js.map +1 -1
  93. package/dist/cli/register-mutation.js +11 -3
  94. package/dist/cli/register-mutation.js.map +1 -1
  95. package/dist/cli/register-setup.js +4 -2
  96. package/dist/cli/register-setup.js.map +1 -1
  97. package/dist/cli/registration-helpers.js +3 -2
  98. package/dist/cli/registration-helpers.js.map +1 -1
  99. package/dist/cli-bundle/bundle-manifest.json +782 -0
  100. package/dist/cli-bundle/chunks/{append-PVZJDM6J.js → append-OJQFUQ4T.js} +5 -5
  101. package/dist/cli-bundle/chunks/append-UZVHUO74.js +11 -0
  102. package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js → chunk-2IFFUZLC.js} +2 -2
  103. package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js → chunk-2JKGO6QX.js} +4 -4
  104. package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js → chunk-2NCIPMQP.js} +2 -2
  105. package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js → chunk-2VPAVL7O.js} +2 -2
  106. package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js → chunk-2WSE6PO2.js} +4 -4
  107. package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js → chunk-34L5OT3Y.js} +2 -2
  108. package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js → chunk-3AUGG2DP.js} +3 -3
  109. package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js → chunk-3CLU2XZO.js} +4 -4
  110. package/dist/cli-bundle/chunks/{chunk-N3CMP4NI.js → chunk-3S5QVM5H.js} +43 -7
  111. package/dist/cli-bundle/chunks/chunk-3S5QVM5H.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js +64 -0
  113. package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js.map +7 -0
  114. package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js → chunk-3WM75PWC.js} +3 -3
  115. package/dist/cli-bundle/chunks/chunk-4223PVZT.js +121 -0
  116. package/dist/cli-bundle/chunks/chunk-4223PVZT.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-5URI7TPJ.js → chunk-4XQ3BDV4.js} +281 -164
  118. package/dist/cli-bundle/chunks/chunk-4XQ3BDV4.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js → chunk-5JLUII3O.js} +13 -13
  120. package/dist/cli-bundle/chunks/{chunk-MKL4CP2I.js → chunk-5ZSLZLDN.js} +631 -246
  121. package/dist/cli-bundle/chunks/chunk-5ZSLZLDN.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-Q37E63AM.js → chunk-6CFNAVTF.js} +21 -141
  123. package/dist/cli-bundle/chunks/chunk-6CFNAVTF.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js → chunk-6N2VXVTQ.js} +2 -2
  125. package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js → chunk-6S3YSUYG.js} +3 -3
  126. package/dist/cli-bundle/chunks/{chunk-ZUKSZVBW.js → chunk-7B67ZL4N.js} +8 -7
  127. package/dist/cli-bundle/chunks/chunk-7B67ZL4N.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-IA3YFTXT.js → chunk-7PIWCHTW.js} +11 -13
  129. package/dist/cli-bundle/chunks/chunk-7PIWCHTW.js.map +1 -0
  130. package/dist/cli-bundle/chunks/{chunk-BPD26E3P.js → chunk-7Z4LKRS4.js} +291 -81
  131. package/dist/cli-bundle/chunks/chunk-7Z4LKRS4.js.map +1 -0
  132. package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js → chunk-AHVTB5I5.js} +4 -4
  133. package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js → chunk-APRVSW2O.js} +3 -3
  134. package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js → chunk-B7PE22W6.js} +4 -4
  135. package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js → chunk-BCOFWYW4.js} +3 -3
  136. package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js → chunk-BEP7WJA2.js} +4 -4
  137. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js +1114 -0
  138. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js.map +7 -0
  139. package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js → chunk-BSEQUTQP.js} +2 -2
  140. package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js.map → chunk-BSEQUTQP.js.map} +2 -2
  141. package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js → chunk-CRVF2JDM.js} +10 -10
  142. package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js → chunk-DM4H7FP4.js} +3 -3
  143. package/dist/cli-bundle/chunks/chunk-DUT67M43.js +5 -0
  144. package/dist/cli-bundle/chunks/{chunk-44LNIULG.js → chunk-DYH63FX7.js} +4 -4
  145. package/dist/cli-bundle/chunks/{chunk-LWTIRS3Y.js → chunk-E2OJMKML.js} +306 -82
  146. package/dist/cli-bundle/chunks/chunk-E2OJMKML.js.map +7 -0
  147. package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js → chunk-EAB64KLB.js} +4 -4
  148. package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js → chunk-EACOH7AU.js} +10 -10
  149. package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js → chunk-EH2OPHBI.js} +10 -10
  150. package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js.map → chunk-EH2OPHBI.js.map} +1 -1
  151. package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js → chunk-EJEXHTY5.js} +2 -2
  152. package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js → chunk-EYLCSJAI.js} +2 -2
  153. package/dist/cli-bundle/chunks/{chunk-655STMGA.js → chunk-FMBNM2EN.js} +2 -2
  154. package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js → chunk-FNSPG7MU.js} +12 -12
  155. package/dist/cli-bundle/chunks/{chunk-5CT5BW6E.js → chunk-GM5QHQU6.js} +46 -40
  156. package/dist/cli-bundle/chunks/chunk-GM5QHQU6.js.map +7 -0
  157. package/dist/cli-bundle/chunks/{chunk-FTQLW4JD.js → chunk-GOSLKLFE.js} +418 -24
  158. package/dist/cli-bundle/chunks/chunk-GOSLKLFE.js.map +1 -0
  159. package/dist/cli-bundle/chunks/{chunk-KB726FMH.js → chunk-H2Z3FYXQ.js} +4 -4
  160. package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js +162 -0
  161. package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js.map +1 -0
  162. package/dist/cli-bundle/chunks/{chunk-2QIQGYPW.js → chunk-H5APFTHZ.js} +53 -10
  163. package/dist/cli-bundle/chunks/chunk-H5APFTHZ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js +118 -0
  165. package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{chunk-ZAYYDNB3.js → chunk-HO4KXD6I.js} +22 -142
  167. package/dist/cli-bundle/chunks/chunk-HO4KXD6I.js.map +1 -0
  168. package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js → chunk-HYB5AZ63.js} +203 -62
  169. package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js.map → chunk-HYB5AZ63.js.map} +3 -3
  170. package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js → chunk-IA5FKNII.js} +2 -2
  171. package/dist/cli-bundle/chunks/{chunk-JL7WZ4O2.js → chunk-IG3SWA4A.js} +33 -9
  172. package/dist/cli-bundle/chunks/chunk-IG3SWA4A.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js → chunk-IJIICKVW.js} +2 -2
  174. package/dist/cli-bundle/chunks/{chunk-IGED7NH2.js → chunk-ILX33QXL.js} +668 -251
  175. package/dist/cli-bundle/chunks/chunk-ILX33QXL.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-UGTVWL3E.js → chunk-INU6DKT5.js} +47 -41
  177. package/dist/cli-bundle/chunks/chunk-INU6DKT5.js.map +1 -0
  178. package/dist/cli-bundle/chunks/{chunk-UB2QYSTO.js → chunk-J5AOEGDC.js} +26 -18
  179. package/dist/cli-bundle/chunks/chunk-J5AOEGDC.js.map +1 -0
  180. package/dist/cli-bundle/chunks/{chunk-4DY4KPQI.js → chunk-J6364LFM.js} +1330 -937
  181. package/dist/cli-bundle/chunks/chunk-J6364LFM.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{chunk-DVOLZJ3C.js → chunk-J6EY5V4N.js} +1295 -939
  183. package/dist/cli-bundle/chunks/chunk-J6EY5V4N.js.map +1 -0
  184. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js +1097 -0
  185. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js.map +1 -0
  186. package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js → chunk-JOUQZENX.js} +3 -3
  187. package/dist/cli-bundle/chunks/{chunk-J4NZOP3I.js → chunk-JXQUXVMI.js} +9 -8
  188. package/dist/cli-bundle/chunks/chunk-JXQUXVMI.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js → chunk-JYFOV7FC.js} +4 -4
  190. package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js → chunk-K2X6U4UA.js} +4 -4
  191. package/dist/cli-bundle/chunks/{chunk-6OTZMORS.js → chunk-K3WII2ME.js} +27 -27
  192. package/dist/cli-bundle/chunks/chunk-K3WII2ME.js.map +7 -0
  193. package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js → chunk-KG44YSKD.js} +4 -4
  194. package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js → chunk-KPMKHGEA.js} +4 -4
  195. package/dist/cli-bundle/chunks/{chunk-QASRVKUQ.js → chunk-LPYWLWDS.js} +257 -163
  196. package/dist/cli-bundle/chunks/chunk-LPYWLWDS.js.map +1 -0
  197. package/dist/cli-bundle/chunks/{chunk-RGXD5JJR.js → chunk-LSG2U345.js} +19 -12
  198. package/dist/cli-bundle/chunks/chunk-LSG2U345.js.map +7 -0
  199. package/dist/cli-bundle/chunks/chunk-MIQDDLB5.js +5 -0
  200. package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js → chunk-NLDFBC6J.js} +2 -2
  201. package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js → chunk-NP22ERDF.js} +3 -3
  202. package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js → chunk-NU3IMIEA.js} +2 -2
  203. package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js → chunk-NVPZIJVR.js} +2 -2
  204. package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js → chunk-ODALILG3.js} +2 -2
  205. package/dist/cli-bundle/chunks/{chunk-CDJYP7OQ.js → chunk-ONG5V5CI.js} +190 -63
  206. package/dist/cli-bundle/chunks/chunk-ONG5V5CI.js.map +1 -0
  207. package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js → chunk-ONREO4ST.js} +3 -3
  208. package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js +61 -0
  209. package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js.map +1 -0
  210. package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js → chunk-P74IZQ7A.js} +12 -12
  211. package/dist/cli-bundle/chunks/chunk-PENXZX3U.js +172 -0
  212. package/dist/cli-bundle/chunks/chunk-PENXZX3U.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js → chunk-PGY23YTC.js} +3 -3
  214. package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js → chunk-PMOSXADO.js} +3 -3
  215. package/dist/cli-bundle/chunks/chunk-PNTULOGU.js +9 -0
  216. package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js → chunk-Q7A43DS4.js} +2 -2
  217. package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js → chunk-QEHQ2GVG.js} +2 -2
  218. package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js → chunk-QIPLHNP7.js} +7 -7
  219. package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js → chunk-QKECXBBG.js} +3 -3
  220. package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js.map → chunk-QKECXBBG.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js → chunk-QKJGPFAF.js} +3 -3
  222. package/dist/cli-bundle/chunks/{chunk-F7PSHRNO.js → chunk-QKXHFPYM.js} +27 -10
  223. package/dist/cli-bundle/chunks/chunk-QKXHFPYM.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js → chunk-RLCHOOHC.js} +2 -2
  225. package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js → chunk-RMLWNPH2.js} +2 -2
  226. package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js → chunk-RRM5JYJC.js} +2 -2
  227. package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js → chunk-S6MQESFR.js} +4 -4
  228. package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js → chunk-SDQLJWBO.js} +4 -4
  229. package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js → chunk-SELVXEZK.js} +2 -2
  230. package/dist/cli-bundle/chunks/{chunk-DYEX6NFH.js → chunk-TD3LVC7D.js} +438 -23
  231. package/dist/cli-bundle/chunks/chunk-TD3LVC7D.js.map +7 -0
  232. package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js → chunk-TKOVBP6C.js} +2 -2
  233. package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js → chunk-TQSZFPIS.js} +4 -4
  234. package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js → chunk-TSMHDIW4.js} +2 -2
  235. package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js → chunk-UFXU44HV.js} +4 -4
  236. package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js → chunk-ULTHRDBP.js} +3 -3
  237. package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js → chunk-UMOPHQSU.js} +9 -9
  238. package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js.map → chunk-UMOPHQSU.js.map} +2 -2
  239. package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js → chunk-UOHFKBUV.js} +3 -3
  240. package/dist/cli-bundle/chunks/{chunk-PHKP3AGR.js → chunk-UWQHLMEB.js} +35 -18
  241. package/dist/cli-bundle/chunks/chunk-UWQHLMEB.js.map +7 -0
  242. package/dist/cli-bundle/chunks/{chunk-6TTOHMTB.js → chunk-UXONS674.js} +45 -112
  243. package/dist/cli-bundle/chunks/chunk-UXONS674.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js → chunk-UY2ACEMF.js} +7 -7
  245. package/dist/cli-bundle/chunks/{chunk-6PKA3SJQ.js → chunk-WQPUU7XD.js} +19 -28
  246. package/dist/cli-bundle/chunks/chunk-WQPUU7XD.js.map +1 -0
  247. package/dist/cli-bundle/chunks/{chunk-7TQMR6LK.js → chunk-WT3ZEOGH.js} +70 -20
  248. package/dist/cli-bundle/chunks/chunk-WT3ZEOGH.js.map +7 -0
  249. package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js → chunk-WUJQK4YV.js} +4 -4
  250. package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js → chunk-XSJUSQAE.js} +2 -2
  251. package/dist/cli-bundle/chunks/{chunk-6MHSBDGD.js → chunk-XXXF6PAQ.js} +50 -117
  252. package/dist/cli-bundle/chunks/chunk-XXXF6PAQ.js.map +7 -0
  253. package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js → chunk-YAQEBNY7.js} +4 -4
  254. package/dist/cli-bundle/chunks/{chunk-7QDSYUMF.js → chunk-YAROI3PD.js} +44 -21
  255. package/dist/cli-bundle/chunks/chunk-YAROI3PD.js.map +1 -0
  256. package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js → chunk-YBLZ2VE7.js} +13 -13
  257. package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js → chunk-YCQET3OT.js} +2 -2
  258. package/dist/cli-bundle/chunks/chunk-YUSOJDWM.js +9 -0
  259. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js +58 -0
  260. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js → chunk-ZI6VQWQ7.js} +4 -4
  262. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js +68 -0
  263. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js.map +7 -0
  264. package/dist/cli-bundle/chunks/{close-LZECOMHO.js → close-CWODTPKG.js} +5 -5
  265. package/dist/cli-bundle/chunks/close-W6LI2PKM.js +12 -0
  266. package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js → close-many-CQFUY7MR.js} +15 -13
  267. package/dist/cli-bundle/chunks/close-many-DLDDVSH5.js +23 -0
  268. package/dist/cli-bundle/chunks/comments-E3TNTK24.js +13 -0
  269. package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js → comments-WGLHR7LB.js} +7 -7
  270. package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js → copy-LXVDXH7B.js} +4 -4
  271. package/dist/cli-bundle/chunks/copy-Q5ZJPUKR.js +9 -0
  272. package/dist/cli-bundle/chunks/{create-F53OBTOU.js → create-J5U6ND4K.js} +9 -9
  273. package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js → create-LBVCYMEG.js} +9 -9
  274. package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js → delete-PMJBNY5G.js} +4 -4
  275. package/dist/cli-bundle/chunks/delete-WNHB3LYW.js +10 -0
  276. package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js → deps-JZ7TMVCB.js} +7 -4
  277. package/dist/cli-bundle/chunks/{deps-U57I7EAK.js → deps-OA26IS25.js} +7 -4
  278. package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js → docs-FEWB2DQB.js} +6 -6
  279. package/dist/cli-bundle/chunks/docs-HA2AIDBB.js +14 -0
  280. package/dist/cli-bundle/chunks/{files-TBZD7V6H.js → files-6YFBJRBG.js} +6 -6
  281. package/dist/cli-bundle/chunks/{files-TTY6N2AV.js → files-EFIWKFTM.js} +6 -6
  282. package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js → focus-4QJR7FOQ.js} +5 -5
  283. package/dist/cli-bundle/chunks/focus-POIW5LTJ.js +10 -0
  284. package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js → history-compact-CKRPDTJN.js} +6 -10
  285. package/dist/cli-bundle/chunks/history-compact-FWG2C7FZ.js +16 -0
  286. package/dist/cli-bundle/chunks/history-redact-BB3TGDAE.js +15 -0
  287. package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js → history-redact-D225BHOZ.js} +5 -6
  288. package/dist/cli-bundle/chunks/history-repair-6GEAM7HE.js +16 -0
  289. package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js → history-repair-RQXKQHL4.js} +6 -8
  290. package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js → learnings-JLNLCOL5.js} +7 -7
  291. package/dist/cli-bundle/chunks/learnings-RSNLSWDC.js +13 -0
  292. package/dist/cli-bundle/chunks/notes-2WDH6DXU.js +13 -0
  293. package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js → notes-GB47XXQQ.js} +7 -7
  294. package/dist/cli-bundle/chunks/plan-DOVI2VMW.js +24 -0
  295. package/dist/cli-bundle/chunks/{plan-2NNEO46V.js → plan-VDCJ2PCN.js} +10 -10
  296. package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js → profile-FAU7NZML.js} +10 -10
  297. package/dist/cli-bundle/chunks/{profile-U725ATWZ.js → profile-IVXQEL3D.js} +10 -10
  298. package/dist/cli-bundle/chunks/{register-list-query-BUWCYHBT.js → register-list-query-DKA3EH5D.js} +22 -19
  299. package/dist/cli-bundle/chunks/register-list-query-DKA3EH5D.js.map +7 -0
  300. package/dist/cli-bundle/chunks/{register-list-query-KTZ6AGE7.js → register-list-query-UL4UKBBN.js} +23 -20
  301. package/dist/cli-bundle/chunks/register-list-query-UL4UKBBN.js.map +1 -0
  302. package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js → register-mutation-ARFHRW55.js} +36 -32
  303. package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js.map → register-mutation-ARFHRW55.js.map} +2 -2
  304. package/dist/cli-bundle/chunks/{register-mutation-4FMGJJF7.js → register-mutation-RBBJ52DK.js} +37 -33
  305. package/dist/cli-bundle/chunks/register-mutation-RBBJ52DK.js.map +1 -0
  306. package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js → register-operations-ZIBBRSED.js} +41 -39
  307. package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js.map → register-operations-ZIBBRSED.js.map} +1 -1
  308. package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js → register-operations-ZUJ5JWPE.js} +39 -37
  309. package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js.map → register-operations-ZUJ5JWPE.js.map} +1 -1
  310. package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js → register-setup-BCVLFEYS.js} +29 -17
  311. package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js.map → register-setup-BCVLFEYS.js.map} +2 -2
  312. package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js → register-setup-TDCGWIOS.js} +19 -18
  313. package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js.map → register-setup-TDCGWIOS.js.map} +1 -1
  314. package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js → restore-25DLT2Q2.js} +6 -6
  315. package/dist/cli-bundle/chunks/restore-YPMVUUEX.js +14 -0
  316. package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js → schema-FNU3WE4O.js} +7 -6
  317. package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js → schema-NBCM3RAD.js} +7 -6
  318. package/dist/cli-bundle/chunks/update-WWBYOPXO.js +21 -0
  319. package/dist/cli-bundle/chunks/update-WWBYOPXO.js.map +7 -0
  320. package/dist/cli-bundle/chunks/{update-Q3UCILNR.js → update-XHSIAIXE.js} +12 -12
  321. package/dist/cli-bundle/chunks/update-XHSIAIXE.js.map +1 -0
  322. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js +32 -0
  323. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js.map +7 -0
  324. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js +36 -0
  325. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js.map +1 -0
  326. package/dist/cli-bundle/main.js +826 -43
  327. package/dist/cli-bundle/main.js.map +4 -4
  328. package/dist/cli-bundle/sdk-runtime.js +70 -57
  329. package/dist/cli-bundle/sdk-testing.js +6 -6
  330. package/dist/cli-bundle/sdk.js +876 -74
  331. package/dist/cli-bundle/sdk.js.map +4 -4
  332. package/dist/cli.js +5 -4
  333. package/dist/cli.js.map +1 -1
  334. package/dist/core/diagnostics/remediation.js +12 -2
  335. package/dist/core/diagnostics/remediation.js.map +1 -1
  336. package/dist/core/history/projection.d.ts +39 -0
  337. package/dist/core/history/projection.js +164 -0
  338. package/dist/core/history/projection.js.map +1 -0
  339. package/dist/core/history/read.d.ts +3 -0
  340. package/dist/core/history/read.js +55 -0
  341. package/dist/core/history/read.js.map +1 -0
  342. package/dist/core/output/output-control.d.ts +18 -0
  343. package/dist/core/output/output-control.js +26 -0
  344. package/dist/core/output/output-control.js.map +1 -0
  345. package/dist/core/output/output.js +20 -8
  346. package/dist/core/output/output.js.map +1 -1
  347. package/dist/core/sentry/helpers.js +10 -2
  348. package/dist/core/sentry/helpers.js.map +1 -1
  349. package/dist/core/shared/command-types.d.ts +2 -0
  350. package/dist/core/shared/command-types.js +2 -2
  351. package/dist/core/shared/command-types.js.map +1 -1
  352. package/dist/core/shared/errors.d.ts +11 -0
  353. package/dist/core/shared/errors.js +2 -2
  354. package/dist/core/shared/errors.js.map +1 -1
  355. package/dist/mcp/server.d.ts +2 -2
  356. package/dist/mcp/tool-definitions.js +5 -5
  357. package/dist/mcp/tool-definitions.js.map +1 -1
  358. package/dist/sdk/author-attribution.d.ts +35 -0
  359. package/dist/sdk/author-attribution.js +118 -0
  360. package/dist/sdk/author-attribution.js.map +1 -0
  361. package/dist/sdk/cli-contracts/command-aliases.d.ts +7 -0
  362. package/dist/sdk/cli-contracts/command-aliases.js +17 -0
  363. package/dist/sdk/cli-contracts/command-aliases.js.map +1 -0
  364. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  365. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  366. package/dist/sdk/cli-contracts/tool-option-contracts.js +6 -2
  367. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  368. package/dist/sdk/cli-contracts/tool-parameter-tables.js +21 -2
  369. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  370. package/dist/sdk/cli-contracts/tool-schema.js +3 -3
  371. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  372. package/dist/sdk/cli-contracts.d.ts +1 -0
  373. package/dist/sdk/cli-contracts.js +3 -2
  374. package/dist/sdk/cli-contracts.js.map +1 -1
  375. package/dist/sdk/cli-program.d.ts +8 -0
  376. package/dist/sdk/cli-program.js +39 -0
  377. package/dist/sdk/cli-program.js.map +1 -0
  378. package/dist/sdk/command-line.d.ts +11 -0
  379. package/dist/sdk/command-line.js +40 -0
  380. package/dist/sdk/command-line.js.map +1 -0
  381. package/dist/sdk/config.d.ts +163 -0
  382. package/dist/sdk/config.js +1087 -0
  383. package/dist/sdk/config.js.map +1 -0
  384. package/dist/sdk/context-relevance.d.ts +21 -0
  385. package/dist/sdk/context-relevance.js +70 -2
  386. package/dist/sdk/context-relevance.js.map +1 -1
  387. package/dist/sdk/dependencies.d.ts +15 -2
  388. package/dist/sdk/dependencies.js +97 -8
  389. package/dist/sdk/dependencies.js.map +1 -1
  390. package/dist/{cli/commands → sdk}/extension/bundled-catalog.d.ts +1 -1
  391. package/dist/{cli/commands → sdk}/extension/bundled-catalog.js +12 -12
  392. package/dist/sdk/extension/bundled-catalog.js.map +1 -0
  393. package/dist/sdk/extension/concurrency.d.ts +7 -0
  394. package/dist/sdk/extension/concurrency.js +26 -0
  395. package/dist/sdk/extension/concurrency.js.map +1 -0
  396. package/dist/sdk/extension/describe.d.ts +91 -0
  397. package/dist/sdk/extension/describe.js +144 -0
  398. package/dist/sdk/extension/describe.js.map +1 -0
  399. package/dist/{cli/commands → sdk}/extension/doctor.d.ts +3 -3
  400. package/dist/{cli/commands → sdk}/extension/doctor.js +7 -7
  401. package/dist/sdk/extension/doctor.js.map +1 -0
  402. package/dist/sdk/extension/install-runtime.d.ts +26 -0
  403. package/dist/sdk/extension/install-runtime.js +269 -0
  404. package/dist/sdk/extension/install-runtime.js.map +1 -0
  405. package/dist/sdk/extension/install-snapshot.d.ts +23 -0
  406. package/dist/sdk/extension/install-snapshot.js +66 -0
  407. package/dist/sdk/extension/install-snapshot.js.map +1 -0
  408. package/dist/{cli/commands → sdk}/extension/install-sources.d.ts +3 -3
  409. package/dist/{cli/commands → sdk}/extension/install-sources.js +15 -12
  410. package/dist/sdk/extension/install-sources.js.map +1 -0
  411. package/dist/{cli/commands → sdk}/extension/managed-state.js +6 -6
  412. package/dist/sdk/extension/managed-state.js.map +1 -0
  413. package/dist/sdk/extension/scaffold.d.ts +36 -0
  414. package/dist/sdk/extension/scaffold.js +2436 -0
  415. package/dist/sdk/extension/scaffold.js.map +1 -0
  416. package/dist/sdk/extension/shared.d.ts +28 -0
  417. package/dist/sdk/extension/shared.js +140 -0
  418. package/dist/sdk/extension/shared.js.map +1 -0
  419. package/dist/sdk/extension/update-check.d.ts +15 -0
  420. package/dist/sdk/extension/update-check.js +68 -0
  421. package/dist/sdk/extension/update-check.js.map +1 -0
  422. package/dist/sdk/extension.d.ts +367 -0
  423. package/dist/sdk/extension.js +2174 -0
  424. package/dist/sdk/extension.js.map +1 -0
  425. package/dist/sdk/governance/gc.d.ts +56 -0
  426. package/dist/sdk/governance/gc.js +276 -0
  427. package/dist/sdk/governance/gc.js.map +1 -0
  428. package/dist/sdk/governance/health.d.ts +187 -0
  429. package/dist/sdk/governance/health.js +1796 -0
  430. package/dist/sdk/governance/health.js.map +1 -0
  431. package/dist/sdk/governance/validate.d.ts +255 -0
  432. package/dist/sdk/governance/validate.js +2175 -0
  433. package/dist/sdk/governance/validate.js.map +1 -0
  434. package/dist/sdk/history-compact.d.ts +142 -0
  435. package/dist/sdk/history-compact.js +508 -0
  436. package/dist/sdk/history-compact.js.map +1 -0
  437. package/dist/sdk/history-mcp.d.ts +17 -0
  438. package/dist/sdk/history-mcp.js +68 -0
  439. package/dist/sdk/history-mcp.js.map +1 -0
  440. package/dist/sdk/history-read.d.ts +31 -0
  441. package/dist/sdk/history-read.js +58 -0
  442. package/dist/sdk/history-read.js.map +1 -0
  443. package/dist/sdk/history-redact.d.ts +120 -0
  444. package/dist/sdk/history-redact.js +577 -0
  445. package/dist/sdk/history-redact.js.map +1 -0
  446. package/dist/sdk/history-repair.d.ts +89 -0
  447. package/dist/sdk/history-repair.js +263 -0
  448. package/dist/sdk/history-repair.js.map +1 -0
  449. package/dist/sdk/index.d.ts +25 -1
  450. package/dist/sdk/index.js +27 -3
  451. package/dist/sdk/index.js.map +1 -1
  452. package/dist/sdk/init-agent-guidance.d.ts +113 -0
  453. package/dist/sdk/init-agent-guidance.js +437 -0
  454. package/dist/sdk/init-agent-guidance.js.map +1 -0
  455. package/dist/sdk/init.d.ts +186 -0
  456. package/dist/sdk/init.js +733 -0
  457. package/dist/sdk/init.js.map +1 -0
  458. package/dist/sdk/invocation-author.d.ts +2 -0
  459. package/dist/sdk/invocation-author.js +39 -0
  460. package/dist/sdk/invocation-author.js.map +1 -0
  461. package/dist/sdk/item-children.d.ts +45 -0
  462. package/dist/sdk/item-children.js +75 -0
  463. package/dist/sdk/item-children.js.map +1 -0
  464. package/dist/sdk/item-schedule.d.ts +26 -0
  465. package/dist/sdk/item-schedule.js +28 -0
  466. package/dist/sdk/item-schedule.js.map +1 -0
  467. package/dist/sdk/output.d.ts +7 -0
  468. package/dist/sdk/output.js +11 -0
  469. package/dist/sdk/output.js.map +1 -0
  470. package/dist/sdk/pagination.d.ts +4 -1
  471. package/dist/sdk/pagination.js +13 -5
  472. package/dist/sdk/pagination.js.map +1 -1
  473. package/dist/sdk/profile.d.ts +176 -0
  474. package/dist/sdk/profile.js +431 -0
  475. package/dist/sdk/profile.js.map +1 -0
  476. package/dist/sdk/relationship-analytics.d.ts +108 -0
  477. package/dist/sdk/relationship-analytics.js +292 -0
  478. package/dist/sdk/relationship-analytics.js.map +1 -0
  479. package/dist/sdk/relationship-context.d.ts +67 -0
  480. package/dist/sdk/relationship-context.js +207 -0
  481. package/dist/sdk/relationship-context.js.map +1 -0
  482. package/dist/sdk/relationship-history.d.ts +109 -0
  483. package/dist/sdk/relationship-history.js +401 -0
  484. package/dist/sdk/relationship-history.js.map +1 -0
  485. package/dist/sdk/relationships.d.ts +145 -0
  486. package/dist/sdk/relationships.js +551 -0
  487. package/dist/sdk/relationships.js.map +1 -0
  488. package/dist/sdk/runtime-input.d.ts +10 -0
  489. package/dist/sdk/runtime-input.js +60 -0
  490. package/dist/sdk/runtime-input.js.map +1 -0
  491. package/dist/sdk/runtime.d.ts +31 -8
  492. package/dist/sdk/runtime.js +61 -57
  493. package/dist/sdk/runtime.js.map +1 -1
  494. package/dist/sdk/schema.d.ts +507 -0
  495. package/dist/sdk/schema.js +1269 -0
  496. package/dist/sdk/schema.js.map +1 -0
  497. package/dist/{cli/commands → sdk}/templates.d.ts +1 -1
  498. package/dist/{cli/commands → sdk}/templates.js +9 -9
  499. package/dist/sdk/templates.js.map +1 -0
  500. package/dist/{cli/commands → sdk}/test/linked-command-detection.d.ts +10 -2
  501. package/dist/sdk/test/linked-command-detection.js +525 -0
  502. package/dist/sdk/test/linked-command-detection.js.map +1 -0
  503. package/docs/COMMANDS.md +58 -40
  504. package/docs/EXTENSIONS.md +10 -1
  505. package/docs/RELATIONSHIP_GRAPH.md +113 -0
  506. package/docs/RELEASING.md +2 -0
  507. package/docs/SDK.md +156 -9
  508. package/docs/SDK_CUSTOMIZATION_PRIMITIVES.md +79 -0
  509. package/marketplace.json +2 -2
  510. package/package.json +3 -2
  511. package/packages/pm-beads/package.json +1 -1
  512. package/packages/pm-calendar/package.json +1 -1
  513. package/packages/pm-command-kit/package.json +1 -1
  514. package/packages/pm-governance-audit/extensions/governance-audit/runtime-utils.ts +76 -16
  515. package/packages/pm-governance-audit/extensions/governance-audit/sdk.ts +8 -0
  516. package/packages/pm-governance-audit/package.json +1 -1
  517. package/packages/pm-guide-shell/package.json +1 -1
  518. package/packages/pm-kanban/package.json +1 -1
  519. package/packages/pm-lifecycle-hooks/package.json +1 -1
  520. package/packages/pm-linked-test-adapters/package.json +1 -1
  521. package/packages/pm-search-advanced/package.json +1 -1
  522. package/packages/pm-templates/package.json +1 -1
  523. package/packages/pm-todos/package.json +1 -1
  524. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  525. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  526. package/scripts/bundle-cli.mjs +66 -23
  527. package/dist/cli/commands/extension/bundled-catalog.js.map +0 -1
  528. package/dist/cli/commands/extension/doctor.js.map +0 -1
  529. package/dist/cli/commands/extension/install-sources.js.map +0 -1
  530. package/dist/cli/commands/extension/managed-state.js.map +0 -1
  531. package/dist/cli/commands/templates.js.map +0 -1
  532. package/dist/cli/commands/test/linked-command-detection.js +0 -248
  533. package/dist/cli/commands/test/linked-command-detection.js.map +0 -1
  534. package/dist/cli-bundle/chunks/append-DYQWQK2J.js +0 -11
  535. package/dist/cli-bundle/chunks/chunk-2GA3NK35.js +0 -530
  536. package/dist/cli-bundle/chunks/chunk-2GA3NK35.js.map +0 -1
  537. package/dist/cli-bundle/chunks/chunk-2QIQGYPW.js.map +0 -7
  538. package/dist/cli-bundle/chunks/chunk-4DY4KPQI.js.map +0 -7
  539. package/dist/cli-bundle/chunks/chunk-4WREH7RT.js +0 -554
  540. package/dist/cli-bundle/chunks/chunk-4WREH7RT.js.map +0 -7
  541. package/dist/cli-bundle/chunks/chunk-5CT5BW6E.js.map +0 -7
  542. package/dist/cli-bundle/chunks/chunk-5URI7TPJ.js.map +0 -7
  543. package/dist/cli-bundle/chunks/chunk-6MHSBDGD.js.map +0 -7
  544. package/dist/cli-bundle/chunks/chunk-6OTZMORS.js.map +0 -7
  545. package/dist/cli-bundle/chunks/chunk-6PKA3SJQ.js.map +0 -1
  546. package/dist/cli-bundle/chunks/chunk-6TTOHMTB.js.map +0 -1
  547. package/dist/cli-bundle/chunks/chunk-7QDSYUMF.js.map +0 -1
  548. package/dist/cli-bundle/chunks/chunk-7TQMR6LK.js.map +0 -7
  549. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js +0 -312
  550. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js.map +0 -7
  551. package/dist/cli-bundle/chunks/chunk-BPD26E3P.js.map +0 -1
  552. package/dist/cli-bundle/chunks/chunk-CDJYP7OQ.js.map +0 -1
  553. package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js +0 -858
  554. package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js.map +0 -1
  555. package/dist/cli-bundle/chunks/chunk-DVOLZJ3C.js.map +0 -1
  556. package/dist/cli-bundle/chunks/chunk-DYEX6NFH.js.map +0 -7
  557. package/dist/cli-bundle/chunks/chunk-F7PSHRNO.js.map +0 -1
  558. package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js +0 -875
  559. package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js.map +0 -7
  560. package/dist/cli-bundle/chunks/chunk-FTQLW4JD.js.map +0 -1
  561. package/dist/cli-bundle/chunks/chunk-IA3YFTXT.js.map +0 -1
  562. package/dist/cli-bundle/chunks/chunk-IGED7NH2.js.map +0 -7
  563. package/dist/cli-bundle/chunks/chunk-J4NZOP3I.js.map +0 -1
  564. package/dist/cli-bundle/chunks/chunk-JL7WZ4O2.js.map +0 -7
  565. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js +0 -309
  566. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js.map +0 -1
  567. package/dist/cli-bundle/chunks/chunk-LWTIRS3Y.js.map +0 -7
  568. package/dist/cli-bundle/chunks/chunk-MKL4CP2I.js.map +0 -1
  569. package/dist/cli-bundle/chunks/chunk-N3CMP4NI.js.map +0 -1
  570. package/dist/cli-bundle/chunks/chunk-PHKP3AGR.js.map +0 -7
  571. package/dist/cli-bundle/chunks/chunk-Q37E63AM.js.map +0 -7
  572. package/dist/cli-bundle/chunks/chunk-QASRVKUQ.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-RGXD5JJR.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-UB2QYSTO.js.map +0 -1
  575. package/dist/cli-bundle/chunks/chunk-UGTVWL3E.js.map +0 -1
  576. package/dist/cli-bundle/chunks/chunk-ZAYYDNB3.js.map +0 -1
  577. package/dist/cli-bundle/chunks/chunk-ZUKSZVBW.js.map +0 -7
  578. package/dist/cli-bundle/chunks/close-RI4JQQHU.js +0 -12
  579. package/dist/cli-bundle/chunks/close-many-LY2XJ52M.js +0 -21
  580. package/dist/cli-bundle/chunks/comments-35M273DN.js +0 -13
  581. package/dist/cli-bundle/chunks/copy-NPYM7M7U.js +0 -9
  582. package/dist/cli-bundle/chunks/delete-ODRWJWAM.js +0 -10
  583. package/dist/cli-bundle/chunks/docs-G7N4E2JO.js +0 -14
  584. package/dist/cli-bundle/chunks/focus-U5TRVCRS.js +0 -10
  585. package/dist/cli-bundle/chunks/history-compact-M7GHYVFN.js +0 -20
  586. package/dist/cli-bundle/chunks/history-redact-JIHZLHDP.js +0 -16
  587. package/dist/cli-bundle/chunks/history-repair-NAFCHLH7.js +0 -18
  588. package/dist/cli-bundle/chunks/learnings-SONGPSHI.js +0 -13
  589. package/dist/cli-bundle/chunks/notes-BSD53H2W.js +0 -13
  590. package/dist/cli-bundle/chunks/plan-AWLYGBNV.js +0 -24
  591. package/dist/cli-bundle/chunks/register-list-query-BUWCYHBT.js.map +0 -7
  592. package/dist/cli-bundle/chunks/register-list-query-KTZ6AGE7.js.map +0 -1
  593. package/dist/cli-bundle/chunks/register-mutation-4FMGJJF7.js.map +0 -1
  594. package/dist/cli-bundle/chunks/restore-66GLMHIX.js +0 -14
  595. package/dist/cli-bundle/chunks/update-2XGHIVQ2.js +0 -21
  596. package/dist/cli-bundle/chunks/update-many-75K57FS3.js +0 -34
  597. package/dist/cli-bundle/chunks/update-many-U42YA445.js +0 -30
  598. /package/dist/cli-bundle/chunks/{append-PVZJDM6J.js.map → append-OJQFUQ4T.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{append-DYQWQK2J.js.map → append-UZVHUO74.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js.map → chunk-2IFFUZLC.js.map} +0 -0
  601. /package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js.map → chunk-2JKGO6QX.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js.map → chunk-2NCIPMQP.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js.map → chunk-2VPAVL7O.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js.map → chunk-2WSE6PO2.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js.map → chunk-34L5OT3Y.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js.map → chunk-3AUGG2DP.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js.map → chunk-3CLU2XZO.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js.map → chunk-3WM75PWC.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js.map → chunk-5JLUII3O.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js.map → chunk-6N2VXVTQ.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js.map → chunk-6S3YSUYG.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js.map → chunk-AHVTB5I5.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js.map → chunk-APRVSW2O.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js.map → chunk-B7PE22W6.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js.map → chunk-BCOFWYW4.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js.map → chunk-BEP7WJA2.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js.map → chunk-CRVF2JDM.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js.map → chunk-DM4H7FP4.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{close-LZECOMHO.js.map → chunk-DUT67M43.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{chunk-44LNIULG.js.map → chunk-DYH63FX7.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js.map → chunk-EAB64KLB.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js.map → chunk-EACOH7AU.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js.map → chunk-EJEXHTY5.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js.map → chunk-EYLCSJAI.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{chunk-655STMGA.js.map → chunk-FMBNM2EN.js.map} +0 -0
  626. /package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js.map → chunk-FNSPG7MU.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{chunk-KB726FMH.js.map → chunk-H2Z3FYXQ.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js.map → chunk-IA5FKNII.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js.map → chunk-IJIICKVW.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js.map → chunk-JOUQZENX.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js.map → chunk-JYFOV7FC.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js.map → chunk-K2X6U4UA.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js.map → chunk-KG44YSKD.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js.map → chunk-KPMKHGEA.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js.map → chunk-MIQDDLB5.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js.map → chunk-NLDFBC6J.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js.map → chunk-NP22ERDF.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js.map → chunk-NU3IMIEA.js.map} +0 -0
  639. /package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js.map → chunk-NVPZIJVR.js.map} +0 -0
  640. /package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js.map → chunk-ODALILG3.js.map} +0 -0
  641. /package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js.map → chunk-ONREO4ST.js.map} +0 -0
  642. /package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js.map → chunk-P74IZQ7A.js.map} +0 -0
  643. /package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js.map → chunk-PGY23YTC.js.map} +0 -0
  644. /package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js.map → chunk-PMOSXADO.js.map} +0 -0
  645. /package/dist/cli-bundle/chunks/{close-RI4JQQHU.js.map → chunk-PNTULOGU.js.map} +0 -0
  646. /package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js.map → chunk-Q7A43DS4.js.map} +0 -0
  647. /package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js.map → chunk-QEHQ2GVG.js.map} +0 -0
  648. /package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js.map → chunk-QIPLHNP7.js.map} +0 -0
  649. /package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js.map → chunk-QKJGPFAF.js.map} +0 -0
  650. /package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js.map → chunk-RLCHOOHC.js.map} +0 -0
  651. /package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js.map → chunk-RMLWNPH2.js.map} +0 -0
  652. /package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js.map → chunk-RRM5JYJC.js.map} +0 -0
  653. /package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js.map → chunk-S6MQESFR.js.map} +0 -0
  654. /package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js.map → chunk-SDQLJWBO.js.map} +0 -0
  655. /package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js.map → chunk-SELVXEZK.js.map} +0 -0
  656. /package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js.map → chunk-TKOVBP6C.js.map} +0 -0
  657. /package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js.map → chunk-TQSZFPIS.js.map} +0 -0
  658. /package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js.map → chunk-TSMHDIW4.js.map} +0 -0
  659. /package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js.map → chunk-UFXU44HV.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js.map → chunk-ULTHRDBP.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js.map → chunk-UOHFKBUV.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js.map → chunk-UY2ACEMF.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js.map → chunk-WUJQK4YV.js.map} +0 -0
  664. /package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js.map → chunk-XSJUSQAE.js.map} +0 -0
  665. /package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js.map → chunk-YAQEBNY7.js.map} +0 -0
  666. /package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js.map → chunk-YBLZ2VE7.js.map} +0 -0
  667. /package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js.map → chunk-YCQET3OT.js.map} +0 -0
  668. /package/dist/cli-bundle/chunks/{close-many-LY2XJ52M.js.map → chunk-YUSOJDWM.js.map} +0 -0
  669. /package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js.map → chunk-ZI6VQWQ7.js.map} +0 -0
  670. /package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js.map → close-CWODTPKG.js.map} +0 -0
  671. /package/dist/cli-bundle/chunks/{comments-35M273DN.js.map → close-W6LI2PKM.js.map} +0 -0
  672. /package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js.map → close-many-CQFUY7MR.js.map} +0 -0
  673. /package/dist/cli-bundle/chunks/{copy-NPYM7M7U.js.map → close-many-DLDDVSH5.js.map} +0 -0
  674. /package/dist/cli-bundle/chunks/{create-F53OBTOU.js.map → comments-E3TNTK24.js.map} +0 -0
  675. /package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js.map → comments-WGLHR7LB.js.map} +0 -0
  676. /package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js.map → copy-LXVDXH7B.js.map} +0 -0
  677. /package/dist/cli-bundle/chunks/{delete-ODRWJWAM.js.map → copy-Q5ZJPUKR.js.map} +0 -0
  678. /package/dist/cli-bundle/chunks/{deps-U57I7EAK.js.map → create-J5U6ND4K.js.map} +0 -0
  679. /package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js.map → create-LBVCYMEG.js.map} +0 -0
  680. /package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js.map → delete-PMJBNY5G.js.map} +0 -0
  681. /package/dist/cli-bundle/chunks/{docs-G7N4E2JO.js.map → delete-WNHB3LYW.js.map} +0 -0
  682. /package/dist/cli-bundle/chunks/{files-TTY6N2AV.js.map → deps-JZ7TMVCB.js.map} +0 -0
  683. /package/dist/cli-bundle/chunks/{files-TBZD7V6H.js.map → deps-OA26IS25.js.map} +0 -0
  684. /package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js.map → docs-FEWB2DQB.js.map} +0 -0
  685. /package/dist/cli-bundle/chunks/{focus-U5TRVCRS.js.map → docs-HA2AIDBB.js.map} +0 -0
  686. /package/dist/cli-bundle/chunks/{history-compact-M7GHYVFN.js.map → files-6YFBJRBG.js.map} +0 -0
  687. /package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js.map → files-EFIWKFTM.js.map} +0 -0
  688. /package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js.map → focus-4QJR7FOQ.js.map} +0 -0
  689. /package/dist/cli-bundle/chunks/{history-redact-JIHZLHDP.js.map → focus-POIW5LTJ.js.map} +0 -0
  690. /package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js.map → history-compact-CKRPDTJN.js.map} +0 -0
  691. /package/dist/cli-bundle/chunks/{history-repair-NAFCHLH7.js.map → history-compact-FWG2C7FZ.js.map} +0 -0
  692. /package/dist/cli-bundle/chunks/{learnings-SONGPSHI.js.map → history-redact-BB3TGDAE.js.map} +0 -0
  693. /package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js.map → history-redact-D225BHOZ.js.map} +0 -0
  694. /package/dist/cli-bundle/chunks/{notes-BSD53H2W.js.map → history-repair-6GEAM7HE.js.map} +0 -0
  695. /package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js.map → history-repair-RQXKQHL4.js.map} +0 -0
  696. /package/dist/cli-bundle/chunks/{plan-2NNEO46V.js.map → learnings-JLNLCOL5.js.map} +0 -0
  697. /package/dist/cli-bundle/chunks/{plan-AWLYGBNV.js.map → learnings-RSNLSWDC.js.map} +0 -0
  698. /package/dist/cli-bundle/chunks/{profile-U725ATWZ.js.map → notes-2WDH6DXU.js.map} +0 -0
  699. /package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js.map → notes-GB47XXQQ.js.map} +0 -0
  700. /package/dist/cli-bundle/chunks/{restore-66GLMHIX.js.map → plan-DOVI2VMW.js.map} +0 -0
  701. /package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js.map → plan-VDCJ2PCN.js.map} +0 -0
  702. /package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js.map → profile-FAU7NZML.js.map} +0 -0
  703. /package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js.map → profile-IVXQEL3D.js.map} +0 -0
  704. /package/dist/cli-bundle/chunks/{update-Q3UCILNR.js.map → restore-25DLT2Q2.js.map} +0 -0
  705. /package/dist/cli-bundle/chunks/{update-2XGHIVQ2.js.map → restore-YPMVUUEX.js.map} +0 -0
  706. /package/dist/cli-bundle/chunks/{update-many-75K57FS3.js.map → schema-FNU3WE4O.js.map} +0 -0
  707. /package/dist/cli-bundle/chunks/{update-many-U42YA445.js.map → schema-NBCM3RAD.js.map} +0 -0
  708. /package/dist/{cli/commands → sdk}/extension/managed-state.d.ts +0 -0
@@ -1,34 +1,35 @@
1
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]="6800d243-3c57-59f4-8e55-c1613574d53e")}catch(e){}}();
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]="f34a834c-7c67-555c-a8b0-6c26e7d8c12a")}catch(e){}}();
3
+ import {
4
+ ensureTypeFolderScaffold
5
+ } from "./chunk-INU6DKT5.js";
3
6
  import {
4
- EXECUTABLE_COMMAND_ALIASES,
5
7
  normalizeExtensionNameForMatch,
6
8
  normalizeManagedDirectoryName,
7
9
  normalizeStringList,
8
10
  parseExtensionManifest,
11
+ quoteCommandArg,
9
12
  renderPmCommand,
10
13
  validateExtensionDirectory
11
- } from "./chunk-DBZVUJTK.js";
14
+ } from "./chunk-H3EIEWGR.js";
12
15
  import {
13
16
  describeExtensionActivation,
14
17
  renderExtensionSurfaceMarkdown
15
- } from "./chunk-MQZ3PLCF.js";
16
- import {
17
- ensureTypeFolderScaffold
18
- } from "./chunk-UGTVWL3E.js";
18
+ } from "./chunk-2IFFUZLC.js";
19
19
  import {
20
20
  TYPE_PRESET_NAMES,
21
21
  normalizeTypePresetName,
22
22
  resolveTypePresetDefinitions
23
- } from "./chunk-ABRCOSDC.js";
23
+ } from "./chunk-3WM75PWC.js";
24
24
  import {
25
+ EXECUTABLE_COMMAND_ALIASES,
25
26
  PM_CORE_COMMAND_NAMES
26
- } from "./chunk-N3CMP4NI.js";
27
+ } from "./chunk-3S5QVM5H.js";
27
28
  import {
28
29
  parseItemTypesFile,
29
30
  serializeItemTypesFile,
30
31
  upsertItemType
31
- } from "./chunk-3TL7WOEF.js";
32
+ } from "./chunk-6N2VXVTQ.js";
32
33
  import {
33
34
  splitCommaList
34
35
  } from "./chunk-NETP4DY4.js";
@@ -40,7 +41,7 @@ import {
40
41
  readSettings,
41
42
  runActiveOnWriteHooks,
42
43
  writeSettings
43
- } from "./chunk-GSEADLRH.js";
44
+ } from "./chunk-Q7A43DS4.js";
44
45
  import {
45
46
  DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,
46
47
  EXIT_CODE,
@@ -53,6 +54,7 @@ import {
53
54
  activateExtensions,
54
55
  ensureRuntimeSchemaFileScaffold,
55
56
  filePathForSchemaSection,
57
+ getSettingsPath,
56
58
  isPathWithinDirectory,
57
59
  levenshteinDistanceWithinLimit,
58
60
  loadExtensions,
@@ -69,7 +71,7 @@ import {
69
71
  resolvePmPackageRootFromModule,
70
72
  resolvePmRoot,
71
73
  writeFileAtomic
72
- } from "./chunk-GXXC7QSK.js";
74
+ } from "./chunk-QKECXBBG.js";
73
75
 
74
76
  // dist/core/packages/manifest.js
75
77
  import fs from "node:fs/promises";
@@ -277,7 +279,7 @@ async function collectPackageExtensionDirectories(packageRoot) {
277
279
  return [...discovered].sort((left, right) => left.localeCompare(right));
278
280
  }
279
281
 
280
- // dist/cli/commands/extension/scaffold.js
282
+ // dist/sdk/extension/scaffold.js
281
283
  import fs2 from "node:fs/promises";
282
284
  import path2 from "node:path";
283
285
  var SCAFFOLD_MANIFEST_VERSION = 1;
@@ -2435,7 +2437,7 @@ async function scaffoldExtensionProject(target, vocabulary = "extension", capabi
2435
2437
  };
2436
2438
  }
2437
2439
 
2438
- // dist/cli/commands/extension/describe.js
2440
+ // dist/sdk/extension/describe.js
2439
2441
  function layerNameKey(layer, name) {
2440
2442
  return `${layer}:${normalizeExtensionNameForMatch(name)}`;
2441
2443
  }
@@ -2504,15 +2506,11 @@ function renderExtensionDescribeMarkdown(result, noun) {
2504
2506
  `;
2505
2507
  }
2506
2508
 
2507
- // dist/cli/commands/extension.js
2508
- import { execFile as execFile2 } from "node:child_process";
2509
- import fs6 from "node:fs/promises";
2510
- import os2 from "node:os";
2511
- import path6 from "node:path";
2512
- import { fileURLToPath as fileURLToPath2 } from "node:url";
2513
- import { promisify as promisify2 } from "node:util";
2509
+ // dist/sdk/extension.js
2510
+ import fs8 from "node:fs/promises";
2511
+ import path8 from "node:path";
2514
2512
 
2515
- // dist/cli/commands/extension/managed-state.js
2513
+ // dist/sdk/extension/managed-state.js
2516
2514
  import fs3 from "node:fs/promises";
2517
2515
  import path3 from "node:path";
2518
2516
  var MANAGED_EXTENSION_STATE_FILENAME = ".managed-extensions.json";
@@ -2683,7 +2681,7 @@ function upsertManagedEntry(state, entry) {
2683
2681
  };
2684
2682
  }
2685
2683
 
2686
- // dist/cli/commands/extension/install-sources.js
2684
+ // dist/sdk/extension/install-sources.js
2687
2685
  import { execFile } from "node:child_process";
2688
2686
  import fs5 from "node:fs/promises";
2689
2687
  import os from "node:os";
@@ -2691,7 +2689,7 @@ import path5 from "node:path";
2691
2689
  import { fileURLToPath } from "node:url";
2692
2690
  import { promisify } from "node:util";
2693
2691
 
2694
- // dist/cli/commands/extension/bundled-catalog.js
2692
+ // dist/sdk/extension/bundled-catalog.js
2695
2693
  import fs4 from "node:fs/promises";
2696
2694
  import path4 from "node:path";
2697
2695
  var PM_PACKAGE_ROOT_ENV = "PM_CLI_PACKAGE_ROOT";
@@ -2712,7 +2710,7 @@ function resolvePackageRootCandidates() {
2712
2710
  if (typeof envRoot === "string" && envRoot.trim().length > 0) {
2713
2711
  candidates.push(path4.resolve(envRoot.trim()));
2714
2712
  }
2715
- candidates.push(resolvePmPackageRootFromModule(import.meta.url, ["../../../.."]));
2713
+ candidates.push(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]));
2716
2714
  return [...new Set(candidates)];
2717
2715
  }
2718
2716
  async function resolveBundledExtensionAliasSource(input3) {
@@ -2940,7 +2938,7 @@ function projectPackageCatalogEntry(entry, fields) {
2940
2938
  return projected;
2941
2939
  }
2942
2940
 
2943
- // dist/cli/commands/extension/install-sources.js
2941
+ // dist/sdk/extension/install-sources.js
2944
2942
  var execFileAsync = promisify(execFile);
2945
2943
  var PM_CLI_PACKAGE_NAME = "@unbrained/pm-cli";
2946
2944
  var bundledPackageAliasesCache;
@@ -3041,9 +3039,12 @@ function parseExtensionInstallSource(input3, options = {}) {
3041
3039
  absolute_path: path5.resolve(process.cwd(), normalizedInput)
3042
3040
  };
3043
3041
  }
3044
- async function runGitCommand(args, execRunner = execFileAsync) {
3042
+ async function runGitCommand(args, execRunner = execFileAsync, timeoutMs) {
3045
3043
  try {
3046
- const result = await execRunner("git", args, { encoding: "utf8" });
3044
+ const result = await execRunner("git", args, {
3045
+ encoding: "utf8",
3046
+ timeout: timeoutMs
3047
+ });
3047
3048
  return (result.stdout ?? "").trim();
3048
3049
  } catch (error) {
3049
3050
  const stderr = typeof error === "object" && error !== null && "stderr" in error ? String(error.stderr) : "";
@@ -3360,7 +3361,7 @@ function removeHostedPmCliDependency(manifest) {
3360
3361
  }
3361
3362
  async function linkHostedPmCliDependency(packageRoot) {
3362
3363
  const hostPackageRoot = resolvePmPackageRootFromModule(import.meta.url, [
3363
- "../../../.."
3364
+ "../../.."
3364
3365
  ]);
3365
3366
  const [scope, packageName] = PM_CLI_PACKAGE_NAME.split("/");
3366
3367
  const scopedDirectory = path5.join(packageRoot, "node_modules", scope);
@@ -3545,7 +3546,7 @@ async function areDirectoriesEquivalent(left, right) {
3545
3546
  return leftRealPath === rightRealPath;
3546
3547
  }
3547
3548
 
3548
- // dist/cli/commands/extension/doctor.js
3549
+ // dist/sdk/extension/doctor.js
3549
3550
  function addRuntimePath(pathsByExtension, extensionName, pathValue) {
3550
3551
  const normalizedName = normalizeExtensionNameForMatch(extensionName);
3551
3552
  const normalizedPath = pathValue.trim();
@@ -4055,12 +4056,347 @@ function buildDoctorConsistencySummary(scope, installedExtensions, loadedExtensi
4055
4056
  };
4056
4057
  }
4057
4058
 
4058
- // dist/cli/commands/extension.js
4059
- var execFileAsync2 = promisify2(execFile2);
4059
+ // dist/sdk/extension/install-runtime.js
4060
+ import { randomUUID } from "node:crypto";
4061
+ import fs6 from "node:fs/promises";
4062
+ import os2 from "node:os";
4063
+ import path6 from "node:path";
4060
4064
  var EXTENSION_INSTALL_COPY_ATTEMPTS = 3;
4061
4065
  var EXTENSION_INSTALL_LOCK_ATTEMPTS = 120;
4062
4066
  var EXTENSION_INSTALL_LOCK_DELAY_MS = 250;
4063
4067
  var EXTENSION_INSTALL_LOCK_STALE_MS = 12e4;
4068
+ var RETRIABLE_EXTENSION_INSTALL_COPY_CODES = /* @__PURE__ */ new Set([
4069
+ "EEXIST",
4070
+ "ENOTEMPTY",
4071
+ "ENOENT"
4072
+ ]);
4073
+ var errnoCode = (error) => typeof error === "object" && error !== null && "code" in error ? error.code : void 0;
4074
+ var isRetriableExtensionInstallCopyError = (error) => RETRIABLE_EXTENSION_INSTALL_COPY_CODES.has(String(errnoCode(error)));
4075
+ var isErrnoCode = (error, code) => errnoCode(error) === code;
4076
+ var sleep = (ms) => new Promise((resolve) => {
4077
+ setTimeout(resolve, ms);
4078
+ });
4079
+ var ensureExtensionModuleTypeMarker = async (destinationDirectory) => {
4080
+ const markerPath = path6.join(destinationDirectory, "package.json");
4081
+ if (await pathExists(markerPath)) {
4082
+ return;
4083
+ }
4084
+ await fs6.writeFile(markerPath, `${JSON.stringify({ type: "module" }, null, 2)}
4085
+ `, "utf8");
4086
+ };
4087
+ var resolveCanonicalExtensionInstallDestination = async (destinationDirectory) => {
4088
+ const resolvedDestination = path6.resolve(destinationDirectory);
4089
+ const destinationParent = path6.dirname(resolvedDestination);
4090
+ const destinationRoot = path6.parse(destinationParent).root;
4091
+ let canonicalDestinationParent = await fs6.realpath(destinationRoot).catch(() => destinationRoot);
4092
+ const relativeDestinationParent = path6.relative(destinationRoot, destinationParent);
4093
+ const destinationSegments = relativeDestinationParent === "" ? [] : relativeDestinationParent.split(path6.sep);
4094
+ for (const [index, segment] of destinationSegments.entries()) {
4095
+ const candidate = path6.join(canonicalDestinationParent, segment);
4096
+ try {
4097
+ canonicalDestinationParent = await fs6.realpath(candidate);
4098
+ } catch {
4099
+ canonicalDestinationParent = path6.join(canonicalDestinationParent, ...destinationSegments.slice(index));
4100
+ break;
4101
+ }
4102
+ }
4103
+ return path6.join(canonicalDestinationParent, path6.basename(resolvedDestination));
4104
+ };
4105
+ var copyExtensionDirectoryWithoutSelfNesting = async (sourceDirectory, destinationDirectory, copyDirectory, temporaryDirectory = os2.tmpdir()) => {
4106
+ const resolvedSource = path6.resolve(sourceDirectory);
4107
+ const canonicalSource = await fs6.realpath(resolvedSource).catch(() => resolvedSource);
4108
+ const canonicalDestination = await resolveCanonicalExtensionInstallDestination(destinationDirectory);
4109
+ if (canonicalSource === canonicalDestination) {
4110
+ return;
4111
+ }
4112
+ if (!isPathWithinDirectory(canonicalSource, canonicalDestination)) {
4113
+ await copyDirectory(sourceDirectory, destinationDirectory, {
4114
+ recursive: true,
4115
+ force: true
4116
+ });
4117
+ return;
4118
+ }
4119
+ const systemTempDirectory = path6.resolve(temporaryDirectory);
4120
+ const stagingBase = isPathWithinDirectory(canonicalSource, systemTempDirectory) ? path6.dirname(canonicalSource) : systemTempDirectory;
4121
+ if (isPathWithinDirectory(canonicalSource, stagingBase)) {
4122
+ throw new PmCliError(`Extension source "${sourceDirectory}" contains its install destination and no external staging directory is available. Install a narrower package directory instead.`, EXIT_CODE.USAGE, { code: "extension_install_source_contains_destination" });
4123
+ }
4124
+ const stagingRoot = await fs6.mkdtemp(path6.join(stagingBase, "pm-extension-copy-"));
4125
+ const stagedDirectory = path6.join(stagingRoot, "extension");
4126
+ try {
4127
+ await copyDirectory(sourceDirectory, stagedDirectory, {
4128
+ recursive: true,
4129
+ force: true
4130
+ });
4131
+ await copyDirectory(stagedDirectory, destinationDirectory, {
4132
+ recursive: true,
4133
+ force: true
4134
+ });
4135
+ } finally {
4136
+ await fs6.rm(stagingRoot, { recursive: true, force: true });
4137
+ }
4138
+ };
4139
+ var copyExtensionDirectoryForInstall = async (sourceDirectory, destinationDirectory, copyDirectory = fs6.cp) => {
4140
+ for (let attempt = 1; attempt <= EXTENSION_INSTALL_COPY_ATTEMPTS; attempt += 1) {
4141
+ try {
4142
+ await fs6.rm(destinationDirectory, { recursive: true, force: true });
4143
+ await copyExtensionDirectoryWithoutSelfNesting(sourceDirectory, destinationDirectory, copyDirectory);
4144
+ return;
4145
+ } catch (error) {
4146
+ if (!isRetriableExtensionInstallCopyError(error) || attempt === EXTENSION_INSTALL_COPY_ATTEMPTS) {
4147
+ throw error;
4148
+ }
4149
+ await sleep(EXTENSION_INSTALL_LOCK_DELAY_MS);
4150
+ }
4151
+ }
4152
+ };
4153
+ var readExtensionInstallLockOwnerToken = async (lockPath) => {
4154
+ let ownerContents;
4155
+ try {
4156
+ ownerContents = await fs6.readFile(path6.join(lockPath, "owner.json"), "utf8");
4157
+ } catch (error) {
4158
+ if (!isErrnoCode(error, "ENOENT"))
4159
+ throw error;
4160
+ return null;
4161
+ }
4162
+ let parsed;
4163
+ try {
4164
+ parsed = JSON.parse(ownerContents);
4165
+ } catch {
4166
+ return null;
4167
+ }
4168
+ if (typeof parsed !== "object" || parsed === null || !("token" in parsed)) {
4169
+ return null;
4170
+ }
4171
+ const token = parsed.token;
4172
+ return typeof token === "string" && token.length > 0 ? token : null;
4173
+ };
4174
+ var removeExtensionInstallLockIfOwned = async (lockPath, ownerToken) => {
4175
+ const currentOwnerToken = await readExtensionInstallLockOwnerToken(lockPath);
4176
+ if (currentOwnerToken !== ownerToken) {
4177
+ return false;
4178
+ }
4179
+ await fs6.rm(lockPath, { recursive: true, force: true });
4180
+ return true;
4181
+ };
4182
+ var reclaimStaleExtensionInstallLock = async (lockPath, staleMs) => {
4183
+ let stat;
4184
+ try {
4185
+ stat = await fs6.stat(lockPath);
4186
+ } catch {
4187
+ return false;
4188
+ }
4189
+ if (Date.now() - stat.mtimeMs <= staleMs) {
4190
+ return false;
4191
+ }
4192
+ const staleOwnerToken = await readExtensionInstallLockOwnerToken(lockPath);
4193
+ if (staleOwnerToken === null) {
4194
+ await fs6.rm(lockPath, { recursive: true, force: true });
4195
+ return true;
4196
+ }
4197
+ return removeExtensionInstallLockIfOwned(lockPath, staleOwnerToken);
4198
+ };
4199
+ var startExtensionInstallLockHeartbeat = (lockPath, ownerToken, intervalMs) => {
4200
+ let heartbeat = Promise.resolve();
4201
+ const timer = setInterval(() => {
4202
+ heartbeat = heartbeat.then(async () => {
4203
+ if (await readExtensionInstallLockOwnerToken(lockPath) !== ownerToken) {
4204
+ return;
4205
+ }
4206
+ const heartbeatAt = /* @__PURE__ */ new Date();
4207
+ await fs6.utimes(lockPath, heartbeatAt, heartbeatAt);
4208
+ }).catch(() => void 0);
4209
+ }, intervalMs);
4210
+ timer.unref();
4211
+ return async () => {
4212
+ clearInterval(timer);
4213
+ await heartbeat;
4214
+ };
4215
+ };
4216
+ var createExtensionInstallLock = async (lockPath, owner) => {
4217
+ await fs6.mkdir(lockPath);
4218
+ try {
4219
+ await fs6.writeFile(path6.join(lockPath, "owner.json"), `${JSON.stringify(owner, null, 2)}
4220
+ `, "utf8");
4221
+ } catch (error) {
4222
+ await fs6.rm(lockPath, { recursive: true, force: true }).catch(() => {
4223
+ });
4224
+ throw error;
4225
+ }
4226
+ };
4227
+ var acquireExtensionInstallLock = async (lockPath, owner, attempts, delayMs, staleMs) => {
4228
+ for (let attempt = 1; attempt <= attempts; attempt += 1) {
4229
+ try {
4230
+ await createExtensionInstallLock(lockPath, owner);
4231
+ return true;
4232
+ } catch (error) {
4233
+ if (!isErrnoCode(error, "EEXIST")) {
4234
+ throw error;
4235
+ }
4236
+ if (await reclaimStaleExtensionInstallLock(lockPath, staleMs)) {
4237
+ attempt -= 1;
4238
+ } else {
4239
+ await sleep(delayMs);
4240
+ }
4241
+ }
4242
+ }
4243
+ return false;
4244
+ };
4245
+ var withExtensionInstallLock = async (settingsRoot, destinationDirectoryName, run, options) => {
4246
+ const lockRoot = path6.join(settingsRoot, "runtime", "extension-install-locks");
4247
+ const lockPath = path6.join(lockRoot, "scope.lock");
4248
+ await fs6.mkdir(lockRoot, { recursive: true });
4249
+ const { attempts: rawAttempts = EXTENSION_INSTALL_LOCK_ATTEMPTS, delay_ms: rawDelayMs = EXTENSION_INSTALL_LOCK_DELAY_MS, stale_ms: rawStaleMs = EXTENSION_INSTALL_LOCK_STALE_MS, heartbeat_ms: rawHeartbeatMs } = options ?? {};
4250
+ if (![rawAttempts, rawDelayMs, rawStaleMs, rawHeartbeatMs].filter((value) => value !== void 0).every(Number.isFinite)) {
4251
+ throw new PmCliError("Extension install lock timings must be finite numbers.", EXIT_CODE.USAGE);
4252
+ }
4253
+ const attempts = Math.max(1, Math.floor(rawAttempts));
4254
+ const delayMs = Math.max(0, Math.floor(rawDelayMs));
4255
+ const staleMs = Math.floor(rawStaleMs);
4256
+ const heartbeatMs = Math.floor(rawHeartbeatMs ?? staleMs / 3);
4257
+ if (staleMs <= 0 || heartbeatMs <= 0 || heartbeatMs >= staleMs) {
4258
+ throw new PmCliError("Extension install lock timings require stale_ms > 0 and 0 < heartbeat_ms < stale_ms.", EXIT_CODE.USAGE);
4259
+ }
4260
+ const owner = {
4261
+ pid: process.pid,
4262
+ token: randomUUID(),
4263
+ created_at: nowIso(),
4264
+ destination: destinationDirectoryName
4265
+ };
4266
+ const acquired = await acquireExtensionInstallLock(lockPath, owner, attempts, delayMs, staleMs);
4267
+ if (!acquired) {
4268
+ throw new PmCliError(`Timed out waiting for extension install lock for "${destinationDirectoryName}".`, EXIT_CODE.CONFLICT);
4269
+ }
4270
+ const stopHeartbeat = startExtensionInstallLockHeartbeat(lockPath, owner.token, heartbeatMs);
4271
+ try {
4272
+ return await run();
4273
+ } finally {
4274
+ await stopHeartbeat();
4275
+ await removeExtensionInstallLockIfOwned(lockPath, owner.token).catch(() => false);
4276
+ }
4277
+ };
4278
+
4279
+ // dist/sdk/extension/concurrency.js
4280
+ var mapWithFixedConcurrency = async (inputs, concurrency, mapper) => {
4281
+ if (!Number.isInteger(concurrency) || concurrency < 1) {
4282
+ throw new RangeError("concurrency must be a positive integer");
4283
+ }
4284
+ const results = new Array(inputs.length);
4285
+ let nextIndex = 0;
4286
+ const workers = Array.from({ length: Math.min(concurrency, inputs.length) }, async () => {
4287
+ while (nextIndex < inputs.length) {
4288
+ const index = nextIndex;
4289
+ nextIndex += 1;
4290
+ results[index] = await mapper(inputs[index]);
4291
+ }
4292
+ });
4293
+ await Promise.all(workers);
4294
+ return results;
4295
+ };
4296
+
4297
+ // dist/sdk/extension/update-check.js
4298
+ var GITHUB_UPDATE_CHECK_TIMEOUT_MS = 1e4;
4299
+ var resolveGithubUpdateOutput = (output3, installedCommitInput, checkedAt) => {
4300
+ const references = output3.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((line) => {
4301
+ const [commit, ref = ""] = line.split(/\s+/);
4302
+ return { commit, ref };
4303
+ });
4304
+ const remoteReference = references.find((reference) => reference.ref.endsWith("^{}")) ?? references[0];
4305
+ if (!remoteReference) {
4306
+ return {
4307
+ checked_at: checkedAt,
4308
+ available: null,
4309
+ error: "no_remote_reference_found"
4310
+ };
4311
+ }
4312
+ const installedCommit = installedCommitInput?.trim();
4313
+ return installedCommit ? {
4314
+ checked_at: checkedAt,
4315
+ remote_commit: remoteReference.commit,
4316
+ available: remoteReference.commit !== installedCommit
4317
+ } : {
4318
+ checked_at: checkedAt,
4319
+ remote_commit: remoteReference.commit,
4320
+ available: null,
4321
+ error: "missing_installed_commit"
4322
+ };
4323
+ };
4324
+ var checkGithubUpdate = async (source, gitCommandRunner = runGitCommand) => {
4325
+ const checkedAt = nowIso();
4326
+ if (source.kind !== "github" || !source.repository) {
4327
+ return {
4328
+ checked_at: checkedAt,
4329
+ available: null,
4330
+ error: "not_a_github_managed_source"
4331
+ };
4332
+ }
4333
+ try {
4334
+ const ref = [source.ref?.trim(), "HEAD"].find(Boolean);
4335
+ const output3 = await gitCommandRunner(["ls-remote", source.repository, ref, `${ref}^{}`], void 0, GITHUB_UPDATE_CHECK_TIMEOUT_MS);
4336
+ return resolveGithubUpdateOutput(output3, source.commit, checkedAt);
4337
+ } catch (error) {
4338
+ return {
4339
+ checked_at: checkedAt,
4340
+ available: null,
4341
+ error: error instanceof Error ? error.message : String(error)
4342
+ };
4343
+ }
4344
+ };
4345
+
4346
+ // dist/sdk/extension/install-snapshot.js
4347
+ import fs7 from "node:fs/promises";
4348
+ import path7 from "node:path";
4349
+ var readOptionalMetadataFile = async (filePath) => fs7.readFile(filePath).catch((error) => {
4350
+ if (isErrnoCode(error, "ENOENT"))
4351
+ return null;
4352
+ throw error;
4353
+ });
4354
+ var captureExtensionInstallSnapshot = async (selectedRoot, settingsRoot, destinationDirectory, destinationExists, backupDirectory) => {
4355
+ const managedStatePath = resolveManagedExtensionStatePath(selectedRoot);
4356
+ const settingsPath = getSettingsPath(settingsRoot);
4357
+ const [managedStateContents, settingsContents] = await Promise.all([
4358
+ readOptionalMetadataFile(managedStatePath),
4359
+ readOptionalMetadataFile(settingsPath)
4360
+ ]);
4361
+ if (destinationExists) {
4362
+ await fs7.cp(destinationDirectory, backupDirectory, {
4363
+ recursive: true,
4364
+ force: true
4365
+ });
4366
+ }
4367
+ return {
4368
+ backupDirectory,
4369
+ destinationDirectory,
4370
+ destinationExists,
4371
+ managedStatePath,
4372
+ managedStateContents,
4373
+ settingsPath,
4374
+ settingsContents
4375
+ };
4376
+ };
4377
+ var restoreExtensionInstallSnapshot = async (snapshot) => {
4378
+ await fs7.rm(snapshot.destinationDirectory, { recursive: true, force: true });
4379
+ if (snapshot.destinationExists) {
4380
+ await fs7.cp(snapshot.backupDirectory, snapshot.destinationDirectory, {
4381
+ recursive: true,
4382
+ force: true
4383
+ });
4384
+ }
4385
+ for (const [filePath, contents] of [
4386
+ [snapshot.managedStatePath, snapshot.managedStateContents],
4387
+ [snapshot.settingsPath, snapshot.settingsContents]
4388
+ ]) {
4389
+ if (contents === null) {
4390
+ await fs7.rm(filePath, { force: true });
4391
+ } else {
4392
+ await fs7.mkdir(path7.dirname(filePath), { recursive: true });
4393
+ await fs7.writeFile(filePath, contents);
4394
+ }
4395
+ }
4396
+ };
4397
+
4398
+ // dist/sdk/extension.js
4399
+ var GITHUB_UPDATE_CHECK_CONCURRENCY = 4;
4064
4400
  var LIFECYCLE_ACTION_TARGETS = [
4065
4401
  ["install", "install", "--install"],
4066
4402
  ["uninstall", "uninstall", "--uninstall"],
@@ -4122,6 +4458,11 @@ var EXTENSION_POLICY_OVERRIDE_LIST_FIELDS = [
4122
4458
  "allowed_services",
4123
4459
  "blocked_services"
4124
4460
  ];
4461
+ var EXTENSION_POLICY_OVERRIDE_BOOLEAN_FIELDS = [
4462
+ "disabled",
4463
+ "require_trusted",
4464
+ "require_provenance"
4465
+ ];
4125
4466
  var DEFAULT_EXTENSION_POLICY_DETAILS = {
4126
4467
  mode: "off",
4127
4468
  trust_mode: "off",
@@ -4142,56 +4483,58 @@ var DEFAULT_EXTENSION_POLICY_DETAILS = {
4142
4483
  blocked_services: [],
4143
4484
  extension_overrides: []
4144
4485
  };
4145
- function normalizePolicyRootLists(policy) {
4486
+ var normalizePolicyRootLists = (policy) => {
4146
4487
  const safePolicy = policy ?? DEFAULT_EXTENSION_POLICY_DETAILS;
4147
4488
  const lists = {};
4148
4489
  for (const field of EXTENSION_POLICY_ROOT_LIST_FIELDS) {
4149
4490
  lists[field] = normalizeStringList(safePolicy[field] ?? []);
4150
4491
  }
4151
4492
  return lists;
4152
- }
4153
- function appendNonEmptyPolicyLists(target, lists) {
4493
+ };
4494
+ var appendNonEmptyPolicyLists = (target, lists) => {
4154
4495
  for (const field of EXTENSION_POLICY_OVERRIDE_LIST_FIELDS) {
4155
4496
  if (lists[field].length > 0) {
4156
4497
  target[field] = lists[field];
4157
4498
  }
4158
4499
  }
4159
4500
  return target;
4160
- }
4161
- function buildExtensionPolicyOverrideDetails(override) {
4162
- const name = typeof override.name === "string" ? override.name.trim() : "";
4163
- if (name.length === 0) {
4164
- return null;
4165
- }
4166
- const details = { name };
4167
- if (override.disabled === true) {
4168
- details.disabled = true;
4169
- }
4170
- if (override.require_trusted === true) {
4171
- details.require_trusted = true;
4172
- }
4173
- if (override.require_provenance === true) {
4174
- details.require_provenance = true;
4501
+ };
4502
+ var appendEnabledPolicyScalars = (target, override) => {
4503
+ for (const field of EXTENSION_POLICY_OVERRIDE_BOOLEAN_FIELDS) {
4504
+ if (override[field] === true) {
4505
+ target[field] = true;
4506
+ }
4175
4507
  }
4176
4508
  if (override.sandbox_profile) {
4177
- details.sandbox_profile = override.sandbox_profile;
4509
+ target.sandbox_profile = override.sandbox_profile;
4178
4510
  }
4511
+ return target;
4512
+ };
4513
+ var normalizePolicyOverrideLists = (override) => {
4179
4514
  const lists = {};
4180
4515
  for (const field of EXTENSION_POLICY_OVERRIDE_LIST_FIELDS) {
4181
4516
  lists[field] = normalizeStringList(override[field] ?? []);
4182
4517
  }
4183
- return appendNonEmptyPolicyLists(details, lists);
4184
- }
4185
- function buildExtensionPolicyDetails(policy) {
4186
- const safePolicy = policy ?? DEFAULT_EXTENSION_POLICY_DETAILS;
4518
+ return lists;
4519
+ };
4520
+ var buildExtensionPolicyOverrideDetails = (override) => {
4521
+ const name = typeof override.name === "string" ? override.name.trim() : "";
4522
+ if (name.length === 0) {
4523
+ return null;
4524
+ }
4525
+ return appendNonEmptyPolicyLists(appendEnabledPolicyScalars({ name }, override), normalizePolicyOverrideLists(override));
4526
+ };
4527
+ var normalizeExtensionPolicyOverrides = (overrides) => (overrides ?? []).map((override) => buildExtensionPolicyOverrideDetails(override)).filter((override) => override !== null).sort((left, right) => left.name.localeCompare(right.name));
4528
+ var buildExtensionPolicyDetails = (policy) => {
4529
+ const safePolicy = Object.assign({}, DEFAULT_EXTENSION_POLICY_DETAILS, policy ?? {});
4187
4530
  const rootLists = normalizePolicyRootLists(policy);
4188
- const overrides = (safePolicy.extension_overrides ?? []).map((override) => buildExtensionPolicyOverrideDetails(override)).filter((override) => override !== null).sort((left, right) => left.name.localeCompare(right.name));
4531
+ const overrides = normalizeExtensionPolicyOverrides(safePolicy.extension_overrides);
4189
4532
  return {
4190
- mode: safePolicy.mode ?? DEFAULT_EXTENSION_POLICY_DETAILS.mode,
4191
- trust_mode: safePolicy.trust_mode ?? DEFAULT_EXTENSION_POLICY_DETAILS.trust_mode,
4533
+ mode: safePolicy.mode,
4534
+ trust_mode: safePolicy.trust_mode,
4192
4535
  require_provenance: safePolicy.require_provenance === true,
4193
4536
  trusted_extensions: rootLists.trusted_extensions,
4194
- default_sandbox_profile: safePolicy.default_sandbox_profile ?? "none",
4537
+ default_sandbox_profile: safePolicy.default_sandbox_profile,
4195
4538
  allowed_extensions: rootLists.allowed_extensions,
4196
4539
  blocked_extensions: rootLists.blocked_extensions,
4197
4540
  allowed_capabilities: rootLists.allowed_capabilities,
@@ -4206,149 +4549,41 @@ function buildExtensionPolicyDetails(policy) {
4206
4549
  blocked_services: rootLists.blocked_services,
4207
4550
  extension_overrides: overrides
4208
4551
  };
4209
- }
4210
- function isRetriableExtensionInstallCopyError(error) {
4211
- if (typeof error !== "object" || error === null || !("code" in error)) {
4212
- return false;
4213
- }
4214
- const code = error.code;
4215
- return code === "EEXIST" || code === "ENOTEMPTY" || code === "ENOENT";
4216
- }
4217
- function isErrnoCode(error, code) {
4218
- return typeof error === "object" && error !== null && "code" in error && error.code === code;
4219
- }
4220
- function sleep(ms) {
4221
- return new Promise((resolve) => {
4222
- setTimeout(resolve, ms);
4223
- });
4224
- }
4225
- async function ensureExtensionModuleTypeMarker(destinationDirectory) {
4226
- const markerPath = path6.join(destinationDirectory, "package.json");
4227
- if (await pathExists(markerPath)) {
4228
- return;
4552
+ };
4553
+ var resolveInstalledExtensionCandidate = async (installed, extensionTarget) => {
4554
+ const lookupValues = [extensionTarget];
4555
+ const bundledAliasManifestName = await resolveBundledAliasManifestName(extensionTarget);
4556
+ if (bundledAliasManifestName) {
4557
+ lookupValues.push(bundledAliasManifestName);
4229
4558
  }
4230
- await fs6.writeFile(markerPath, `${JSON.stringify({ type: "module" }, null, 2)}
4231
- `, "utf8");
4232
- }
4233
- async function copyExtensionDirectoryForInstall(sourceDirectory, destinationDirectory, copyDirectory = fs6.cp) {
4234
- for (let attempt = 1; attempt <= EXTENSION_INSTALL_COPY_ATTEMPTS; attempt += 1) {
4235
- try {
4236
- if (await pathExists(destinationDirectory)) {
4237
- await fs6.rm(destinationDirectory, { recursive: true, force: true });
4238
- }
4239
- await copyExtensionDirectoryWithoutSelfNesting(sourceDirectory, destinationDirectory, copyDirectory);
4240
- return;
4241
- } catch (error) {
4242
- if (!isRetriableExtensionInstallCopyError(error) || attempt === EXTENSION_INSTALL_COPY_ATTEMPTS) {
4243
- throw error;
4244
- }
4245
- await sleep(EXTENSION_INSTALL_LOCK_DELAY_MS);
4559
+ const normalizedLookups = [
4560
+ ...new Set(lookupValues.map((value) => normalizeExtensionNameForMatch(value)).filter((value) => value.length > 0))
4561
+ ];
4562
+ for (const lookup of normalizedLookups) {
4563
+ const byName = installed.find((entry) => normalizeExtensionNameForMatch(entry.name) === lookup);
4564
+ if (byName) {
4565
+ return byName;
4566
+ }
4567
+ const byDirectory = installed.find((entry) => normalizeExtensionNameForMatch(entry.directory) === lookup);
4568
+ if (byDirectory) {
4569
+ return byDirectory;
4246
4570
  }
4247
4571
  }
4248
- }
4249
- async function copyExtensionDirectoryWithoutSelfNesting(sourceDirectory, destinationDirectory, copyDirectory) {
4250
- const resolvedSource = path6.resolve(sourceDirectory);
4251
- const resolvedDestination = path6.resolve(destinationDirectory);
4252
- if (resolvedSource === resolvedDestination) {
4253
- return;
4254
- }
4255
- if (!isPathWithinDirectory(resolvedSource, resolvedDestination)) {
4256
- await copyDirectory(sourceDirectory, destinationDirectory, {
4257
- recursive: true,
4258
- force: true
4259
- });
4260
- return;
4261
- }
4262
- const stagingRoot = await fs6.mkdtemp(path6.join(os2.tmpdir(), "pm-extension-copy-"));
4263
- const stagedDirectory = path6.join(stagingRoot, "extension");
4264
- try {
4265
- await copyDirectory(sourceDirectory, stagedDirectory, {
4266
- recursive: true,
4267
- force: true
4268
- });
4269
- await copyDirectory(stagedDirectory, destinationDirectory, {
4270
- recursive: true,
4271
- force: true
4272
- });
4273
- } finally {
4274
- await fs6.rm(stagingRoot, { recursive: true, force: true });
4275
- }
4276
- }
4277
- async function withExtensionInstallLock(settingsRoot, destinationDirectoryName, run, options) {
4278
- const lockRoot = path6.join(settingsRoot, "runtime", "extension-install-locks");
4279
- const lockPath = path6.join(lockRoot, `${destinationDirectoryName}.lock`);
4280
- await fs6.mkdir(lockRoot, { recursive: true });
4281
- const attempts = Math.max(1, Math.floor(options?.attempts ?? EXTENSION_INSTALL_LOCK_ATTEMPTS));
4282
- const delayMs = Math.max(0, Math.floor(options?.delay_ms ?? EXTENSION_INSTALL_LOCK_DELAY_MS));
4283
- const staleMs = Math.max(0, Math.floor(options?.stale_ms ?? EXTENSION_INSTALL_LOCK_STALE_MS));
4284
- let acquired = false;
4285
- for (let attempt = 1; attempt <= attempts; attempt += 1) {
4286
- try {
4287
- await fs6.mkdir(lockPath);
4288
- acquired = true;
4289
- await fs6.writeFile(path6.join(lockPath, "owner.json"), `${JSON.stringify({ pid: process.pid, created_at: nowIso(), destination: destinationDirectoryName }, null, 2)}
4290
- `, "utf8");
4291
- break;
4292
- } catch (error) {
4293
- if (!isErrnoCode(error, "EEXIST")) {
4294
- throw error;
4295
- }
4296
- let stat = null;
4297
- try {
4298
- stat = await fs6.stat(lockPath);
4299
- } catch {
4300
- stat = null;
4301
- }
4302
- if (stat && Date.now() - stat.mtimeMs > staleMs) {
4303
- await fs6.rm(lockPath, { recursive: true, force: true });
4304
- continue;
4305
- }
4306
- await sleep(delayMs);
4307
- }
4308
- }
4309
- if (!acquired) {
4310
- throw new PmCliError(`Timed out waiting for extension install lock for "${destinationDirectoryName}".`, EXIT_CODE.CONFLICT);
4311
- }
4312
- try {
4313
- return await run();
4314
- } finally {
4315
- await fs6.rm(lockPath, { recursive: true, force: true }).catch(() => void 0);
4316
- }
4317
- }
4318
- async function resolveInstalledExtensionCandidate(installed, extensionTarget) {
4319
- const lookupValues = [extensionTarget];
4320
- const bundledAliasManifestName = await resolveBundledAliasManifestName(extensionTarget);
4321
- if (bundledAliasManifestName) {
4322
- lookupValues.push(bundledAliasManifestName);
4323
- }
4324
- const normalizedLookups = [
4325
- ...new Set(lookupValues.map((value) => normalizeExtensionNameForMatch(value)).filter((value) => value.length > 0))
4326
- ];
4327
- for (const lookup of normalizedLookups) {
4328
- const byName = installed.find((entry) => normalizeExtensionNameForMatch(entry.name) === lookup);
4329
- if (byName) {
4330
- return byName;
4331
- }
4332
- const byDirectory = installed.find((entry) => normalizeExtensionNameForMatch(entry.directory) === lookup);
4333
- if (byDirectory) {
4334
- return byDirectory;
4335
- }
4336
- }
4337
- return void 0;
4338
- }
4339
- function isExtensionEnabled(settings, name) {
4340
- const normalizedName = name.trim();
4341
- const enabled = new Set(normalizeStringList(settings.extensions.enabled));
4342
- const disabled = new Set(normalizeStringList(settings.extensions.disabled));
4343
- if (disabled.has(normalizedName)) {
4344
- return false;
4572
+ return void 0;
4573
+ };
4574
+ var isExtensionEnabled = (settings, name) => {
4575
+ const normalizedName = name.trim();
4576
+ const enabled = new Set(normalizeStringList(settings.extensions.enabled));
4577
+ const disabled = new Set(normalizeStringList(settings.extensions.disabled));
4578
+ if (disabled.has(normalizedName)) {
4579
+ return false;
4345
4580
  }
4346
4581
  if (enabled.size === 0) {
4347
4582
  return true;
4348
4583
  }
4349
4584
  return enabled.has(normalizedName);
4350
- }
4351
- function ensureActivated(settings, name) {
4585
+ };
4586
+ var ensureActivated = (settings, name) => {
4352
4587
  const normalizedName = name.trim();
4353
4588
  const enabled = new Set(normalizeStringList(settings.extensions.enabled));
4354
4589
  const disabled = new Set(normalizeStringList(settings.extensions.disabled));
@@ -4361,8 +4596,8 @@ function ensureActivated(settings, name) {
4361
4596
  settings.extensions.enabled = [...enabled].sort((left, right) => left.localeCompare(right));
4362
4597
  settings.extensions.disabled = [...disabled].sort((left, right) => left.localeCompare(right));
4363
4598
  return settings.extensions.enabled.join("\0") !== previousEnabled.join("\0") || settings.extensions.disabled.join("\0") !== previousDisabled.join("\0");
4364
- }
4365
- function ensureDeactivated(settings, name) {
4599
+ };
4600
+ var ensureDeactivated = (settings, name) => {
4366
4601
  const normalizedName = name.trim();
4367
4602
  const enabled = new Set(normalizeStringList(settings.extensions.enabled));
4368
4603
  const disabled = new Set(normalizeStringList(settings.extensions.disabled));
@@ -4373,8 +4608,8 @@ function ensureDeactivated(settings, name) {
4373
4608
  settings.extensions.enabled = [...enabled].sort((left, right) => left.localeCompare(right));
4374
4609
  settings.extensions.disabled = [...disabled].sort((left, right) => left.localeCompare(right));
4375
4610
  return settings.extensions.enabled.join("\0") !== previousEnabled.join("\0") || settings.extensions.disabled.join("\0") !== previousDisabled.join("\0");
4376
- }
4377
- function clearExtensionState(settings, name) {
4611
+ };
4612
+ var clearExtensionState = (settings, name) => {
4378
4613
  const normalizedName = name.trim();
4379
4614
  const enabled = new Set(normalizeStringList(settings.extensions.enabled));
4380
4615
  const disabled = new Set(normalizeStringList(settings.extensions.disabled));
@@ -4385,31 +4620,18 @@ function clearExtensionState(settings, name) {
4385
4620
  settings.extensions.enabled = [...enabled].sort((left, right) => left.localeCompare(right));
4386
4621
  settings.extensions.disabled = [...disabled].sort((left, right) => left.localeCompare(right));
4387
4622
  return settings.extensions.enabled.join("\0") !== previousEnabled.join("\0") || settings.extensions.disabled.join("\0") !== previousDisabled.join("\0");
4388
- }
4389
- function suggestLifecycleActionTarget(target) {
4623
+ };
4624
+ var suggestLifecycleActionTarget = (target) => {
4390
4625
  const normalizedTarget = target.trim().toLowerCase();
4391
- const exactMatch = LIFECYCLE_ACTION_TARGETS.find(([candidate]) => candidate === normalizedTarget);
4392
- if (exactMatch) {
4393
- return { action: exactMatch[1], flag: exactMatch[2] };
4394
- }
4395
- const maxDistance = normalizedTarget.length <= 4 ? 1 : 2;
4396
- let nearest = null;
4397
- for (const [candidate, action, flag] of LIFECYCLE_ACTION_TARGETS) {
4398
- const distance = levenshteinDistanceWithinLimit(normalizedTarget, candidate, maxDistance);
4399
- if (distance === null) {
4400
- continue;
4401
- }
4402
- if (nearest === null) {
4403
- nearest = { action, flag, distance };
4404
- continue;
4405
- }
4406
- if (distance < nearest.distance) {
4407
- nearest = { action, flag, distance };
4408
- }
4409
- }
4410
- return nearest === null ? null : { action: nearest.action, flag: nearest.flag };
4411
- }
4412
- function buildUnknownLifecycleActionError(target, options) {
4626
+ const maxDistance = Math.min(2, Math.max(1, Math.ceil(normalizedTarget.length / 4)));
4627
+ const nearest = LIFECYCLE_ACTION_TARGETS.map(([candidate, action, flag]) => ({
4628
+ action,
4629
+ flag,
4630
+ distance: levenshteinDistanceWithinLimit(normalizedTarget, candidate, maxDistance)
4631
+ })).filter((entry) => entry.distance !== null).sort((left, right) => left.distance - right.distance)[0];
4632
+ return nearest ? { action: nearest.action, flag: nearest.flag } : null;
4633
+ };
4634
+ var buildUnknownLifecycleActionError = (target, options) => {
4413
4635
  const noun = options.vocabulary === "package" ? "package" : "extension";
4414
4636
  const suggestion = suggestLifecycleActionTarget(target);
4415
4637
  if (!suggestion) {
@@ -4432,7 +4654,7 @@ function buildUnknownLifecycleActionError(target, options) {
4432
4654
  ]
4433
4655
  }
4434
4656
  });
4435
- }
4657
+ };
4436
4658
  var EXTENSION_ACTION_FLAG_SELECTORS = [
4437
4659
  ["install", "install"],
4438
4660
  ["uninstall", "uninstall"],
@@ -4449,31 +4671,19 @@ var EXTENSION_ACTION_FLAG_SELECTORS = [
4449
4671
  ["activate", "activate"],
4450
4672
  ["deactivate", "deactivate"]
4451
4673
  ];
4452
- function resolveImplicitActionFromTarget(normalizedTarget) {
4453
- if (normalizedTarget === "doctor") {
4454
- return "doctor";
4455
- }
4456
- if (normalizedTarget === "reload") {
4457
- return "reload";
4458
- }
4459
- if (normalizedTarget === "catalog") {
4460
- return "catalog";
4461
- }
4462
- if (normalizedTarget === "init" || normalizedTarget === "scaffold") {
4463
- return "init";
4464
- }
4465
- if (normalizedTarget === "explore") {
4466
- return "explore";
4467
- }
4468
- if (normalizedTarget === "manage") {
4469
- return "manage";
4470
- }
4471
- if (normalizedTarget === "list" || normalizedTarget === "") {
4472
- return "explore";
4473
- }
4474
- return null;
4475
- }
4476
- function resolveAction(target, options) {
4674
+ var IMPLICIT_EXTENSION_ACTIONS = {
4675
+ doctor: "doctor",
4676
+ reload: "reload",
4677
+ catalog: "catalog",
4678
+ init: "init",
4679
+ scaffold: "init",
4680
+ explore: "explore",
4681
+ manage: "manage",
4682
+ list: "explore",
4683
+ "": "explore"
4684
+ };
4685
+ var resolveImplicitActionFromTarget = (normalizedTarget) => IMPLICIT_EXTENSION_ACTIONS[normalizedTarget] ?? null;
4686
+ var resolveAction = (target, options) => {
4477
4687
  const selected = [
4478
4688
  ...new Set(EXTENSION_ACTION_FLAG_SELECTORS.filter(([flag]) => options[flag] === true).map(([, mappedAction]) => mappedAction))
4479
4689
  ];
@@ -4491,59 +4701,55 @@ function resolveAction(target, options) {
4491
4701
  throw new PmCliError("Extension action flags are mutually exclusive.", EXIT_CODE.USAGE);
4492
4702
  }
4493
4703
  return selected[0];
4494
- }
4495
- function resolveScope(options) {
4704
+ };
4705
+ var resolveScope = (options) => {
4496
4706
  const projectLike = options.project === true || options.local === true;
4497
4707
  const global = options.global === true;
4498
4708
  if (projectLike && global) {
4499
4709
  throw new PmCliError('Options "--project/--local" and "--global" are mutually exclusive.', EXIT_CODE.USAGE);
4500
4710
  }
4501
4711
  return global ? "global" : "project";
4502
- }
4503
- function resolveUpdateCheckResolution(managedEntry) {
4504
- if (!managedEntry) {
4505
- return {
4506
- status: "skipped_unmanaged",
4507
- reason: "extension_not_managed"
4508
- };
4509
- }
4510
- if (managedEntry.source.kind !== "github") {
4511
- return {
4512
- status: "skipped_non_github",
4513
- reason: `managed_source_kind_${managedEntry.source.kind}`
4514
- };
4515
- }
4516
- const updateError = typeof managedEntry.update_error === "string" ? managedEntry.update_error.trim() : "";
4517
- if (updateError.length > 0) {
4518
- return {
4519
- status: "failed",
4520
- reason: updateError
4521
- };
4522
- }
4523
- if (typeof managedEntry.last_update_check_at === "string" && managedEntry.last_update_check_at.trim().length > 0) {
4524
- if (managedEntry.update_available === true) {
4525
- return {
4526
- status: "checked",
4527
- reason: "update_available"
4528
- };
4712
+ };
4713
+ var EXTENSION_UPDATE_CHECK_RESOLVERS = [
4714
+ (managedEntry) => managedEntry ? null : {
4715
+ status: "skipped_unmanaged",
4716
+ reason: "extension_not_managed"
4717
+ },
4718
+ (managedEntry) => managedEntry && managedEntry.source.kind !== "github" ? {
4719
+ status: "skipped_non_github",
4720
+ reason: `managed_source_kind_${managedEntry.source.kind}`
4721
+ } : null,
4722
+ (managedEntry) => {
4723
+ const updateError = typeof managedEntry?.update_error === "string" ? managedEntry.update_error.trim() : "";
4724
+ return updateError.length > 0 ? { status: "failed", reason: updateError } : null;
4725
+ },
4726
+ (managedEntry) => {
4727
+ const entry = managedEntry;
4728
+ const checkedAt = typeof entry.last_update_check_at === "string" ? entry.last_update_check_at.trim() : "";
4729
+ if (checkedAt.length === 0) {
4730
+ return null;
4529
4731
  }
4530
- if (managedEntry.update_available === false) {
4531
- return {
4532
- status: "checked",
4533
- reason: "up_to_date"
4534
- };
4732
+ const reason = {
4733
+ true: "update_available",
4734
+ false: "up_to_date"
4735
+ }[String(entry.update_available)] ?? "checked_without_commit_baseline";
4736
+ return { status: "checked", reason };
4737
+ }
4738
+ ];
4739
+ var resolveUpdateCheckResolution = (managedEntry) => {
4740
+ for (const resolve of EXTENSION_UPDATE_CHECK_RESOLVERS) {
4741
+ const resolution = resolve(managedEntry);
4742
+ if (resolution) {
4743
+ return resolution;
4535
4744
  }
4536
- return {
4537
- status: "checked",
4538
- reason: "checked_without_commit_baseline"
4539
- };
4540
4745
  }
4541
4746
  return {
4542
4747
  status: "not_checked",
4543
4748
  reason: "no_update_check_recorded"
4544
4749
  };
4545
- }
4546
- function buildInstalledExtensionSummary(identity, scope, managedEntry, updateCheck) {
4750
+ };
4751
+ var buildInstalledExtensionSummary = (identity, scope, managedEntry, updateCheck) => {
4752
+ const managed = managedEntry ?? {};
4547
4753
  return {
4548
4754
  name: identity.name,
4549
4755
  directory: identity.directory,
@@ -4555,92 +4761,106 @@ function buildInstalledExtensionSummary(identity, scope, managedEntry, updateChe
4555
4761
  runtime_active: null,
4556
4762
  activation_status: "unknown",
4557
4763
  managed: Boolean(managedEntry),
4558
- source: managedEntry?.source,
4559
- update_available: managedEntry?.update_available,
4560
- last_update_check_at: managedEntry?.last_update_check_at,
4561
- last_update_remote_commit: managedEntry?.last_update_remote_commit,
4562
- update_error: managedEntry?.update_error,
4764
+ source: managed.source,
4765
+ update_available: managed.update_available,
4766
+ last_update_check_at: managed.last_update_check_at,
4767
+ last_update_remote_commit: managed.last_update_remote_commit,
4768
+ update_error: managed.update_error,
4563
4769
  update_check_status: updateCheck.status,
4564
4770
  update_check_reason: updateCheck.reason
4565
4771
  };
4566
- }
4567
- async function listInstalledExtensions(extensionsRoot, scope, settings, state) {
4772
+ };
4773
+ var buildMissingManifestInspection = (directoryName, scope, settings, managedEntry) => {
4774
+ const managed = Object.assign({
4775
+ name: directoryName,
4776
+ manifest_version: "unknown",
4777
+ manifest_entry: "unknown"
4778
+ }, managedEntry);
4779
+ const enabled = managedEntry ? isExtensionEnabled(settings, managedEntry.name) : false;
4780
+ return {
4781
+ warning: `extension_manifest_missing:${scope}:${directoryName}`,
4782
+ summary: buildInstalledExtensionSummary({
4783
+ name: managed.name,
4784
+ directory: directoryName,
4785
+ version: managed.manifest_version,
4786
+ entry: managed.manifest_entry,
4787
+ enabled
4788
+ }, scope, managedEntry, resolveUpdateCheckResolution(managedEntry))
4789
+ };
4790
+ };
4791
+ var inspectInstalledExtensionDirectory = async (extensionsRoot, directoryName, scope, settings, managedByName, managedByDirectory) => {
4792
+ const extensionDirectory = path8.join(extensionsRoot, directoryName);
4793
+ const manifestPath = path8.join(extensionDirectory, "manifest.json");
4794
+ const managedDirectoryEntry = managedByDirectory.get(normalizeExtensionNameForMatch(directoryName));
4795
+ if (!await pathExists(manifestPath)) {
4796
+ return buildMissingManifestInspection(directoryName, scope, settings, managedDirectoryEntry);
4797
+ }
4798
+ const invalidJson = /* @__PURE__ */ Symbol("invalid-extension-manifest-json");
4799
+ const rawManifest = await fs8.readFile(manifestPath, "utf8").then((contents) => JSON.parse(contents)).catch(() => invalidJson);
4800
+ if (rawManifest === invalidJson) {
4801
+ return {
4802
+ warning: `extension_manifest_invalid_json:${scope}:${directoryName}`
4803
+ };
4804
+ }
4805
+ const manifest = parseExtensionManifest(rawManifest);
4806
+ if (!manifest) {
4807
+ return { warning: `extension_manifest_invalid:${scope}:${directoryName}` };
4808
+ }
4809
+ const managedEntry = managedByName.get(normalizeExtensionNameForMatch(manifest.name)) ?? managedByDirectory.get(normalizeExtensionNameForMatch(directoryName));
4810
+ return {
4811
+ summary: buildInstalledExtensionSummary({
4812
+ name: manifest.name,
4813
+ directory: directoryName,
4814
+ version: manifest.version,
4815
+ entry: manifest.entry,
4816
+ enabled: isExtensionEnabled(settings, manifest.name)
4817
+ }, scope, managedEntry, resolveUpdateCheckResolution(managedEntry))
4818
+ };
4819
+ };
4820
+ var listInstalledExtensions = async (extensionsRoot, scope, settings, state) => {
4568
4821
  if (!await pathExists(extensionsRoot)) {
4569
4822
  return {
4570
4823
  extensions: [],
4571
4824
  warnings: []
4572
4825
  };
4573
4826
  }
4574
- const entries = await fs6.readdir(extensionsRoot, { withFileTypes: true });
4827
+ const entries = await fs8.readdir(extensionsRoot, { withFileTypes: true });
4575
4828
  const directories = entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort((left, right) => left.localeCompare(right));
4576
- const managedByName = /* @__PURE__ */ new Map();
4577
- const managedByDirectory = /* @__PURE__ */ new Map();
4578
- for (const managedEntry of state.entries) {
4579
- managedByName.set(normalizeExtensionNameForMatch(managedEntry.name), managedEntry);
4580
- managedByDirectory.set(normalizeExtensionNameForMatch(managedEntry.directory), managedEntry);
4581
- }
4829
+ const managedByName = new Map(state.entries.map((managedEntry) => [
4830
+ normalizeExtensionNameForMatch(managedEntry.name),
4831
+ managedEntry
4832
+ ]));
4833
+ const managedByDirectory = new Map(state.entries.map((managedEntry) => [
4834
+ normalizeExtensionNameForMatch(managedEntry.directory),
4835
+ managedEntry
4836
+ ]));
4582
4837
  const warnings = [];
4583
4838
  const summaries = [];
4584
4839
  for (const directoryName of directories) {
4585
- const extensionDirectory = path6.join(extensionsRoot, directoryName);
4586
- const manifestPath = path6.join(extensionDirectory, "manifest.json");
4587
- if (!await pathExists(manifestPath)) {
4588
- warnings.push(`extension_manifest_missing:${scope}:${directoryName}`);
4589
- const managedEntry2 = managedByDirectory.get(normalizeExtensionNameForMatch(directoryName));
4590
- summaries.push(buildInstalledExtensionSummary({
4591
- name: managedEntry2?.name ?? directoryName,
4592
- directory: directoryName,
4593
- version: managedEntry2?.manifest_version ?? "unknown",
4594
- entry: managedEntry2?.manifest_entry ?? "unknown",
4595
- enabled: managedEntry2 ? isExtensionEnabled(settings, managedEntry2.name) : false
4596
- }, scope, managedEntry2, resolveUpdateCheckResolution(managedEntry2)));
4597
- continue;
4840
+ const inspected = await inspectInstalledExtensionDirectory(extensionsRoot, directoryName, scope, settings, managedByName, managedByDirectory);
4841
+ if (inspected.warning) {
4842
+ warnings.push(inspected.warning);
4598
4843
  }
4599
- let rawManifest;
4600
- try {
4601
- rawManifest = JSON.parse(await fs6.readFile(manifestPath, "utf8"));
4602
- } catch {
4603
- warnings.push(`extension_manifest_invalid_json:${scope}:${directoryName}`);
4604
- continue;
4844
+ if (inspected.summary) {
4845
+ summaries.push(inspected.summary);
4605
4846
  }
4606
- const manifest = parseExtensionManifest(rawManifest);
4607
- if (!manifest) {
4608
- warnings.push(`extension_manifest_invalid:${scope}:${directoryName}`);
4609
- continue;
4610
- }
4611
- const managedEntry = managedByName.get(normalizeExtensionNameForMatch(manifest.name)) ?? managedByDirectory.get(normalizeExtensionNameForMatch(directoryName));
4612
- summaries.push(buildInstalledExtensionSummary({
4613
- name: manifest.name,
4614
- directory: directoryName,
4615
- version: manifest.version,
4616
- entry: manifest.entry,
4617
- enabled: isExtensionEnabled(settings, manifest.name)
4618
- }, scope, managedEntry, resolveUpdateCheckResolution(managedEntry)));
4619
4847
  }
4620
4848
  return {
4621
4849
  extensions: summaries.sort((left, right) => left.name.localeCompare(right.name)),
4622
4850
  warnings: warnings.sort((left, right) => left.localeCompare(right))
4623
4851
  };
4624
- }
4852
+ };
4625
4853
  var extensionRuntimeProbeQueue = createSerialQueue();
4626
- function summarizeRuntimeCommandPathsForExtension(extensionName, installed) {
4854
+ var summarizeRuntimeCommandPathsForExtension = (extensionName, installed) => {
4627
4855
  const normalizedName = normalizeExtensionNameForMatch(extensionName);
4628
4856
  const entry = installed.find((candidate) => normalizeExtensionNameForMatch(candidate.name) === normalizedName);
4629
4857
  return {
4630
4858
  command_paths: [...entry?.command_paths ?? []].sort((left, right) => left.localeCompare(right)),
4631
4859
  action_paths: [...entry?.action_paths ?? []].sort((left, right) => left.localeCompare(right))
4632
4860
  };
4633
- }
4634
- function resolveCommandDiscoveryPackageName(extensionName, source) {
4635
- if (typeof source.package === "string" && source.package.trim().length > 0) {
4636
- return source.package.trim();
4637
- }
4638
- if (source.kind === "builtin" && typeof source.name === "string" && source.name.trim().length > 0) {
4639
- return source.name.trim();
4640
- }
4641
- return extensionName;
4642
- }
4643
- function buildInstallCommandDiscovery(extensionName, source, commandSummary, activationFailure) {
4861
+ };
4862
+ var resolveCommandDiscoveryPackageName = (extensionName, source) => [source.package, source.kind === "builtin" ? source.name : void 0].find((candidate) => candidate?.trim())?.trim() ?? extensionName;
4863
+ var buildInstallCommandDiscovery = (extensionName, source, commandSummary, activationFailure) => {
4644
4864
  const helpCommands = commandSummary.command_paths.map((commandPath) => `pm ${commandPath} --help`);
4645
4865
  const sdkDependencyMissing = activationFailure?.error.toLowerCase().includes("@unbrained/pm-cli") === true;
4646
4866
  const nextSteps = commandSummary.command_paths.length > 0 ? [...helpCommands] : [
@@ -4658,42 +4878,40 @@ function buildInstallCommandDiscovery(extensionName, source, commandSummary, act
4658
4878
  next_steps: nextSteps,
4659
4879
  ...sdkDependencyMissing ? { sdk_dependency_status: "missing" } : {}
4660
4880
  };
4661
- }
4662
- function summarizeActivationFailureForDiagnostics(failure) {
4663
- const trace = failure.trace ? {
4664
- method: failure.trace.method,
4665
- registration_index: failure.trace.registration_index,
4666
- expected_schema: failure.trace.expected_schema,
4667
- ...failure.trace.command ? { command: failure.trace.command } : {},
4668
- ...failure.trace.capability ? { capability: failure.trace.capability } : {},
4669
- ...failure.trace.missing_capability ? { missing_capability: failure.trace.missing_capability } : {},
4670
- ...failure.trace.hint ? { hint: failure.trace.hint } : {}
4671
- } : void 0;
4672
- return {
4881
+ };
4882
+ var summarizeActivationFailureForDiagnostics = (failure) => {
4883
+ const trace = failure.trace;
4884
+ const summary = {
4673
4885
  layer: failure.layer,
4674
4886
  name: failure.name,
4675
4887
  entry_path: failure.entry_path,
4676
- error: failure.error,
4677
- ...failure.trace?.missing_capability ? { missing_capability: failure.trace.missing_capability } : {},
4678
- ...failure.trace?.hint ? { hint: failure.trace.hint } : {},
4679
- ...trace ? { trace } : {}
4888
+ error: failure.error
4680
4889
  };
4681
- }
4682
- function collectActivationFailureDiagnostics(failures) {
4890
+ if (!trace)
4891
+ return summary;
4892
+ summary.trace = Object.fromEntries(Object.entries(trace).filter(([, value]) => value !== void 0));
4893
+ if (trace.missing_capability) {
4894
+ summary.missing_capability = trace.missing_capability;
4895
+ }
4896
+ if (trace.hint)
4897
+ summary.hint = trace.hint;
4898
+ return summary;
4899
+ };
4900
+ var collectActivationFailureDiagnostics = (failures) => {
4683
4901
  return failures.map((failure) => summarizeActivationFailureForDiagnostics(failure)).sort((left, right) => `${left.layer}:${left.name}`.localeCompare(`${right.layer}:${right.name}`));
4684
- }
4685
- function findActivationFailureByName(extensionName, failures, layer) {
4902
+ };
4903
+ var findActivationFailureByName = (extensionName, failures, layer) => {
4686
4904
  const normalizedName = normalizeExtensionNameForMatch(extensionName);
4687
4905
  return failures.find((failure) => (layer === void 0 || failure.layer === layer) && normalizeExtensionNameForMatch(failure.name) === normalizedName);
4688
- }
4689
- function resolveInstallRuntimeActivationStatus(extensionName, scope, runtimeInstalled, installActivationFailure) {
4906
+ };
4907
+ var resolveInstallRuntimeActivationStatus = (extensionName, scope, runtimeInstalled, installActivationFailure) => {
4690
4908
  const runtimeInstalledExtension = runtimeInstalled.find((entry) => entry.scope === scope && normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(extensionName));
4691
4909
  return runtimeInstalledExtension?.activation_status ?? (installActivationFailure ? "failed" : "unknown");
4692
- }
4693
- async function probeRuntimeCommandPathsForInstall(pmRoot, settings, refreshedInstalled, global) {
4910
+ };
4911
+ var probeRuntimeCommandPathsForInstall = (pmRoot, settings, refreshedInstalled, global) => {
4694
4912
  return extensionRuntimeProbeQueue.enqueue(async () => {
4695
4913
  const originalPackageRoot = process.env.PM_CLI_PACKAGE_ROOT;
4696
- process.env.PM_CLI_PACKAGE_ROOT = path6.resolve(path6.dirname(fileURLToPath2(import.meta.url)), "../../..");
4914
+ process.env.PM_CLI_PACKAGE_ROOT = resolvePmPackageRootFromModule(import.meta.url, ["../.."]);
4697
4915
  try {
4698
4916
  const loadResult = await loadExtensions({
4699
4917
  pmRoot,
@@ -4731,61 +4949,8 @@ async function probeRuntimeCommandPathsForInstall(pmRoot, settings, refreshedIns
4731
4949
  }
4732
4950
  }
4733
4951
  });
4734
- }
4735
- async function checkGithubUpdate(source, gitCommandRunner = runGitCommand) {
4736
- const checkedAt = nowIso();
4737
- if (source.kind !== "github" || !source.repository) {
4738
- return {
4739
- checked_at: checkedAt,
4740
- available: null,
4741
- error: "not_a_github_managed_source"
4742
- };
4743
- }
4744
- try {
4745
- const ref = source.ref && source.ref.trim().length > 0 ? source.ref.trim() : "HEAD";
4746
- const output3 = await gitCommandRunner([
4747
- "ls-remote",
4748
- source.repository,
4749
- ref
4750
- ]);
4751
- const firstLine = output3.split(/\r?\n/).map((line) => line.trim()).find((line) => line.length > 0);
4752
- if (!firstLine) {
4753
- return {
4754
- checked_at: checkedAt,
4755
- available: null,
4756
- error: "no_remote_reference_found"
4757
- };
4758
- }
4759
- const [remoteCommit] = firstLine.split(/\s+/);
4760
- if (typeof remoteCommit !== "string" || remoteCommit.length === 0) {
4761
- return {
4762
- checked_at: checkedAt,
4763
- available: null,
4764
- error: "invalid_remote_reference"
4765
- };
4766
- }
4767
- if (typeof source.commit === "string" && source.commit.trim().length > 0) {
4768
- return {
4769
- checked_at: checkedAt,
4770
- remote_commit: remoteCommit,
4771
- available: remoteCommit !== source.commit.trim()
4772
- };
4773
- }
4774
- return {
4775
- checked_at: checkedAt,
4776
- remote_commit: remoteCommit,
4777
- available: null,
4778
- error: "missing_installed_commit"
4779
- };
4780
- } catch (error) {
4781
- return {
4782
- checked_at: checkedAt,
4783
- available: null,
4784
- error: error instanceof Error ? error.message : String(error)
4785
- };
4786
- }
4787
- }
4788
- async function adoptUnmanagedExtensions(extensionsRoot, scope, installedExtensions, state) {
4952
+ };
4953
+ var adoptUnmanagedExtensions = async (extensionsRoot, scope, installedExtensions, state) => {
4789
4954
  const unmanagedCandidates = installedExtensions.filter((entry) => !entry.managed);
4790
4955
  const sortedCandidates = [...unmanagedCandidates].sort((left, right) => {
4791
4956
  const byName = left.name.localeCompare(right.name);
@@ -4797,7 +4962,7 @@ async function adoptUnmanagedExtensions(extensionsRoot, scope, installedExtensio
4797
4962
  let nextState = state;
4798
4963
  const adoptedEntries = [];
4799
4964
  for (const candidate of sortedCandidates) {
4800
- const extensionDirectory = path6.join(extensionsRoot, candidate.directory);
4965
+ const extensionDirectory = path8.join(extensionsRoot, candidate.directory);
4801
4966
  const validated = await validateExtensionDirectory(extensionDirectory);
4802
4967
  const now = nowIso();
4803
4968
  const sourceRecord = {
@@ -4833,8 +4998,8 @@ async function adoptUnmanagedExtensions(extensionsRoot, scope, installedExtensio
4833
4998
  unmanaged_candidates: sortedCandidates,
4834
4999
  already_managed_count: installedExtensions.length - unmanagedCandidates.length
4835
5000
  };
4836
- }
4837
- function resolveExtensionRootsForScope(scope, global) {
5001
+ };
5002
+ var resolveExtensionRootsForScope = (scope, global) => {
4838
5003
  const pmRoot = resolvePmRoot(process.cwd(), global.path);
4839
5004
  const roots = resolveExtensionRoots(pmRoot, process.cwd());
4840
5005
  const settingsRoot = scope === "global" ? resolveGlobalPmRoot(process.cwd()) : pmRoot;
@@ -4846,58 +5011,56 @@ function resolveExtensionRootsForScope(scope, global) {
4846
5011
  selected_root: selectedRoot,
4847
5012
  roots
4848
5013
  };
4849
- }
4850
- function resolveGithubOption(options) {
4851
- if (typeof options.gh === "string" && typeof options.github === "string" && options.gh.trim() !== options.github.trim()) {
5014
+ };
5015
+ var resolveGithubOption = (options) => {
5016
+ const values = [options.gh, options.github].filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean);
5017
+ const uniqueValues = [...new Set(values)];
5018
+ if (uniqueValues.length > 1) {
4852
5019
  throw new PmCliError('Options "--gh" and "--github" must match when both are provided.', EXIT_CODE.USAGE);
4853
5020
  }
4854
- if (typeof options.gh === "string" && options.gh.trim().length > 0) {
4855
- return options.gh.trim();
4856
- }
4857
- if (typeof options.github === "string" && options.github.trim().length > 0) {
4858
- return options.github.trim();
4859
- }
4860
- return void 0;
4861
- }
4862
- function getLifecycleActionFlag(action) {
5021
+ return uniqueValues[0];
5022
+ };
5023
+ var getLifecycleActionFlag = (action) => {
4863
5024
  return LIFECYCLE_ACTION_FLAGS[action];
4864
- }
4865
- function requireTarget(target, action, options = {}) {
4866
- const normalized = target?.trim();
4867
- if (!normalized) {
4868
- if (action === "init") {
4869
- 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);
5025
+ };
5026
+ var throwMissingLifecycleTarget = (action, options) => {
5027
+ const noun = options.vocabulary === "package" ? "package" : "extension";
5028
+ const targetName = action === "install" ? "source" : "name";
5029
+ const targetLabel = `${noun} ${targetName}`;
5030
+ const actionFlag = getLifecycleActionFlag(action);
5031
+ const commandTarget = `<${targetName}>`;
5032
+ const command = `pm ${noun} ${actionFlag} ${commandTarget}`;
5033
+ throw new PmCliError(`Action "${action}" requires ${targetLabel} input.`, EXIT_CODE.USAGE, {
5034
+ code: "missing_lifecycle_target",
5035
+ required: `Provide a ${targetName} target for ${action}.`,
5036
+ examples: [
5037
+ `pm ${noun} ${action} ${commandTarget}`,
5038
+ command,
5039
+ `pm ${noun} --help`
5040
+ ],
5041
+ recovery: {
5042
+ attempted_command: `pm ${noun} ${action}`,
5043
+ suggested_retry: command,
5044
+ fallback_candidates: [
5045
+ {
5046
+ source: "lifecycle_action",
5047
+ command,
5048
+ reason: `flag-form ${action} command with required ${targetName} target`
5049
+ }
5050
+ ]
4870
5051
  }
4871
- const noun = options.vocabulary === "package" ? "package" : "extension";
4872
- const targetName = action === "install" ? "source" : "name";
4873
- const targetLabel = `${noun} ${targetName}`;
4874
- const actionFlag = getLifecycleActionFlag(action);
4875
- const commandTarget = `<${targetName}>`;
4876
- const command = `pm ${noun} ${actionFlag} ${commandTarget}`;
4877
- throw new PmCliError(`Action "${action}" requires ${targetLabel} input.`, EXIT_CODE.USAGE, {
4878
- code: "missing_lifecycle_target",
4879
- required: `Provide a ${targetName} target for ${action}.`,
4880
- examples: [
4881
- `pm ${noun} ${action} ${commandTarget}`,
4882
- command,
4883
- `pm ${noun} --help`
4884
- ],
4885
- recovery: {
4886
- attempted_command: `pm ${noun} ${action}`,
4887
- suggested_retry: command,
4888
- fallback_candidates: [
4889
- {
4890
- source: "lifecycle_action",
4891
- command,
4892
- reason: `flag-form ${action} command with required ${targetName} target`
4893
- }
4894
- ]
4895
- }
4896
- });
5052
+ });
5053
+ };
5054
+ var requireTarget = (target, action, options = {}) => {
5055
+ const normalized = target?.trim();
5056
+ if (normalized)
5057
+ return normalized;
5058
+ if (action === "init") {
5059
+ 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);
4897
5060
  }
4898
- return normalized;
4899
- }
4900
- function collectGlobalOutputOverrideDoctorWarnings(activationResult) {
5061
+ return throwMissingLifecycleTarget(action, options);
5062
+ };
5063
+ var collectGlobalOutputOverrideDoctorWarnings = (activationResult) => {
4901
5064
  const warnings = [];
4902
5065
  for (const entry of activationResult.services.overrides) {
4903
5066
  if (entry.service !== "output_format") {
@@ -4909,31 +5072,21 @@ function collectGlobalOutputOverrideDoctorWarnings(activationResult) {
4909
5072
  warnings.push(`extension_output_renderer_override_global:${entry.format}:${entry.layer}:${entry.name}`);
4910
5073
  }
4911
5074
  return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
4912
- }
4913
- function collectSchemaNarrowActivationDoctorWarnings(loadResult, activationResult) {
4914
- const schemaContributors = /* @__PURE__ */ new Set();
4915
- for (const entry of activationResult.registrations.item_types) {
4916
- if (entry.types.length > 0) {
4917
- schemaContributors.add(`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`);
4918
- }
4919
- }
4920
- for (const entry of activationResult.registrations.item_fields) {
4921
- if (entry.fields.length > 0) {
4922
- schemaContributors.add(`${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`);
4923
- }
4924
- }
4925
- const warnings = [];
4926
- for (const extension of loadResult.loaded) {
4927
- if ((extension.activation?.commands ?? []).length === 0) {
4928
- continue;
4929
- }
4930
- if (schemaContributors.has(`${extension.layer}:${normalizeExtensionNameForMatch(extension.name)}`)) {
4931
- warnings.push(`extension_schema_narrow_activation:${extension.layer}:${extension.name}`);
4932
- }
4933
- }
4934
- return [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
4935
- }
4936
- function assertExtensionActionOptionScope(action, options) {
5075
+ };
5076
+ var collectSchemaNarrowActivationDoctorWarnings = (loadResult, activationResult) => {
5077
+ const schemaContributors = new Set([
5078
+ ...activationResult.registrations.item_types.map((entry) => ({
5079
+ entry,
5080
+ count: entry.types.length
5081
+ })),
5082
+ ...activationResult.registrations.item_fields.map((entry) => ({
5083
+ entry,
5084
+ count: entry.fields.length
5085
+ }))
5086
+ ].filter(({ count }) => count > 0).map(({ entry }) => `${entry.layer}:${normalizeExtensionNameForMatch(entry.name)}`));
5087
+ return loadResult.loaded.filter((extension) => (extension.activation?.commands ?? []).length > 0).filter((extension) => schemaContributors.has(`${extension.layer}:${normalizeExtensionNameForMatch(extension.name)}`)).map((extension) => `extension_schema_narrow_activation:${extension.layer}:${extension.name}`).filter((warning, index, warnings) => warnings.indexOf(warning) === index).sort((left, right) => left.localeCompare(right));
5088
+ };
5089
+ var assertExtensionActionOptionScope = (action, options) => {
4937
5090
  const guards = [
4938
5091
  {
4939
5092
  triggered: options.strictExit === true || options.failOnWarn === true,
@@ -4976,86 +5129,115 @@ function assertExtensionActionOptionScope(action, options) {
4976
5129
  message: "--declarative is only valid with --init/--scaffold."
4977
5130
  }
4978
5131
  ];
4979
- for (const guard of guards) {
4980
- if (guard.triggered && !guard.allowed) {
4981
- throw new PmCliError(guard.message, EXIT_CODE.USAGE);
4982
- }
5132
+ const invalidGuard = guards.find((guard) => guard.triggered && !guard.allowed);
5133
+ if (invalidGuard) {
5134
+ throw new PmCliError(invalidGuard.message, EXIT_CODE.USAGE);
4983
5135
  }
4984
- }
4985
- function resolveNormalizedExtensionTarget(target, action, options) {
4986
- const normalizedInput = target?.trim().toLowerCase();
4987
- if (action === "doctor" && normalizedInput === "doctor") {
4988
- return void 0;
4989
- }
4990
- if (action === "reload" && normalizedInput === "reload") {
4991
- return void 0;
4992
- }
4993
- if (action === "catalog" && normalizedInput === "catalog") {
4994
- return void 0;
4995
- }
4996
- const inferredInitAlias = action === "init" && options.init !== true && options.scaffold !== true && (normalizedInput === "init" || normalizedInput === "scaffold");
4997
- if (inferredInitAlias) {
4998
- return void 0;
5136
+ };
5137
+ var resolveNormalizedExtensionTarget = (target, action, options) => {
5138
+ const normalizedInput = String(target ?? "").trim().toLowerCase();
5139
+ const explicitInitAction = [options.init, options.scaffold].includes(true);
5140
+ const aliases = {
5141
+ doctor: ["doctor"],
5142
+ reload: ["reload"],
5143
+ catalog: ["catalog"],
5144
+ init: explicitInitAction ? [] : ["init", "scaffold"]
5145
+ };
5146
+ return (aliases[action] ?? []).includes(normalizedInput) ? void 0 : target;
5147
+ };
5148
+ var resolveExtensionResultRoots = (ctx) => {
5149
+ const projectedCatalog = [
5150
+ ctx.action === "catalog",
5151
+ typeof ctx.options.fields === "string",
5152
+ String(ctx.options.fields).trim().length > 0
5153
+ ].every(Boolean);
5154
+ return projectedCatalog ? {
5155
+ project: "project",
5156
+ global: "global",
5157
+ selected: ctx.scope,
5158
+ settings_root: "project"
5159
+ } : {
5160
+ project: ctx.resolvedRoots.roots.project,
5161
+ global: ctx.resolvedRoots.roots.global,
5162
+ selected: ctx.resolvedRoots.selected_root,
5163
+ settings_root: ctx.resolvedRoots.settings_root
5164
+ };
5165
+ };
5166
+ var buildExtensionActionResult = (ctx, details, ok) => {
5167
+ const result = {
5168
+ ok,
5169
+ action: ctx.action,
5170
+ scope: ctx.scope,
5171
+ roots: resolveExtensionResultRoots(ctx),
5172
+ warnings: [...new Set(ctx.warnings)].sort((left, right) => left.localeCompare(right)),
5173
+ details
5174
+ };
5175
+ if (ctx.action === "doctor") {
5176
+ Object.defineProperty(result, NATIVE_OUTPUT_MARKER, {
5177
+ value: true,
5178
+ enumerable: false,
5179
+ configurable: false
5180
+ });
4999
5181
  }
5000
- return target;
5001
- }
5002
- async function runExtension(target, options, global) {
5182
+ return result;
5183
+ };
5184
+ var runExtension = async (target, options, global) => {
5003
5185
  const action = resolveAction(target, options);
5004
5186
  assertExtensionActionOptionScope(action, options);
5005
5187
  const normalizedTarget = resolveNormalizedExtensionTarget(target, action, options);
5006
5188
  const scope = resolveScope(options);
5007
5189
  const resolvedRoots = resolveExtensionRootsForScope(scope, global);
5008
5190
  const warnings = [];
5009
- const withResult = (details, ok = true) => {
5010
- const result = {
5011
- ok,
5012
- action,
5013
- scope,
5014
- roots: action === "catalog" && typeof options.fields === "string" && options.fields.trim().length > 0 ? {
5015
- project: "project",
5016
- global: "global",
5017
- selected: scope,
5018
- settings_root: "project"
5019
- } : {
5020
- project: resolvedRoots.roots.project,
5021
- global: resolvedRoots.roots.global,
5022
- selected: resolvedRoots.selected_root,
5023
- settings_root: resolvedRoots.settings_root
5024
- },
5025
- warnings: [...new Set(warnings)].sort((left, right) => left.localeCompare(right)),
5026
- details
5027
- };
5028
- if (action === "doctor") {
5029
- Object.defineProperty(result, NATIVE_OUTPUT_MARKER, {
5030
- value: true,
5031
- enumerable: false,
5032
- configurable: false
5033
- });
5034
- }
5035
- return result;
5036
- };
5037
- const ctx = {
5191
+ const actionContext = {
5038
5192
  action,
5039
5193
  normalizedTarget,
5040
5194
  scope,
5041
5195
  resolvedRoots,
5042
5196
  warnings,
5043
5197
  options,
5044
- global,
5198
+ global
5199
+ };
5200
+ const withResult = (details, ok = true) => buildExtensionActionResult(actionContext, details, ok);
5201
+ const ctx = {
5202
+ ...actionContext,
5045
5203
  withResult
5046
5204
  };
5047
- return EXTENSION_ACTION_HANDLERS[action](ctx);
5048
- }
5049
- async function runExtensionInitAction(ctx) {
5205
+ return await dispatchExtensionAction(ctx);
5206
+ };
5207
+ var buildExtensionScaffoldNextSteps = (scaffold, options) => {
5208
+ const vocabulary = options.vocabulary ?? "extension";
5209
+ const shellTargetPath = scaffold.target_path.replace(/\\/g, "/");
5210
+ const quotedShellTargetPath = quoteCommandArg(shellTargetPath);
5211
+ const dependencySteps = {
5212
+ package: `Install dependencies: cd ${quotedShellTargetPath}, then run "npm install"`,
5213
+ extension: `Install type-check dependencies: cd ${quotedShellTargetPath}, then run "npm install -D typescript @types/node @unbrained/pm-cli"`
5214
+ };
5215
+ const validationSteps = {
5216
+ package: `Validate the package: cd ${quotedShellTargetPath}, then run "npm run typecheck" and "npm test"`,
5217
+ extension: `Type-check the source (optional): cd ${quotedShellTargetPath}, then run "npx tsc --noEmit"`
5218
+ };
5219
+ const declarativeGuidance = [];
5220
+ if ([vocabulary === "package", options.declarative === true].every(Boolean)) {
5221
+ declarativeGuidance.push("Ensure the target workspace can resolve @unbrained/pm-cli before installing this declarative package.");
5222
+ }
5223
+ return [
5224
+ dependencySteps[vocabulary],
5225
+ ...declarativeGuidance,
5226
+ `Install the scaffold: ${renderPmCommand(vocabulary === "package" ? ["install", "--project", shellTargetPath] : ["extension", "--install", "--project", shellTargetPath])}`,
5227
+ `Smoke-test command path: pm ${scaffold.command_name}`,
5228
+ validationSteps[vocabulary],
5229
+ `Run diagnostics: ${vocabulary === "package" ? "pm package doctor" : "pm extension --doctor"} --project --detail summary`
5230
+ ];
5231
+ };
5232
+ var runExtensionInitAction = async (ctx) => {
5050
5233
  const { action, normalizedTarget, options, withResult } = ctx;
5051
5234
  const githubOption = resolveGithubOption(options);
5052
- if (githubOption !== void 0 || typeof options.ref === "string" && options.ref.trim().length > 0) {
5235
+ const disallowedSourceOptions = [githubOption, options.ref].filter((value) => typeof value === "string").map((value) => value.trim()).filter(Boolean);
5236
+ if (disallowedSourceOptions.length > 0) {
5053
5237
  throw new PmCliError('Action "init" does not accept --gh/--github/--ref options.', EXIT_CODE.USAGE);
5054
5238
  }
5055
5239
  const scaffoldTarget = requireTarget(normalizedTarget, action, options);
5056
5240
  const scaffold = await scaffoldExtensionProject(scaffoldTarget, options.vocabulary ?? "extension", options.capability, options.declarative === true);
5057
- const quotedTargetPath = JSON.stringify(scaffold.target_path);
5058
- const quotedShellTargetPath = JSON.stringify(scaffold.target_path.replace(/\\/g, "/"));
5059
5241
  return withResult({
5060
5242
  scaffolded: scaffold.created_directory || scaffold.files.some((entry) => entry.status === "created"),
5061
5243
  extension: {
@@ -5063,35 +5245,14 @@ async function runExtensionInitAction(ctx) {
5063
5245
  command: scaffold.command_name
5064
5246
  },
5065
5247
  capability: scaffold.capability,
5066
- style: scaffold.style,
5067
- target_path: scaffold.target_path,
5068
- created_directory: scaffold.created_directory,
5069
- files: scaffold.files,
5070
- next_steps: [
5071
- // Extensions are authored AND loaded as TypeScript (ADR pm-2c28 / pm-m1uz):
5072
- // the manifest entry is ./index.ts and pm strips types on load (Node
5073
- // >=22.18), so there is no compile/build step — install dependencies, then
5074
- // install the scaffold directly.
5075
- ...options.vocabulary === "package" ? [
5076
- `Install dependencies: cd ${quotedShellTargetPath}, then run "npm install"`
5077
- ] : [
5078
- `Install type-check dependencies: cd ${quotedShellTargetPath}, then run "npm install -D typescript @types/node @unbrained/pm-cli"`
5079
- ],
5080
- ...options.vocabulary === "package" && options.declarative === true ? [
5081
- "Ensure the target workspace can resolve @unbrained/pm-cli before installing this declarative package."
5082
- ] : [],
5083
- `Install the scaffold: ${options.vocabulary === "package" ? "pm install --project" : "pm extension --install --project"} ${quotedTargetPath}`,
5084
- `Smoke-test command path: pm ${scaffold.command_name}`,
5085
- ...options.vocabulary === "package" ? [
5086
- `Validate the package: cd ${quotedShellTargetPath}, then run "npm run typecheck" and "npm test"`
5087
- ] : [
5088
- `Type-check the source (optional): cd ${quotedShellTargetPath}, then run "npx tsc --noEmit"`
5089
- ],
5090
- `Run diagnostics: ${options.vocabulary === "package" ? "pm package doctor" : "pm extension --doctor"} --project --detail summary`
5091
- ]
5248
+ style: scaffold.style,
5249
+ target_path: scaffold.target_path,
5250
+ created_directory: scaffold.created_directory,
5251
+ files: scaffold.files,
5252
+ next_steps: buildExtensionScaffoldNextSteps(scaffold, options)
5092
5253
  });
5093
- }
5094
- async function runExtensionReloadAction(ctx) {
5254
+ };
5255
+ var runExtensionReloadAction = async (ctx) => {
5095
5256
  const { normalizedTarget, resolvedRoots, warnings, options, global, withResult } = ctx;
5096
5257
  if (normalizedTarget !== void 0) {
5097
5258
  throw new PmCliError('Action "reload" does not accept a target argument.', EXIT_CODE.USAGE);
@@ -5139,114 +5300,173 @@ async function runExtensionReloadAction(ctx) {
5139
5300
  warnings.push("extension_reload_watch_hint:watch_mode_requested_non_interactive_single_pass_only");
5140
5301
  }
5141
5302
  return withResult(details);
5142
- }
5143
- async function runExtensionCatalogAction(ctx) {
5303
+ };
5304
+ var runExtensionCatalogAction = async (ctx) => {
5144
5305
  const { normalizedTarget, scope, options, global, withResult } = ctx;
5145
5306
  if (typeof normalizedTarget === "string" && normalizedTarget.length > 0 && normalizedTarget !== "catalog") {
5146
5307
  throw new PmCliError('Action "catalog" does not accept a package target.', EXIT_CODE.USAGE);
5147
5308
  }
5148
5309
  return withResult(await buildBundledPackageCatalog(scope, global, options));
5149
- }
5150
- function buildInstallManagedSource(bundledAliasName, bundledPackageName, installSource, resolvedSource) {
5310
+ };
5311
+ var buildBundledInstallManagedSource = (alias, packageName) => ({
5312
+ kind: "builtin",
5313
+ input: alias,
5314
+ location: alias,
5315
+ name: alias,
5316
+ ...packageName === null ? {} : { package: packageName }
5317
+ });
5318
+ var buildLocalInstallManagedSource = (source) => ({
5319
+ kind: "local",
5320
+ input: source.input,
5321
+ location: source.absolute_path
5322
+ });
5323
+ var buildNpmInstallManagedSource = (source, resolved) => ({
5324
+ kind: "npm",
5325
+ input: source.input,
5326
+ location: resolved.resolved_subpath ?? ".",
5327
+ package: resolved.npm_package,
5328
+ version: resolved.npm_version
5329
+ });
5330
+ var buildGithubInstallManagedSource = (source, resolved) => ({
5331
+ kind: "github",
5332
+ input: source.input,
5333
+ location: resolved.resolved_subpath ?? source.subpath ?? ".",
5334
+ repository: source.repository,
5335
+ owner: source.owner,
5336
+ repo: source.repo,
5337
+ ref: source.ref,
5338
+ subpath: resolved.resolved_subpath ?? source.subpath,
5339
+ commit: resolved.commit
5340
+ });
5341
+ var buildInstallManagedSource = (bundledAliasName, bundledPackageName, installSource, resolvedSource) => {
5151
5342
  if (bundledAliasName) {
5152
- return {
5153
- kind: "builtin",
5154
- input: bundledAliasName,
5155
- location: bundledAliasName,
5156
- name: bundledAliasName,
5157
- ...bundledPackageName === null ? {} : { package: bundledPackageName }
5158
- };
5343
+ return buildBundledInstallManagedSource(bundledAliasName, bundledPackageName);
5159
5344
  }
5160
5345
  if (installSource.kind === "local") {
5161
- return {
5162
- kind: "local",
5163
- input: installSource.input,
5164
- location: installSource.absolute_path
5165
- };
5346
+ return buildLocalInstallManagedSource(installSource);
5166
5347
  }
5167
5348
  if (installSource.kind === "npm") {
5168
- return {
5169
- kind: "npm",
5170
- input: installSource.input,
5171
- location: resolvedSource.resolved_subpath ?? ".",
5172
- package: resolvedSource.npm_package,
5173
- version: resolvedSource.npm_version
5174
- };
5349
+ return buildNpmInstallManagedSource(installSource, resolvedSource);
5350
+ }
5351
+ return buildGithubInstallManagedSource(installSource, resolvedSource);
5352
+ };
5353
+ var resolveManagedInstallTimestamps = (existing, manifestVersion, source, now) => {
5354
+ if (!existing)
5355
+ return { installed_at: now, updated_at: now };
5356
+ if (existing.manifest_version !== manifestVersion) {
5357
+ return { installed_at: existing.installed_at, updated_at: now };
5358
+ }
5359
+ if (!managedExtensionSourcesEquivalent(existing.source, source)) {
5360
+ return { installed_at: existing.installed_at, updated_at: now };
5175
5361
  }
5176
5362
  return {
5177
- kind: "github",
5178
- input: installSource.input,
5179
- location: resolvedSource.resolved_subpath ?? installSource.subpath ?? ".",
5180
- repository: installSource.repository,
5181
- owner: installSource.owner,
5182
- repo: installSource.repo,
5183
- ref: installSource.ref,
5184
- subpath: resolvedSource.resolved_subpath ?? installSource.subpath,
5185
- commit: resolvedSource.commit
5363
+ installed_at: existing.installed_at,
5364
+ updated_at: existing.updated_at
5186
5365
  };
5187
- }
5188
- async function performExtensionInstallUnderLock(ctx, input3) {
5189
- const { scope, resolvedRoots, warnings, global, withResult } = ctx;
5190
- const { validated, destinationDirectoryName, bundledAliasName, bundledPackageName, installSource, resolvedSource } = input3;
5366
+ };
5367
+ var persistExtensionInstall = async (ctx, input3) => {
5368
+ const { scope, resolvedRoots, warnings } = ctx;
5369
+ const { validated, destinationDirectoryName } = input3;
5191
5370
  const settings = await readSettings(resolvedRoots.settings_root);
5192
5371
  const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
5193
5372
  warnings.push(...managedStateRead.warnings);
5194
- const destinationDirectory = path6.join(resolvedRoots.selected_root, destinationDirectoryName);
5373
+ const destinationDirectory = path8.join(resolvedRoots.selected_root, destinationDirectoryName);
5195
5374
  const destinationExists = await pathExists(destinationDirectory);
5196
5375
  const installInPlace = await areDirectoriesEquivalent(validated.directory, destinationDirectory);
5197
- await fs6.mkdir(resolvedRoots.selected_root, { recursive: true });
5198
- if (!installInPlace) {
5199
- await copyExtensionDirectoryForInstall(validated.directory, destinationDirectory);
5200
- }
5201
- await ensureExtensionModuleTypeMarker(destinationDirectory);
5202
- const sourceRecord = buildInstallManagedSource(bundledAliasName, bundledPackageName, installSource, resolvedSource);
5203
- const now = nowIso();
5204
- const existingManagedEntry = managedStateRead.state.entries.find((entry) => normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(validated.manifest.name));
5205
- const sourceUnchanged = existingManagedEntry !== void 0 && existingManagedEntry.manifest_version === validated.manifest.version && managedExtensionSourcesEquivalent(existingManagedEntry.source, sourceRecord);
5206
- const managedState = upsertManagedEntry(managedStateRead.state, {
5207
- name: validated.manifest.name,
5208
- directory: destinationDirectoryName,
5209
- scope,
5210
- manifest_version: validated.manifest.version,
5211
- manifest_entry: validated.manifest.entry,
5212
- capabilities: [...validated.manifest.capabilities],
5213
- installed_at: existingManagedEntry?.installed_at ?? now,
5214
- updated_at: sourceUnchanged ? existingManagedEntry.updated_at : now,
5215
- source: sourceRecord
5216
- });
5217
- await writeManagedExtensionState(resolvedRoots.selected_root, managedState);
5218
- const activationChanged = ensureActivated(settings, validated.manifest.name);
5219
- if (activationChanged) {
5220
- await writeSettings(resolvedRoots.settings_root, settings, "settings:write");
5376
+ await fs8.mkdir(resolvedRoots.selected_root, { recursive: true });
5377
+ const backupRoot = await fs8.mkdtemp(path8.join(resolvedRoots.selected_root, ".pm-extension-install-backup-"));
5378
+ const backupDirectory = path8.join(backupRoot, "destination");
5379
+ try {
5380
+ const snapshot = await captureExtensionInstallSnapshot(resolvedRoots.selected_root, resolvedRoots.settings_root, destinationDirectory, destinationExists, backupDirectory);
5381
+ const sourceRecord = buildInstallManagedSource(input3.bundledAliasName, input3.bundledPackageName, input3.installSource, input3.resolvedSource);
5382
+ const existingManagedEntry = managedStateRead.state.entries.find((entry) => normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(validated.manifest.name));
5383
+ const timestamps = resolveManagedInstallTimestamps(existingManagedEntry, validated.manifest.version, sourceRecord, nowIso());
5384
+ const managedState = upsertManagedEntry(managedStateRead.state, {
5385
+ name: validated.manifest.name,
5386
+ directory: destinationDirectoryName,
5387
+ scope,
5388
+ manifest_version: validated.manifest.version,
5389
+ manifest_entry: validated.manifest.entry,
5390
+ capabilities: [...validated.manifest.capabilities],
5391
+ ...timestamps,
5392
+ source: sourceRecord
5393
+ });
5394
+ const activationChanged = ensureActivated(settings, validated.manifest.name);
5395
+ try {
5396
+ if (!installInPlace) {
5397
+ await copyExtensionDirectoryForInstall(validated.directory, destinationDirectory);
5398
+ }
5399
+ await ensureExtensionModuleTypeMarker(destinationDirectory);
5400
+ await writeManagedExtensionState(resolvedRoots.selected_root, managedState);
5401
+ if (activationChanged) {
5402
+ await writeSettings(resolvedRoots.settings_root, settings, "settings:write");
5403
+ }
5404
+ } catch (error) {
5405
+ try {
5406
+ await restoreExtensionInstallSnapshot(snapshot);
5407
+ } catch (rollbackError) {
5408
+ throw new AggregateError([error, rollbackError], `Extension install failed: ${String(error)}; rollback failed: ${String(rollbackError)}`, { cause: rollbackError });
5409
+ }
5410
+ throw error;
5411
+ }
5412
+ return {
5413
+ settings,
5414
+ managedState,
5415
+ sourceRecord,
5416
+ destinationDirectory,
5417
+ destinationExists,
5418
+ installInPlace,
5419
+ activationChanged
5420
+ };
5421
+ } finally {
5422
+ await fs8.rm(backupRoot, { recursive: true, force: true }).catch(() => void 0);
5221
5423
  }
5222
- const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
5223
- warnings.push(...refreshedInstalled.warnings);
5224
- const runtimeProbe = await probeRuntimeCommandPathsForInstall(resolvedRoots.pm_root, settings, refreshedInstalled.extensions, global);
5225
- warnings.push(...runtimeProbe.warnings);
5226
- 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 })));
5227
- if (scope === "project" && installedItemTypeDefinitions.length > 0) {
5228
- await ensureTypeFolderScaffold(resolvedRoots.pm_root, installedItemTypeDefinitions, warnings, "install:type-folder");
5424
+ };
5425
+ var scaffoldInstalledExtensionItemTypes = async (ctx, extensionName, registrations) => {
5426
+ const definitions = registrations.filter((entry) => normalizeExtensionNameForMatch(entry.name) === normalizeExtensionNameForMatch(extensionName)).flatMap((entry) => entry.types.map((type) => ({ name: type.name, folder: type.folder })));
5427
+ if (ctx.scope === "project" && definitions.length > 0) {
5428
+ await ensureTypeFolderScaffold(ctx.resolvedRoots.pm_root, definitions, ctx.warnings, "install:type-folder");
5229
5429
  }
5230
- const commandSummary = summarizeRuntimeCommandPathsForExtension(validated.manifest.name, runtimeProbe.installed);
5231
- const installActivationFailure = findActivationFailureByName(validated.manifest.name, runtimeProbe.activation_failures, scope);
5232
- const runtimeActivationStatus = resolveInstallRuntimeActivationStatus(validated.manifest.name, scope, runtimeProbe.installed, installActivationFailure);
5233
- const activated = !runtimeProbe.extensions_disabled && runtimeActivationStatus !== "failed";
5430
+ return definitions;
5431
+ };
5432
+ var buildInstalledExtensionActivation = (ctx, extensionName, runtimeProbe, commandSummary, installedItemTypes) => {
5433
+ const failure = findActivationFailureByName(extensionName, runtimeProbe.activation_failures, ctx.scope);
5434
+ const status = resolveInstallRuntimeActivationStatus(extensionName, ctx.scope, runtimeProbe.installed, failure);
5435
+ const activated = [!runtimeProbe.extensions_disabled, status === "ok"].every(Boolean);
5234
5436
  if (!activated) {
5235
- warnings.push(`extension_install_activation_failed:${scope}:${validated.manifest.name}:${runtimeActivationStatus}`);
5437
+ ctx.warnings.push(`extension_install_activation_failed:${ctx.scope}:${extensionName}:${status}`);
5236
5438
  }
5237
- const verification = {
5238
- status: activated ? "ok" : "degraded",
5239
- target_pm_root: resolvedRoots.pm_root,
5240
- activation_status: runtimeActivationStatus,
5439
+ const healthByActivation = {
5440
+ true: { status: "ok", blocking_failure_count: 0 },
5441
+ false: { status: "degraded", blocking_failure_count: 1 }
5442
+ };
5443
+ return {
5241
5444
  activated,
5242
- registered_commands: commandSummary.command_paths,
5243
- registered_actions: commandSummary.action_paths,
5244
- registered_item_types: installedItemTypeDefinitions,
5245
- health: {
5246
- status: activated ? "ok" : "degraded",
5247
- blocking_failure_count: activated ? 0 : 1
5445
+ status,
5446
+ failure,
5447
+ verification: {
5448
+ status: healthByActivation[String(activated)].status,
5449
+ target_pm_root: ctx.resolvedRoots.pm_root,
5450
+ activation_status: status,
5451
+ activated,
5452
+ registered_commands: commandSummary.command_paths,
5453
+ registered_actions: commandSummary.action_paths,
5454
+ registered_item_types: installedItemTypes,
5455
+ health: healthByActivation[String(activated)]
5248
5456
  }
5249
5457
  };
5458
+ };
5459
+ var performExtensionInstallUnderLock = async (ctx, input3) => {
5460
+ const { scope, resolvedRoots, warnings, global, withResult } = ctx;
5461
+ const { validated, destinationDirectoryName } = input3;
5462
+ const persisted = await persistExtensionInstall(ctx, input3);
5463
+ const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, persisted.settings, persisted.managedState);
5464
+ warnings.push(...refreshedInstalled.warnings);
5465
+ const runtimeProbe = await probeRuntimeCommandPathsForInstall(resolvedRoots.pm_root, persisted.settings, refreshedInstalled.extensions, global);
5466
+ warnings.push(...runtimeProbe.warnings);
5467
+ const installedItemTypeDefinitions = await scaffoldInstalledExtensionItemTypes(ctx, validated.manifest.name, runtimeProbe.item_type_registrations);
5468
+ const commandSummary = summarizeRuntimeCommandPathsForExtension(validated.manifest.name, runtimeProbe.installed);
5469
+ const activation = buildInstalledExtensionActivation(ctx, validated.manifest.name, runtimeProbe, commandSummary, installedItemTypeDefinitions);
5250
5470
  return withResult({
5251
5471
  extension: {
5252
5472
  name: validated.manifest.name,
@@ -5255,74 +5475,80 @@ async function performExtensionInstallUnderLock(ctx, input3) {
5255
5475
  capabilities: validated.manifest.capabilities,
5256
5476
  directory: destinationDirectoryName
5257
5477
  },
5258
- source: sourceRecord,
5259
- destination_path: destinationDirectory,
5260
- overwritten: destinationExists && !installInPlace,
5261
- installed_in_place: installInPlace,
5262
- activated,
5263
- settings_changed: activationChanged,
5264
- runtime_activation_status: runtimeActivationStatus,
5478
+ source: persisted.sourceRecord,
5479
+ destination_path: persisted.destinationDirectory,
5480
+ overwritten: [
5481
+ persisted.destinationExists,
5482
+ !persisted.installInPlace
5483
+ ].every(Boolean),
5484
+ installed_in_place: persisted.installInPlace,
5485
+ activated: activation.activated,
5486
+ settings_changed: persisted.activationChanged,
5487
+ runtime_activation_status: activation.status,
5265
5488
  command_paths: commandSummary.command_paths,
5266
5489
  action_paths: commandSummary.action_paths,
5267
- command_discovery: buildInstallCommandDiscovery(validated.manifest.name, sourceRecord, commandSummary, installActivationFailure),
5268
- verification,
5490
+ command_discovery: buildInstallCommandDiscovery(validated.manifest.name, persisted.sourceRecord, commandSummary, activation.failure),
5491
+ verification: activation.verification,
5269
5492
  activation_diagnostics: {
5270
5493
  failed_count: runtimeProbe.activation_failures.length,
5271
5494
  failed: runtimeProbe.activation_failures,
5272
- installed_extension_failed: installActivationFailure ?? null
5273
- }
5274
- }, activated);
5275
- }
5276
- async function runExtensionInstallAction(ctx) {
5277
- const { action, normalizedTarget, resolvedRoots, warnings, options, global, withResult } = ctx;
5278
- const githubOption = resolveGithubOption(options);
5279
- const explicitSourceInput = githubOption ?? requireTarget(normalizedTarget, action, options);
5280
- if (typeof githubOption !== "string" && isBundledPackageInstallAllTarget(explicitSourceInput)) {
5281
- if (typeof options.ref === "string" && options.ref.trim().length > 0) {
5282
- throw new PmCliError('Action "install all" does not accept --ref.', EXIT_CODE.USAGE);
5283
- }
5284
- const aliases = await listBundledPackageAliases();
5285
- const packages = [];
5286
- for (const alias of aliases) {
5287
- packages.push({
5288
- alias,
5289
- result: await runExtension(alias, { ...options, install: true }, global)
5290
- });
5495
+ installed_extension_failed: activation.failure ?? null
5291
5496
  }
5292
- for (const entry of packages) {
5293
- warnings.push(...entry.result.warnings);
5294
- }
5295
- const installedAll = packages.every((entry) => entry.result.ok);
5296
- return withResult({
5297
- installed_all: installedAll,
5298
- installed_count: packages.filter((entry) => entry.result.ok).length,
5299
- failed_count: packages.filter((entry) => !entry.result.ok).length,
5300
- packages: packages.map((entry) => ({
5497
+ }, activation.activated);
5498
+ };
5499
+ var runBundledExtensionInstallAll = async (ctx) => {
5500
+ const { options, global, warnings, withResult } = ctx;
5501
+ if (typeof options.ref === "string" && options.ref.trim().length > 0) {
5502
+ throw new PmCliError('Action "install all" does not accept --ref.', EXIT_CODE.USAGE);
5503
+ }
5504
+ const packages = [];
5505
+ for (const alias of await listBundledPackageAliases()) {
5506
+ packages.push({
5507
+ alias,
5508
+ result: await runExtension(alias, { ...options, install: true }, global)
5509
+ });
5510
+ }
5511
+ warnings.push(...packages.flatMap((entry) => entry.result.warnings));
5512
+ const installedAll = packages.every((entry) => entry.result.ok);
5513
+ return withResult({
5514
+ installed_all: installedAll,
5515
+ installed_count: packages.filter((entry) => entry.result.ok).length,
5516
+ failed_count: packages.filter((entry) => !entry.result.ok).length,
5517
+ packages: packages.map((entry) => {
5518
+ const details = entry.result.details;
5519
+ return {
5301
5520
  alias: entry.alias,
5302
5521
  ok: entry.result.ok,
5303
- extension: entry.result.details.extension,
5304
- source: entry.result.details.source,
5305
- destination_path: entry.result.details.destination_path,
5306
- activated: entry.result.details.activated,
5307
- settings_changed: entry.result.details.settings_changed,
5308
- command_paths: entry.result.details.command_paths,
5309
- action_paths: entry.result.details.action_paths,
5310
- command_discovery: entry.result.details.command_discovery,
5311
- verification: entry.result.details.verification,
5312
- runtime_activation_status: entry.result.details.runtime_activation_status,
5313
- activation_diagnostics: entry.result.details.activation_diagnostics,
5522
+ extension: details.extension,
5523
+ source: details.source,
5524
+ destination_path: details.destination_path,
5525
+ activated: details.activated,
5526
+ settings_changed: details.settings_changed,
5527
+ command_paths: details.command_paths,
5528
+ action_paths: details.action_paths,
5529
+ command_discovery: details.command_discovery,
5530
+ verification: details.verification,
5531
+ runtime_activation_status: details.runtime_activation_status,
5532
+ activation_diagnostics: details.activation_diagnostics,
5314
5533
  warnings: entry.result.warnings
5315
- }))
5316
- }, installedAll);
5317
- }
5534
+ };
5535
+ })
5536
+ }, installedAll);
5537
+ };
5538
+ var resolveSingleExtensionInstallSource = async (explicitSourceInput, githubOption, ref) => {
5318
5539
  const bundledAliasSource = typeof githubOption === "string" ? null : await resolveBundledExtensionAliasSource(explicitSourceInput);
5319
5540
  const bundledAliasName = bundledAliasSource === null ? null : explicitSourceInput.trim().toLowerCase();
5320
5541
  const bundledPackageName = bundledAliasName === null ? null : await resolveBundledPackageNpmName(bundledAliasName);
5321
5542
  const sourceInput = bundledAliasSource ?? explicitSourceInput;
5322
5543
  const installSource = parseExtensionInstallSource(sourceInput, {
5323
5544
  forceGithub: typeof githubOption === "string",
5324
- ref: options.ref
5545
+ ref
5325
5546
  });
5547
+ return { bundledAliasName, bundledPackageName, installSource };
5548
+ };
5549
+ var runSingleExtensionInstall = async (ctx, explicitSourceInput, githubOption) => {
5550
+ const { resolvedRoots } = ctx;
5551
+ const { bundledAliasName, bundledPackageName, installSource } = await resolveSingleExtensionInstallSource(explicitSourceInput, githubOption, ctx.options.ref);
5326
5552
  const resolvedSource = await resolveInstallSource(installSource);
5327
5553
  try {
5328
5554
  const validated = await validateExtensionDirectory(resolvedSource.directory);
@@ -5340,8 +5566,19 @@ async function runExtensionInstallAction(ctx) {
5340
5566
  await resolvedSource.cleanup();
5341
5567
  }
5342
5568
  }
5343
- }
5344
- async function runExtensionAdoptAllAction(ctx) {
5569
+ };
5570
+ var runExtensionInstallAction = async (ctx) => {
5571
+ const githubOption = resolveGithubOption(ctx.options);
5572
+ const explicitSourceInput = githubOption ?? requireTarget(ctx.normalizedTarget, ctx.action, ctx.options);
5573
+ if ([
5574
+ githubOption === void 0,
5575
+ isBundledPackageInstallAllTarget(explicitSourceInput)
5576
+ ].every(Boolean)) {
5577
+ return runBundledExtensionInstallAll(ctx);
5578
+ }
5579
+ return runSingleExtensionInstall(ctx, explicitSourceInput, githubOption);
5580
+ };
5581
+ var runExtensionAdoptAllAction = async (ctx) => {
5345
5582
  const { normalizedTarget, scope, resolvedRoots, warnings, options, withResult } = ctx;
5346
5583
  if (normalizedTarget !== void 0) {
5347
5584
  throw new PmCliError('Action "adopt-all" does not accept a target argument.', EXIT_CODE.USAGE);
@@ -5360,14 +5597,18 @@ async function runExtensionAdoptAllAction(ctx) {
5360
5597
  warnings.push(...refreshedInstalled.warnings);
5361
5598
  const triage = buildExtensionTriageSummary(scope, warnings, refreshedInstalled.extensions, options);
5362
5599
  warnings.push(...triage.warnings);
5600
+ const refreshedByIdentity = new Map(refreshedInstalled.extensions.map((entry) => [
5601
+ `${normalizeExtensionNameForMatch(entry.name)}:${normalizeExtensionNameForMatch(entry.directory)}`,
5602
+ entry
5603
+ ]));
5604
+ const refreshedByDirectory = new Map(refreshedInstalled.extensions.map((entry) => [
5605
+ normalizeExtensionNameForMatch(entry.directory),
5606
+ entry
5607
+ ]));
5363
5608
  const adoptedDetails = adoption.adopted_entries.map((entry) => {
5364
- 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 */
5365
- refreshedInstalled.extensions.find((candidate) => normalizeExtensionNameForMatch(candidate.directory) === normalizeExtensionNameForMatch(entry.directory));
5366
- return {
5367
- ...entry,
5368
- update_check_status: refreshedEntry?.update_check_status ?? null,
5369
- update_check_reason: refreshedEntry?.update_check_reason ?? null
5370
- };
5609
+ const normalizedDirectory = normalizeExtensionNameForMatch(entry.directory);
5610
+ const refreshedEntry = refreshedByIdentity.get(`${normalizeExtensionNameForMatch(entry.name)}:${normalizedDirectory}`) ?? refreshedByDirectory.get(normalizedDirectory);
5611
+ return { ...entry, ...projectExtensionUpdateCheck(refreshedEntry) };
5371
5612
  });
5372
5613
  return withResult({
5373
5614
  adopted_all: adoptedDetails.length > 0,
@@ -5379,8 +5620,40 @@ async function runExtensionAdoptAllAction(ctx) {
5379
5620
  update_health_partial: triage.update_health_partial,
5380
5621
  update_health_coverage: triage.update_health_coverage
5381
5622
  });
5382
- }
5383
- async function runExtensionAdoptAction(ctx) {
5623
+ };
5624
+ var projectExtensionUpdateCheck = (entry) => {
5625
+ return {
5626
+ update_check_status: entry?.update_check_status ?? null,
5627
+ update_check_reason: entry?.update_check_reason ?? null
5628
+ };
5629
+ };
5630
+ var buildAdoptedExtensionSource = (githubOption, extensionTarget, extensionDirectory, ref) => {
5631
+ if (githubOption === void 0) {
5632
+ return {
5633
+ kind: "local",
5634
+ input: extensionTarget,
5635
+ location: extensionDirectory
5636
+ };
5637
+ }
5638
+ const parsed = parseExtensionInstallSource(githubOption, {
5639
+ forceGithub: true,
5640
+ ref
5641
+ });
5642
+ if (parsed.kind !== "github") {
5643
+ throw new PmCliError(`Invalid GitHub shorthand "${githubOption}".`, EXIT_CODE.USAGE);
5644
+ }
5645
+ return {
5646
+ kind: "github",
5647
+ input: parsed.input,
5648
+ location: parsed.subpath ?? ".",
5649
+ repository: parsed.repository,
5650
+ owner: parsed.owner,
5651
+ repo: parsed.repo,
5652
+ ref: parsed.ref,
5653
+ subpath: parsed.subpath
5654
+ };
5655
+ };
5656
+ var runExtensionAdoptAction = async (ctx) => {
5384
5657
  const { action, normalizedTarget, scope, resolvedRoots, warnings, options, withResult } = ctx;
5385
5658
  const extensionTarget = requireTarget(normalizedTarget, action, options);
5386
5659
  const githubOption = resolveGithubOption(options);
@@ -5403,32 +5676,10 @@ async function runExtensionAdoptAction(ctx) {
5403
5676
  }
5404
5677
  });
5405
5678
  }
5406
- const extensionDirectory = path6.join(resolvedRoots.selected_root, candidate.directory);
5679
+ const extensionDirectory = path8.join(resolvedRoots.selected_root, candidate.directory);
5407
5680
  const validated = await validateExtensionDirectory(extensionDirectory);
5408
5681
  const now = nowIso();
5409
- const sourceRecord = githubOption === void 0 ? {
5410
- kind: "local",
5411
- input: extensionTarget,
5412
- location: extensionDirectory
5413
- } : (() => {
5414
- const parsed = parseExtensionInstallSource(githubOption, {
5415
- forceGithub: true,
5416
- ref: options.ref
5417
- });
5418
- if (parsed.kind !== "github") {
5419
- throw new PmCliError(`Invalid GitHub shorthand "${githubOption}".`, EXIT_CODE.USAGE);
5420
- }
5421
- return {
5422
- kind: "github",
5423
- input: parsed.input,
5424
- location: parsed.subpath ?? ".",
5425
- repository: parsed.repository,
5426
- owner: parsed.owner,
5427
- repo: parsed.repo,
5428
- ref: parsed.ref,
5429
- subpath: parsed.subpath
5430
- };
5431
- })();
5682
+ const sourceRecord = buildAdoptedExtensionSource(githubOption, extensionTarget, extensionDirectory, options.ref);
5432
5683
  const managedState = upsertManagedEntry(managedStateRead.state, {
5433
5684
  name: validated.manifest.name,
5434
5685
  directory: candidate.directory,
@@ -5453,11 +5704,10 @@ async function runExtensionAdoptAction(ctx) {
5453
5704
  entry: validated.manifest.entry
5454
5705
  },
5455
5706
  source: sourceRecord,
5456
- update_check_status: refreshedEntry?.update_check_status ?? null,
5457
- update_check_reason: refreshedEntry?.update_check_reason ?? null
5707
+ ...projectExtensionUpdateCheck(refreshedEntry)
5458
5708
  });
5459
- }
5460
- async function resolveRequiredInstalledExtension(ctx) {
5709
+ };
5710
+ var resolveRequiredInstalledExtension = async (ctx) => {
5461
5711
  const { action, normalizedTarget, scope, resolvedRoots, warnings, options } = ctx;
5462
5712
  const extensionTarget = requireTarget(normalizedTarget, action, options);
5463
5713
  const settings = await readSettings(resolvedRoots.settings_root);
@@ -5470,12 +5720,12 @@ async function resolveRequiredInstalledExtension(ctx) {
5470
5720
  throw new PmCliError(`Installed extension "${extensionTarget}" was not found in ${scope} scope.`, EXIT_CODE.NOT_FOUND);
5471
5721
  }
5472
5722
  return { settings, managedStateRead, candidate };
5473
- }
5474
- async function runExtensionUninstallAction(ctx) {
5723
+ };
5724
+ var runExtensionUninstallAction = async (ctx) => {
5475
5725
  const { resolvedRoots, withResult } = ctx;
5476
5726
  const { settings, managedStateRead, candidate } = await resolveRequiredInstalledExtension(ctx);
5477
- const destinationDirectory = path6.join(resolvedRoots.selected_root, candidate.directory);
5478
- await fs6.rm(destinationDirectory, { recursive: true, force: true });
5727
+ const destinationDirectory = path8.join(resolvedRoots.selected_root, candidate.directory);
5728
+ await fs8.rm(destinationDirectory, { recursive: true, force: true });
5479
5729
  const updatedState = {
5480
5730
  ...managedStateRead.state,
5481
5731
  updated_at: nowIso(),
@@ -5497,8 +5747,8 @@ async function runExtensionUninstallAction(ctx) {
5497
5747
  destination_path: destinationDirectory,
5498
5748
  settings_changed: stateChanged
5499
5749
  });
5500
- }
5501
- async function runExtensionActivateDeactivateAction(ctx) {
5750
+ };
5751
+ var runExtensionActivateDeactivateAction = async (ctx) => {
5502
5752
  const { action, resolvedRoots, withResult } = ctx;
5503
5753
  const { settings, candidate } = await resolveRequiredInstalledExtension(ctx);
5504
5754
  const settingsChanged = action === "activate" ? ensureActivated(settings, candidate.name) : ensureDeactivated(settings, candidate.name);
@@ -5517,37 +5767,65 @@ async function runExtensionActivateDeactivateAction(ctx) {
5517
5767
  disabled: [...settings.extensions.disabled]
5518
5768
  }
5519
5769
  });
5520
- }
5521
- function buildDoctorRemediation(baseRemediation, loadFailureCount, activationFailureCount, vocabulary, managedStateFix, isolationHint) {
5770
+ };
5771
+ var buildDoctorRemediation = (baseRemediation, loadFailureCount, activationFailureCount, vocabulary, managedStateFix, isolationHint) => {
5772
+ const noun = vocabulary === "package" ? "package" : "extension";
5773
+ const doctorAction = { package: "doctor", extension: "--doctor" }[noun];
5774
+ const adoptedCount = managedStateFix?.adopted_entries.length ?? 0;
5775
+ const conditionalEntries = [
5776
+ [isolationHint !== null, isolationHint ?? ""],
5777
+ [
5778
+ loadFailureCount > 0,
5779
+ `Run pm ${noun} explore --project and pm ${noun} explore --global to inspect load failures.`
5780
+ ],
5781
+ [
5782
+ activationFailureCount > 0,
5783
+ `Review activation failures in pm ${noun} ${doctorAction} --detail deep output.`
5784
+ ],
5785
+ [
5786
+ adoptedCount > 0,
5787
+ `Managed-state fix adopted ${adoptedCount} extension(s).`
5788
+ ]
5789
+ ];
5522
5790
  return [
5523
5791
  ...new Set([
5524
5792
  ...baseRemediation,
5525
- ...isolationHint === null ? [] : [isolationHint],
5526
- /* c8 ignore start -- vocabulary-specific remediation branches are copy-only variants */
5527
- ...loadFailureCount > 0 ? [
5528
- 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."
5529
- ] : [],
5530
- ...activationFailureCount > 0 ? [
5531
- vocabulary === "package" ? "Review activation failures in pm package doctor --detail deep output." : "Review activation failures in pm extension --doctor --detail deep output."
5532
- ] : [],
5533
- /* c8 ignore stop */
5534
- ...managedStateFix && managedStateFix.adopted_entries.length > 0 ? [
5535
- `Managed-state fix adopted ${managedStateFix.adopted_entries.length} extension(s).`
5536
- ] : []
5793
+ ...conditionalEntries.filter(([include]) => include).map(([, entry]) => entry)
5537
5794
  ].map((entry) => entry.trim()).filter((entry) => entry.length > 0))
5538
5795
  ];
5539
- }
5540
- function hasGlobalLayerDiagnostics(loadResult) {
5796
+ };
5797
+ var hasGlobalLayerDiagnostics = (loadResult) => {
5541
5798
  return loadResult.loaded.some((entry) => entry.layer === "global") || loadResult.failed.some((entry) => entry.layer === "global") || loadResult.warnings.some((warning) => warning.includes(":global:"));
5542
- }
5543
- function buildDoctorIsolationHint(scope, isolated, vocabulary, loadResult) {
5799
+ };
5800
+ var buildDoctorIsolationHint = (scope, isolated, vocabulary, loadResult) => {
5544
5801
  if (scope !== "project" || isolated || !hasGlobalLayerDiagnostics(loadResult)) {
5545
5802
  return null;
5546
5803
  }
5547
5804
  const noun = vocabulary === "package" ? "package" : "extension";
5548
5805
  return `Global ${noun} registrations are included in project diagnostics. For hermetic ${noun} smoke tests, rerun pm ${noun} doctor --project --isolated --detail deep --trace, or set PM_GLOBAL_PATH to a temporary directory for the whole test process.`;
5549
- }
5550
- function buildDoctorIsolationMetadata(scope, isolated, vocabulary, loadResult) {
5806
+ };
5807
+ var resolveDoctorInvocationOptions = (target, scope, options) => {
5808
+ if (String(target ?? "").trim().length > 0) {
5809
+ throw new PmCliError('Action "doctor" does not accept a target argument.', EXIT_CODE.USAGE);
5810
+ }
5811
+ const isolated = [options.isolated, options.ignoreGlobal].includes(true);
5812
+ if ([isolated, scope === "global"].every(Boolean)) {
5813
+ throw new PmCliError("--isolated and --ignore-global are only valid with project-scope doctor diagnostics.", EXIT_CODE.USAGE);
5814
+ }
5815
+ const detailMode = parseDoctorDetailMode(options.detail);
5816
+ const includeTrace = options.trace === true;
5817
+ if ([includeTrace, detailMode !== "deep"].every(Boolean)) {
5818
+ throw new PmCliError("--trace requires --detail deep with --doctor.", EXIT_CODE.USAGE);
5819
+ }
5820
+ return { isolated, detailMode, includeTrace };
5821
+ };
5822
+ var applyDoctorManagedStateFix = async (ctx, installed, state) => {
5823
+ if (ctx.options.fixManagedState !== true)
5824
+ return { state, fix: null };
5825
+ const fix = await adoptUnmanagedExtensions(ctx.resolvedRoots.selected_root, ctx.scope, installed, state);
5826
+ return { state: fix.state, fix };
5827
+ };
5828
+ var buildDoctorIsolationMetadata = (scope, isolated, vocabulary, loadResult) => {
5551
5829
  const noun = vocabulary === "package" ? "package" : "extension";
5552
5830
  if (scope !== "project") {
5553
5831
  return {
@@ -5566,31 +5844,16 @@ function buildDoctorIsolationMetadata(scope, isolated, vocabulary, loadResult) {
5566
5844
  rerun_command: isolated ? null : isolatedCommand,
5567
5845
  pm_global_path_recipe: `PM_GLOBAL_PATH=$(mktemp -d) pm ${noun} doctor --project --detail deep --trace`
5568
5846
  };
5569
- }
5570
- async function runExtensionDoctorAction(ctx) {
5847
+ };
5848
+ var runExtensionDoctorAction = async (ctx) => {
5571
5849
  const { normalizedTarget, scope, resolvedRoots, warnings, options, global, withResult } = ctx;
5572
- if (normalizedTarget && normalizedTarget.trim().length > 0) {
5573
- throw new PmCliError('Action "doctor" does not accept a target argument.', EXIT_CODE.USAGE);
5574
- }
5575
- const isolated = options.isolated === true || options.ignoreGlobal === true;
5576
- if (isolated && scope === "global") {
5577
- throw new PmCliError("--isolated and --ignore-global are only valid with project-scope doctor diagnostics.", EXIT_CODE.USAGE);
5578
- }
5579
- const detailMode = parseDoctorDetailMode(options.detail);
5580
- const includeTrace = options.trace === true;
5581
- if (includeTrace && detailMode !== "deep") {
5582
- throw new PmCliError("--trace requires --detail deep with --doctor.", EXIT_CODE.USAGE);
5583
- }
5850
+ const { isolated, detailMode, includeTrace } = resolveDoctorInvocationOptions(normalizedTarget, scope, options);
5584
5851
  const settings = await readSettings(resolvedRoots.settings_root);
5585
5852
  const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
5586
5853
  warnings.push(...managedStateRead.warnings);
5587
5854
  const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
5588
5855
  warnings.push(...installed.warnings);
5589
- let managedState = managedStateRead.state;
5590
- const managedStateFix = options.fixManagedState === true ? await adoptUnmanagedExtensions(resolvedRoots.selected_root, scope, installed.extensions, managedStateRead.state) : null;
5591
- if (managedStateFix) {
5592
- managedState = managedStateFix.state;
5593
- }
5856
+ const { state: managedState, fix: managedStateFix } = await applyDoctorManagedStateFix(ctx, installed.extensions, managedStateRead.state);
5594
5857
  const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
5595
5858
  warnings.push(...refreshedInstalled.warnings);
5596
5859
  const loadResult = await loadExtensions({
@@ -5759,21 +6022,21 @@ async function runExtensionDoctorAction(ctx) {
5759
6022
  name: entry.name,
5760
6023
  entry_path: entry.entry_path,
5761
6024
  error: entry.error,
5762
- method: entry.trace?.method,
5763
- command: entry.trace?.command,
5764
- capability: entry.trace?.capability,
5765
- missing_capability: entry.trace?.missing_capability,
5766
- registration_index: entry.trace?.registration_index,
5767
- expected_schema: entry.trace?.expected_schema,
5768
- hint: entry.trace?.hint,
5769
- received: entry.trace?.received
6025
+ method: entry.trace.method,
6026
+ command: entry.trace.command,
6027
+ capability: entry.trace.capability,
6028
+ missing_capability: entry.trace.missing_capability,
6029
+ registration_index: entry.trace.registration_index,
6030
+ expected_schema: entry.trace.expected_schema,
6031
+ hint: entry.trace.hint,
6032
+ received: entry.trace.received
5770
6033
  }))
5771
6034
  };
5772
6035
  }
5773
6036
  }
5774
6037
  return withResult(details);
5775
- }
5776
- async function runExtensionDescribeAction(ctx) {
6038
+ };
6039
+ var runExtensionDescribeAction = async (ctx) => {
5777
6040
  const { normalizedTarget, scope, resolvedRoots, warnings, options, global, withResult } = ctx;
5778
6041
  const settings = await readSettings(resolvedRoots.settings_root);
5779
6042
  const loadResult = await loadExtensions({
@@ -5800,25 +6063,18 @@ async function runExtensionDescribeAction(ctx) {
5800
6063
  extensions: describeResult.extensions,
5801
6064
  union: describeResult.union
5802
6065
  });
5803
- }
5804
- async function runExtensionExploreManageAction(ctx) {
5805
- const { action, scope, resolvedRoots, warnings, options, global, withResult } = ctx;
5806
- const settings = await readSettings(resolvedRoots.settings_root);
5807
- const configuredPolicy = buildExtensionPolicyDetails(settings.extensions.policy);
5808
- const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
5809
- warnings.push(...managedStateRead.warnings);
5810
- const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
5811
- warnings.push(...installed.warnings);
5812
- let managedState = managedStateRead.state;
5813
- const managedStateFix = action === "manage" && options.fixManagedState === true ? await adoptUnmanagedExtensions(resolvedRoots.selected_root, scope, installed.extensions, managedStateRead.state) : null;
5814
- if (managedStateFix) {
5815
- managedState = managedStateFix.state;
5816
- }
5817
- if (action === "manage") {
5818
- const updates = await Promise.all(managedState.entries.map(async (entry) => {
5819
- if (entry.source.kind !== "github") {
6066
+ };
6067
+ var prepareExploreManageState = async (ctx, installed, initialState) => {
6068
+ let state = initialState;
6069
+ let fix = null;
6070
+ if ([ctx.action === "manage", ctx.options.fixManagedState === true].every(Boolean)) {
6071
+ fix = await adoptUnmanagedExtensions(ctx.resolvedRoots.selected_root, ctx.scope, installed, initialState);
6072
+ state = fix.state;
6073
+ }
6074
+ if (ctx.action === "manage") {
6075
+ const entries = await mapWithFixedConcurrency(state.entries, GITHUB_UPDATE_CHECK_CONCURRENCY, async (entry) => {
6076
+ if (entry.source.kind !== "github")
5820
6077
  return entry;
5821
- }
5822
6078
  const updateStatus = await checkGithubUpdate(entry.source);
5823
6079
  return {
5824
6080
  ...entry,
@@ -5827,55 +6083,85 @@ async function runExtensionExploreManageAction(ctx) {
5827
6083
  update_available: updateStatus.available,
5828
6084
  update_error: updateStatus.error
5829
6085
  };
5830
- }));
5831
- managedState = {
5832
- ...managedState,
6086
+ });
6087
+ state = {
6088
+ ...state,
5833
6089
  updated_at: nowIso(),
5834
- entries: sortManagedEntries(updates)
6090
+ entries: sortManagedEntries(entries)
5835
6091
  };
5836
- await writeManagedExtensionState(resolvedRoots.selected_root, managedState);
6092
+ await writeManagedExtensionState(ctx.resolvedRoots.selected_root, state);
5837
6093
  }
5838
- const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
5839
- warnings.push(...refreshedInstalled.warnings);
5840
- if (action === "manage") {
5841
- const updateWarnings = refreshedInstalled.extensions.filter((entry) => entry.update_check_status === "failed").map((entry) => `extension_update_check_failed:${entry.name}`);
5842
- warnings.push(...updateWarnings);
6094
+ return { state, fix };
6095
+ };
6096
+ var probeExploreManageRuntime = async (ctx, settings, installed) => {
6097
+ const requested = [
6098
+ ctx.action === "explore",
6099
+ ctx.options.runtimeProbe === true
6100
+ ].includes(true);
6101
+ if (!requested) {
6102
+ return {
6103
+ installed,
6104
+ failures: void 0,
6105
+ summary: { requested: false, executed: false }
6106
+ };
5843
6107
  }
5844
- let runtimeProbeSummary;
5845
- let runtimeInstalledExtensions = refreshedInstalled.extensions;
5846
- let runtimeActivationFailures;
5847
- if (action === "explore" || options.runtimeProbe === true) {
5848
- const loadResult = await loadExtensions({
5849
- pmRoot: resolvedRoots.pm_root,
5850
- settings,
5851
- cwd: process.cwd(),
5852
- noExtensions: global.noExtensions === true
5853
- });
5854
- const activationResult = await activateExtensions({
5855
- ...loadResult,
5856
- loaded: loadResult.loaded
5857
- });
5858
- warnings.push(...loadResult.warnings);
5859
- warnings.push(...activationResult.warnings);
5860
- runtimeInstalledExtensions = applyDoctorRuntimeActivationState(refreshedInstalled.extensions, loadResult, activationResult);
5861
- runtimeActivationFailures = collectActivationFailureDiagnostics(activationResult.failed);
5862
- runtimeProbeSummary = {
6108
+ const loadResult = await loadExtensions({
6109
+ pmRoot: ctx.resolvedRoots.pm_root,
6110
+ settings,
6111
+ cwd: process.cwd(),
6112
+ noExtensions: ctx.global.noExtensions === true
6113
+ });
6114
+ const activationResult = await activateExtensions({
6115
+ ...loadResult,
6116
+ loaded: loadResult.loaded
6117
+ });
6118
+ ctx.warnings.push(...loadResult.warnings, ...activationResult.warnings);
6119
+ return {
6120
+ installed: applyDoctorRuntimeActivationState(installed, loadResult, activationResult),
6121
+ failures: collectActivationFailureDiagnostics(activationResult.failed),
6122
+ summary: {
5863
6123
  requested: true,
5864
6124
  executed: true,
5865
- reason: action === "explore" ? "explore_defaults_to_runtime_probe" : "runtime_probe_requested",
6125
+ reason: ctx.action === "explore" ? "explore_defaults_to_runtime_probe" : "runtime_probe_requested",
5866
6126
  load_failure_count: loadResult.failed.length,
5867
6127
  activation_failure_count: activationResult.failed.length,
5868
6128
  warning_count: [
5869
6129
  .../* @__PURE__ */ new Set([...loadResult.warnings, ...activationResult.warnings])
5870
6130
  ].length,
5871
6131
  policy: loadResult.policy
5872
- };
5873
- } else if (action === "manage") {
5874
- runtimeProbeSummary = {
5875
- requested: false,
5876
- executed: false
5877
- };
6132
+ }
6133
+ };
6134
+ };
6135
+ var projectExploreManageFix = (fix, installed) => fix ? {
6136
+ requested: true,
6137
+ applied: fix.adopted_entries.length > 0,
6138
+ adopted_count: fix.adopted_entries.length,
6139
+ adopted_extensions: fix.adopted_entries.map((entry) => entry.name),
6140
+ already_managed_count: fix.already_managed_count
6141
+ } : {
6142
+ requested: false,
6143
+ applied: false,
6144
+ adopted_count: 0,
6145
+ adopted_extensions: [],
6146
+ already_managed_count: installed.filter((entry) => entry.managed).length
6147
+ };
6148
+ var runExtensionExploreManageAction = async (ctx) => {
6149
+ const { action, scope, resolvedRoots, warnings, options, withResult } = ctx;
6150
+ const settings = await readSettings(resolvedRoots.settings_root);
6151
+ const configuredPolicy = buildExtensionPolicyDetails(settings.extensions.policy);
6152
+ const managedStateRead = await readManagedExtensionState(resolvedRoots.selected_root);
6153
+ warnings.push(...managedStateRead.warnings);
6154
+ const installed = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedStateRead.state);
6155
+ warnings.push(...installed.warnings);
6156
+ const { state: managedState, fix: managedStateFix } = await prepareExploreManageState(ctx, installed.extensions, managedStateRead.state);
6157
+ const refreshedInstalled = await listInstalledExtensions(resolvedRoots.selected_root, scope, settings, managedState);
6158
+ warnings.push(...refreshedInstalled.warnings);
6159
+ if (action === "manage") {
6160
+ const updateWarnings = refreshedInstalled.extensions.filter((entry) => entry.update_check_status === "failed").map((entry) => `extension_update_check_failed:${entry.name}`);
6161
+ warnings.push(...updateWarnings);
5878
6162
  }
6163
+ const runtimeProbe = await probeExploreManageRuntime(ctx, settings, refreshedInstalled.extensions);
6164
+ const runtimeInstalledExtensions = runtimeProbe.installed;
5879
6165
  const triage = buildExtensionTriageSummary(scope, warnings, runtimeInstalledExtensions, options);
5880
6166
  warnings.push(...triage.warnings);
5881
6167
  const details = {
@@ -5887,33 +6173,21 @@ async function runExtensionExploreManageAction(ctx) {
5887
6173
  triage,
5888
6174
  policy: configuredPolicy
5889
6175
  };
5890
- if (runtimeActivationFailures !== void 0) {
6176
+ if (runtimeProbe.failures !== void 0) {
5891
6177
  details.activation_diagnostics = {
5892
- failed_count: runtimeActivationFailures.length,
5893
- failed: runtimeActivationFailures
6178
+ failed_count: runtimeProbe.failures.length,
6179
+ failed: runtimeProbe.failures
5894
6180
  };
5895
6181
  }
5896
6182
  if (action === "explore") {
5897
- details.runtime_probe = runtimeProbeSummary;
6183
+ details.runtime_probe = runtimeProbe.summary;
5898
6184
  }
5899
6185
  if (action === "manage") {
5900
- details.runtime_probe = runtimeProbeSummary;
5901
- details.managed_state_fix = managedStateFix !== null ? {
5902
- requested: true,
5903
- applied: managedStateFix.adopted_entries.length > 0,
5904
- adopted_count: managedStateFix.adopted_entries.length,
5905
- adopted_extensions: managedStateFix.adopted_entries.map((entry) => entry.name),
5906
- already_managed_count: managedStateFix.already_managed_count
5907
- } : {
5908
- requested: false,
5909
- applied: false,
5910
- adopted_count: 0,
5911
- adopted_extensions: [],
5912
- already_managed_count: runtimeInstalledExtensions.filter((entry) => entry.managed).length
5913
- };
6186
+ details.runtime_probe = runtimeProbe.summary;
6187
+ details.managed_state_fix = projectExploreManageFix(managedStateFix, runtimeInstalledExtensions);
5914
6188
  }
5915
6189
  return withResult(details);
5916
- }
6190
+ };
5917
6191
  var EXTENSION_ACTION_HANDLERS = {
5918
6192
  init: runExtensionInitAction,
5919
6193
  install: runExtensionInstallAction,
@@ -5929,10 +6203,20 @@ var EXTENSION_ACTION_HANDLERS = {
5929
6203
  activate: runExtensionActivateDeactivateAction,
5930
6204
  deactivate: runExtensionActivateDeactivateAction
5931
6205
  };
6206
+ var requiresExtensionStateLock = (ctx) => [
6207
+ ctx.action === "uninstall",
6208
+ ctx.action === "manage",
6209
+ ctx.action === "adopt",
6210
+ ctx.action === "adopt-all",
6211
+ ctx.action === "activate",
6212
+ ctx.action === "deactivate",
6213
+ [ctx.action === "doctor", ctx.options.fixManagedState === true].every(Boolean)
6214
+ ].some(Boolean);
6215
+ var dispatchExtensionAction = (ctx) => requiresExtensionStateLock(ctx) ? withExtensionInstallLock(ctx.resolvedRoots.settings_root, `${ctx.action}-state`, () => EXTENSION_ACTION_HANDLERS[ctx.action](ctx)) : EXTENSION_ACTION_HANDLERS[ctx.action](ctx);
5932
6216
 
5933
6217
  // dist/sdk/workspace.js
5934
6218
  import { readFile, writeFile } from "node:fs/promises";
5935
- import path7 from "node:path";
6219
+ import path9 from "node:path";
5936
6220
  var PM_GITIGNORE_START = "# pm-cli:runtime-cache:start";
5937
6221
  var PM_GITIGNORE_END = "# pm-cli:runtime-cache:end";
5938
6222
  var PM_GITIGNORE_BLOCK = [
@@ -5946,7 +6230,7 @@ function getPmGitignoreBlock() {
5946
6230
  return PM_GITIGNORE_BLOCK;
5947
6231
  }
5948
6232
  async function ensurePmGitignore(workspaceRoot) {
5949
- const gitignorePath = path7.join(workspaceRoot, ".gitignore");
6233
+ const gitignorePath = path9.join(workspaceRoot, ".gitignore");
5950
6234
  let current = "";
5951
6235
  try {
5952
6236
  current = await readFile(gitignorePath, "utf8");
@@ -5970,15 +6254,9 @@ async function ensurePmGitignore(workspaceRoot) {
5970
6254
  return { path: gitignorePath, changed: true };
5971
6255
  }
5972
6256
 
5973
- // dist/cli/commands/init.js
5974
- import fs8 from "node:fs/promises";
5975
- import path9 from "node:path";
5976
- import readline2 from "node:readline/promises";
5977
- import { stdin as input2, stdout as output2 } from "node:process";
5978
-
5979
- // dist/cli/commands/init-agent-guidance.js
5980
- import fs7 from "node:fs/promises";
5981
- import path8 from "node:path";
6257
+ // dist/sdk/init-agent-guidance.js
6258
+ import fs9 from "node:fs/promises";
6259
+ import path10 from "node:path";
5982
6260
  import readline from "node:readline/promises";
5983
6261
  import { stdin as input, stdout as output } from "node:process";
5984
6262
  var INIT_AGENT_GUIDANCE_MODE_VALUES = [
@@ -6007,13 +6285,33 @@ var AGENT_GUIDANCE_START_MARKER_PREFIX = "<!-- pm-cli:agent-guidance:start:";
6007
6285
  var AGENT_GUIDANCE_START_MARKER = `<!-- pm-cli:agent-guidance:start:v${AGENT_GUIDANCE_TEMPLATE_VERSION} -->`;
6008
6286
  var AGENT_GUIDANCE_END_MARKER = "<!-- pm-cli:agent-guidance:end -->";
6009
6287
  var AGENT_GUIDANCE_ADD_LATER_HINT = "Add workflow guidance later: pm init --agent-guidance add";
6288
+ var _testOnly = {
6289
+ toPortableRelativePath,
6290
+ ensureTrailingNewline,
6291
+ detectLineEnding,
6292
+ findGuidanceBlockRange,
6293
+ buildAgentGuidanceBlock,
6294
+ upsertAgentGuidanceBlock,
6295
+ resolveProjectRoot,
6296
+ resolveTargetGuidancePath,
6297
+ parsePromptChoice,
6298
+ pushUnique,
6299
+ promptForGuidanceWrite,
6300
+ normalizeAgentGuidanceState,
6301
+ applyAgentGuidanceState,
6302
+ writeGuidanceFile,
6303
+ setAgentGuidanceReadlineFactoryForTests
6304
+ };
6010
6305
  var createAgentGuidanceReadlineInterface = () => readline.createInterface({ input, output });
6306
+ function setAgentGuidanceReadlineFactoryForTests(factory) {
6307
+ createAgentGuidanceReadlineInterface = factory ?? (() => readline.createInterface({ input, output }));
6308
+ }
6011
6309
  function toPortableRelativePath(projectRoot, targetPath) {
6012
- const relative = path8.relative(projectRoot, targetPath);
6310
+ const relative = path10.relative(projectRoot, targetPath);
6013
6311
  if (relative.length === 0) {
6014
- return path8.basename(targetPath);
6312
+ return path10.basename(targetPath);
6015
6313
  }
6016
- return relative.split(path8.sep).join("/");
6314
+ return relative.split(path10.sep).join("/");
6017
6315
  }
6018
6316
  function ensureTrailingNewline(value) {
6019
6317
  return value.endsWith("\n") ? value : `${value}
@@ -6076,14 +6374,14 @@ function upsertAgentGuidanceBlock(existingContent) {
6076
6374
  };
6077
6375
  }
6078
6376
  function resolveProjectRoot(pmRoot, cwd) {
6079
- const parent = path8.dirname(pmRoot);
6080
- if (path8.basename(pmRoot) === "pm" && path8.basename(parent) === ".agents") {
6081
- return path8.dirname(parent);
6377
+ const parent = path10.dirname(pmRoot);
6378
+ if (path10.basename(pmRoot) === "pm" && path10.basename(parent) === ".agents") {
6379
+ return path10.dirname(parent);
6082
6380
  }
6083
- return path8.resolve(cwd, pmRoot);
6381
+ return path10.resolve(cwd, pmRoot);
6084
6382
  }
6085
6383
  function resolveTargetGuidancePath(scans, projectRoot) {
6086
- const existingAgents = scans.find((entry) => path8.basename(entry.file_path) === "AGENTS.md" && entry.exists);
6384
+ const existingAgents = scans.find((entry) => path10.basename(entry.file_path) === "AGENTS.md" && entry.exists);
6087
6385
  if (existingAgents) {
6088
6386
  return existingAgents.file_path;
6089
6387
  }
@@ -6091,7 +6389,7 @@ function resolveTargetGuidancePath(scans, projectRoot) {
6091
6389
  if (existingAny) {
6092
6390
  return existingAny.file_path;
6093
6391
  }
6094
- return path8.join(projectRoot, "AGENTS.md");
6392
+ return path10.join(projectRoot, "AGENTS.md");
6095
6393
  }
6096
6394
  function parsePromptChoice(answer, currentDefault) {
6097
6395
  const normalized = answer.trim().toLowerCase();
@@ -6133,7 +6431,7 @@ function normalizeAgentGuidanceState(settings) {
6133
6431
  async function scanGuidanceFiles(projectRoot) {
6134
6432
  const scans = [];
6135
6433
  for (const filename of AGENT_GUIDANCE_TARGET_FILENAMES) {
6136
- const filePath = path8.join(projectRoot, filename);
6434
+ const filePath = path10.join(projectRoot, filename);
6137
6435
  const exists = await pathExists(filePath);
6138
6436
  if (!exists) {
6139
6437
  scans.push({
@@ -6144,7 +6442,7 @@ async function scanGuidanceFiles(projectRoot) {
6144
6442
  });
6145
6443
  continue;
6146
6444
  }
6147
- const content = await fs7.readFile(filePath, "utf8");
6445
+ const content = await fs9.readFile(filePath, "utf8");
6148
6446
  const contentLower = content.toLowerCase();
6149
6447
  const tokenHits = AGENT_GUIDANCE_REQUIRED_TOKENS.filter((token) => contentLower.includes(token));
6150
6448
  const hasMarker = hasGuidanceMarker(content);
@@ -6172,12 +6470,12 @@ function applyAgentGuidanceState(settings, currentState) {
6172
6470
  }
6173
6471
  async function writeGuidanceFile(filePath) {
6174
6472
  const exists = await pathExists(filePath);
6175
- const currentContent = exists ? await fs7.readFile(filePath, "utf8") : "";
6473
+ const currentContent = exists ? await fs9.readFile(filePath, "utf8") : "";
6176
6474
  const nextContent = upsertAgentGuidanceBlock(currentContent);
6177
6475
  if (!nextContent.changed) {
6178
6476
  return { changed: false, warnings: [] };
6179
6477
  }
6180
- await fs7.writeFile(filePath, nextContent.next_content, "utf8");
6478
+ await writeFileAtomic(filePath, nextContent.next_content);
6181
6479
  return {
6182
6480
  changed: true,
6183
6481
  warnings: await runActiveOnWriteHooks({
@@ -6359,7 +6657,12 @@ async function runInitAgentGuidance(options) {
6359
6657
  };
6360
6658
  }
6361
6659
 
6362
- // dist/cli/commands/init.js
6660
+ // dist/sdk/init.js
6661
+ import fs10 from "node:fs/promises";
6662
+ import path11 from "node:path";
6663
+ import readline2 from "node:readline/promises";
6664
+ import { stdin as input2, stdout as output2 } from "node:process";
6665
+ import { hostname, userInfo } from "node:os";
6363
6666
  function summarizeInitResult(result) {
6364
6667
  return {
6365
6668
  ok: result.ok,
@@ -6383,7 +6686,28 @@ function summarizeInitResult(result) {
6383
6686
  hint: "Re-run with --verbose for the full settings tree."
6384
6687
  };
6385
6688
  }
6689
+ var _testOnly2 = {
6690
+ normalizeInitGovernancePreset,
6691
+ normalizeInitTypePreset,
6692
+ normalizeOptionalInitAuthor,
6693
+ normalizeInitAgentGuidanceMode,
6694
+ isPathLikeInitTarget,
6695
+ resolveInitInvocation,
6696
+ resolveInitPrefixInput,
6697
+ parseYesNoChoice,
6698
+ applyGovernancePreset,
6699
+ runInitWizard,
6700
+ setInitReadlineFactoryForTests,
6701
+ summarizeInstalledPackages,
6702
+ buildInitNextSteps,
6703
+ registerInitTypePreset,
6704
+ assertExplicitTrackerPathIsNotWorkspaceRoot,
6705
+ isLikelyWorkspaceRoot
6706
+ };
6386
6707
  var createInitReadlineInterface = () => readline2.createInterface({ input: input2, output: output2 });
6708
+ function setInitReadlineFactoryForTests(factory) {
6709
+ createInitReadlineInterface = factory ?? (() => readline2.createInterface({ input: input2, output: output2 }));
6710
+ }
6387
6711
  function cloneDefaults() {
6388
6712
  return structuredClone(SETTINGS_DEFAULTS);
6389
6713
  }
@@ -6439,7 +6763,7 @@ function isPathLikeInitTarget(rawValue) {
6439
6763
  if (trimmed.length === 0) {
6440
6764
  return false;
6441
6765
  }
6442
- return path9.isAbsolute(trimmed) || trimmed.startsWith(".") || trimmed.includes("/") || trimmed.includes("\\");
6766
+ return path11.isAbsolute(trimmed) || /^[a-z]:/iu.test(trimmed) || trimmed.startsWith(".") || trimmed.includes("/") || trimmed.includes("\\");
6443
6767
  }
6444
6768
  function resolveInitInvocation(cwd, global, prefixArg, workspaceArg) {
6445
6769
  const normalizedWorkspace = workspaceArg?.trim();
@@ -6450,8 +6774,8 @@ function resolveInitInvocation(cwd, global, prefixArg, workspaceArg) {
6450
6774
  if (global.path !== void 0 || isPathLikeInitTarget(prefixArg)) {
6451
6775
  throw new PmCliError("--workspace cannot be combined with --pm-path/--path or a path-like positional target.", EXIT_CODE.USAGE);
6452
6776
  }
6453
- const workspaceRoot = path9.resolve(cwd, normalizedWorkspace);
6454
- const pmRoot2 = path9.join(workspaceRoot, ".agents", "pm");
6777
+ const workspaceRoot = path11.resolve(cwd, normalizedWorkspace);
6778
+ const pmRoot2 = path11.join(workspaceRoot, ".agents", "pm");
6455
6779
  return {
6456
6780
  pmRoot: pmRoot2,
6457
6781
  prefixArg,
@@ -6463,7 +6787,7 @@ function resolveInitInvocation(cwd, global, prefixArg, workspaceArg) {
6463
6787
  };
6464
6788
  }
6465
6789
  if (global.path === void 0 && isPathLikeInitTarget(prefixArg)) {
6466
- const positionalTarget = path9.resolve(cwd, prefixArg.trim());
6790
+ const positionalTarget = path11.resolve(cwd, prefixArg.trim());
6467
6791
  return {
6468
6792
  pmRoot: positionalTarget,
6469
6793
  prefixArg: void 0,
@@ -6481,6 +6805,35 @@ function resolveInitInvocation(cwd, global, prefixArg, workspaceArg) {
6481
6805
  } : { mode: "tracker-path", tracker_root: pmRoot }
6482
6806
  };
6483
6807
  }
6808
+ function resolveInitPrefixInput(positionalPrefix, flaggedPrefix) {
6809
+ if (flaggedPrefix === void 0) {
6810
+ return positionalPrefix;
6811
+ }
6812
+ if (flaggedPrefix.trim().length === 0) {
6813
+ throw new PmCliError("--id-prefix must not be empty", EXIT_CODE.USAGE);
6814
+ }
6815
+ if (isPathLikeInitTarget(flaggedPrefix)) {
6816
+ throw new PmCliError(`--id-prefix accepts an item ID prefix, not a tracker path: "${flaggedPrefix}".`, EXIT_CODE.USAGE, {
6817
+ code: "init_id_prefix_path_like",
6818
+ required: "Pass the tracker path positionally or with the global --path option.",
6819
+ examples: [
6820
+ `pm init ${flaggedPrefix}`,
6821
+ `pm --path ${flaggedPrefix} init`
6822
+ ]
6823
+ });
6824
+ }
6825
+ if (positionalPrefix !== void 0 && normalizePrefix(positionalPrefix) !== normalizePrefix(flaggedPrefix)) {
6826
+ throw new PmCliError(`Conflicting id prefixes: positional "${positionalPrefix}" and --id-prefix "${flaggedPrefix}".`, EXIT_CODE.USAGE, {
6827
+ code: "init_id_prefix_conflict",
6828
+ required: "Use either the positional id prefix or --id-prefix with one value.",
6829
+ examples: [
6830
+ `pm init ${normalizePrefix(positionalPrefix)}`,
6831
+ `pm init --id-prefix ${normalizePrefix(flaggedPrefix)}`
6832
+ ]
6833
+ });
6834
+ }
6835
+ return flaggedPrefix;
6836
+ }
6484
6837
  function normalizeInitAgentGuidanceMode(rawValue) {
6485
6838
  if (rawValue === void 0) {
6486
6839
  return "ask";
@@ -6556,10 +6909,10 @@ async function isLikelyWorkspaceRoot(candidate) {
6556
6909
  "package.json",
6557
6910
  "pnpm-workspace.yaml",
6558
6911
  "AGENTS.md",
6559
- path9.join(".agents", "pm")
6912
+ path11.join(".agents", "pm")
6560
6913
  ];
6561
6914
  for (const indicator of indicators) {
6562
- if (await pathExists(path9.join(candidate, indicator))) {
6915
+ if (await pathExists(path11.join(candidate, indicator))) {
6563
6916
  return true;
6564
6917
  }
6565
6918
  }
@@ -6569,13 +6922,13 @@ async function assertExplicitTrackerPathIsNotWorkspaceRoot(pmRoot, explicitTrack
6569
6922
  if (!explicitTrackerTarget || force) {
6570
6923
  return;
6571
6924
  }
6572
- if (await pathExists(path9.join(pmRoot, "settings.json"))) {
6925
+ if (await pathExists(path11.join(pmRoot, "settings.json"))) {
6573
6926
  return;
6574
6927
  }
6575
6928
  if (!await isLikelyWorkspaceRoot(pmRoot)) {
6576
6929
  return;
6577
6930
  }
6578
- const nestedTracker = path9.join(pmRoot, ".agents", "pm");
6931
+ const nestedTracker = path11.join(pmRoot, ".agents", "pm");
6579
6932
  throw new PmCliError(`Refusing to initialize tracker files directly in workspace root "${pmRoot}".`, EXIT_CODE.USAGE, {
6580
6933
  code: "workspace_root_pm_path",
6581
6934
  type: "urn:pm-cli:error:workspace_root_pm_path",
@@ -6599,9 +6952,9 @@ async function ensureInitDirectories(pmRoot, subdirs) {
6599
6952
  const createdDirs = [];
6600
6953
  const warnings = [];
6601
6954
  for (const subdir of subdirs) {
6602
- const target = subdir ? path9.join(pmRoot, subdir) : pmRoot;
6955
+ const target = subdir ? path11.join(pmRoot, subdir) : pmRoot;
6603
6956
  const existed = await pathExists(target);
6604
- await fs8.mkdir(target, { recursive: true });
6957
+ await fs10.mkdir(target, { recursive: true });
6605
6958
  if (existed) {
6606
6959
  warnings.push(`already_exists:${target}`);
6607
6960
  } else {
@@ -6758,9 +7111,8 @@ async function createNewInitSettings(params) {
6758
7111
  const settings = cloneDefaults();
6759
7112
  settings.id_prefix = normalizedPrefix;
6760
7113
  applyGovernancePreset(settings, effectivePreset);
6761
- if (params.normalizedOptions.authorFromOption !== void 0) {
6762
- settings.author_default = params.normalizedOptions.authorFromOption;
6763
- }
7114
+ const environmentAuthor = process.env.PM_AUTHOR?.trim() || void 0;
7115
+ settings.author_default = params.normalizedOptions.authorFromOption ?? environmentAuthor ?? `${userInfo().username}@${hostname()}`;
6764
7116
  if (chosenTelemetryEnabled !== void 0) {
6765
7117
  settings.telemetry.enabled = chosenTelemetryEnabled;
6766
7118
  settings.telemetry.first_run_prompt_completed = true;
@@ -6835,10 +7187,10 @@ async function ensureInitTypeDirectories(params) {
6835
7187
  params.warnings.push(...scaffold.warnings);
6836
7188
  }
6837
7189
  function resolveInitWorkspaceRoot(target) {
6838
- const trackerRoot = path9.resolve(target.tracker_root);
6839
- const agentsRoot = path9.dirname(trackerRoot);
6840
- if (path9.basename(trackerRoot) === "pm" && path9.basename(agentsRoot) === ".agents") {
6841
- return path9.dirname(agentsRoot);
7190
+ const trackerRoot = path11.resolve(target.tracker_root);
7191
+ const agentsRoot = path11.dirname(trackerRoot);
7192
+ if (path11.basename(trackerRoot) === "pm" && path11.basename(agentsRoot) === ".agents") {
7193
+ return path11.dirname(agentsRoot);
6842
7194
  }
6843
7195
  return target.workspace_root;
6844
7196
  }
@@ -6887,16 +7239,16 @@ async function runInit(prefixArg, global, options = {}) {
6887
7239
  const cwd = process.cwd();
6888
7240
  const invocation = resolveInitInvocation(cwd, global, prefixArg, options.workspace);
6889
7241
  const pmRoot = invocation.pmRoot;
6890
- prefixArg = invocation.prefixArg;
7242
+ prefixArg = resolveInitPrefixInput(invocation.prefixArg, options.idPrefix);
7243
+ const normalizedOptions = normalizeInitCommandOptions(options);
6891
7244
  await assertExplicitTrackerPathIsNotWorkspaceRoot(pmRoot, invocation.target.mode === "tracker-path", options.force === true);
6892
7245
  const createdDirs = [];
6893
7246
  const warnings = [];
6894
7247
  const baseDirs = await ensureInitDirectories(pmRoot, PM_REQUIRED_SUBDIRS);
6895
7248
  createdDirs.push(...baseDirs.createdDirs);
6896
7249
  warnings.push(...baseDirs.warnings);
6897
- const settingsPath = path9.join(pmRoot, "settings.json");
7250
+ const settingsPath = path11.join(pmRoot, "settings.json");
6898
7251
  const settingsExists = await pathExists(settingsPath);
6899
- const normalizedOptions = normalizeInitCommandOptions(options);
6900
7252
  const settingsResolution = await resolveInitSettings({
6901
7253
  pmRoot,
6902
7254
  settingsPath,
@@ -6908,9 +7260,10 @@ async function runInit(prefixArg, global, options = {}) {
6908
7260
  warnings
6909
7261
  });
6910
7262
  let { settings } = settingsResolution;
7263
+ const workspaceRoot = resolveInitWorkspaceRoot(invocation.target);
6911
7264
  const agentGuidance = await applyInitAgentGuidance({
6912
7265
  pmRoot,
6913
- cwd,
7266
+ cwd: workspaceRoot ?? cwd,
6914
7267
  agentGuidanceMode: normalizedOptions.agentGuidanceMode,
6915
7268
  settings,
6916
7269
  warnings
@@ -6928,7 +7281,6 @@ async function runInit(prefixArg, global, options = {}) {
6928
7281
  settings = await readSettings(pmRoot);
6929
7282
  }
6930
7283
  await ensureInitTypeDirectories({ pmRoot, settings, createdDirs, warnings });
6931
- const workspaceRoot = resolveInitWorkspaceRoot(invocation.target);
6932
7284
  if (workspaceRoot) {
6933
7285
  const gitignore = await ensurePmGitignore(workspaceRoot);
6934
7286
  if (gitignore.changed) {
@@ -6974,9 +7326,13 @@ export {
6974
7326
  PM_GITIGNORE_END,
6975
7327
  getPmGitignoreBlock,
6976
7328
  ensurePmGitignore,
7329
+ INIT_AGENT_GUIDANCE_MODE_VALUES,
7330
+ _testOnly,
7331
+ runInitAgentGuidance,
6977
7332
  summarizeInitResult,
7333
+ _testOnly2,
6978
7334
  runInit
6979
7335
  };
6980
- //# sourceMappingURL=chunk-DVOLZJ3C.js.map
7336
+ //# sourceMappingURL=chunk-J6EY5V4N.js.map
6981
7337
 
6982
- //# debugId=6800d243-3c57-59f4-8e55-c1613574d53e
7338
+ //# debugId=f34a834c-7c67-555c-a8b0-6c26e7d8c12a