@unbrained/pm-cli 2026.5.31 → 2026.6.6

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 (638) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/CONTRIBUTING.md +1 -0
  3. package/README.md +12 -4
  4. package/dist/cli/argv-utils.js +7 -3
  5. package/dist/cli/argv-utils.js.map +1 -1
  6. package/dist/cli/bootstrap-args.d.ts +1 -0
  7. package/dist/cli/bootstrap-args.js +23 -3
  8. package/dist/cli/bootstrap-args.js.map +1 -1
  9. package/dist/cli/commands/calendar.js +17 -3
  10. package/dist/cli/commands/calendar.js.map +1 -1
  11. package/dist/cli/commands/close-many.d.ts +63 -0
  12. package/dist/cli/commands/close-many.js +302 -0
  13. package/dist/cli/commands/close-many.js.map +1 -0
  14. package/dist/cli/commands/completion.d.ts +1 -0
  15. package/dist/cli/commands/completion.js +260 -32
  16. package/dist/cli/commands/completion.js.map +1 -1
  17. package/dist/cli/commands/config.d.ts +4 -4
  18. package/dist/cli/commands/config.js +115 -3
  19. package/dist/cli/commands/config.js.map +1 -1
  20. package/dist/cli/commands/contracts.js +193 -162
  21. package/dist/cli/commands/contracts.js.map +1 -1
  22. package/dist/cli/commands/create.d.ts +1 -0
  23. package/dist/cli/commands/create.js +77 -114
  24. package/dist/cli/commands/create.js.map +1 -1
  25. package/dist/cli/commands/extension/doctor.d.ts +12 -0
  26. package/dist/cli/commands/extension/doctor.js +97 -2
  27. package/dist/cli/commands/extension/doctor.js.map +1 -1
  28. package/dist/cli/commands/extension/scaffold.js +49 -48
  29. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  30. package/dist/cli/commands/extension.js +51 -23
  31. package/dist/cli/commands/extension.js.map +1 -1
  32. package/dist/cli/commands/gc.d.ts +8 -1
  33. package/dist/cli/commands/gc.js +26 -3
  34. package/dist/cli/commands/gc.js.map +1 -1
  35. package/dist/cli/commands/get.js +7 -7
  36. package/dist/cli/commands/get.js.map +1 -1
  37. package/dist/cli/commands/health.js +51 -3
  38. package/dist/cli/commands/health.js.map +1 -1
  39. package/dist/cli/commands/history.d.ts +4 -1
  40. package/dist/cli/commands/history.js +12 -24
  41. package/dist/cli/commands/history.js.map +1 -1
  42. package/dist/cli/commands/index.d.ts +3 -1
  43. package/dist/cli/commands/index.js +5 -3
  44. package/dist/cli/commands/index.js.map +1 -1
  45. package/dist/cli/commands/init.d.ts +10 -0
  46. package/dist/cli/commands/init.js +107 -4
  47. package/dist/cli/commands/init.js.map +1 -1
  48. package/dist/cli/commands/list.d.ts +5 -0
  49. package/dist/cli/commands/list.js +58 -26
  50. package/dist/cli/commands/list.js.map +1 -1
  51. package/dist/cli/commands/reindex.js +163 -47
  52. package/dist/cli/commands/reindex.js.map +1 -1
  53. package/dist/cli/commands/repeatable-metadata-parsers.d.ts +15 -0
  54. package/dist/cli/commands/repeatable-metadata-parsers.js +120 -0
  55. package/dist/cli/commands/repeatable-metadata-parsers.js.map +1 -0
  56. package/dist/cli/commands/restore.js +25 -4
  57. package/dist/cli/commands/restore.js.map +1 -1
  58. package/dist/cli/commands/schema.d.ts +122 -1
  59. package/dist/cli/commands/schema.js +536 -6
  60. package/dist/cli/commands/schema.js.map +1 -1
  61. package/dist/cli/commands/search.d.ts +1 -0
  62. package/dist/cli/commands/search.js +18 -4
  63. package/dist/cli/commands/search.js.map +1 -1
  64. package/dist/cli/commands/stats.d.ts +8 -1
  65. package/dist/cli/commands/stats.js +18 -17
  66. package/dist/cli/commands/stats.js.map +1 -1
  67. package/dist/cli/commands/telemetry.d.ts +8 -0
  68. package/dist/cli/commands/telemetry.js +253 -0
  69. package/dist/cli/commands/telemetry.js.map +1 -0
  70. package/dist/cli/commands/test.js +4 -3
  71. package/dist/cli/commands/test.js.map +1 -1
  72. package/dist/cli/commands/update-many.js +69 -140
  73. package/dist/cli/commands/update-many.js.map +1 -1
  74. package/dist/cli/commands/update.d.ts +2 -0
  75. package/dist/cli/commands/update.js +138 -119
  76. package/dist/cli/commands/update.js.map +1 -1
  77. package/dist/cli/commands/validate.d.ts +1 -0
  78. package/dist/cli/commands/validate.js +63 -33
  79. package/dist/cli/commands/validate.js.map +1 -1
  80. package/dist/cli/error-guidance.js +26 -3
  81. package/dist/cli/error-guidance.js.map +1 -1
  82. package/dist/cli/help-content.js +91 -3
  83. package/dist/cli/help-content.js.map +1 -1
  84. package/dist/cli/main.js +377 -23
  85. package/dist/cli/main.js.map +1 -1
  86. package/dist/cli/register-list-query.js +14 -5
  87. package/dist/cli/register-list-query.js.map +1 -1
  88. package/dist/cli/register-mutation.js +200 -28
  89. package/dist/cli/register-mutation.js.map +1 -1
  90. package/dist/cli/register-operations.js +31 -6
  91. package/dist/cli/register-operations.js.map +1 -1
  92. package/dist/cli/register-setup.js +4 -2
  93. package/dist/cli/register-setup.js.map +1 -1
  94. package/dist/cli/registration-helpers.js +31 -4
  95. package/dist/cli/registration-helpers.js.map +1 -1
  96. package/dist/cli-bundle/chunks/activity-CVXTCHYY.js +16 -0
  97. package/dist/cli-bundle/chunks/activity-JM6DTDND.js +20 -0
  98. package/dist/cli-bundle/chunks/activity-JM6DTDND.js.map +1 -0
  99. package/dist/cli-bundle/chunks/aggregate-GI7WSZPH.js +206 -0
  100. package/dist/cli-bundle/chunks/aggregate-GI7WSZPH.js.map +1 -0
  101. package/dist/cli-bundle/chunks/{aggregate-ADUOSFRO.js → aggregate-VNAHUNNF.js} +11 -11
  102. package/dist/cli-bundle/chunks/{append-JD2DETU7.js → append-7H5N64R2.js} +8 -9
  103. package/dist/cli-bundle/chunks/{append-JD2DETU7.js.map → append-7H5N64R2.js.map} +1 -1
  104. package/dist/cli-bundle/chunks/append-WMKRXKCE.js +69 -0
  105. package/dist/cli-bundle/chunks/append-WMKRXKCE.js.map +1 -0
  106. package/dist/cli-bundle/chunks/{chunk-3M73P3G6.js → chunk-23YFZ3IG.js} +210 -132
  107. package/dist/cli-bundle/chunks/chunk-23YFZ3IG.js.map +7 -0
  108. package/dist/cli-bundle/chunks/chunk-2HVRUSQA.js +128 -0
  109. package/dist/cli-bundle/chunks/chunk-2HVRUSQA.js.map +1 -0
  110. package/dist/cli-bundle/chunks/chunk-2RSPZI5H.js +266 -0
  111. package/dist/cli-bundle/chunks/chunk-2RSPZI5H.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-2VBQ6ZXS.js +631 -0
  113. package/dist/cli-bundle/chunks/chunk-2VBQ6ZXS.js.map +1 -0
  114. package/dist/cli-bundle/chunks/chunk-2VVCGBNV.js +380 -0
  115. package/dist/cli-bundle/chunks/chunk-2VVCGBNV.js.map +1 -0
  116. package/dist/cli-bundle/chunks/chunk-3BWOVLTH.js +1664 -0
  117. package/dist/cli-bundle/chunks/chunk-3BWOVLTH.js.map +1 -0
  118. package/dist/cli-bundle/chunks/{chunk-6HT2F4TK.js → chunk-3FI4SEFT.js} +175 -54
  119. package/dist/cli-bundle/chunks/chunk-3FI4SEFT.js.map +7 -0
  120. package/dist/cli-bundle/chunks/{chunk-JULRTHJQ.js → chunk-3LB74A67.js} +119 -6
  121. package/dist/cli-bundle/chunks/chunk-3LB74A67.js.map +7 -0
  122. package/dist/cli-bundle/chunks/chunk-3VAM3NNM.js +57 -0
  123. package/dist/cli-bundle/chunks/chunk-3VAM3NNM.js.map +1 -0
  124. package/dist/cli-bundle/chunks/chunk-4LL6TK5B.js +1832 -0
  125. package/dist/cli-bundle/chunks/chunk-4LL6TK5B.js.map +1 -0
  126. package/dist/cli-bundle/chunks/chunk-52MAOQ6J.js +422 -0
  127. package/dist/cli-bundle/chunks/chunk-52MAOQ6J.js.map +7 -0
  128. package/dist/cli-bundle/chunks/chunk-5FDATVEZ.js +412 -0
  129. package/dist/cli-bundle/chunks/chunk-5FDATVEZ.js.map +1 -0
  130. package/dist/cli-bundle/chunks/chunk-5SFCOO6B.js +5622 -0
  131. package/dist/cli-bundle/chunks/chunk-5SFCOO6B.js.map +1 -0
  132. package/dist/cli-bundle/chunks/{chunk-U7FMKRXH.js → chunk-6ER6DXH5.js} +37 -16
  133. package/dist/cli-bundle/chunks/chunk-6ER6DXH5.js.map +7 -0
  134. package/dist/cli-bundle/chunks/chunk-6P6GGMOG.js +218 -0
  135. package/dist/cli-bundle/chunks/chunk-6P6GGMOG.js.map +1 -0
  136. package/dist/cli-bundle/chunks/chunk-77GFDHGF.js +80 -0
  137. package/dist/cli-bundle/chunks/chunk-77GFDHGF.js.map +1 -0
  138. package/dist/cli-bundle/chunks/{chunk-MD7K4JYF.js → chunk-AO442XLN.js} +26 -15
  139. package/dist/cli-bundle/chunks/chunk-AO442XLN.js.map +7 -0
  140. package/dist/cli-bundle/chunks/chunk-AY43SBIN.js +751 -0
  141. package/dist/cli-bundle/chunks/chunk-AY43SBIN.js.map +1 -0
  142. package/dist/cli-bundle/chunks/{chunk-D7AOMPRH.js → chunk-BQHUILZS.js} +5 -5
  143. package/dist/cli-bundle/chunks/chunk-E5FJNAZA.js +242 -0
  144. package/dist/cli-bundle/chunks/chunk-E5FJNAZA.js.map +1 -0
  145. package/dist/cli-bundle/chunks/{chunk-OGZEG5TT.js → chunk-ECCMVXGM.js} +164 -53
  146. package/dist/cli-bundle/chunks/chunk-ECCMVXGM.js.map +7 -0
  147. package/dist/cli-bundle/chunks/chunk-FRAUKRU2.js +182 -0
  148. package/dist/cli-bundle/chunks/chunk-FRAUKRU2.js.map +1 -0
  149. package/dist/cli-bundle/chunks/chunk-GCOQW437.js +130 -0
  150. package/dist/cli-bundle/chunks/chunk-GCOQW437.js.map +1 -0
  151. package/dist/cli-bundle/chunks/chunk-GGYWB3Y2.js +1340 -0
  152. package/dist/cli-bundle/chunks/chunk-GGYWB3Y2.js.map +1 -0
  153. package/dist/cli-bundle/chunks/{chunk-G57E5D7T.js → chunk-GU2ZJ2VV.js} +5 -5
  154. package/dist/cli-bundle/chunks/chunk-GXSUPCBV.js +231 -0
  155. package/dist/cli-bundle/chunks/chunk-GXSUPCBV.js.map +1 -0
  156. package/dist/cli-bundle/chunks/chunk-HZGUAH22.js +76 -0
  157. package/dist/cli-bundle/chunks/chunk-HZGUAH22.js.map +1 -0
  158. package/dist/cli-bundle/chunks/chunk-I2HSTRJF.js +346 -0
  159. package/dist/cli-bundle/chunks/chunk-I2HSTRJF.js.map +1 -0
  160. package/dist/cli-bundle/chunks/chunk-I6BNFU5X.js +140 -0
  161. package/dist/cli-bundle/chunks/chunk-I6BNFU5X.js.map +7 -0
  162. package/dist/cli-bundle/chunks/{chunk-JTWRXG4B.js → chunk-IJGCZSIQ.js} +251 -251
  163. package/dist/cli-bundle/chunks/chunk-IJGCZSIQ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/chunk-IOR7LGF4.js +1491 -0
  165. package/dist/cli-bundle/chunks/chunk-IOR7LGF4.js.map +1 -0
  166. package/dist/cli-bundle/chunks/chunk-IUV734HF.js +17 -0
  167. package/dist/cli-bundle/chunks/chunk-IUV734HF.js.map +1 -0
  168. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js +15 -0
  169. package/dist/cli-bundle/chunks/chunk-J27KIHTG.js.map +1 -0
  170. package/dist/cli-bundle/chunks/{chunk-AKOOMO3T.js → chunk-KAG77BY3.js} +2 -2
  171. package/dist/cli-bundle/chunks/{chunk-KBQY3YG5.js → chunk-KJ33AOCY.js} +3 -3
  172. package/dist/cli-bundle/chunks/{chunk-WDPXDQFG.js → chunk-KJE2FOS4.js} +6 -4
  173. package/dist/cli-bundle/chunks/chunk-KJE2FOS4.js.map +7 -0
  174. package/dist/cli-bundle/chunks/chunk-KWU6HG75.js +3883 -0
  175. package/dist/cli-bundle/chunks/chunk-KWU6HG75.js.map +1 -0
  176. package/dist/cli-bundle/chunks/chunk-LB3RUL2N.js +1325 -0
  177. package/dist/cli-bundle/chunks/chunk-LB3RUL2N.js.map +1 -0
  178. package/dist/cli-bundle/chunks/{chunk-5HSEP75M.js → chunk-LCM63IXU.js} +18 -6
  179. package/dist/cli-bundle/chunks/chunk-LCM63IXU.js.map +7 -0
  180. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js +24 -0
  181. package/dist/cli-bundle/chunks/chunk-LXYVKYMQ.js.map +1 -0
  182. package/dist/cli-bundle/chunks/chunk-ME2YH6FN.js +182 -0
  183. package/dist/cli-bundle/chunks/chunk-ME2YH6FN.js.map +1 -0
  184. package/dist/cli-bundle/chunks/chunk-MITFDD35.js +1809 -0
  185. package/dist/cli-bundle/chunks/chunk-MITFDD35.js.map +1 -0
  186. package/dist/cli-bundle/chunks/{chunk-WJ2NAC37.js → chunk-N7ACFE26.js} +3 -3
  187. package/dist/cli-bundle/chunks/chunk-NUZ5HKR4.js +332 -0
  188. package/dist/cli-bundle/chunks/chunk-NUZ5HKR4.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-7Y53ZJIQ.js → chunk-OVQCEJPG.js} +22 -3
  190. package/dist/cli-bundle/chunks/chunk-OVQCEJPG.js.map +7 -0
  191. package/dist/cli-bundle/chunks/{chunk-PXUAZUUY.js → chunk-OZ7NSQHL.js} +12 -11
  192. package/dist/cli-bundle/chunks/chunk-OZ7NSQHL.js.map +7 -0
  193. package/dist/cli-bundle/chunks/{chunk-P53TN6IA.js → chunk-PDDFYW4X.js} +35 -8
  194. package/dist/cli-bundle/chunks/chunk-PDDFYW4X.js.map +7 -0
  195. package/dist/cli-bundle/chunks/{chunk-6YCV7WSL.js → chunk-PIU6RSL3.js} +10 -12
  196. package/dist/cli-bundle/chunks/{chunk-6YCV7WSL.js.map → chunk-PIU6RSL3.js.map} +1 -1
  197. package/dist/cli-bundle/chunks/chunk-PO3GSVFV.js +338 -0
  198. package/dist/cli-bundle/chunks/chunk-PO3GSVFV.js.map +1 -0
  199. package/dist/cli-bundle/chunks/{chunk-LRBOHPUE.js → chunk-PRJCELV4.js} +108 -21
  200. package/dist/cli-bundle/chunks/chunk-PRJCELV4.js.map +7 -0
  201. package/dist/cli-bundle/chunks/{chunk-GN7IJPCD.js → chunk-PROOHX4K.js} +332 -32
  202. package/dist/cli-bundle/chunks/chunk-PROOHX4K.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-FQE6XZDB.js → chunk-Q7SPNHLW.js} +54 -32
  204. package/dist/cli-bundle/chunks/chunk-Q7SPNHLW.js.map +7 -0
  205. package/dist/cli-bundle/chunks/{chunk-PVNQLCIS.js → chunk-QO7EBBOM.js} +2 -2
  206. package/dist/cli-bundle/chunks/{chunk-A7E7PUVX.js → chunk-R6UFP2GE.js} +7 -7
  207. package/dist/cli-bundle/chunks/chunk-RWPSOIEE.js +154 -0
  208. package/dist/cli-bundle/chunks/chunk-RWPSOIEE.js.map +1 -0
  209. package/dist/cli-bundle/chunks/chunk-RZN6VURO.js +119 -0
  210. package/dist/cli-bundle/chunks/chunk-RZN6VURO.js.map +1 -0
  211. package/dist/cli-bundle/chunks/chunk-SKJWX3QB.js +1501 -0
  212. package/dist/cli-bundle/chunks/chunk-SKJWX3QB.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{chunk-CEFIVZPG.js → chunk-T3LC5LKB.js} +2 -2
  214. package/dist/cli-bundle/chunks/chunk-TCD3R2PF.js +173 -0
  215. package/dist/cli-bundle/chunks/chunk-TCD3R2PF.js.map +1 -0
  216. package/dist/cli-bundle/chunks/chunk-TPH5XEVD.js +2988 -0
  217. package/dist/cli-bundle/chunks/chunk-TPH5XEVD.js.map +1 -0
  218. package/dist/cli-bundle/chunks/{chunk-LSXGH6NE.js → chunk-U5SXYXSY.js} +821 -200
  219. package/dist/cli-bundle/chunks/chunk-U5SXYXSY.js.map +7 -0
  220. package/dist/cli-bundle/chunks/chunk-UBOPJT3S.js +540 -0
  221. package/dist/cli-bundle/chunks/chunk-UBOPJT3S.js.map +1 -0
  222. package/dist/cli-bundle/chunks/{chunk-JFWUHHS2.js → chunk-UM2GBHS4.js} +5 -4
  223. package/dist/cli-bundle/chunks/chunk-W7XABV4H.js +454 -0
  224. package/dist/cli-bundle/chunks/chunk-W7XABV4H.js.map +1 -0
  225. package/dist/cli-bundle/chunks/{chunk-SEXQN4KL.js → chunk-WKY2IBOQ.js} +3 -3
  226. package/dist/cli-bundle/chunks/chunk-WOPXVEZP.js +698 -0
  227. package/dist/cli-bundle/chunks/chunk-WOPXVEZP.js.map +1 -0
  228. package/dist/cli-bundle/chunks/chunk-WSMOSYRD.js +1704 -0
  229. package/dist/cli-bundle/chunks/chunk-WSMOSYRD.js.map +1 -0
  230. package/dist/cli-bundle/chunks/{chunk-NGN7UV5K.js → chunk-XLTD2HN3.js} +2 -2
  231. package/dist/cli-bundle/chunks/chunk-XSJCLN2R.js +131 -0
  232. package/dist/cli-bundle/chunks/chunk-XSJCLN2R.js.map +7 -0
  233. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js +53 -0
  234. package/dist/cli-bundle/chunks/chunk-XSLQSXAH.js.map +1 -0
  235. package/dist/cli-bundle/chunks/{chunk-BUPWJ3IJ.js → chunk-XTGLRY2Y.js} +484 -49
  236. package/dist/cli-bundle/chunks/chunk-XTGLRY2Y.js.map +7 -0
  237. package/dist/cli-bundle/chunks/{chunk-L2FXEKDB.js → chunk-YL2DJGYS.js} +7 -7
  238. package/dist/cli-bundle/chunks/{claim-EE4TKKCV.js → claim-4DBF6RVG.js} +10 -11
  239. package/dist/cli-bundle/chunks/{claim-EE4TKKCV.js.map → claim-4DBF6RVG.js.map} +1 -1
  240. package/dist/cli-bundle/chunks/claim-X2P4IB7J.js +129 -0
  241. package/dist/cli-bundle/chunks/claim-X2P4IB7J.js.map +1 -0
  242. package/dist/cli-bundle/chunks/close-3HDWDA3L.js +13 -0
  243. package/dist/cli-bundle/chunks/close-PTYFA45H.js +17 -0
  244. package/dist/cli-bundle/chunks/close-PTYFA45H.js.map +1 -0
  245. package/dist/cli-bundle/chunks/close-many-7CGIDPTJ.js +314 -0
  246. package/dist/cli-bundle/chunks/close-many-7CGIDPTJ.js.map +7 -0
  247. package/dist/cli-bundle/chunks/close-many-ERFO6LHR.js +311 -0
  248. package/dist/cli-bundle/chunks/close-many-ERFO6LHR.js.map +1 -0
  249. package/dist/cli-bundle/chunks/comments-OONGABK5.js +100 -0
  250. package/dist/cli-bundle/chunks/comments-OONGABK5.js.map +1 -0
  251. package/dist/cli-bundle/chunks/{comments-AAKJQ6LW.js → comments-QKBYCWKD.js} +10 -11
  252. package/dist/cli-bundle/chunks/{comments-AAKJQ6LW.js.map → comments-QKBYCWKD.js.map} +1 -1
  253. package/dist/cli-bundle/chunks/config-6FXCQKIF.js +1671 -0
  254. package/dist/cli-bundle/chunks/config-6FXCQKIF.js.map +1 -0
  255. package/dist/cli-bundle/chunks/{config-V3FZOKLI.js → config-U4RZ4CQB.js} +121 -10
  256. package/dist/cli-bundle/chunks/config-U4RZ4CQB.js.map +7 -0
  257. package/dist/cli-bundle/chunks/{context-RZ5QPNJB.js → context-FYYJGFWS.js} +32 -19
  258. package/dist/cli-bundle/chunks/{context-RZ5QPNJB.js.map → context-FYYJGFWS.js.map} +2 -2
  259. package/dist/cli-bundle/chunks/context-YMJ3Z2HQ.js +1461 -0
  260. package/dist/cli-bundle/chunks/context-YMJ3Z2HQ.js.map +1 -0
  261. package/dist/cli-bundle/chunks/contracts-QDB6OMLQ.js +1278 -0
  262. package/dist/cli-bundle/chunks/contracts-QDB6OMLQ.js.map +1 -0
  263. package/dist/cli-bundle/chunks/{contracts-YLMH33VU.js → contracts-RFSPGVVJ.js} +198 -162
  264. package/dist/cli-bundle/chunks/contracts-RFSPGVVJ.js.map +7 -0
  265. package/dist/cli-bundle/chunks/create-I5L4EYYZ.js +31 -0
  266. package/dist/cli-bundle/chunks/create-I5L4EYYZ.js.map +1 -0
  267. package/dist/cli-bundle/chunks/create-JTZNCTQC.js +27 -0
  268. package/dist/cli-bundle/chunks/delete-7HPGI4GZ.js +55 -0
  269. package/dist/cli-bundle/chunks/delete-7HPGI4GZ.js.map +1 -0
  270. package/dist/cli-bundle/chunks/{delete-RHCTEORS.js → delete-VXUPH5RS.js} +7 -8
  271. package/dist/cli-bundle/chunks/{delete-RHCTEORS.js.map → delete-VXUPH5RS.js.map} +1 -1
  272. package/dist/cli-bundle/chunks/{deps-MZYCMLAO.js → deps-JSRRWC3Z.js} +7 -8
  273. package/dist/cli-bundle/chunks/{deps-MZYCMLAO.js.map → deps-JSRRWC3Z.js.map} +1 -1
  274. package/dist/cli-bundle/chunks/deps-SCZIFK2Z.js +225 -0
  275. package/dist/cli-bundle/chunks/deps-SCZIFK2Z.js.map +1 -0
  276. package/dist/cli-bundle/chunks/docs-GJK6K4VP.js +31 -0
  277. package/dist/cli-bundle/chunks/docs-GJK6K4VP.js.map +1 -0
  278. package/dist/cli-bundle/chunks/{docs-FXXUCZYU.js → docs-WW4N3MBM.js} +9 -10
  279. package/dist/cli-bundle/chunks/{docs-FXXUCZYU.js.map → docs-WW4N3MBM.js.map} +1 -1
  280. package/dist/cli-bundle/chunks/{extension-B4WL7BQU.js → extension-J7IBMFTD.js} +4 -5
  281. package/dist/cli-bundle/chunks/extension-VDY2U33M.js +28 -0
  282. package/dist/cli-bundle/chunks/extension-VDY2U33M.js.map +1 -0
  283. package/dist/cli-bundle/chunks/files-ISZJGILQ.js +282 -0
  284. package/dist/cli-bundle/chunks/files-ISZJGILQ.js.map +1 -0
  285. package/dist/cli-bundle/chunks/{files-WVOX67PE.js → files-WKOD326U.js} +9 -10
  286. package/dist/cli-bundle/chunks/{files-WVOX67PE.js.map → files-WKOD326U.js.map} +1 -1
  287. package/dist/cli-bundle/chunks/gc-JDVJ6OQ2.js +362 -0
  288. package/dist/cli-bundle/chunks/gc-JDVJ6OQ2.js.map +1 -0
  289. package/dist/cli-bundle/chunks/gc-ULPVWMTN.js +372 -0
  290. package/dist/cli-bundle/chunks/gc-ULPVWMTN.js.map +7 -0
  291. package/dist/cli-bundle/chunks/get-RV37HT3G.js +194 -0
  292. package/dist/cli-bundle/chunks/get-RV37HT3G.js.map +1 -0
  293. package/dist/cli-bundle/chunks/{get-LTK3HOCQ.js → get-WXU6WI5P.js} +16 -17
  294. package/dist/cli-bundle/chunks/get-WXU6WI5P.js.map +7 -0
  295. package/dist/cli-bundle/chunks/{health-TCWL55KM.js → health-6L6EH4WR.js} +57 -16
  296. package/dist/cli-bundle/chunks/health-6L6EH4WR.js.map +7 -0
  297. package/dist/cli-bundle/chunks/health-LOI2HHKB.js +1271 -0
  298. package/dist/cli-bundle/chunks/health-LOI2HHKB.js.map +1 -0
  299. package/dist/cli-bundle/chunks/history-2BA3T5AE.js +20 -0
  300. package/dist/cli-bundle/chunks/history-PKN67D5O.js +24 -0
  301. package/dist/cli-bundle/chunks/history-PKN67D5O.js.map +1 -0
  302. package/dist/cli-bundle/chunks/history-redact-JBZNXHGR.js +19 -0
  303. package/dist/cli-bundle/chunks/history-redact-V4FOJGS7.js +23 -0
  304. package/dist/cli-bundle/chunks/history-redact-V4FOJGS7.js.map +1 -0
  305. package/dist/cli-bundle/chunks/{history-repair-ZWSTDRH2.js → history-repair-HIBCBIKK.js} +12 -14
  306. package/dist/cli-bundle/chunks/{history-repair-ZWSTDRH2.js.map → history-repair-HIBCBIKK.js.map} +1 -1
  307. package/dist/cli-bundle/chunks/history-repair-SDMHR7JT.js +193 -0
  308. package/dist/cli-bundle/chunks/history-repair-SDMHR7JT.js.map +1 -0
  309. package/dist/cli-bundle/chunks/init-HIVSNX3O.js +16 -0
  310. package/dist/cli-bundle/chunks/init-P56QYWJF.js +20 -0
  311. package/dist/cli-bundle/chunks/init-P56QYWJF.js.map +1 -0
  312. package/dist/cli-bundle/chunks/learnings-GDFRG5J7.js +44 -0
  313. package/dist/cli-bundle/chunks/learnings-GDFRG5J7.js.map +1 -0
  314. package/dist/cli-bundle/chunks/{learnings-NXTWE3FR.js → learnings-MIXSESLK.js} +10 -11
  315. package/dist/cli-bundle/chunks/{learnings-NXTWE3FR.js.map → learnings-MIXSESLK.js.map} +1 -1
  316. package/dist/cli-bundle/chunks/list-FGOWQMSM.js +24 -0
  317. package/dist/cli-bundle/chunks/list-FGOWQMSM.js.map +1 -0
  318. package/dist/cli-bundle/chunks/list-MUSQNMTD.js +20 -0
  319. package/dist/cli-bundle/chunks/{notes-DFS5ZGOO.js → notes-4XVSH2AZ.js} +10 -11
  320. package/dist/cli-bundle/chunks/{notes-DFS5ZGOO.js.map → notes-4XVSH2AZ.js.map} +1 -1
  321. package/dist/cli-bundle/chunks/notes-5UK3GEH2.js +44 -0
  322. package/dist/cli-bundle/chunks/notes-5UK3GEH2.js.map +1 -0
  323. package/dist/cli-bundle/chunks/plan-DUMBV3QB.js +1171 -0
  324. package/dist/cli-bundle/chunks/plan-DUMBV3QB.js.map +1 -0
  325. package/dist/cli-bundle/chunks/{plan-67AB2PLM.js → plan-SLMODHWX.js} +13 -14
  326. package/dist/cli-bundle/chunks/{plan-67AB2PLM.js.map → plan-SLMODHWX.js.map} +1 -1
  327. package/dist/cli-bundle/chunks/register-list-query-POCFZ5JW.js +229 -0
  328. package/dist/cli-bundle/chunks/register-list-query-POCFZ5JW.js.map +1 -0
  329. package/dist/cli-bundle/chunks/{register-list-query-UP3VRUFS.js → register-list-query-WST76HSQ.js} +26 -26
  330. package/dist/cli-bundle/chunks/register-list-query-WST76HSQ.js.map +7 -0
  331. package/dist/cli-bundle/chunks/register-mutation-N5GSUZJV.js +813 -0
  332. package/dist/cli-bundle/chunks/register-mutation-N5GSUZJV.js.map +1 -0
  333. package/dist/cli-bundle/chunks/{register-mutation-YWSBF545.js → register-mutation-OA675SOU.js} +154 -43
  334. package/dist/cli-bundle/chunks/register-mutation-OA675SOU.js.map +7 -0
  335. package/dist/cli-bundle/chunks/register-operations-GNHBE5I3.js +383 -0
  336. package/dist/cli-bundle/chunks/register-operations-GNHBE5I3.js.map +1 -0
  337. package/dist/cli-bundle/chunks/{register-operations-3BDTGSDH.js → register-operations-N3PMHXH5.js} +49 -37
  338. package/dist/cli-bundle/chunks/register-operations-N3PMHXH5.js.map +7 -0
  339. package/dist/cli-bundle/chunks/register-setup-JIMPKJKV.js +242 -0
  340. package/dist/cli-bundle/chunks/register-setup-JIMPKJKV.js.map +1 -0
  341. package/dist/cli-bundle/chunks/{register-setup-V56GDRUS.js → register-setup-ZHJI2DI3.js} +18 -19
  342. package/dist/cli-bundle/chunks/{register-setup-V56GDRUS.js.map → register-setup-ZHJI2DI3.js.map} +2 -2
  343. package/dist/cli-bundle/chunks/restore-D4RGNX33.js +17 -0
  344. package/dist/cli-bundle/chunks/restore-PBL6T5TW.js +21 -0
  345. package/dist/cli-bundle/chunks/restore-PBL6T5TW.js.map +1 -0
  346. package/dist/cli-bundle/chunks/schema-2NOO6NGB.js +780 -0
  347. package/dist/cli-bundle/chunks/schema-2NOO6NGB.js.map +7 -0
  348. package/dist/cli-bundle/chunks/schema-EBI4NLUO.js +770 -0
  349. package/dist/cli-bundle/chunks/schema-EBI4NLUO.js.map +1 -0
  350. package/dist/cli-bundle/chunks/search-JPUQTVCY.js +1127 -0
  351. package/dist/cli-bundle/chunks/search-JPUQTVCY.js.map +1 -0
  352. package/dist/cli-bundle/chunks/{search-HENBL456.js → search-OA6JX27A.js} +25 -16
  353. package/dist/cli-bundle/chunks/search-OA6JX27A.js.map +7 -0
  354. package/dist/cli-bundle/chunks/stats-CV54BAWY.js +202 -0
  355. package/dist/cli-bundle/chunks/stats-CV54BAWY.js.map +1 -0
  356. package/dist/cli-bundle/chunks/stats-XYB6KTFG.js +212 -0
  357. package/dist/cli-bundle/chunks/stats-XYB6KTFG.js.map +7 -0
  358. package/dist/cli-bundle/chunks/telemetry-LMJ7PFUO.js +251 -0
  359. package/dist/cli-bundle/chunks/telemetry-LMJ7PFUO.js.map +7 -0
  360. package/dist/cli-bundle/chunks/telemetry-NCMEPJNR.js +248 -0
  361. package/dist/cli-bundle/chunks/telemetry-NCMEPJNR.js.map +1 -0
  362. package/dist/cli-bundle/chunks/test-MXX3E5JL.js +31 -0
  363. package/dist/cli-bundle/chunks/test-WBROAJIE.js +35 -0
  364. package/dist/cli-bundle/chunks/test-WBROAJIE.js.map +1 -0
  365. package/dist/cli-bundle/chunks/test-all-N6NSRDTV.js +328 -0
  366. package/dist/cli-bundle/chunks/test-all-N6NSRDTV.js.map +1 -0
  367. package/dist/cli-bundle/chunks/{test-all-G2AZOHXI.js → test-all-NTOZ7C3M.js} +13 -14
  368. package/dist/cli-bundle/chunks/{test-all-G2AZOHXI.js.map → test-all-NTOZ7C3M.js.map} +1 -1
  369. package/dist/cli-bundle/chunks/test-runs-V6A7LPWZ.js +929 -0
  370. package/dist/cli-bundle/chunks/test-runs-V6A7LPWZ.js.map +1 -0
  371. package/dist/cli-bundle/chunks/{test-runs-GX5HTPSF.js → test-runs-WMVTQU3Y.js} +5 -5
  372. package/dist/cli-bundle/chunks/update-OSV3NAQB.js +25 -0
  373. package/dist/cli-bundle/chunks/update-OSV3NAQB.js.map +1 -0
  374. package/dist/cli-bundle/chunks/update-YRXSUGYQ.js +21 -0
  375. package/dist/cli-bundle/chunks/update-many-EM6OXYGO.js +605 -0
  376. package/dist/cli-bundle/chunks/update-many-EM6OXYGO.js.map +1 -0
  377. package/dist/cli-bundle/chunks/{update-many-46HRSP2Q.js → update-many-KGGEYABR.js} +78 -146
  378. package/dist/cli-bundle/chunks/update-many-KGGEYABR.js.map +7 -0
  379. package/dist/cli-bundle/chunks/{upgrade-H5HHM5UV.js → upgrade-BLI7XBAJ.js} +5 -7
  380. package/dist/cli-bundle/chunks/{upgrade-H5HHM5UV.js.map → upgrade-BLI7XBAJ.js.map} +1 -1
  381. package/dist/cli-bundle/chunks/upgrade-LXPOQKFV.js +266 -0
  382. package/dist/cli-bundle/chunks/upgrade-LXPOQKFV.js.map +1 -0
  383. package/dist/cli-bundle/chunks/{validate-TMCVKIGZ.js → validate-AGOAUOVW.js} +61 -48
  384. package/dist/cli-bundle/chunks/validate-AGOAUOVW.js.map +7 -0
  385. package/dist/cli-bundle/chunks/validate-L5J6A7YO.js +1120 -0
  386. package/dist/cli-bundle/chunks/validate-L5J6A7YO.js.map +1 -0
  387. package/dist/cli-bundle/main.js +534 -1505
  388. package/dist/cli-bundle/main.js.map +4 -4
  389. package/dist/core/checkpoint/mutation-checkpoint.d.ts +44 -0
  390. package/dist/core/checkpoint/mutation-checkpoint.js +119 -0
  391. package/dist/core/checkpoint/mutation-checkpoint.js.map +1 -0
  392. package/dist/core/config/positional-value.js +4 -2
  393. package/dist/core/config/positional-value.js.map +1 -1
  394. package/dist/core/diagnostics/remediation.d.ts +73 -0
  395. package/dist/core/diagnostics/remediation.js +328 -0
  396. package/dist/core/diagnostics/remediation.js.map +1 -0
  397. package/dist/core/extensions/extension-hook-runtime.js +9 -2
  398. package/dist/core/extensions/extension-hook-runtime.js.map +1 -1
  399. package/dist/core/extensions/extension-types.d.ts +60 -4
  400. package/dist/core/extensions/extension-types.js +2 -2
  401. package/dist/core/extensions/extension-types.js.map +1 -1
  402. package/dist/core/extensions/index.d.ts +5 -1
  403. package/dist/core/extensions/index.js +61 -2
  404. package/dist/core/extensions/index.js.map +1 -1
  405. package/dist/core/extensions/item-fields.d.ts +5 -1
  406. package/dist/core/extensions/item-fields.js +126 -4
  407. package/dist/core/extensions/item-fields.js.map +1 -1
  408. package/dist/core/extensions/loader.js +283 -8
  409. package/dist/core/extensions/loader.js.map +1 -1
  410. package/dist/core/history/history-diff.d.ts +47 -0
  411. package/dist/core/history/history-diff.js +152 -0
  412. package/dist/core/history/history-diff.js.map +1 -0
  413. package/dist/core/history/history-storage-stats.d.ts +31 -0
  414. package/dist/core/history/history-storage-stats.js +101 -0
  415. package/dist/core/history/history-storage-stats.js.map +1 -0
  416. package/dist/core/item/item-format.d.ts +3 -2
  417. package/dist/core/item/item-format.js +15 -10
  418. package/dist/core/item/item-format.js.map +1 -1
  419. package/dist/core/item/status-filter.d.ts +29 -0
  420. package/dist/core/item/status-filter.js +97 -0
  421. package/dist/core/item/status-filter.js.map +1 -0
  422. package/dist/core/item/type-registry.js +4 -2
  423. package/dist/core/item/type-registry.js.map +1 -1
  424. package/dist/core/lock/lock-gc.d.ts +46 -0
  425. package/dist/core/lock/lock-gc.js +194 -0
  426. package/dist/core/lock/lock-gc.js.map +1 -0
  427. package/dist/core/output/output.js +17 -5
  428. package/dist/core/output/output.js.map +1 -1
  429. package/dist/core/schema/item-types-file.d.ts +15 -0
  430. package/dist/core/schema/item-types-file.js +27 -2
  431. package/dist/core/schema/item-types-file.js.map +1 -1
  432. package/dist/core/schema/runtime-field-filters.js +4 -3
  433. package/dist/core/schema/runtime-field-filters.js.map +1 -1
  434. package/dist/core/schema/runtime-field-values.d.ts +1 -1
  435. package/dist/core/schema/runtime-field-values.js +10 -4
  436. package/dist/core/schema/runtime-field-values.js.map +1 -1
  437. package/dist/core/schema/runtime-schema.js +75 -2
  438. package/dist/core/schema/runtime-schema.js.map +1 -1
  439. package/dist/core/schema/status-defs-file.d.ts +113 -0
  440. package/dist/core/schema/status-defs-file.js +260 -0
  441. package/dist/core/schema/status-defs-file.js.map +1 -0
  442. package/dist/core/schema/type-workflows.d.ts +64 -0
  443. package/dist/core/schema/type-workflows.js +98 -0
  444. package/dist/core/schema/type-workflows.js.map +1 -0
  445. package/dist/core/search/cache.d.ts +3 -1
  446. package/dist/core/search/cache.js +104 -28
  447. package/dist/core/search/cache.js.map +1 -1
  448. package/dist/core/search/http-client.d.ts +2 -2
  449. package/dist/core/search/http-client.js +2 -2
  450. package/dist/core/search/http-client.js.map +1 -1
  451. package/dist/core/search/vector-stores.d.ts +1 -0
  452. package/dist/core/search/vector-stores.js +64 -14
  453. package/dist/core/search/vector-stores.js.map +1 -1
  454. package/dist/core/search/vectorization-metadata.d.ts +13 -0
  455. package/dist/core/search/vectorization-metadata.js +65 -0
  456. package/dist/core/search/vectorization-metadata.js.map +1 -0
  457. package/dist/core/shared/serial-queue.d.ts +12 -0
  458. package/dist/core/shared/serial-queue.js +43 -0
  459. package/dist/core/shared/serial-queue.js.map +1 -0
  460. package/dist/core/shared/serialization.d.ts +1 -0
  461. package/dist/core/shared/serialization.js +86 -2
  462. package/dist/core/shared/serialization.js.map +1 -1
  463. package/dist/core/store/front-matter-cache.js +14 -5
  464. package/dist/core/store/front-matter-cache.js.map +1 -1
  465. package/dist/core/store/item-store.d.ts +2 -0
  466. package/dist/core/store/item-store.js +61 -6
  467. package/dist/core/store/item-store.js.map +1 -1
  468. package/dist/core/store/settings-validator.js +18 -2
  469. package/dist/core/store/settings-validator.js.map +1 -1
  470. package/dist/core/store/settings.d.ts +19 -1
  471. package/dist/core/store/settings.js +130 -10
  472. package/dist/core/store/settings.js.map +1 -1
  473. package/dist/core/telemetry/consent.js +3 -3
  474. package/dist/core/telemetry/consent.js.map +1 -1
  475. package/dist/core/telemetry/observability.js +5 -4
  476. package/dist/core/telemetry/observability.js.map +1 -1
  477. package/dist/core/telemetry/runtime.js +16 -4
  478. package/dist/core/telemetry/runtime.js.map +1 -1
  479. package/dist/mcp/server.d.ts +1 -0
  480. package/dist/mcp/server.js +372 -45
  481. package/dist/mcp/server.js.map +1 -1
  482. package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -2
  483. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  484. package/dist/sdk/cli-contracts/commander-types.js +7 -2
  485. package/dist/sdk/cli-contracts/commander-types.js.map +1 -1
  486. package/dist/sdk/cli-contracts/enum-contracts.d.ts +2 -2
  487. package/dist/sdk/cli-contracts/enum-contracts.js +6 -2
  488. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  489. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +1 -0
  490. package/dist/sdk/cli-contracts/tool-option-contracts.js +53 -3
  491. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  492. package/dist/sdk/cli-contracts/tool-parameter-tables.js +42 -10
  493. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  494. package/dist/sdk/cli-contracts.d.ts +42 -1
  495. package/dist/sdk/cli-contracts.js +225 -19
  496. package/dist/sdk/cli-contracts.js.map +1 -1
  497. package/dist/sdk/errors.d.ts +22 -0
  498. package/dist/sdk/errors.js +46 -0
  499. package/dist/sdk/errors.js.map +1 -0
  500. package/dist/sdk/index.d.ts +2 -1
  501. package/dist/sdk/index.js +3 -2
  502. package/dist/sdk/index.js.map +1 -1
  503. package/dist/sdk/package-import-adapters.js +14 -3
  504. package/dist/sdk/package-import-adapters.js.map +1 -1
  505. package/dist/sdk/runtime.d.ts +1 -0
  506. package/dist/sdk/runtime.js +3 -2
  507. package/dist/sdk/runtime.js.map +1 -1
  508. package/dist/sdk/testing.d.ts +77 -0
  509. package/dist/sdk/testing.js +239 -0
  510. package/dist/sdk/testing.js.map +1 -0
  511. package/dist/types.d.ts +19 -0
  512. package/dist/types.js +3 -2
  513. package/dist/types.js.map +1 -1
  514. package/docs/AGENT_GUIDE.md +22 -3
  515. package/docs/ARCHITECTURE.md +11 -1
  516. package/docs/CLAUDE_CODE_PLUGIN.md +2 -2
  517. package/docs/COMMANDS.md +118 -7
  518. package/docs/CONFIGURATION.md +57 -2
  519. package/docs/EXTENSIONS.md +125 -6
  520. package/docs/EXTENSION_AUTHOR_CONTRACTS.md +73 -0
  521. package/docs/ONBOARDING.md +165 -0
  522. package/docs/QUICKSTART.md +3 -1
  523. package/docs/README.md +12 -4
  524. package/docs/RELEASING.md +38 -3
  525. package/docs/SDK.md +273 -1
  526. package/docs/TESTING.md +36 -1
  527. package/docs/examples/policy-restricted-extension/manifest.json +1 -0
  528. package/docs/examples/starter-extension/index.js +9 -1
  529. package/docs/examples/starter-extension/manifest.json +1 -0
  530. package/package.json +16 -7
  531. package/packages/pm-beads/extensions/beads/index.js +2 -4
  532. package/packages/pm-beads/extensions/beads/index.ts +43 -33
  533. package/packages/pm-beads/extensions/beads/manifest.json +12 -1
  534. package/packages/pm-calendar/README.md +6 -0
  535. package/packages/pm-calendar/extensions/calendar/index.js +6 -1
  536. package/packages/pm-calendar/extensions/calendar/index.ts +6 -1
  537. package/packages/pm-calendar/extensions/calendar/manifest.json +6 -1
  538. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +6 -1
  539. package/packages/pm-guide-shell/README.md +4 -0
  540. package/packages/pm-guide-shell/extensions/guide-shell/index.js +22 -0
  541. package/packages/pm-guide-shell/extensions/guide-shell/index.ts +22 -0
  542. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +6 -1
  543. package/packages/pm-guide-shell/extensions/guide-shell/runtime.js +74 -3
  544. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +84 -4
  545. package/packages/pm-lifecycle-hooks/README.md +29 -0
  546. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.js +18 -0
  547. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/index.ts +20 -0
  548. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +9 -0
  549. package/packages/pm-lifecycle-hooks/package.json +52 -0
  550. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +13 -1
  551. package/packages/pm-search-advanced/extensions/search-advanced/index.js +69 -1
  552. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +91 -2
  553. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +13 -1
  554. package/packages/pm-templates/extensions/templates/manifest.json +6 -1
  555. package/packages/pm-todos/extensions/todos/index.js +3 -7
  556. package/packages/pm-todos/extensions/todos/index.ts +55 -42
  557. package/packages/pm-todos/extensions/todos/manifest.json +13 -1
  558. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  559. package/plugins/pm-claude/README.md +7 -4
  560. package/plugins/pm-claude/agents/pm-coordinator.md +1 -1
  561. package/plugins/pm-claude/commands/pm-init.md +1 -1
  562. package/scripts/bundle-cli.mjs +121 -17
  563. package/dist/cli-bundle/chunks/activity-OWYSUZOY.js +0 -17
  564. package/dist/cli-bundle/chunks/chunk-3M73P3G6.js.map +0 -7
  565. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js +0 -189
  566. package/dist/cli-bundle/chunks/chunk-4AEZR5EJ.js.map +0 -7
  567. package/dist/cli-bundle/chunks/chunk-5HSEP75M.js.map +0 -7
  568. package/dist/cli-bundle/chunks/chunk-6HT2F4TK.js.map +0 -7
  569. package/dist/cli-bundle/chunks/chunk-7Y53ZJIQ.js.map +0 -7
  570. package/dist/cli-bundle/chunks/chunk-BUPWJ3IJ.js.map +0 -7
  571. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js +0 -47
  572. package/dist/cli-bundle/chunks/chunk-EGUGFSNX.js.map +0 -7
  573. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js +0 -56
  574. package/dist/cli-bundle/chunks/chunk-FM26RGSU.js.map +0 -7
  575. package/dist/cli-bundle/chunks/chunk-FQE6XZDB.js.map +0 -7
  576. package/dist/cli-bundle/chunks/chunk-GN7IJPCD.js.map +0 -7
  577. package/dist/cli-bundle/chunks/chunk-JTWRXG4B.js.map +0 -7
  578. package/dist/cli-bundle/chunks/chunk-JULRTHJQ.js.map +0 -7
  579. package/dist/cli-bundle/chunks/chunk-LRBOHPUE.js.map +0 -7
  580. package/dist/cli-bundle/chunks/chunk-LSXGH6NE.js.map +0 -7
  581. package/dist/cli-bundle/chunks/chunk-MD7K4JYF.js.map +0 -7
  582. package/dist/cli-bundle/chunks/chunk-OGZEG5TT.js.map +0 -7
  583. package/dist/cli-bundle/chunks/chunk-P53TN6IA.js.map +0 -7
  584. package/dist/cli-bundle/chunks/chunk-PXUAZUUY.js.map +0 -7
  585. package/dist/cli-bundle/chunks/chunk-U7FMKRXH.js.map +0 -7
  586. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js +0 -141
  587. package/dist/cli-bundle/chunks/chunk-VGICHR7D.js.map +0 -7
  588. package/dist/cli-bundle/chunks/chunk-WDPXDQFG.js.map +0 -7
  589. package/dist/cli-bundle/chunks/close-XY4CSAYF.js +0 -14
  590. package/dist/cli-bundle/chunks/config-V3FZOKLI.js.map +0 -7
  591. package/dist/cli-bundle/chunks/contracts-YLMH33VU.js.map +0 -7
  592. package/dist/cli-bundle/chunks/create-PZVHRIZQ.js +0 -28
  593. package/dist/cli-bundle/chunks/gc-JWNF66EC.js +0 -181
  594. package/dist/cli-bundle/chunks/gc-JWNF66EC.js.map +0 -7
  595. package/dist/cli-bundle/chunks/get-LTK3HOCQ.js.map +0 -7
  596. package/dist/cli-bundle/chunks/health-TCWL55KM.js.map +0 -7
  597. package/dist/cli-bundle/chunks/history-A2JUDXUE.js +0 -21
  598. package/dist/cli-bundle/chunks/history-redact-ED6RFCPL.js +0 -20
  599. package/dist/cli-bundle/chunks/init-M2WUB4YH.js +0 -16
  600. package/dist/cli-bundle/chunks/list-OGWQPC26.js +0 -20
  601. package/dist/cli-bundle/chunks/register-list-query-UP3VRUFS.js.map +0 -7
  602. package/dist/cli-bundle/chunks/register-mutation-YWSBF545.js.map +0 -7
  603. package/dist/cli-bundle/chunks/register-operations-3BDTGSDH.js.map +0 -7
  604. package/dist/cli-bundle/chunks/restore-MB2ISME7.js +0 -18
  605. package/dist/cli-bundle/chunks/schema-Q622KC46.js +0 -119
  606. package/dist/cli-bundle/chunks/schema-Q622KC46.js.map +0 -7
  607. package/dist/cli-bundle/chunks/search-HENBL456.js.map +0 -7
  608. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js +0 -124
  609. package/dist/cli-bundle/chunks/stats-N6H3YP2F.js.map +0 -7
  610. package/dist/cli-bundle/chunks/test-VNBDRJ4Z.js +0 -32
  611. package/dist/cli-bundle/chunks/update-H6SCWNMA.js +0 -22
  612. package/dist/cli-bundle/chunks/update-many-46HRSP2Q.js.map +0 -7
  613. package/dist/cli-bundle/chunks/validate-TMCVKIGZ.js.map +0 -7
  614. /package/dist/cli-bundle/chunks/{activity-OWYSUZOY.js.map → activity-CVXTCHYY.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{aggregate-ADUOSFRO.js.map → aggregate-VNAHUNNF.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{chunk-D7AOMPRH.js.map → chunk-BQHUILZS.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{chunk-G57E5D7T.js.map → chunk-GU2ZJ2VV.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{chunk-AKOOMO3T.js.map → chunk-KAG77BY3.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{chunk-KBQY3YG5.js.map → chunk-KJ33AOCY.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{chunk-WJ2NAC37.js.map → chunk-N7ACFE26.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{chunk-PVNQLCIS.js.map → chunk-QO7EBBOM.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{chunk-A7E7PUVX.js.map → chunk-R6UFP2GE.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{chunk-CEFIVZPG.js.map → chunk-T3LC5LKB.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{chunk-JFWUHHS2.js.map → chunk-UM2GBHS4.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{chunk-SEXQN4KL.js.map → chunk-WKY2IBOQ.js.map} +0 -0
  626. /package/dist/cli-bundle/chunks/{chunk-NGN7UV5K.js.map → chunk-XLTD2HN3.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{chunk-L2FXEKDB.js.map → chunk-YL2DJGYS.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{close-XY4CSAYF.js.map → close-3HDWDA3L.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{create-PZVHRIZQ.js.map → create-JTZNCTQC.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{extension-B4WL7BQU.js.map → extension-J7IBMFTD.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{history-A2JUDXUE.js.map → history-2BA3T5AE.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{history-redact-ED6RFCPL.js.map → history-redact-JBZNXHGR.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{init-M2WUB4YH.js.map → init-HIVSNX3O.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{list-OGWQPC26.js.map → list-MUSQNMTD.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{restore-MB2ISME7.js.map → restore-D4RGNX33.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{test-VNBDRJ4Z.js.map → test-MXX3E5JL.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{test-runs-GX5HTPSF.js.map → test-runs-WMVTQU3Y.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{update-H6SCWNMA.js.map → update-YRXSUGYQ.js.map} +0 -0
@@ -1,10 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
- levenshteinDistanceWithinLimit
4
- } from "./chunks/chunk-EAOG77HM.js";
3
+ deriveTelemetryCommandResolution,
4
+ deriveTelemetryCommandTaxonomy,
5
+ emitTelemetryErrorEvent,
6
+ finishTelemetryCommand,
7
+ startTelemetryCommand
8
+ } from "./chunks/chunk-SKJWX3QB.js";
5
9
  import {
6
10
  migrateItemFilesToFormat
7
- } from "./chunks/chunk-KBQY3YG5.js";
11
+ } from "./chunks/chunk-KJ33AOCY.js";
8
12
  import {
9
13
  applyDefaultOutputFormat,
10
14
  clearResolvedGlobalOptions,
@@ -14,50 +18,49 @@ import {
14
18
  getGlobalOptions,
15
19
  invalidateSearchCachesForMutation,
16
20
  setResolvedGlobalOptions
17
- } from "./chunks/chunk-P53TN6IA.js";
21
+ } from "./chunks/chunk-PDDFYW4X.js";
18
22
  import {
19
23
  PM_CORE_COMMAND_NAMES,
20
24
  resolveSubcommandFlagContractsForCommand
21
- } from "./chunks/chunk-GN7IJPCD.js";
22
- import "./chunks/chunk-6HT2F4TK.js";
25
+ } from "./chunks/chunk-PROOHX4K.js";
26
+ import "./chunks/chunk-3FI4SEFT.js";
23
27
  import {
24
28
  printError,
25
29
  printResult,
26
30
  writeStdout
27
- } from "./chunks/chunk-5HSEP75M.js";
31
+ } from "./chunks/chunk-LCM63IXU.js";
28
32
  import {
29
- resolvePmPackageRootFromModule
30
- } from "./chunks/chunk-EGUGFSNX.js";
31
- import "./chunks/chunk-BUPWJ3IJ.js";
32
- import "./chunks/chunk-4AEZR5EJ.js";
33
- import "./chunks/chunk-CEFIVZPG.js";
34
- import "./chunks/chunk-MD7K4JYF.js";
33
+ levenshteinDistanceWithinLimit
34
+ } from "./chunks/chunk-EAOG77HM.js";
35
+ import "./chunks/chunk-XTGLRY2Y.js";
36
+ import "./chunks/chunk-T3LC5LKB.js";
37
+ import "./chunks/chunk-AO442XLN.js";
35
38
  import {
36
39
  commandOptionFlagLabel,
37
40
  resolveCommandOptionPolicyState,
38
41
  resolveItemTypeRegistry,
39
42
  resolveTypeDefinition
40
- } from "./chunks/chunk-WDPXDQFG.js";
41
- import {
42
- nowIso
43
- } from "./chunks/chunk-PVNQLCIS.js";
43
+ } from "./chunks/chunk-KJE2FOS4.js";
44
+ import "./chunks/chunk-QO7EBBOM.js";
44
45
  import {
45
46
  BUILTIN_ITEM_TYPE_VALUES,
46
47
  EXIT_CODE,
47
48
  PmCliError,
48
49
  activateExtensions,
49
- appendLineAtomic,
50
50
  asRecordOrNull,
51
51
  clearActiveExtensionHooks,
52
+ consumeAfterCommandAffectedItems,
53
+ createEmptyExtensionRegistrationRegistry,
54
+ discoverExtensions,
52
55
  getActiveCommandResult,
53
56
  getActiveExtensionRegistrations,
54
57
  getSettingsPath,
55
58
  loadExtensions,
56
59
  pathExists,
57
- readFileIfExists,
58
60
  readSettings,
59
61
  readSettingsWithMetadata,
60
62
  resolveGlobalPmRoot,
63
+ resolvePmPackageRootFromModule,
61
64
  resolvePmRoot,
62
65
  resolveRuntimeFieldRegistry,
63
66
  resolveTelemetryErrorCategory,
@@ -77,13 +80,12 @@ import {
77
80
  setActiveExtensionRenderers,
78
81
  setActiveExtensionServices,
79
82
  toNonEmptyStringOrUndefined,
80
- writeFileAtomic,
81
83
  writeSettings
82
- } from "./chunks/chunk-LSXGH6NE.js";
84
+ } from "./chunks/chunk-U5SXYXSY.js";
83
85
 
84
86
  // dist/cli/main.js
85
87
  import fs2 from "node:fs";
86
- import path3 from "node:path";
88
+ import path2 from "node:path";
87
89
  import { Command } from "commander";
88
90
 
89
91
  // dist/core/telemetry/consent.js
@@ -92,13 +94,13 @@ import { stdin as input, stdout as output } from "node:process";
92
94
  !(function() {
93
95
  try {
94
96
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
95
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "6fcbb185-889c-5474-9f02-321a53177803");
97
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "c965da5d-6609-5258-ba49-a57475f7f2ef");
96
98
  } catch (e2) {
97
99
  }
98
100
  })();
99
101
  var TELEMETRY_PROMPT_DISABLE_ENV = "PM_TELEMETRY_PROMPT";
100
102
  var TELEMETRY_PROMPT_DISABLE_VALUES = /* @__PURE__ */ new Set(["0", "false", "no", "off"]);
101
- var TELEMETRY_PROMPT_SKIPPED_COMMANDS = /* @__PURE__ */ new Set(["init", "completion", "completion-tags"]);
103
+ var TELEMETRY_PROMPT_SKIPPED_COMMANDS = /* @__PURE__ */ new Set(["init", "completion", "completion-statuses", "completion-tags", "completion-types"]);
102
104
  function parseBooleanLike(value) {
103
105
  if (typeof value !== "string") {
104
106
  return false;
@@ -132,1464 +134,45 @@ function parseTelemetryPromptAnswer(answer) {
132
134
  return true;
133
135
  }
134
136
  async function promptTelemetryConsent(currentDefault) {
135
- const defaultLabel = currentDefault ? "Y/n" : "y/N";
136
- const prompt = `pm telemetry helps improve reliability and usage diagnostics.
137
- It is enabled by default and can be changed anytime via:
138
- pm config global set telemetry-tracking --policy disabled
139
- Enable telemetry now? [${defaultLabel}] `;
140
- const rl = readline.createInterface({ input, output });
141
- try {
142
- const answer = await rl.question(prompt);
143
- if (answer.trim().length === 0) {
144
- return currentDefault;
145
- }
146
- return parseTelemetryPromptAnswer(answer);
147
- } finally {
148
- rl.close();
149
- }
150
- }
151
- async function maybeRunFirstUseTelemetryPrompt(commandPath, globalOptions) {
152
- if (shouldSkipTelemetryPrompt(commandPath, globalOptions)) {
153
- return;
154
- }
155
- try {
156
- const globalPmRoot = resolveGlobalPmRoot(process.cwd());
157
- const settings = await readSettings(globalPmRoot);
158
- if (settings.telemetry.first_run_prompt_completed) {
159
- return;
160
- }
161
- const enabled = await promptTelemetryConsent(settings.telemetry.enabled);
162
- settings.telemetry.enabled = enabled;
163
- settings.telemetry.first_run_prompt_completed = true;
164
- await writeSettings(globalPmRoot, settings, "telemetry:first_run_prompt");
165
- output.write(`Telemetry ${enabled ? "enabled" : "disabled"} for this CLI install. Update any time with pm config global set telemetry-tracking --policy ${enabled ? "disabled" : "enabled"}.
166
- `);
167
- } catch {
168
- }
169
- }
170
-
171
- // dist/core/telemetry/runtime.js
172
- import crypto from "node:crypto";
173
- import { spawn } from "node:child_process";
174
- import { mkdirSync, rmSync, statSync } from "node:fs";
175
- import { mkdir, readdir, rm, stat } from "node:fs/promises";
176
- import os from "node:os";
177
- import path from "node:path";
178
-
179
- // dist/core/telemetry/observability.js
180
- !(function() {
181
- try {
182
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
183
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "05b6b4cc-d37d-593c-b34c-b491c722d181");
184
- } catch (e2) {
185
- }
186
- })();
187
- var SETUP_ROOT_COMMANDS = /* @__PURE__ */ new Set(["init", "config", "completion", "completion-tags"]);
188
- var QUERY_ROOT_COMMANDS = /* @__PURE__ */ new Set([
189
- "list",
190
- "list-all",
191
- "list-open",
192
- "list-in-progress",
193
- "list-blocked",
194
- "list-closed",
195
- "list-canceled",
196
- "list-draft",
197
- "search",
198
- "get",
199
- "context",
200
- "calendar",
201
- "history",
202
- "activity",
203
- "aggregate",
204
- "deps",
205
- "contracts",
206
- "stats",
207
- "dedupe-audit"
208
- ]);
209
- var MUTATION_ROOT_COMMANDS = /* @__PURE__ */ new Set([
210
- "create",
211
- "update",
212
- "update-many",
213
- "append",
214
- "close",
215
- "delete",
216
- "restore",
217
- "claim",
218
- "release",
219
- "comments",
220
- "notes",
221
- "learnings",
222
- "files",
223
- "docs",
224
- "start-task",
225
- "pause-task",
226
- "close-task"
227
- ]);
228
- var TESTING_ROOT_COMMANDS = /* @__PURE__ */ new Set(["test", "test-all", "test-runs", "test-verify", "trace-test", "test-ping"]);
229
- var DIAGNOSTICS_ROOT_COMMANDS = /* @__PURE__ */ new Set(["health", "validate", "normalize", "reindex", "gc", "extension-doctor"]);
230
- function normalizeCommandPath(commandPath) {
231
- return commandPath.trim().replaceAll(/\s+/g, " ").toLowerCase();
232
- }
233
- function normalizeErrorCode(errorCode2) {
234
- const normalized = errorCode2?.trim().toLowerCase();
235
- return normalized && normalized.length > 0 ? normalized : void 0;
236
- }
237
- function deriveTelemetryCommandTaxonomy(commandPath) {
238
- const normalizedPath = normalizeCommandPath(commandPath);
239
- const tokens = normalizedPath.length > 0 ? normalizedPath.split(" ") : ["<unknown>"];
240
- const root = tokens[0] ?? "<unknown>";
241
- const leaf = tokens[tokens.length - 1] ?? root;
242
- let family = "other";
243
- if (SETUP_ROOT_COMMANDS.has(root)) {
244
- family = "setup";
245
- } else if (QUERY_ROOT_COMMANDS.has(root)) {
246
- family = "query";
247
- } else if (MUTATION_ROOT_COMMANDS.has(root)) {
248
- family = "mutation";
249
- } else if (TESTING_ROOT_COMMANDS.has(root)) {
250
- family = "testing";
251
- } else if (root === "extension") {
252
- family = "extension";
253
- } else if (DIAGNOSTICS_ROOT_COMMANDS.has(root)) {
254
- family = "diagnostics";
255
- }
256
- return {
257
- command_path: normalizedPath.length > 0 ? normalizedPath : "<unknown>",
258
- command_root: root,
259
- command_leaf: leaf,
260
- command_depth: tokens.length,
261
- command_family: family
262
- };
263
- }
264
- function inferTelemetryErrorCode(params) {
265
- if (params.ok) {
266
- return void 0;
267
- }
268
- const explicit = normalizeErrorCode(params.errorCode);
269
- if (explicit) {
270
- return explicit;
271
- }
272
- const message = (params.errorMessage ?? "").trim().toLowerCase();
273
- if (message.includes("unknown command")) {
274
- return "unknown_command";
275
- }
276
- if (message.includes("unknown option")) {
277
- return "unknown_option";
278
- }
279
- if (message.includes("missing required options") || message.includes("missing required option")) {
280
- return "missing_required_option";
281
- }
282
- if (message.includes("missing required argument")) {
283
- return "missing_required_argument";
284
- }
285
- if (message.includes("no update flags provided")) {
286
- return "no_update_fields";
287
- }
288
- if (message.includes("is assigned to") && message.includes("use --force")) {
289
- return "ownership_conflict";
290
- }
291
- if (message.includes("is locked")) {
292
- return "lock_conflict";
293
- }
294
- if (message.includes("already terminal") && message.includes("use --force")) {
295
- return "terminal_state_conflict";
296
- }
297
- if (message.includes("tracker is not initialized")) {
298
- return "tracker_not_initialized";
299
- }
300
- if (message.includes(" not found")) {
301
- return "item_not_found";
302
- }
303
- if (message.includes('use "pm close <id> <text>" to close an item') || message.includes("invalid --status value") && message.includes('"closed"')) {
304
- return "close_through_update";
305
- }
306
- if (message.startsWith("invalid ") || message.includes(" must be ") || message.includes(" requires ")) {
307
- return "invalid_argument_value";
308
- }
309
- if (message.includes("strict create mode requires concrete values for --")) {
310
- return "missing_required_option";
311
- }
312
- if (message.includes("either as positional") && message.includes("not both")) {
313
- return "invalid_command_usage";
314
- }
315
- const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode ?? 0)) : void 0;
316
- if (exitCode === EXIT_CODE.USAGE) {
317
- return "invalid_command_usage";
318
- }
319
- if (exitCode === EXIT_CODE.NOT_FOUND) {
320
- return "item_not_found";
321
- }
322
- if (exitCode === EXIT_CODE.CONFLICT) {
323
- return "lock_conflict";
324
- }
325
- if (exitCode === EXIT_CODE.DEPENDENCY_FAILED) {
326
- return "dependency_failed";
327
- }
328
- return "command_failed";
329
- }
330
- function deriveTelemetryCommandResolution(params) {
331
- if (params.ok) {
332
- return "success";
333
- }
334
- const normalizedCode = normalizeErrorCode(params.errorCode);
335
- if (normalizedCode === "unknown_command") {
336
- return "nonexistent_command";
337
- }
338
- if (normalizedCode === "unknown_option") {
339
- return "invalid_option";
340
- }
341
- if (normalizedCode === "missing_required_option") {
342
- return "missing_required_option";
343
- }
344
- if (normalizedCode === "missing_required_argument") {
345
- return "missing_required_argument";
346
- }
347
- if (normalizedCode === "health_findings") {
348
- return "health_findings";
349
- }
350
- if (normalizedCode === "validation_findings") {
351
- return "validation_findings";
352
- }
353
- if (params.errorCategory === "usage") {
354
- return "invalid_usage";
355
- }
356
- if (params.errorCategory === "validation") {
357
- return "validation_failed";
358
- }
359
- if (params.errorCategory === "conflict") {
360
- return "conflict";
361
- }
362
- if (params.errorCategory === "runtime") {
363
- return "runtime_failed";
364
- }
365
- return "unknown_failed";
366
- }
367
-
368
- // dist/core/telemetry/runtime.js
369
- !(function() {
370
- try {
371
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
372
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b2cd9110-8de0-5e79-a029-c0902f862999");
373
- } catch (e2) {
374
- }
375
- })();
376
- var TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
377
- var TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
378
- var TELEMETRY_SCHEMA_VERSION = 1;
379
- var TELEMETRY_FLUSH_BATCH_SIZE = 100;
380
- var TELEMETRY_MAX_RETRY_DELAY_MS = 36e5;
381
- var TELEMETRY_RETRY_BASE_DELAY_MS = 3e4;
382
- var TELEMETRY_HTTP_TIMEOUT_MS = 5e3;
383
- var MILLISECONDS_PER_DAY = 864e5;
384
- var TELEMETRY_MAX_EVENT_BYTES = 65536;
385
- var TELEMETRY_SANITIZE_MAX_DEPTH = 6;
386
- var TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS = 20;
387
- var TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;
388
- var TELEMETRY_RESULT_PREVIEW_MAX_BYTES = 8192;
389
- var TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS = [25, 50, 100, 200];
390
- var TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1e3;
391
- var TELEMETRY_FLUSH_LOCK_STALE_MS = 6e4;
392
- var TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS = 6e4;
393
- var OTEL_TRACES_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
394
- var OTEL_BASE_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_ENDPOINT";
395
- var OTEL_SERVICE_NAME_ENV = "OTEL_SERVICE_NAME";
396
- var PM_TELEMETRY_DISABLED_ENV = "PM_TELEMETRY_DISABLED";
397
- var PM_NO_TELEMETRY_ENV = "PM_NO_TELEMETRY";
398
- var PM_TELEMETRY_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
399
- var PM_TELEMETRY_OTEL_DISABLED_ENV = "PM_TELEMETRY_OTEL_DISABLED";
400
- var PM_TELEMETRY_OTEL_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
401
- var PM_TELEMETRY_INLINE_FLUSH_ENV = "PM_TELEMETRY_INLINE_FLUSH";
402
- var PM_TELEMETRY_FLUSH_CHILD_ENV = "PM_TELEMETRY_FLUSH_CHILD";
403
- var PM_TELEMETRY_SOURCE_CONTEXT_ENV = "PM_TELEMETRY_SOURCE_CONTEXT";
404
- var PM_TELEMETRY_SOURCE_CONTEXT_VALUES = ["user", "automation", "test", "dogfood", "audit_smoke"];
405
- var _lastFlushPromise = Promise.resolve();
406
- var _queueMutationPromise = Promise.resolve();
407
- var PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
408
- var BOOLEAN_TRUE_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
409
- var PROCESS_SESSION_ID = crypto.randomUUID();
410
- var SENSITIVE_KEYWORDS = [
411
- "token",
412
- "secret",
413
- "password",
414
- "passwd",
415
- "api_key",
416
- "apikey",
417
- "authorization",
418
- "cookie",
419
- "session",
420
- "credentials",
421
- "bearer"
422
- ];
423
- var SENSITIVE_INLINE_KEY_PATTERN = "(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer)";
424
- var INLINE_SENSITIVE_ASSIGNMENT_PATTERN = new RegExp(`\\b(${SENSITIVE_INLINE_KEY_PATTERN})\\s*([:=])\\s*([^\\s,;]+)`, "giu");
425
- var INLINE_SENSITIVE_FLAG_PATTERN = new RegExp(`(--${SENSITIVE_INLINE_KEY_PATTERN})(=|\\s+)([^\\s,;]+)`, "giu");
426
- var ABSOLUTE_PATH_TOKEN_PATTERN = /(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;
427
- var EMAIL_PATTERN = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu;
428
- var BEARER_TOKEN_PATTERN = /bearer\s+[a-z0-9._=-]+/giu;
429
- var PRIVATE_IP_PATTERN = /\b(?:10\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|172\.(?:1[6-9]|2\d|3[01])\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)|192\.168\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d)\.(?:25[0-5]|2[0-4]\d|[01]?\d?\d))\b/g;
430
- function queuePath(globalPmRoot) {
431
- return path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
432
- }
433
- function telemetryRuntimeDirectory(globalPmRoot) {
434
- return path.dirname(queuePath(globalPmRoot));
435
- }
436
- function runtimeStatePath(globalPmRoot) {
437
- return path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
438
- }
439
- function flushLockPath(globalPmRoot) {
440
- return path.join(globalPmRoot, "runtime", "telemetry", "flush.lock");
441
- }
442
- function flushSpawnLockPath(globalPmRoot) {
443
- return path.join(globalPmRoot, "runtime", "telemetry", "flush.spawn.lock");
444
- }
445
- function telemetryFlushRunnerPath() {
446
- return path.join(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]), "dist", "cli", "telemetry-flush.js");
447
- }
448
- function shouldFlushInline() {
449
- if (parseBooleanTrueLike(process.env[PM_TELEMETRY_INLINE_FLUSH_ENV])) {
450
- return true;
451
- }
452
- if (parseBooleanTrueLike(process.env[PM_TELEMETRY_FLUSH_CHILD_ENV])) {
453
- return true;
454
- }
455
- const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
456
- return typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test";
457
- }
458
- async function readRuntimeState(globalPmRoot) {
459
- const raw = await readFileIfExists(runtimeStatePath(globalPmRoot));
460
- if (!raw || raw.trim().length === 0) {
461
- return {};
462
- }
463
- try {
464
- const parsed = JSON.parse(raw);
465
- if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
466
- return {};
467
- }
468
- return parsed;
469
- } catch {
470
- return {};
471
- }
472
- }
473
- async function writeRuntimeState(globalPmRoot, patch) {
474
- try {
475
- const current = await readRuntimeState(globalPmRoot);
476
- const next = {
477
- ...current,
478
- ...patch
479
- };
480
- const normalized = Object.fromEntries(Object.entries(next).filter(([, value]) => value !== void 0).sort((left, right) => left[0].localeCompare(right[0])));
481
- await writeFileAtomic(runtimeStatePath(globalPmRoot), `${JSON.stringify(normalized, null, 2)}
482
- `);
483
- } catch {
484
- }
485
- }
486
- function isSensitiveKey(key) {
487
- const normalized = key.trim().toLowerCase().replaceAll("-", "_").replaceAll(/[^a-z0-9_]+/g, "_");
488
- const tokens = normalized.split("_").filter((token) => token.length > 0);
489
- return SENSITIVE_KEYWORDS.some((keyword) => normalized === keyword || normalized.endsWith(`_${keyword}`) || tokens.includes(keyword));
490
- }
491
- function redactInlineSensitiveAssignments(input2) {
492
- const withoutAssignments = input2.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_PATTERN, (_match, key, delimiter) => `${key}${delimiter}[redacted]`);
493
- return withoutAssignments.replaceAll(INLINE_SENSITIVE_FLAG_PATTERN, (_match, flag, delimiter) => `${flag}${delimiter}[redacted]`);
494
- }
495
- function redactAbsolutePathTokens(input2) {
496
- return input2.replaceAll(ABSOLUTE_PATH_TOKEN_PATTERN, (_match, prefix) => `${prefix}[redacted_path]`);
497
- }
498
- function sanitizeCommonSensitiveTokens(input2) {
499
- const withoutEmails = input2.replaceAll(EMAIL_PATTERN, "[redacted_email]");
500
- const withoutBearer = withoutEmails.replaceAll(BEARER_TOKEN_PATTERN, "bearer [redacted_token]");
501
- return withoutBearer.replaceAll(PRIVATE_IP_PATTERN, "[redacted_ip]");
502
- }
503
- function sanitizeStringRedacted(input2) {
504
- const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input2);
505
- const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
506
- const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
507
- const trimmed = withoutAbsolutePaths.trim();
508
- if (trimmed.startsWith("/") && trimmed.length > 1) {
509
- return "[redacted_path]";
510
- }
511
- if (withoutAbsolutePaths.length > 512) {
512
- return `${withoutAbsolutePaths.slice(0, 509)}...`;
513
- }
514
- return withoutAbsolutePaths;
515
- }
516
- function sanitizeStringMax(input2) {
517
- const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input2);
518
- const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
519
- const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
520
- const trimmed = withoutAbsolutePaths.trim();
521
- if (trimmed.startsWith("/") && trimmed.length > 1) {
522
- return "[redacted_path]";
523
- }
524
- if (withoutAbsolutePaths.length > 2048) {
525
- return `${withoutAbsolutePaths.slice(0, 2045)}...`;
526
- }
527
- return withoutAbsolutePaths;
528
- }
529
- function sanitizeString(input2, captureLevel = "redacted") {
530
- if (captureLevel === "max") {
531
- return sanitizeStringMax(input2);
532
- }
533
- return sanitizeStringRedacted(input2);
534
- }
535
- function sanitizeValue(value, keyHint, captureLevel = "redacted", depth = 0) {
536
- if (keyHint && isSensitiveKey(keyHint)) {
537
- return "[redacted]";
538
- }
539
- if (value === null || value === void 0) {
540
- return value;
541
- }
542
- if (typeof value === "string") {
543
- return sanitizeString(value, captureLevel);
544
- }
545
- if (typeof value === "number" || typeof value === "boolean") {
546
- return value;
547
- }
548
- if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
549
- return "[depth_truncated]";
550
- }
551
- if (Array.isArray(value)) {
552
- return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => sanitizeValue(entry, void 0, captureLevel, depth + 1));
553
- }
554
- if (typeof value === "object") {
555
- const record = value;
556
- const sanitized = {};
557
- for (const [key, nested] of Object.entries(record)) {
558
- sanitized[key] = sanitizeValue(nested, key, captureLevel, depth + 1);
559
- }
560
- return sanitized;
561
- }
562
- return String(value);
563
- }
564
- function sanitizeCommandArgs(args, captureLevel = "redacted") {
565
- const sanitized = [];
566
- let nextIsSensitiveValue = false;
567
- for (const rawArg of args) {
568
- const arg = sanitizeString(rawArg, captureLevel);
569
- if (nextIsSensitiveValue) {
570
- sanitized.push("[redacted]");
571
- nextIsSensitiveValue = false;
572
- continue;
573
- }
574
- if (arg.startsWith("--")) {
575
- const withoutPrefix = arg.slice(2);
576
- const delimiterIndex = withoutPrefix.indexOf("=");
577
- if (delimiterIndex >= 0) {
578
- const key = withoutPrefix.slice(0, delimiterIndex);
579
- const value = withoutPrefix.slice(delimiterIndex + 1);
580
- if (isSensitiveKey(key)) {
581
- sanitized.push(`--${key}=[redacted]`);
582
- } else {
583
- sanitized.push(`--${key}=${sanitizeString(value, captureLevel)}`);
584
- }
585
- continue;
586
- }
587
- if (isSensitiveKey(withoutPrefix)) {
588
- sanitized.push(`--${withoutPrefix}`);
589
- nextIsSensitiveValue = true;
590
- continue;
591
- }
592
- }
593
- sanitized.push(arg);
594
- }
595
- return sanitized;
596
- }
597
- function normalizeCaptureLevel(value) {
598
- const normalized = value?.trim().toLowerCase();
599
- if (normalized === "minimal" || normalized === "redacted" || normalized === "max") {
600
- return normalized;
601
- }
602
- return "redacted";
603
- }
604
- function parseBooleanTrueLike(value) {
605
- return BOOLEAN_TRUE_VALUES.has((value ?? "").trim().toLowerCase());
606
- }
607
- function normalizePmVersion(value) {
608
- const trimmed = value?.trim() ?? "";
609
- return trimmed.length > 0 ? trimmed : "0.0.0";
610
- }
611
- function normalizeTelemetryErrorCode(value) {
612
- const normalized = value?.trim();
613
- return normalized && normalized.length > 0 ? normalized : void 0;
614
- }
615
- function normalizeTelemetryExitCode(exitCode, ok) {
616
- if (Number.isFinite(exitCode)) {
617
- return Math.max(0, Math.trunc(exitCode ?? 0));
618
- }
619
- return ok ? 0 : 1;
620
- }
621
- function normalizeTelemetryErrorCategory(params) {
622
- if (params.ok) {
623
- return void 0;
624
- }
625
- if (typeof params.errorCategory === "string" && params.errorCategory.trim().length > 0) {
626
- return params.errorCategory;
627
- }
628
- if (typeof params.errorCode === "string" && params.errorCode.trim().length > 0) {
629
- return resolveTelemetryErrorCategory(params.errorCode);
630
- }
631
- return "unknown";
632
- }
633
- function resolveTelemetrySourceContext(globalOptions) {
634
- const override = (process.env[PM_TELEMETRY_SOURCE_CONTEXT_ENV] ?? "").trim().toLowerCase();
635
- if (PM_TELEMETRY_SOURCE_CONTEXT_SET.has(override)) {
636
- return {
637
- source_context: override,
638
- source_context_source: "env_override"
639
- };
640
- }
641
- const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
642
- if (typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test") {
643
- return {
644
- source_context: "test",
645
- source_context_source: "inferred"
646
- };
647
- }
648
- const nonTty = process.stdin.isTTY !== true || process.stdout.isTTY !== true;
649
- const ci = parseBooleanTrueLike(process.env.CI);
650
- const scriptLikeMode = globalOptions.json === true || globalOptions.quiet === true;
651
- if (nonTty || ci || scriptLikeMode) {
652
- return {
653
- source_context: "automation",
654
- source_context_source: "inferred"
655
- };
656
- }
657
- return {
658
- source_context: "user",
659
- source_context_source: "inferred"
660
- };
661
- }
662
- function hashWithInstallationId(installationId, value) {
663
- return crypto.createHash("sha256").update(`${installationId}:${value}`).digest("hex");
664
- }
665
- function normalizeForHash(value, depth = 0) {
666
- if (value === null || value === void 0) {
667
- return value;
668
- }
669
- if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
670
- return value;
671
- }
672
- if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
673
- return "[depth_truncated]";
674
- }
675
- if (Array.isArray(value)) {
676
- return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => normalizeForHash(entry, depth + 1));
677
- }
678
- if (typeof value === "object") {
679
- const record = value;
680
- const normalized = {};
681
- const sortedKeys = Object.keys(record).sort((left, right) => left.localeCompare(right));
682
- for (const key of sortedKeys) {
683
- normalized[key] = normalizeForHash(record[key], depth + 1);
684
- }
685
- return normalized;
686
- }
687
- return String(value);
688
- }
689
- function hashTelemetryValue(installationId, value) {
690
- return hashWithInstallationId(installationId, JSON.stringify(normalizeForHash(value)));
691
- }
692
- function hashCommandArgs(installationId, args) {
693
- return {
694
- hashes: args.map((arg) => hashWithInstallationId(installationId, arg)),
695
- digest: hashWithInstallationId(installationId, args.join("\0"))
696
- };
697
- }
698
- function hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage) {
699
- const normalizedMessage = sanitizeString(errorMessage ?? "", "redacted");
700
- const fingerprintSource = `${command}\0${errorCode2 ?? "unknown_error"}\0${normalizedMessage}`;
701
- return hashWithInstallationId(installationId, fingerprintSource);
702
- }
703
- function telemetryDisabledByEnvironment() {
704
- return PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_TELEMETRY_DISABLED_ENV] ?? "").trim().toLowerCase()) || PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_NO_TELEMETRY_ENV] ?? "").trim().toLowerCase());
705
- }
706
- function resolveOtelTracesEndpoint() {
707
- if (PM_TELEMETRY_OTEL_DISABLED_VALUES.has((process.env[PM_TELEMETRY_OTEL_DISABLED_ENV] ?? "").trim().toLowerCase())) {
708
- return null;
709
- }
710
- const directEndpoint = (process.env[OTEL_TRACES_ENDPOINT_ENV] ?? "").trim();
711
- if (directEndpoint.length > 0) {
712
- try {
713
- return new URL(directEndpoint).toString();
714
- } catch {
715
- return null;
716
- }
717
- }
718
- const baseEndpoint = (process.env[OTEL_BASE_ENDPOINT_ENV] ?? "").trim();
719
- if (baseEndpoint.length === 0) {
720
- return null;
721
- }
722
- try {
723
- const url = new URL(baseEndpoint);
724
- const normalizedPath = url.pathname.replace(/\/+$/, "");
725
- if (!normalizedPath.endsWith("/v1/traces")) {
726
- url.pathname = `${normalizedPath.length === 0 ? "" : normalizedPath}/v1/traces`;
727
- }
728
- return url.toString();
729
- } catch {
730
- return null;
731
- }
732
- }
733
- function isoToUnixNano(iso) {
734
- const parsedMs = Date.parse(iso);
735
- const epochMs = Number.isNaN(parsedMs) ? Date.now() : parsedMs;
736
- return `${BigInt(epochMs) * 1000000n}`;
737
- }
738
- function otlpStringAttribute(key, value) {
739
- return {
740
- key,
741
- value: { stringValue: value }
742
- };
743
- }
744
- function otlpBoolAttribute(key, value) {
745
- return {
746
- key,
747
- value: { boolValue: value }
748
- };
749
- }
750
- function otlpIntAttribute(key, value) {
751
- return {
752
- key,
753
- value: { intValue: String(Math.max(0, Math.trunc(value))) }
754
- };
755
- }
756
- async function exportLocalOtelSpan(activeCommand, outcome, finishedAtIso, durationMs) {
757
- if (typeof activeCommand.otel_traces_endpoint !== "string" || activeCommand.otel_traces_endpoint.trim().length === 0 || typeof activeCommand.otel_trace_id !== "string" || activeCommand.otel_trace_id.length === 0 || typeof activeCommand.otel_span_id !== "string" || activeCommand.otel_span_id.length === 0) {
758
- return;
759
- }
760
- const serviceNameCandidate = sanitizeString((process.env[OTEL_SERVICE_NAME_ENV] ?? "").trim());
761
- const serviceName = serviceNameCandidate.length > 0 ? serviceNameCandidate : "pm-cli";
762
- const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
763
- const normalizedErrorCode = normalizeTelemetryErrorCode(outcome.error_code);
764
- const normalizedErrorCategory = normalizeTelemetryErrorCategory({
765
- ok: outcome.ok,
766
- errorCode: normalizedErrorCode,
767
- errorCategory: outcome.error_category
768
- });
769
- const attributes = [
770
- otlpStringAttribute("pm.command", sanitizeString(activeCommand.command)),
771
- otlpStringAttribute("pm.version", activeCommand.pm_version),
772
- otlpStringAttribute("pm.source_context", activeCommand.source_context),
773
- otlpStringAttribute("pm.source_context_source", activeCommand.source_context_source),
774
- otlpStringAttribute("pm.installation_id", activeCommand.installation_id),
775
- otlpStringAttribute("pm.session_id", PROCESS_SESSION_ID),
776
- otlpStringAttribute("pm.pm_root_hash", activeCommand.pm_root_hash),
777
- otlpStringAttribute("pm.cwd_hash", activeCommand.cwd_hash),
778
- otlpBoolAttribute("pm.ok", outcome.ok),
779
- otlpIntAttribute("pm.exit_code", normalizedExitCode),
780
- otlpIntAttribute("pm.duration_ms", durationMs)
781
- ];
782
- if (typeof normalizedErrorCode === "string") {
783
- attributes.push(otlpStringAttribute("pm.error_code", normalizedErrorCode));
784
- }
785
- if (typeof normalizedErrorCategory === "string") {
786
- attributes.push(otlpStringAttribute("pm.error_category", normalizedErrorCategory));
787
- }
788
- if (typeof outcome.error === "string" && outcome.error.trim().length > 0) {
789
- attributes.push(otlpStringAttribute("pm.error", sanitizeString(outcome.error)));
790
- }
791
- const payload = {
792
- resourceSpans: [
793
- {
794
- resource: {
795
- attributes: [otlpStringAttribute("service.name", serviceName)]
796
- },
797
- scopeSpans: [
798
- {
799
- scope: {
800
- name: "pm-cli.telemetry",
801
- version: "1"
802
- },
803
- spans: [
804
- {
805
- traceId: activeCommand.otel_trace_id,
806
- spanId: activeCommand.otel_span_id,
807
- name: `pm.command.${sanitizeString(activeCommand.command)}`,
808
- kind: 1,
809
- startTimeUnixNano: isoToUnixNano(activeCommand.started_at),
810
- endTimeUnixNano: isoToUnixNano(finishedAtIso),
811
- attributes,
812
- status: {
813
- code: outcome.ok ? 1 : 2,
814
- message: outcome.ok ? "" : sanitizeString(outcome.error ?? "command_failed")
815
- }
816
- }
817
- ]
818
- }
819
- ]
820
- }
821
- ]
822
- };
823
- const response = await fetch(activeCommand.otel_traces_endpoint, {
824
- method: "POST",
825
- headers: {
826
- "content-type": "application/json"
827
- },
828
- body: JSON.stringify(payload),
829
- signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
830
- });
831
- if (!response.ok) {
832
- throw new Error(`local_otel_export_http_${response.status}`);
833
- }
834
- }
835
- function summarizeResult(result, captureLevel = "redacted") {
836
- if (result === null || result === void 0) {
837
- return { type: "nullish" };
838
- }
839
- if (typeof result === "string") {
840
- return { type: "string", value: sanitizeString(result, captureLevel) };
841
- }
842
- if (typeof result === "number" || typeof result === "boolean") {
843
- return { type: typeof result, value: result };
844
- }
845
- if (Array.isArray(result)) {
846
- return {
847
- type: "array",
848
- length: result.length,
849
- sample: result.slice(0, 5).map((entry) => sanitizeValue(entry, void 0, captureLevel))
850
- };
851
- }
852
- if (typeof result === "object") {
853
- const record = result;
854
- const keys = Object.keys(record).sort((left, right) => left.localeCompare(right));
855
- const sanitized = {};
856
- let previewBytes = 0;
857
- for (const key of keys.slice(0, 25)) {
858
- const sanitizedValue = sanitizeValue(record[key], key, captureLevel);
859
- const entrySize = JSON.stringify(sanitizedValue)?.length ?? 0;
860
- if (previewBytes + entrySize > TELEMETRY_RESULT_PREVIEW_MAX_BYTES) {
861
- sanitized[key] = "[preview_truncated]";
862
- break;
863
- }
864
- previewBytes += entrySize;
865
- sanitized[key] = sanitizedValue;
866
- }
867
- return {
868
- type: "object",
869
- key_count: keys.length,
870
- keys_preview: keys.slice(0, 50),
871
- preview: sanitized
872
- };
873
- }
874
- return { type: typeof result, value: String(result) };
875
- }
876
- function buildCommandStartPayload(params) {
877
- const { captureLevel, context, pmVersion, sourceContext, pmRootHash, cwdHash, installationId } = params;
878
- const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
879
- const hashedArgs = hashCommandArgs(installationId, context.args);
880
- const commandInvocationDigest = hashWithInstallationId(installationId, `${context.command}\0${context.args.join("\0")}`);
881
- const commandOptionsDigest = hashTelemetryValue(installationId, context.options);
882
- const globalOptionsDigest = hashTelemetryValue(installationId, context.global);
883
- if (captureLevel === "minimal") {
884
- return {
885
- capture_level: captureLevel,
886
- pm_version: pmVersion,
887
- source_context: sourceContext.source_context,
888
- source_context_source: sourceContext.source_context_source,
889
- command_taxonomy: commandTaxonomy,
890
- command_args_digest: hashedArgs.digest,
891
- command_invocation_digest: commandInvocationDigest,
892
- command_options_digest: commandOptionsDigest,
893
- global_options_digest: globalOptionsDigest
894
- };
895
- }
896
- return {
897
- pm_version: pmVersion,
898
- source_context: sourceContext.source_context,
899
- source_context_source: sourceContext.source_context_source,
900
- command_taxonomy: commandTaxonomy,
901
- command_args: sanitizeCommandArgs(context.args, captureLevel),
902
- command_args_hashes: hashedArgs.hashes,
903
- command_args_digest: hashedArgs.digest,
904
- command_invocation_digest: commandInvocationDigest,
905
- command_options: sanitizeValue(context.options, void 0, captureLevel),
906
- command_options_digest: commandOptionsDigest,
907
- global_options: sanitizeValue(context.global, void 0, captureLevel),
908
- global_options_digest: globalOptionsDigest,
909
- pm_root_hash: pmRootHash,
910
- cwd_hash: cwdHash,
911
- capture_level: captureLevel,
912
- runtime: {
913
- node: process.version,
914
- platform: process.platform,
915
- arch: process.arch,
916
- hostname_hash: hashWithInstallationId(installationId, os.hostname()),
917
- stdin_tty: process.stdin.isTTY === true,
918
- stdout_tty: process.stdout.isTTY === true
919
- }
920
- };
921
- }
922
- function buildCommandFinishPayload(params) {
923
- const { captureLevel, pmVersion, sourceContext, outcome, durationMs, startedAt, command, installationId, commandTaxonomy, exitCode, errorCode: errorCode2, errorCategory, commandResolution, resolutionStage } = params;
924
- const errorFingerprint = outcome.ok === false ? hashTelemetryErrorFingerprint(installationId, command, errorCode2, outcome.error) : void 0;
925
- if (captureLevel === "minimal") {
926
- return {
927
- capture_level: captureLevel,
928
- pm_version: pmVersion,
929
- source_context: sourceContext.source_context,
930
- source_context_source: sourceContext.source_context_source,
931
- command_taxonomy: commandTaxonomy,
932
- command_resolution: commandResolution,
933
- resolution_stage: resolutionStage,
934
- ok: outcome.ok,
935
- exit_code: exitCode,
936
- error_code: errorCode2,
937
- error_category: errorCategory,
938
- error: outcome.error ? sanitizeString(outcome.error, "redacted") : void 0,
939
- error_fingerprint: errorFingerprint,
940
- duration_ms: durationMs
941
- };
942
- }
943
- return {
944
- capture_level: captureLevel,
945
- pm_version: pmVersion,
946
- source_context: sourceContext.source_context,
947
- source_context_source: sourceContext.source_context_source,
948
- command_taxonomy: commandTaxonomy,
949
- command_resolution: commandResolution,
950
- resolution_stage: resolutionStage,
951
- ok: outcome.ok,
952
- exit_code: exitCode,
953
- error_code: errorCode2,
954
- error_category: errorCategory,
955
- error: outcome.error ? sanitizeString(outcome.error, captureLevel) : void 0,
956
- error_fingerprint: errorFingerprint,
957
- duration_ms: durationMs,
958
- started_at: startedAt,
959
- result_summary: summarizeResult(outcome.result, captureLevel)
960
- };
961
- }
962
- function buildCommandErrorPayload(params) {
963
- const { captureLevel, pmVersion, sourceContext, command, commandTaxonomy, commandResolution, resolutionStage, args, options, pmRootHash, cwdHash, installationId, errorCode: errorCode2, errorMessage, errorCategory, exitCode } = params;
964
- const attemptedArgHashes = hashCommandArgs(installationId, args);
965
- const attemptedCommandDigest = hashWithInstallationId(installationId, command);
966
- const attemptedOptionsDigest = hashTelemetryValue(installationId, options);
967
- const errorFingerprint = hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage);
968
- if (captureLevel === "minimal") {
969
- return {
970
- capture_level: captureLevel,
971
- pm_version: pmVersion,
972
- source_context: sourceContext.source_context,
973
- source_context_source: sourceContext.source_context_source,
974
- command_taxonomy: commandTaxonomy,
975
- command_resolution: commandResolution,
976
- resolution_stage: resolutionStage,
977
- attempted_command_digest: attemptedCommandDigest,
978
- attempted_args_digest: attemptedArgHashes.digest,
979
- attempted_options_digest: attemptedOptionsDigest,
980
- error_code: errorCode2,
981
- error_category: errorCategory,
982
- exit_code: exitCode,
983
- error: sanitizeString(errorMessage, "redacted"),
984
- error_fingerprint: errorFingerprint
985
- };
986
- }
987
- return {
988
- capture_level: captureLevel,
989
- pm_version: pmVersion,
990
- source_context: sourceContext.source_context,
991
- source_context_source: sourceContext.source_context_source,
992
- command_taxonomy: commandTaxonomy,
993
- command_resolution: commandResolution,
994
- resolution_stage: resolutionStage,
995
- attempted_command: sanitizeString(command, captureLevel),
996
- attempted_command_digest: attemptedCommandDigest,
997
- attempted_args: sanitizeCommandArgs(args, captureLevel),
998
- attempted_args_hashes: attemptedArgHashes.hashes,
999
- attempted_args_digest: attemptedArgHashes.digest,
1000
- attempted_options: sanitizeValue(options, void 0, captureLevel),
1001
- attempted_options_digest: attemptedOptionsDigest,
1002
- error_code: errorCode2,
1003
- error_category: errorCategory,
1004
- exit_code: exitCode,
1005
- error: sanitizeString(errorMessage, captureLevel),
1006
- error_fingerprint: errorFingerprint,
1007
- pm_root_hash: pmRootHash,
1008
- cwd_hash: cwdHash,
1009
- runtime: {
1010
- node: process.version,
1011
- platform: process.platform,
1012
- arch: process.arch,
1013
- hostname_hash: hashWithInstallationId(installationId, os.hostname()),
1014
- stdin_tty: process.stdin.isTTY === true,
1015
- stdout_tty: process.stdout.isTTY === true
1016
- }
1017
- };
1018
- }
1019
- async function ensureInstallationId(globalPmRoot) {
1020
- const settings = await readSettings(globalPmRoot);
1021
- let changed = false;
1022
- if (settings.telemetry.installation_id.trim().length === 0) {
1023
- settings.telemetry.installation_id = crypto.randomUUID();
1024
- changed = true;
1025
- }
1026
- if (changed) {
1027
- await writeSettings(globalPmRoot, settings, "telemetry:install_id");
1028
- }
1029
- return {
1030
- installationId: settings.telemetry.installation_id,
1031
- endpoint: settings.telemetry.endpoint,
1032
- retentionDays: Math.max(1, Math.trunc(settings.telemetry.retention_days))
1033
- };
1034
- }
1035
- async function enqueueTelemetryEvent(globalPmRoot, event) {
1036
- const queued = {
1037
- event,
1038
- attempts: 0
1039
- };
1040
- let serialized = JSON.stringify(queued);
1041
- if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {
1042
- const trimmed = { ...event, payload: { ...event.payload, result_summary: { truncated: true, reason: "payload_size_exceeded", original_bytes: serialized.length } } };
1043
- const trimmedQueued = { event: trimmed, attempts: 0 };
1044
- serialized = JSON.stringify(trimmedQueued);
1045
- }
1046
- await withQueueMutation(async () => {
1047
- await appendLineAtomic(queuePath(globalPmRoot), serialized);
1048
- });
1049
- }
1050
- function parseQueueLines(raw) {
1051
- const entries = [];
1052
- for (const line of raw.split("\n")) {
1053
- const trimmed = line.trim();
1054
- if (trimmed.length === 0) {
1055
- continue;
1056
- }
1057
- try {
1058
- const parsed = JSON.parse(trimmed);
1059
- if (parsed && typeof parsed === "object" && parsed.event && typeof parsed.event === "object" && typeof parsed.attempts === "number") {
1060
- entries.push(parsed);
1061
- }
1062
- } catch {
1063
- }
1064
- }
1065
- return entries;
1066
- }
1067
- function nextRetryIso(attempts) {
1068
- const delay = Math.min(TELEMETRY_RETRY_BASE_DELAY_MS * 2 ** Math.max(attempts - 1, 0), TELEMETRY_MAX_RETRY_DELAY_MS);
1069
- return new Date(Date.now() + delay).toISOString();
1070
- }
1071
- function isDueForRetry(entry) {
1072
- if (typeof entry.next_attempt_after !== "string" || entry.next_attempt_after.trim().length === 0) {
1073
- return true;
1074
- }
1075
- const dueAtMs = Date.parse(entry.next_attempt_after);
1076
- if (Number.isNaN(dueAtMs)) {
1077
- return true;
1078
- }
1079
- return dueAtMs <= Date.now();
1080
- }
1081
- function retentionCutoffMs(retentionDays) {
1082
- const normalizedDays = Number.isFinite(retentionDays) ? Math.max(1, Math.trunc(retentionDays)) : 1;
1083
- return Date.now() - normalizedDays * MILLISECONDS_PER_DAY;
1084
- }
1085
- function isExpiredQueueEntry(entry, cutoffMs) {
1086
- const occurredAt = entry.event?.occurred_at;
1087
- if (typeof occurredAt !== "string" || occurredAt.trim().length === 0) {
1088
- return false;
1089
- }
1090
- const occurredAtMs = Date.parse(occurredAt);
1091
- if (Number.isNaN(occurredAtMs)) {
1092
- return false;
1093
- }
1094
- return occurredAtMs < cutoffMs;
1095
- }
1096
- function pruneExpiredQueueEntries(entries, retentionDays) {
1097
- const cutoffMs = retentionCutoffMs(retentionDays);
1098
- const retained = [];
1099
- let prunedCount = 0;
1100
- for (const entry of entries) {
1101
- const serializedSize = JSON.stringify(entry).length;
1102
- const oversized = serializedSize > TELEMETRY_MAX_EVENT_BYTES;
1103
- if (oversized || isExpiredQueueEntry(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {
1104
- prunedCount += 1;
1105
- continue;
1106
- }
1107
- retained.push(entry);
1108
- }
1109
- return { entries: retained, prunedCount };
1110
- }
1111
- async function rewriteQueue(globalPmRoot, entries) {
1112
- const serialized = entries.map((entry) => JSON.stringify(entry)).join("\n");
1113
- const contents = serialized.length > 0 ? `${serialized}
1114
- ` : "";
1115
- for (let attempt = 0; ; attempt += 1) {
1116
- try {
1117
- await writeFileAtomic(queuePath(globalPmRoot), contents);
1118
- return;
1119
- } catch (error) {
1120
- const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];
1121
- if (retryDelay === void 0 || !isRetryableQueueRewriteError(error)) {
1122
- throw error;
1123
- }
1124
- await sleep(retryDelay);
1125
- }
1126
- }
1127
- }
1128
- function isRetryableQueueRewriteError(error) {
1129
- if (typeof error !== "object" || error === null || !("code" in error)) {
1130
- return false;
1131
- }
1132
- const code = error.code;
1133
- return code === "EACCES" || code === "EBUSY" || code === "EPERM";
1134
- }
1135
- function sleep(milliseconds) {
1136
- return new Promise((resolve) => {
1137
- setTimeout(resolve, milliseconds);
1138
- });
1139
- }
1140
- async function cleanupTelemetryQueueTempOrphans(globalPmRoot, maxAgeMs = TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS) {
1141
- try {
1142
- const dirPath = telemetryRuntimeDirectory(globalPmRoot);
1143
- const entries = await readdir(dirPath, { withFileTypes: true });
1144
- const cutoffMs = Date.now() - Math.max(0, maxAgeMs);
1145
- await Promise.all(entries.filter((entry) => entry.isFile() && /^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(entry.name)).map(async (entry) => {
1146
- const candidate = path.join(dirPath, entry.name);
1147
- const candidateStats = await stat(candidate);
1148
- if (candidateStats.mtimeMs < cutoffMs) {
1149
- await rm(candidate, { force: true });
1150
- }
1151
- }));
1152
- } catch {
1153
- }
1154
- }
1155
- async function withQueueMutation(operation) {
1156
- const run = _queueMutationPromise.catch(() => {
1157
- }).then(operation);
1158
- _queueMutationPromise = run.catch(() => {
1159
- });
1160
- return run;
1161
- }
1162
- async function readCurrentQueueEntries(globalPmRoot) {
1163
- const raw = await readFileIfExists(queuePath(globalPmRoot));
1164
- if (raw === null || raw.trim().length === 0) {
1165
- return [];
1166
- }
1167
- return parseQueueLines(raw);
1168
- }
1169
- async function removeFlushedEntriesFromCurrentQueue(globalPmRoot, flushedIds, retentionDays) {
1170
- return withQueueMutation(async () => {
1171
- const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1172
- const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1173
- const remaining = retainedEntries.filter((entry) => !flushedIds.has(entry.event.event_id));
1174
- await rewriteQueue(globalPmRoot, remaining);
1175
- return remaining;
1176
- });
1177
- }
1178
- async function markFailedEntriesInCurrentQueue(globalPmRoot, failedIds, attemptTime, retentionDays) {
1179
- return withQueueMutation(async () => {
1180
- const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1181
- const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1182
- const retried = retainedEntries.map((entry) => {
1183
- if (!failedIds.has(entry.event.event_id)) {
1184
- return entry;
1185
- }
1186
- const attempts = entry.attempts + 1;
1187
- return {
1188
- ...entry,
1189
- attempts,
1190
- last_attempt_at: attemptTime,
1191
- next_attempt_after: nextRetryIso(attempts)
1192
- };
1193
- });
1194
- await rewriteQueue(globalPmRoot, retried);
1195
- return retried;
1196
- });
1197
- }
1198
- async function flushQueue(globalPmRoot, endpoint, retentionDays) {
1199
- await cleanupTelemetryQueueTempOrphans(globalPmRoot);
1200
- const normalizedEndpoint = endpoint.trim();
1201
- if (normalizedEndpoint.length === 0) {
1202
- return;
1203
- }
1204
- const raw = await readFileIfExists(queuePath(globalPmRoot));
1205
- if (raw === null || raw.trim().length === 0) {
1206
- await writeRuntimeState(globalPmRoot, {
1207
- endpoint: normalizedEndpoint,
1208
- queue_entries: 0
1209
- });
1210
- return;
1211
- }
1212
- const queueEntries = parseQueueLines(raw);
1213
- if (queueEntries.length === 0) {
1214
- await writeRuntimeState(globalPmRoot, {
1215
- endpoint: normalizedEndpoint,
1216
- queue_entries: 0
1217
- });
1218
- return;
1219
- }
1220
- const { entries: retainedEntries, prunedCount } = pruneExpiredQueueEntries(queueEntries, retentionDays);
1221
- if (retainedEntries.length === 0) {
1222
- if (prunedCount > 0) {
1223
- await rewriteQueue(globalPmRoot, []);
1224
- }
1225
- await writeRuntimeState(globalPmRoot, {
1226
- endpoint: normalizedEndpoint,
1227
- queue_entries: 0
1228
- });
1229
- return;
1230
- }
1231
- const dueEntries = retainedEntries.filter((entry) => isDueForRetry(entry)).slice(0, TELEMETRY_FLUSH_BATCH_SIZE);
1232
- if (dueEntries.length === 0) {
1233
- if (prunedCount > 0) {
1234
- await rewriteQueue(globalPmRoot, retainedEntries);
1235
- }
1236
- await writeRuntimeState(globalPmRoot, {
1237
- endpoint: normalizedEndpoint,
1238
- queue_entries: retainedEntries.length
1239
- });
1240
- return;
1241
- }
1242
- const dueIds = new Set(dueEntries.map((entry) => entry.event.event_id));
1243
- const attemptTime = nowIso();
1244
- const requestHeaders = {
1245
- "content-type": "application/json"
1246
- };
1247
- const ingestKey = process.env.PM_TELEMETRY_INGEST_KEY?.trim();
1248
- if (ingestKey) {
1249
- requestHeaders["x-pm-telemetry-key"] = ingestKey;
1250
- }
1251
- try {
1252
- const response = await fetch(normalizedEndpoint, {
1253
- method: "POST",
1254
- headers: requestHeaders,
1255
- body: JSON.stringify({
1256
- schema_version: TELEMETRY_SCHEMA_VERSION,
1257
- events: dueEntries.map((entry) => entry.event)
1258
- }),
1259
- signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
1260
- });
1261
- if (!response.ok) {
1262
- throw new Error(`telemetry_flush_http_${response.status}`);
1263
- }
1264
- } catch (error) {
1265
- const retried = await markFailedEntriesInCurrentQueue(globalPmRoot, dueIds, attemptTime, retentionDays);
1266
- const errorMessage = (() => {
1267
- if (error instanceof Error) {
1268
- return sanitizeString(error.message, "redacted");
1269
- }
1270
- return "telemetry_flush_failed";
1271
- })();
1272
- await writeRuntimeState(globalPmRoot, {
1273
- endpoint: normalizedEndpoint,
1274
- queue_entries: retried.length,
1275
- last_attempted_flush_at: attemptTime,
1276
- last_failed_flush_at: attemptTime,
1277
- last_failed_flush_error: errorMessage
1278
- });
1279
- return;
1280
- }
1281
- try {
1282
- const remaining = await removeFlushedEntriesFromCurrentQueue(globalPmRoot, dueIds, retentionDays);
1283
- await writeRuntimeState(globalPmRoot, {
1284
- endpoint: normalizedEndpoint,
1285
- queue_entries: remaining.length,
1286
- last_attempted_flush_at: attemptTime,
1287
- last_successful_flush_at: attemptTime,
1288
- last_failed_flush_at: void 0,
1289
- last_failed_flush_error: void 0
1290
- });
1291
- } catch (error) {
1292
- const errorMessage = (() => {
1293
- if (error instanceof Error) {
1294
- return sanitizeString(error.message, "redacted");
1295
- }
1296
- return "telemetry_flush_failed";
1297
- })();
1298
- const currentEntries = await readCurrentQueueEntries(globalPmRoot).catch(() => retainedEntries);
1299
- await writeRuntimeState(globalPmRoot, {
1300
- endpoint: normalizedEndpoint,
1301
- queue_entries: currentEntries.length,
1302
- last_attempted_flush_at: attemptTime,
1303
- last_failed_flush_at: attemptTime,
1304
- last_failed_flush_error: errorMessage
1305
- });
1306
- }
1307
- }
1308
- function isFreshDirectoryLock(lockPath, staleMs) {
1309
- try {
1310
- return Date.now() - statSync(lockPath).mtimeMs < staleMs;
1311
- } catch {
1312
- return false;
1313
- }
1314
- }
1315
- function removeDirectoryLockBestEffort(lockPath) {
1316
- try {
1317
- rmSync(lockPath, { recursive: true, force: true });
1318
- } catch {
1319
- }
1320
- }
1321
- function errorCode(error) {
1322
- if (typeof error !== "object" || error === null || !("code" in error)) {
1323
- return void 0;
1324
- }
1325
- const code = error.code;
1326
- return typeof code === "string" ? code : void 0;
1327
- }
1328
- function createDirectoryLock(lockPath) {
1329
- try {
1330
- mkdirSync(lockPath);
1331
- return true;
1332
- } catch (error) {
1333
- const code = errorCode(error);
1334
- if (code === "EEXIST") {
1335
- return false;
1336
- }
1337
- if (code !== "ENOENT") {
1338
- return false;
1339
- }
1340
- }
1341
- try {
1342
- mkdirSync(path.dirname(lockPath), { recursive: true });
1343
- mkdirSync(lockPath);
1344
- return true;
1345
- } catch {
1346
- return false;
1347
- }
1348
- }
1349
- function acquireTelemetryFlushSpawnGate(globalPmRoot) {
1350
- if (isFreshDirectoryLock(flushLockPath(globalPmRoot), TELEMETRY_FLUSH_LOCK_STALE_MS)) {
1351
- return false;
1352
- }
1353
- const lockPath = flushSpawnLockPath(globalPmRoot);
1354
- try {
1355
- if (Date.now() - statSync(lockPath).mtimeMs < TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS) {
1356
- return false;
1357
- }
1358
- removeDirectoryLockBestEffort(lockPath);
1359
- } catch (error) {
1360
- if (errorCode(error) !== "ENOENT") {
1361
- return false;
1362
- }
1363
- }
1364
- return createDirectoryLock(lockPath);
1365
- }
1366
- function releaseTelemetryFlushSpawnGate(globalPmRoot) {
1367
- removeDirectoryLockBestEffort(flushSpawnLockPath(globalPmRoot));
1368
- }
1369
- function scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays) {
1370
- if (shouldFlushInline()) {
1371
- const previousFlush = _lastFlushPromise;
1372
- const nextFlush = flushQueue(globalPmRoot, endpoint, retentionDays).catch(() => {
1373
- });
1374
- _lastFlushPromise = Promise.allSettled([previousFlush, nextFlush]).then(() => {
1375
- });
1376
- return;
1377
- }
1378
- try {
1379
- const acquiredSpawnGate = acquireTelemetryFlushSpawnGate(globalPmRoot);
1380
- if (!acquiredSpawnGate) {
1381
- return;
1382
- }
1383
- const child = spawn(process.execPath, [telemetryFlushRunnerPath()], {
1384
- detached: true,
1385
- stdio: "ignore",
1386
- env: {
1387
- ...process.env,
1388
- PM_GLOBAL_PATH: globalPmRoot,
1389
- [PM_TELEMETRY_FLUSH_CHILD_ENV]: "1"
1390
- }
1391
- });
1392
- child.unref();
1393
- } catch {
1394
- releaseTelemetryFlushSpawnGate(globalPmRoot);
1395
- }
1396
- }
1397
- async function startTelemetryCommand(context) {
1398
- if (telemetryDisabledByEnvironment()) {
1399
- return null;
1400
- }
1401
- try {
1402
- const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1403
- const settings = await readSettings(globalPmRoot);
1404
- if (!settings.telemetry.enabled) {
1405
- return null;
1406
- }
1407
- const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1408
- const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1409
- const pmVersion = normalizePmVersion(context.pm_version);
1410
- const sourceContext = resolveTelemetrySourceContext(context.global);
1411
- const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1412
- const cwdHash = hashWithInstallationId(installationId, process.cwd());
1413
- const otelTracesEndpoint = resolveOtelTracesEndpoint();
1414
- const occurredAt = nowIso();
1415
- const event = {
1416
- schema_version: TELEMETRY_SCHEMA_VERSION,
1417
- event_id: crypto.randomUUID(),
1418
- event_type: "command_start",
1419
- occurred_at: occurredAt,
1420
- installation_id: installationId,
1421
- session_id: PROCESS_SESSION_ID,
1422
- command: context.command,
1423
- payload: buildCommandStartPayload({
1424
- captureLevel,
1425
- context,
1426
- pmVersion,
1427
- sourceContext,
1428
- pmRootHash,
1429
- cwdHash,
1430
- installationId
1431
- })
1432
- };
1433
- await enqueueTelemetryEvent(globalPmRoot, event);
1434
- scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
1435
- const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
1436
- return {
1437
- started_at: occurredAt,
1438
- started_at_ms: Date.now(),
1439
- command: context.command,
1440
- command_taxonomy: commandTaxonomy,
1441
- pm_version: pmVersion,
1442
- source_context: sourceContext.source_context,
1443
- source_context_source: sourceContext.source_context_source,
1444
- installation_id: installationId,
1445
- pm_root_hash: pmRootHash,
1446
- cwd_hash: cwdHash,
1447
- endpoint,
1448
- retention_days: retentionDays,
1449
- global_pm_root: globalPmRoot,
1450
- capture_level: captureLevel,
1451
- otel_traces_endpoint: otelTracesEndpoint ?? void 0,
1452
- otel_trace_id: otelTracesEndpoint ? crypto.randomBytes(16).toString("hex") : void 0,
1453
- otel_span_id: otelTracesEndpoint ? crypto.randomBytes(8).toString("hex") : void 0
1454
- };
1455
- } catch {
1456
- return null;
1457
- }
1458
- }
1459
- async function finishTelemetryCommand(activeCommand, outcome) {
1460
- if (!activeCommand) {
1461
- return;
1462
- }
137
+ const defaultLabel = currentDefault ? "Y/n" : "y/N";
138
+ const prompt = `pm telemetry helps improve reliability and usage diagnostics.
139
+ It is enabled by default and can be changed anytime via:
140
+ pm config global set telemetry-tracking --policy disabled
141
+ Enable telemetry now? [${defaultLabel}] `;
142
+ const rl = readline.createInterface({ input, output });
1463
143
  try {
1464
- const finishedAt = nowIso();
1465
- const durationMs = Math.max(0, Date.now() - activeCommand.started_at_ms);
1466
- const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1467
- ok: outcome.ok,
1468
- errorCode: outcome.error_code,
1469
- errorMessage: outcome.error,
1470
- exitCode: outcome.exit_code
1471
- }));
1472
- const normalizedErrorCategory = normalizeTelemetryErrorCategory({
1473
- ok: outcome.ok,
1474
- errorCode: normalizedErrorCode,
1475
- errorCategory: outcome.error_category
1476
- });
1477
- const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
1478
- const commandResolution = outcome.command_resolution ?? deriveTelemetryCommandResolution({
1479
- ok: outcome.ok,
1480
- errorCode: normalizedErrorCode,
1481
- errorCategory: normalizedErrorCategory
1482
- });
1483
- const resolutionStage = outcome.resolution_stage ?? "execute";
1484
- const event = {
1485
- schema_version: TELEMETRY_SCHEMA_VERSION,
1486
- event_id: crypto.randomUUID(),
1487
- event_type: "command_finish",
1488
- occurred_at: finishedAt,
1489
- installation_id: activeCommand.installation_id,
1490
- session_id: PROCESS_SESSION_ID,
1491
- command: activeCommand.command,
1492
- payload: buildCommandFinishPayload({
1493
- captureLevel: activeCommand.capture_level,
1494
- pmVersion: activeCommand.pm_version,
1495
- sourceContext: {
1496
- source_context: activeCommand.source_context,
1497
- source_context_source: activeCommand.source_context_source
1498
- },
1499
- outcome,
1500
- durationMs,
1501
- startedAt: activeCommand.started_at,
1502
- command: activeCommand.command,
1503
- installationId: activeCommand.installation_id,
1504
- commandTaxonomy: activeCommand.command_taxonomy,
1505
- exitCode: normalizedExitCode,
1506
- errorCode: normalizedErrorCode,
1507
- errorCategory: normalizedErrorCategory,
1508
- commandResolution,
1509
- resolutionStage
1510
- })
1511
- };
1512
- await enqueueTelemetryEvent(activeCommand.global_pm_root, event);
1513
- scheduleTelemetryFlush(activeCommand.global_pm_root, activeCommand.endpoint, activeCommand.retention_days);
1514
- void exportLocalOtelSpan(activeCommand, {
1515
- ...outcome,
1516
- exit_code: normalizedExitCode,
1517
- error_code: normalizedErrorCode,
1518
- error_category: normalizedErrorCategory
1519
- }, finishedAt, durationMs).catch(() => {
1520
- });
1521
- } catch {
144
+ const answer = await rl.question(prompt);
145
+ if (answer.trim().length === 0) {
146
+ return currentDefault;
147
+ }
148
+ return parseTelemetryPromptAnswer(answer);
149
+ } finally {
150
+ rl.close();
1522
151
  }
1523
152
  }
1524
- async function emitTelemetryErrorEvent(context) {
1525
- if (telemetryDisabledByEnvironment()) {
153
+ async function maybeRunFirstUseTelemetryPrompt(commandPath, globalOptions) {
154
+ if (shouldSkipTelemetryPrompt(commandPath, globalOptions)) {
1526
155
  return;
1527
156
  }
1528
157
  try {
1529
158
  const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1530
159
  const settings = await readSettings(globalPmRoot);
1531
- if (!settings.telemetry.enabled) {
160
+ if (settings.telemetry.first_run_prompt_completed) {
1532
161
  return;
1533
162
  }
1534
- const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1535
- const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1536
- const pmVersion = normalizePmVersion(context.pm_version);
1537
- const sourceContext = resolveTelemetrySourceContext(context.global);
1538
- const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1539
- const cwdHash = hashWithInstallationId(installationId, process.cwd());
1540
- const occurredAt = nowIso();
1541
- const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1542
- ok: false,
1543
- errorCode: context.error_code,
1544
- errorMessage: context.error_message,
1545
- exitCode: context.exit_code
1546
- })) ?? "unknown_error";
1547
- const normalizedErrorCategory = context.error_category ?? resolveTelemetryErrorCategory(normalizedErrorCode);
1548
- const normalizedExitCode = normalizeTelemetryExitCode(context.exit_code, false);
1549
- const normalizedCommand = context.command.trim().length > 0 ? context.command : "<unknown>";
1550
- const commandTaxonomy = deriveTelemetryCommandTaxonomy(normalizedCommand);
1551
- const commandResolution = context.command_resolution ?? deriveTelemetryCommandResolution({
1552
- ok: false,
1553
- errorCode: normalizedErrorCode,
1554
- errorCategory: normalizedErrorCategory
1555
- });
1556
- const resolutionStage = context.resolution_stage ?? "unknown";
1557
- const event = {
1558
- schema_version: TELEMETRY_SCHEMA_VERSION,
1559
- event_id: crypto.randomUUID(),
1560
- event_type: "command_error",
1561
- occurred_at: occurredAt,
1562
- installation_id: installationId,
1563
- session_id: PROCESS_SESSION_ID,
1564
- command: sanitizeString(normalizedCommand, "redacted"),
1565
- payload: buildCommandErrorPayload({
1566
- captureLevel,
1567
- pmVersion,
1568
- sourceContext,
1569
- command: normalizedCommand,
1570
- commandTaxonomy,
1571
- commandResolution,
1572
- resolutionStage,
1573
- args: context.args,
1574
- options: context.options,
1575
- pmRootHash,
1576
- cwdHash,
1577
- installationId,
1578
- errorCode: normalizedErrorCode,
1579
- errorCategory: normalizedErrorCategory,
1580
- exitCode: normalizedExitCode,
1581
- errorMessage: context.error_message
1582
- })
1583
- };
1584
- await enqueueTelemetryEvent(globalPmRoot, event);
1585
- scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
163
+ const enabled = await promptTelemetryConsent(settings.telemetry.enabled);
164
+ settings.telemetry.enabled = enabled;
165
+ settings.telemetry.first_run_prompt_completed = true;
166
+ await writeSettings(globalPmRoot, settings, "telemetry:first_run_prompt");
167
+ output.write(`Telemetry ${enabled ? "enabled" : "disabled"} for this CLI install. Update any time with pm config global set telemetry-tracking --policy ${enabled ? "disabled" : "enabled"}.
168
+ `);
1586
169
  } catch {
1587
170
  }
1588
171
  }
1589
172
 
1590
173
  // dist/core/sentry/instrument.js
1591
174
  import fs from "node:fs";
1592
- import path2 from "node:path";
175
+ import path from "node:path";
1593
176
  !(function() {
1594
177
  try {
1595
178
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
@@ -1736,7 +319,7 @@ function isKnownNoisyConsoleBreadcrumb(breadcrumb) {
1736
319
  }
1737
320
  function resolveCliVersion() {
1738
321
  try {
1739
- const candidate = path2.join(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]), "package.json");
322
+ const candidate = path.join(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]), "package.json");
1740
323
  if (fs.existsSync(candidate)) {
1741
324
  const parsed = JSON.parse(fs.readFileSync(candidate, "utf8"));
1742
325
  if (typeof parsed.version === "string")
@@ -2344,7 +927,7 @@ function parseLooseCommandOptions(args) {
2344
927
  !(function() {
2345
928
  try {
2346
929
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
2347
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "87ab8982-4eaf-5b48-88af-96ff4450ab0f");
930
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "74a0432a-8374-53db-8e95-5ebd38cf8557");
2348
931
  } catch (e2) {
2349
932
  }
2350
933
  })();
@@ -2488,6 +1071,70 @@ var HELP_BY_COMMAND_PATH = {
2488
1071
  "Use --dry-run before upgrade when automation needs a deterministic plan."
2489
1072
  ]
2490
1073
  },
1074
+ "package init": {
1075
+ why: "Generates an installable starter pm package with package metadata and a root extension entrypoint.",
1076
+ examples: [
1077
+ "pm package init ./my-package",
1078
+ "pm install ./my-package --project",
1079
+ "pm package doctor --project --detail summary"
1080
+ ],
1081
+ tips: [
1082
+ "The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.",
1083
+ "Use package doctor after changes to verify activation, policy, and collision diagnostics."
1084
+ ]
1085
+ },
1086
+ "package install": {
1087
+ why: "Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",
1088
+ examples: [
1089
+ "pm package install ./my-package --project",
1090
+ "pm install npm:pm-changelog --project",
1091
+ "pm package install --github org/repo/packages/my-pm-package --ref main"
1092
+ ],
1093
+ tips: [
1094
+ "Prefer the top-level pm install alias in scripts when only installation is needed.",
1095
+ "Run pm package manage or pm package doctor after installing external packages."
1096
+ ]
1097
+ },
1098
+ "package catalog": {
1099
+ why: "Lists bundled first-party package catalog metadata and compact field projections.",
1100
+ examples: [
1101
+ "pm package catalog --project",
1102
+ "pm package catalog --project --fields alias,installed,install_command",
1103
+ "pm package list --project --fields alias,package_name,category"
1104
+ ],
1105
+ tips: [
1106
+ "Use --fields for low-token package discovery in agent loops.",
1107
+ "External npm package discovery still belongs to npm search."
1108
+ ]
1109
+ },
1110
+ "extension init": {
1111
+ why: "Generates an installable starter runtime extension with manifest and entrypoint files.",
1112
+ examples: [
1113
+ "pm extension init ./my-extension",
1114
+ "pm extension --install --project ./my-extension",
1115
+ "pm extension --doctor --project --detail summary"
1116
+ ],
1117
+ tips: [
1118
+ "Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."
1119
+ ]
1120
+ },
1121
+ "extension install": {
1122
+ why: "Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",
1123
+ examples: [
1124
+ "pm extension install ./my-extension --project",
1125
+ "pm extension --install --project ./my-extension",
1126
+ "pm extension doctor --project --detail summary"
1127
+ ],
1128
+ tips: ["Prefer pm install or pm package install for new package-first automation."]
1129
+ },
1130
+ "extension catalog": {
1131
+ why: "Compatibility view of bundled package catalog metadata.",
1132
+ examples: [
1133
+ "pm extension catalog --project",
1134
+ "pm extension catalog --project --fields alias,installed,install_command"
1135
+ ],
1136
+ tips: ["Prefer pm package catalog in new user-facing workflows."]
1137
+ },
2491
1138
  install: {
2492
1139
  why: "Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",
2493
1140
  examples: [
@@ -2553,6 +1200,21 @@ var HELP_BY_COMMAND_PATH = {
2553
1200
  "Checkpoints are enabled by default for apply mode and can be restored with --rollback."
2554
1201
  ]
2555
1202
  },
1203
+ "close-many": {
1204
+ why: "Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",
1205
+ examples: [
1206
+ 'pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run',
1207
+ 'pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn',
1208
+ 'pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',
1209
+ "pm close-many --rollback close-many-20260604-abc123"
1210
+ ],
1211
+ tips: [
1212
+ "At least one filter (--filter-* or --ids) is required so close-many never matches every item.",
1213
+ "Already-terminal matches are skipped by default; pass --force to re-close them.",
1214
+ "Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.",
1215
+ "Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."
1216
+ ]
1217
+ },
2556
1218
  normalize: {
2557
1219
  why: "Scans items for low-signal lifecycle metadata drift, emits deterministic per-item plans, and optionally applies normalized metadata updates with update-style safety checks.",
2558
1220
  examples: [
@@ -2715,7 +1377,7 @@ var HELP_BY_COMMAND_PATH = {
2715
1377
  "pm get pm-a1b2 --fields id,title,status,parent,type --json"
2716
1378
  ],
2717
1379
  tips: [
2718
- "Default depth is deep for backward compatibility; use brief for metadata-only checks and standard for body plus linked artifacts without append-only logs.",
1380
+ "Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.",
2719
1381
  "Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.",
2720
1382
  "JSON output shape is { item, body, linked, claim_state }; body is top-level (not item.body)."
2721
1383
  ]
@@ -2857,6 +1519,15 @@ var HELP_BY_COMMAND_PATH = {
2857
1519
  why: "Reports tracker-level totals and distribution by type/status.",
2858
1520
  examples: ["pm stats", "pm stats --json"]
2859
1521
  },
1522
+ telemetry: {
1523
+ why: "Inspects and manages local telemetry queue/runtime state for observability diagnostics.",
1524
+ examples: [
1525
+ "pm telemetry status",
1526
+ "pm telemetry stats --limit 10",
1527
+ "pm telemetry flush",
1528
+ "pm telemetry clear"
1529
+ ]
1530
+ },
2860
1531
  health: {
2861
1532
  why: "Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",
2862
1533
  examples: [
@@ -2980,7 +1651,7 @@ function attachRichHelpText(program2, argv = process.argv.slice(2)) {
2980
1651
  !(function() {
2981
1652
  try {
2982
1653
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
2983
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "92cba1f2-f9c5-5748-90ce-ab2049ada502");
1654
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "7f17a5b9-5783-523d-b9cd-61968ddd9ed2");
2984
1655
  } catch (e2) {
2985
1656
  }
2986
1657
  })();
@@ -2996,13 +1667,17 @@ function normalizeLongOptionFlag(token) {
2996
1667
  }
2997
1668
  function extractProvidedOptionFlags(argv) {
2998
1669
  const provided = /* @__PURE__ */ new Set();
1670
+ const ordered = [];
2999
1671
  for (const token of argv) {
3000
1672
  const normalized = normalizeLongOptionFlag(token);
3001
1673
  if (normalized) {
1674
+ if (!provided.has(normalized)) {
1675
+ ordered.push(normalized);
1676
+ }
3002
1677
  provided.add(normalized);
3003
1678
  }
3004
1679
  }
3005
- return [...provided].sort((left, right) => left.localeCompare(right));
1680
+ return ordered;
3006
1681
  }
3007
1682
  function quoteCommandArg(arg) {
3008
1683
  if (/^[A-Za-z0-9._:/@=-]+$/.test(arg)) {
@@ -3018,7 +1693,7 @@ function renderPmCommand(argv) {
3018
1693
  !(function() {
3019
1694
  try {
3020
1695
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
3021
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "98367a9e-b72b-56c3-a337-fcc10e562f6e");
1696
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "883618a4-a53f-5506-ab97-d734647806e7");
3022
1697
  } catch (e2) {
3023
1698
  }
3024
1699
  })();
@@ -3181,6 +1856,10 @@ function guidanceToClassification(message) {
3181
1856
  function normalizeMessage(message) {
3182
1857
  return message.replace(/\(outputHelp\)/g, "").trim();
3183
1858
  }
1859
+ function isModuleResolutionErrorMessage(message) {
1860
+ const normalized = message.toLowerCase();
1861
+ return normalized.includes("cannot find module") || normalized.includes("cannot find package") || normalized.includes("err_module_not_found") || normalized.includes("module_not_found");
1862
+ }
3184
1863
  function normalizeContextList(values) {
3185
1864
  if (!Array.isArray(values)) {
3186
1865
  return void 0;
@@ -3600,10 +2279,26 @@ function formatUnknownErrorForJson(rawMessage, exitCode) {
3600
2279
  return guidanceToJsonEnvelope(guidance, exitCode);
3601
2280
  }
3602
2281
  function buildUnknownErrorGuidance(rawMessage) {
2282
+ const message = normalizeMessage(rawMessage);
2283
+ if (isModuleResolutionErrorMessage(message)) {
2284
+ return makeGuidanceMessage({
2285
+ code: "module_import_failed",
2286
+ title: "Module import failed",
2287
+ happened: message,
2288
+ required: "Ensure the active checkout is built and any package or extension entry file exists before retrying.",
2289
+ why: "Node could not resolve an imported module. In pm this usually means an extension/package entrypoint, build artifact, or dependency is missing from the active runtime.",
2290
+ examples: ["pnpm build", "pm package manage --doctor --project", "pm health --check-only --json"],
2291
+ nextSteps: [
2292
+ "Rebuild the checkout or package that provides the missing module.",
2293
+ "Run package doctor for installed extensions when the failure follows package installation or activation.",
2294
+ "Rerun the original pm command after the runtime files are present."
2295
+ ]
2296
+ });
2297
+ }
3603
2298
  return makeGuidanceMessage({
3604
2299
  code: "unknown_error",
3605
2300
  title: "Unhandled error",
3606
- happened: normalizeMessage(rawMessage),
2301
+ happened: message,
3607
2302
  required: "Inspect command input and runtime state, then retry.",
3608
2303
  why: "Unexpected runtime failures can occur from environment or extension-level issues.",
3609
2304
  examples: ["pm --help", "pm health --json"]
@@ -4009,7 +2704,7 @@ function ensureCommandPath(root, pathParts) {
4009
2704
  !(function() {
4010
2705
  try {
4011
2706
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
4012
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "09a59142-b988-5127-9105-7bdfc1f9c832");
2707
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "abcf109c-c846-5b61-b510-f1ad6ff4f3aa");
4013
2708
  } catch (e2) {
4014
2709
  }
4015
2710
  })();
@@ -4520,7 +3215,8 @@ function normalizeBootstrapInvocation(argv) {
4520
3215
  }
4521
3216
  const aliasNormalized = rewriteCommandAlias(legacyNormalized, trace);
4522
3217
  const commandName = parseBootstrapCommandName(aliasNormalized);
4523
- const lookup = buildFlagLookup(commandName);
3218
+ const commandPathName = parseBootstrapCommandPathName(aliasNormalized);
3219
+ const lookup = buildFlagLookup(commandPathName ?? commandName);
4524
3220
  const normalizedArgv = [];
4525
3221
  for (let index = 0; index < aliasNormalized.length; index += 1) {
4526
3222
  const token = aliasNormalized[index];
@@ -4564,6 +3260,15 @@ function normalizeBootstrapInvocation(argv) {
4564
3260
  trace
4565
3261
  };
4566
3262
  }
3263
+ function parseBootstrapCommandPathName(argv) {
3264
+ const stripped = stripGlobalBootstrapTokens(argv);
3265
+ const first = stripped[0]?.trim().toLowerCase();
3266
+ const second = stripped[1]?.trim().toLowerCase();
3267
+ if ((first === "extension" || first === "package" || first === "packages") && typeof second === "string" && second.length > 0 && !second.startsWith("-")) {
3268
+ return `${first} ${second}`;
3269
+ }
3270
+ return first;
3271
+ }
4567
3272
  function parseBootstrapTypeValue(argv) {
4568
3273
  for (let index = 0; index < argv.length; index += 1) {
4569
3274
  const token = argv[index];
@@ -5012,7 +3717,7 @@ function buildUnknownCommandGuidanceFromRuntime(rawMessage, root, extensionDescr
5012
3717
  const fallbackTopLevel = [...new Set(commandPaths.map((commandPath) => commandPath.split(" ")[0]).filter((segment) => segment.length > 0))];
5013
3718
  fallbackTopLevel.sort((left, right) => left.localeCompare(right));
5014
3719
  const suggestedPaths = (combinedCandidates.length > 0 ? combinedCandidates : fallbackTopLevel).slice(0, 3);
5015
- const examples = [.../* @__PURE__ */ new Set(["pm --help", ...suggestedPaths.map((path4) => `pm ${path4} --help`)])];
3720
+ const examples = [.../* @__PURE__ */ new Set(["pm --help", ...suggestedPaths.map((path3) => `pm ${path3} --help`)])];
5016
3721
  const optionalPackageHint = resolveOptionalPackageInstallHint(normalizedUnknown);
5017
3722
  const didYouMean = combinedCandidates.length > 0 ? `Did you mean: ${combinedCandidates.slice(0, 3).join(", ")}?` : null;
5018
3723
  return {
@@ -5427,7 +4132,7 @@ function attachCreateUpdatePolicyHelpText(rootProgram, typeRegistry, argv) {
5427
4132
  !(function() {
5428
4133
  try {
5429
4134
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5430
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "fb080e3e-ad71-5608-a944-ce887395e3e9");
4135
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "85d31f87-d392-5da2-9d53-1525fb938ff2");
5431
4136
  } catch (e2) {
5432
4137
  }
5433
4138
  })();
@@ -5457,6 +4162,7 @@ var TELEMETRY_COMMAND_RESOLUTION_SET = /* @__PURE__ */ new Set([
5457
4162
  var TELEMETRY_RESOLUTION_STAGE_SET = /* @__PURE__ */ new Set(["parse", "preflight", "execute", "unknown"]);
5458
4163
  var TELEMETRY_ERROR_CATEGORY_SET = /* @__PURE__ */ new Set(["usage", "validation", "conflict", "runtime", "unknown"]);
5459
4164
  var runtimeExtensionSnapshotCache = null;
4165
+ var runtimeExtensionDiscoverySnapshotCache = null;
5460
4166
  var activeRuntimeExtensionCommandDescriptors = /* @__PURE__ */ new Map();
5461
4167
  var HANDLED_ERROR_SENTRY_FLUSH_TIMEOUT_MS = 250;
5462
4168
  var EXPECTED_HANDLED_ERROR_EXIT_CODES = /* @__PURE__ */ new Set([
@@ -5465,10 +4171,10 @@ var EXPECTED_HANDLED_ERROR_EXIT_CODES = /* @__PURE__ */ new Set([
5465
4171
  EXIT_CODE.CONFLICT
5466
4172
  ]);
5467
4173
  var TRUE_LIKE_ENV_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
5468
- var loadSetupRegistrationModule = createLazyModule(() => import("./chunks/register-setup-V56GDRUS.js"));
5469
- var loadListQueryRegistrationModule = createLazyModule(() => import("./chunks/register-list-query-UP3VRUFS.js"));
5470
- var loadMutationRegistrationModule = createLazyModule(() => import("./chunks/register-mutation-YWSBF545.js"));
5471
- var loadOperationRegistrationModule = createLazyModule(() => import("./chunks/register-operations-3BDTGSDH.js"));
4174
+ var loadSetupRegistrationModule = createLazyModule(() => import("./chunks/register-setup-ZHJI2DI3.js"));
4175
+ var loadListQueryRegistrationModule = createLazyModule(() => import("./chunks/register-list-query-WST76HSQ.js"));
4176
+ var loadMutationRegistrationModule = createLazyModule(() => import("./chunks/register-mutation-OA675SOU.js"));
4177
+ var loadOperationRegistrationModule = createLazyModule(() => import("./chunks/register-operations-N3PMHXH5.js"));
5472
4178
  function describeUnknownError(error) {
5473
4179
  if (error instanceof PmCliError) {
5474
4180
  return error.message;
@@ -5533,7 +4239,7 @@ function buildPmCliRecoveryContext(context, invocationArgv, rawMessage) {
5533
4239
  if (!suggestedRetry) {
5534
4240
  suggestedRetry = attemptedCommand;
5535
4241
  }
5536
- if (suggestedRetry === attemptedCommand) {
4242
+ if (!existingRecovery?.suggested_retry && suggestedRetry === attemptedCommand) {
5537
4243
  suggestedRetry = void 0;
5538
4244
  }
5539
4245
  const recovery = {
@@ -5607,7 +4313,7 @@ function normalizeTelemetryResolutionStage(value) {
5607
4313
  }
5608
4314
  return normalized;
5609
4315
  }
5610
- function normalizeTelemetryErrorCategory2(value) {
4316
+ function normalizeTelemetryErrorCategory(value) {
5611
4317
  if (!value) {
5612
4318
  return void 0;
5613
4319
  }
@@ -5673,12 +4379,12 @@ function buildPostActionTelemetryOutcome() {
5673
4379
  const resultExitCode = readRecordNumber(result, "exit_code", "exitCode");
5674
4380
  const exitCode = processExitCode ?? resultExitCode ?? EXIT_CODE.SUCCESS;
5675
4381
  const ok = exitCode === EXIT_CODE.SUCCESS;
5676
- const errorCode2 = readRecordString(result, "error_code", "errorCode") ?? inferPostActionErrorCode(ok, exitCode);
5677
- const errorCategory = normalizeTelemetryErrorCategory2(readRecordString(result, "error_category", "errorCategory")) ?? (!ok ? resolveTelemetryErrorCategory(errorCode2) : void 0);
4382
+ const errorCode = readRecordString(result, "error_code", "errorCode") ?? inferPostActionErrorCode(ok, exitCode);
4383
+ const errorCategory = normalizeTelemetryErrorCategory(readRecordString(result, "error_category", "errorCategory")) ?? (!ok ? resolveTelemetryErrorCategory(errorCode) : void 0);
5678
4384
  const errorMessage = !ok ? inferPostActionFailureMessage(result) ?? `command_exit_${exitCode}` : void 0;
5679
4385
  const commandResolution = normalizeTelemetryCommandResolution(readRecordString(result, "command_resolution", "commandResolution")) ?? deriveTelemetryCommandResolution({
5680
4386
  ok,
5681
- errorCode: errorCode2,
4387
+ errorCode,
5682
4388
  errorCategory
5683
4389
  });
5684
4390
  const resolutionStage = normalizeTelemetryResolutionStage(readRecordString(result, "resolution_stage", "resolutionStage")) ?? "execute";
@@ -5686,7 +4392,7 @@ function buildPostActionTelemetryOutcome() {
5686
4392
  ok,
5687
4393
  error: errorMessage,
5688
4394
  exit_code: exitCode,
5689
- error_code: errorCode2,
4395
+ error_code: errorCode,
5690
4396
  error_category: errorCategory,
5691
4397
  command_resolution: commandResolution,
5692
4398
  resolution_stage: resolutionStage
@@ -5711,17 +4417,28 @@ async function runAndClearAfterCommandHooks(outcome) {
5711
4417
  clearActiveExtensionHooks();
5712
4418
  return;
5713
4419
  }
5714
- const hookWarnings = await runAfterCommandHooks(runtime.hooks, {
5715
- command: runtime.commandName,
5716
- args: runtime.commandArgs,
5717
- options: { ...runtime.commandOptions },
5718
- global: { ...runtime.globalOptions },
5719
- pm_root: runtime.pmRoot,
5720
- ok: outcome.ok,
5721
- error: outcome.error,
5722
- result: getActiveCommandResult()
5723
- });
5724
- clearActiveExtensionHooks();
4420
+ let hookWarnings = [];
4421
+ try {
4422
+ hookWarnings = await runAfterCommandHooks(runtime.hooks, {
4423
+ command: runtime.commandName,
4424
+ args: runtime.commandArgs,
4425
+ options: { ...runtime.commandOptions },
4426
+ global: { ...runtime.globalOptions },
4427
+ pm_root: runtime.pmRoot,
4428
+ ok: outcome.ok,
4429
+ error: outcome.error,
4430
+ result: getActiveCommandResult(),
4431
+ affected: consumeAfterCommandAffectedItems()
4432
+ });
4433
+ } catch (error) {
4434
+ const message = error instanceof Error ? error.message : String(error);
4435
+ hookWarnings = [`afterCommand hooks failed: ${message}`];
4436
+ } finally {
4437
+ clearActiveExtensionHooks();
4438
+ }
4439
+ if (!runtime.globalOptions.json && hookWarnings.length > 0) {
4440
+ printError(`[pm] warning: afterCommand hook_warnings=${formatHookWarnings(hookWarnings)}`);
4441
+ }
5725
4442
  if (runtime.profileEnabled && hookWarnings.length > 0) {
5726
4443
  printError(`profile:extensions hook_warnings=${formatHookWarnings(hookWarnings)}`);
5727
4444
  }
@@ -5920,6 +4637,18 @@ async function registerRuntimeSchemaFieldFlags(rootProgram, invocationArgv) {
5920
4637
  }
5921
4638
  }
5922
4639
  }
4640
+ async function maybeAttachCreateUpdatePolicyHelpText(rootProgram, pmRoot, invocationArgv, registrations, settings) {
4641
+ const bootstrapCommand = parseBootstrapCommandName(invocationArgv);
4642
+ if (bootstrapCommand !== "create" && bootstrapCommand !== "update") {
4643
+ return;
4644
+ }
4645
+ try {
4646
+ const resolvedSettings = settings ?? await readSettings(pmRoot);
4647
+ const typeRegistry = resolveItemTypeRegistry(resolvedSettings, registrations);
4648
+ attachCreateUpdatePolicyHelpText(rootProgram, typeRegistry, invocationArgv);
4649
+ } catch {
4650
+ }
4651
+ }
5923
4652
  function defaultPreflightDecision() {
5924
4653
  return {
5925
4654
  enforce_item_format_gate: true,
@@ -5931,6 +4660,180 @@ function defaultPreflightDecision() {
5931
4660
  function buildRuntimeExtensionSnapshotCacheKey(pmRoot) {
5932
4661
  return `pm-root:${pmRoot}`;
5933
4662
  }
4663
+ function bootstrapProfileEnabled(invocationArgv) {
4664
+ return invocationArgv.some((token) => token === "--profile");
4665
+ }
4666
+ function buildRuntimeExtensionDiscoverySnapshotCacheKey(pmRoot) {
4667
+ return `pm-root:${pmRoot}`;
4668
+ }
4669
+ function collectLeadingCommandArgs(commandArgs) {
4670
+ const leading = [];
4671
+ for (const arg of commandArgs ?? []) {
4672
+ if (arg.startsWith("-")) {
4673
+ break;
4674
+ }
4675
+ const normalized = normalizeExtensionCommandPath(arg);
4676
+ if (normalized.length === 0) {
4677
+ continue;
4678
+ }
4679
+ leading.push(normalized);
4680
+ }
4681
+ return leading;
4682
+ }
4683
+ function collectActivationCommandCandidates(probe) {
4684
+ const commandPath = normalizeExtensionCommandPath(probe.commandPath ?? "");
4685
+ if (commandPath.length === 0) {
4686
+ return [];
4687
+ }
4688
+ const candidates = [commandPath];
4689
+ const parts = commandPath.split(" ").filter((part) => part.length > 0);
4690
+ for (const arg of collectLeadingCommandArgs(probe.commandArgs)) {
4691
+ parts.push(...arg.split(" ").filter((part) => part.length > 0));
4692
+ candidates.push(parts.join(" "));
4693
+ }
4694
+ return [...new Set(candidates)];
4695
+ }
4696
+ function activationCommandMatchesProbe(command, probe) {
4697
+ const normalized = normalizeExtensionCommandPath(command);
4698
+ if (normalized.length === 0) {
4699
+ return false;
4700
+ }
4701
+ const candidates = collectActivationCommandCandidates(probe);
4702
+ for (const candidate of candidates) {
4703
+ if (candidate === normalized || candidate.startsWith(`${normalized} `)) {
4704
+ return true;
4705
+ }
4706
+ }
4707
+ if (probe.allowCommandPrefixMatch === true) {
4708
+ return candidates.some((candidate) => normalized.startsWith(`${candidate} `));
4709
+ }
4710
+ return false;
4711
+ }
4712
+ function extensionActivationCommands(extension) {
4713
+ return extension.activation?.commands ?? [];
4714
+ }
4715
+ function extensionCapabilities(extension) {
4716
+ return new Set((extension.capabilities ?? []).map((capability) => capability.trim().toLowerCase()));
4717
+ }
4718
+ var GLOBAL_EXTENSION_ACTIVATION_CAPABILITIES = /* @__PURE__ */ new Set(["hooks", "parser", "preflight", "renderers"]);
4719
+ var CONSERVATIVE_EXTENSION_ACTIVATION_CAPABILITIES = /* @__PURE__ */ new Set(["commands", "schema", "services"]);
4720
+ var SEARCH_EXTENSION_ACTIVATION_COMMANDS = /* @__PURE__ */ new Set(["reindex", "search", "search-advanced"]);
4721
+ var CREATE_TEMPLATE_FLAGS = /* @__PURE__ */ new Set(["--template"]);
4722
+ function hasAnyCapability(capabilities, expected) {
4723
+ for (const capability of expected) {
4724
+ if (capabilities.has(capability)) {
4725
+ return true;
4726
+ }
4727
+ }
4728
+ return false;
4729
+ }
4730
+ function commandPathNeedsSearchExtensions(commandPath) {
4731
+ const normalized = normalizeExtensionCommandPath(commandPath ?? "");
4732
+ if (normalized.length === 0) {
4733
+ return false;
4734
+ }
4735
+ const [topLevel] = normalized.split(" ");
4736
+ return SEARCH_EXTENSION_ACTIVATION_COMMANDS.has(topLevel ?? normalized);
4737
+ }
4738
+ function probeUsesAnyFlag(probe, flags) {
4739
+ for (const arg of probe.commandArgs ?? []) {
4740
+ if (!arg.startsWith("--")) {
4741
+ continue;
4742
+ }
4743
+ const [flagName] = arg.split("=", 1);
4744
+ if (flags.has(flagName)) {
4745
+ return true;
4746
+ }
4747
+ }
4748
+ return false;
4749
+ }
4750
+ function commandPathNeedsTemplateExtensions(probe) {
4751
+ return normalizeExtensionCommandPath(probe.commandPath ?? "") === "create" && probeUsesAnyFlag(probe, CREATE_TEMPLATE_FLAGS);
4752
+ }
4753
+ function extensionProvidesTemplatesRuntime(commands) {
4754
+ return commands.some((command) => {
4755
+ const normalized = normalizeExtensionCommandPath(command);
4756
+ return normalized === "templates" || normalized.startsWith("templates ");
4757
+ });
4758
+ }
4759
+ function extensionNeedsActivationForProbe(extension, probe) {
4760
+ const capabilities = extensionCapabilities(extension);
4761
+ const commands = extensionActivationCommands(extension);
4762
+ if (commands.length > 0 && commands.some((command) => activationCommandMatchesProbe(command, probe))) {
4763
+ return true;
4764
+ }
4765
+ if (hasAnyCapability(capabilities, GLOBAL_EXTENSION_ACTIVATION_CAPABILITIES)) {
4766
+ return true;
4767
+ }
4768
+ if (commandPathNeedsTemplateExtensions(probe) && extensionProvidesTemplatesRuntime(commands)) {
4769
+ return true;
4770
+ }
4771
+ if (capabilities.has("search")) {
4772
+ return commandPathNeedsSearchExtensions(probe.commandPath);
4773
+ }
4774
+ if (commands.length > 0) {
4775
+ return false;
4776
+ }
4777
+ if (hasAnyCapability(capabilities, CONSERVATIVE_EXTENSION_ACTIVATION_CAPABILITIES)) {
4778
+ return true;
4779
+ }
4780
+ if (capabilities.has("importers")) {
4781
+ return probe.allowCommandPrefixMatch === true;
4782
+ }
4783
+ return false;
4784
+ }
4785
+ function discoveryNeedsActivationForProbe(discovery, probe) {
4786
+ if (discovery.effective.length === 0) {
4787
+ return false;
4788
+ }
4789
+ const hasCommandProbe = normalizeExtensionCommandPath(probe.commandPath ?? "").length > 0;
4790
+ if (!hasCommandProbe) {
4791
+ return discovery.effective.some((extension) => {
4792
+ const capabilities = extensionCapabilities(extension);
4793
+ return extensionActivationCommands(extension).length > 0 || hasAnyCapability(capabilities, GLOBAL_EXTENSION_ACTIVATION_CAPABILITIES) || hasAnyCapability(capabilities, CONSERVATIVE_EXTENSION_ACTIVATION_CAPABILITIES) || capabilities.has("importers") || capabilities.has("search");
4794
+ });
4795
+ }
4796
+ return discovery.effective.some((extension) => extensionNeedsActivationForProbe(extension, probe));
4797
+ }
4798
+ function buildBootstrapActivationProbe(invocationArgv) {
4799
+ const helpRequest = parseBootstrapHelpRequest(invocationArgv);
4800
+ if (helpRequest.requested && helpRequest.commandPathTokens.length > 0) {
4801
+ const [commandPath, ...commandArgs] = helpRequest.commandPathTokens;
4802
+ return {
4803
+ commandPath,
4804
+ commandArgs,
4805
+ allowCommandPrefixMatch: true
4806
+ };
4807
+ }
4808
+ const stripped = stripGlobalBootstrapTokens(invocationArgv);
4809
+ const commandIndex = stripped.findIndex((token) => token.trim().length > 0 && !token.startsWith("-"));
4810
+ if (commandIndex < 0) {
4811
+ return {};
4812
+ }
4813
+ return {
4814
+ commandPath: stripped[commandIndex],
4815
+ commandArgs: stripped.slice(commandIndex + 1),
4816
+ allowCommandPrefixMatch: helpRequest.requested
4817
+ };
4818
+ }
4819
+ function collectParsedActivationCommandArgs(command) {
4820
+ const commandArgs = command.args.map(String);
4821
+ const commandPath = normalizeExtensionCommandPath(getCommandPath(command));
4822
+ if (commandPath === "create") {
4823
+ const options = command.optsWithGlobals();
4824
+ if (typeof options.template === "string" && options.template.trim().length > 0) {
4825
+ commandArgs.push("--template");
4826
+ }
4827
+ }
4828
+ return commandArgs;
4829
+ }
4830
+ function emitSettingsReadWarnings(warnings) {
4831
+ for (const warning of warnings) {
4832
+ if (warning.startsWith("settings_read_")) {
4833
+ printError(`[pm] warning: ${warning} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`);
4834
+ }
4835
+ }
4836
+ }
5934
4837
  function emitExtensionProfile(globalOptions, snapshot) {
5935
4838
  if (!globalOptions.profile) {
5936
4839
  return;
@@ -5940,6 +4843,55 @@ function emitExtensionProfile(globalOptions, snapshot) {
5940
4843
  printError(`profile:extensions activation_warnings=${formatHookWarnings(snapshot.activationWarnings)}`);
5941
4844
  }
5942
4845
  }
4846
+ function emitExtensionSkippedProfile(profileEnabled, snapshot, probe) {
4847
+ if (!profileEnabled) {
4848
+ return;
4849
+ }
4850
+ const command = normalizeExtensionCommandPath(probe.commandPath ?? "") || "<none>";
4851
+ printError(`profile:extensions activation=skipped command=${command} effective=${snapshot.discovery.effective.length} warnings=${snapshot.discovery.warnings.length} discovery_ms=${snapshot.discoveryMs}`);
4852
+ }
4853
+ async function loadRuntimeExtensionDiscoverySnapshot(pmRoot) {
4854
+ const cacheKey = buildRuntimeExtensionDiscoverySnapshotCacheKey(pmRoot);
4855
+ if (runtimeExtensionDiscoverySnapshotCache?.key === cacheKey) {
4856
+ return runtimeExtensionDiscoverySnapshotCache.snapshot;
4857
+ }
4858
+ const settingsPath = getSettingsPath(pmRoot);
4859
+ if (!await pathExists(settingsPath)) {
4860
+ runtimeExtensionDiscoverySnapshotCache = {
4861
+ key: cacheKey,
4862
+ snapshot: null
4863
+ };
4864
+ return null;
4865
+ }
4866
+ try {
4867
+ const startedAt = Date.now();
4868
+ const { settings, warnings: settingsReadWarnings } = await readSettingsWithMetadata(pmRoot);
4869
+ const discovery = await discoverExtensions({
4870
+ pmRoot,
4871
+ settings,
4872
+ cwd: process.cwd(),
4873
+ noExtensions: false
4874
+ });
4875
+ const snapshot = {
4876
+ pmRoot,
4877
+ settings,
4878
+ discovery,
4879
+ discoveryMs: Date.now() - startedAt,
4880
+ settingsReadWarnings: [...settingsReadWarnings]
4881
+ };
4882
+ runtimeExtensionDiscoverySnapshotCache = {
4883
+ key: cacheKey,
4884
+ snapshot
4885
+ };
4886
+ return snapshot;
4887
+ } catch {
4888
+ runtimeExtensionDiscoverySnapshotCache = {
4889
+ key: cacheKey,
4890
+ snapshot: null
4891
+ };
4892
+ return null;
4893
+ }
4894
+ }
5943
4895
  async function loadRuntimeExtensionSnapshot(pmRoot) {
5944
4896
  const cacheKey = buildRuntimeExtensionSnapshotCacheKey(pmRoot);
5945
4897
  if (runtimeExtensionSnapshotCache?.key === cacheKey) {
@@ -6003,9 +4955,26 @@ async function loadRuntimeExtensionSnapshot(pmRoot) {
6003
4955
  async function maybeLoadRuntimeExtensions(command) {
6004
4956
  const globalOptions = getGlobalOptions(command);
6005
4957
  if (globalOptions.noExtensions) {
4958
+ const noExtPmRoot = resolvePmRoot(process.cwd(), globalOptions.path);
4959
+ if (await pathExists(getSettingsPath(noExtPmRoot))) {
4960
+ emitSettingsReadWarnings((await readSettingsWithMetadata(noExtPmRoot)).warnings);
4961
+ }
6006
4962
  return null;
6007
4963
  }
6008
4964
  const pmRoot = resolvePmRoot(process.cwd(), globalOptions.path);
4965
+ const discoverySnapshot = await loadRuntimeExtensionDiscoverySnapshot(pmRoot);
4966
+ if (!discoverySnapshot) {
4967
+ return null;
4968
+ }
4969
+ emitSettingsReadWarnings(discoverySnapshot.settingsReadWarnings);
4970
+ const probe = {
4971
+ commandPath: getCommandPath(command),
4972
+ commandArgs: collectParsedActivationCommandArgs(command)
4973
+ };
4974
+ if (!discoveryNeedsActivationForProbe(discoverySnapshot.discovery, probe)) {
4975
+ emitExtensionSkippedProfile(globalOptions.profile, discoverySnapshot, probe);
4976
+ return null;
4977
+ }
6009
4978
  const snapshot = await loadRuntimeExtensionSnapshot(pmRoot);
6010
4979
  if (!snapshot) {
6011
4980
  return null;
@@ -6197,22 +5166,37 @@ function wrapProgramActionsForExtensionHandlers(rootProgram) {
6197
5166
  }
6198
5167
  async function registerDynamicExtensionCommandPaths(rootProgram, invocationArgv) {
6199
5168
  const bootstrapGlobalOptions = parseBootstrapGlobalOptions(invocationArgv);
5169
+ const pmRoot = resolvePmRoot(process.cwd(), bootstrapGlobalOptions.path);
6200
5170
  if (bootstrapGlobalOptions.noExtensions) {
6201
5171
  activeRuntimeExtensionCommandDescriptors = /* @__PURE__ */ new Map();
6202
5172
  setActiveExtensionServices({ overrides: [] });
5173
+ await maybeAttachCreateUpdatePolicyHelpText(rootProgram, pmRoot, invocationArgv, createEmptyExtensionRegistrationRegistry());
5174
+ return;
5175
+ }
5176
+ const discoverySnapshot = await loadRuntimeExtensionDiscoverySnapshot(pmRoot);
5177
+ const probe = buildBootstrapActivationProbe(invocationArgv);
5178
+ if (!discoverySnapshot) {
5179
+ activeRuntimeExtensionCommandDescriptors = /* @__PURE__ */ new Map();
5180
+ setActiveExtensionServices({ overrides: [] });
5181
+ return;
5182
+ }
5183
+ if (!discoveryNeedsActivationForProbe(discoverySnapshot.discovery, probe)) {
5184
+ activeRuntimeExtensionCommandDescriptors = /* @__PURE__ */ new Map();
5185
+ setActiveExtensionServices({ overrides: [] });
5186
+ await maybeAttachCreateUpdatePolicyHelpText(rootProgram, pmRoot, invocationArgv, createEmptyExtensionRegistrationRegistry(), discoverySnapshot.settings);
5187
+ emitExtensionSkippedProfile(bootstrapProfileEnabled(invocationArgv), discoverySnapshot, probe);
6203
5188
  return;
6204
5189
  }
6205
- const pmRoot = resolvePmRoot(process.cwd(), bootstrapGlobalOptions.path);
6206
5190
  const snapshot = await loadRuntimeExtensionSnapshot(pmRoot);
6207
5191
  if (!snapshot) {
6208
5192
  activeRuntimeExtensionCommandDescriptors = /* @__PURE__ */ new Map();
6209
5193
  setActiveExtensionServices({ overrides: [] });
5194
+ await maybeAttachCreateUpdatePolicyHelpText(rootProgram, pmRoot, invocationArgv, createEmptyExtensionRegistrationRegistry(), discoverySnapshot.settings);
6210
5195
  return;
6211
5196
  }
6212
5197
  setActiveExtensionServices(snapshot.services);
6213
5198
  activeRuntimeExtensionCommandDescriptors = new Map(snapshot.commandDescriptors);
6214
- const typeRegistry = resolveItemTypeRegistry(snapshot.settings, snapshot.registrations);
6215
- attachCreateUpdatePolicyHelpText(rootProgram, typeRegistry, invocationArgv);
5199
+ await maybeAttachCreateUpdatePolicyHelpText(rootProgram, pmRoot, invocationArgv, snapshot.registrations, snapshot.settings);
6216
5200
  const commandPaths = [.../* @__PURE__ */ new Set([...snapshot.commandHandlers, ...snapshot.commandDescriptors.keys()])].sort((left, right) => left.localeCompare(right));
6217
5201
  for (const commandPath of commandPaths) {
6218
5202
  const pathParts = commandPath.split(" ").filter((part) => part.length > 0);
@@ -6272,7 +5256,7 @@ async function registerDynamicExtensionCommandPaths(rootProgram, invocationArgv)
6272
5256
  }
6273
5257
  function resolveCliVersion2() {
6274
5258
  try {
6275
- const packageJsonPath = path3.join(resolvePmPackageRoot(), "package.json");
5259
+ const packageJsonPath = path2.join(resolvePmPackageRoot(), "package.json");
6276
5260
  const raw = fs2.readFileSync(packageJsonPath, "utf8");
6277
5261
  const parsed = JSON.parse(raw);
6278
5262
  return typeof parsed.version === "string" ? parsed.version : "0.0.0";
@@ -6450,6 +5434,7 @@ var LIST_QUERY_COMMAND_NAMES = /* @__PURE__ */ new Set([
6450
5434
  var MUTATION_COMMAND_NAMES = /* @__PURE__ */ new Set([
6451
5435
  "append",
6452
5436
  "close",
5437
+ "close-many",
6453
5438
  "comments",
6454
5439
  "delete",
6455
5440
  "deps",
@@ -6480,6 +5465,14 @@ var OPERATION_COMMAND_NAMES = /* @__PURE__ */ new Set([
6480
5465
  "test-runs-worker",
6481
5466
  "validate"
6482
5467
  ]);
5468
+ var MUTATING_OPERATION_COMMAND_NAMES = /* @__PURE__ */ new Set([
5469
+ "claim",
5470
+ "close-task",
5471
+ "pause-task",
5472
+ "release",
5473
+ "start-task",
5474
+ "test"
5475
+ ]);
6483
5476
  var REGISTER_ALL_CORE_COMMAND_FAMILIES = {
6484
5477
  setup: true,
6485
5478
  listQuery: true,
@@ -6619,12 +5612,37 @@ function shouldRegisterRuntimeSchemaFlags(invocationArgv) {
6619
5612
  }
6620
5613
  return RUNTIME_SCHEMA_FLAG_BOOTSTRAP_COMMANDS.has(commandName);
6621
5614
  }
5615
+ function enforceExplicitRetryForFlagTypos(bootstrapInvocation) {
5616
+ const commandName = bootstrapInvocation.commandName;
5617
+ if (!commandName) {
5618
+ return;
5619
+ }
5620
+ const typoEvent = bootstrapInvocation.trace.find((entry) => entry.reason === "flag_typo");
5621
+ if (!typoEvent) {
5622
+ return;
5623
+ }
5624
+ const normalizedTokens = Array.isArray(typoEvent.to) ? typoEvent.to : [String(typoEvent.to ?? "")].filter((entry) => entry.length > 0);
5625
+ const normalizedDisplay = normalizedTokens.length > 0 ? normalizedTokens.join(" ") : "the canonical flag";
5626
+ const mutatingCommand = MUTATION_COMMAND_NAMES.has(commandName) || MUTATING_OPERATION_COMMAND_NAMES.has(commandName);
5627
+ const code = mutatingCommand ? "mutating_flag_typo_requires_retry" : "flag_typo_requires_retry";
5628
+ const commandScope = mutatingCommand ? "mutating option" : "option";
5629
+ throw new PmCliError(`Refusing to auto-correct ${commandScope} ${typoEvent.from} to ${normalizedDisplay}. Retry with the canonical flag so the command is explicit.`, EXIT_CODE.USAGE, {
5630
+ code,
5631
+ examples: [renderPmCommand(bootstrapInvocation.argv)],
5632
+ nextSteps: ["Retry the command with the canonical flag shown in examples."],
5633
+ recovery: {
5634
+ normalized_args: [...bootstrapInvocation.argv],
5635
+ suggested_retry: renderPmCommand(bootstrapInvocation.argv)
5636
+ }
5637
+ });
5638
+ }
6622
5639
  async function runPmCli(rawArgv = process.argv.slice(2)) {
6623
5640
  const bootstrapInvocation = normalizeBootstrapInvocation(rawArgv);
6624
5641
  const invocationArgv = bootstrapInvocation.argv;
6625
5642
  const invocationProcessArgv = [process.argv[0], process.argv[1], ...invocationArgv];
6626
5643
  const isBareInvocation = invocationArgv.length === 0;
6627
5644
  try {
5645
+ enforceExplicitRetryForFlagTypos(bootstrapInvocation);
6628
5646
  applyBootstrapPagerPolicy(invocationArgv);
6629
5647
  const registrationSelection = resolveCoreCommandRegistrationSelection(invocationArgv);
6630
5648
  await registerCoreCommandFamilies(program, registrationSelection);
@@ -6683,8 +5701,17 @@ async function runPmCli(rawArgv = process.argv.slice(2)) {
6683
5701
  };
6684
5702
  };
6685
5703
  if (!bootstrapGlobal.noExtensions) {
6686
- const bootstrapSnapshot = await loadRuntimeExtensionSnapshot(bootstrapPmRoot);
6687
- setActiveExtensionServices(bootstrapSnapshot?.services ?? { overrides: [] });
5704
+ const bootstrapProbe = buildBootstrapActivationProbe(invocationArgv);
5705
+ const discoverySnapshot = await loadRuntimeExtensionDiscoverySnapshot(bootstrapPmRoot);
5706
+ if (discoverySnapshot && discoveryNeedsActivationForProbe(discoverySnapshot.discovery, bootstrapProbe)) {
5707
+ const bootstrapSnapshot = await loadRuntimeExtensionSnapshot(bootstrapPmRoot);
5708
+ setActiveExtensionServices(bootstrapSnapshot?.services ?? { overrides: [] });
5709
+ } else {
5710
+ if (discoverySnapshot) {
5711
+ emitExtensionSkippedProfile(bootstrapProfileEnabled(invocationArgv), discoverySnapshot, bootstrapProbe);
5712
+ }
5713
+ setActiveExtensionServices({ overrides: [] });
5714
+ }
6688
5715
  }
6689
5716
  const numericExitCode = readThrownExitCode(error);
6690
5717
  if (error instanceof PmCliError || !isCommanderError(error) && typeof numericExitCode === "number" && Number.isFinite(numericExitCode)) {
@@ -6729,7 +5756,9 @@ async function runPmCli(rawArgv = process.argv.slice(2)) {
6729
5756
  command_resolution: commandResolution2,
6730
5757
  resolution_stage: "execute"
6731
5758
  });
6732
- sentryCaptureCliError(wrapThrownErrorForSentry(error, errorMessage));
5759
+ if (loggedHandledErrorToSentry) {
5760
+ sentryCaptureCliError(wrapThrownErrorForSentry(error, errorMessage));
5761
+ }
6733
5762
  if (jsonErrors) {
6734
5763
  printError(JSON.stringify(formatPmCliErrorForJson(errorMessage, exitCode, enrichedContext), null, 2));
6735
5764
  } else {