@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
@@ -0,0 +1,1491 @@
1
+
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="705a511a-3aa8-5101-b1fa-07ed6544814a")}catch(e){}}();
3
+ import {
4
+ nowIso
5
+ } from "./chunk-TCD3R2PF.js";
6
+ import {
7
+ EXIT_CODE,
8
+ appendLineAtomic,
9
+ readFileIfExists,
10
+ readSettings,
11
+ resolveGlobalPmRoot,
12
+ resolvePmPackageRootFromModule,
13
+ resolveTelemetryErrorCategory,
14
+ writeFileAtomic,
15
+ writeSettings
16
+ } from "./chunk-5SFCOO6B.js";
17
+
18
+ // dist/core/telemetry/observability.js
19
+ var SETUP_ROOT_COMMANDS = /* @__PURE__ */ new Set(["init", "config", "completion", "completion-statuses", "completion-tags", "completion-types"]);
20
+ var QUERY_ROOT_COMMANDS = /* @__PURE__ */ new Set([
21
+ "list",
22
+ "list-all",
23
+ "list-open",
24
+ "list-in-progress",
25
+ "list-blocked",
26
+ "list-closed",
27
+ "list-canceled",
28
+ "list-draft",
29
+ "search",
30
+ "get",
31
+ "context",
32
+ "calendar",
33
+ "history",
34
+ "activity",
35
+ "aggregate",
36
+ "deps",
37
+ "contracts",
38
+ "stats",
39
+ "dedupe-audit"
40
+ ]);
41
+ var MUTATION_ROOT_COMMANDS = /* @__PURE__ */ new Set([
42
+ "create",
43
+ "update",
44
+ "update-many",
45
+ "close-many",
46
+ "append",
47
+ "close",
48
+ "delete",
49
+ "restore",
50
+ "claim",
51
+ "release",
52
+ "comments",
53
+ "notes",
54
+ "learnings",
55
+ "files",
56
+ "docs",
57
+ "start-task",
58
+ "pause-task",
59
+ "close-task"
60
+ ]);
61
+ var TESTING_ROOT_COMMANDS = /* @__PURE__ */ new Set(["test", "test-all", "test-runs", "test-verify", "trace-test", "test-ping"]);
62
+ var DIAGNOSTICS_ROOT_COMMANDS = /* @__PURE__ */ new Set(["health", "validate", "normalize", "reindex", "gc", "telemetry", "extension-doctor"]);
63
+ function normalizeCommandPath(commandPath) {
64
+ return commandPath.trim().replaceAll(/\s+/g, " ").toLowerCase();
65
+ }
66
+ function normalizeErrorCode(errorCode2) {
67
+ const normalized = errorCode2?.trim().toLowerCase();
68
+ return normalized && normalized.length > 0 ? normalized : void 0;
69
+ }
70
+ function deriveTelemetryCommandTaxonomy(commandPath) {
71
+ const normalizedPath = normalizeCommandPath(commandPath);
72
+ const tokens = normalizedPath.length > 0 ? normalizedPath.split(" ") : ["<unknown>"];
73
+ const root = tokens[0] ?? "<unknown>";
74
+ const leaf = tokens[tokens.length - 1] ?? root;
75
+ let family = "other";
76
+ if (SETUP_ROOT_COMMANDS.has(root)) {
77
+ family = "setup";
78
+ } else if (QUERY_ROOT_COMMANDS.has(root)) {
79
+ family = "query";
80
+ } else if (MUTATION_ROOT_COMMANDS.has(root)) {
81
+ family = "mutation";
82
+ } else if (TESTING_ROOT_COMMANDS.has(root)) {
83
+ family = "testing";
84
+ } else if (root === "extension") {
85
+ family = "extension";
86
+ } else if (DIAGNOSTICS_ROOT_COMMANDS.has(root)) {
87
+ family = "diagnostics";
88
+ }
89
+ return {
90
+ command_path: normalizedPath.length > 0 ? normalizedPath : "<unknown>",
91
+ command_root: root,
92
+ command_leaf: leaf,
93
+ command_depth: tokens.length,
94
+ command_family: family
95
+ };
96
+ }
97
+ function inferTelemetryErrorCode(params) {
98
+ if (params.ok) {
99
+ return void 0;
100
+ }
101
+ const explicit = normalizeErrorCode(params.errorCode);
102
+ if (explicit) {
103
+ return explicit;
104
+ }
105
+ const message = (params.errorMessage ?? "").trim().toLowerCase();
106
+ if (message.includes("unknown command")) {
107
+ return "unknown_command";
108
+ }
109
+ if (message.includes("unknown option")) {
110
+ return "unknown_option";
111
+ }
112
+ if (message.includes("missing required options") || message.includes("missing required option")) {
113
+ return "missing_required_option";
114
+ }
115
+ if (message.includes("missing required argument")) {
116
+ return "missing_required_argument";
117
+ }
118
+ if (message.includes("no update flags provided")) {
119
+ return "no_update_fields";
120
+ }
121
+ if (message.includes("is assigned to") && message.includes("use --force")) {
122
+ return "ownership_conflict";
123
+ }
124
+ if (message.includes("is locked")) {
125
+ return "lock_conflict";
126
+ }
127
+ if (message.includes("already terminal") && message.includes("use --force")) {
128
+ return "terminal_state_conflict";
129
+ }
130
+ if (message.includes("tracker is not initialized")) {
131
+ return "tracker_not_initialized";
132
+ }
133
+ if (message.includes(" not found")) {
134
+ return "item_not_found";
135
+ }
136
+ if (message.includes('use "pm close <id> <text>" to close an item') || message.includes("invalid --status value") && message.includes('"closed"')) {
137
+ return "close_through_update";
138
+ }
139
+ if (message.startsWith("invalid ") || message.includes(" must be ") || message.includes(" requires ")) {
140
+ return "invalid_argument_value";
141
+ }
142
+ if (message.includes("strict create mode requires concrete values for --")) {
143
+ return "missing_required_option";
144
+ }
145
+ if (message.includes("either as positional") && message.includes("not both")) {
146
+ return "invalid_command_usage";
147
+ }
148
+ const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode ?? 0)) : void 0;
149
+ if (exitCode === EXIT_CODE.USAGE) {
150
+ return "invalid_command_usage";
151
+ }
152
+ if (exitCode === EXIT_CODE.NOT_FOUND) {
153
+ return "item_not_found";
154
+ }
155
+ if (exitCode === EXIT_CODE.CONFLICT) {
156
+ return "lock_conflict";
157
+ }
158
+ if (exitCode === EXIT_CODE.DEPENDENCY_FAILED) {
159
+ return "dependency_failed";
160
+ }
161
+ return "command_failed";
162
+ }
163
+ function deriveTelemetryCommandResolution(params) {
164
+ if (params.ok) {
165
+ return "success";
166
+ }
167
+ const normalizedCode = normalizeErrorCode(params.errorCode);
168
+ if (normalizedCode === "unknown_command") {
169
+ return "nonexistent_command";
170
+ }
171
+ if (normalizedCode === "unknown_option") {
172
+ return "invalid_option";
173
+ }
174
+ if (normalizedCode === "missing_required_option") {
175
+ return "missing_required_option";
176
+ }
177
+ if (normalizedCode === "missing_required_argument") {
178
+ return "missing_required_argument";
179
+ }
180
+ if (normalizedCode === "health_findings") {
181
+ return "health_findings";
182
+ }
183
+ if (normalizedCode === "validation_findings") {
184
+ return "validation_findings";
185
+ }
186
+ if (params.errorCategory === "usage") {
187
+ return "invalid_usage";
188
+ }
189
+ if (params.errorCategory === "validation") {
190
+ return "validation_failed";
191
+ }
192
+ if (params.errorCategory === "conflict") {
193
+ return "conflict";
194
+ }
195
+ if (params.errorCategory === "runtime") {
196
+ return "runtime_failed";
197
+ }
198
+ return "unknown_failed";
199
+ }
200
+
201
+ // dist/core/telemetry/runtime.js
202
+ import crypto from "node:crypto";
203
+ import { spawn } from "node:child_process";
204
+ import { mkdirSync, rmSync, statSync } from "node:fs";
205
+ import { mkdir, readdir, rm, stat } from "node:fs/promises";
206
+ import os from "node:os";
207
+ import path from "node:path";
208
+ var TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
209
+ var TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
210
+ var TELEMETRY_SCHEMA_VERSION = 1;
211
+ var TELEMETRY_CLIENT_SCHEMA_VERSION = 1;
212
+ var TELEMETRY_FLUSH_BATCH_SIZE = 100;
213
+ var TELEMETRY_MAX_RETRY_DELAY_MS = 36e5;
214
+ var TELEMETRY_RETRY_BASE_DELAY_MS = 3e4;
215
+ var TELEMETRY_HTTP_TIMEOUT_MS = 5e3;
216
+ var MILLISECONDS_PER_DAY = 864e5;
217
+ var TELEMETRY_MAX_EVENT_BYTES = 65536;
218
+ var TELEMETRY_SANITIZE_MAX_DEPTH = 6;
219
+ var TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS = 20;
220
+ var TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;
221
+ var TELEMETRY_RESULT_PREVIEW_MAX_BYTES = 8192;
222
+ var TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS = [25, 50, 100, 200];
223
+ var TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1e3;
224
+ var TELEMETRY_FLUSH_LOCK_STALE_MS = 6e4;
225
+ var TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS = 6e4;
226
+ var OTEL_TRACES_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
227
+ var OTEL_BASE_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_ENDPOINT";
228
+ var OTEL_SERVICE_NAME_ENV = "OTEL_SERVICE_NAME";
229
+ var PM_TELEMETRY_DISABLED_ENV = "PM_TELEMETRY_DISABLED";
230
+ var PM_NO_TELEMETRY_ENV = "PM_NO_TELEMETRY";
231
+ var PM_TELEMETRY_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
232
+ var PM_TELEMETRY_OTEL_DISABLED_ENV = "PM_TELEMETRY_OTEL_DISABLED";
233
+ var PM_TELEMETRY_OTEL_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
234
+ var PM_TELEMETRY_INLINE_FLUSH_ENV = "PM_TELEMETRY_INLINE_FLUSH";
235
+ var PM_TELEMETRY_FLUSH_CHILD_ENV = "PM_TELEMETRY_FLUSH_CHILD";
236
+ var PM_TELEMETRY_SOURCE_CONTEXT_ENV = "PM_TELEMETRY_SOURCE_CONTEXT";
237
+ var PM_TELEMETRY_SOURCE_CONTEXT_VALUES = ["user", "automation", "test", "dogfood", "audit_smoke"];
238
+ var _lastFlushPromise = Promise.resolve();
239
+ var _queueMutationPromise = Promise.resolve();
240
+ var PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
241
+ var BOOLEAN_TRUE_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
242
+ var PROCESS_SESSION_ID = crypto.randomUUID();
243
+ var SENSITIVE_KEYWORDS = [
244
+ "token",
245
+ "secret",
246
+ "password",
247
+ "passwd",
248
+ "api_key",
249
+ "apikey",
250
+ "authorization",
251
+ "cookie",
252
+ "session",
253
+ "credentials",
254
+ "bearer"
255
+ ];
256
+ var SENSITIVE_INLINE_KEY_PATTERN = "(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer)";
257
+ var INLINE_SENSITIVE_ASSIGNMENT_PATTERN = new RegExp(`\\b(${SENSITIVE_INLINE_KEY_PATTERN})\\s*([:=])\\s*([^\\s,;]+)`, "giu");
258
+ var INLINE_SENSITIVE_FLAG_PATTERN = new RegExp(`(--${SENSITIVE_INLINE_KEY_PATTERN})(=|\\s+)([^\\s,;]+)`, "giu");
259
+ var ABSOLUTE_PATH_TOKEN_PATTERN = /(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;
260
+ var EMAIL_PATTERN = /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/giu;
261
+ var BEARER_TOKEN_PATTERN = /bearer\s+[a-z0-9._=-]+/giu;
262
+ 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;
263
+ function queuePath(globalPmRoot) {
264
+ return path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
265
+ }
266
+ function telemetryRuntimeDirectory(globalPmRoot) {
267
+ return path.dirname(queuePath(globalPmRoot));
268
+ }
269
+ function runtimeStatePath(globalPmRoot) {
270
+ return path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
271
+ }
272
+ function flushLockPath(globalPmRoot) {
273
+ return path.join(globalPmRoot, "runtime", "telemetry", "flush.lock");
274
+ }
275
+ function flushSpawnLockPath(globalPmRoot) {
276
+ return path.join(globalPmRoot, "runtime", "telemetry", "flush.spawn.lock");
277
+ }
278
+ function telemetryFlushRunnerPath() {
279
+ return path.join(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]), "dist", "cli", "telemetry-flush.js");
280
+ }
281
+ function shouldFlushInline() {
282
+ if (parseBooleanTrueLike(process.env[PM_TELEMETRY_INLINE_FLUSH_ENV])) {
283
+ return true;
284
+ }
285
+ if (parseBooleanTrueLike(process.env[PM_TELEMETRY_FLUSH_CHILD_ENV])) {
286
+ return true;
287
+ }
288
+ const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
289
+ return typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test";
290
+ }
291
+ async function readRuntimeState(globalPmRoot) {
292
+ const raw = await readFileIfExists(runtimeStatePath(globalPmRoot));
293
+ if (!raw || raw.trim().length === 0) {
294
+ return {};
295
+ }
296
+ try {
297
+ const parsed = JSON.parse(raw);
298
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
299
+ return {};
300
+ }
301
+ return parsed;
302
+ } catch {
303
+ return {};
304
+ }
305
+ }
306
+ async function writeRuntimeState(globalPmRoot, patch) {
307
+ try {
308
+ const current = await readRuntimeState(globalPmRoot);
309
+ const next = {
310
+ ...current,
311
+ ...patch
312
+ };
313
+ const normalized = Object.fromEntries(Object.entries(next).filter(([, value]) => value !== void 0).sort((left, right) => left[0].localeCompare(right[0])));
314
+ await writeFileAtomic(runtimeStatePath(globalPmRoot), `${JSON.stringify(normalized, null, 2)}
315
+ `);
316
+ } catch {
317
+ }
318
+ }
319
+ function isSensitiveKey(key) {
320
+ const normalized = key.trim().toLowerCase().replaceAll("-", "_").replaceAll(/[^a-z0-9_]+/g, "_");
321
+ const tokens = normalized.split("_").filter((token) => token.length > 0);
322
+ return SENSITIVE_KEYWORDS.some((keyword) => normalized === keyword || normalized.endsWith(`_${keyword}`) || tokens.includes(keyword));
323
+ }
324
+ function redactInlineSensitiveAssignments(input) {
325
+ const withoutAssignments = input.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_PATTERN, (_match, key, delimiter) => `${key}${delimiter}[redacted]`);
326
+ return withoutAssignments.replaceAll(INLINE_SENSITIVE_FLAG_PATTERN, (_match, flag, delimiter) => `${flag}${delimiter}[redacted]`);
327
+ }
328
+ function redactAbsolutePathTokens(input) {
329
+ return input.replaceAll(ABSOLUTE_PATH_TOKEN_PATTERN, (_match, prefix) => `${prefix}[redacted_path]`);
330
+ }
331
+ function sanitizeCommonSensitiveTokens(input) {
332
+ const withoutEmails = input.replaceAll(EMAIL_PATTERN, "[redacted_email]");
333
+ const withoutBearer = withoutEmails.replaceAll(BEARER_TOKEN_PATTERN, "bearer [redacted_token]");
334
+ return withoutBearer.replaceAll(PRIVATE_IP_PATTERN, "[redacted_ip]");
335
+ }
336
+ function sanitizeStringRedacted(input) {
337
+ const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);
338
+ const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
339
+ const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
340
+ const trimmed = withoutAbsolutePaths.trim();
341
+ if (trimmed.startsWith("/") && trimmed.length > 1) {
342
+ return "[redacted_path]";
343
+ }
344
+ if (withoutAbsolutePaths.length > 512) {
345
+ return `${withoutAbsolutePaths.slice(0, 509)}...`;
346
+ }
347
+ return withoutAbsolutePaths;
348
+ }
349
+ function sanitizeStringMax(input) {
350
+ const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);
351
+ const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
352
+ const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
353
+ const trimmed = withoutAbsolutePaths.trim();
354
+ if (trimmed.startsWith("/") && trimmed.length > 1) {
355
+ return "[redacted_path]";
356
+ }
357
+ if (withoutAbsolutePaths.length > 2048) {
358
+ return `${withoutAbsolutePaths.slice(0, 2045)}...`;
359
+ }
360
+ return withoutAbsolutePaths;
361
+ }
362
+ function sanitizeString(input, captureLevel = "redacted") {
363
+ if (captureLevel === "max") {
364
+ return sanitizeStringMax(input);
365
+ }
366
+ return sanitizeStringRedacted(input);
367
+ }
368
+ function sanitizeValue(value, keyHint, captureLevel = "redacted", depth = 0) {
369
+ if (keyHint && isSensitiveKey(keyHint)) {
370
+ return "[redacted]";
371
+ }
372
+ if (value === null || value === void 0) {
373
+ return value;
374
+ }
375
+ if (typeof value === "string") {
376
+ return sanitizeString(value, captureLevel);
377
+ }
378
+ if (typeof value === "number" || typeof value === "boolean") {
379
+ return value;
380
+ }
381
+ if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
382
+ return "[depth_truncated]";
383
+ }
384
+ if (Array.isArray(value)) {
385
+ return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => sanitizeValue(entry, void 0, captureLevel, depth + 1));
386
+ }
387
+ if (typeof value === "object") {
388
+ const record = value;
389
+ const sanitized = {};
390
+ for (const [key, nested] of Object.entries(record)) {
391
+ sanitized[key] = sanitizeValue(nested, key, captureLevel, depth + 1);
392
+ }
393
+ return sanitized;
394
+ }
395
+ return String(value);
396
+ }
397
+ function sanitizeCommandArgs(args, captureLevel = "redacted") {
398
+ const sanitized = [];
399
+ let nextIsSensitiveValue = false;
400
+ for (const rawArg of args) {
401
+ const arg = sanitizeString(rawArg, captureLevel);
402
+ if (nextIsSensitiveValue) {
403
+ sanitized.push("[redacted]");
404
+ nextIsSensitiveValue = false;
405
+ continue;
406
+ }
407
+ if (arg.startsWith("--")) {
408
+ const withoutPrefix = arg.slice(2);
409
+ const delimiterIndex = withoutPrefix.indexOf("=");
410
+ if (delimiterIndex >= 0) {
411
+ const key = withoutPrefix.slice(0, delimiterIndex);
412
+ const value = withoutPrefix.slice(delimiterIndex + 1);
413
+ if (isSensitiveKey(key)) {
414
+ sanitized.push(`--${key}=[redacted]`);
415
+ } else {
416
+ sanitized.push(`--${key}=${sanitizeString(value, captureLevel)}`);
417
+ }
418
+ continue;
419
+ }
420
+ if (isSensitiveKey(withoutPrefix)) {
421
+ sanitized.push(`--${withoutPrefix}`);
422
+ nextIsSensitiveValue = true;
423
+ continue;
424
+ }
425
+ }
426
+ sanitized.push(arg);
427
+ }
428
+ return sanitized;
429
+ }
430
+ function normalizeCaptureLevel(value) {
431
+ const normalized = value?.trim().toLowerCase();
432
+ if (normalized === "minimal" || normalized === "redacted" || normalized === "max") {
433
+ return normalized;
434
+ }
435
+ return "redacted";
436
+ }
437
+ function parseBooleanTrueLike(value) {
438
+ return BOOLEAN_TRUE_VALUES.has((value ?? "").trim().toLowerCase());
439
+ }
440
+ function normalizePmVersion(value) {
441
+ const trimmed = value?.trim() ?? "";
442
+ return trimmed.length > 0 ? trimmed : "0.0.0";
443
+ }
444
+ function normalizeTelemetryErrorCode(value) {
445
+ const normalized = value?.trim();
446
+ return normalized && normalized.length > 0 ? normalized : void 0;
447
+ }
448
+ function normalizeTelemetryExitCode(exitCode, ok) {
449
+ if (Number.isFinite(exitCode)) {
450
+ return Math.max(0, Math.trunc(exitCode ?? 0));
451
+ }
452
+ return ok ? 0 : 1;
453
+ }
454
+ function normalizeTelemetryErrorCategory(params) {
455
+ if (params.ok) {
456
+ return void 0;
457
+ }
458
+ if (typeof params.errorCategory === "string" && params.errorCategory.trim().length > 0) {
459
+ return params.errorCategory;
460
+ }
461
+ if (typeof params.errorCode === "string" && params.errorCode.trim().length > 0) {
462
+ return resolveTelemetryErrorCategory(params.errorCode);
463
+ }
464
+ return "unknown";
465
+ }
466
+ function resolveTelemetrySourceContext(globalOptions) {
467
+ const override = (process.env[PM_TELEMETRY_SOURCE_CONTEXT_ENV] ?? "").trim().toLowerCase();
468
+ if (PM_TELEMETRY_SOURCE_CONTEXT_SET.has(override)) {
469
+ return {
470
+ source_context: override,
471
+ source_context_source: "env_override"
472
+ };
473
+ }
474
+ const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
475
+ if (typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test") {
476
+ return {
477
+ source_context: "test",
478
+ source_context_source: "inferred"
479
+ };
480
+ }
481
+ const nonTty = process.stdin.isTTY !== true || process.stdout.isTTY !== true;
482
+ const ci = parseBooleanTrueLike(process.env.CI);
483
+ const scriptLikeMode = globalOptions.json === true || globalOptions.quiet === true;
484
+ if (nonTty || ci || scriptLikeMode) {
485
+ return {
486
+ source_context: "automation",
487
+ source_context_source: "inferred"
488
+ };
489
+ }
490
+ return {
491
+ source_context: "user",
492
+ source_context_source: "inferred"
493
+ };
494
+ }
495
+ function hashWithInstallationId(installationId, value) {
496
+ return crypto.createHash("sha256").update(`${installationId}:${value}`).digest("hex");
497
+ }
498
+ function normalizeForHash(value, depth = 0) {
499
+ if (value === null || value === void 0) {
500
+ return value;
501
+ }
502
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
503
+ return value;
504
+ }
505
+ if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
506
+ return "[depth_truncated]";
507
+ }
508
+ if (Array.isArray(value)) {
509
+ return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => normalizeForHash(entry, depth + 1));
510
+ }
511
+ if (typeof value === "object") {
512
+ const record = value;
513
+ const normalized = {};
514
+ const sortedKeys = Object.keys(record).sort((left, right) => left.localeCompare(right));
515
+ for (const key of sortedKeys) {
516
+ normalized[key] = normalizeForHash(record[key], depth + 1);
517
+ }
518
+ return normalized;
519
+ }
520
+ return String(value);
521
+ }
522
+ function hashTelemetryValue(installationId, value) {
523
+ return hashWithInstallationId(installationId, JSON.stringify(normalizeForHash(value)));
524
+ }
525
+ function hashCommandArgs(installationId, args) {
526
+ return {
527
+ hashes: args.map((arg) => hashWithInstallationId(installationId, arg)),
528
+ digest: hashWithInstallationId(installationId, args.join("\0"))
529
+ };
530
+ }
531
+ function hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage) {
532
+ const normalizedMessage = sanitizeString(errorMessage ?? "", "redacted");
533
+ const fingerprintSource = `${command}\0${errorCode2 ?? "unknown_error"}\0${normalizedMessage}`;
534
+ return hashWithInstallationId(installationId, fingerprintSource);
535
+ }
536
+ function telemetryDisabledByEnvironment() {
537
+ 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());
538
+ }
539
+ function resolveOtelTracesEndpoint() {
540
+ if (PM_TELEMETRY_OTEL_DISABLED_VALUES.has((process.env[PM_TELEMETRY_OTEL_DISABLED_ENV] ?? "").trim().toLowerCase())) {
541
+ return null;
542
+ }
543
+ const directEndpoint = (process.env[OTEL_TRACES_ENDPOINT_ENV] ?? "").trim();
544
+ if (directEndpoint.length > 0) {
545
+ try {
546
+ return new URL(directEndpoint).toString();
547
+ } catch {
548
+ return null;
549
+ }
550
+ }
551
+ const baseEndpoint = (process.env[OTEL_BASE_ENDPOINT_ENV] ?? "").trim();
552
+ if (baseEndpoint.length === 0) {
553
+ return null;
554
+ }
555
+ try {
556
+ const url = new URL(baseEndpoint);
557
+ const normalizedPath = url.pathname.replace(/\/+$/, "");
558
+ if (!normalizedPath.endsWith("/v1/traces")) {
559
+ url.pathname = `${normalizedPath.length === 0 ? "" : normalizedPath}/v1/traces`;
560
+ }
561
+ return url.toString();
562
+ } catch {
563
+ return null;
564
+ }
565
+ }
566
+ function isoToUnixNano(iso) {
567
+ const parsedMs = Date.parse(iso);
568
+ const epochMs = Number.isNaN(parsedMs) ? Date.now() : parsedMs;
569
+ return `${BigInt(epochMs) * 1000000n}`;
570
+ }
571
+ function otlpStringAttribute(key, value) {
572
+ return {
573
+ key,
574
+ value: { stringValue: value }
575
+ };
576
+ }
577
+ function otlpBoolAttribute(key, value) {
578
+ return {
579
+ key,
580
+ value: { boolValue: value }
581
+ };
582
+ }
583
+ function otlpIntAttribute(key, value) {
584
+ return {
585
+ key,
586
+ value: { intValue: String(Math.max(0, Math.trunc(value))) }
587
+ };
588
+ }
589
+ async function exportLocalOtelSpan(activeCommand, outcome, finishedAtIso, durationMs) {
590
+ 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) {
591
+ return;
592
+ }
593
+ const serviceNameCandidate = sanitizeString((process.env[OTEL_SERVICE_NAME_ENV] ?? "").trim());
594
+ const serviceName = serviceNameCandidate.length > 0 ? serviceNameCandidate : "pm-cli";
595
+ const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
596
+ const normalizedErrorCode = normalizeTelemetryErrorCode(outcome.error_code);
597
+ const normalizedErrorCategory = normalizeTelemetryErrorCategory({
598
+ ok: outcome.ok,
599
+ errorCode: normalizedErrorCode,
600
+ errorCategory: outcome.error_category
601
+ });
602
+ const attributes = [
603
+ otlpStringAttribute("pm.command", sanitizeString(activeCommand.command)),
604
+ otlpStringAttribute("pm.version", activeCommand.pm_version),
605
+ otlpStringAttribute("pm.source_context", activeCommand.source_context),
606
+ otlpStringAttribute("pm.source_context_source", activeCommand.source_context_source),
607
+ otlpStringAttribute("pm.installation_id", activeCommand.installation_id),
608
+ otlpStringAttribute("pm.session_id", PROCESS_SESSION_ID),
609
+ otlpStringAttribute("pm.pm_root_hash", activeCommand.pm_root_hash),
610
+ otlpStringAttribute("pm.cwd_hash", activeCommand.cwd_hash),
611
+ otlpBoolAttribute("pm.ok", outcome.ok),
612
+ otlpIntAttribute("pm.exit_code", normalizedExitCode),
613
+ otlpIntAttribute("pm.duration_ms", durationMs)
614
+ ];
615
+ if (typeof normalizedErrorCode === "string") {
616
+ attributes.push(otlpStringAttribute("pm.error_code", normalizedErrorCode));
617
+ }
618
+ if (typeof normalizedErrorCategory === "string") {
619
+ attributes.push(otlpStringAttribute("pm.error_category", normalizedErrorCategory));
620
+ }
621
+ if (typeof outcome.error === "string" && outcome.error.trim().length > 0) {
622
+ attributes.push(otlpStringAttribute("pm.error", sanitizeString(outcome.error)));
623
+ }
624
+ const payload = {
625
+ resourceSpans: [
626
+ {
627
+ resource: {
628
+ attributes: [otlpStringAttribute("service.name", serviceName)]
629
+ },
630
+ scopeSpans: [
631
+ {
632
+ scope: {
633
+ name: "pm-cli.telemetry",
634
+ version: "1"
635
+ },
636
+ spans: [
637
+ {
638
+ traceId: activeCommand.otel_trace_id,
639
+ spanId: activeCommand.otel_span_id,
640
+ name: `pm.command.${sanitizeString(activeCommand.command)}`,
641
+ kind: 1,
642
+ startTimeUnixNano: isoToUnixNano(activeCommand.started_at),
643
+ endTimeUnixNano: isoToUnixNano(finishedAtIso),
644
+ attributes,
645
+ status: {
646
+ code: outcome.ok ? 1 : 2,
647
+ message: outcome.ok ? "" : sanitizeString(outcome.error ?? "command_failed")
648
+ }
649
+ }
650
+ ]
651
+ }
652
+ ]
653
+ }
654
+ ]
655
+ };
656
+ const response = await fetch(activeCommand.otel_traces_endpoint, {
657
+ method: "POST",
658
+ headers: {
659
+ "content-type": "application/json"
660
+ },
661
+ body: JSON.stringify(payload),
662
+ signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
663
+ });
664
+ if (!response.ok) {
665
+ throw new Error(`local_otel_export_http_${response.status}`);
666
+ }
667
+ }
668
+ function summarizeResult(result, captureLevel = "redacted") {
669
+ if (result === null || result === void 0) {
670
+ return { type: "nullish" };
671
+ }
672
+ if (typeof result === "string") {
673
+ return { type: "string", value: sanitizeString(result, captureLevel) };
674
+ }
675
+ if (typeof result === "number" || typeof result === "boolean") {
676
+ return { type: typeof result, value: result };
677
+ }
678
+ if (Array.isArray(result)) {
679
+ return {
680
+ type: "array",
681
+ length: result.length,
682
+ sample: result.slice(0, 5).map((entry) => sanitizeValue(entry, void 0, captureLevel))
683
+ };
684
+ }
685
+ if (typeof result === "object") {
686
+ const record = result;
687
+ const keys = Object.keys(record).sort((left, right) => left.localeCompare(right));
688
+ const sanitized = {};
689
+ let previewBytes = 0;
690
+ for (const key of keys.slice(0, 25)) {
691
+ const sanitizedValue = sanitizeValue(record[key], key, captureLevel);
692
+ const entrySize = JSON.stringify(sanitizedValue)?.length ?? 0;
693
+ if (previewBytes + entrySize > TELEMETRY_RESULT_PREVIEW_MAX_BYTES) {
694
+ sanitized[key] = "[preview_truncated]";
695
+ break;
696
+ }
697
+ previewBytes += entrySize;
698
+ sanitized[key] = sanitizedValue;
699
+ }
700
+ return {
701
+ type: "object",
702
+ key_count: keys.length,
703
+ keys_preview: keys.slice(0, 50),
704
+ preview: sanitized
705
+ };
706
+ }
707
+ return { type: typeof result, value: String(result) };
708
+ }
709
+ function buildCommandStartPayload(params) {
710
+ const { captureLevel, context, pmVersion, sourceContext, pmRootHash, cwdHash, installationId } = params;
711
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
712
+ const hashedArgs = hashCommandArgs(installationId, context.args);
713
+ const commandInvocationDigest = hashWithInstallationId(installationId, `${context.command}\0${context.args.join("\0")}`);
714
+ const commandOptionsDigest = hashTelemetryValue(installationId, context.options);
715
+ const globalOptionsDigest = hashTelemetryValue(installationId, context.global);
716
+ if (captureLevel === "minimal") {
717
+ return {
718
+ capture_level: captureLevel,
719
+ pm_version: pmVersion,
720
+ source_context: sourceContext.source_context,
721
+ source_context_source: sourceContext.source_context_source,
722
+ command_taxonomy: commandTaxonomy,
723
+ command_args_digest: hashedArgs.digest,
724
+ command_invocation_digest: commandInvocationDigest,
725
+ command_options_digest: commandOptionsDigest,
726
+ global_options_digest: globalOptionsDigest
727
+ };
728
+ }
729
+ return {
730
+ pm_version: pmVersion,
731
+ source_context: sourceContext.source_context,
732
+ source_context_source: sourceContext.source_context_source,
733
+ command_taxonomy: commandTaxonomy,
734
+ command_args: sanitizeCommandArgs(context.args, captureLevel),
735
+ command_args_hashes: hashedArgs.hashes,
736
+ command_args_digest: hashedArgs.digest,
737
+ command_invocation_digest: commandInvocationDigest,
738
+ command_options: sanitizeValue(context.options, void 0, captureLevel),
739
+ command_options_digest: commandOptionsDigest,
740
+ global_options: sanitizeValue(context.global, void 0, captureLevel),
741
+ global_options_digest: globalOptionsDigest,
742
+ pm_root_hash: pmRootHash,
743
+ cwd_hash: cwdHash,
744
+ capture_level: captureLevel,
745
+ runtime: {
746
+ node: process.version,
747
+ platform: process.platform,
748
+ arch: process.arch,
749
+ hostname_hash: hashWithInstallationId(installationId, os.hostname()),
750
+ stdin_tty: process.stdin.isTTY === true,
751
+ stdout_tty: process.stdout.isTTY === true
752
+ }
753
+ };
754
+ }
755
+ function buildCommandFinishPayload(params) {
756
+ const { captureLevel, pmVersion, sourceContext, outcome, durationMs, startedAt, command, installationId, commandTaxonomy, exitCode, errorCode: errorCode2, errorCategory, commandResolution, resolutionStage } = params;
757
+ const errorFingerprint = outcome.ok === false ? hashTelemetryErrorFingerprint(installationId, command, errorCode2, outcome.error) : void 0;
758
+ if (captureLevel === "minimal") {
759
+ return {
760
+ capture_level: captureLevel,
761
+ pm_version: pmVersion,
762
+ source_context: sourceContext.source_context,
763
+ source_context_source: sourceContext.source_context_source,
764
+ command_taxonomy: commandTaxonomy,
765
+ command_resolution: commandResolution,
766
+ resolution_stage: resolutionStage,
767
+ ok: outcome.ok,
768
+ exit_code: exitCode,
769
+ error_code: errorCode2,
770
+ error_category: errorCategory,
771
+ error: outcome.error ? sanitizeString(outcome.error, "redacted") : void 0,
772
+ error_fingerprint: errorFingerprint,
773
+ duration_ms: durationMs
774
+ };
775
+ }
776
+ return {
777
+ capture_level: captureLevel,
778
+ pm_version: pmVersion,
779
+ source_context: sourceContext.source_context,
780
+ source_context_source: sourceContext.source_context_source,
781
+ command_taxonomy: commandTaxonomy,
782
+ command_resolution: commandResolution,
783
+ resolution_stage: resolutionStage,
784
+ ok: outcome.ok,
785
+ exit_code: exitCode,
786
+ error_code: errorCode2,
787
+ error_category: errorCategory,
788
+ error: outcome.error ? sanitizeString(outcome.error, captureLevel) : void 0,
789
+ error_fingerprint: errorFingerprint,
790
+ duration_ms: durationMs,
791
+ started_at: startedAt,
792
+ result_summary: summarizeResult(outcome.result, captureLevel)
793
+ };
794
+ }
795
+ function buildCommandErrorPayload(params) {
796
+ const { captureLevel, pmVersion, sourceContext, command, commandTaxonomy, commandResolution, resolutionStage, args, options, pmRootHash, cwdHash, installationId, errorCode: errorCode2, errorMessage, errorCategory, exitCode } = params;
797
+ const attemptedArgHashes = hashCommandArgs(installationId, args);
798
+ const attemptedCommandDigest = hashWithInstallationId(installationId, command);
799
+ const attemptedOptionsDigest = hashTelemetryValue(installationId, options);
800
+ const errorFingerprint = hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage);
801
+ if (captureLevel === "minimal") {
802
+ return {
803
+ capture_level: captureLevel,
804
+ pm_version: pmVersion,
805
+ source_context: sourceContext.source_context,
806
+ source_context_source: sourceContext.source_context_source,
807
+ command_taxonomy: commandTaxonomy,
808
+ command_resolution: commandResolution,
809
+ resolution_stage: resolutionStage,
810
+ attempted_command_digest: attemptedCommandDigest,
811
+ attempted_args_digest: attemptedArgHashes.digest,
812
+ attempted_options_digest: attemptedOptionsDigest,
813
+ error_code: errorCode2,
814
+ error_category: errorCategory,
815
+ exit_code: exitCode,
816
+ error: sanitizeString(errorMessage, "redacted"),
817
+ error_fingerprint: errorFingerprint
818
+ };
819
+ }
820
+ return {
821
+ capture_level: captureLevel,
822
+ pm_version: pmVersion,
823
+ source_context: sourceContext.source_context,
824
+ source_context_source: sourceContext.source_context_source,
825
+ command_taxonomy: commandTaxonomy,
826
+ command_resolution: commandResolution,
827
+ resolution_stage: resolutionStage,
828
+ attempted_command: sanitizeString(command, captureLevel),
829
+ attempted_command_digest: attemptedCommandDigest,
830
+ attempted_args: sanitizeCommandArgs(args, captureLevel),
831
+ attempted_args_hashes: attemptedArgHashes.hashes,
832
+ attempted_args_digest: attemptedArgHashes.digest,
833
+ attempted_options: sanitizeValue(options, void 0, captureLevel),
834
+ attempted_options_digest: attemptedOptionsDigest,
835
+ error_code: errorCode2,
836
+ error_category: errorCategory,
837
+ exit_code: exitCode,
838
+ error: sanitizeString(errorMessage, captureLevel),
839
+ error_fingerprint: errorFingerprint,
840
+ pm_root_hash: pmRootHash,
841
+ cwd_hash: cwdHash,
842
+ runtime: {
843
+ node: process.version,
844
+ platform: process.platform,
845
+ arch: process.arch,
846
+ hostname_hash: hashWithInstallationId(installationId, os.hostname()),
847
+ stdin_tty: process.stdin.isTTY === true,
848
+ stdout_tty: process.stdout.isTTY === true
849
+ }
850
+ };
851
+ }
852
+ async function ensureInstallationId(globalPmRoot) {
853
+ const settings = await readSettings(globalPmRoot);
854
+ let changed = false;
855
+ if (settings.telemetry.installation_id.trim().length === 0) {
856
+ settings.telemetry.installation_id = crypto.randomUUID();
857
+ changed = true;
858
+ }
859
+ if (changed) {
860
+ await writeSettings(globalPmRoot, settings, "telemetry:install_id");
861
+ }
862
+ return {
863
+ installationId: settings.telemetry.installation_id,
864
+ endpoint: settings.telemetry.endpoint,
865
+ retentionDays: Math.max(1, Math.trunc(settings.telemetry.retention_days))
866
+ };
867
+ }
868
+ async function enqueueTelemetryEvent(globalPmRoot, event) {
869
+ const queued = {
870
+ client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,
871
+ event,
872
+ attempts: 0
873
+ };
874
+ let serialized = JSON.stringify(queued);
875
+ if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {
876
+ const trimmed = { ...event, payload: { ...event.payload, result_summary: { truncated: true, reason: "payload_size_exceeded", original_bytes: serialized.length } } };
877
+ const trimmedQueued = {
878
+ client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,
879
+ event: trimmed,
880
+ attempts: 0
881
+ };
882
+ serialized = JSON.stringify(trimmedQueued);
883
+ }
884
+ await withQueueMutation(async () => {
885
+ await appendLineAtomic(queuePath(globalPmRoot), serialized);
886
+ });
887
+ }
888
+ function parseQueueLines(raw) {
889
+ const entries = [];
890
+ for (const line of raw.split("\n")) {
891
+ const trimmed = line.trim();
892
+ if (trimmed.length === 0) {
893
+ continue;
894
+ }
895
+ try {
896
+ const parsed = JSON.parse(trimmed);
897
+ if (parsed && typeof parsed === "object" && parsed.event && typeof parsed.event === "object" && typeof parsed.attempts === "number" && (parsed.client_schema_version === void 0 || typeof parsed.client_schema_version === "number" && Number.isFinite(parsed.client_schema_version))) {
898
+ entries.push(parsed);
899
+ }
900
+ } catch {
901
+ }
902
+ }
903
+ return entries;
904
+ }
905
+ function nextRetryIso(attempts) {
906
+ const delay = Math.min(TELEMETRY_RETRY_BASE_DELAY_MS * 2 ** Math.max(attempts - 1, 0), TELEMETRY_MAX_RETRY_DELAY_MS);
907
+ return new Date(Date.now() + delay).toISOString();
908
+ }
909
+ function isDueForRetry(entry) {
910
+ if (typeof entry.next_attempt_after !== "string" || entry.next_attempt_after.trim().length === 0) {
911
+ return true;
912
+ }
913
+ const dueAtMs = Date.parse(entry.next_attempt_after);
914
+ if (Number.isNaN(dueAtMs)) {
915
+ return true;
916
+ }
917
+ return dueAtMs <= Date.now();
918
+ }
919
+ function retentionCutoffMs(retentionDays) {
920
+ const normalizedDays = Number.isFinite(retentionDays) ? Math.max(1, Math.trunc(retentionDays)) : 1;
921
+ return Date.now() - normalizedDays * MILLISECONDS_PER_DAY;
922
+ }
923
+ function isExpiredQueueEntry(entry, cutoffMs) {
924
+ const occurredAt = entry.event?.occurred_at;
925
+ if (typeof occurredAt !== "string" || occurredAt.trim().length === 0) {
926
+ return false;
927
+ }
928
+ const occurredAtMs = Date.parse(occurredAt);
929
+ if (Number.isNaN(occurredAtMs)) {
930
+ return false;
931
+ }
932
+ return occurredAtMs < cutoffMs;
933
+ }
934
+ function pruneExpiredQueueEntries(entries, retentionDays) {
935
+ const cutoffMs = retentionCutoffMs(retentionDays);
936
+ const retained = [];
937
+ let prunedCount = 0;
938
+ for (const entry of entries) {
939
+ const serializedSize = JSON.stringify(entry).length;
940
+ const oversized = serializedSize > TELEMETRY_MAX_EVENT_BYTES;
941
+ if (oversized || isExpiredQueueEntry(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {
942
+ prunedCount += 1;
943
+ continue;
944
+ }
945
+ retained.push(entry);
946
+ }
947
+ return { entries: retained, prunedCount };
948
+ }
949
+ async function rewriteQueue(globalPmRoot, entries) {
950
+ const serialized = entries.map((entry) => JSON.stringify(entry)).join("\n");
951
+ const contents = serialized.length > 0 ? `${serialized}
952
+ ` : "";
953
+ for (let attempt = 0; ; attempt += 1) {
954
+ try {
955
+ await writeFileAtomic(queuePath(globalPmRoot), contents);
956
+ return;
957
+ } catch (error) {
958
+ const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];
959
+ if (retryDelay === void 0 || !isRetryableQueueRewriteError(error)) {
960
+ throw error;
961
+ }
962
+ await sleep(retryDelay);
963
+ }
964
+ }
965
+ }
966
+ function isRetryableQueueRewriteError(error) {
967
+ if (typeof error !== "object" || error === null || !("code" in error)) {
968
+ return false;
969
+ }
970
+ const code = error.code;
971
+ return code === "EACCES" || code === "EBUSY" || code === "EPERM";
972
+ }
973
+ function sleep(milliseconds) {
974
+ return new Promise((resolve) => {
975
+ setTimeout(resolve, milliseconds);
976
+ });
977
+ }
978
+ async function cleanupTelemetryQueueTempOrphans(globalPmRoot, maxAgeMs = TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS) {
979
+ try {
980
+ const dirPath = telemetryRuntimeDirectory(globalPmRoot);
981
+ const entries = await readdir(dirPath, { withFileTypes: true });
982
+ const cutoffMs = Date.now() - Math.max(0, maxAgeMs);
983
+ await Promise.all(entries.filter((entry) => entry.isFile() && /^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(entry.name)).map(async (entry) => {
984
+ const candidate = path.join(dirPath, entry.name);
985
+ const candidateStats = await stat(candidate);
986
+ if (candidateStats.mtimeMs < cutoffMs) {
987
+ await rm(candidate, { force: true });
988
+ }
989
+ }));
990
+ } catch {
991
+ }
992
+ }
993
+ async function withQueueMutation(operation) {
994
+ const run = _queueMutationPromise.catch(() => {
995
+ }).then(operation);
996
+ _queueMutationPromise = run.catch(() => {
997
+ });
998
+ return run;
999
+ }
1000
+ async function readCurrentQueueEntries(globalPmRoot) {
1001
+ const raw = await readFileIfExists(queuePath(globalPmRoot));
1002
+ if (raw === null || raw.trim().length === 0) {
1003
+ return [];
1004
+ }
1005
+ return parseQueueLines(raw);
1006
+ }
1007
+ async function removeFlushedEntriesFromCurrentQueue(globalPmRoot, flushedIds, retentionDays) {
1008
+ return withQueueMutation(async () => {
1009
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1010
+ const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1011
+ const remaining = retainedEntries.filter((entry) => !flushedIds.has(entry.event.event_id));
1012
+ await rewriteQueue(globalPmRoot, remaining);
1013
+ return remaining;
1014
+ });
1015
+ }
1016
+ async function markFailedEntriesInCurrentQueue(globalPmRoot, failedIds, attemptTime, retentionDays) {
1017
+ return withQueueMutation(async () => {
1018
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1019
+ const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1020
+ const retried = retainedEntries.map((entry) => {
1021
+ if (!failedIds.has(entry.event.event_id)) {
1022
+ return entry;
1023
+ }
1024
+ const attempts = entry.attempts + 1;
1025
+ return {
1026
+ ...entry,
1027
+ attempts,
1028
+ last_attempt_at: attemptTime,
1029
+ next_attempt_after: nextRetryIso(attempts)
1030
+ };
1031
+ });
1032
+ await rewriteQueue(globalPmRoot, retried);
1033
+ return retried;
1034
+ });
1035
+ }
1036
+ async function flushQueue(globalPmRoot, endpoint, retentionDays) {
1037
+ await cleanupTelemetryQueueTempOrphans(globalPmRoot);
1038
+ const normalizedEndpoint = endpoint.trim();
1039
+ if (normalizedEndpoint.length === 0) {
1040
+ return;
1041
+ }
1042
+ const raw = await readFileIfExists(queuePath(globalPmRoot));
1043
+ if (raw === null || raw.trim().length === 0) {
1044
+ await writeRuntimeState(globalPmRoot, {
1045
+ endpoint: normalizedEndpoint,
1046
+ queue_entries: 0
1047
+ });
1048
+ return;
1049
+ }
1050
+ const queueEntries = parseQueueLines(raw);
1051
+ if (queueEntries.length === 0) {
1052
+ await writeRuntimeState(globalPmRoot, {
1053
+ endpoint: normalizedEndpoint,
1054
+ queue_entries: 0
1055
+ });
1056
+ return;
1057
+ }
1058
+ const { entries: retainedEntries, prunedCount } = pruneExpiredQueueEntries(queueEntries, retentionDays);
1059
+ if (retainedEntries.length === 0) {
1060
+ if (prunedCount > 0) {
1061
+ await rewriteQueue(globalPmRoot, []);
1062
+ }
1063
+ await writeRuntimeState(globalPmRoot, {
1064
+ endpoint: normalizedEndpoint,
1065
+ queue_entries: 0
1066
+ });
1067
+ return;
1068
+ }
1069
+ const dueEntries = retainedEntries.filter((entry) => isDueForRetry(entry)).slice(0, TELEMETRY_FLUSH_BATCH_SIZE);
1070
+ if (dueEntries.length === 0) {
1071
+ if (prunedCount > 0) {
1072
+ await rewriteQueue(globalPmRoot, retainedEntries);
1073
+ }
1074
+ await writeRuntimeState(globalPmRoot, {
1075
+ endpoint: normalizedEndpoint,
1076
+ queue_entries: retainedEntries.length
1077
+ });
1078
+ return;
1079
+ }
1080
+ const dueIds = new Set(dueEntries.map((entry) => entry.event.event_id));
1081
+ const attemptTime = nowIso();
1082
+ const requestHeaders = {
1083
+ "content-type": "application/json"
1084
+ };
1085
+ const ingestKey = process.env.PM_TELEMETRY_INGEST_KEY?.trim();
1086
+ if (ingestKey) {
1087
+ requestHeaders["x-pm-telemetry-key"] = ingestKey;
1088
+ }
1089
+ try {
1090
+ const response = await fetch(normalizedEndpoint, {
1091
+ method: "POST",
1092
+ headers: requestHeaders,
1093
+ body: JSON.stringify({
1094
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1095
+ events: dueEntries.map((entry) => entry.event)
1096
+ }),
1097
+ signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
1098
+ });
1099
+ if (!response.ok) {
1100
+ throw new Error(`telemetry_flush_http_${response.status}`);
1101
+ }
1102
+ } catch (error) {
1103
+ const retried = await markFailedEntriesInCurrentQueue(globalPmRoot, dueIds, attemptTime, retentionDays);
1104
+ const errorMessage = (() => {
1105
+ if (error instanceof Error) {
1106
+ return sanitizeString(error.message, "redacted");
1107
+ }
1108
+ return "telemetry_flush_failed";
1109
+ })();
1110
+ await writeRuntimeState(globalPmRoot, {
1111
+ endpoint: normalizedEndpoint,
1112
+ queue_entries: retried.length,
1113
+ last_attempted_flush_at: attemptTime,
1114
+ last_failed_flush_at: attemptTime,
1115
+ last_failed_flush_error: errorMessage
1116
+ });
1117
+ return;
1118
+ }
1119
+ try {
1120
+ const remaining = await removeFlushedEntriesFromCurrentQueue(globalPmRoot, dueIds, retentionDays);
1121
+ await writeRuntimeState(globalPmRoot, {
1122
+ endpoint: normalizedEndpoint,
1123
+ queue_entries: remaining.length,
1124
+ last_attempted_flush_at: attemptTime,
1125
+ last_successful_flush_at: attemptTime,
1126
+ last_failed_flush_at: void 0,
1127
+ last_failed_flush_error: void 0
1128
+ });
1129
+ } catch (error) {
1130
+ const errorMessage = (() => {
1131
+ if (error instanceof Error) {
1132
+ return sanitizeString(error.message, "redacted");
1133
+ }
1134
+ return "telemetry_flush_failed";
1135
+ })();
1136
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot).catch(() => retainedEntries);
1137
+ await writeRuntimeState(globalPmRoot, {
1138
+ endpoint: normalizedEndpoint,
1139
+ queue_entries: currentEntries.length,
1140
+ last_attempted_flush_at: attemptTime,
1141
+ last_failed_flush_at: attemptTime,
1142
+ last_failed_flush_error: errorMessage
1143
+ });
1144
+ }
1145
+ }
1146
+ async function acquireTelemetryFlushLock(globalPmRoot) {
1147
+ const lockPath = flushLockPath(globalPmRoot);
1148
+ await mkdir(path.dirname(lockPath), { recursive: true });
1149
+ try {
1150
+ await mkdir(lockPath);
1151
+ return true;
1152
+ } catch (error) {
1153
+ if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "EEXIST") {
1154
+ throw error;
1155
+ }
1156
+ }
1157
+ try {
1158
+ const lockStats = await stat(lockPath);
1159
+ if (Date.now() - lockStats.mtimeMs < TELEMETRY_FLUSH_LOCK_STALE_MS) {
1160
+ return false;
1161
+ }
1162
+ await rm(lockPath, { recursive: true, force: true });
1163
+ await mkdir(lockPath);
1164
+ return true;
1165
+ } catch {
1166
+ return false;
1167
+ }
1168
+ }
1169
+ function isFreshDirectoryLock(lockPath, staleMs) {
1170
+ try {
1171
+ return Date.now() - statSync(lockPath).mtimeMs < staleMs;
1172
+ } catch {
1173
+ return false;
1174
+ }
1175
+ }
1176
+ function removeDirectoryLockBestEffort(lockPath) {
1177
+ try {
1178
+ rmSync(lockPath, { recursive: true, force: true });
1179
+ } catch {
1180
+ }
1181
+ }
1182
+ function errorCode(error) {
1183
+ if (typeof error !== "object" || error === null || !("code" in error)) {
1184
+ return void 0;
1185
+ }
1186
+ const code = error.code;
1187
+ return typeof code === "string" ? code : void 0;
1188
+ }
1189
+ function createDirectoryLock(lockPath) {
1190
+ try {
1191
+ mkdirSync(lockPath);
1192
+ return true;
1193
+ } catch (error) {
1194
+ const code = errorCode(error);
1195
+ if (code === "EEXIST") {
1196
+ return false;
1197
+ }
1198
+ if (code !== "ENOENT") {
1199
+ return false;
1200
+ }
1201
+ }
1202
+ try {
1203
+ mkdirSync(path.dirname(lockPath), { recursive: true });
1204
+ mkdirSync(lockPath);
1205
+ return true;
1206
+ } catch {
1207
+ return false;
1208
+ }
1209
+ }
1210
+ function acquireTelemetryFlushSpawnGate(globalPmRoot) {
1211
+ if (isFreshDirectoryLock(flushLockPath(globalPmRoot), TELEMETRY_FLUSH_LOCK_STALE_MS)) {
1212
+ return false;
1213
+ }
1214
+ const lockPath = flushSpawnLockPath(globalPmRoot);
1215
+ try {
1216
+ if (Date.now() - statSync(lockPath).mtimeMs < TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS) {
1217
+ return false;
1218
+ }
1219
+ removeDirectoryLockBestEffort(lockPath);
1220
+ } catch (error) {
1221
+ if (errorCode(error) !== "ENOENT") {
1222
+ return false;
1223
+ }
1224
+ }
1225
+ return createDirectoryLock(lockPath);
1226
+ }
1227
+ function releaseTelemetryFlushSpawnGate(globalPmRoot) {
1228
+ removeDirectoryLockBestEffort(flushSpawnLockPath(globalPmRoot));
1229
+ }
1230
+ async function flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays) {
1231
+ const acquired = await acquireTelemetryFlushLock(globalPmRoot);
1232
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1233
+ if (!acquired) {
1234
+ return;
1235
+ }
1236
+ try {
1237
+ await flushQueue(globalPmRoot, endpoint, retentionDays);
1238
+ } finally {
1239
+ await rm(flushLockPath(globalPmRoot), { recursive: true, force: true }).catch(() => {
1240
+ });
1241
+ }
1242
+ }
1243
+ function scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays) {
1244
+ if (shouldFlushInline()) {
1245
+ const previousFlush = _lastFlushPromise;
1246
+ const nextFlush = flushQueue(globalPmRoot, endpoint, retentionDays).catch(() => {
1247
+ });
1248
+ _lastFlushPromise = Promise.allSettled([previousFlush, nextFlush]).then(() => {
1249
+ });
1250
+ return;
1251
+ }
1252
+ try {
1253
+ const acquiredSpawnGate = acquireTelemetryFlushSpawnGate(globalPmRoot);
1254
+ if (!acquiredSpawnGate) {
1255
+ return;
1256
+ }
1257
+ const child = spawn(process.execPath, [telemetryFlushRunnerPath()], {
1258
+ detached: true,
1259
+ stdio: "ignore",
1260
+ env: {
1261
+ ...process.env,
1262
+ PM_GLOBAL_PATH: globalPmRoot,
1263
+ [PM_TELEMETRY_FLUSH_CHILD_ENV]: "1"
1264
+ }
1265
+ });
1266
+ child.unref();
1267
+ } catch {
1268
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1269
+ }
1270
+ }
1271
+ async function flushTelemetryQueueNow(globalPmRoot = resolveGlobalPmRoot(process.cwd())) {
1272
+ if (telemetryDisabledByEnvironment()) {
1273
+ return;
1274
+ }
1275
+ try {
1276
+ const settings = await readSettings(globalPmRoot);
1277
+ if (!settings.telemetry.enabled) {
1278
+ return;
1279
+ }
1280
+ const { endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1281
+ await flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays);
1282
+ } catch {
1283
+ }
1284
+ }
1285
+ async function startTelemetryCommand(context) {
1286
+ if (telemetryDisabledByEnvironment()) {
1287
+ return null;
1288
+ }
1289
+ if (context.command === "telemetry" && context.args.some((token) => token.trim().toLowerCase() === "clear")) {
1290
+ return null;
1291
+ }
1292
+ try {
1293
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1294
+ const settings = await readSettings(globalPmRoot);
1295
+ if (!settings.telemetry.enabled) {
1296
+ return null;
1297
+ }
1298
+ const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1299
+ const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1300
+ const pmVersion = normalizePmVersion(context.pm_version);
1301
+ const sourceContext = resolveTelemetrySourceContext(context.global);
1302
+ const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1303
+ const cwdHash = hashWithInstallationId(installationId, process.cwd());
1304
+ const otelTracesEndpoint = resolveOtelTracesEndpoint();
1305
+ const occurredAt = nowIso();
1306
+ const event = {
1307
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1308
+ event_id: crypto.randomUUID(),
1309
+ event_type: "command_start",
1310
+ occurred_at: occurredAt,
1311
+ installation_id: installationId,
1312
+ session_id: PROCESS_SESSION_ID,
1313
+ command: context.command,
1314
+ payload: buildCommandStartPayload({
1315
+ captureLevel,
1316
+ context,
1317
+ pmVersion,
1318
+ sourceContext,
1319
+ pmRootHash,
1320
+ cwdHash,
1321
+ installationId
1322
+ })
1323
+ };
1324
+ await enqueueTelemetryEvent(globalPmRoot, event);
1325
+ scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
1326
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
1327
+ return {
1328
+ started_at: occurredAt,
1329
+ started_at_ms: Date.now(),
1330
+ command: context.command,
1331
+ command_taxonomy: commandTaxonomy,
1332
+ pm_version: pmVersion,
1333
+ source_context: sourceContext.source_context,
1334
+ source_context_source: sourceContext.source_context_source,
1335
+ installation_id: installationId,
1336
+ pm_root_hash: pmRootHash,
1337
+ cwd_hash: cwdHash,
1338
+ endpoint,
1339
+ retention_days: retentionDays,
1340
+ global_pm_root: globalPmRoot,
1341
+ capture_level: captureLevel,
1342
+ otel_traces_endpoint: otelTracesEndpoint ?? void 0,
1343
+ otel_trace_id: otelTracesEndpoint ? crypto.randomBytes(16).toString("hex") : void 0,
1344
+ otel_span_id: otelTracesEndpoint ? crypto.randomBytes(8).toString("hex") : void 0
1345
+ };
1346
+ } catch {
1347
+ return null;
1348
+ }
1349
+ }
1350
+ async function finishTelemetryCommand(activeCommand, outcome) {
1351
+ if (!activeCommand) {
1352
+ return;
1353
+ }
1354
+ try {
1355
+ const finishedAt = nowIso();
1356
+ const durationMs = Math.max(0, Date.now() - activeCommand.started_at_ms);
1357
+ const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1358
+ ok: outcome.ok,
1359
+ errorCode: outcome.error_code,
1360
+ errorMessage: outcome.error,
1361
+ exitCode: outcome.exit_code
1362
+ }));
1363
+ const normalizedErrorCategory = normalizeTelemetryErrorCategory({
1364
+ ok: outcome.ok,
1365
+ errorCode: normalizedErrorCode,
1366
+ errorCategory: outcome.error_category
1367
+ });
1368
+ const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
1369
+ const commandResolution = outcome.command_resolution ?? deriveTelemetryCommandResolution({
1370
+ ok: outcome.ok,
1371
+ errorCode: normalizedErrorCode,
1372
+ errorCategory: normalizedErrorCategory
1373
+ });
1374
+ const resolutionStage = outcome.resolution_stage ?? "execute";
1375
+ const event = {
1376
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1377
+ event_id: crypto.randomUUID(),
1378
+ event_type: "command_finish",
1379
+ occurred_at: finishedAt,
1380
+ installation_id: activeCommand.installation_id,
1381
+ session_id: PROCESS_SESSION_ID,
1382
+ command: activeCommand.command,
1383
+ payload: buildCommandFinishPayload({
1384
+ captureLevel: activeCommand.capture_level,
1385
+ pmVersion: activeCommand.pm_version,
1386
+ sourceContext: {
1387
+ source_context: activeCommand.source_context,
1388
+ source_context_source: activeCommand.source_context_source
1389
+ },
1390
+ outcome,
1391
+ durationMs,
1392
+ startedAt: activeCommand.started_at,
1393
+ command: activeCommand.command,
1394
+ installationId: activeCommand.installation_id,
1395
+ commandTaxonomy: activeCommand.command_taxonomy,
1396
+ exitCode: normalizedExitCode,
1397
+ errorCode: normalizedErrorCode,
1398
+ errorCategory: normalizedErrorCategory,
1399
+ commandResolution,
1400
+ resolutionStage
1401
+ })
1402
+ };
1403
+ await enqueueTelemetryEvent(activeCommand.global_pm_root, event);
1404
+ scheduleTelemetryFlush(activeCommand.global_pm_root, activeCommand.endpoint, activeCommand.retention_days);
1405
+ void exportLocalOtelSpan(activeCommand, {
1406
+ ...outcome,
1407
+ exit_code: normalizedExitCode,
1408
+ error_code: normalizedErrorCode,
1409
+ error_category: normalizedErrorCategory
1410
+ }, finishedAt, durationMs).catch(() => {
1411
+ });
1412
+ } catch {
1413
+ }
1414
+ }
1415
+ async function emitTelemetryErrorEvent(context) {
1416
+ if (telemetryDisabledByEnvironment()) {
1417
+ return;
1418
+ }
1419
+ try {
1420
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1421
+ const settings = await readSettings(globalPmRoot);
1422
+ if (!settings.telemetry.enabled) {
1423
+ return;
1424
+ }
1425
+ const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1426
+ const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1427
+ const pmVersion = normalizePmVersion(context.pm_version);
1428
+ const sourceContext = resolveTelemetrySourceContext(context.global);
1429
+ const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1430
+ const cwdHash = hashWithInstallationId(installationId, process.cwd());
1431
+ const occurredAt = nowIso();
1432
+ const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1433
+ ok: false,
1434
+ errorCode: context.error_code,
1435
+ errorMessage: context.error_message,
1436
+ exitCode: context.exit_code
1437
+ })) ?? "unknown_error";
1438
+ const normalizedErrorCategory = context.error_category ?? resolveTelemetryErrorCategory(normalizedErrorCode);
1439
+ const normalizedExitCode = normalizeTelemetryExitCode(context.exit_code, false);
1440
+ const normalizedCommand = context.command.trim().length > 0 ? context.command : "<unknown>";
1441
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(normalizedCommand);
1442
+ const commandResolution = context.command_resolution ?? deriveTelemetryCommandResolution({
1443
+ ok: false,
1444
+ errorCode: normalizedErrorCode,
1445
+ errorCategory: normalizedErrorCategory
1446
+ });
1447
+ const resolutionStage = context.resolution_stage ?? "unknown";
1448
+ const event = {
1449
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1450
+ event_id: crypto.randomUUID(),
1451
+ event_type: "command_error",
1452
+ occurred_at: occurredAt,
1453
+ installation_id: installationId,
1454
+ session_id: PROCESS_SESSION_ID,
1455
+ command: sanitizeString(normalizedCommand, "redacted"),
1456
+ payload: buildCommandErrorPayload({
1457
+ captureLevel,
1458
+ pmVersion,
1459
+ sourceContext,
1460
+ command: normalizedCommand,
1461
+ commandTaxonomy,
1462
+ commandResolution,
1463
+ resolutionStage,
1464
+ args: context.args,
1465
+ options: context.options,
1466
+ pmRootHash,
1467
+ cwdHash,
1468
+ installationId,
1469
+ errorCode: normalizedErrorCode,
1470
+ errorCategory: normalizedErrorCategory,
1471
+ exitCode: normalizedExitCode,
1472
+ errorMessage: context.error_message
1473
+ })
1474
+ };
1475
+ await enqueueTelemetryEvent(globalPmRoot, event);
1476
+ scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
1477
+ } catch {
1478
+ }
1479
+ }
1480
+
1481
+ export {
1482
+ deriveTelemetryCommandTaxonomy,
1483
+ deriveTelemetryCommandResolution,
1484
+ flushTelemetryQueueNow,
1485
+ startTelemetryCommand,
1486
+ finishTelemetryCommand,
1487
+ emitTelemetryErrorEvent
1488
+ };
1489
+ //# sourceMappingURL=chunk-IOR7LGF4.js.map
1490
+
1491
+ //# debugId=705a511a-3aa8-5101-b1fa-07ed6544814a