@unbrained/pm-cli 2026.7.18 → 2026.7.19

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 (497) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +17 -0
  3. package/dist/cli/commands/claim.js +6 -4
  4. package/dist/cli/commands/claim.js.map +1 -1
  5. package/dist/cli/commands/comments.js +5 -2
  6. package/dist/cli/commands/comments.js.map +1 -1
  7. package/dist/cli/commands/context.d.ts +10 -1
  8. package/dist/cli/commands/context.js +44 -6
  9. package/dist/cli/commands/context.js.map +1 -1
  10. package/dist/cli/commands/create.js +15 -4
  11. package/dist/cli/commands/create.js.map +1 -1
  12. package/dist/cli/commands/next.js +13 -3
  13. package/dist/cli/commands/next.js.map +1 -1
  14. package/dist/cli/commands/update.js +14 -3
  15. package/dist/cli/commands/update.js.map +1 -1
  16. package/dist/cli/error-guidance.js +23 -4
  17. package/dist/cli/error-guidance.js.map +1 -1
  18. package/dist/cli/extension-command-help.d.ts +11 -0
  19. package/dist/cli/extension-command-help.js +62 -2
  20. package/dist/cli/extension-command-help.js.map +1 -1
  21. package/dist/cli/main.d.ts +1 -0
  22. package/dist/cli/main.js +16 -11
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli-bundle/bundle-manifest.json +326 -350
  25. package/dist/cli-bundle/chunks/{append-5YF3TO7I.js → append-MBXHNWSX.js} +5 -5
  26. package/dist/cli-bundle/chunks/append-XUYF7NON.js +11 -0
  27. package/dist/cli-bundle/chunks/{chunk-BIRYX32V.js → chunk-2UCG5H6B.js} +3 -3
  28. package/dist/cli-bundle/chunks/{chunk-VE6ZSTQW.js → chunk-2XPDCXK5.js} +4 -4
  29. package/dist/cli-bundle/chunks/{chunk-I3INI567.js → chunk-3EZZTFL2.js} +909 -124
  30. package/dist/cli-bundle/chunks/chunk-3EZZTFL2.js.map +7 -0
  31. package/dist/cli-bundle/chunks/{chunk-GLZKZON6.js → chunk-3HSRP6T2.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-XWBD6DSR.js → chunk-3KPNOZOH.js} +23 -23
  33. package/dist/cli-bundle/chunks/{chunk-MR4SHYR4.js → chunk-3QNUDDY2.js} +104 -23
  34. package/dist/cli-bundle/chunks/chunk-3QNUDDY2.js.map +7 -0
  35. package/dist/cli-bundle/chunks/{chunk-SIPOACV5.js → chunk-46Z6FAVP.js} +888 -124
  36. package/dist/cli-bundle/chunks/chunk-46Z6FAVP.js.map +1 -0
  37. package/dist/cli-bundle/chunks/{chunk-HO4DLBNK.js → chunk-4M6RZJXF.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-RXPQ5Q23.js → chunk-4PSJVGRE.js} +11 -11
  39. package/dist/cli-bundle/chunks/{chunk-ADXDCAKP.js → chunk-5S6IZXK7.js} +146 -32
  40. package/dist/cli-bundle/chunks/{chunk-IL5SPRMH.js.map → chunk-5S6IZXK7.js.map} +7 -1
  41. package/dist/cli-bundle/chunks/chunk-66SRNEBK.js +143 -0
  42. package/dist/cli-bundle/chunks/chunk-66SRNEBK.js.map +7 -0
  43. package/dist/cli-bundle/chunks/{chunk-YFE7JHX3.js → chunk-6BNV3G6C.js} +2 -2
  44. package/dist/cli-bundle/chunks/{chunk-43UMFKCK.js → chunk-6V4T4RD3.js} +23 -23
  45. package/dist/cli-bundle/chunks/chunk-77XFQRTD.js +140 -0
  46. package/dist/cli-bundle/chunks/chunk-77XFQRTD.js.map +1 -0
  47. package/dist/cli-bundle/chunks/{chunk-EHJFUOXL.js → chunk-7B7IHMLH.js} +3 -3
  48. package/dist/cli-bundle/chunks/{chunk-I7DIDUSP.js → chunk-7CHWLT2J.js} +2 -2
  49. package/dist/cli-bundle/chunks/{chunk-L6FVNR7X.js → chunk-A3GAQLBH.js} +5 -5
  50. package/dist/cli-bundle/chunks/{chunk-B57RJHBZ.js → chunk-A4FVWFZY.js} +4 -4
  51. package/dist/cli-bundle/chunks/{chunk-D52ZN3BF.js → chunk-A5EQPNV7.js} +2 -2
  52. package/dist/cli-bundle/chunks/{chunk-TZAE66GQ.js → chunk-AGEBQRBG.js} +15 -15
  53. package/dist/cli-bundle/chunks/{chunk-WU3KAN6A.js → chunk-AQUNTB7G.js} +3 -3
  54. package/dist/cli-bundle/chunks/{chunk-OGVTB5VO.js → chunk-AR24KW26.js} +237 -36
  55. package/dist/cli-bundle/chunks/chunk-AR24KW26.js.map +7 -0
  56. package/dist/cli-bundle/chunks/{chunk-XWYQ2LT4.js → chunk-BBGR4FKQ.js} +4 -4
  57. package/dist/cli-bundle/chunks/{chunk-HTXXXF45.js → chunk-BDC4TW4B.js} +98 -24
  58. package/dist/cli-bundle/chunks/chunk-BDC4TW4B.js.map +1 -0
  59. package/dist/cli-bundle/chunks/{chunk-2FUOXSRN.js → chunk-BFJP4VYC.js} +4 -4
  60. package/dist/cli-bundle/chunks/{chunk-633PKXLT.js → chunk-BZKE2O5V.js} +3 -3
  61. package/dist/cli-bundle/chunks/{chunk-XPUTSGJU.js → chunk-CZA2DXCV.js} +230 -36
  62. package/dist/cli-bundle/chunks/chunk-CZA2DXCV.js.map +1 -0
  63. package/dist/cli-bundle/chunks/{chunk-KX62NMZC.js → chunk-D35WYXWC.js} +626 -5
  64. package/dist/cli-bundle/chunks/chunk-D35WYXWC.js.map +1 -0
  65. package/dist/cli-bundle/chunks/chunk-DOASIOQR.js +289 -0
  66. package/dist/cli-bundle/chunks/chunk-DOASIOQR.js.map +7 -0
  67. package/dist/cli-bundle/chunks/{chunk-L337QKWJ.js → chunk-DUDLSQFG.js} +5 -5
  68. package/dist/cli-bundle/chunks/{chunk-BVLOMU6O.js → chunk-E7KBMWEF.js} +2 -2
  69. package/dist/cli-bundle/chunks/{chunk-3QDR6ZLU.js → chunk-EAV3P54W.js} +9 -9
  70. package/dist/cli-bundle/chunks/{chunk-3QDR6ZLU.js.map → chunk-EAV3P54W.js.map} +2 -2
  71. package/dist/cli-bundle/chunks/{chunk-WQXRZMFN.js → chunk-EEECAV5M.js} +2 -2
  72. package/dist/cli-bundle/chunks/{chunk-35FHWD4C.js → chunk-EI3UIMZM.js} +4 -4
  73. package/dist/cli-bundle/chunks/{chunk-RGMWJLXF.js → chunk-EVAN5VJA.js} +8 -5
  74. package/dist/cli-bundle/chunks/{chunk-RGMWJLXF.js.map → chunk-EVAN5VJA.js.map} +2 -2
  75. package/dist/cli-bundle/chunks/{chunk-PT7MCCGD.js → chunk-FIUTBFC6.js} +2 -2
  76. package/dist/cli-bundle/chunks/{chunk-7H5NNCJ5.js → chunk-FQF6VVPH.js} +4 -4
  77. package/dist/cli-bundle/chunks/{chunk-6DYOZS6C.js → chunk-FQO5THHM.js} +2 -2
  78. package/dist/cli-bundle/chunks/{chunk-5HGZKQUL.js → chunk-FQODDTE7.js} +4 -4
  79. package/dist/cli-bundle/chunks/{chunk-67RO3H4N.js → chunk-G33XIMRT.js} +6 -6
  80. package/dist/cli-bundle/chunks/{chunk-D53RTYVI.js → chunk-GFZB5CLP.js} +20 -10
  81. package/dist/cli-bundle/chunks/chunk-GFZB5CLP.js.map +7 -0
  82. package/dist/cli-bundle/chunks/{chunk-QWBKN3QC.js → chunk-GKCEEXMA.js} +8 -8
  83. package/dist/cli-bundle/chunks/{chunk-DG2EQRIH.js → chunk-GRDK25BN.js} +7 -7
  84. package/dist/cli-bundle/chunks/{chunk-FXFCFL73.js → chunk-H3YKUVDR.js} +5 -5
  85. package/dist/cli-bundle/chunks/{chunk-IL5SPRMH.js → chunk-IEMXESIS.js} +123 -16
  86. package/dist/cli-bundle/chunks/chunk-IEMXESIS.js.map +1 -0
  87. package/dist/cli-bundle/chunks/{chunk-ARGDWQ4J.js → chunk-IGBBTPM5.js} +2 -2
  88. package/dist/cli-bundle/chunks/{chunk-QPGQNLPI.js → chunk-IR3GOO6E.js} +3842 -4109
  89. package/dist/cli-bundle/chunks/chunk-IR3GOO6E.js.map +1 -0
  90. package/dist/cli-bundle/chunks/{chunk-FY4RLHSC.js → chunk-IRJ6F23W.js} +2 -2
  91. package/dist/cli-bundle/chunks/{chunk-66MKH7SZ.js → chunk-IXG5CMBR.js} +4 -4
  92. package/dist/cli-bundle/chunks/{chunk-F3VC3GOV.js → chunk-JBW2S2C6.js} +2090 -253
  93. package/dist/cli-bundle/chunks/chunk-JBW2S2C6.js.map +7 -0
  94. package/dist/cli-bundle/chunks/{chunk-7UCY6DR5.js → chunk-JPWUZOMR.js} +2 -2
  95. package/dist/cli-bundle/chunks/{chunk-FVNWHUME.js → chunk-K2L6FZBX.js} +8 -8
  96. package/dist/cli-bundle/chunks/chunk-KGPLSHJD.js +286 -0
  97. package/dist/cli-bundle/chunks/chunk-KGPLSHJD.js.map +1 -0
  98. package/dist/cli-bundle/chunks/{chunk-YQEZWI3R.js → chunk-KZ5AC6B5.js} +5 -3
  99. package/dist/cli-bundle/chunks/chunk-KZ5AC6B5.js.map +7 -0
  100. package/dist/cli-bundle/chunks/{chunk-X2MGQMZO.js → chunk-LT5UWU7H.js} +2 -2
  101. package/dist/cli-bundle/chunks/{chunk-KH6QAHME.js → chunk-M4B4RK4J.js} +3 -3
  102. package/dist/cli-bundle/chunks/{chunk-QRZNCRNA.js → chunk-MI3346YW.js} +377 -240
  103. package/dist/cli-bundle/chunks/chunk-MI3346YW.js.map +1 -0
  104. package/dist/cli-bundle/chunks/{chunk-2XOSFSTH.js → chunk-MQOSMBWV.js} +5 -5
  105. package/dist/cli-bundle/chunks/{chunk-YIIIAKCE.js → chunk-MRXAHR4B.js} +28 -22
  106. package/dist/cli-bundle/chunks/chunk-MRXAHR4B.js.map +1 -0
  107. package/dist/cli-bundle/chunks/{chunk-7R6UIHYY.js → chunk-N2TEEOXJ.js} +5 -5
  108. package/dist/cli-bundle/chunks/{chunk-NTRQLE2R.js → chunk-N7FCFJ76.js} +2 -2
  109. package/dist/cli-bundle/chunks/{chunk-37DRDP2B.js → chunk-NPEYH6CE.js} +5 -5
  110. package/dist/cli-bundle/chunks/{chunk-GKPCTQYG.js → chunk-NTS2RKHN.js} +3942 -4216
  111. package/dist/cli-bundle/chunks/chunk-NTS2RKHN.js.map +7 -0
  112. package/dist/cli-bundle/chunks/{chunk-6VHUGVNP.js → chunk-ODEIDKGW.js} +2062 -246
  113. package/dist/cli-bundle/chunks/chunk-ODEIDKGW.js.map +1 -0
  114. package/dist/cli-bundle/chunks/{chunk-2CXL335K.js → chunk-OK7VSX3N.js} +3 -3
  115. package/dist/cli-bundle/chunks/{chunk-NNANAWFH.js → chunk-OKPZDH43.js} +3 -3
  116. package/dist/cli-bundle/chunks/{chunk-G6MYGULG.js → chunk-OKWJUL6F.js} +6 -6
  117. package/dist/cli-bundle/chunks/{chunk-HPAYDSR2.js → chunk-P24ZU5QV.js} +27 -21
  118. package/dist/cli-bundle/chunks/chunk-P24ZU5QV.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-TGBTLGPX.js → chunk-Q4PSG2GV.js} +13 -4
  120. package/dist/cli-bundle/chunks/{chunk-TGBTLGPX.js.map → chunk-Q4PSG2GV.js.map} +1 -1
  121. package/dist/cli-bundle/chunks/{chunk-5UKQLQM2.js → chunk-Q5NHJ6RO.js} +6 -4
  122. package/dist/cli-bundle/chunks/chunk-Q5NHJ6RO.js.map +1 -0
  123. package/dist/cli-bundle/chunks/{chunk-D5XHO4Q7.js → chunk-Q6JPYR7I.js} +2 -2
  124. package/dist/cli-bundle/chunks/{chunk-P22HGFFI.js → chunk-QFG4MB7P.js} +5 -5
  125. package/dist/cli-bundle/chunks/{chunk-P22HGFFI.js.map → chunk-QFG4MB7P.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/{chunk-IE5KRAKN.js → chunk-QQ77W23U.js} +4 -4
  127. package/dist/cli-bundle/chunks/{chunk-M7MVOKVV.js → chunk-QYGK2XQ3.js} +3 -3
  128. package/dist/cli-bundle/chunks/{chunk-646MQXFW.js → chunk-RLLOZAM2.js} +4 -4
  129. package/dist/cli-bundle/chunks/{chunk-646MQXFW.js.map → chunk-RLLOZAM2.js.map} +2 -2
  130. package/dist/cli-bundle/chunks/{chunk-X5YCTFKT.js → chunk-RWAIRGBC.js} +3 -3
  131. package/dist/cli-bundle/chunks/{chunk-W5E2UUSH.js → chunk-RX53WHFI.js} +3 -3
  132. package/dist/cli-bundle/chunks/{chunk-R5XTTZSJ.js → chunk-SBW7EQC4.js} +5 -5
  133. package/dist/cli-bundle/chunks/{chunk-TM5CIO3F.js → chunk-SGJB6PXA.js} +3 -3
  134. package/dist/cli-bundle/chunks/{chunk-DDFGYUCQ.js → chunk-STBCBDKF.js} +7 -7
  135. package/dist/cli-bundle/chunks/{chunk-EX7OQT3Y.js → chunk-SUNZKVAH.js} +10 -10
  136. package/dist/cli-bundle/chunks/{chunk-EX7OQT3Y.js.map → chunk-SUNZKVAH.js.map} +1 -1
  137. package/dist/cli-bundle/chunks/{chunk-FHOBCGQO.js → chunk-SVAWG7EE.js} +2 -2
  138. package/dist/cli-bundle/chunks/{chunk-6O44IN44.js → chunk-T6MOTLOJ.js} +2 -2
  139. package/dist/cli-bundle/chunks/{chunk-HSYV4ZYT.js → chunk-TELI67UP.js} +9 -6
  140. package/dist/cli-bundle/chunks/{chunk-HSYV4ZYT.js.map → chunk-TELI67UP.js.map} +1 -1
  141. package/dist/cli-bundle/chunks/{chunk-EWIT5WIC.js → chunk-U6RYD446.js} +11 -11
  142. package/dist/cli-bundle/chunks/{chunk-E4FXM2XB.js → chunk-UE7LK3RE.js} +5 -5
  143. package/dist/cli-bundle/chunks/{chunk-N33FD2UI.js → chunk-UNNCT5QY.js} +3 -3
  144. package/dist/cli-bundle/chunks/{chunk-2IPNL3DR.js → chunk-UOIFZ66L.js} +3 -3
  145. package/dist/cli-bundle/chunks/{chunk-LSOWTLEM.js → chunk-UU6EP25G.js} +2 -2
  146. package/dist/cli-bundle/chunks/{chunk-HYTOJW2Q.js → chunk-UW6HCMP2.js} +15 -15
  147. package/dist/cli-bundle/chunks/{chunk-47HXN6RX.js → chunk-UWAQI3B7.js} +3 -3
  148. package/dist/cli-bundle/chunks/{chunk-YKFHF37B.js → chunk-V4QHAMI5.js} +3 -3
  149. package/dist/cli-bundle/chunks/{chunk-VAHZIPWS.js → chunk-VA3H7VVC.js} +4 -4
  150. package/dist/cli-bundle/chunks/{chunk-XC2HEEOV.js → chunk-VFA5EIEN.js} +21 -11
  151. package/dist/cli-bundle/chunks/chunk-VFA5EIEN.js.map +1 -0
  152. package/dist/cli-bundle/chunks/{chunk-TLWJP5BF.js → chunk-VQOG2ETB.js} +4 -4
  153. package/dist/cli-bundle/chunks/{chunk-H5IOT54C.js → chunk-VSQE43NO.js} +8 -8
  154. package/dist/cli-bundle/chunks/{chunk-BDA35QG5.js → chunk-W6IEJXNC.js} +2 -2
  155. package/dist/cli-bundle/chunks/{chunk-WACRQ26A.js → chunk-WCBB6VI3.js} +637 -9
  156. package/dist/cli-bundle/chunks/chunk-WCBB6VI3.js.map +7 -0
  157. package/dist/cli-bundle/chunks/{chunk-OWP6QFBV.js → chunk-XDWXPG2E.js} +4 -4
  158. package/dist/cli-bundle/chunks/{chunk-CKX4WOPC.js → chunk-XKVHL3MB.js} +2 -2
  159. package/dist/cli-bundle/chunks/{chunk-WL3SS45P.js → chunk-XVB6BATY.js} +3 -3
  160. package/dist/cli-bundle/chunks/{chunk-NVZ6NVHJ.js → chunk-XXWDEQ6O.js} +4 -4
  161. package/dist/cli-bundle/chunks/{chunk-ILVOOAT4.js → chunk-Y2VSGFT4.js} +8 -8
  162. package/dist/cli-bundle/chunks/{chunk-NCVT6XEL.js → chunk-YG56M3NE.js} +11 -11
  163. package/dist/cli-bundle/chunks/{chunk-AFGKSHAM.js → chunk-YGEA4CLH.js} +4 -4
  164. package/dist/cli-bundle/chunks/{chunk-AXRT7K5V.js → chunk-YIC5NGXF.js} +11 -11
  165. package/dist/cli-bundle/chunks/{chunk-DHNG452T.js → chunk-ZF52NVRT.js} +396 -245
  166. package/dist/cli-bundle/chunks/chunk-ZF52NVRT.js.map +7 -0
  167. package/dist/cli-bundle/chunks/{chunk-XXLXJL7V.js → chunk-ZUCBPXNA.js} +4 -4
  168. package/dist/cli-bundle/chunks/{close-X3CF6FQP.js → close-7NWA3GLA.js} +5 -5
  169. package/dist/cli-bundle/chunks/close-ZZCDDWJT.js +12 -0
  170. package/dist/cli-bundle/chunks/close-many-QCZHFCON.js +23 -0
  171. package/dist/cli-bundle/chunks/{close-many-J7A5EHOQ.js → close-many-YALQ7AXS.js} +14 -14
  172. package/dist/cli-bundle/chunks/comments-FMQNYPSZ.js +13 -0
  173. package/dist/cli-bundle/chunks/{comments-TMHMALA5.js → comments-SQIQ5WYR.js} +7 -7
  174. package/dist/cli-bundle/chunks/copy-GI3RCVZP.js +9 -0
  175. package/dist/cli-bundle/chunks/{copy-FWQA5OU4.js → copy-YDAMENCP.js} +4 -4
  176. package/dist/cli-bundle/chunks/{create-AQ5SIGZC.js → create-JSL6CXU3.js} +11 -9
  177. package/dist/cli-bundle/chunks/create-LXMLYJNM.js +29 -0
  178. package/dist/cli-bundle/chunks/delete-5DFAXJNI.js +10 -0
  179. package/dist/cli-bundle/chunks/{delete-YYYFOSEA.js → delete-IGVOZEU2.js} +4 -4
  180. package/dist/cli-bundle/chunks/{deps-NIIKXLPB.js → deps-BQAXUQAK.js} +6 -6
  181. package/dist/cli-bundle/chunks/{deps-MQ4ZIGZB.js → deps-CBPPSS6J.js} +6 -6
  182. package/dist/cli-bundle/chunks/docs-KCWPLQOV.js +14 -0
  183. package/dist/cli-bundle/chunks/{docs-53NUGMIQ.js → docs-NS2AZWCN.js} +7 -7
  184. package/dist/cli-bundle/chunks/{files-3PXGXYDB.js → files-PVWEPT5J.js} +7 -7
  185. package/dist/cli-bundle/chunks/{files-EGLKHD7O.js → files-XUUBQ76I.js} +7 -7
  186. package/dist/cli-bundle/chunks/focus-3EJVFI3D.js +10 -0
  187. package/dist/cli-bundle/chunks/{focus-SRPASFTN.js → focus-DHBHKK3E.js} +5 -5
  188. package/dist/cli-bundle/chunks/{history-compact-G4DULDCX.js → history-compact-3TNPYVFG.js} +6 -6
  189. package/dist/cli-bundle/chunks/history-compact-JHYVDYLW.js +16 -0
  190. package/dist/cli-bundle/chunks/{history-redact-IUSJ6X3E.js → history-redact-ELRL73XN.js} +4 -4
  191. package/dist/cli-bundle/chunks/{history-redact-THHGRQXV.js → history-redact-KKFDICCF.js} +4 -4
  192. package/dist/cli-bundle/chunks/{history-repair-LUQWRS7X.js → history-repair-J7WKZFAG.js} +6 -6
  193. package/dist/cli-bundle/chunks/history-repair-REMI7DDI.js +16 -0
  194. package/dist/cli-bundle/chunks/learnings-O6V5WDCV.js +13 -0
  195. package/dist/cli-bundle/chunks/{learnings-2MRNBFJF.js → learnings-X4D6JCCG.js} +7 -7
  196. package/dist/cli-bundle/chunks/{notes-73JWKWUD.js → notes-UQC6VS6N.js} +7 -7
  197. package/dist/cli-bundle/chunks/notes-ZSZREWZA.js +13 -0
  198. package/dist/cli-bundle/chunks/{plan-AZPMCG37.js → plan-5GKRBJJO.js} +12 -10
  199. package/dist/cli-bundle/chunks/plan-EZW2YDDY.js +26 -0
  200. package/dist/cli-bundle/chunks/{profile-AVCIIZID.js → profile-5PQAPCLF.js} +10 -10
  201. package/dist/cli-bundle/chunks/{profile-LFYO3HHX.js → profile-CW4BD3FO.js} +10 -10
  202. package/dist/cli-bundle/chunks/{register-list-query-UKMF55FT.js → register-list-query-HTDQE6VI.js} +24 -24
  203. package/dist/cli-bundle/chunks/{register-list-query-MZUF2EEC.js → register-list-query-PHIPDFP2.js} +24 -24
  204. package/dist/cli-bundle/chunks/{register-mutation-T6RVNJC4.js → register-mutation-BLEWM5I6.js} +32 -32
  205. package/dist/cli-bundle/chunks/{register-mutation-2PBW2GEX.js → register-mutation-OTYHR7J6.js} +32 -32
  206. package/dist/cli-bundle/chunks/{register-operations-KHZYR6MG.js → register-operations-AMCUFYEW.js} +38 -40
  207. package/dist/cli-bundle/chunks/{register-operations-KHZYR6MG.js.map → register-operations-AMCUFYEW.js.map} +1 -1
  208. package/dist/cli-bundle/chunks/{register-operations-WPQ2LWZJ.js → register-operations-MRLHOZYR.js} +36 -38
  209. package/dist/cli-bundle/chunks/{register-operations-WPQ2LWZJ.js.map → register-operations-MRLHOZYR.js.map} +1 -1
  210. package/dist/cli-bundle/chunks/{register-setup-PGDNOXDQ.js → register-setup-N2FOSWAG.js} +15 -17
  211. package/dist/cli-bundle/chunks/{register-setup-PGDNOXDQ.js.map → register-setup-N2FOSWAG.js.map} +1 -1
  212. package/dist/cli-bundle/chunks/{register-setup-TDN7WAO6.js → register-setup-ZVKTDL4G.js} +17 -19
  213. package/dist/cli-bundle/chunks/{register-setup-TDN7WAO6.js.map → register-setup-ZVKTDL4G.js.map} +1 -1
  214. package/dist/cli-bundle/chunks/restore-A55MLFAI.js +14 -0
  215. package/dist/cli-bundle/chunks/{restore-E3PRGDN3.js → restore-HEQAG6EK.js} +6 -6
  216. package/dist/cli-bundle/chunks/{schema-5JNFQFUW.js → schema-MAXAIHEC.js} +6 -6
  217. package/dist/cli-bundle/chunks/{schema-TMIW4XZC.js → schema-Q5DAWJ2S.js} +6 -6
  218. package/dist/cli-bundle/chunks/update-5DTSCWVF.js +23 -0
  219. package/dist/cli-bundle/chunks/{update-SQYZA3ZW.js → update-DWFXXJKP.js} +15 -13
  220. package/dist/cli-bundle/chunks/update-many-6T4ZLZS7.js +34 -0
  221. package/dist/cli-bundle/chunks/update-many-MYRK6VBJ.js +38 -0
  222. package/dist/cli-bundle/main.js +152 -29
  223. package/dist/cli-bundle/main.js.map +3 -3
  224. package/dist/cli-bundle/sdk-runtime.js +72 -75
  225. package/dist/cli-bundle/sdk-testing.js +8 -8
  226. package/dist/cli-bundle/sdk.js +288 -642
  227. package/dist/cli-bundle/sdk.js.map +4 -4
  228. package/dist/core/extensions/activation-summary.d.ts +2 -0
  229. package/dist/core/extensions/activation-summary.js +7 -2
  230. package/dist/core/extensions/activation-summary.js.map +1 -1
  231. package/dist/core/extensions/capability-usage.d.ts +1 -1
  232. package/dist/core/extensions/capability-usage.js +5 -2
  233. package/dist/core/extensions/capability-usage.js.map +1 -1
  234. package/dist/core/extensions/extension-hook-runtime.js +3 -2
  235. package/dist/core/extensions/extension-hook-runtime.js.map +1 -1
  236. package/dist/core/extensions/extension-registries.js +3 -2
  237. package/dist/core/extensions/extension-registries.js.map +1 -1
  238. package/dist/core/extensions/extension-types.d.ts +38 -1
  239. package/dist/core/extensions/extension-types.js +3 -2
  240. package/dist/core/extensions/extension-types.js.map +1 -1
  241. package/dist/core/extensions/loader.js +36 -2
  242. package/dist/core/extensions/loader.js.map +1 -1
  243. package/dist/core/store/item-store.d.ts +4 -1
  244. package/dist/core/store/item-store.js +3 -3
  245. package/dist/core/store/item-store.js.map +1 -1
  246. package/dist/core/store/paths.d.ts +2 -0
  247. package/dist/core/store/paths.js +26 -3
  248. package/dist/core/store/paths.js.map +1 -1
  249. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  250. package/dist/sdk/compose.d.ts +3 -0
  251. package/dist/sdk/compose.js +14 -2
  252. package/dist/sdk/compose.js.map +1 -1
  253. package/dist/sdk/dependencies.js +3 -3
  254. package/dist/sdk/dependencies.js.map +1 -1
  255. package/dist/sdk/extension-command-context.d.ts +10 -0
  256. package/dist/sdk/extension-command-context.js +30 -0
  257. package/dist/sdk/extension-command-context.js.map +1 -0
  258. package/dist/sdk/graph/assembly.js +14 -4
  259. package/dist/sdk/graph/assembly.js.map +1 -1
  260. package/dist/sdk/graph/index.d.ts +1 -0
  261. package/dist/sdk/graph/index.js +3 -2
  262. package/dist/sdk/graph/index.js.map +1 -1
  263. package/dist/sdk/graph/mutation-advisory.d.ts +20 -0
  264. package/dist/sdk/graph/mutation-advisory.js +80 -0
  265. package/dist/sdk/graph/mutation-advisory.js.map +1 -0
  266. package/dist/sdk/graph/run.d.ts +5 -1
  267. package/dist/sdk/graph/run.js +11 -3
  268. package/dist/sdk/graph/run.js.map +1 -1
  269. package/dist/sdk/index.d.ts +4 -1
  270. package/dist/sdk/index.js +5 -2
  271. package/dist/sdk/index.js.map +1 -1
  272. package/dist/sdk/ownership-source.d.ts +2 -0
  273. package/dist/sdk/ownership-source.js +22 -0
  274. package/dist/sdk/ownership-source.js.map +1 -0
  275. package/dist/sdk/relationship-history.d.ts +38 -0
  276. package/dist/sdk/relationship-history.js +60 -2
  277. package/dist/sdk/relationship-history.js.map +1 -1
  278. package/dist/sdk/relationships.js +49 -8
  279. package/dist/sdk/relationships.js.map +1 -1
  280. package/dist/sdk/runtime-input.js +3 -2
  281. package/dist/sdk/runtime-input.js.map +1 -1
  282. package/dist/sdk/runtime.d.ts +2 -0
  283. package/dist/sdk/runtime.js +19 -2
  284. package/dist/sdk/runtime.js.map +1 -1
  285. package/dist/sdk/tracker-root-discovery.d.ts +6 -0
  286. package/dist/sdk/tracker-root-discovery.js +10 -0
  287. package/dist/sdk/tracker-root-discovery.js.map +1 -0
  288. package/dist/sdk/workspace-transaction.d.ts +83 -0
  289. package/dist/sdk/workspace-transaction.js +364 -0
  290. package/dist/sdk/workspace-transaction.js.map +1 -0
  291. package/docs/AGENT_UX_CONTRACTS.md +41 -0
  292. package/docs/EXTENSIONS.md +4 -4
  293. package/docs/README.md +1 -0
  294. package/docs/SDK.md +102 -1
  295. package/marketplace.json +2 -2
  296. package/package.json +1 -1
  297. package/packages/pm-beads/package.json +1 -1
  298. package/packages/pm-calendar/package.json +1 -1
  299. package/packages/pm-command-kit/package.json +1 -1
  300. package/packages/pm-governance-audit/package.json +1 -1
  301. package/packages/pm-guide-shell/package.json +1 -1
  302. package/packages/pm-kanban/package.json +1 -1
  303. package/packages/pm-lifecycle-hooks/package.json +1 -1
  304. package/packages/pm-linked-test-adapters/package.json +1 -1
  305. package/packages/pm-search-advanced/package.json +1 -1
  306. package/packages/pm-templates/package.json +1 -1
  307. package/packages/pm-todos/package.json +1 -1
  308. package/packages/pm-vcs/GAP_REPORT.md +31 -0
  309. package/packages/pm-vcs/README.md +62 -0
  310. package/packages/pm-vcs/extensions/vcs/index.ts +745 -0
  311. package/packages/pm-vcs/extensions/vcs/manifest.json +19 -0
  312. package/packages/pm-vcs/extensions/vcs/package.json +3 -0
  313. package/packages/pm-vcs/package.json +55 -0
  314. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  315. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  316. package/dist/cli-bundle/chunks/append-JHO5K6RP.js +0 -11
  317. package/dist/cli-bundle/chunks/chunk-2BX74BAS.js +0 -125
  318. package/dist/cli-bundle/chunks/chunk-2BX74BAS.js.map +0 -7
  319. package/dist/cli-bundle/chunks/chunk-3CUQZNQ6.js +0 -672
  320. package/dist/cli-bundle/chunks/chunk-3CUQZNQ6.js.map +0 -7
  321. package/dist/cli-bundle/chunks/chunk-5UKQLQM2.js.map +0 -1
  322. package/dist/cli-bundle/chunks/chunk-6VHUGVNP.js.map +0 -1
  323. package/dist/cli-bundle/chunks/chunk-74FKFFXO.js +0 -172
  324. package/dist/cli-bundle/chunks/chunk-74FKFFXO.js.map +0 -7
  325. package/dist/cli-bundle/chunks/chunk-ADXDCAKP.js.map +0 -7
  326. package/dist/cli-bundle/chunks/chunk-BAP7G3N2.js +0 -178
  327. package/dist/cli-bundle/chunks/chunk-BAP7G3N2.js.map +0 -7
  328. package/dist/cli-bundle/chunks/chunk-D53RTYVI.js.map +0 -7
  329. package/dist/cli-bundle/chunks/chunk-DHNG452T.js.map +0 -7
  330. package/dist/cli-bundle/chunks/chunk-EY7ZE3TG.js +0 -1831
  331. package/dist/cli-bundle/chunks/chunk-EY7ZE3TG.js.map +0 -1
  332. package/dist/cli-bundle/chunks/chunk-F3VC3GOV.js.map +0 -7
  333. package/dist/cli-bundle/chunks/chunk-FL4D53ND.js +0 -162
  334. package/dist/cli-bundle/chunks/chunk-FL4D53ND.js.map +0 -1
  335. package/dist/cli-bundle/chunks/chunk-GKPCTQYG.js.map +0 -7
  336. package/dist/cli-bundle/chunks/chunk-HPAYDSR2.js.map +0 -7
  337. package/dist/cli-bundle/chunks/chunk-HTXXXF45.js.map +0 -1
  338. package/dist/cli-bundle/chunks/chunk-I3INI567.js.map +0 -7
  339. package/dist/cli-bundle/chunks/chunk-KX62NMZC.js.map +0 -1
  340. package/dist/cli-bundle/chunks/chunk-L5BTTDU5.js +0 -662
  341. package/dist/cli-bundle/chunks/chunk-L5BTTDU5.js.map +0 -1
  342. package/dist/cli-bundle/chunks/chunk-MR4SHYR4.js.map +0 -7
  343. package/dist/cli-bundle/chunks/chunk-OGVTB5VO.js.map +0 -7
  344. package/dist/cli-bundle/chunks/chunk-QPGQNLPI.js.map +0 -1
  345. package/dist/cli-bundle/chunks/chunk-QRZNCRNA.js.map +0 -1
  346. package/dist/cli-bundle/chunks/chunk-RC4UOUXA.js +0 -122
  347. package/dist/cli-bundle/chunks/chunk-RC4UOUXA.js.map +0 -1
  348. package/dist/cli-bundle/chunks/chunk-RTBX3C4C.js +0 -1841
  349. package/dist/cli-bundle/chunks/chunk-RTBX3C4C.js.map +0 -7
  350. package/dist/cli-bundle/chunks/chunk-SIPOACV5.js.map +0 -1
  351. package/dist/cli-bundle/chunks/chunk-WACRQ26A.js.map +0 -7
  352. package/dist/cli-bundle/chunks/chunk-XC2HEEOV.js.map +0 -1
  353. package/dist/cli-bundle/chunks/chunk-XPUTSGJU.js.map +0 -1
  354. package/dist/cli-bundle/chunks/chunk-YIIIAKCE.js.map +0 -1
  355. package/dist/cli-bundle/chunks/chunk-YJSURTBB.js +0 -175
  356. package/dist/cli-bundle/chunks/chunk-YJSURTBB.js.map +0 -1
  357. package/dist/cli-bundle/chunks/chunk-YQEZWI3R.js.map +0 -7
  358. package/dist/cli-bundle/chunks/close-GPD7DTJV.js +0 -12
  359. package/dist/cli-bundle/chunks/close-many-NQLYGPYW.js +0 -23
  360. package/dist/cli-bundle/chunks/comments-2AOZQ5D2.js +0 -13
  361. package/dist/cli-bundle/chunks/copy-N3LCQBMC.js +0 -9
  362. package/dist/cli-bundle/chunks/create-KOGQ3JKD.js +0 -27
  363. package/dist/cli-bundle/chunks/delete-6G3MBZ6S.js +0 -10
  364. package/dist/cli-bundle/chunks/docs-OWRGDMNY.js +0 -14
  365. package/dist/cli-bundle/chunks/focus-KZLIA6WS.js +0 -10
  366. package/dist/cli-bundle/chunks/history-compact-HHIUOMZ7.js +0 -16
  367. package/dist/cli-bundle/chunks/history-repair-KG7SWXI6.js +0 -16
  368. package/dist/cli-bundle/chunks/learnings-ZVHSALJY.js +0 -13
  369. package/dist/cli-bundle/chunks/notes-BAKUL5DJ.js +0 -13
  370. package/dist/cli-bundle/chunks/plan-LEAGLPGP.js +0 -24
  371. package/dist/cli-bundle/chunks/restore-KIUYTAEJ.js +0 -14
  372. package/dist/cli-bundle/chunks/update-XZJYS5X7.js +0 -21
  373. package/dist/cli-bundle/chunks/update-many-R24B3GBK.js +0 -36
  374. package/dist/cli-bundle/chunks/update-many-WQ3R3J6N.js +0 -32
  375. /package/dist/cli-bundle/chunks/{append-5YF3TO7I.js.map → append-MBXHNWSX.js.map} +0 -0
  376. /package/dist/cli-bundle/chunks/{append-JHO5K6RP.js.map → append-XUYF7NON.js.map} +0 -0
  377. /package/dist/cli-bundle/chunks/{chunk-BIRYX32V.js.map → chunk-2UCG5H6B.js.map} +0 -0
  378. /package/dist/cli-bundle/chunks/{chunk-VE6ZSTQW.js.map → chunk-2XPDCXK5.js.map} +0 -0
  379. /package/dist/cli-bundle/chunks/{chunk-GLZKZON6.js.map → chunk-3HSRP6T2.js.map} +0 -0
  380. /package/dist/cli-bundle/chunks/{chunk-XWBD6DSR.js.map → chunk-3KPNOZOH.js.map} +0 -0
  381. /package/dist/cli-bundle/chunks/{chunk-HO4DLBNK.js.map → chunk-4M6RZJXF.js.map} +0 -0
  382. /package/dist/cli-bundle/chunks/{chunk-RXPQ5Q23.js.map → chunk-4PSJVGRE.js.map} +0 -0
  383. /package/dist/cli-bundle/chunks/{chunk-YFE7JHX3.js.map → chunk-6BNV3G6C.js.map} +0 -0
  384. /package/dist/cli-bundle/chunks/{chunk-43UMFKCK.js.map → chunk-6V4T4RD3.js.map} +0 -0
  385. /package/dist/cli-bundle/chunks/{chunk-EHJFUOXL.js.map → chunk-7B7IHMLH.js.map} +0 -0
  386. /package/dist/cli-bundle/chunks/{chunk-I7DIDUSP.js.map → chunk-7CHWLT2J.js.map} +0 -0
  387. /package/dist/cli-bundle/chunks/{chunk-L6FVNR7X.js.map → chunk-A3GAQLBH.js.map} +0 -0
  388. /package/dist/cli-bundle/chunks/{chunk-B57RJHBZ.js.map → chunk-A4FVWFZY.js.map} +0 -0
  389. /package/dist/cli-bundle/chunks/{chunk-D52ZN3BF.js.map → chunk-A5EQPNV7.js.map} +0 -0
  390. /package/dist/cli-bundle/chunks/{chunk-TZAE66GQ.js.map → chunk-AGEBQRBG.js.map} +0 -0
  391. /package/dist/cli-bundle/chunks/{chunk-WU3KAN6A.js.map → chunk-AQUNTB7G.js.map} +0 -0
  392. /package/dist/cli-bundle/chunks/{chunk-XWYQ2LT4.js.map → chunk-BBGR4FKQ.js.map} +0 -0
  393. /package/dist/cli-bundle/chunks/{chunk-2FUOXSRN.js.map → chunk-BFJP4VYC.js.map} +0 -0
  394. /package/dist/cli-bundle/chunks/{chunk-633PKXLT.js.map → chunk-BZKE2O5V.js.map} +0 -0
  395. /package/dist/cli-bundle/chunks/{chunk-L337QKWJ.js.map → chunk-DUDLSQFG.js.map} +0 -0
  396. /package/dist/cli-bundle/chunks/{chunk-BVLOMU6O.js.map → chunk-E7KBMWEF.js.map} +0 -0
  397. /package/dist/cli-bundle/chunks/{chunk-WQXRZMFN.js.map → chunk-EEECAV5M.js.map} +0 -0
  398. /package/dist/cli-bundle/chunks/{chunk-35FHWD4C.js.map → chunk-EI3UIMZM.js.map} +0 -0
  399. /package/dist/cli-bundle/chunks/{chunk-PT7MCCGD.js.map → chunk-FIUTBFC6.js.map} +0 -0
  400. /package/dist/cli-bundle/chunks/{chunk-7H5NNCJ5.js.map → chunk-FQF6VVPH.js.map} +0 -0
  401. /package/dist/cli-bundle/chunks/{chunk-6DYOZS6C.js.map → chunk-FQO5THHM.js.map} +0 -0
  402. /package/dist/cli-bundle/chunks/{chunk-5HGZKQUL.js.map → chunk-FQODDTE7.js.map} +0 -0
  403. /package/dist/cli-bundle/chunks/{chunk-67RO3H4N.js.map → chunk-G33XIMRT.js.map} +0 -0
  404. /package/dist/cli-bundle/chunks/{chunk-QWBKN3QC.js.map → chunk-GKCEEXMA.js.map} +0 -0
  405. /package/dist/cli-bundle/chunks/{chunk-DG2EQRIH.js.map → chunk-GRDK25BN.js.map} +0 -0
  406. /package/dist/cli-bundle/chunks/{chunk-FXFCFL73.js.map → chunk-H3YKUVDR.js.map} +0 -0
  407. /package/dist/cli-bundle/chunks/{chunk-ARGDWQ4J.js.map → chunk-IGBBTPM5.js.map} +0 -0
  408. /package/dist/cli-bundle/chunks/{chunk-FY4RLHSC.js.map → chunk-IRJ6F23W.js.map} +0 -0
  409. /package/dist/cli-bundle/chunks/{chunk-66MKH7SZ.js.map → chunk-IXG5CMBR.js.map} +0 -0
  410. /package/dist/cli-bundle/chunks/{chunk-7UCY6DR5.js.map → chunk-JPWUZOMR.js.map} +0 -0
  411. /package/dist/cli-bundle/chunks/{chunk-FVNWHUME.js.map → chunk-K2L6FZBX.js.map} +0 -0
  412. /package/dist/cli-bundle/chunks/{chunk-X2MGQMZO.js.map → chunk-LT5UWU7H.js.map} +0 -0
  413. /package/dist/cli-bundle/chunks/{chunk-KH6QAHME.js.map → chunk-M4B4RK4J.js.map} +0 -0
  414. /package/dist/cli-bundle/chunks/{chunk-2XOSFSTH.js.map → chunk-MQOSMBWV.js.map} +0 -0
  415. /package/dist/cli-bundle/chunks/{chunk-7R6UIHYY.js.map → chunk-N2TEEOXJ.js.map} +0 -0
  416. /package/dist/cli-bundle/chunks/{chunk-NTRQLE2R.js.map → chunk-N7FCFJ76.js.map} +0 -0
  417. /package/dist/cli-bundle/chunks/{chunk-37DRDP2B.js.map → chunk-NPEYH6CE.js.map} +0 -0
  418. /package/dist/cli-bundle/chunks/{chunk-2CXL335K.js.map → chunk-OK7VSX3N.js.map} +0 -0
  419. /package/dist/cli-bundle/chunks/{chunk-NNANAWFH.js.map → chunk-OKPZDH43.js.map} +0 -0
  420. /package/dist/cli-bundle/chunks/{chunk-G6MYGULG.js.map → chunk-OKWJUL6F.js.map} +0 -0
  421. /package/dist/cli-bundle/chunks/{chunk-D5XHO4Q7.js.map → chunk-Q6JPYR7I.js.map} +0 -0
  422. /package/dist/cli-bundle/chunks/{chunk-IE5KRAKN.js.map → chunk-QQ77W23U.js.map} +0 -0
  423. /package/dist/cli-bundle/chunks/{chunk-M7MVOKVV.js.map → chunk-QYGK2XQ3.js.map} +0 -0
  424. /package/dist/cli-bundle/chunks/{chunk-X5YCTFKT.js.map → chunk-RWAIRGBC.js.map} +0 -0
  425. /package/dist/cli-bundle/chunks/{chunk-W5E2UUSH.js.map → chunk-RX53WHFI.js.map} +0 -0
  426. /package/dist/cli-bundle/chunks/{chunk-R5XTTZSJ.js.map → chunk-SBW7EQC4.js.map} +0 -0
  427. /package/dist/cli-bundle/chunks/{chunk-TM5CIO3F.js.map → chunk-SGJB6PXA.js.map} +0 -0
  428. /package/dist/cli-bundle/chunks/{chunk-DDFGYUCQ.js.map → chunk-STBCBDKF.js.map} +0 -0
  429. /package/dist/cli-bundle/chunks/{chunk-FHOBCGQO.js.map → chunk-SVAWG7EE.js.map} +0 -0
  430. /package/dist/cli-bundle/chunks/{chunk-6O44IN44.js.map → chunk-T6MOTLOJ.js.map} +0 -0
  431. /package/dist/cli-bundle/chunks/{chunk-EWIT5WIC.js.map → chunk-U6RYD446.js.map} +0 -0
  432. /package/dist/cli-bundle/chunks/{chunk-E4FXM2XB.js.map → chunk-UE7LK3RE.js.map} +0 -0
  433. /package/dist/cli-bundle/chunks/{chunk-N33FD2UI.js.map → chunk-UNNCT5QY.js.map} +0 -0
  434. /package/dist/cli-bundle/chunks/{chunk-2IPNL3DR.js.map → chunk-UOIFZ66L.js.map} +0 -0
  435. /package/dist/cli-bundle/chunks/{chunk-LSOWTLEM.js.map → chunk-UU6EP25G.js.map} +0 -0
  436. /package/dist/cli-bundle/chunks/{chunk-HYTOJW2Q.js.map → chunk-UW6HCMP2.js.map} +0 -0
  437. /package/dist/cli-bundle/chunks/{chunk-47HXN6RX.js.map → chunk-UWAQI3B7.js.map} +0 -0
  438. /package/dist/cli-bundle/chunks/{chunk-YKFHF37B.js.map → chunk-V4QHAMI5.js.map} +0 -0
  439. /package/dist/cli-bundle/chunks/{chunk-VAHZIPWS.js.map → chunk-VA3H7VVC.js.map} +0 -0
  440. /package/dist/cli-bundle/chunks/{chunk-TLWJP5BF.js.map → chunk-VQOG2ETB.js.map} +0 -0
  441. /package/dist/cli-bundle/chunks/{chunk-H5IOT54C.js.map → chunk-VSQE43NO.js.map} +0 -0
  442. /package/dist/cli-bundle/chunks/{chunk-BDA35QG5.js.map → chunk-W6IEJXNC.js.map} +0 -0
  443. /package/dist/cli-bundle/chunks/{chunk-OWP6QFBV.js.map → chunk-XDWXPG2E.js.map} +0 -0
  444. /package/dist/cli-bundle/chunks/{chunk-CKX4WOPC.js.map → chunk-XKVHL3MB.js.map} +0 -0
  445. /package/dist/cli-bundle/chunks/{chunk-WL3SS45P.js.map → chunk-XVB6BATY.js.map} +0 -0
  446. /package/dist/cli-bundle/chunks/{chunk-NVZ6NVHJ.js.map → chunk-XXWDEQ6O.js.map} +0 -0
  447. /package/dist/cli-bundle/chunks/{chunk-ILVOOAT4.js.map → chunk-Y2VSGFT4.js.map} +0 -0
  448. /package/dist/cli-bundle/chunks/{chunk-NCVT6XEL.js.map → chunk-YG56M3NE.js.map} +0 -0
  449. /package/dist/cli-bundle/chunks/{chunk-AFGKSHAM.js.map → chunk-YGEA4CLH.js.map} +0 -0
  450. /package/dist/cli-bundle/chunks/{chunk-AXRT7K5V.js.map → chunk-YIC5NGXF.js.map} +0 -0
  451. /package/dist/cli-bundle/chunks/{chunk-XXLXJL7V.js.map → chunk-ZUCBPXNA.js.map} +0 -0
  452. /package/dist/cli-bundle/chunks/{close-X3CF6FQP.js.map → close-7NWA3GLA.js.map} +0 -0
  453. /package/dist/cli-bundle/chunks/{close-GPD7DTJV.js.map → close-ZZCDDWJT.js.map} +0 -0
  454. /package/dist/cli-bundle/chunks/{close-many-NQLYGPYW.js.map → close-many-QCZHFCON.js.map} +0 -0
  455. /package/dist/cli-bundle/chunks/{close-many-J7A5EHOQ.js.map → close-many-YALQ7AXS.js.map} +0 -0
  456. /package/dist/cli-bundle/chunks/{comments-2AOZQ5D2.js.map → comments-FMQNYPSZ.js.map} +0 -0
  457. /package/dist/cli-bundle/chunks/{comments-TMHMALA5.js.map → comments-SQIQ5WYR.js.map} +0 -0
  458. /package/dist/cli-bundle/chunks/{copy-N3LCQBMC.js.map → copy-GI3RCVZP.js.map} +0 -0
  459. /package/dist/cli-bundle/chunks/{copy-FWQA5OU4.js.map → copy-YDAMENCP.js.map} +0 -0
  460. /package/dist/cli-bundle/chunks/{create-AQ5SIGZC.js.map → create-JSL6CXU3.js.map} +0 -0
  461. /package/dist/cli-bundle/chunks/{create-KOGQ3JKD.js.map → create-LXMLYJNM.js.map} +0 -0
  462. /package/dist/cli-bundle/chunks/{delete-6G3MBZ6S.js.map → delete-5DFAXJNI.js.map} +0 -0
  463. /package/dist/cli-bundle/chunks/{delete-YYYFOSEA.js.map → delete-IGVOZEU2.js.map} +0 -0
  464. /package/dist/cli-bundle/chunks/{deps-NIIKXLPB.js.map → deps-BQAXUQAK.js.map} +0 -0
  465. /package/dist/cli-bundle/chunks/{deps-MQ4ZIGZB.js.map → deps-CBPPSS6J.js.map} +0 -0
  466. /package/dist/cli-bundle/chunks/{docs-OWRGDMNY.js.map → docs-KCWPLQOV.js.map} +0 -0
  467. /package/dist/cli-bundle/chunks/{docs-53NUGMIQ.js.map → docs-NS2AZWCN.js.map} +0 -0
  468. /package/dist/cli-bundle/chunks/{files-3PXGXYDB.js.map → files-PVWEPT5J.js.map} +0 -0
  469. /package/dist/cli-bundle/chunks/{files-EGLKHD7O.js.map → files-XUUBQ76I.js.map} +0 -0
  470. /package/dist/cli-bundle/chunks/{focus-KZLIA6WS.js.map → focus-3EJVFI3D.js.map} +0 -0
  471. /package/dist/cli-bundle/chunks/{focus-SRPASFTN.js.map → focus-DHBHKK3E.js.map} +0 -0
  472. /package/dist/cli-bundle/chunks/{history-compact-G4DULDCX.js.map → history-compact-3TNPYVFG.js.map} +0 -0
  473. /package/dist/cli-bundle/chunks/{history-compact-HHIUOMZ7.js.map → history-compact-JHYVDYLW.js.map} +0 -0
  474. /package/dist/cli-bundle/chunks/{history-redact-IUSJ6X3E.js.map → history-redact-ELRL73XN.js.map} +0 -0
  475. /package/dist/cli-bundle/chunks/{history-redact-THHGRQXV.js.map → history-redact-KKFDICCF.js.map} +0 -0
  476. /package/dist/cli-bundle/chunks/{history-repair-LUQWRS7X.js.map → history-repair-J7WKZFAG.js.map} +0 -0
  477. /package/dist/cli-bundle/chunks/{history-repair-KG7SWXI6.js.map → history-repair-REMI7DDI.js.map} +0 -0
  478. /package/dist/cli-bundle/chunks/{learnings-ZVHSALJY.js.map → learnings-O6V5WDCV.js.map} +0 -0
  479. /package/dist/cli-bundle/chunks/{learnings-2MRNBFJF.js.map → learnings-X4D6JCCG.js.map} +0 -0
  480. /package/dist/cli-bundle/chunks/{notes-73JWKWUD.js.map → notes-UQC6VS6N.js.map} +0 -0
  481. /package/dist/cli-bundle/chunks/{notes-BAKUL5DJ.js.map → notes-ZSZREWZA.js.map} +0 -0
  482. /package/dist/cli-bundle/chunks/{plan-AZPMCG37.js.map → plan-5GKRBJJO.js.map} +0 -0
  483. /package/dist/cli-bundle/chunks/{plan-LEAGLPGP.js.map → plan-EZW2YDDY.js.map} +0 -0
  484. /package/dist/cli-bundle/chunks/{profile-AVCIIZID.js.map → profile-5PQAPCLF.js.map} +0 -0
  485. /package/dist/cli-bundle/chunks/{profile-LFYO3HHX.js.map → profile-CW4BD3FO.js.map} +0 -0
  486. /package/dist/cli-bundle/chunks/{register-list-query-UKMF55FT.js.map → register-list-query-HTDQE6VI.js.map} +0 -0
  487. /package/dist/cli-bundle/chunks/{register-list-query-MZUF2EEC.js.map → register-list-query-PHIPDFP2.js.map} +0 -0
  488. /package/dist/cli-bundle/chunks/{register-mutation-T6RVNJC4.js.map → register-mutation-BLEWM5I6.js.map} +0 -0
  489. /package/dist/cli-bundle/chunks/{register-mutation-2PBW2GEX.js.map → register-mutation-OTYHR7J6.js.map} +0 -0
  490. /package/dist/cli-bundle/chunks/{restore-KIUYTAEJ.js.map → restore-A55MLFAI.js.map} +0 -0
  491. /package/dist/cli-bundle/chunks/{restore-E3PRGDN3.js.map → restore-HEQAG6EK.js.map} +0 -0
  492. /package/dist/cli-bundle/chunks/{schema-5JNFQFUW.js.map → schema-MAXAIHEC.js.map} +0 -0
  493. /package/dist/cli-bundle/chunks/{schema-TMIW4XZC.js.map → schema-Q5DAWJ2S.js.map} +0 -0
  494. /package/dist/cli-bundle/chunks/{update-XZJYS5X7.js.map → update-5DTSCWVF.js.map} +0 -0
  495. /package/dist/cli-bundle/chunks/{update-SQYZA3ZW.js.map → update-DWFXXJKP.js.map} +0 -0
  496. /package/dist/cli-bundle/chunks/{update-many-WQ3R3J6N.js.map → update-many-6T4ZLZS7.js.map} +0 -0
  497. /package/dist/cli-bundle/chunks/{update-many-R24B3GBK.js.map → update-many-MYRK6VBJ.js.map} +0 -0
@@ -1,56 +1,17 @@
1
- import {
2
- runDocs
3
- } from "./chunk-D5XHO4Q7.js";
4
- import {
5
- scanHistoryDrift
6
- } from "./chunk-2FUOXSRN.js";
7
- import {
8
- runFiles
9
- } from "./chunk-66MKH7SZ.js";
10
- import {
11
- isRemoteLinkedArtifactReference
12
- } from "./chunk-FVNWHUME.js";
13
1
  import {
14
2
  runUpdate
15
- } from "./chunk-HPAYDSR2.js";
16
- import {
17
- wrapOwnershipConflict
18
- } from "./chunk-QWBKN3QC.js";
19
- import {
20
- PM_TELEMETRY_SOURCE_CONTEXT_VALUES,
21
- TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS,
22
- TELEMETRY_SCHEMA_VERSION,
23
- flushTelemetryQueueNow
24
- } from "./chunk-RTBX3C4C.js";
3
+ } from "./chunk-P24ZU5QV.js";
25
4
  import {
26
5
  buildCapabilityContractMetadata,
27
6
  buildRegistrationCollisionRemediation,
28
7
  collectUnknownCapabilityGuidance,
29
8
  readManagedExtensionState,
30
9
  runInit
31
- } from "./chunk-DHNG452T.js";
10
+ } from "./chunk-ZF52NVRT.js";
32
11
  import {
33
12
  collectStaleVectorizationIds,
34
13
  runNext
35
- } from "./chunk-OGVTB5VO.js";
36
- import {
37
- collectDanglingDependencyReferences,
38
- createRelationshipKindRegistry
39
- } from "./chunk-3CUQZNQ6.js";
40
- import {
41
- computeContentFieldUtilization
42
- } from "./chunk-AXRT7K5V.js";
43
- import {
44
- computeMetadataCoverage,
45
- groupItemsByDimension,
46
- lifecycleClassifierFromStatusRegistry
47
- } from "./chunk-NTRQLE2R.js";
48
- import {
49
- parseLimit
50
- } from "./chunk-I7DIDUSP.js";
51
- import {
52
- resolveAuthor
53
- } from "./chunk-YRYYFGV3.js";
14
+ } from "./chunk-AR24KW26.js";
54
15
  import {
55
16
  buildVectorizationEmbeddingIdentity,
56
17
  hasVectorizationEmbeddingIdentityChanged,
@@ -60,7 +21,10 @@ import {
60
21
  resolveProviderConfigSource,
61
22
  resolveSettingsWithSemanticRuntimeDefaults,
62
23
  resolveVectorStores
63
- } from "./chunk-7R6UIHYY.js";
24
+ } from "./chunk-N2TEEOXJ.js";
25
+ import {
26
+ scanHistoryDrift
27
+ } from "./chunk-BFJP4VYC.js";
64
28
  import {
65
29
  ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS,
66
30
  ACTIVITY_FLAG_CONTRACTS,
@@ -152,7 +116,10 @@ import {
152
116
  UPGRADE_FLAG_CONTRACTS,
153
117
  VALIDATE_FLAG_CONTRACTS,
154
118
  compactFlagAliasContracts
155
- } from "./chunk-WQXRZMFN.js";
119
+ } from "./chunk-EEECAV5M.js";
120
+ import {
121
+ wrapOwnershipConflict
122
+ } from "./chunk-GKCEEXMA.js";
156
123
  import {
157
124
  LINKED_TEST_PM_CONTEXT_MODE_VALUES,
158
125
  LINKED_TEST_PROTECTED_ENV_KEYS,
@@ -169,12 +136,41 @@ import {
169
136
  parseLinkedTestRegexList,
170
137
  parseLinkedTestStringList,
171
138
  runCreate
172
- } from "./chunk-MR4SHYR4.js";
139
+ } from "./chunk-3QNUDDY2.js";
140
+ import {
141
+ collectDanglingDependencyReferences
142
+ } from "./chunk-66SRNEBK.js";
143
+ import {
144
+ runDocs
145
+ } from "./chunk-Q6JPYR7I.js";
146
+ import {
147
+ runFiles
148
+ } from "./chunk-IXG5CMBR.js";
149
+ import {
150
+ isRemoteLinkedArtifactReference
151
+ } from "./chunk-K2L6FZBX.js";
173
152
  import {
174
153
  createStdinTokenResolver,
175
154
  parseCsvKv,
176
155
  parseOptionalNumber
177
- } from "./chunk-D52ZN3BF.js";
156
+ } from "./chunk-A5EQPNV7.js";
157
+ import {
158
+ computeContentFieldUtilization
159
+ } from "./chunk-YIC5NGXF.js";
160
+ import {
161
+ computeMetadataCoverage,
162
+ groupItemsByDimension,
163
+ lifecycleClassifierFromStatusRegistry
164
+ } from "./chunk-N7FCFJ76.js";
165
+ import {
166
+ parseLimit
167
+ } from "./chunk-7CHWLT2J.js";
168
+ import {
169
+ readHistoryEntries
170
+ } from "./chunk-RWAIRGBC.js";
171
+ import {
172
+ resolveAuthor
173
+ } from "./chunk-YRYYFGV3.js";
178
174
  import {
179
175
  CURRENT_ITEM_FORMAT_VERSION,
180
176
  compareTimestampStrings,
@@ -201,7 +197,7 @@ import {
201
197
  stableValueEquals,
202
198
  toItemRecord,
203
199
  writeSettings
204
- } from "./chunk-646MQXFW.js";
200
+ } from "./chunk-RLLOZAM2.js";
205
201
  import {
206
202
  DEFAULT_VALIDATE_CLOSURE_LIKE_METADATA_FIELD_PATTERNS,
207
203
  DEFAULT_VALIDATE_STALE_BLOCKER_REASON_PATTERNS,
@@ -216,9 +212,12 @@ import {
216
212
  SCOPE_VALUES,
217
213
  SETTINGS_DEFAULTS,
218
214
  activateExtensions,
215
+ appendLineAtomic,
219
216
  collectRegisteredItemFieldNames,
220
217
  commandOptionFlagLabel,
218
+ createRelationshipKindRegistry,
221
219
  ensureDir,
220
+ getHistoryPath,
222
221
  getItemFormatFromPath,
223
222
  getSettingsPath,
224
223
  getTestRunRecordPath,
@@ -237,31 +236,1849 @@ import {
237
236
  resolveCommandOptionPolicyState,
238
237
  resolveGlobalPmRoot,
239
238
  resolveItemTypeRegistry,
239
+ resolvePmPackageRootFromModule,
240
240
  resolvePmRoot,
241
241
  resolveRuntimeFieldRegistry,
242
242
  resolveRuntimeStatusRegistry,
243
+ resolveTelemetryErrorCategory,
243
244
  statusIsTerminal,
244
245
  toNonEmptyStringOrUndefined,
245
246
  writeFileAtomic
246
- } from "./chunk-WACRQ26A.js";
247
+ } from "./chunk-WCBB6VI3.js";
248
+
249
+ // dist/core/telemetry/observability.js
250
+ !(function() {
251
+ try {
252
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
253
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "709506f3-2e03-5e96-92ed-ce143873577a");
254
+ } catch (e2) {
255
+ }
256
+ })();
257
+ var SETUP_ROOT_COMMANDS = /* @__PURE__ */ new Set([
258
+ "init",
259
+ "config",
260
+ "completion",
261
+ "completion-statuses",
262
+ "completion-tags",
263
+ "completion-types"
264
+ ]);
265
+ var QUERY_ROOT_COMMANDS = /* @__PURE__ */ new Set([
266
+ "list",
267
+ "list-all",
268
+ "list-open",
269
+ "list-in-progress",
270
+ "list-blocked",
271
+ "list-closed",
272
+ "list-canceled",
273
+ "list-draft",
274
+ "search",
275
+ "get",
276
+ "context",
277
+ "calendar",
278
+ "history",
279
+ "activity",
280
+ "aggregate",
281
+ "deps",
282
+ "contracts",
283
+ "stats"
284
+ ]);
285
+ var MUTATION_ROOT_COMMANDS = /* @__PURE__ */ new Set([
286
+ "create",
287
+ "update",
288
+ "update-many",
289
+ "close-many",
290
+ "append",
291
+ "close",
292
+ "delete",
293
+ "restore",
294
+ "claim",
295
+ "release",
296
+ "comments",
297
+ "notes",
298
+ "learnings",
299
+ "files",
300
+ "docs",
301
+ "start-task",
302
+ "pause-task",
303
+ "close-task"
304
+ ]);
305
+ var TESTING_ROOT_COMMANDS = /* @__PURE__ */ new Set([
306
+ "test",
307
+ "test-all",
308
+ "test-runs",
309
+ "test-verify",
310
+ "trace-test",
311
+ "test-ping"
312
+ ]);
313
+ var DIAGNOSTICS_ROOT_COMMANDS = /* @__PURE__ */ new Set([
314
+ "health",
315
+ "validate",
316
+ "normalize",
317
+ "reindex",
318
+ "gc",
319
+ "telemetry",
320
+ "extension-doctor"
321
+ ]);
322
+ function normalizeCommandPath(commandPath) {
323
+ return commandPath.trim().replaceAll(/\s+/g, " ").toLowerCase();
324
+ }
325
+ function normalizeErrorCode(errorCode2) {
326
+ const normalized = errorCode2?.trim().toLowerCase();
327
+ return normalized && normalized.length > 0 ? normalized : void 0;
328
+ }
329
+ var TELEMETRY_ERROR_MESSAGE_CLASSIFIERS = [
330
+ {
331
+ code: "unknown_command",
332
+ matches: (message) => message.includes("unknown command")
333
+ },
334
+ {
335
+ code: "unknown_option",
336
+ matches: (message) => message.includes("unknown option")
337
+ },
338
+ {
339
+ code: "missing_required_option",
340
+ matches: (message) => message.includes("missing required options") || message.includes("missing required option")
341
+ },
342
+ {
343
+ code: "missing_required_argument",
344
+ matches: (message) => message.includes("missing required argument")
345
+ },
346
+ {
347
+ code: "no_update_fields",
348
+ matches: (message) => message.includes("no update flags provided")
349
+ },
350
+ {
351
+ code: "ownership_conflict",
352
+ matches: (message) => message.includes("is assigned to") && message.includes("use --force")
353
+ },
354
+ {
355
+ code: "lock_conflict",
356
+ matches: (message) => message.includes("is locked")
357
+ },
358
+ {
359
+ code: "terminal_state_conflict",
360
+ matches: (message) => message.includes("already terminal") && message.includes("use --force")
361
+ },
362
+ {
363
+ code: "tracker_not_initialized",
364
+ matches: (message) => message.includes("tracker is not initialized")
365
+ },
366
+ {
367
+ code: "item_not_found",
368
+ matches: (message) => message.includes(" not found")
369
+ },
370
+ {
371
+ code: "close_through_update",
372
+ matches: (message) => message.includes('use "pm close <id> <text>" to close an item') || message.includes("invalid --status value") && message.includes('"closed"')
373
+ },
374
+ {
375
+ code: "invalid_argument_value",
376
+ matches: (message) => message.startsWith("invalid ") || message.includes(" must be ") || message.includes(" requires ")
377
+ },
378
+ {
379
+ code: "invalid_command_usage",
380
+ matches: (message) => message.includes("either as positional") && message.includes("not both")
381
+ }
382
+ ];
383
+ var TELEMETRY_EXIT_CODE_FALLBACKS = /* @__PURE__ */ new Map([
384
+ [EXIT_CODE.USAGE, "invalid_command_usage"],
385
+ [EXIT_CODE.NOT_FOUND, "item_not_found"],
386
+ [EXIT_CODE.CONFLICT, "lock_conflict"],
387
+ [EXIT_CODE.DEPENDENCY_FAILED, "dependency_failed"]
388
+ ]);
389
+ function deriveTelemetryCommandTaxonomy(commandPath) {
390
+ const normalizedPath = normalizeCommandPath(commandPath);
391
+ const tokens = normalizedPath.length > 0 ? normalizedPath.split(" ") : ["<unknown>"];
392
+ const root = tokens[0];
393
+ const leaf = tokens[tokens.length - 1];
394
+ let family = "other";
395
+ if (SETUP_ROOT_COMMANDS.has(root)) {
396
+ family = "setup";
397
+ } else if (QUERY_ROOT_COMMANDS.has(root)) {
398
+ family = "query";
399
+ } else if (MUTATION_ROOT_COMMANDS.has(root)) {
400
+ family = "mutation";
401
+ } else if (TESTING_ROOT_COMMANDS.has(root)) {
402
+ family = "testing";
403
+ } else if (root === "extension") {
404
+ family = "extension";
405
+ } else if (DIAGNOSTICS_ROOT_COMMANDS.has(root)) {
406
+ family = "diagnostics";
407
+ }
408
+ return {
409
+ command_path: normalizedPath.length > 0 ? normalizedPath : "<unknown>",
410
+ command_root: root,
411
+ command_leaf: leaf,
412
+ command_depth: tokens.length,
413
+ command_family: family
414
+ };
415
+ }
416
+ function inferTelemetryErrorCode(params) {
417
+ if (params.ok) {
418
+ return void 0;
419
+ }
420
+ const explicit = normalizeErrorCode(params.errorCode);
421
+ if (explicit) {
422
+ return explicit;
423
+ }
424
+ const message = (params.errorMessage ?? "").trim().toLowerCase();
425
+ for (const classifier of TELEMETRY_ERROR_MESSAGE_CLASSIFIERS) {
426
+ if (classifier.matches(message)) {
427
+ return classifier.code;
428
+ }
429
+ }
430
+ const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode)) : void 0;
431
+ if (exitCode !== void 0) {
432
+ return TELEMETRY_EXIT_CODE_FALLBACKS.get(exitCode) ?? "command_failed";
433
+ }
434
+ return "command_failed";
435
+ }
436
+ function deriveTelemetryCommandResolution(params) {
437
+ if (params.ok) {
438
+ return "success";
439
+ }
440
+ const normalizedCode = normalizeErrorCode(params.errorCode);
441
+ if (normalizedCode === "unknown_command") {
442
+ return "nonexistent_command";
443
+ }
444
+ if (normalizedCode === "unknown_option") {
445
+ return "invalid_option";
446
+ }
447
+ if (normalizedCode === "missing_required_option") {
448
+ return "missing_required_option";
449
+ }
450
+ if (normalizedCode === "missing_required_argument") {
451
+ return "missing_required_argument";
452
+ }
453
+ if (normalizedCode === "health_findings") {
454
+ return "health_findings";
455
+ }
456
+ if (normalizedCode === "validation_findings") {
457
+ return "validation_findings";
458
+ }
459
+ if (params.errorCategory === "usage") {
460
+ return "invalid_usage";
461
+ }
462
+ if (params.errorCategory === "validation") {
463
+ return "validation_failed";
464
+ }
465
+ if (params.errorCategory === "conflict") {
466
+ return "conflict";
467
+ }
468
+ if (params.errorCategory === "runtime") {
469
+ return "runtime_failed";
470
+ }
471
+ return "unknown_failed";
472
+ }
473
+
474
+ // dist/core/telemetry/runtime.js
475
+ import crypto from "node:crypto";
476
+ import { spawn } from "node:child_process";
477
+ import { mkdirSync, rmSync, statSync } from "node:fs";
478
+ import { mkdir, readdir, rm, stat } from "node:fs/promises";
479
+ import os from "node:os";
480
+ import path from "node:path";
481
+ !(function() {
482
+ try {
483
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
484
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b74503bf-b4b8-5528-a465-df9bb7f71863");
485
+ } catch (e2) {
486
+ }
487
+ })();
488
+ var TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
489
+ var TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
490
+ var TELEMETRY_OTEL_SPANS_RELATIVE_PATH = path.join("runtime", "telemetry", "otel-spans.jsonl");
491
+ var TELEMETRY_OTEL_SPANS_FLUSH_BATCH_SIZE = 8;
492
+ var TELEMETRY_OTEL_SPANS_MAX_PENDING = 500;
493
+ var TELEMETRY_SCHEMA_VERSION = 1;
494
+ var TELEMETRY_CLIENT_SCHEMA_VERSION = 1;
495
+ var TELEMETRY_FLUSH_BATCH_SIZE = 100;
496
+ var TELEMETRY_MAX_RETRY_DELAY_MS = 36e5;
497
+ var TELEMETRY_RETRY_BASE_DELAY_MS = 3e4;
498
+ var TELEMETRY_HTTP_TIMEOUT_MS = 5e3;
499
+ var MILLISECONDS_PER_DAY = 864e5;
500
+ var TELEMETRY_MAX_EVENT_BYTES = 65536;
501
+ var TELEMETRY_SANITIZE_MAX_DEPTH = 6;
502
+ var TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS = 20;
503
+ var TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;
504
+ var TELEMETRY_RESULT_PREVIEW_MAX_BYTES = 8192;
505
+ var TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS = [25, 50, 100, 200];
506
+ var TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1e3;
507
+ var TELEMETRY_FLUSH_LOCK_STALE_MS = 6e4;
508
+ var TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS = 6e4;
509
+ var OTEL_TRACES_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_TRACES_ENDPOINT";
510
+ var OTEL_BASE_ENDPOINT_ENV = "OTEL_EXPORTER_OTLP_ENDPOINT";
511
+ var OTEL_SERVICE_NAME_ENV = "OTEL_SERVICE_NAME";
512
+ var PM_TELEMETRY_DISABLED_ENV = "PM_TELEMETRY_DISABLED";
513
+ var PM_NO_TELEMETRY_ENV = "PM_NO_TELEMETRY";
514
+ var PM_TELEMETRY_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
515
+ var PM_TELEMETRY_OTEL_DISABLED_ENV = "PM_TELEMETRY_OTEL_DISABLED";
516
+ var PM_TELEMETRY_OTEL_DISABLED_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
517
+ var PM_TELEMETRY_INLINE_FLUSH_ENV = "PM_TELEMETRY_INLINE_FLUSH";
518
+ var PM_TELEMETRY_FLUSH_CHILD_ENV = "PM_TELEMETRY_FLUSH_CHILD";
519
+ var PM_TELEMETRY_SOURCE_CONTEXT_ENV = "PM_TELEMETRY_SOURCE_CONTEXT";
520
+ var PM_AUTHOR_ENV = "PM_AUTHOR";
521
+ var PM_TELEMETRY_SOURCE_CONTEXT_VALUES = [
522
+ "user",
523
+ "automation",
524
+ "test",
525
+ "dogfood"
526
+ ];
527
+ var _lastFlushPromise = Promise.resolve();
528
+ var _queueMutationPromise = Promise.resolve();
529
+ var PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
530
+ var BOOLEAN_TRUE_VALUES = /* @__PURE__ */ new Set(["1", "true", "yes", "on"]);
531
+ var PROCESS_SESSION_ID = crypto.randomUUID();
532
+ var SENSITIVE_KEYWORDS = [
533
+ "token",
534
+ "secret",
535
+ "password",
536
+ "passwd",
537
+ "api_key",
538
+ "apikey",
539
+ "authorization",
540
+ "cookie",
541
+ "session",
542
+ "credentials",
543
+ "bearer"
544
+ ];
545
+ var SENSITIVE_INLINE_KEY_PATTERN = "(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer)";
546
+ var INLINE_SENSITIVE_ASSIGNMENT_PATTERN = new RegExp(`\\b(${SENSITIVE_INLINE_KEY_PATTERN})\\s*([:=])\\s*([^\\s,;]+)`, "giu");
547
+ var INLINE_SENSITIVE_FLAG_PATTERN = new RegExp(`(--${SENSITIVE_INLINE_KEY_PATTERN})(=|\\s+)([^\\s,;]+)`, "giu");
548
+ var ABSOLUTE_PATH_TOKEN_PATTERN = /(^|[\s"'`(=])\/(?:[^\s"'`),;]+)/g;
549
+ var BEARER_TOKEN_PATTERN = /bearer\s+[a-z0-9._=-]+/giu;
550
+ 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;
551
+ function queuePath(globalPmRoot) {
552
+ return path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
553
+ }
554
+ function otelSpansQueuePath(globalPmRoot) {
555
+ return path.join(globalPmRoot, TELEMETRY_OTEL_SPANS_RELATIVE_PATH);
556
+ }
557
+ function telemetryRuntimeDirectory(globalPmRoot) {
558
+ return path.dirname(queuePath(globalPmRoot));
559
+ }
560
+ function runtimeStatePath(globalPmRoot) {
561
+ return path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
562
+ }
563
+ function flushLockPath(globalPmRoot) {
564
+ return path.join(globalPmRoot, "runtime", "telemetry", "flush.lock");
565
+ }
566
+ function flushSpawnLockPath(globalPmRoot) {
567
+ return path.join(globalPmRoot, "runtime", "telemetry", "flush.spawn.lock");
568
+ }
569
+ function telemetryFlushRunnerPath() {
570
+ return path.join(resolvePmPackageRootFromModule(import.meta.url, ["../../.."]), "dist", "cli", "telemetry-flush.js");
571
+ }
572
+ function shouldFlushInline() {
573
+ if (parseBooleanTrueLike(process.env[PM_TELEMETRY_INLINE_FLUSH_ENV])) {
574
+ return true;
575
+ }
576
+ if (parseBooleanTrueLike(process.env[PM_TELEMETRY_FLUSH_CHILD_ENV])) {
577
+ return true;
578
+ }
579
+ const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
580
+ return typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test";
581
+ }
582
+ async function readRuntimeState(globalPmRoot) {
583
+ const raw = await readFileIfExists(runtimeStatePath(globalPmRoot));
584
+ if (!raw || raw.trim().length === 0) {
585
+ return {};
586
+ }
587
+ try {
588
+ const parsed = JSON.parse(raw);
589
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
590
+ return {};
591
+ }
592
+ return parsed;
593
+ } catch {
594
+ return {};
595
+ }
596
+ }
597
+ async function writeRuntimeState(globalPmRoot, patch) {
598
+ try {
599
+ const current = await readRuntimeState(globalPmRoot);
600
+ const next = {
601
+ ...current,
602
+ ...patch
603
+ };
604
+ const normalized = Object.fromEntries(Object.entries(next).filter(([, value]) => value !== void 0).sort((left, right) => left[0].localeCompare(right[0])));
605
+ await writeFileAtomic(runtimeStatePath(globalPmRoot), `${JSON.stringify(normalized, null, 2)}
606
+ `);
607
+ } catch {
608
+ }
609
+ }
610
+ function isSensitiveKey(key) {
611
+ const normalized = key.trim().toLowerCase().replaceAll("-", "_").replaceAll(/[^a-z0-9_]+/g, "_");
612
+ const tokens = normalized.split("_").filter((token) => token.length > 0);
613
+ return SENSITIVE_KEYWORDS.some((keyword) => normalized === keyword || normalized.endsWith(`_${keyword}`) || tokens.includes(keyword));
614
+ }
615
+ function redactInlineSensitiveAssignments(input) {
616
+ const withoutAssignments = input.replaceAll(INLINE_SENSITIVE_ASSIGNMENT_PATTERN, (_match, key, delimiter) => `${key}${delimiter}[redacted]`);
617
+ return withoutAssignments.replaceAll(INLINE_SENSITIVE_FLAG_PATTERN, (_match, flag, delimiter) => `${flag}${delimiter}[redacted]`);
618
+ }
619
+ function redactAbsolutePathTokens(input) {
620
+ return input.replaceAll(ABSOLUTE_PATH_TOKEN_PATTERN, (_match, prefix) => `${prefix}[redacted_path]`);
621
+ }
622
+ function isAsciiLetterOrDigitCode(code) {
623
+ const isUpper = code >= 65 && code <= 90;
624
+ const isLower = code >= 97 && code <= 122;
625
+ const isDigit = code >= 48 && code <= 57;
626
+ return isUpper || isLower || isDigit;
627
+ }
628
+ function isEmailLocalCharacter(character) {
629
+ if (!character) {
630
+ return false;
631
+ }
632
+ const code = character.charCodeAt(0);
633
+ if (isAsciiLetterOrDigitCode(code)) {
634
+ return true;
635
+ }
636
+ return character === "." || character === "_" || character === "%" || character === "+" || character === "-";
637
+ }
638
+ function isEmailDomainCharacter(character) {
639
+ if (!character) {
640
+ return false;
641
+ }
642
+ const code = character.charCodeAt(0);
643
+ if (isAsciiLetterOrDigitCode(code)) {
644
+ return true;
645
+ }
646
+ return character === "." || character === "-";
647
+ }
648
+ function looksLikeEmailToken(token) {
649
+ const atIndex = token.indexOf("@");
650
+ if (atIndex <= 0 || atIndex !== token.lastIndexOf("@") || atIndex === token.length - 1) {
651
+ return false;
652
+ }
653
+ const localPart = token.slice(0, atIndex);
654
+ const domainPart = token.slice(atIndex + 1);
655
+ const lastDot = domainPart.lastIndexOf(".");
656
+ if (lastDot <= 0 || lastDot === domainPart.length - 1) {
657
+ return false;
658
+ }
659
+ if (domainPart.length - (lastDot + 1) < 2) {
660
+ return false;
661
+ }
662
+ for (const character of localPart) {
663
+ if (!isEmailLocalCharacter(character)) {
664
+ return false;
665
+ }
666
+ }
667
+ for (const character of domainPart) {
668
+ if (!isEmailDomainCharacter(character)) {
669
+ return false;
670
+ }
671
+ }
672
+ return true;
673
+ }
674
+ function redactEmailTokens(input) {
675
+ let redacted = "";
676
+ let cursor = 0;
677
+ while (cursor < input.length) {
678
+ const atIndex = input.indexOf("@", cursor);
679
+ if (atIndex < 0) {
680
+ redacted += input.slice(cursor);
681
+ break;
682
+ }
683
+ let start = atIndex - 1;
684
+ while (start >= cursor && isEmailLocalCharacter(input[start])) {
685
+ start -= 1;
686
+ }
687
+ start += 1;
688
+ let end = atIndex + 1;
689
+ while (end < input.length && isEmailDomainCharacter(input[end])) {
690
+ end += 1;
691
+ }
692
+ const candidate = input.slice(start, end);
693
+ if (looksLikeEmailToken(candidate)) {
694
+ redacted += input.slice(cursor, start);
695
+ redacted += "[redacted_email]";
696
+ cursor = end;
697
+ continue;
698
+ }
699
+ redacted += input.slice(cursor, atIndex + 1);
700
+ cursor = atIndex + 1;
701
+ }
702
+ return redacted;
703
+ }
704
+ function sanitizeCommonSensitiveTokens(input) {
705
+ const withoutEmails = redactEmailTokens(input);
706
+ const withoutBearer = withoutEmails.replaceAll(BEARER_TOKEN_PATTERN, "bearer [redacted_token]");
707
+ return withoutBearer.replaceAll(PRIVATE_IP_PATTERN, "[redacted_ip]");
708
+ }
709
+ function sanitizeStringRedacted(input) {
710
+ const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);
711
+ const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
712
+ const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
713
+ const trimmed = withoutAbsolutePaths.trim();
714
+ if (trimmed.startsWith("/") && trimmed.length > 1) {
715
+ return "[redacted_path]";
716
+ }
717
+ if (withoutAbsolutePaths.length > 512) {
718
+ return `${withoutAbsolutePaths.slice(0, 509)}...`;
719
+ }
720
+ return withoutAbsolutePaths;
721
+ }
722
+ function sanitizeStringMax(input) {
723
+ const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);
724
+ const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);
725
+ const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);
726
+ const trimmed = withoutAbsolutePaths.trim();
727
+ if (trimmed.startsWith("/") && trimmed.length > 1) {
728
+ return "[redacted_path]";
729
+ }
730
+ if (withoutAbsolutePaths.length > 2048) {
731
+ return `${withoutAbsolutePaths.slice(0, 2045)}...`;
732
+ }
733
+ return withoutAbsolutePaths;
734
+ }
735
+ function sanitizeString(input, captureLevel = "redacted") {
736
+ if (captureLevel === "max") {
737
+ return sanitizeStringMax(input);
738
+ }
739
+ return sanitizeStringRedacted(input);
740
+ }
741
+ function sanitizeValue(value, keyHint, captureLevel = "redacted", depth = 0) {
742
+ if (keyHint && isSensitiveKey(keyHint)) {
743
+ return "[redacted]";
744
+ }
745
+ if (value === null || value === void 0) {
746
+ return value;
747
+ }
748
+ if (typeof value === "string") {
749
+ return sanitizeString(value, captureLevel);
750
+ }
751
+ if (typeof value === "number" || typeof value === "boolean") {
752
+ return value;
753
+ }
754
+ if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
755
+ return "[depth_truncated]";
756
+ }
757
+ if (Array.isArray(value)) {
758
+ return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => sanitizeValue(entry, void 0, captureLevel, depth + 1));
759
+ }
760
+ if (typeof value === "object") {
761
+ const record = value;
762
+ const sanitized = {};
763
+ for (const [key, nested] of Object.entries(record)) {
764
+ sanitized[key] = sanitizeValue(nested, key, captureLevel, depth + 1);
765
+ }
766
+ return sanitized;
767
+ }
768
+ return String(value);
769
+ }
770
+ function sanitizeCommandArgs(args, captureLevel = "redacted") {
771
+ const sanitized = [];
772
+ let nextIsSensitiveValue = false;
773
+ for (const rawArg of args) {
774
+ const arg = sanitizeString(rawArg, captureLevel);
775
+ if (nextIsSensitiveValue) {
776
+ sanitized.push("[redacted]");
777
+ nextIsSensitiveValue = false;
778
+ continue;
779
+ }
780
+ if (arg.startsWith("--")) {
781
+ const withoutPrefix = arg.slice(2);
782
+ const delimiterIndex = withoutPrefix.indexOf("=");
783
+ if (delimiterIndex >= 0) {
784
+ const key = withoutPrefix.slice(0, delimiterIndex);
785
+ const value = withoutPrefix.slice(delimiterIndex + 1);
786
+ if (isSensitiveKey(key)) {
787
+ sanitized.push(`--${key}=[redacted]`);
788
+ } else {
789
+ sanitized.push(`--${key}=${sanitizeString(value, captureLevel)}`);
790
+ }
791
+ continue;
792
+ }
793
+ if (isSensitiveKey(withoutPrefix)) {
794
+ sanitized.push(`--${withoutPrefix}`);
795
+ nextIsSensitiveValue = true;
796
+ continue;
797
+ }
798
+ }
799
+ sanitized.push(arg);
800
+ }
801
+ return sanitized;
802
+ }
803
+ function normalizeCaptureLevel(value) {
804
+ const normalized = value?.trim().toLowerCase();
805
+ if (normalized === "minimal" || normalized === "redacted" || normalized === "max") {
806
+ return normalized;
807
+ }
808
+ return "redacted";
809
+ }
810
+ function parseBooleanTrueLike(value) {
811
+ return BOOLEAN_TRUE_VALUES.has((value ?? "").trim().toLowerCase());
812
+ }
813
+ function normalizePmVersion(value) {
814
+ const trimmed = typeof value === "string" ? value.trim() : "";
815
+ return trimmed.length > 0 ? trimmed : "0.0.0";
816
+ }
817
+ function normalizeTelemetryErrorCode(value) {
818
+ const normalized = value?.trim();
819
+ return normalized && normalized.length > 0 ? normalized : void 0;
820
+ }
821
+ function normalizeTelemetryExitCode(exitCode, ok) {
822
+ if (Number.isFinite(exitCode)) {
823
+ return Math.max(0, Math.trunc(exitCode));
824
+ }
825
+ return ok ? 0 : 1;
826
+ }
827
+ function normalizeTelemetryErrorCategory(params) {
828
+ if (params.ok) {
829
+ return void 0;
830
+ }
831
+ if (typeof params.errorCategory === "string" && params.errorCategory.trim().length > 0) {
832
+ return params.errorCategory;
833
+ }
834
+ if (typeof params.errorCode === "string" && params.errorCode.trim().length > 0) {
835
+ return resolveTelemetryErrorCategory(params.errorCode);
836
+ }
837
+ return "unknown";
838
+ }
839
+ function resolveTelemetrySourceContext(globalOptions) {
840
+ const override = (process.env[PM_TELEMETRY_SOURCE_CONTEXT_ENV] ?? "").trim().toLowerCase();
841
+ if (PM_TELEMETRY_SOURCE_CONTEXT_SET.has(override)) {
842
+ return {
843
+ source_context: override,
844
+ source_context_source: "env_override"
845
+ };
846
+ }
847
+ const nodeEnv = (process.env.NODE_ENV ?? "").trim().toLowerCase();
848
+ if (typeof process.env.VITEST === "string" || typeof process.env.VITEST_WORKER_ID === "string" || nodeEnv === "test") {
849
+ return {
850
+ source_context: "test",
851
+ source_context_source: "inferred"
852
+ };
853
+ }
854
+ const nonTty = process.stdin.isTTY !== true || process.stdout.isTTY !== true;
855
+ const ci = parseBooleanTrueLike(process.env.CI);
856
+ const scriptLikeMode = globalOptions.json === true || globalOptions.quiet === true;
857
+ if (nonTty || ci || scriptLikeMode) {
858
+ return {
859
+ source_context: "automation",
860
+ source_context_source: "inferred"
861
+ };
862
+ }
863
+ return {
864
+ source_context: "user",
865
+ source_context_source: "inferred"
866
+ };
867
+ }
868
+ function hashWithInstallationId(installationId, value) {
869
+ return crypto.createHash("sha256").update(`${installationId}:${value}`).digest("hex");
870
+ }
871
+ function buildAuthorContextPayloadFields(captureLevel, installationId) {
872
+ const author = (process.env[PM_AUTHOR_ENV] ?? "").trim();
873
+ if (captureLevel === "minimal") {
874
+ return { has_author_context: author.length > 0 };
875
+ }
876
+ return author.length > 0 ? { author_context_hash: hashWithInstallationId(installationId, author) } : {};
877
+ }
878
+ function normalizeForHash(value, depth = 0) {
879
+ if (value === null || value === void 0) {
880
+ return value;
881
+ }
882
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
883
+ return value;
884
+ }
885
+ if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {
886
+ return "[depth_truncated]";
887
+ }
888
+ if (Array.isArray(value)) {
889
+ return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => normalizeForHash(entry, depth + 1));
890
+ }
891
+ if (typeof value === "object") {
892
+ const record = value;
893
+ const normalized = {};
894
+ const sortedKeys = Object.keys(record).sort((left, right) => left.localeCompare(right));
895
+ for (const key of sortedKeys) {
896
+ normalized[key] = normalizeForHash(record[key], depth + 1);
897
+ }
898
+ return normalized;
899
+ }
900
+ return String(value);
901
+ }
902
+ function hashTelemetryValue(installationId, value) {
903
+ return hashWithInstallationId(installationId, JSON.stringify(normalizeForHash(value)));
904
+ }
905
+ function hashCommandArgs(installationId, args) {
906
+ return {
907
+ hashes: args.map((arg) => hashWithInstallationId(installationId, arg)),
908
+ digest: hashWithInstallationId(installationId, args.join("\0"))
909
+ };
910
+ }
911
+ function hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage) {
912
+ const normalizedMessage = sanitizeString(typeof errorMessage === "string" ? errorMessage : "", "redacted");
913
+ const normalizedCode = typeof errorCode2 === "string" && errorCode2.length > 0 ? errorCode2 : "unknown_error";
914
+ const fingerprintSource = `${command}\0${normalizedCode}\0${normalizedMessage}`;
915
+ return hashWithInstallationId(installationId, fingerprintSource);
916
+ }
917
+ function telemetryDisabledByEnvironment() {
918
+ 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());
919
+ }
920
+ function resolveOtelTracesEndpoint() {
921
+ if (PM_TELEMETRY_OTEL_DISABLED_VALUES.has((process.env[PM_TELEMETRY_OTEL_DISABLED_ENV] ?? "").trim().toLowerCase())) {
922
+ return null;
923
+ }
924
+ const directEndpoint = (process.env[OTEL_TRACES_ENDPOINT_ENV] ?? "").trim();
925
+ if (directEndpoint.length > 0) {
926
+ try {
927
+ return new URL(directEndpoint).toString();
928
+ } catch {
929
+ return null;
930
+ }
931
+ }
932
+ const baseEndpoint = (process.env[OTEL_BASE_ENDPOINT_ENV] ?? "").trim();
933
+ if (baseEndpoint.length === 0) {
934
+ return null;
935
+ }
936
+ try {
937
+ const url = new URL(baseEndpoint);
938
+ const normalizedPath = url.pathname.replace(/\/+$/, "");
939
+ if (!normalizedPath.endsWith("/v1/traces")) {
940
+ url.pathname = `${normalizedPath.length === 0 ? "" : normalizedPath}/v1/traces`;
941
+ }
942
+ return url.toString();
943
+ } catch {
944
+ return null;
945
+ }
946
+ }
947
+ function isoToUnixNano(iso) {
948
+ const parsedMs = Date.parse(iso);
949
+ const epochMs = Number.isNaN(parsedMs) ? Date.now() : parsedMs;
950
+ return `${BigInt(epochMs) * 1000000n}`;
951
+ }
952
+ function otlpStringAttribute(key, value) {
953
+ return {
954
+ key,
955
+ value: { stringValue: value }
956
+ };
957
+ }
958
+ function otlpBoolAttribute(key, value) {
959
+ return {
960
+ key,
961
+ value: { boolValue: value }
962
+ };
963
+ }
964
+ function otlpIntAttribute(key, value) {
965
+ return {
966
+ key,
967
+ value: { intValue: String(Math.max(0, Math.trunc(value))) }
968
+ };
969
+ }
970
+ function buildOtelSpanRequest(activeCommand, outcome, finishedAtIso, durationMs) {
971
+ 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) {
972
+ return null;
973
+ }
974
+ const serviceNameCandidate = sanitizeString((process.env[OTEL_SERVICE_NAME_ENV] ?? "").trim());
975
+ const serviceName = serviceNameCandidate.length > 0 ? serviceNameCandidate : "pm-cli";
976
+ const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
977
+ const normalizedErrorCode = normalizeTelemetryErrorCode(outcome.error_code);
978
+ const normalizedErrorCategory = normalizeTelemetryErrorCategory({
979
+ ok: outcome.ok,
980
+ errorCode: normalizedErrorCode,
981
+ errorCategory: outcome.error_category
982
+ });
983
+ const attributes = [
984
+ otlpStringAttribute("pm.command", sanitizeString(activeCommand.command)),
985
+ otlpStringAttribute("pm.version", activeCommand.pm_version),
986
+ otlpStringAttribute("pm.source_context", activeCommand.source_context),
987
+ otlpStringAttribute("pm.source_context_source", activeCommand.source_context_source),
988
+ otlpStringAttribute("pm.installation_id", activeCommand.installation_id),
989
+ otlpStringAttribute("pm.session_id", PROCESS_SESSION_ID),
990
+ otlpStringAttribute("pm.pm_root_hash", activeCommand.pm_root_hash),
991
+ otlpStringAttribute("pm.cwd_hash", activeCommand.cwd_hash),
992
+ otlpBoolAttribute("pm.ok", outcome.ok),
993
+ otlpIntAttribute("pm.exit_code", normalizedExitCode),
994
+ otlpIntAttribute("pm.duration_ms", durationMs)
995
+ ];
996
+ if (typeof normalizedErrorCode === "string") {
997
+ attributes.push(otlpStringAttribute("pm.error_code", normalizedErrorCode));
998
+ }
999
+ if (typeof normalizedErrorCategory === "string") {
1000
+ attributes.push(otlpStringAttribute("pm.error_category", normalizedErrorCategory));
1001
+ }
1002
+ if (typeof outcome.error === "string" && outcome.error.trim().length > 0) {
1003
+ attributes.push(otlpStringAttribute("pm.error", sanitizeString(outcome.error)));
1004
+ }
1005
+ const payload = {
1006
+ resourceSpans: [
1007
+ {
1008
+ resource: {
1009
+ attributes: [otlpStringAttribute("service.name", serviceName)]
1010
+ },
1011
+ scopeSpans: [
1012
+ {
1013
+ scope: {
1014
+ name: "pm-cli.telemetry",
1015
+ version: "1"
1016
+ },
1017
+ spans: [
1018
+ {
1019
+ traceId: activeCommand.otel_trace_id,
1020
+ spanId: activeCommand.otel_span_id,
1021
+ name: `pm.command.${sanitizeString(activeCommand.command)}`,
1022
+ kind: 1,
1023
+ startTimeUnixNano: isoToUnixNano(activeCommand.started_at),
1024
+ endTimeUnixNano: isoToUnixNano(finishedAtIso),
1025
+ attributes,
1026
+ status: {
1027
+ code: outcome.ok ? 1 : 2,
1028
+ message: outcome.ok ? "" : sanitizeString(typeof outcome.error === "string" ? outcome.error : "command_failed")
1029
+ }
1030
+ }
1031
+ ]
1032
+ }
1033
+ ]
1034
+ }
1035
+ ]
1036
+ };
1037
+ return { endpoint: activeCommand.otel_traces_endpoint, payload };
1038
+ }
1039
+ function summarizeResult(result, captureLevel = "redacted") {
1040
+ if (result === null || result === void 0) {
1041
+ return { type: "nullish" };
1042
+ }
1043
+ if (typeof result === "string") {
1044
+ return { type: "string", value: sanitizeString(result, captureLevel) };
1045
+ }
1046
+ if (typeof result === "number" || typeof result === "boolean") {
1047
+ return { type: typeof result, value: result };
1048
+ }
1049
+ if (Array.isArray(result)) {
1050
+ return {
1051
+ type: "array",
1052
+ length: result.length,
1053
+ sample: result.slice(0, 5).map((entry) => sanitizeValue(entry, void 0, captureLevel))
1054
+ };
1055
+ }
1056
+ if (typeof result === "object") {
1057
+ const record = result;
1058
+ const keys = Object.keys(record).sort((left, right) => left.localeCompare(right));
1059
+ const sanitized = {};
1060
+ let previewBytes = 0;
1061
+ for (const key of keys.slice(0, 25)) {
1062
+ const sanitizedValue = sanitizeValue(record[key], key, captureLevel);
1063
+ const entrySize = JSON.stringify(sanitizedValue).length;
1064
+ if (previewBytes + entrySize > TELEMETRY_RESULT_PREVIEW_MAX_BYTES) {
1065
+ sanitized[key] = "[preview_truncated]";
1066
+ break;
1067
+ }
1068
+ previewBytes += entrySize;
1069
+ sanitized[key] = sanitizedValue;
1070
+ }
1071
+ return {
1072
+ type: "object",
1073
+ key_count: keys.length,
1074
+ keys_preview: keys.slice(0, 50),
1075
+ preview: sanitized
1076
+ };
1077
+ }
1078
+ return { type: typeof result, value: String(result) };
1079
+ }
1080
+ function buildCommandStartPayload(params) {
1081
+ const { captureLevel, context, pmVersion, sourceContext, pmRootHash, cwdHash, installationId } = params;
1082
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
1083
+ const hashedArgs = hashCommandArgs(installationId, context.args);
1084
+ const commandInvocationDigest = hashWithInstallationId(installationId, `${context.command}\0${context.args.join("\0")}`);
1085
+ const commandOptionsDigest = hashTelemetryValue(installationId, context.options);
1086
+ const globalOptionsDigest = hashTelemetryValue(installationId, context.global);
1087
+ const authorContextFields = buildAuthorContextPayloadFields(captureLevel, installationId);
1088
+ if (captureLevel === "minimal") {
1089
+ return {
1090
+ capture_level: captureLevel,
1091
+ pm_version: pmVersion,
1092
+ source_context: sourceContext.source_context,
1093
+ source_context_source: sourceContext.source_context_source,
1094
+ command_taxonomy: commandTaxonomy,
1095
+ command_args_digest: hashedArgs.digest,
1096
+ command_invocation_digest: commandInvocationDigest,
1097
+ command_options_digest: commandOptionsDigest,
1098
+ global_options_digest: globalOptionsDigest,
1099
+ ...authorContextFields
1100
+ };
1101
+ }
1102
+ return {
1103
+ pm_version: pmVersion,
1104
+ source_context: sourceContext.source_context,
1105
+ source_context_source: sourceContext.source_context_source,
1106
+ command_taxonomy: commandTaxonomy,
1107
+ ...authorContextFields,
1108
+ command_args: sanitizeCommandArgs(context.args, captureLevel),
1109
+ command_args_hashes: hashedArgs.hashes,
1110
+ command_args_digest: hashedArgs.digest,
1111
+ command_invocation_digest: commandInvocationDigest,
1112
+ command_options: sanitizeValue(context.options, void 0, captureLevel),
1113
+ command_options_digest: commandOptionsDigest,
1114
+ global_options: sanitizeValue(context.global, void 0, captureLevel),
1115
+ global_options_digest: globalOptionsDigest,
1116
+ pm_root_hash: pmRootHash,
1117
+ cwd_hash: cwdHash,
1118
+ capture_level: captureLevel,
1119
+ runtime: {
1120
+ node: process.version,
1121
+ platform: process.platform,
1122
+ arch: process.arch,
1123
+ hostname_hash: hashWithInstallationId(installationId, os.hostname()),
1124
+ stdin_tty: process.stdin.isTTY === true,
1125
+ stdout_tty: process.stdout.isTTY === true
1126
+ }
1127
+ };
1128
+ }
1129
+ function buildCommandFinishPayload(params) {
1130
+ const { captureLevel, pmVersion, sourceContext, outcome, durationMs, startedAt, command, installationId, commandTaxonomy, exitCode, errorCode: errorCode2, errorCategory, commandResolution, resolutionStage } = params;
1131
+ const errorFingerprint = outcome.ok === false ? hashTelemetryErrorFingerprint(installationId, command, errorCode2, outcome.error) : void 0;
1132
+ const authorContextFields = buildAuthorContextPayloadFields(captureLevel, installationId);
1133
+ if (captureLevel === "minimal") {
1134
+ return {
1135
+ capture_level: captureLevel,
1136
+ pm_version: pmVersion,
1137
+ source_context: sourceContext.source_context,
1138
+ source_context_source: sourceContext.source_context_source,
1139
+ command_taxonomy: commandTaxonomy,
1140
+ command_resolution: commandResolution,
1141
+ resolution_stage: resolutionStage,
1142
+ ok: outcome.ok,
1143
+ exit_code: exitCode,
1144
+ error_code: errorCode2,
1145
+ error_category: errorCategory,
1146
+ error: outcome.error ? sanitizeString(outcome.error, "redacted") : void 0,
1147
+ error_fingerprint: errorFingerprint,
1148
+ duration_ms: durationMs,
1149
+ ...authorContextFields
1150
+ };
1151
+ }
1152
+ return {
1153
+ capture_level: captureLevel,
1154
+ pm_version: pmVersion,
1155
+ source_context: sourceContext.source_context,
1156
+ source_context_source: sourceContext.source_context_source,
1157
+ command_taxonomy: commandTaxonomy,
1158
+ command_resolution: commandResolution,
1159
+ resolution_stage: resolutionStage,
1160
+ ...authorContextFields,
1161
+ ok: outcome.ok,
1162
+ exit_code: exitCode,
1163
+ error_code: errorCode2,
1164
+ error_category: errorCategory,
1165
+ error: outcome.error ? sanitizeString(outcome.error, captureLevel) : void 0,
1166
+ error_fingerprint: errorFingerprint,
1167
+ duration_ms: durationMs,
1168
+ started_at: startedAt,
1169
+ result_summary: summarizeResult(outcome.result, captureLevel)
1170
+ };
1171
+ }
1172
+ function buildCommandErrorPayload(params) {
1173
+ const { captureLevel, pmVersion, sourceContext, command, commandTaxonomy, commandResolution, resolutionStage, args, options, pmRootHash, cwdHash, installationId, errorCode: errorCode2, errorMessage, errorCategory, exitCode } = params;
1174
+ const attemptedArgHashes = hashCommandArgs(installationId, args);
1175
+ const attemptedCommandDigest = hashWithInstallationId(installationId, command);
1176
+ const attemptedOptionsDigest = hashTelemetryValue(installationId, options);
1177
+ const errorFingerprint = hashTelemetryErrorFingerprint(installationId, command, errorCode2, errorMessage);
1178
+ if (captureLevel === "minimal") {
1179
+ return {
1180
+ capture_level: captureLevel,
1181
+ pm_version: pmVersion,
1182
+ source_context: sourceContext.source_context,
1183
+ source_context_source: sourceContext.source_context_source,
1184
+ command_taxonomy: commandTaxonomy,
1185
+ command_resolution: commandResolution,
1186
+ resolution_stage: resolutionStage,
1187
+ attempted_command_digest: attemptedCommandDigest,
1188
+ attempted_args_digest: attemptedArgHashes.digest,
1189
+ attempted_options_digest: attemptedOptionsDigest,
1190
+ error_code: errorCode2,
1191
+ error_category: errorCategory,
1192
+ exit_code: exitCode,
1193
+ error: sanitizeString(errorMessage, "redacted"),
1194
+ error_fingerprint: errorFingerprint
1195
+ };
1196
+ }
1197
+ return {
1198
+ capture_level: captureLevel,
1199
+ pm_version: pmVersion,
1200
+ source_context: sourceContext.source_context,
1201
+ source_context_source: sourceContext.source_context_source,
1202
+ command_taxonomy: commandTaxonomy,
1203
+ command_resolution: commandResolution,
1204
+ resolution_stage: resolutionStage,
1205
+ attempted_command: sanitizeString(command, captureLevel),
1206
+ attempted_command_digest: attemptedCommandDigest,
1207
+ attempted_args: sanitizeCommandArgs(args, captureLevel),
1208
+ attempted_args_hashes: attemptedArgHashes.hashes,
1209
+ attempted_args_digest: attemptedArgHashes.digest,
1210
+ attempted_options: sanitizeValue(options, void 0, captureLevel),
1211
+ attempted_options_digest: attemptedOptionsDigest,
1212
+ error_code: errorCode2,
1213
+ error_category: errorCategory,
1214
+ exit_code: exitCode,
1215
+ error: sanitizeString(errorMessage, captureLevel),
1216
+ error_fingerprint: errorFingerprint,
1217
+ pm_root_hash: pmRootHash,
1218
+ cwd_hash: cwdHash,
1219
+ runtime: {
1220
+ node: process.version,
1221
+ platform: process.platform,
1222
+ arch: process.arch,
1223
+ hostname_hash: hashWithInstallationId(installationId, os.hostname()),
1224
+ stdin_tty: process.stdin.isTTY === true,
1225
+ stdout_tty: process.stdout.isTTY === true
1226
+ }
1227
+ };
1228
+ }
1229
+ async function ensureInstallationId(globalPmRoot) {
1230
+ const settings = await readSettings(globalPmRoot);
1231
+ let changed = false;
1232
+ if (settings.telemetry.installation_id.trim().length === 0) {
1233
+ settings.telemetry.installation_id = crypto.randomUUID();
1234
+ changed = true;
1235
+ }
1236
+ if (changed) {
1237
+ await writeSettings(globalPmRoot, settings, "telemetry:install_id");
1238
+ }
1239
+ return {
1240
+ installationId: settings.telemetry.installation_id,
1241
+ endpoint: settings.telemetry.endpoint,
1242
+ retentionDays: Math.max(1, Math.trunc(settings.telemetry.retention_days))
1243
+ };
1244
+ }
1245
+ async function enqueueTelemetryEvent(globalPmRoot, event) {
1246
+ const queued = {
1247
+ client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,
1248
+ event,
1249
+ attempts: 0
1250
+ };
1251
+ let serialized = JSON.stringify(queued);
1252
+ if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {
1253
+ const trimmed = {
1254
+ ...event,
1255
+ payload: {
1256
+ ...event.payload,
1257
+ result_summary: {
1258
+ truncated: true,
1259
+ reason: "payload_size_exceeded",
1260
+ original_bytes: serialized.length
1261
+ }
1262
+ }
1263
+ };
1264
+ const trimmedQueued = {
1265
+ client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,
1266
+ event: trimmed,
1267
+ attempts: 0
1268
+ };
1269
+ serialized = JSON.stringify(trimmedQueued);
1270
+ }
1271
+ await withQueueMutation(async () => {
1272
+ await appendLineAtomic(queuePath(globalPmRoot), serialized);
1273
+ });
1274
+ }
1275
+ function parseQueueLines(raw) {
1276
+ const entries = [];
1277
+ for (const line of raw.split("\n")) {
1278
+ const trimmed = line.trim();
1279
+ if (trimmed.length === 0) {
1280
+ continue;
1281
+ }
1282
+ try {
1283
+ const parsed = JSON.parse(trimmed);
1284
+ 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))) {
1285
+ entries.push(parsed);
1286
+ }
1287
+ } catch {
1288
+ }
1289
+ }
1290
+ return entries;
1291
+ }
1292
+ function nextRetryIso(attempts) {
1293
+ const delay = Math.min(TELEMETRY_RETRY_BASE_DELAY_MS * 2 ** Math.max(attempts - 1, 0), TELEMETRY_MAX_RETRY_DELAY_MS);
1294
+ return new Date(Date.now() + delay).toISOString();
1295
+ }
1296
+ function isDueForRetryAt(nextAttemptAfter) {
1297
+ if (typeof nextAttemptAfter !== "string" || nextAttemptAfter.trim().length === 0) {
1298
+ return true;
1299
+ }
1300
+ const dueAtMs = Date.parse(nextAttemptAfter);
1301
+ if (Number.isNaN(dueAtMs)) {
1302
+ return true;
1303
+ }
1304
+ return dueAtMs <= Date.now();
1305
+ }
1306
+ function isDueForRetry(entry) {
1307
+ return isDueForRetryAt(entry.next_attempt_after);
1308
+ }
1309
+ function retentionCutoffMs(retentionDays) {
1310
+ const normalizedDays = Number.isFinite(retentionDays) ? Math.max(1, Math.trunc(retentionDays)) : 1;
1311
+ return Date.now() - normalizedDays * MILLISECONDS_PER_DAY;
1312
+ }
1313
+ function isExpiredQueueEntry(entry, cutoffMs) {
1314
+ const occurredAt = entry.event?.occurred_at;
1315
+ if (typeof occurredAt !== "string" || occurredAt.trim().length === 0) {
1316
+ return false;
1317
+ }
1318
+ const occurredAtMs = Date.parse(occurredAt);
1319
+ if (Number.isNaN(occurredAtMs)) {
1320
+ return false;
1321
+ }
1322
+ return occurredAtMs < cutoffMs;
1323
+ }
1324
+ function pruneExpiredQueueEntries(entries, retentionDays) {
1325
+ const cutoffMs = retentionCutoffMs(retentionDays);
1326
+ const retained = [];
1327
+ let prunedCount = 0;
1328
+ for (const entry of entries) {
1329
+ const serializedSize = JSON.stringify(entry).length;
1330
+ const oversized = serializedSize > TELEMETRY_MAX_EVENT_BYTES;
1331
+ if (oversized || isExpiredQueueEntry(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {
1332
+ prunedCount += 1;
1333
+ continue;
1334
+ }
1335
+ retained.push(entry);
1336
+ }
1337
+ return { entries: retained, prunedCount };
1338
+ }
1339
+ async function rewriteQueue(globalPmRoot, entries) {
1340
+ const serialized = entries.map((entry) => JSON.stringify(entry)).join("\n");
1341
+ const contents = serialized.length > 0 ? `${serialized}
1342
+ ` : "";
1343
+ for (let attempt = 0; ; attempt += 1) {
1344
+ try {
1345
+ await writeFileAtomic(queuePath(globalPmRoot), contents);
1346
+ return;
1347
+ } catch (error) {
1348
+ const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];
1349
+ if (retryDelay === void 0 || !isRetryableQueueRewriteError(error)) {
1350
+ throw error;
1351
+ }
1352
+ await sleep(retryDelay);
1353
+ }
1354
+ }
1355
+ }
1356
+ function isRetryableQueueRewriteError(error) {
1357
+ if (typeof error !== "object" || error === null || !("code" in error)) {
1358
+ return false;
1359
+ }
1360
+ const code = error.code;
1361
+ return code === "EACCES" || code === "EBUSY" || code === "EPERM";
1362
+ }
1363
+ function sleep(milliseconds) {
1364
+ return new Promise((resolve) => {
1365
+ setTimeout(resolve, milliseconds);
1366
+ });
1367
+ }
1368
+ async function enqueuePendingOtelSpan(globalPmRoot, request) {
1369
+ const pending = {
1370
+ id: crypto.randomUUID(),
1371
+ endpoint: request.endpoint,
1372
+ payload: request.payload,
1373
+ enqueued_at: nowIso(),
1374
+ attempts: 0
1375
+ };
1376
+ const serialized = JSON.stringify(pending);
1377
+ if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {
1378
+ return;
1379
+ }
1380
+ await withQueueMutation(async () => {
1381
+ await appendLineAtomic(otelSpansQueuePath(globalPmRoot), serialized);
1382
+ });
1383
+ }
1384
+ function backfillPendingOtelSpanId(entry) {
1385
+ const material = JSON.stringify([
1386
+ entry.endpoint,
1387
+ entry.enqueued_at,
1388
+ entry.payload
1389
+ ]);
1390
+ return crypto.createHash("sha256").update(material).digest("hex").slice(0, 32);
1391
+ }
1392
+ function parsePendingOtelSpanLines(raw) {
1393
+ const entries = [];
1394
+ for (const line of raw.split("\n")) {
1395
+ const trimmed = line.trim();
1396
+ if (trimmed.length === 0) {
1397
+ continue;
1398
+ }
1399
+ try {
1400
+ const parsed = JSON.parse(trimmed);
1401
+ if (parsed && typeof parsed === "object" && typeof parsed.endpoint === "string" && parsed.endpoint.trim().length > 0 && "payload" in parsed && typeof parsed.attempts === "number" && Number.isFinite(parsed.attempts)) {
1402
+ if (typeof parsed.id !== "string" || parsed.id.length === 0) {
1403
+ parsed.id = backfillPendingOtelSpanId(parsed);
1404
+ }
1405
+ entries.push(parsed);
1406
+ }
1407
+ } catch {
1408
+ }
1409
+ }
1410
+ return entries;
1411
+ }
1412
+ function isExpiredPendingOtelSpan(entry, cutoffMs) {
1413
+ if (typeof entry.enqueued_at !== "string" || entry.enqueued_at.trim().length === 0) {
1414
+ return false;
1415
+ }
1416
+ const enqueuedAtMs = Date.parse(entry.enqueued_at);
1417
+ if (Number.isNaN(enqueuedAtMs)) {
1418
+ return false;
1419
+ }
1420
+ return enqueuedAtMs < cutoffMs;
1421
+ }
1422
+ function prunePendingOtelSpans(entries, retentionDays) {
1423
+ const cutoffMs = retentionCutoffMs(retentionDays);
1424
+ const retained = [];
1425
+ let prunedCount = 0;
1426
+ for (const entry of entries) {
1427
+ const oversized = JSON.stringify(entry).length > TELEMETRY_MAX_EVENT_BYTES;
1428
+ if (oversized || isExpiredPendingOtelSpan(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {
1429
+ prunedCount += 1;
1430
+ continue;
1431
+ }
1432
+ retained.push(entry);
1433
+ }
1434
+ if (retained.length > TELEMETRY_OTEL_SPANS_MAX_PENDING) {
1435
+ const overflow = retained.length - TELEMETRY_OTEL_SPANS_MAX_PENDING;
1436
+ prunedCount += overflow;
1437
+ return { entries: retained.slice(overflow), prunedCount };
1438
+ }
1439
+ return { entries: retained, prunedCount };
1440
+ }
1441
+ async function rewritePendingOtelSpans(globalPmRoot, entries) {
1442
+ const serialized = entries.map((entry) => JSON.stringify(entry)).join("\n");
1443
+ const contents = serialized.length > 0 ? `${serialized}
1444
+ ` : "";
1445
+ for (let attempt = 0; ; attempt += 1) {
1446
+ try {
1447
+ await writeFileAtomic(otelSpansQueuePath(globalPmRoot), contents);
1448
+ return;
1449
+ } catch (error) {
1450
+ const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];
1451
+ if (retryDelay === void 0 || !isRetryableQueueRewriteError(error)) {
1452
+ throw error;
1453
+ }
1454
+ await sleep(retryDelay);
1455
+ }
1456
+ }
1457
+ }
1458
+ async function reconcilePendingOtelSpansAfterFlush(globalPmRoot, retentionDays, succeededIds, failedUpdates) {
1459
+ return withQueueMutation(async () => {
1460
+ const raw = await readFileIfExists(otelSpansQueuePath(globalPmRoot));
1461
+ const current = raw === null ? [] : parsePendingOtelSpanLines(raw);
1462
+ const reconciled = [];
1463
+ for (const entry of current) {
1464
+ if (succeededIds.has(entry.id)) {
1465
+ continue;
1466
+ }
1467
+ const failure = failedUpdates.get(entry.id);
1468
+ reconciled.push(failure ? {
1469
+ ...entry,
1470
+ attempts: failure.attempts,
1471
+ next_attempt_after: failure.next_attempt_after
1472
+ } : entry);
1473
+ }
1474
+ const { entries: retained } = prunePendingOtelSpans(reconciled, retentionDays);
1475
+ await rewritePendingOtelSpans(globalPmRoot, retained);
1476
+ return retained.length;
1477
+ });
1478
+ }
1479
+ async function flushPendingOtelSpans(globalPmRoot, retentionDays) {
1480
+ const raw = await readFileIfExists(otelSpansQueuePath(globalPmRoot));
1481
+ if (raw === null || raw.trim().length === 0) {
1482
+ await writeRuntimeState(globalPmRoot, { pending_otel_spans: 0 });
1483
+ return;
1484
+ }
1485
+ const entries = parsePendingOtelSpanLines(raw);
1486
+ const { entries: retained, prunedCount } = prunePendingOtelSpans(entries, retentionDays);
1487
+ const due = retained.filter((entry) => isDueForRetryAt(entry.next_attempt_after)).slice(0, TELEMETRY_OTEL_SPANS_FLUSH_BATCH_SIZE);
1488
+ if (due.length === 0) {
1489
+ const remaining2 = prunedCount > 0 ? await reconcilePendingOtelSpansAfterFlush(globalPmRoot, retentionDays, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Map()) : retained.length;
1490
+ await writeRuntimeState(globalPmRoot, { pending_otel_spans: remaining2 });
1491
+ return;
1492
+ }
1493
+ const attemptTime = nowIso();
1494
+ const succeededIds = /* @__PURE__ */ new Set();
1495
+ const failedUpdates = /* @__PURE__ */ new Map();
1496
+ let succeededCount = 0;
1497
+ let lastError;
1498
+ await Promise.all(due.map(async (span) => {
1499
+ try {
1500
+ const response = await fetch(span.endpoint, {
1501
+ method: "POST",
1502
+ headers: { "content-type": "application/json" },
1503
+ body: JSON.stringify(span.payload),
1504
+ signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
1505
+ });
1506
+ if (!response.ok) {
1507
+ throw new Error(`local_otel_export_http_${response.status}`);
1508
+ }
1509
+ succeededIds.add(span.id);
1510
+ succeededCount += 1;
1511
+ } catch (error) {
1512
+ lastError = error instanceof Error ? sanitizeString(error.message, "redacted") : "local_otel_export_failed";
1513
+ const nextAttempts = span.attempts + 1;
1514
+ failedUpdates.set(span.id, {
1515
+ attempts: nextAttempts,
1516
+ next_attempt_after: nextRetryIso(nextAttempts)
1517
+ });
1518
+ }
1519
+ }));
1520
+ const remaining = await reconcilePendingOtelSpansAfterFlush(globalPmRoot, retentionDays, succeededIds, failedUpdates);
1521
+ const statePatch = {
1522
+ pending_otel_spans: remaining,
1523
+ last_otel_attempt_at: attemptTime
1524
+ };
1525
+ if (succeededCount > 0) {
1526
+ statePatch.last_otel_success_at = attemptTime;
1527
+ }
1528
+ if (lastError !== void 0) {
1529
+ statePatch.last_otel_failure_at = attemptTime;
1530
+ statePatch.last_otel_failure_error = lastError;
1531
+ } else if (remaining === 0) {
1532
+ statePatch.last_otel_failure_at = void 0;
1533
+ statePatch.last_otel_failure_error = void 0;
1534
+ }
1535
+ await writeRuntimeState(globalPmRoot, statePatch);
1536
+ }
1537
+ async function flushTelemetryArtifacts(globalPmRoot, endpoint, retentionDays) {
1538
+ try {
1539
+ await flushQueue(globalPmRoot, endpoint, retentionDays);
1540
+ } catch {
1541
+ }
1542
+ try {
1543
+ await flushPendingOtelSpans(globalPmRoot, retentionDays);
1544
+ } catch {
1545
+ }
1546
+ }
1547
+ async function cleanupTelemetryQueueTempOrphans(globalPmRoot, maxAgeMs = TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS) {
1548
+ try {
1549
+ const dirPath = telemetryRuntimeDirectory(globalPmRoot);
1550
+ const entries = await readdir(dirPath, { withFileTypes: true });
1551
+ const cutoffMs = Date.now() - Math.max(0, maxAgeMs);
1552
+ await Promise.all(entries.filter((entry) => entry.isFile() && /^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(entry.name)).map(async (entry) => {
1553
+ const candidate = path.join(dirPath, entry.name);
1554
+ const candidateStats = await stat(candidate);
1555
+ if (candidateStats.mtimeMs < cutoffMs) {
1556
+ await rm(candidate, { force: true });
1557
+ }
1558
+ }));
1559
+ } catch {
1560
+ }
1561
+ }
1562
+ async function withQueueMutation(operation) {
1563
+ const run = _queueMutationPromise.catch(
1564
+ /* c8 ignore next */
1565
+ () => {
1566
+ }
1567
+ ).then(operation);
1568
+ _queueMutationPromise = run.catch(
1569
+ /* c8 ignore next */
1570
+ () => {
1571
+ }
1572
+ );
1573
+ return run;
1574
+ }
1575
+ async function readCurrentQueueEntries(globalPmRoot) {
1576
+ const raw = await readFileIfExists(queuePath(globalPmRoot));
1577
+ if (raw === null || raw.trim().length === 0) {
1578
+ return [];
1579
+ }
1580
+ return parseQueueLines(raw);
1581
+ }
1582
+ async function removeFlushedEntriesFromCurrentQueue(globalPmRoot, flushedIds, retentionDays) {
1583
+ return withQueueMutation(async () => {
1584
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1585
+ const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1586
+ const remaining = retainedEntries.filter((entry) => !flushedIds.has(entry.event.event_id));
1587
+ await rewriteQueue(globalPmRoot, remaining);
1588
+ return remaining;
1589
+ });
1590
+ }
1591
+ async function markFailedEntriesInCurrentQueue(globalPmRoot, failedIds, attemptTime, retentionDays) {
1592
+ return withQueueMutation(async () => {
1593
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot);
1594
+ const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);
1595
+ const retried = retainedEntries.map((entry) => {
1596
+ if (!failedIds.has(entry.event.event_id)) {
1597
+ return entry;
1598
+ }
1599
+ const attempts = entry.attempts + 1;
1600
+ return {
1601
+ ...entry,
1602
+ attempts,
1603
+ last_attempt_at: attemptTime,
1604
+ next_attempt_after: nextRetryIso(attempts)
1605
+ };
1606
+ });
1607
+ await rewriteQueue(globalPmRoot, retried);
1608
+ return retried;
1609
+ });
1610
+ }
1611
+ async function flushQueue(globalPmRoot, endpoint, retentionDays) {
1612
+ await cleanupTelemetryQueueTempOrphans(globalPmRoot);
1613
+ const normalizedEndpoint = endpoint.trim();
1614
+ if (normalizedEndpoint.length === 0) {
1615
+ return;
1616
+ }
1617
+ const raw = await readFileIfExists(queuePath(globalPmRoot));
1618
+ if (raw === null || raw.trim().length === 0) {
1619
+ await writeRuntimeState(globalPmRoot, {
1620
+ endpoint: normalizedEndpoint,
1621
+ queue_entries: 0
1622
+ });
1623
+ return;
1624
+ }
1625
+ const queueEntries = parseQueueLines(raw);
1626
+ if (queueEntries.length === 0) {
1627
+ await writeRuntimeState(globalPmRoot, {
1628
+ endpoint: normalizedEndpoint,
1629
+ queue_entries: 0
1630
+ });
1631
+ return;
1632
+ }
1633
+ const { entries: retainedEntries, prunedCount } = pruneExpiredQueueEntries(queueEntries, retentionDays);
1634
+ if (retainedEntries.length === 0) {
1635
+ await rewriteQueue(globalPmRoot, []);
1636
+ await writeRuntimeState(globalPmRoot, {
1637
+ endpoint: normalizedEndpoint,
1638
+ queue_entries: 0
1639
+ });
1640
+ return;
1641
+ }
1642
+ const dueEntries = retainedEntries.filter((entry) => isDueForRetry(entry)).slice(0, TELEMETRY_FLUSH_BATCH_SIZE);
1643
+ if (dueEntries.length === 0) {
1644
+ if (prunedCount > 0) {
1645
+ await rewriteQueue(globalPmRoot, retainedEntries);
1646
+ }
1647
+ await writeRuntimeState(globalPmRoot, {
1648
+ endpoint: normalizedEndpoint,
1649
+ queue_entries: retainedEntries.length
1650
+ });
1651
+ return;
1652
+ }
1653
+ const dueIds = new Set(dueEntries.map((entry) => entry.event.event_id));
1654
+ const attemptTime = nowIso();
1655
+ const requestHeaders = {
1656
+ "content-type": "application/json"
1657
+ };
1658
+ const ingestKey = process.env.PM_TELEMETRY_INGEST_KEY?.trim();
1659
+ if (ingestKey) {
1660
+ requestHeaders["x-pm-telemetry-key"] = ingestKey;
1661
+ }
1662
+ try {
1663
+ const response = await fetch(normalizedEndpoint, {
1664
+ method: "POST",
1665
+ headers: requestHeaders,
1666
+ body: JSON.stringify({
1667
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1668
+ events: dueEntries.map((entry) => entry.event)
1669
+ }),
1670
+ signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS)
1671
+ });
1672
+ if (!response.ok) {
1673
+ throw new Error(`telemetry_flush_http_${response.status}`);
1674
+ }
1675
+ } catch (error) {
1676
+ const retried = await markFailedEntriesInCurrentQueue(globalPmRoot, dueIds, attemptTime, retentionDays);
1677
+ const errorMessage = (() => {
1678
+ if (error instanceof Error) {
1679
+ return sanitizeString(error.message, "redacted");
1680
+ }
1681
+ return "telemetry_flush_failed";
1682
+ })();
1683
+ await writeRuntimeState(globalPmRoot, {
1684
+ endpoint: normalizedEndpoint,
1685
+ queue_entries: retried.length,
1686
+ last_attempted_flush_at: attemptTime,
1687
+ last_failed_flush_at: attemptTime,
1688
+ last_failed_flush_error: errorMessage
1689
+ });
1690
+ return;
1691
+ }
1692
+ try {
1693
+ const remaining = await removeFlushedEntriesFromCurrentQueue(globalPmRoot, dueIds, retentionDays);
1694
+ await writeRuntimeState(globalPmRoot, {
1695
+ endpoint: normalizedEndpoint,
1696
+ queue_entries: remaining.length,
1697
+ last_attempted_flush_at: attemptTime,
1698
+ last_successful_flush_at: attemptTime,
1699
+ last_failed_flush_at: void 0,
1700
+ last_failed_flush_error: void 0
1701
+ });
1702
+ } catch (error) {
1703
+ const errorMessage = (() => {
1704
+ if (error instanceof Error) {
1705
+ return sanitizeString(error.message, "redacted");
1706
+ }
1707
+ return "telemetry_flush_failed";
1708
+ })();
1709
+ const currentEntries = await readCurrentQueueEntries(globalPmRoot).catch(() => retainedEntries);
1710
+ await writeRuntimeState(globalPmRoot, {
1711
+ endpoint: normalizedEndpoint,
1712
+ queue_entries: currentEntries.length,
1713
+ last_attempted_flush_at: attemptTime,
1714
+ last_failed_flush_at: attemptTime,
1715
+ last_failed_flush_error: errorMessage
1716
+ });
1717
+ }
1718
+ }
1719
+ async function acquireTelemetryFlushLock(globalPmRoot) {
1720
+ const lockPath = flushLockPath(globalPmRoot);
1721
+ await mkdir(path.dirname(lockPath), { recursive: true });
1722
+ try {
1723
+ await mkdir(lockPath);
1724
+ return true;
1725
+ } catch (error) {
1726
+ if (typeof error !== "object" || error === null || !("code" in error) || error.code !== "EEXIST") {
1727
+ throw error;
1728
+ }
1729
+ }
1730
+ try {
1731
+ const lockStats = await stat(lockPath);
1732
+ if (Date.now() - lockStats.mtimeMs < TELEMETRY_FLUSH_LOCK_STALE_MS) {
1733
+ return false;
1734
+ }
1735
+ await rm(lockPath, { recursive: true, force: true });
1736
+ await mkdir(lockPath);
1737
+ return true;
1738
+ } catch {
1739
+ return false;
1740
+ }
1741
+ }
1742
+ function isFreshDirectoryLock(lockPath, staleMs) {
1743
+ try {
1744
+ return Date.now() - statSync(lockPath).mtimeMs < staleMs;
1745
+ } catch {
1746
+ return false;
1747
+ }
1748
+ }
1749
+ function removeDirectoryLockBestEffort(lockPath) {
1750
+ try {
1751
+ rmSync(lockPath, { recursive: true, force: true });
1752
+ } catch {
1753
+ }
1754
+ }
1755
+ function errorCode(error) {
1756
+ if (typeof error !== "object" || error === null || !("code" in error)) {
1757
+ return void 0;
1758
+ }
1759
+ const code = error.code;
1760
+ return typeof code === "string" ? code : void 0;
1761
+ }
1762
+ function createDirectoryLock(lockPath) {
1763
+ try {
1764
+ mkdirSync(lockPath);
1765
+ return true;
1766
+ } catch (error) {
1767
+ const code = errorCode(error);
1768
+ if (code === "EEXIST") {
1769
+ return false;
1770
+ }
1771
+ if (code !== "ENOENT") {
1772
+ return false;
1773
+ }
1774
+ }
1775
+ try {
1776
+ mkdirSync(path.dirname(lockPath), { recursive: true });
1777
+ mkdirSync(lockPath);
1778
+ return true;
1779
+ } catch {
1780
+ return false;
1781
+ }
1782
+ }
1783
+ function acquireTelemetryFlushSpawnGate(globalPmRoot) {
1784
+ if (isFreshDirectoryLock(flushLockPath(globalPmRoot), TELEMETRY_FLUSH_LOCK_STALE_MS)) {
1785
+ return false;
1786
+ }
1787
+ const lockPath = flushSpawnLockPath(globalPmRoot);
1788
+ try {
1789
+ if (Date.now() - statSync(lockPath).mtimeMs < TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS) {
1790
+ return false;
1791
+ }
1792
+ removeDirectoryLockBestEffort(lockPath);
1793
+ } catch (error) {
1794
+ if (errorCode(error) !== "ENOENT") {
1795
+ return false;
1796
+ }
1797
+ }
1798
+ return createDirectoryLock(lockPath);
1799
+ }
1800
+ function releaseTelemetryFlushSpawnGate(globalPmRoot) {
1801
+ removeDirectoryLockBestEffort(flushSpawnLockPath(globalPmRoot));
1802
+ }
1803
+ async function flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays) {
1804
+ const acquired = await acquireTelemetryFlushLock(globalPmRoot);
1805
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1806
+ if (!acquired) {
1807
+ return;
1808
+ }
1809
+ try {
1810
+ await flushTelemetryArtifacts(globalPmRoot, endpoint, retentionDays);
1811
+ } finally {
1812
+ try {
1813
+ await rm(flushLockPath(globalPmRoot), { recursive: true, force: true });
1814
+ } catch {
1815
+ }
1816
+ }
1817
+ }
1818
+ function scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays) {
1819
+ if (shouldFlushInline()) {
1820
+ const previousFlush = _lastFlushPromise;
1821
+ const nextFlush = flushTelemetryArtifacts(globalPmRoot, endpoint, retentionDays);
1822
+ _lastFlushPromise = Promise.allSettled([previousFlush, nextFlush]).then(() => {
1823
+ });
1824
+ return;
1825
+ }
1826
+ try {
1827
+ const acquiredSpawnGate = acquireTelemetryFlushSpawnGate(globalPmRoot);
1828
+ if (!acquiredSpawnGate) {
1829
+ return;
1830
+ }
1831
+ const child = spawn(process.execPath, [telemetryFlushRunnerPath()], {
1832
+ detached: true,
1833
+ stdio: "ignore",
1834
+ // Detached workers inherit cwd by default. On Windows that can keep a
1835
+ // disposable project directory locked after the foreground command exits.
1836
+ cwd: os.tmpdir(),
1837
+ env: {
1838
+ ...process.env,
1839
+ PM_GLOBAL_PATH: globalPmRoot,
1840
+ [PM_TELEMETRY_FLUSH_CHILD_ENV]: "1"
1841
+ }
1842
+ });
1843
+ child.on("error", () => {
1844
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1845
+ });
1846
+ child.unref();
1847
+ } catch {
1848
+ releaseTelemetryFlushSpawnGate(globalPmRoot);
1849
+ }
1850
+ }
1851
+ async function flushTelemetryQueueNow(globalPmRoot = resolveGlobalPmRoot(process.cwd())) {
1852
+ if (telemetryDisabledByEnvironment()) {
1853
+ return;
1854
+ }
1855
+ try {
1856
+ const settings = await readSettings(globalPmRoot);
1857
+ if (!settings.telemetry.enabled) {
1858
+ return;
1859
+ }
1860
+ const { endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1861
+ await flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays);
1862
+ } catch {
1863
+ }
1864
+ }
1865
+ async function startTelemetryCommand(context) {
1866
+ if (telemetryDisabledByEnvironment()) {
1867
+ return null;
1868
+ }
1869
+ if (context.command === "telemetry" && context.args.some((token) => token.trim().toLowerCase() === "clear")) {
1870
+ return null;
1871
+ }
1872
+ try {
1873
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1874
+ const settings = await readSettings(globalPmRoot);
1875
+ if (!settings.telemetry.enabled) {
1876
+ return null;
1877
+ }
1878
+ const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
1879
+ const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
1880
+ const pmVersion = normalizePmVersion(context.pm_version);
1881
+ const sourceContext = resolveTelemetrySourceContext(context.global);
1882
+ const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
1883
+ const cwdHash = hashWithInstallationId(installationId, process.cwd());
1884
+ const otelTracesEndpoint = resolveOtelTracesEndpoint();
1885
+ const occurredAt = nowIso();
1886
+ const event = {
1887
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1888
+ event_id: crypto.randomUUID(),
1889
+ event_type: "command_start",
1890
+ occurred_at: occurredAt,
1891
+ installation_id: installationId,
1892
+ session_id: PROCESS_SESSION_ID,
1893
+ command: context.command,
1894
+ payload: buildCommandStartPayload({
1895
+ captureLevel,
1896
+ context,
1897
+ pmVersion,
1898
+ sourceContext,
1899
+ pmRootHash,
1900
+ cwdHash,
1901
+ installationId
1902
+ })
1903
+ };
1904
+ await enqueueTelemetryEvent(globalPmRoot, event);
1905
+ scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
1906
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);
1907
+ return {
1908
+ started_at: occurredAt,
1909
+ started_at_ms: Date.now(),
1910
+ command: context.command,
1911
+ command_taxonomy: commandTaxonomy,
1912
+ pm_version: pmVersion,
1913
+ source_context: sourceContext.source_context,
1914
+ source_context_source: sourceContext.source_context_source,
1915
+ installation_id: installationId,
1916
+ pm_root_hash: pmRootHash,
1917
+ cwd_hash: cwdHash,
1918
+ endpoint,
1919
+ retention_days: retentionDays,
1920
+ global_pm_root: globalPmRoot,
1921
+ capture_level: captureLevel,
1922
+ otel_traces_endpoint: otelTracesEndpoint ?? void 0,
1923
+ otel_trace_id: otelTracesEndpoint ? crypto.randomBytes(16).toString("hex") : void 0,
1924
+ otel_span_id: otelTracesEndpoint ? crypto.randomBytes(8).toString("hex") : void 0
1925
+ };
1926
+ } catch {
1927
+ return null;
1928
+ }
1929
+ }
1930
+ async function finishTelemetryCommand(activeCommand, outcome) {
1931
+ if (!activeCommand) {
1932
+ return;
1933
+ }
1934
+ try {
1935
+ const finishedAt = nowIso();
1936
+ const durationMs = Math.max(0, Date.now() - activeCommand.started_at_ms);
1937
+ const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
1938
+ ok: outcome.ok,
1939
+ errorCode: outcome.error_code,
1940
+ errorMessage: outcome.error,
1941
+ exitCode: outcome.exit_code
1942
+ }));
1943
+ const normalizedErrorCategory = normalizeTelemetryErrorCategory({
1944
+ ok: outcome.ok,
1945
+ errorCode: normalizedErrorCode,
1946
+ errorCategory: outcome.error_category
1947
+ });
1948
+ const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);
1949
+ const commandResolution = outcome.command_resolution ?? deriveTelemetryCommandResolution({
1950
+ ok: outcome.ok,
1951
+ errorCode: normalizedErrorCode,
1952
+ errorCategory: normalizedErrorCategory
1953
+ });
1954
+ const resolutionStage = outcome.resolution_stage ?? "execute";
1955
+ const event = {
1956
+ schema_version: TELEMETRY_SCHEMA_VERSION,
1957
+ event_id: crypto.randomUUID(),
1958
+ event_type: "command_finish",
1959
+ occurred_at: finishedAt,
1960
+ installation_id: activeCommand.installation_id,
1961
+ session_id: PROCESS_SESSION_ID,
1962
+ command: activeCommand.command,
1963
+ payload: buildCommandFinishPayload({
1964
+ captureLevel: activeCommand.capture_level,
1965
+ pmVersion: activeCommand.pm_version,
1966
+ sourceContext: {
1967
+ source_context: activeCommand.source_context,
1968
+ source_context_source: activeCommand.source_context_source
1969
+ },
1970
+ outcome,
1971
+ durationMs,
1972
+ startedAt: activeCommand.started_at,
1973
+ command: activeCommand.command,
1974
+ installationId: activeCommand.installation_id,
1975
+ commandTaxonomy: activeCommand.command_taxonomy,
1976
+ exitCode: normalizedExitCode,
1977
+ errorCode: normalizedErrorCode,
1978
+ errorCategory: normalizedErrorCategory,
1979
+ commandResolution,
1980
+ resolutionStage
1981
+ })
1982
+ };
1983
+ await enqueueTelemetryEvent(activeCommand.global_pm_root, event);
1984
+ const otelRequest = buildOtelSpanRequest(activeCommand, {
1985
+ ...outcome,
1986
+ exit_code: normalizedExitCode,
1987
+ error_code: normalizedErrorCode,
1988
+ error_category: normalizedErrorCategory
1989
+ }, finishedAt, durationMs);
1990
+ if (otelRequest) {
1991
+ await enqueuePendingOtelSpan(activeCommand.global_pm_root, otelRequest);
1992
+ }
1993
+ scheduleTelemetryFlush(activeCommand.global_pm_root, activeCommand.endpoint, activeCommand.retention_days);
1994
+ } catch {
1995
+ }
1996
+ }
1997
+ async function emitTelemetryErrorEvent(context) {
1998
+ if (telemetryDisabledByEnvironment()) {
1999
+ return;
2000
+ }
2001
+ try {
2002
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
2003
+ const settings = await readSettings(globalPmRoot);
2004
+ if (!settings.telemetry.enabled) {
2005
+ return;
2006
+ }
2007
+ const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);
2008
+ const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);
2009
+ const pmVersion = normalizePmVersion(context.pm_version);
2010
+ const sourceContext = resolveTelemetrySourceContext(context.global);
2011
+ const pmRootHash = hashWithInstallationId(installationId, context.pm_root);
2012
+ const cwdHash = hashWithInstallationId(installationId, process.cwd());
2013
+ const occurredAt = nowIso();
2014
+ const normalizedErrorCode = normalizeTelemetryErrorCode(inferTelemetryErrorCode({
2015
+ ok: false,
2016
+ errorCode: context.error_code,
2017
+ errorMessage: context.error_message,
2018
+ exitCode: context.exit_code
2019
+ }));
2020
+ const normalizedErrorCategory = context.error_category ?? resolveTelemetryErrorCategory(normalizedErrorCode);
2021
+ const normalizedExitCode = normalizeTelemetryExitCode(context.exit_code, false);
2022
+ const normalizedCommand = context.command.trim().length > 0 ? context.command : "<unknown>";
2023
+ const commandTaxonomy = deriveTelemetryCommandTaxonomy(normalizedCommand);
2024
+ const commandResolution = context.command_resolution ?? deriveTelemetryCommandResolution({
2025
+ ok: false,
2026
+ errorCode: normalizedErrorCode,
2027
+ errorCategory: normalizedErrorCategory
2028
+ });
2029
+ const resolutionStage = context.resolution_stage ?? "unknown";
2030
+ const event = {
2031
+ schema_version: TELEMETRY_SCHEMA_VERSION,
2032
+ event_id: crypto.randomUUID(),
2033
+ event_type: "command_error",
2034
+ occurred_at: occurredAt,
2035
+ installation_id: installationId,
2036
+ session_id: PROCESS_SESSION_ID,
2037
+ command: sanitizeString(normalizedCommand, "redacted"),
2038
+ payload: buildCommandErrorPayload({
2039
+ captureLevel,
2040
+ pmVersion,
2041
+ sourceContext,
2042
+ command: normalizedCommand,
2043
+ commandTaxonomy,
2044
+ commandResolution,
2045
+ resolutionStage,
2046
+ args: context.args,
2047
+ options: context.options,
2048
+ pmRootHash,
2049
+ cwdHash,
2050
+ installationId,
2051
+ errorCode: normalizedErrorCode,
2052
+ errorCategory: normalizedErrorCategory,
2053
+ exitCode: normalizedExitCode,
2054
+ errorMessage: context.error_message
2055
+ })
2056
+ };
2057
+ await enqueueTelemetryEvent(globalPmRoot, event);
2058
+ scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);
2059
+ } catch {
2060
+ }
2061
+ }
247
2062
 
248
- // dist/sdk/start-task-status.js
2063
+ // dist/sdk/ownership-source.js
249
2064
  !(function() {
250
2065
  try {
251
2066
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
252
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3da16ce3-1da3-5e4a-ac27-0a0a55e6e84a");
2067
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "cd6c9ede-4766-5914-9b88-d337a872e0fc");
253
2068
  } catch (e2) {
254
2069
  }
255
2070
  })();
256
- function resolveStartTaskInProgressStatus(statusRegistry) {
257
- return normalizeStatusInputWithRegistry("in_progress", statusRegistry) ?? statusRegistry.open_status;
2071
+ async function describeItemOwnershipConflict(pmRoot, itemId, assignee) {
2072
+ const history = await readHistoryEntries(getHistoryPath(pmRoot, itemId), itemId).catch(() => []);
2073
+ const latestOwnershipOperation = [...history].reverse().find((entry) => entry.patch.some((operation) => operation.path === "/metadata/assignee"))?.op;
2074
+ return latestOwnershipOperation === "claim" ? `claimed by ${assignee}` : `assigned to ${assignee}`;
258
2075
  }
259
2076
 
260
2077
  // dist/cli/commands/claim.js
261
2078
  !(function() {
262
2079
  try {
263
2080
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
264
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "b0765d0a-904e-5230-a9c3-a4859d07c7ab");
2081
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "07b1663e-40e3-52cf-99f6-458a651ab229");
265
2082
  } catch (e2) {
266
2083
  }
267
2084
  })();
@@ -289,7 +2106,7 @@ async function runClaim(id, force, global2, options = {}) {
289
2106
  message: options.message,
290
2107
  force,
291
2108
  skipNoop: true,
292
- mutate(document) {
2109
+ async mutate(document) {
293
2110
  const currentAssignee = document.metadata.assignee;
294
2111
  const currentAssigneeText = typeof currentAssignee === "string" ? currentAssignee : "";
295
2112
  previousAssignee = currentAssigneeText.trim().length > 0 ? currentAssigneeText : null;
@@ -303,7 +2120,8 @@ async function runClaim(id, force, global2, options = {}) {
303
2120
  return { changedFields: [] };
304
2121
  }
305
2122
  if (heldByOther && !force) {
306
- throw new PmCliError(`Item ${document.metadata.id} is already claimed by ${previousAssignee}. Use --force to take over, or --if-available to skip without failing.`, EXIT_CODE.CONFLICT, {
2123
+ const ownershipPhrase = await describeItemOwnershipConflict(pmRoot, document.metadata.id, currentAssigneeText);
2124
+ throw new PmCliError(`Item ${document.metadata.id} is already ${ownershipPhrase}. Use --force to take over, or --if-available to skip without failing.`, EXIT_CODE.CONFLICT, {
307
2125
  code: "already_claimed_by",
308
2126
  why: "Claim is an atomic test-and-set so parallel agents never proceed believing they own the same item.",
309
2127
  nextSteps: [
@@ -1221,22 +3039,22 @@ function packageOwnedActionForCommand(command) {
1221
3039
  }
1222
3040
  function resolveActionCommandPath(action) {
1223
3041
  if (PM_CORE_COMMAND_NAMES.includes(action)) {
1224
- return normalizeCommandPath(action);
3042
+ return normalizeCommandPath2(action);
1225
3043
  }
1226
3044
  if (action.startsWith("extension-")) {
1227
- return normalizeCommandPath(`extension ${action.slice("extension-".length)}`);
3045
+ return normalizeCommandPath2(`extension ${action.slice("extension-".length)}`);
1228
3046
  }
1229
3047
  if (action.startsWith("package-")) {
1230
- return normalizeCommandPath(`package ${action.slice("package-".length)}`);
3048
+ return normalizeCommandPath2(`package ${action.slice("package-".length)}`);
1231
3049
  }
1232
3050
  if (action.startsWith("test-runs-")) {
1233
- return normalizeCommandPath(`test-runs ${action.slice("test-runs-".length)}`);
3051
+ return normalizeCommandPath2(`test-runs ${action.slice("test-runs-".length)}`);
1234
3052
  }
1235
3053
  if (action.startsWith("templates-")) {
1236
- return normalizeCommandPath(`templates ${action.slice("templates-".length)}`);
3054
+ return normalizeCommandPath2(`templates ${action.slice("templates-".length)}`);
1237
3055
  }
1238
3056
  if (PACKAGE_OWNED_ACTIONS.has(action)) {
1239
- return PACKAGE_OWNED_ACTION_COMMAND_PATHS.get(action) ?? normalizeCommandPath(action);
3057
+ return PACKAGE_OWNED_ACTION_COMMAND_PATHS.get(action) ?? normalizeCommandPath2(action);
1240
3058
  }
1241
3059
  return null;
1242
3060
  }
@@ -1252,7 +3070,7 @@ function actionDescriptorMatchesSelectedCommand(descriptor, selectedCommand) {
1252
3070
  });
1253
3071
  }
1254
3072
  function splitCommandPathAliases(commandPath) {
1255
- return commandPath.split("|").map((entry) => normalizeCommandPath(entry)).filter((entry) => entry.length > 0);
3073
+ return commandPath.split("|").map((entry) => normalizeCommandPath2(entry)).filter((entry) => entry.length > 0);
1256
3074
  }
1257
3075
  function resolveScopedCommandsFromActionDescriptors(descriptors, commandCatalog) {
1258
3076
  const commandSet = new Set(commandCatalog);
@@ -1332,7 +3150,7 @@ function filterSchemaByActions(schema, actions) {
1332
3150
  oneOf: filtered
1333
3151
  };
1334
3152
  }
1335
- function normalizeCommandPath(value) {
3153
+ function normalizeCommandPath2(value) {
1336
3154
  return value.trim().toLowerCase().split(/\s+/).filter((entry) => entry.length > 0).join(" ");
1337
3155
  }
1338
3156
  function normalizeActionNameFromCommand(commandPath) {
@@ -1417,7 +3235,7 @@ function toExtensionFlagContract(definition) {
1417
3235
  function collectExtensionFlagContractsByCommand(registrations) {
1418
3236
  const grouped = /* @__PURE__ */ new Map();
1419
3237
  for (const registration of registrations) {
1420
- const commandPath = normalizeCommandPath(registration.target_command);
3238
+ const commandPath = normalizeCommandPath2(registration.target_command);
1421
3239
  if (commandPath.length === 0) {
1422
3240
  continue;
1423
3241
  }
@@ -1468,7 +3286,7 @@ function collectExtensionCommandContracts(runtimeProbe) {
1468
3286
  const flagsByCommand = collectExtensionFlagContractsByCommand(runtimeProbe.flagRegistrations);
1469
3287
  const definitionsByCommand = /* @__PURE__ */ new Map();
1470
3288
  for (const definition of runtimeProbe.commandDefinitions) {
1471
- const command = normalizeCommandPath(definition.command);
3289
+ const command = normalizeCommandPath2(definition.command);
1472
3290
  if (command.length === 0) {
1473
3291
  continue;
1474
3292
  }
@@ -1502,7 +3320,7 @@ function collectExtensionCommandContracts(runtimeProbe) {
1502
3320
  }
1503
3321
  const extensionCommands = /* @__PURE__ */ new Set();
1504
3322
  for (const command of runtimeProbe.handlers) {
1505
- extensionCommands.add(normalizeCommandPath(command));
3323
+ extensionCommands.add(normalizeCommandPath2(command));
1506
3324
  }
1507
3325
  for (const command of definitionsByCommand.keys()) {
1508
3326
  extensionCommands.add(command);
@@ -1689,7 +3507,7 @@ async function resolveRuntimeExtensionActionProbe(global2) {
1689
3507
  ...loadResult,
1690
3508
  loaded: loadResult.loaded
1691
3509
  });
1692
- const handlers = new Set(activationResult.commands.handlers.map((entry) => normalizeCommandPath(entry.command)));
3510
+ const handlers = new Set(activationResult.commands.handlers.map((entry) => normalizeCommandPath2(entry.command)));
1693
3511
  return {
1694
3512
  handlers,
1695
3513
  disabledReason: null,
@@ -1749,7 +3567,7 @@ function collectActionContractDescriptors(extensionContracts, options = {}) {
1749
3567
  action: contract.action,
1750
3568
  provider: "extension",
1751
3569
  requires_extension: true,
1752
- command_path: normalizeCommandPath(contract.command)
3570
+ command_path: normalizeCommandPath2(contract.command)
1753
3571
  });
1754
3572
  }
1755
3573
  return [...descriptors.values()].sort((left, right) => (left.action ?? "").localeCompare(right.action ?? ""));
@@ -2106,7 +3924,7 @@ function buildContractsCommandCatalog(actionDescriptors, mergedExtensionContract
2106
3924
  ...actionDescriptors.flatMap((entry) => entry.command_path ? splitCommandPathAliases(entry.command_path) : []),
2107
3925
  ...mergedExtensionContracts.flatMap((entry) => entry.command.split("|"))
2108
3926
  ])
2109
- ].map((entry) => normalizeCommandPath(entry)).filter((entry) => entry.length > 0).sort((left, right) => left.localeCompare(right));
3927
+ ].map((entry) => normalizeCommandPath2(entry)).filter((entry) => entry.length > 0).sort((left, right) => left.localeCompare(right));
2110
3928
  }
2111
3929
  function buildCommandNamespaceError(command, namespaceChildren) {
2112
3930
  const displayedNamespaceChildren = namespaceChildren.slice(0, COMMAND_NAMESPACE_DISPLAY_LIMIT);
@@ -2416,13 +4234,82 @@ async function runContracts(options, global2) {
2416
4234
  return result;
2417
4235
  }
2418
4236
 
4237
+ // dist/cli/commands/scheduling-shortcuts.js
4238
+ !(function() {
4239
+ try {
4240
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
4241
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "861b3772-eeff-5118-ad1a-7d373b8903f1");
4242
+ } catch (e2) {
4243
+ }
4244
+ })();
4245
+ var DEFAULT_DURATION = "1h";
4246
+ var DEFAULT_START = "now";
4247
+ var DEFAULT_REMINDER_AT = "+1d";
4248
+ function quoteCsvValue(value) {
4249
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
4250
+ }
4251
+ function appendPair(pairs, key, value) {
4252
+ if (value !== void 0) {
4253
+ pairs.push(`${key}=${quoteCsvValue(value)}`);
4254
+ }
4255
+ }
4256
+ function buildCommonOptions(type, title, options) {
4257
+ return {
4258
+ type,
4259
+ title,
4260
+ schedulePreset: "lightweight",
4261
+ parent: options.parent,
4262
+ allowMissingParent: options.allowMissingParent,
4263
+ tags: options.tags,
4264
+ priority: options.priority,
4265
+ body: options.body,
4266
+ description: options.description,
4267
+ author: options.author,
4268
+ message: options.message
4269
+ };
4270
+ }
4271
+ function buildEventEntry(options) {
4272
+ const pairs = [];
4273
+ appendPair(pairs, "start", options.start ?? DEFAULT_START);
4274
+ if (options.end !== void 0) {
4275
+ appendPair(pairs, "end", options.end);
4276
+ } else {
4277
+ appendPair(pairs, "duration", options.duration ?? DEFAULT_DURATION);
4278
+ }
4279
+ appendPair(pairs, "location", options.location);
4280
+ appendPair(pairs, "timezone", options.timezone);
4281
+ if (options.allDay === true) {
4282
+ appendPair(pairs, "all_day", "true");
4283
+ }
4284
+ return pairs.join(",");
4285
+ }
4286
+ async function createScheduled(type, title, options, global2) {
4287
+ const createOptions = buildCommonOptions(type, title, options);
4288
+ createOptions.event = [buildEventEntry(options)];
4289
+ return runCreate(createOptions, global2);
4290
+ }
4291
+ function runMeet(title, options, global2) {
4292
+ return createScheduled("Meeting", title, options, global2);
4293
+ }
4294
+ function runEvent(title, options, global2) {
4295
+ return createScheduled("Event", title, options, global2);
4296
+ }
4297
+ function runRemind(title, options, global2) {
4298
+ const createOptions = buildCommonOptions("Reminder", title, options);
4299
+ const pairs = [];
4300
+ appendPair(pairs, "at", options.at ?? DEFAULT_REMINDER_AT);
4301
+ appendPair(pairs, "text", options.text ?? title);
4302
+ createOptions.reminder = [pairs.join(",")];
4303
+ return runCreate(createOptions, global2);
4304
+ }
4305
+
2419
4306
  // dist/sdk/governance/gc.js
2420
4307
  import fs3 from "node:fs/promises";
2421
- import path3 from "node:path";
4308
+ import path4 from "node:path";
2422
4309
 
2423
4310
  // dist/core/checkpoint/checkpoint-gc.js
2424
4311
  import fs from "node:fs/promises";
2425
- import path from "node:path";
4312
+ import path2 from "node:path";
2426
4313
  !(function() {
2427
4314
  try {
2428
4315
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
@@ -2430,7 +4317,7 @@ import path from "node:path";
2430
4317
  } catch (e2) {
2431
4318
  }
2432
4319
  })();
2433
- var MILLISECONDS_PER_DAY = 864e5;
4320
+ var MILLISECONDS_PER_DAY2 = 864e5;
2434
4321
  function isErrno(error, code) {
2435
4322
  return typeof error === "object" && error !== null && "code" in error && error.code === code;
2436
4323
  }
@@ -2460,7 +4347,7 @@ async function collectCheckpointFiles(checkpointsDir, warnings) {
2460
4347
  const files = [];
2461
4348
  for (const entry of dirEntries) {
2462
4349
  if (entry.isDirectory()) {
2463
- const subdir = path.join(checkpointsDir, entry.name);
4350
+ const subdir = path2.join(checkpointsDir, entry.name);
2464
4351
  let nested;
2465
4352
  try {
2466
4353
  nested = await fs.readdir(subdir);
@@ -2484,8 +4371,8 @@ async function collectCheckpointFiles(checkpointsDir, warnings) {
2484
4371
  async function runCheckpointGc(pmRoot, options) {
2485
4372
  const { dryRun, hooks } = options;
2486
4373
  const nowMs2 = options.now ?? Date.now();
2487
- const retentionMs = Math.max(0, options.retentionDays) * MILLISECONDS_PER_DAY;
2488
- const checkpointsDir = path.join(pmRoot, "checkpoints");
4374
+ const retentionMs = Math.max(0, options.retentionDays) * MILLISECONDS_PER_DAY2;
4375
+ const checkpointsDir = path2.join(pmRoot, "checkpoints");
2489
4376
  const result = {
2490
4377
  scanned: 0,
2491
4378
  removed: [],
@@ -2495,7 +4382,7 @@ async function runCheckpointGc(pmRoot, options) {
2495
4382
  };
2496
4383
  const files = await collectCheckpointFiles(checkpointsDir, result.warnings);
2497
4384
  for (const relName of files) {
2498
- const absPath = path.join(checkpointsDir, relName);
4385
+ const absPath = path2.join(checkpointsDir, relName);
2499
4386
  const relPath = `checkpoints/${relName}`;
2500
4387
  result.scanned += 1;
2501
4388
  if (hooks?.onRead) {
@@ -2570,7 +4457,7 @@ async function runCheckpointGc(pmRoot, options) {
2570
4457
 
2571
4458
  // dist/core/lock/lock-gc.js
2572
4459
  import fs2 from "node:fs/promises";
2573
- import path2 from "node:path";
4460
+ import path3 from "node:path";
2574
4461
  !(function() {
2575
4462
  try {
2576
4463
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
@@ -2650,7 +4537,7 @@ function classifyLockContent(file, raw, nowMs2) {
2650
4537
  }
2651
4538
  async function scanLockHealth(pmRoot, now) {
2652
4539
  const nowMs2 = now ?? Date.now();
2653
- const locksDir = path2.join(pmRoot, "locks");
4540
+ const locksDir = path3.join(pmRoot, "locks");
2654
4541
  const scan = {
2655
4542
  scanned: 0,
2656
4543
  active_lock_count: 0,
@@ -2671,7 +4558,7 @@ async function scanLockHealth(pmRoot, now) {
2671
4558
  for (const file of dirEntries) {
2672
4559
  let raw;
2673
4560
  try {
2674
- raw = await fs2.readFile(path2.join(locksDir, file), "utf8");
4561
+ raw = await fs2.readFile(path3.join(locksDir, file), "utf8");
2675
4562
  } catch (readError) {
2676
4563
  if (isErrno2(readError, "ENOENT")) {
2677
4564
  continue;
@@ -2695,7 +4582,7 @@ async function scanLockHealth(pmRoot, now) {
2695
4582
  async function runLockGc(pmRoot, options) {
2696
4583
  const { dryRun, hooks } = options;
2697
4584
  const nowMs2 = options.now ?? Date.now();
2698
- const locksDir = path2.join(pmRoot, "locks");
4585
+ const locksDir = path3.join(pmRoot, "locks");
2699
4586
  const result = {
2700
4587
  scanned: 0,
2701
4588
  removed: [],
@@ -2715,7 +4602,7 @@ async function runLockGc(pmRoot, options) {
2715
4602
  }
2716
4603
  for (const file of dirEntries) {
2717
4604
  result.scanned += 1;
2718
- const absPath = path2.join(locksDir, file);
4605
+ const absPath = path3.join(locksDir, file);
2719
4606
  const relPath = `locks/${file}`;
2720
4607
  if (hooks?.onRead) {
2721
4608
  const hookWarnings = await hooks.onRead(absPath);
@@ -2850,7 +4737,7 @@ function isErrno3(error, code) {
2850
4737
  }
2851
4738
  async function removeCacheFile(pmRoot, target, dryRun) {
2852
4739
  const relativePath = target.relativePath;
2853
- const absolutePath = path3.join(pmRoot, relativePath);
4740
+ const absolutePath = path4.join(pmRoot, relativePath);
2854
4741
  const warnings = await runActiveOnReadHooks({
2855
4742
  path: absolutePath,
2856
4743
  scope: "project"
@@ -3036,7 +4923,7 @@ async function runGc(global2, options = {}) {
3036
4923
 
3037
4924
  // dist/sdk/author-attribution.js
3038
4925
  import fs4 from "node:fs/promises";
3039
- import path4 from "node:path";
4926
+ import path5 from "node:path";
3040
4927
  !(function() {
3041
4928
  try {
3042
4929
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
@@ -3092,7 +4979,7 @@ var inspectHistoryAuthorStream = (itemId, raw, sampleLimit = 20) => {
3092
4979
  };
3093
4980
  };
3094
4981
  var scanHistoryAuthorAttribution = async (pmRoot, sampleLimit = 20) => {
3095
- const historyDirectory = path4.join(pmRoot, "history");
4982
+ const historyDirectory = path5.join(pmRoot, "history");
3096
4983
  let fileNames;
3097
4984
  try {
3098
4985
  fileNames = (await fs4.readdir(historyDirectory)).filter((fileName) => fileName.endsWith(".jsonl")).sort((left, right) => left.localeCompare(right));
@@ -3109,7 +4996,7 @@ var scanHistoryAuthorAttribution = async (pmRoot, sampleLimit = 20) => {
3109
4996
  for (const fileName of fileNames) {
3110
4997
  let raw;
3111
4998
  try {
3112
- raw = await fs4.readFile(path4.join(historyDirectory, fileName), "utf8");
4999
+ raw = await fs4.readFile(path5.join(historyDirectory, fileName), "utf8");
3113
5000
  } catch {
3114
5001
  continue;
3115
5002
  }
@@ -3138,7 +5025,7 @@ var scanHistoryAuthorAttribution = async (pmRoot, sampleLimit = 20) => {
3138
5025
 
3139
5026
  // dist/sdk/governance/health.js
3140
5027
  import fs5 from "node:fs/promises";
3141
- import path5 from "node:path";
5028
+ import path6 from "node:path";
3142
5029
 
3143
5030
  // dist/core/diagnostics/remediation.js
3144
5031
  !(function() {
@@ -3524,11 +5411,11 @@ function buildRemediationCommands(warnings) {
3524
5411
  } catch (e2) {
3525
5412
  }
3526
5413
  })();
3527
- var PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
5414
+ var PM_TELEMETRY_SOURCE_CONTEXT_SET2 = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
3528
5415
  var STALE_VECTORIZATION_SUMMARY_LIMIT = 25;
3529
5416
  var BRIEF_HEALTH_DETAIL_LIMIT = 8;
3530
- var TELEMETRY_QUEUE_RELATIVE_PATH = path5.join("runtime", "telemetry", "events.jsonl");
3531
- var TELEMETRY_STATE_RELATIVE_PATH = path5.join("runtime", "telemetry", "state.json");
5417
+ var TELEMETRY_QUEUE_RELATIVE_PATH2 = path6.join("runtime", "telemetry", "events.jsonl");
5418
+ var TELEMETRY_STATE_RELATIVE_PATH2 = path6.join("runtime", "telemetry", "state.json");
3532
5419
  var TELEMETRY_ENDPOINT_PROBE_TIMEOUT_MS = 2500;
3533
5420
  var TELEMETRY_QUEUE_HIGH_WATER_MARK = 500;
3534
5421
  var TELEMETRY_QUEUE_HIGH_RETRY_THRESHOLD = TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS - 3;
@@ -3567,7 +5454,7 @@ async function isDirectory(targetPath) {
3567
5454
  }
3568
5455
  }
3569
5456
  async function countHistoryStreams(pmRoot, compactPolicy) {
3570
- const historyDir = path5.join(pmRoot, "history");
5457
+ const historyDir = path6.join(pmRoot, "history");
3571
5458
  if (!await isDirectory(historyDir)) {
3572
5459
  return { count: 0, warnings: [], over_threshold: [], max_entries: null };
3573
5460
  }
@@ -3577,7 +5464,7 @@ async function countHistoryStreams(pmRoot, compactPolicy) {
3577
5464
  const warnings = [];
3578
5465
  const overThreshold = [];
3579
5466
  for (const fileName of historyFiles) {
3580
- const streamPath = path5.join(historyDir, fileName);
5467
+ const streamPath = path6.join(historyDir, fileName);
3581
5468
  warnings.push(...await runActiveOnReadHooks({ path: streamPath, scope: "project" }));
3582
5469
  if (!policyActive) {
3583
5470
  continue;
@@ -3604,13 +5491,13 @@ async function countHistoryStreams(pmRoot, compactPolicy) {
3604
5491
  };
3605
5492
  }
3606
5493
  function normalizeRelativePath(pmRoot, targetPath) {
3607
- return path5.relative(pmRoot, targetPath).replaceAll("\\", "/");
5494
+ return path6.relative(pmRoot, targetPath).replaceAll("\\", "/");
3608
5495
  }
3609
5496
  async function listItemDocumentPaths(pmRoot, typeToFolder) {
3610
5497
  const folders = [...new Set(Object.values(typeToFolder))].sort((left, right) => left.localeCompare(right));
3611
5498
  const itemPaths = [];
3612
5499
  for (const folder of folders) {
3613
- const directoryPath = path5.join(pmRoot, folder);
5500
+ const directoryPath = path6.join(pmRoot, folder);
3614
5501
  let entries = [];
3615
5502
  try {
3616
5503
  entries = await fs5.readdir(directoryPath);
@@ -3624,7 +5511,7 @@ async function listItemDocumentPaths(pmRoot, typeToFolder) {
3624
5511
  if (!ITEM_FILE_EXTENSIONS.some((extension) => entry.toLowerCase().endsWith(extension))) {
3625
5512
  continue;
3626
5513
  }
3627
- itemPaths.push(path5.join(directoryPath, entry));
5514
+ itemPaths.push(path6.join(directoryPath, entry));
3628
5515
  }
3629
5516
  }
3630
5517
  itemPaths.sort((left, right) => normalizeRelativePath(pmRoot, left).localeCompare(normalizeRelativePath(pmRoot, right)));
@@ -3673,7 +5560,7 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema) {
3673
5560
  }
3674
5561
  }
3675
5562
  const formatVersionScan = scanItemFormatVersions(formatVersionEntries);
3676
- const historyDir = path5.join(pmRoot, "history");
5563
+ const historyDir = path6.join(pmRoot, "history");
3677
5564
  const historyUnreadable = [];
3678
5565
  const historyConflictMarkers = [];
3679
5566
  const historyInvalidJson = [];
@@ -3687,7 +5574,7 @@ async function buildIntegrityCheck(pmRoot, typeToFolder, schema) {
3687
5574
  }
3688
5575
  for (const fileName of historyFiles) {
3689
5576
  const itemId = fileName.slice(0, -".jsonl".length);
3690
- const historyPath = path5.join(historyDir, fileName);
5577
+ const historyPath = path6.join(historyDir, fileName);
3691
5578
  let raw = "";
3692
5579
  try {
3693
5580
  raw = await fs5.readFile(historyPath, "utf8");
@@ -4298,7 +6185,7 @@ function telemetryEnvFlagEnabled(envKey) {
4298
6185
  }
4299
6186
  function telemetrySourceContextOverride() {
4300
6187
  const value = (process.env.PM_TELEMETRY_SOURCE_CONTEXT ?? "").trim().toLowerCase();
4301
- return PM_TELEMETRY_SOURCE_CONTEXT_SET.has(value) ? value : null;
6188
+ return PM_TELEMETRY_SOURCE_CONTEXT_SET2.has(value) ? value : null;
4302
6189
  }
4303
6190
  function normalizeEndpointForDisplay(rawEndpoint) {
4304
6191
  const trimmed = rawEndpoint.trim();
@@ -4484,9 +6371,9 @@ async function probeTelemetryEndpointHealth(endpoint) {
4484
6371
  }
4485
6372
  async function buildTelemetryCheck(settings, options) {
4486
6373
  const globalPmRoot = resolveGlobalPmRoot(process.cwd());
4487
- const queuePath = path5.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
4488
- const statePath = path5.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
4489
- const queueRaw = await readFileIfExists(queuePath);
6374
+ const queuePath2 = path6.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH2);
6375
+ const statePath = path6.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH2);
6376
+ const queueRaw = await readFileIfExists(queuePath2);
4490
6377
  const queueExists = queueRaw !== null;
4491
6378
  const queueSizeBytes = queueRaw ? Buffer.byteLength(queueRaw, "utf8") : 0;
4492
6379
  const queueSummary = queueRaw ? parseTelemetryQueue(queueRaw) : emptyTelemetryQueueSummary();
@@ -4511,7 +6398,7 @@ async function buildTelemetryCheck(settings, options) {
4511
6398
  capture_level: settings.telemetry.capture_level,
4512
6399
  endpoint: endpointDisplay,
4513
6400
  global_pm_root: globalPmRoot,
4514
- queue_path: queuePath,
6401
+ queue_path: queuePath2,
4515
6402
  queue_exists: queueExists,
4516
6403
  queue_entries: queueSummary.validEntries,
4517
6404
  queue_draining: isTelemetryQueueDraining(queueHasEntries, warnings),
@@ -4816,7 +6703,7 @@ async function scanHealthDirectories(pmRoot, typeRegistry, strictDirectories) {
4816
6703
  const missingOptionalDirs = [];
4817
6704
  const hookWarnings = [];
4818
6705
  for (const relativeDir of [...requiredDirs, ...optionalDirs]) {
4819
- const directoryPath = path5.join(pmRoot, relativeDir);
6706
+ const directoryPath = path6.join(pmRoot, relativeDir);
4820
6707
  hookWarnings.push(...await runActiveOnReadHooks({
4821
6708
  path: directoryPath,
4822
6709
  scope: "project"
@@ -5123,78 +7010,9 @@ var _testOnlyHealthCommand = {
5123
7010
  }
5124
7011
  })();
5125
7012
 
5126
- // dist/cli/commands/scheduling-shortcuts.js
5127
- !(function() {
5128
- try {
5129
- var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
5130
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "861b3772-eeff-5118-ad1a-7d373b8903f1");
5131
- } catch (e2) {
5132
- }
5133
- })();
5134
- var DEFAULT_DURATION = "1h";
5135
- var DEFAULT_START = "now";
5136
- var DEFAULT_REMINDER_AT = "+1d";
5137
- function quoteCsvValue(value) {
5138
- return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
5139
- }
5140
- function appendPair(pairs, key, value) {
5141
- if (value !== void 0) {
5142
- pairs.push(`${key}=${quoteCsvValue(value)}`);
5143
- }
5144
- }
5145
- function buildCommonOptions(type, title, options) {
5146
- return {
5147
- type,
5148
- title,
5149
- schedulePreset: "lightweight",
5150
- parent: options.parent,
5151
- allowMissingParent: options.allowMissingParent,
5152
- tags: options.tags,
5153
- priority: options.priority,
5154
- body: options.body,
5155
- description: options.description,
5156
- author: options.author,
5157
- message: options.message
5158
- };
5159
- }
5160
- function buildEventEntry(options) {
5161
- const pairs = [];
5162
- appendPair(pairs, "start", options.start ?? DEFAULT_START);
5163
- if (options.end !== void 0) {
5164
- appendPair(pairs, "end", options.end);
5165
- } else {
5166
- appendPair(pairs, "duration", options.duration ?? DEFAULT_DURATION);
5167
- }
5168
- appendPair(pairs, "location", options.location);
5169
- appendPair(pairs, "timezone", options.timezone);
5170
- if (options.allDay === true) {
5171
- appendPair(pairs, "all_day", "true");
5172
- }
5173
- return pairs.join(",");
5174
- }
5175
- async function createScheduled(type, title, options, global2) {
5176
- const createOptions = buildCommonOptions(type, title, options);
5177
- createOptions.event = [buildEventEntry(options)];
5178
- return runCreate(createOptions, global2);
5179
- }
5180
- function runMeet(title, options, global2) {
5181
- return createScheduled("Meeting", title, options, global2);
5182
- }
5183
- function runEvent(title, options, global2) {
5184
- return createScheduled("Event", title, options, global2);
5185
- }
5186
- function runRemind(title, options, global2) {
5187
- const createOptions = buildCommonOptions("Reminder", title, options);
5188
- const pairs = [];
5189
- appendPair(pairs, "at", options.at ?? DEFAULT_REMINDER_AT);
5190
- appendPair(pairs, "text", options.text ?? title);
5191
- createOptions.reminder = [pairs.join(",")];
5192
- return runCreate(createOptions, global2);
5193
- }
5194
-
5195
7013
  // dist/sdk/stats.js
5196
7014
  import fs6 from "node:fs/promises";
5197
- import path6 from "node:path";
7015
+ import path7 from "node:path";
5198
7016
 
5199
7017
  // dist/core/history/history-storage-stats.js
5200
7018
  !(function() {
@@ -5257,21 +7075,21 @@ function computeHistoryStorageStats(streams, options) {
5257
7075
  let newestEntry = null;
5258
7076
  let globalOldestMs = Number.POSITIVE_INFINITY;
5259
7077
  let globalNewestMs = Number.NEGATIVE_INFINITY;
5260
- for (const stat of stats) {
5261
- totalLines += stat.lines;
5262
- totalBytes += stat.bytes;
5263
- if (stat.oldest_ts !== null) {
5264
- const ms = Date.parse(stat.oldest_ts);
5265
- if (shouldReplaceExtreme(ms, globalOldestMs, stat.id, oldestEntry?.id ?? null, "min")) {
7078
+ for (const stat2 of stats) {
7079
+ totalLines += stat2.lines;
7080
+ totalBytes += stat2.bytes;
7081
+ if (stat2.oldest_ts !== null) {
7082
+ const ms = Date.parse(stat2.oldest_ts);
7083
+ if (shouldReplaceExtreme(ms, globalOldestMs, stat2.id, oldestEntry?.id ?? null, "min")) {
5266
7084
  globalOldestMs = ms;
5267
- oldestEntry = { id: stat.id, ts: stat.oldest_ts };
7085
+ oldestEntry = { id: stat2.id, ts: stat2.oldest_ts };
5268
7086
  }
5269
7087
  }
5270
- if (stat.newest_ts !== null) {
5271
- const ms = Date.parse(stat.newest_ts);
5272
- if (shouldReplaceExtreme(ms, globalNewestMs, stat.id, newestEntry?.id ?? null, "max")) {
7088
+ if (stat2.newest_ts !== null) {
7089
+ const ms = Date.parse(stat2.newest_ts);
7090
+ if (shouldReplaceExtreme(ms, globalNewestMs, stat2.id, newestEntry?.id ?? null, "max")) {
5273
7091
  globalNewestMs = ms;
5274
- newestEntry = { id: stat.id, ts: stat.newest_ts };
7092
+ newestEntry = { id: stat2.id, ts: stat2.newest_ts };
5275
7093
  }
5276
7094
  }
5277
7095
  }
@@ -5315,7 +7133,7 @@ function countNonEmptyLines(raw) {
5315
7133
  return raw.split(/\r?\n/u).filter((line) => line.trim().length > 0).length;
5316
7134
  }
5317
7135
  async function readHistoryStreamContents(pmRoot) {
5318
- const historyDir = path6.join(pmRoot, "history");
7136
+ const historyDir = path7.join(pmRoot, "history");
5319
7137
  if (!await pathExists(historyDir)) {
5320
7138
  return [];
5321
7139
  }
@@ -5326,7 +7144,7 @@ async function readHistoryStreamContents(pmRoot) {
5326
7144
  const historyFiles = (await fs6.readdir(historyDir)).filter((entry) => entry.endsWith(".jsonl")).sort((a, b) => a.localeCompare(b));
5327
7145
  const streams = [];
5328
7146
  for (const file of historyFiles) {
5329
- const historyPath = path6.join(historyDir, file);
7147
+ const historyPath = path7.join(historyDir, file);
5330
7148
  const raw = await readFileIfExists(historyPath);
5331
7149
  if (raw === null) {
5332
7150
  continue;
@@ -5409,7 +7227,7 @@ async function runStats(global2, options = {}) {
5409
7227
 
5410
7228
  // dist/sdk/telemetry.js
5411
7229
  import fs7 from "node:fs/promises";
5412
- import path7 from "node:path";
7230
+ import path8 from "node:path";
5413
7231
  !(function() {
5414
7232
  try {
5415
7233
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
@@ -5417,9 +7235,9 @@ import path7 from "node:path";
5417
7235
  } catch (e2) {
5418
7236
  }
5419
7237
  })();
5420
- var TELEMETRY_QUEUE_RELATIVE_PATH2 = path7.join("runtime", "telemetry", "events.jsonl");
5421
- var TELEMETRY_STATE_RELATIVE_PATH2 = path7.join("runtime", "telemetry", "state.json");
5422
- var TELEMETRY_RUNTIME_RELATIVE_PATH = path7.join("runtime", "telemetry");
7238
+ var TELEMETRY_QUEUE_RELATIVE_PATH3 = path8.join("runtime", "telemetry", "events.jsonl");
7239
+ var TELEMETRY_STATE_RELATIVE_PATH3 = path8.join("runtime", "telemetry", "state.json");
7240
+ var TELEMETRY_RUNTIME_RELATIVE_PATH = path8.join("runtime", "telemetry");
5423
7241
  var DEFAULT_STATS_LIMIT = 20;
5424
7242
  var TELEMETRY_SUBCOMMANDS = [
5425
7243
  "status",
@@ -5636,15 +7454,15 @@ var readTelemetryRuntimeState = async (statePath) => {
5636
7454
  var nullableTelemetryStateValue = (value) => value ?? null;
5637
7455
  var buildTelemetryStatusSummary = async (globalPmRoot) => {
5638
7456
  const settings = await readSettings(globalPmRoot);
5639
- const queuePath = path7.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH2);
5640
- const statePath = path7.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH2);
5641
- const queueRaw = await readFileIfExists(queuePath);
7457
+ const queuePath2 = path8.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH3);
7458
+ const statePath = path8.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH3);
7459
+ const queueRaw = await readFileIfExists(queuePath2);
5642
7460
  const queue = parseTelemetryQueue2(queueRaw);
5643
7461
  const runtimeState = await readTelemetryRuntimeState(statePath);
5644
7462
  return {
5645
7463
  enabled: settings.telemetry.enabled,
5646
7464
  endpoint: settings.telemetry.endpoint,
5647
- queue_path: queuePath,
7465
+ queue_path: queuePath2,
5648
7466
  state_path: statePath,
5649
7467
  queue_rows_total: queue.rows_total,
5650
7468
  queue_entries: queue.valid_entries,
@@ -5715,7 +7533,7 @@ var runTelemetryClear = async (_options, context) => {
5715
7533
  if (settingsChanged) {
5716
7534
  await writeSettings(context.globalPmRoot, settings, "telemetry:clear");
5717
7535
  }
5718
- const telemetryRuntimePath = path7.join(context.globalPmRoot, TELEMETRY_RUNTIME_RELATIVE_PATH);
7536
+ const telemetryRuntimePath = path8.join(context.globalPmRoot, TELEMETRY_RUNTIME_RELATIVE_PATH);
5719
7537
  const existed = await pathExists(telemetryRuntimePath);
5720
7538
  await fs7.rm(telemetryRuntimePath, { recursive: true, force: true });
5721
7539
  return {
@@ -5741,8 +7559,8 @@ var runTelemetry = async (options, _global) => {
5741
7559
  const globalPmRoot = resolveGlobalPmRoot(process.cwd());
5742
7560
  return TELEMETRY_COMMAND_HANDLERS[subcommand](options, {
5743
7561
  globalPmRoot,
5744
- queuePath: path7.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH2),
5745
- statePath: path7.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH2)
7562
+ queuePath: path8.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH3),
7563
+ statePath: path8.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH3)
5746
7564
  });
5747
7565
  };
5748
7566
 
@@ -6219,10 +8037,10 @@ function firstPositionalToken(tokens, flagsWithValue = /* @__PURE__ */ new Set()
6219
8037
  }
6220
8038
 
6221
8039
  // dist/sdk/test/execution.js
6222
- import { spawn } from "node:child_process";
6223
- import { cp, mkdir, mkdtemp, readdir, rm } from "node:fs/promises";
8040
+ import { spawn as spawn2 } from "node:child_process";
8041
+ import { cp, mkdir as mkdir2, mkdtemp, readdir as readdir2, rm as rm2 } from "node:fs/promises";
6224
8042
  import { tmpdir } from "node:os";
6225
- import path8 from "node:path";
8043
+ import path9 from "node:path";
6226
8044
 
6227
8045
  // dist/core/test/item-test-run-tracking.js
6228
8046
  !(function() {
@@ -6922,7 +8740,7 @@ async function killProcessTree(pid) {
6922
8740
  }
6923
8741
  if (process.platform === "win32") {
6924
8742
  await new Promise((resolve) => {
6925
- const killer = spawn("taskkill", ["/pid", String(pid), "/T", "/F"], {
8743
+ const killer = spawn2("taskkill", ["/pid", String(pid), "/T", "/F"], {
6926
8744
  stdio: "ignore",
6927
8745
  windowsHide: true
6928
8746
  });
@@ -7059,7 +8877,7 @@ function waitForLinkedTestChildClose(child) {
7059
8877
  });
7060
8878
  }
7061
8879
  function createLinkedTestChild(command, env) {
7062
- return spawn(command, {
8880
+ return spawn2(command, {
7063
8881
  cwd: process.cwd(),
7064
8882
  env,
7065
8883
  shell: true,
@@ -7231,7 +9049,7 @@ async function copyIntoSandboxIfPresent(sourcePath, targetPath, recursive = fals
7231
9049
  if (!await pathExists(sourcePath)) {
7232
9050
  return;
7233
9051
  }
7234
- await mkdir(path8.dirname(targetPath), { recursive: true });
9052
+ await mkdir2(path9.dirname(targetPath), { recursive: true });
7235
9053
  try {
7236
9054
  if (recursive) {
7237
9055
  await cp(sourcePath, targetPath, { recursive: true, force: true });
@@ -7247,21 +9065,21 @@ async function copyIntoSandboxIfPresent(sourcePath, targetPath, recursive = fals
7247
9065
  }
7248
9066
  async function seedLinkedTestSandbox(sandboxPmPath, sandboxGlobalPath, sourceRoots) {
7249
9067
  await copyIntoSandboxIfPresent(getSettingsPath(sourceRoots.projectPmRoot), getSettingsPath(sandboxPmPath));
7250
- await copyIntoSandboxIfPresent(path8.join(sourceRoots.projectPmRoot, "extensions"), path8.join(sandboxPmPath, "extensions"), true);
9068
+ await copyIntoSandboxIfPresent(path9.join(sourceRoots.projectPmRoot, "extensions"), path9.join(sandboxPmPath, "extensions"), true);
7251
9069
  await copyIntoSandboxIfPresent(getSettingsPath(sourceRoots.globalPmRoot), getSettingsPath(sandboxGlobalPath));
7252
- await copyIntoSandboxIfPresent(path8.join(sourceRoots.globalPmRoot, "extensions"), path8.join(sandboxGlobalPath, "extensions"), true);
9070
+ await copyIntoSandboxIfPresent(path9.join(sourceRoots.globalPmRoot, "extensions"), path9.join(sandboxGlobalPath, "extensions"), true);
7253
9071
  }
7254
9072
  async function seedLinkedTestTrackerData(sourceRoot, sandboxRoot) {
7255
9073
  if (!await pathExists(sourceRoot)) {
7256
9074
  return;
7257
9075
  }
7258
- const entries = await readdir(sourceRoot, { withFileTypes: true });
9076
+ const entries = await readdir2(sourceRoot, { withFileTypes: true });
7259
9077
  for (const entry of entries) {
7260
9078
  if (LINKED_TEST_TRACKER_DIRS_TO_SKIP.has(entry.name)) {
7261
9079
  continue;
7262
9080
  }
7263
- const sourcePath = path8.join(sourceRoot, entry.name);
7264
- const targetPath = path8.join(sandboxRoot, entry.name);
9081
+ const sourcePath = path9.join(sourceRoot, entry.name);
9082
+ const targetPath = path9.join(sandboxRoot, entry.name);
7265
9083
  if (entry.isDirectory()) {
7266
9084
  await copyIntoSandboxIfPresent(sourcePath, targetPath, true);
7267
9085
  continue;
@@ -7276,15 +9094,15 @@ async function countLinkedTestItemFiles(pmRoot) {
7276
9094
  return 0;
7277
9095
  }
7278
9096
  let total = 0;
7279
- const entries = await readdir(pmRoot, { withFileTypes: true });
9097
+ const entries = await readdir2(pmRoot, { withFileTypes: true });
7280
9098
  for (const entry of entries) {
7281
9099
  if (!entry.isDirectory() || LINKED_TEST_ITEM_COUNT_DIRS_TO_SKIP.has(entry.name)) {
7282
9100
  continue;
7283
9101
  }
7284
- const folderPath = path8.join(pmRoot, entry.name);
9102
+ const folderPath = path9.join(pmRoot, entry.name);
7285
9103
  let files;
7286
9104
  try {
7287
- files = await readdir(folderPath, { withFileTypes: true });
9105
+ files = await readdir2(folderPath, { withFileTypes: true });
7288
9106
  } catch {
7289
9107
  continue;
7290
9108
  }
@@ -7476,10 +9294,10 @@ ${stderr}`;
7476
9294
  function createLinkedTestSandboxLayout(sandboxRoot) {
7477
9295
  return {
7478
9296
  root: sandboxRoot,
7479
- schemaProjectPmPath: path8.join(sandboxRoot, "schema", "project", ".agents", "pm"),
7480
- schemaGlobalPmPath: path8.join(sandboxRoot, "schema", "global"),
7481
- trackerProjectPmPath: path8.join(sandboxRoot, "tracker", "project", ".agents", "pm"),
7482
- trackerGlobalPmPath: path8.join(sandboxRoot, "tracker", "global")
9297
+ schemaProjectPmPath: path9.join(sandboxRoot, "schema", "project", ".agents", "pm"),
9298
+ schemaGlobalPmPath: path9.join(sandboxRoot, "schema", "global"),
9299
+ trackerProjectPmPath: path9.join(sandboxRoot, "tracker", "project", ".agents", "pm"),
9300
+ trackerGlobalPmPath: path9.join(sandboxRoot, "tracker", "global")
7483
9301
  };
7484
9302
  }
7485
9303
  async function initializeLinkedTestSandboxes(layout) {
@@ -7679,7 +9497,7 @@ async function runSingleLinkedTest(params) {
7679
9497
  }
7680
9498
  async function runLinkedTests(tests, defaultTimeoutSeconds, options) {
7681
9499
  const results = [];
7682
- const sandboxRoot = await mkdtemp(path8.join(tmpdir(), "pm-linked-test-"));
9500
+ const sandboxRoot = await mkdtemp(path9.join(tmpdir(), "pm-linked-test-"));
7683
9501
  const layout = createLinkedTestSandboxLayout(sandboxRoot);
7684
9502
  const runLevelPmContextMode = parsePmContextMode(options?.pmContext);
7685
9503
  const progressMode = options?.progress === true ? "always" : "auto";
@@ -7722,7 +9540,7 @@ async function runLinkedTests(tests, defaultTimeoutSeconds, options) {
7722
9540
  }));
7723
9541
  }
7724
9542
  } finally {
7725
- await rm(layout.root, {
9543
+ await rm2(layout.root, {
7726
9544
  recursive: true,
7727
9545
  force: true,
7728
9546
  maxRetries: 3,
@@ -8415,13 +10233,13 @@ var runTestAll = async (options, global2) => {
8415
10233
  })();
8416
10234
 
8417
10235
  // dist/sdk/test/runs.js
8418
- import os from "node:os";
10236
+ import os2 from "node:os";
8419
10237
 
8420
10238
  // dist/core/test/background-runs.js
8421
10239
  import fs8 from "node:fs/promises";
8422
- import { spawn as spawn2 } from "node:child_process";
10240
+ import { spawn as spawn3 } from "node:child_process";
8423
10241
  import { createHash, randomBytes } from "node:crypto";
8424
- import path9 from "node:path";
10242
+ import path10 from "node:path";
8425
10243
  !(function() {
8426
10244
  try {
8427
10245
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
@@ -8466,7 +10284,7 @@ function buildBackgroundTestRunFingerprint(kind, commandArgs, pmRoot) {
8466
10284
  const payload = {
8467
10285
  kind,
8468
10286
  command: normalizeCommandArgs(commandArgs),
8469
- pm_root: path9.resolve(pmRoot)
10287
+ pm_root: path10.resolve(pmRoot)
8470
10288
  };
8471
10289
  return createHash("sha256").update(JSON.stringify(payload)).digest("hex");
8472
10290
  }
@@ -8522,7 +10340,7 @@ async function listBackgroundRunRecordPaths(pmRoot) {
8522
10340
  return [];
8523
10341
  }
8524
10342
  const entries = await fs8.readdir(recordsRoot, { withFileTypes: true });
8525
- return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path9.join(recordsRoot, entry.name)).sort((left, right) => right.localeCompare(left));
10343
+ return entries.filter((entry) => entry.isFile() && entry.name.endsWith(".json")).map((entry) => path10.join(recordsRoot, entry.name)).sort((left, right) => right.localeCompare(left));
8526
10344
  }
8527
10345
  function parseLinuxRssStatus(raw) {
8528
10346
  const match = raw.match(/^VmRSS:\s+(\d+)\s+kB$/m);
@@ -8700,18 +10518,18 @@ function tailLines(value, limit) {
8700
10518
  async function resolveBackgroundCliEntry(cwd) {
8701
10519
  const configured = process.env.PM_BACKGROUND_CLI_ENTRY?.trim();
8702
10520
  if (configured && configured.length > 0) {
8703
- const resolvedConfigured = path9.resolve(cwd, configured);
10521
+ const resolvedConfigured = path10.resolve(cwd, configured);
8704
10522
  if (await pathExists(resolvedConfigured)) {
8705
10523
  return resolvedConfigured;
8706
10524
  }
8707
10525
  }
8708
- const distEntry = path9.resolve(cwd, "dist", "cli.js");
10526
+ const distEntry = path10.resolve(cwd, "dist", "cli.js");
8709
10527
  if (await pathExists(distEntry)) {
8710
10528
  return distEntry;
8711
10529
  }
8712
10530
  const argvEntry = process.argv[1]?.trim();
8713
10531
  if (argvEntry && argvEntry.length > 0) {
8714
- const resolvedArgvEntry = path9.resolve(cwd, argvEntry);
10532
+ const resolvedArgvEntry = path10.resolve(cwd, argvEntry);
8715
10533
  if (await pathExists(resolvedArgvEntry)) {
8716
10534
  return resolvedArgvEntry;
8717
10535
  }
@@ -8825,7 +10643,7 @@ async function spawnBackgroundTestRunWorker(options) {
8825
10643
  PM_BACKGROUND_TEST_RUN_RESUMED_FROM: record.resumed_from ?? "",
8826
10644
  FORCE_COLOR: "0"
8827
10645
  };
8828
- const child = spawn2(process.execPath, [cliEntry, ...args], {
10646
+ const child = spawn3(process.execPath, [cliEntry, ...args], {
8829
10647
  cwd: process.cwd(),
8830
10648
  env,
8831
10649
  detached: true,
@@ -9007,7 +10825,7 @@ async function runBackgroundTestRunWorker(pmRoot, runId, noExtensions = false) {
9007
10825
  const env = buildBackgroundWorkerEnv(record);
9008
10826
  await writeBackgroundRunRecord(pmRoot, record);
9009
10827
  const childArgs = buildBackgroundWorkerChildArgs(record, noExtensions);
9010
- const child = spawn2(process.execPath, [cliEntry, ...childArgs], {
10828
+ const child = spawn3(process.execPath, [cliEntry, ...childArgs], {
9011
10829
  cwd: process.cwd(),
9012
10830
  env,
9013
10831
  detached: false,
@@ -9299,7 +11117,7 @@ function normalizeStream(value) {
9299
11117
  }
9300
11118
  function resolveWhoamiFallback() {
9301
11119
  try {
9302
- const username = os.userInfo().username.trim();
11120
+ const username = os2.userInfo().username.trim();
9303
11121
  if (username.length > 0) {
9304
11122
  return username;
9305
11123
  }
@@ -9447,7 +11265,7 @@ async function runTestRunsWorker(runId, global2) {
9447
11265
  import fs9 from "node:fs/promises";
9448
11266
  import { realpathSync } from "node:fs";
9449
11267
  import { execFile } from "node:child_process";
9450
- import path10 from "node:path";
11268
+ import path11 from "node:path";
9451
11269
  import { promisify } from "node:util";
9452
11270
 
9453
11271
  // dist/core/validate/fix-planning.js
@@ -9788,8 +11606,8 @@ function buildMissingLinkedPathRows(rows, lookup) {
9788
11606
  });
9789
11607
  }
9790
11608
  }
9791
- return [...buckets.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([path11, bucket]) => ({
9792
- path: path11,
11609
+ return [...buckets.entries()].sort(([left], [right]) => left.localeCompare(right)).map(([path12, bucket]) => ({
11610
+ path: path12,
9793
11611
  classification: bucket.classification,
9794
11612
  items: [...bucket.owners.values()].map((owner) => {
9795
11613
  const metadata = lookup(owner.item_id);
@@ -10133,16 +11951,16 @@ function resolveFileScanMode(scanMode) {
10133
11951
  throw new PmCliError(`Unknown --scan-mode value "${scanMode}". Supported values: ${VALIDATE_FILE_SCAN_MODES.join(", ")}.`, EXIT_CODE.USAGE);
10134
11952
  }
10135
11953
  function resolveWorkspaceRoot(pmRoot) {
10136
- const resolvedPmRoot = path10.resolve(pmRoot);
11954
+ const resolvedPmRoot = path11.resolve(pmRoot);
10137
11955
  const normalizedPmRoot = resolvedPmRoot.replaceAll("\\", "/");
10138
11956
  if (normalizedPmRoot.endsWith("/.agents/pm")) {
10139
- return path10.dirname(path10.dirname(resolvedPmRoot));
11957
+ return path11.dirname(path11.dirname(resolvedPmRoot));
10140
11958
  }
10141
- const resolvedCwd = path10.resolve(process.cwd());
11959
+ const resolvedCwd = path11.resolve(process.cwd());
10142
11960
  const canonicalPmRoot = realpathForWorkspaceRoot(resolvedPmRoot);
10143
11961
  const canonicalCwd = realpathForWorkspaceRoot(resolvedCwd);
10144
- const relativeFromPmRoot = path10.relative(canonicalPmRoot, canonicalCwd);
10145
- const cwdInsidePmRoot = relativeFromPmRoot.length === 0 || !relativeFromPmRoot.startsWith("..") && !path10.isAbsolute(relativeFromPmRoot);
11962
+ const relativeFromPmRoot = path11.relative(canonicalPmRoot, canonicalCwd);
11963
+ const cwdInsidePmRoot = relativeFromPmRoot.length === 0 || !relativeFromPmRoot.startsWith("..") && !path11.isAbsolute(relativeFromPmRoot);
10146
11964
  if (cwdInsidePmRoot) {
10147
11965
  return resolvedPmRoot;
10148
11966
  }
@@ -10152,11 +11970,11 @@ function realpathForWorkspaceRoot(inputPath) {
10152
11970
  try {
10153
11971
  return realpathSync.native(inputPath);
10154
11972
  } catch {
10155
- return path10.resolve(inputPath);
11973
+ return path11.resolve(inputPath);
10156
11974
  }
10157
11975
  }
10158
11976
  async function listFilesRecursive(basePath, relativePath, output) {
10159
- const targetDirectory = relativePath.length > 0 ? path10.join(basePath, relativePath) : basePath;
11977
+ const targetDirectory = relativePath.length > 0 ? path11.join(basePath, relativePath) : basePath;
10160
11978
  let entries;
10161
11979
  try {
10162
11980
  entries = await fs9.readdir(targetDirectory, { withFileTypes: true });
@@ -10170,7 +11988,7 @@ async function listFilesRecursive(basePath, relativePath, output) {
10170
11988
  if (entry.name.startsWith(".")) {
10171
11989
  continue;
10172
11990
  }
10173
- const childRelative = relativePath.length > 0 ? path10.join(relativePath, entry.name) : entry.name;
11991
+ const childRelative = relativePath.length > 0 ? path11.join(relativePath, entry.name) : entry.name;
10174
11992
  if (entry.isDirectory()) {
10175
11993
  if (DIRECTORY_IGNORE_SET.has(entry.name)) {
10176
11994
  continue;
@@ -10190,7 +12008,7 @@ async function collectDefaultProjectFileCandidates(workspaceRoot) {
10190
12008
  await listFilesRecursive(workspaceRoot, directory, discovered);
10191
12009
  }
10192
12010
  for (const candidate of FILE_SCAN_ROOT_FILES) {
10193
- const absolute = path10.join(workspaceRoot, candidate);
12011
+ const absolute = path11.join(workspaceRoot, candidate);
10194
12012
  try {
10195
12013
  const stats = await fs9.stat(absolute);
10196
12014
  if (stats.isFile()) {
@@ -10222,7 +12040,7 @@ function resolvePmInternalCandidatePrefixes(pmRoot, workspaceRoot) {
10222
12040
  if (configuredDefault.length > 0) {
10223
12041
  prefixes.add(configuredDefault);
10224
12042
  }
10225
- const relativePmRoot = normalizeRelativeDirectoryPath(path10.relative(workspaceRoot, pmRoot));
12043
+ const relativePmRoot = normalizeRelativeDirectoryPath(path11.relative(workspaceRoot, pmRoot));
10226
12044
  if (relativePmRoot.length > 0 && !relativePmRoot.startsWith("..")) {
10227
12045
  prefixes.add(relativePmRoot);
10228
12046
  }
@@ -10702,30 +12520,30 @@ function resolveLifecycleDependencyCycleSamplePath(component, graph) {
10702
12520
  return [start, start];
10703
12521
  }
10704
12522
  const componentSet = new Set(component);
10705
- const path11 = [start];
12523
+ const path12 = [start];
10706
12524
  const visited = /* @__PURE__ */ new Set([start]);
10707
12525
  const search = (current) => {
10708
12526
  const neighbors = (graph.get(current) ?? []).filter((candidate) => componentSet.has(candidate));
10709
12527
  for (const next of neighbors) {
10710
- if (next === start && path11.length > 1) {
10711
- path11.push(start);
12528
+ if (next === start && path12.length > 1) {
12529
+ path12.push(start);
10712
12530
  return true;
10713
12531
  }
10714
12532
  if (visited.has(next)) {
10715
12533
  continue;
10716
12534
  }
10717
12535
  visited.add(next);
10718
- path11.push(next);
12536
+ path12.push(next);
10719
12537
  if (search(next)) {
10720
12538
  return true;
10721
12539
  }
10722
- path11.pop();
12540
+ path12.pop();
10723
12541
  visited.delete(next);
10724
12542
  }
10725
12543
  return false;
10726
12544
  };
10727
12545
  if (search(start)) {
10728
- return [...path11];
12546
+ return [...path12];
10729
12547
  }
10730
12548
  return [...component, start];
10731
12549
  }
@@ -10983,7 +12801,7 @@ function linkedArtifactPathExceedsFilesystemLimits(artifactPath) {
10983
12801
  return normalized.length > LINKED_ARTIFACT_MAX_PATH_LENGTH || normalized.split(/[\\/]/).some((segment) => segment.length > LINKED_ARTIFACT_MAX_SEGMENT_LENGTH);
10984
12802
  }
10985
12803
  async function linkedArtifactIsMissing(workspaceRoot, artifactPath) {
10986
- const absolutePath = path10.isAbsolute(artifactPath) ? artifactPath : path10.resolve(workspaceRoot, artifactPath);
12804
+ const absolutePath = path11.isAbsolute(artifactPath) ? artifactPath : path11.resolve(workspaceRoot, artifactPath);
10987
12805
  if (linkedArtifactPathExceedsFilesystemLimits(absolutePath)) {
10988
12806
  return false;
10989
12807
  }
@@ -11656,20 +13474,38 @@ var runValidate2 = (options, global2) => runValidate(options, global2, {
11656
13474
  runUpdate: (id, updateOptions, updateGlobal) => runUpdate(id, updateOptions, updateGlobal)
11657
13475
  });
11658
13476
 
13477
+ // dist/sdk/start-task-status.js
13478
+ !(function() {
13479
+ try {
13480
+ var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
13481
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3da16ce3-1da3-5e4a-ac27-0a0a55e6e84a");
13482
+ } catch (e2) {
13483
+ }
13484
+ })();
13485
+ function resolveStartTaskInProgressStatus(statusRegistry) {
13486
+ return normalizeStatusInputWithRegistry("in_progress", statusRegistry) ?? statusRegistry.open_status;
13487
+ }
13488
+
11659
13489
  export {
11660
- resolveStartTaskInProgressStatus,
13490
+ deriveTelemetryCommandTaxonomy,
13491
+ deriveTelemetryCommandResolution,
13492
+ flushTelemetryQueueNow,
13493
+ startTelemetryCommand,
13494
+ finishTelemetryCommand,
13495
+ emitTelemetryErrorEvent,
13496
+ describeItemOwnershipConflict,
11661
13497
  runClaim,
11662
13498
  runClaimNext,
11663
13499
  runRelease,
11664
13500
  runContracts,
13501
+ runMeet,
13502
+ runEvent,
13503
+ runRemind,
11665
13504
  runGc,
11666
13505
  inspectHistoryAuthorStream,
11667
13506
  scanHistoryAuthorAttribution,
11668
13507
  runHealth,
11669
13508
  _testOnlyHealthCommand,
11670
- runMeet,
11671
- runEvent,
11672
- runRemind,
11673
13509
  runStats,
11674
13510
  TELEMETRY_SUBCOMMANDS,
11675
13511
  runTelemetry,
@@ -11690,6 +13526,7 @@ export {
11690
13526
  runTestRunsWorker,
11691
13527
  _testOnlyValidateCommand,
11692
13528
  runValidate,
11693
- runValidate2
13529
+ runValidate2,
13530
+ resolveStartTaskInProgressStatus
11694
13531
  };
11695
- //# sourceMappingURL=chunk-F3VC3GOV.js.map
13532
+ //# sourceMappingURL=chunk-JBW2S2C6.js.map