@unbrained/pm-cli 2026.6.9 → 2026.6.10

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 (506) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/dist/cli/bootstrap-args.js +4 -2
  3. package/dist/cli/bootstrap-args.js.map +1 -1
  4. package/dist/cli/commands/aggregate.d.ts +7 -0
  5. package/dist/cli/commands/aggregate.js +53 -12
  6. package/dist/cli/commands/aggregate.js.map +1 -1
  7. package/dist/cli/commands/close.d.ts +1 -0
  8. package/dist/cli/commands/close.js +106 -3
  9. package/dist/cli/commands/close.js.map +1 -1
  10. package/dist/cli/commands/completion.js +20 -7
  11. package/dist/cli/commands/completion.js.map +1 -1
  12. package/dist/cli/commands/context.d.ts +9 -0
  13. package/dist/cli/commands/context.js +149 -20
  14. package/dist/cli/commands/context.js.map +1 -1
  15. package/dist/cli/commands/create.d.ts +1 -0
  16. package/dist/cli/commands/create.js +5 -3
  17. package/dist/cli/commands/create.js.map +1 -1
  18. package/dist/cli/commands/extension.js +4 -2
  19. package/dist/cli/commands/extension.js.map +1 -1
  20. package/dist/cli/commands/health.js +44 -6
  21. package/dist/cli/commands/health.js.map +1 -1
  22. package/dist/cli/commands/history.js +6 -5
  23. package/dist/cli/commands/history.js.map +1 -1
  24. package/dist/cli/commands/linked-test-parsers.d.ts +1 -0
  25. package/dist/cli/commands/linked-test-parsers.js +289 -2
  26. package/dist/cli/commands/linked-test-parsers.js.map +1 -1
  27. package/dist/cli/commands/reindex.d.ts +1 -0
  28. package/dist/cli/commands/reindex.js +33 -4
  29. package/dist/cli/commands/reindex.js.map +1 -1
  30. package/dist/cli/commands/test.d.ts +6 -0
  31. package/dist/cli/commands/test.js +46 -5
  32. package/dist/cli/commands/test.js.map +1 -1
  33. package/dist/cli/extension-command-help.d.ts +1 -0
  34. package/dist/cli/extension-command-help.js +42 -2
  35. package/dist/cli/extension-command-help.js.map +1 -1
  36. package/dist/cli/extension-command-options.d.ts +2 -0
  37. package/dist/cli/extension-command-options.js +51 -2
  38. package/dist/cli/extension-command-options.js.map +1 -1
  39. package/dist/cli/main.js +26 -26
  40. package/dist/cli/main.js.map +1 -1
  41. package/dist/cli/register-list-query.js +3 -2
  42. package/dist/cli/register-list-query.js.map +1 -1
  43. package/dist/cli/register-mutation.js +4 -2
  44. package/dist/cli/register-mutation.js.map +1 -1
  45. package/dist/cli/register-operations.js +15 -6
  46. package/dist/cli/register-operations.js.map +1 -1
  47. package/dist/cli/registration-helpers.js +9 -2
  48. package/dist/cli/registration-helpers.js.map +1 -1
  49. package/dist/cli-bundle/chunks/activity-5QLX6DHN.js +16 -0
  50. package/dist/cli-bundle/chunks/{activity-RUJATACW.js → activity-W6TS5F2L.js} +11 -11
  51. package/dist/cli-bundle/chunks/{aggregate-IQ27NFBI.js → aggregate-NNJLKGEK.js} +64 -23
  52. package/dist/cli-bundle/chunks/aggregate-NNJLKGEK.js.map +7 -0
  53. package/dist/cli-bundle/chunks/{aggregate-TT7OCHHT.js → aggregate-UK2WJ4Z3.js} +65 -24
  54. package/dist/cli-bundle/chunks/aggregate-UK2WJ4Z3.js.map +1 -0
  55. package/dist/cli-bundle/chunks/{append-CWQZBUWV.js → append-7BS36Z2L.js} +8 -8
  56. package/dist/cli-bundle/chunks/{append-E7AJ5RTR.js → append-DHGTLUZW.js} +8 -8
  57. package/dist/cli-bundle/chunks/{chunk-FHUI7AXS.js → chunk-2MKBPWMK.js} +3 -3
  58. package/dist/cli-bundle/chunks/{chunk-42IULX44.js → chunk-344GDQTH.js} +2 -2
  59. package/dist/cli-bundle/chunks/{chunk-5MMLINZB.js → chunk-3VTWCBXL.js} +3 -3
  60. package/dist/cli-bundle/chunks/{chunk-NUGAWYEN.js → chunk-4CYHWHZU.js} +2 -2
  61. package/dist/cli-bundle/chunks/{chunk-T7NWFVOA.js → chunk-4H2NDEGJ.js} +7 -7
  62. package/dist/cli-bundle/chunks/{chunk-FKH7K6YP.js → chunk-5HH6QRH5.js} +9 -9
  63. package/dist/cli-bundle/chunks/{chunk-OPYA2HIU.js → chunk-5OMABP7I.js} +7 -7
  64. package/dist/cli-bundle/chunks/{chunk-RKCJ2JMA.js → chunk-6ADVKPVV.js} +7 -7
  65. package/dist/cli-bundle/chunks/{chunk-EFRHTZO4.js → chunk-6KQS23TX.js} +8 -8
  66. package/dist/cli-bundle/chunks/{chunk-YX5LAKFJ.js → chunk-6N46IM44.js} +2 -2
  67. package/dist/cli-bundle/chunks/{chunk-WQZCEEQN.js → chunk-6OSG3EMX.js} +157 -12
  68. package/dist/cli-bundle/chunks/chunk-6OSG3EMX.js.map +1 -0
  69. package/dist/cli-bundle/chunks/{chunk-CAXUGAAF.js → chunk-73PSHEMT.js} +8 -8
  70. package/dist/cli-bundle/chunks/{chunk-RE2JQJZJ.js → chunk-7DUVDW7C.js} +3 -3
  71. package/dist/cli-bundle/chunks/{chunk-U3Z4OCZC.js → chunk-7GYMMDDW.js} +2 -2
  72. package/dist/cli-bundle/chunks/{chunk-SAUXUI6U.js → chunk-7TW64BS5.js} +2 -2
  73. package/dist/cli-bundle/chunks/{chunk-T7B5VAKD.js → chunk-A6XVYNQJ.js} +13 -6
  74. package/dist/cli-bundle/chunks/chunk-A6XVYNQJ.js.map +7 -0
  75. package/dist/cli-bundle/chunks/{chunk-E7LOIIFP.js → chunk-ANVZCNL5.js} +3 -3
  76. package/dist/cli-bundle/chunks/{chunk-NJRZIJ4N.js → chunk-BE5G7HEL.js} +14 -8
  77. package/dist/cli-bundle/chunks/chunk-BE5G7HEL.js.map +1 -0
  78. package/dist/cli-bundle/chunks/{chunk-RLVI7KDW.js → chunk-CMEHZD6G.js} +163 -11
  79. package/dist/cli-bundle/chunks/chunk-CMEHZD6G.js.map +7 -0
  80. package/dist/cli-bundle/chunks/{chunk-D5D7VKIC.js → chunk-CTW7QAHM.js} +6 -5
  81. package/dist/cli-bundle/chunks/chunk-CTW7QAHM.js.map +1 -0
  82. package/dist/cli-bundle/chunks/{chunk-KTVXLI54.js → chunk-D6JZBUZ6.js} +7 -7
  83. package/dist/cli-bundle/chunks/{chunk-I26E6XA7.js → chunk-DEYNERFX.js} +8 -6
  84. package/dist/cli-bundle/chunks/chunk-DEYNERFX.js.map +1 -0
  85. package/dist/cli-bundle/chunks/{chunk-YI6W2DBN.js → chunk-DMDEC4QP.js} +6 -6
  86. package/dist/cli-bundle/chunks/{chunk-AM2AXVFS.js → chunk-DTRIVUTN.js} +5 -5
  87. package/dist/cli-bundle/chunks/{chunk-I4FGL3K2.js → chunk-EAQLLID6.js} +16 -6
  88. package/dist/cli-bundle/chunks/chunk-EAQLLID6.js.map +1 -0
  89. package/dist/cli-bundle/chunks/{chunk-JEGFLKSI.js → chunk-EIS32UA4.js} +2 -2
  90. package/dist/cli-bundle/chunks/chunk-F2PVV7IX.js +528 -0
  91. package/dist/cli-bundle/chunks/chunk-F2PVV7IX.js.map +7 -0
  92. package/dist/cli-bundle/chunks/{chunk-4LRVXVJK.js → chunk-GF5XIBUH.js} +70 -9
  93. package/dist/cli-bundle/chunks/chunk-GF5XIBUH.js.map +7 -0
  94. package/dist/cli-bundle/chunks/{chunk-PUSOAQCR.js → chunk-GP6SHEAI.js} +5 -5
  95. package/dist/cli-bundle/chunks/{chunk-I3UILOUU.js → chunk-GRHPU6EM.js} +2 -2
  96. package/dist/cli-bundle/chunks/{chunk-WCWIDJII.js → chunk-I2FM2SMO.js} +2 -2
  97. package/dist/cli-bundle/chunks/{chunk-ANKG2JKL.js → chunk-IEQ3N7WP.js} +12 -5
  98. package/dist/cli-bundle/chunks/chunk-IEQ3N7WP.js.map +1 -0
  99. package/dist/cli-bundle/chunks/{chunk-JN3BT7UY.js → chunk-K45NAJV2.js} +9 -9
  100. package/dist/cli-bundle/chunks/{chunk-23WNCJBA.js → chunk-K7SXBA75.js} +2 -2
  101. package/dist/cli-bundle/chunks/{chunk-FJNJEWU4.js → chunk-KHBRV5JU.js} +14 -12
  102. package/dist/cli-bundle/chunks/chunk-KHBRV5JU.js.map +1 -0
  103. package/dist/cli-bundle/chunks/{chunk-7YTWXGE3.js → chunk-KMMUDSSB.js} +112 -7
  104. package/dist/cli-bundle/chunks/chunk-KMMUDSSB.js.map +1 -0
  105. package/dist/cli-bundle/chunks/{chunk-JVMAOD54.js → chunk-KRZQGRVL.js} +14 -7
  106. package/dist/cli-bundle/chunks/chunk-KRZQGRVL.js.map +1 -0
  107. package/dist/cli-bundle/chunks/{chunk-BACSNVWE.js → chunk-LUJQJR7G.js} +71 -69
  108. package/dist/cli-bundle/chunks/{chunk-BACSNVWE.js.map → chunk-LUJQJR7G.js.map} +1 -1
  109. package/dist/cli-bundle/chunks/{chunk-P2NVFE4L.js → chunk-LYL32FT6.js} +3 -3
  110. package/dist/cli-bundle/chunks/{chunk-AVGOVJGV.js → chunk-MF6KSSMF.js} +9 -9
  111. package/dist/cli-bundle/chunks/{chunk-AVGOVJGV.js.map → chunk-MF6KSSMF.js.map} +1 -1
  112. package/dist/cli-bundle/chunks/{chunk-ZPXDD6RQ.js → chunk-O64EYNHF.js} +6 -6
  113. package/dist/cli-bundle/chunks/{chunk-C72IQIBT.js → chunk-OQGJSCZZ.js} +301 -30
  114. package/dist/cli-bundle/chunks/chunk-OQGJSCZZ.js.map +7 -0
  115. package/dist/cli-bundle/chunks/{chunk-44JP4PYY.js → chunk-OROMGSBP.js} +2 -2
  116. package/dist/cli-bundle/chunks/{chunk-LU54Z4QI.js → chunk-OSGWBWLK.js} +76 -74
  117. package/dist/cli-bundle/chunks/{chunk-LU54Z4QI.js.map → chunk-OSGWBWLK.js.map} +3 -3
  118. package/dist/cli-bundle/chunks/{chunk-OT6XAMO5.js → chunk-OVNSQHDG.js} +7 -5
  119. package/dist/cli-bundle/chunks/{chunk-OT6XAMO5.js.map → chunk-OVNSQHDG.js.map} +2 -2
  120. package/dist/cli-bundle/chunks/{chunk-PW7C262O.js → chunk-PYULT32I.js} +2 -2
  121. package/dist/cli-bundle/chunks/{chunk-NHRZSYAA.js → chunk-Q6PSD5DZ.js} +3 -3
  122. package/dist/cli-bundle/chunks/{chunk-A5342JVL.js → chunk-QGIWURY3.js} +12 -12
  123. package/dist/cli-bundle/chunks/{chunk-GPOSGWCN.js → chunk-QJ2OIEOC.js} +68 -7
  124. package/dist/cli-bundle/chunks/chunk-QJ2OIEOC.js.map +1 -0
  125. package/dist/cli-bundle/chunks/{chunk-5ATRWEZO.js → chunk-SNASEDXB.js} +3 -3
  126. package/dist/cli-bundle/chunks/{chunk-KDX6VC3P.js → chunk-T6QLB34N.js} +3 -3
  127. package/dist/cli-bundle/chunks/{chunk-6IGTNFE3.js → chunk-TALBUVWF.js} +2 -2
  128. package/dist/cli-bundle/chunks/{chunk-VDVVOLR6.js → chunk-TV6FZGVK.js} +3 -3
  129. package/dist/cli-bundle/chunks/{chunk-H37YPWLM.js → chunk-TXWMLDMG.js} +13 -7
  130. package/dist/cli-bundle/chunks/chunk-TXWMLDMG.js.map +7 -0
  131. package/dist/cli-bundle/chunks/{chunk-TLD3UYGY.js → chunk-TZLGCTA5.js} +5 -4
  132. package/dist/cli-bundle/chunks/chunk-TZLGCTA5.js.map +7 -0
  133. package/dist/cli-bundle/chunks/{chunk-7CR4GAYN.js → chunk-UDWUDUJI.js} +2 -2
  134. package/dist/cli-bundle/chunks/{chunk-YSANBZAE.js → chunk-UMWF6ZAS.js} +12 -5
  135. package/dist/cli-bundle/chunks/chunk-UMWF6ZAS.js.map +7 -0
  136. package/dist/cli-bundle/chunks/{chunk-F2REA7VW.js → chunk-UNH3KSHG.js} +3 -3
  137. package/dist/cli-bundle/chunks/{chunk-4TJWRPIH.js → chunk-UY26RIBR.js} +2 -2
  138. package/dist/cli-bundle/chunks/{chunk-MNXJ6YDO.js → chunk-VSS3CSTF.js} +9 -9
  139. package/dist/cli-bundle/chunks/{chunk-EQ6N6IDR.js → chunk-WBU257Z4.js} +13 -11
  140. package/dist/cli-bundle/chunks/chunk-WBU257Z4.js.map +7 -0
  141. package/dist/cli-bundle/chunks/{chunk-5JF76OJF.js → chunk-WNMRICXH.js} +289 -25
  142. package/dist/cli-bundle/chunks/chunk-WNMRICXH.js.map +1 -0
  143. package/dist/cli-bundle/chunks/chunk-WSWOQP3Z.js +518 -0
  144. package/dist/cli-bundle/chunks/chunk-WSWOQP3Z.js.map +1 -0
  145. package/dist/cli-bundle/chunks/{chunk-ENCVPOID.js → chunk-WWEFBBVF.js} +12 -12
  146. package/dist/cli-bundle/chunks/{chunk-XEOO6K5J.js → chunk-X3IPJU2O.js} +9 -9
  147. package/dist/cli-bundle/chunks/{chunk-RMTI5R76.js → chunk-X5YC5DZM.js} +111 -6
  148. package/dist/cli-bundle/chunks/chunk-X5YC5DZM.js.map +7 -0
  149. package/dist/cli-bundle/chunks/{chunk-3RHE76G6.js → chunk-XH6RA5A5.js} +15 -15
  150. package/dist/cli-bundle/chunks/chunk-XH6RA5A5.js.map +1 -0
  151. package/dist/cli-bundle/chunks/{chunk-LF2VNLEZ.js → chunk-XRE4CTNP.js} +8 -8
  152. package/dist/cli-bundle/chunks/{chunk-LF2VNLEZ.js.map → chunk-XRE4CTNP.js.map} +2 -2
  153. package/dist/cli-bundle/chunks/{chunk-SD6H3RLA.js → chunk-XSCGU4WT.js} +15 -5
  154. package/dist/cli-bundle/chunks/{chunk-SD6H3RLA.js.map → chunk-XSCGU4WT.js.map} +2 -2
  155. package/dist/cli-bundle/chunks/{chunk-BIRVSIM2.js → chunk-ZH7C7ZVX.js} +14 -14
  156. package/dist/cli-bundle/chunks/chunk-ZH7C7ZVX.js.map +7 -0
  157. package/dist/cli-bundle/chunks/{claim-UXFGCF3P.js → claim-3TY5LE54.js} +10 -10
  158. package/dist/cli-bundle/chunks/{claim-RV6WYUF7.js → claim-LM4YY6QQ.js} +10 -10
  159. package/dist/cli-bundle/chunks/{close-O4JK2JKD.js → close-CSD4LEMT.js} +8 -8
  160. package/dist/cli-bundle/chunks/close-SIQCDOBR.js +13 -0
  161. package/dist/cli-bundle/chunks/{close-many-EQO4TPIE.js → close-many-B5SHDX6W.js} +15 -15
  162. package/dist/cli-bundle/chunks/{close-many-SRDBV3SI.js → close-many-WRXB5KVY.js} +15 -15
  163. package/dist/cli-bundle/chunks/{comments-OMB7YE27.js → comments-A5ALOYTG.js} +10 -10
  164. package/dist/cli-bundle/chunks/{comments-TTZUIB2O.js → comments-BDDEK3VW.js} +10 -10
  165. package/dist/cli-bundle/chunks/{config-5VPR42A6.js → config-W2NHDNQT.js} +8 -8
  166. package/dist/cli-bundle/chunks/{config-NNLXVGVC.js → config-YUYBMJOW.js} +8 -8
  167. package/dist/cli-bundle/chunks/{context-4QK6GRXO.js → context-LRJ74NSU.js} +146 -33
  168. package/dist/cli-bundle/chunks/{context-4QK6GRXO.js.map → context-LRJ74NSU.js.map} +2 -2
  169. package/dist/cli-bundle/chunks/{context-4N7GYTVQ.js → context-R2QLOJCK.js} +147 -34
  170. package/dist/cli-bundle/chunks/context-R2QLOJCK.js.map +1 -0
  171. package/dist/cli-bundle/chunks/{contracts-AOBNEBVT.js → contracts-47X7RYUF.js} +4 -4
  172. package/dist/cli-bundle/chunks/{contracts-DXCWXOSP.js → contracts-HJHR4NCD.js} +4 -4
  173. package/dist/cli-bundle/chunks/{copy-XSYEQTLA.js → copy-B7HFOWFB.js} +7 -7
  174. package/dist/cli-bundle/chunks/{copy-5NM3SVJA.js → copy-P4UVYZ7M.js} +7 -7
  175. package/dist/cli-bundle/chunks/{create-FCCAATQV.js → create-5ERJF64D.js} +13 -13
  176. package/dist/cli-bundle/chunks/create-TXNRPS4K.js +27 -0
  177. package/dist/cli-bundle/chunks/{delete-5JFP6OG7.js → delete-LX3LGBCH.js} +7 -7
  178. package/dist/cli-bundle/chunks/{delete-PQXJQXQ7.js → delete-S3WVK6LP.js} +7 -7
  179. package/dist/cli-bundle/chunks/{deps-XXKBOQUA.js → deps-GWSNH7OZ.js} +7 -7
  180. package/dist/cli-bundle/chunks/{deps-S5322EOQ.js → deps-YSM4LZQD.js} +7 -7
  181. package/dist/cli-bundle/chunks/{docs-DZRPAW5S.js → docs-7RYFBHQD.js} +9 -9
  182. package/dist/cli-bundle/chunks/{docs-C7CCVWAJ.js → docs-TG6JMVMY.js} +9 -9
  183. package/dist/cli-bundle/chunks/{extension-CSHP6FZX.js → extension-R3LUKMX7.js} +5 -5
  184. package/dist/cli-bundle/chunks/{extension-XNNVUVAY.js → extension-VNMRKIHI.js} +5 -5
  185. package/dist/cli-bundle/chunks/{files-OBWYYPKM.js → files-KAKU57OT.js} +9 -9
  186. package/dist/cli-bundle/chunks/{files-UPCNKEIZ.js → files-QB3EYPMO.js} +9 -9
  187. package/dist/cli-bundle/chunks/{gc-KXK6KBRN.js → gc-B747VM4M.js} +3 -3
  188. package/dist/cli-bundle/chunks/{gc-FA2ONELT.js → gc-KNUPLPSW.js} +3 -3
  189. package/dist/cli-bundle/chunks/{get-PNTSONGB.js → get-GMGLIQ5I.js} +11 -11
  190. package/dist/cli-bundle/chunks/{get-FLHYTOBA.js → get-SBL6NHYQ.js} +11 -11
  191. package/dist/cli-bundle/chunks/{health-CS5RNTJX.js → health-IG43Z4KL.js} +47 -19
  192. package/dist/cli-bundle/chunks/health-IG43Z4KL.js.map +1 -0
  193. package/dist/cli-bundle/chunks/{health-KCRVYIYY.js → health-WWZJ5KJS.js} +46 -18
  194. package/dist/cli-bundle/chunks/health-WWZJ5KJS.js.map +7 -0
  195. package/dist/cli-bundle/chunks/history-6UKSZTRT.js +20 -0
  196. package/dist/cli-bundle/chunks/{history-COQTPBEU.js → history-XCWRXBXC.js} +10 -10
  197. package/dist/cli-bundle/chunks/{history-compact-66PSRYL3.js → history-compact-IDH7E7VN.js} +11 -11
  198. package/dist/cli-bundle/chunks/{history-compact-PVS2A3FS.js → history-compact-KICKUCR7.js} +11 -11
  199. package/dist/cli-bundle/chunks/history-redact-HKYBTK6X.js +19 -0
  200. package/dist/cli-bundle/chunks/{history-redact-DCXAWGTF.js → history-redact-JJWH3QWK.js} +11 -11
  201. package/dist/cli-bundle/chunks/{history-repair-TA3NRIFO.js → history-repair-7HWBZKXN.js} +11 -11
  202. package/dist/cli-bundle/chunks/{history-repair-SEQDFTGW.js → history-repair-N5HXKJOI.js} +11 -11
  203. package/dist/cli-bundle/chunks/init-27JLDUO2.js +17 -0
  204. package/dist/cli-bundle/chunks/{init-IQJE3EKJ.js → init-OQA3TWIS.js} +9 -9
  205. package/dist/cli-bundle/chunks/{learnings-XC6EMW5E.js → learnings-L7VQUSVI.js} +10 -10
  206. package/dist/cli-bundle/chunks/{learnings-RJPGH2ME.js → learnings-Z4GAIZQ5.js} +10 -10
  207. package/dist/cli-bundle/chunks/list-6U3CJVXS.js +19 -0
  208. package/dist/cli-bundle/chunks/{list-NJV6WBT4.js → list-W5ROBC5U.js} +10 -10
  209. package/dist/cli-bundle/chunks/{notes-2KWHADK3.js → notes-JJDOEDFK.js} +10 -10
  210. package/dist/cli-bundle/chunks/{notes-FNCDMZW2.js → notes-SDCK7BEN.js} +10 -10
  211. package/dist/cli-bundle/chunks/{plan-MQO5JTSV.js → plan-H5HYHMBB.js} +13 -13
  212. package/dist/cli-bundle/chunks/{plan-CYK2P5PD.js → plan-W2B5RYR3.js} +13 -13
  213. package/dist/cli-bundle/chunks/{register-list-query-IO3RR5K6.js → register-list-query-QGRFMDWA.js} +20 -20
  214. package/dist/cli-bundle/chunks/register-list-query-QGRFMDWA.js.map +7 -0
  215. package/dist/cli-bundle/chunks/{register-list-query-6RA24SIZ.js → register-list-query-V4S23735.js} +21 -21
  216. package/dist/cli-bundle/chunks/register-list-query-V4S23735.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{register-mutation-VV2SC2KL.js → register-mutation-I57PLUHA.js} +36 -35
  218. package/dist/cli-bundle/chunks/register-mutation-I57PLUHA.js.map +1 -0
  219. package/dist/cli-bundle/chunks/{register-mutation-KVFUXCAZ.js → register-mutation-ZPZNJXSA.js} +35 -34
  220. package/dist/cli-bundle/chunks/register-mutation-ZPZNJXSA.js.map +7 -0
  221. package/dist/cli-bundle/chunks/{register-operations-DFNVRSJ5.js → register-operations-KAMLXAF5.js} +42 -37
  222. package/dist/cli-bundle/chunks/register-operations-KAMLXAF5.js.map +1 -0
  223. package/dist/cli-bundle/chunks/{register-operations-TAUUTRJ4.js → register-operations-YEN4YEZ2.js} +41 -36
  224. package/dist/cli-bundle/chunks/register-operations-YEN4YEZ2.js.map +7 -0
  225. package/dist/cli-bundle/chunks/{register-setup-GAQZZRUA.js → register-setup-BZ3TNE3G.js} +15 -15
  226. package/dist/cli-bundle/chunks/{register-setup-X2R5CFDV.js → register-setup-WLFL3OUF.js} +15 -15
  227. package/dist/cli-bundle/chunks/restore-GNI2W5CN.js +17 -0
  228. package/dist/cli-bundle/chunks/{restore-E3GZKRRK.js → restore-RGFSPG4K.js} +11 -11
  229. package/dist/cli-bundle/chunks/{schema-3CPFLDAY.js → schema-CCDU3RLC.js} +8 -8
  230. package/dist/cli-bundle/chunks/{schema-7EHBPNXM.js → schema-KZASL323.js} +8 -8
  231. package/dist/cli-bundle/chunks/{search-OBZVYJJ2.js → search-7KSOLI2E.js} +10 -10
  232. package/dist/cli-bundle/chunks/{search-2T3NCCUR.js → search-DTL7CO22.js} +10 -10
  233. package/dist/cli-bundle/chunks/{stats-ULGQACF7.js → stats-IOXQMGI6.js} +7 -7
  234. package/dist/cli-bundle/chunks/{stats-6LVK4JER.js → stats-QNV7B2CE.js} +7 -7
  235. package/dist/cli-bundle/chunks/{telemetry-6G27FLCP.js → telemetry-IV5C6JOM.js} +4 -4
  236. package/dist/cli-bundle/chunks/{telemetry-HHKRTMZA.js → telemetry-NHR5RFXT.js} +4 -4
  237. package/dist/cli-bundle/chunks/test-4Z37CXW4.js +32 -0
  238. package/dist/cli-bundle/chunks/{test-2PP4YBV6.js → test-PIL2CEEB.js} +14 -14
  239. package/dist/cli-bundle/chunks/{test-all-NETGVNM6.js → test-all-GRLYHBNP.js} +14 -14
  240. package/dist/cli-bundle/chunks/{test-all-6Z272JRI.js → test-all-MFN4MYCV.js} +14 -14
  241. package/dist/cli-bundle/chunks/{test-runs-CRPQVMMG.js → test-runs-7LRFWWCA.js} +5 -5
  242. package/dist/cli-bundle/chunks/{test-runs-M24WA6TI.js → test-runs-7WCSC3TY.js} +5 -5
  243. package/dist/cli-bundle/chunks/update-I4G34LKJ.js +21 -0
  244. package/dist/cli-bundle/chunks/update-VI5DBZ3G.js +25 -0
  245. package/dist/cli-bundle/chunks/{update-many-JSRF5EH5.js → update-many-LOTAYUTN.js} +22 -22
  246. package/dist/cli-bundle/chunks/{update-many-Y3HOL7WA.js → update-many-UYMTVF42.js} +22 -22
  247. package/dist/cli-bundle/chunks/{upgrade-ECB6GH3M.js → upgrade-LT2MLLPS.js} +5 -5
  248. package/dist/cli-bundle/chunks/{upgrade-5RTQVKKE.js → upgrade-ZZSC7CLV.js} +5 -5
  249. package/dist/cli-bundle/chunks/{validate-J6Q444SD.js → validate-3XRORNMP.js} +16 -16
  250. package/dist/cli-bundle/chunks/{validate-MCNMAXVA.js → validate-IQIQSKUX.js} +16 -16
  251. package/dist/cli-bundle/main.js +132 -44
  252. package/dist/cli-bundle/main.js.map +2 -2
  253. package/dist/core/diagnostics/remediation.js +12 -2
  254. package/dist/core/diagnostics/remediation.js.map +1 -1
  255. package/dist/core/extensions/extension-policy.d.ts +14 -1
  256. package/dist/core/extensions/extension-policy.js +38 -3
  257. package/dist/core/extensions/extension-policy.js.map +1 -1
  258. package/dist/core/extensions/extension-types.d.ts +40 -1
  259. package/dist/core/extensions/extension-types.js +28 -2
  260. package/dist/core/extensions/extension-types.js.map +1 -1
  261. package/dist/core/extensions/loader.d.ts +6 -4
  262. package/dist/core/extensions/loader.js +67 -14
  263. package/dist/core/extensions/loader.js.map +1 -1
  264. package/dist/core/history/replay.d.ts +1 -1
  265. package/dist/core/history/replay.js +13 -4
  266. package/dist/core/history/replay.js.map +1 -1
  267. package/dist/core/output/mutation-projection.d.ts +2 -0
  268. package/dist/core/output/mutation-projection.js +9 -2
  269. package/dist/core/output/mutation-projection.js.map +1 -1
  270. package/dist/core/output/output.d.ts +2 -0
  271. package/dist/core/output/output.js +7 -3
  272. package/dist/core/output/output.js.map +1 -1
  273. package/dist/core/shared/command-types.d.ts +1 -0
  274. package/dist/core/shared/command-types.js +2 -2
  275. package/dist/core/shared/command-types.js.map +1 -1
  276. package/dist/core/shared/constants.js +7 -4
  277. package/dist/core/shared/constants.js.map +1 -1
  278. package/dist/core/store/item-store.d.ts +1 -1
  279. package/dist/core/store/item-store.js +3 -3
  280. package/dist/core/store/item-store.js.map +1 -1
  281. package/dist/core/store/settings-read-cache.d.ts +15 -0
  282. package/dist/core/store/settings-read-cache.js +72 -0
  283. package/dist/core/store/settings-read-cache.js.map +1 -0
  284. package/dist/core/store/settings-validator.d.ts +4 -1
  285. package/dist/core/store/settings-validator.js +14 -2
  286. package/dist/core/store/settings-validator.js.map +1 -1
  287. package/dist/core/store/settings.js +166 -16
  288. package/dist/core/store/settings.js.map +1 -1
  289. package/dist/core/telemetry/runtime.d.ts +1 -0
  290. package/dist/core/telemetry/runtime.js +3 -3
  291. package/dist/core/telemetry/runtime.js.map +1 -1
  292. package/dist/core/test/run-selectors.d.ts +27 -0
  293. package/dist/core/test/run-selectors.js +110 -0
  294. package/dist/core/test/run-selectors.js.map +1 -0
  295. package/dist/mcp/server.js +50 -11
  296. package/dist/mcp/server.js.map +1 -1
  297. package/dist/sdk/cli-contracts/commander-mutation-options.js +3 -2
  298. package/dist/sdk/cli-contracts/commander-mutation-options.js.map +1 -1
  299. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  300. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  301. package/dist/sdk/cli-contracts/tool-parameter-tables.js +29 -2
  302. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  303. package/dist/sdk/cli-contracts.js +37 -5
  304. package/dist/sdk/cli-contracts.js.map +1 -1
  305. package/dist/sdk/index.d.ts +1 -1
  306. package/dist/sdk/index.js +2 -2
  307. package/dist/sdk/index.js.map +1 -1
  308. package/dist/sdk/runtime.d.ts +6 -0
  309. package/dist/sdk/runtime.js +51 -3
  310. package/dist/sdk/runtime.js.map +1 -1
  311. package/dist/types.d.ts +4 -1
  312. package/dist/types.js +4 -2
  313. package/dist/types.js.map +1 -1
  314. package/docs/AGENT_GUIDE.md +7 -1
  315. package/docs/ARCHITECTURE.md +7 -0
  316. package/docs/COMMANDS.md +37 -3
  317. package/docs/CONFIGURATION.md +1 -1
  318. package/docs/EXTENSIONS.md +55 -53
  319. package/docs/SDK.md +8 -2
  320. package/docs/TESTING.md +60 -0
  321. package/docs/schemas/extension-manifest.schema.json +120 -0
  322. package/package.json +2 -2
  323. package/packages/pm-beads/extensions/beads/manifest.json +10 -0
  324. package/packages/pm-calendar/extensions/calendar/manifest.json +10 -0
  325. package/packages/pm-command-kit/README.md +72 -0
  326. package/packages/pm-command-kit/extensions/command-kit/index.js +181 -0
  327. package/packages/pm-command-kit/extensions/command-kit/index.ts +176 -0
  328. package/packages/pm-command-kit/extensions/command-kit/manifest.json +22 -0
  329. package/packages/pm-command-kit/package.json +53 -0
  330. package/packages/pm-governance-audit/extensions/governance-audit/manifest.json +10 -0
  331. package/packages/pm-guide-shell/extensions/guide-shell/manifest.json +10 -0
  332. package/packages/pm-lifecycle-hooks/extensions/lifecycle-hooks/manifest.json +10 -0
  333. package/packages/pm-linked-test-adapters/extensions/linked-test-adapters/manifest.json +10 -0
  334. package/packages/pm-search-advanced/extensions/search-advanced/index.js +6 -0
  335. package/packages/pm-search-advanced/extensions/search-advanced/index.ts +6 -0
  336. package/packages/pm-search-advanced/extensions/search-advanced/manifest.json +10 -0
  337. package/packages/pm-search-advanced/extensions/search-advanced/runtime.js +1 -0
  338. package/packages/pm-search-advanced/extensions/search-advanced/runtime.ts +1 -0
  339. package/packages/pm-templates/extensions/templates/manifest.json +10 -0
  340. package/packages/pm-todos/extensions/todos/manifest.json +10 -0
  341. package/dist/cli-bundle/chunks/activity-HF3VJYKH.js +0 -16
  342. package/dist/cli-bundle/chunks/aggregate-IQ27NFBI.js.map +0 -7
  343. package/dist/cli-bundle/chunks/aggregate-TT7OCHHT.js.map +0 -1
  344. package/dist/cli-bundle/chunks/chunk-3RHE76G6.js.map +0 -1
  345. package/dist/cli-bundle/chunks/chunk-4LRVXVJK.js.map +0 -7
  346. package/dist/cli-bundle/chunks/chunk-5JF76OJF.js.map +0 -1
  347. package/dist/cli-bundle/chunks/chunk-7YTWXGE3.js.map +0 -1
  348. package/dist/cli-bundle/chunks/chunk-ANKG2JKL.js.map +0 -1
  349. package/dist/cli-bundle/chunks/chunk-BIRVSIM2.js.map +0 -7
  350. package/dist/cli-bundle/chunks/chunk-C72IQIBT.js.map +0 -7
  351. package/dist/cli-bundle/chunks/chunk-D5D7VKIC.js.map +0 -1
  352. package/dist/cli-bundle/chunks/chunk-EQ6N6IDR.js.map +0 -7
  353. package/dist/cli-bundle/chunks/chunk-FJNJEWU4.js.map +0 -1
  354. package/dist/cli-bundle/chunks/chunk-GPOSGWCN.js.map +0 -1
  355. package/dist/cli-bundle/chunks/chunk-H37YPWLM.js.map +0 -7
  356. package/dist/cli-bundle/chunks/chunk-I26E6XA7.js.map +0 -1
  357. package/dist/cli-bundle/chunks/chunk-I4FGL3K2.js.map +0 -1
  358. package/dist/cli-bundle/chunks/chunk-JVMAOD54.js.map +0 -1
  359. package/dist/cli-bundle/chunks/chunk-LU2HE272.js +0 -242
  360. package/dist/cli-bundle/chunks/chunk-LU2HE272.js.map +0 -1
  361. package/dist/cli-bundle/chunks/chunk-NJRZIJ4N.js.map +0 -1
  362. package/dist/cli-bundle/chunks/chunk-O4L7Z6LB.js +0 -252
  363. package/dist/cli-bundle/chunks/chunk-O4L7Z6LB.js.map +0 -7
  364. package/dist/cli-bundle/chunks/chunk-RLVI7KDW.js.map +0 -7
  365. package/dist/cli-bundle/chunks/chunk-RMTI5R76.js.map +0 -7
  366. package/dist/cli-bundle/chunks/chunk-T7B5VAKD.js.map +0 -7
  367. package/dist/cli-bundle/chunks/chunk-TLD3UYGY.js.map +0 -7
  368. package/dist/cli-bundle/chunks/chunk-WQZCEEQN.js.map +0 -1
  369. package/dist/cli-bundle/chunks/chunk-YSANBZAE.js.map +0 -7
  370. package/dist/cli-bundle/chunks/close-JTTGW7TS.js +0 -13
  371. package/dist/cli-bundle/chunks/context-4N7GYTVQ.js.map +0 -1
  372. package/dist/cli-bundle/chunks/create-JAPLFDGJ.js +0 -27
  373. package/dist/cli-bundle/chunks/health-CS5RNTJX.js.map +0 -1
  374. package/dist/cli-bundle/chunks/health-KCRVYIYY.js.map +0 -7
  375. package/dist/cli-bundle/chunks/history-6624XISO.js +0 -20
  376. package/dist/cli-bundle/chunks/history-redact-ZRQTI7NB.js +0 -19
  377. package/dist/cli-bundle/chunks/init-ZVE2HMKK.js +0 -17
  378. package/dist/cli-bundle/chunks/list-OO5P472O.js +0 -19
  379. package/dist/cli-bundle/chunks/register-list-query-6RA24SIZ.js.map +0 -1
  380. package/dist/cli-bundle/chunks/register-list-query-IO3RR5K6.js.map +0 -7
  381. package/dist/cli-bundle/chunks/register-mutation-KVFUXCAZ.js.map +0 -7
  382. package/dist/cli-bundle/chunks/register-mutation-VV2SC2KL.js.map +0 -1
  383. package/dist/cli-bundle/chunks/register-operations-DFNVRSJ5.js.map +0 -1
  384. package/dist/cli-bundle/chunks/register-operations-TAUUTRJ4.js.map +0 -7
  385. package/dist/cli-bundle/chunks/restore-F4ALFV4D.js +0 -17
  386. package/dist/cli-bundle/chunks/test-PPOLRIBA.js +0 -32
  387. package/dist/cli-bundle/chunks/update-MCPCPMHV.js +0 -25
  388. package/dist/cli-bundle/chunks/update-O7TBOUVQ.js +0 -21
  389. /package/dist/cli-bundle/chunks/{activity-HF3VJYKH.js.map → activity-5QLX6DHN.js.map} +0 -0
  390. /package/dist/cli-bundle/chunks/{activity-RUJATACW.js.map → activity-W6TS5F2L.js.map} +0 -0
  391. /package/dist/cli-bundle/chunks/{append-CWQZBUWV.js.map → append-7BS36Z2L.js.map} +0 -0
  392. /package/dist/cli-bundle/chunks/{append-E7AJ5RTR.js.map → append-DHGTLUZW.js.map} +0 -0
  393. /package/dist/cli-bundle/chunks/{chunk-FHUI7AXS.js.map → chunk-2MKBPWMK.js.map} +0 -0
  394. /package/dist/cli-bundle/chunks/{chunk-42IULX44.js.map → chunk-344GDQTH.js.map} +0 -0
  395. /package/dist/cli-bundle/chunks/{chunk-5MMLINZB.js.map → chunk-3VTWCBXL.js.map} +0 -0
  396. /package/dist/cli-bundle/chunks/{chunk-NUGAWYEN.js.map → chunk-4CYHWHZU.js.map} +0 -0
  397. /package/dist/cli-bundle/chunks/{chunk-T7NWFVOA.js.map → chunk-4H2NDEGJ.js.map} +0 -0
  398. /package/dist/cli-bundle/chunks/{chunk-FKH7K6YP.js.map → chunk-5HH6QRH5.js.map} +0 -0
  399. /package/dist/cli-bundle/chunks/{chunk-OPYA2HIU.js.map → chunk-5OMABP7I.js.map} +0 -0
  400. /package/dist/cli-bundle/chunks/{chunk-RKCJ2JMA.js.map → chunk-6ADVKPVV.js.map} +0 -0
  401. /package/dist/cli-bundle/chunks/{chunk-EFRHTZO4.js.map → chunk-6KQS23TX.js.map} +0 -0
  402. /package/dist/cli-bundle/chunks/{chunk-YX5LAKFJ.js.map → chunk-6N46IM44.js.map} +0 -0
  403. /package/dist/cli-bundle/chunks/{chunk-CAXUGAAF.js.map → chunk-73PSHEMT.js.map} +0 -0
  404. /package/dist/cli-bundle/chunks/{chunk-RE2JQJZJ.js.map → chunk-7DUVDW7C.js.map} +0 -0
  405. /package/dist/cli-bundle/chunks/{chunk-U3Z4OCZC.js.map → chunk-7GYMMDDW.js.map} +0 -0
  406. /package/dist/cli-bundle/chunks/{chunk-SAUXUI6U.js.map → chunk-7TW64BS5.js.map} +0 -0
  407. /package/dist/cli-bundle/chunks/{chunk-E7LOIIFP.js.map → chunk-ANVZCNL5.js.map} +0 -0
  408. /package/dist/cli-bundle/chunks/{chunk-KTVXLI54.js.map → chunk-D6JZBUZ6.js.map} +0 -0
  409. /package/dist/cli-bundle/chunks/{chunk-YI6W2DBN.js.map → chunk-DMDEC4QP.js.map} +0 -0
  410. /package/dist/cli-bundle/chunks/{chunk-AM2AXVFS.js.map → chunk-DTRIVUTN.js.map} +0 -0
  411. /package/dist/cli-bundle/chunks/{chunk-JEGFLKSI.js.map → chunk-EIS32UA4.js.map} +0 -0
  412. /package/dist/cli-bundle/chunks/{chunk-PUSOAQCR.js.map → chunk-GP6SHEAI.js.map} +0 -0
  413. /package/dist/cli-bundle/chunks/{chunk-I3UILOUU.js.map → chunk-GRHPU6EM.js.map} +0 -0
  414. /package/dist/cli-bundle/chunks/{chunk-WCWIDJII.js.map → chunk-I2FM2SMO.js.map} +0 -0
  415. /package/dist/cli-bundle/chunks/{chunk-JN3BT7UY.js.map → chunk-K45NAJV2.js.map} +0 -0
  416. /package/dist/cli-bundle/chunks/{chunk-23WNCJBA.js.map → chunk-K7SXBA75.js.map} +0 -0
  417. /package/dist/cli-bundle/chunks/{chunk-P2NVFE4L.js.map → chunk-LYL32FT6.js.map} +0 -0
  418. /package/dist/cli-bundle/chunks/{chunk-ZPXDD6RQ.js.map → chunk-O64EYNHF.js.map} +0 -0
  419. /package/dist/cli-bundle/chunks/{chunk-44JP4PYY.js.map → chunk-OROMGSBP.js.map} +0 -0
  420. /package/dist/cli-bundle/chunks/{chunk-PW7C262O.js.map → chunk-PYULT32I.js.map} +0 -0
  421. /package/dist/cli-bundle/chunks/{chunk-NHRZSYAA.js.map → chunk-Q6PSD5DZ.js.map} +0 -0
  422. /package/dist/cli-bundle/chunks/{chunk-A5342JVL.js.map → chunk-QGIWURY3.js.map} +0 -0
  423. /package/dist/cli-bundle/chunks/{chunk-5ATRWEZO.js.map → chunk-SNASEDXB.js.map} +0 -0
  424. /package/dist/cli-bundle/chunks/{chunk-KDX6VC3P.js.map → chunk-T6QLB34N.js.map} +0 -0
  425. /package/dist/cli-bundle/chunks/{chunk-6IGTNFE3.js.map → chunk-TALBUVWF.js.map} +0 -0
  426. /package/dist/cli-bundle/chunks/{chunk-VDVVOLR6.js.map → chunk-TV6FZGVK.js.map} +0 -0
  427. /package/dist/cli-bundle/chunks/{chunk-7CR4GAYN.js.map → chunk-UDWUDUJI.js.map} +0 -0
  428. /package/dist/cli-bundle/chunks/{chunk-F2REA7VW.js.map → chunk-UNH3KSHG.js.map} +0 -0
  429. /package/dist/cli-bundle/chunks/{chunk-4TJWRPIH.js.map → chunk-UY26RIBR.js.map} +0 -0
  430. /package/dist/cli-bundle/chunks/{chunk-MNXJ6YDO.js.map → chunk-VSS3CSTF.js.map} +0 -0
  431. /package/dist/cli-bundle/chunks/{chunk-ENCVPOID.js.map → chunk-WWEFBBVF.js.map} +0 -0
  432. /package/dist/cli-bundle/chunks/{chunk-XEOO6K5J.js.map → chunk-X3IPJU2O.js.map} +0 -0
  433. /package/dist/cli-bundle/chunks/{claim-UXFGCF3P.js.map → claim-3TY5LE54.js.map} +0 -0
  434. /package/dist/cli-bundle/chunks/{claim-RV6WYUF7.js.map → claim-LM4YY6QQ.js.map} +0 -0
  435. /package/dist/cli-bundle/chunks/{close-O4JK2JKD.js.map → close-CSD4LEMT.js.map} +0 -0
  436. /package/dist/cli-bundle/chunks/{close-JTTGW7TS.js.map → close-SIQCDOBR.js.map} +0 -0
  437. /package/dist/cli-bundle/chunks/{close-many-EQO4TPIE.js.map → close-many-B5SHDX6W.js.map} +0 -0
  438. /package/dist/cli-bundle/chunks/{close-many-SRDBV3SI.js.map → close-many-WRXB5KVY.js.map} +0 -0
  439. /package/dist/cli-bundle/chunks/{comments-OMB7YE27.js.map → comments-A5ALOYTG.js.map} +0 -0
  440. /package/dist/cli-bundle/chunks/{comments-TTZUIB2O.js.map → comments-BDDEK3VW.js.map} +0 -0
  441. /package/dist/cli-bundle/chunks/{config-5VPR42A6.js.map → config-W2NHDNQT.js.map} +0 -0
  442. /package/dist/cli-bundle/chunks/{config-NNLXVGVC.js.map → config-YUYBMJOW.js.map} +0 -0
  443. /package/dist/cli-bundle/chunks/{contracts-AOBNEBVT.js.map → contracts-47X7RYUF.js.map} +0 -0
  444. /package/dist/cli-bundle/chunks/{contracts-DXCWXOSP.js.map → contracts-HJHR4NCD.js.map} +0 -0
  445. /package/dist/cli-bundle/chunks/{copy-XSYEQTLA.js.map → copy-B7HFOWFB.js.map} +0 -0
  446. /package/dist/cli-bundle/chunks/{copy-5NM3SVJA.js.map → copy-P4UVYZ7M.js.map} +0 -0
  447. /package/dist/cli-bundle/chunks/{create-FCCAATQV.js.map → create-5ERJF64D.js.map} +0 -0
  448. /package/dist/cli-bundle/chunks/{create-JAPLFDGJ.js.map → create-TXNRPS4K.js.map} +0 -0
  449. /package/dist/cli-bundle/chunks/{delete-5JFP6OG7.js.map → delete-LX3LGBCH.js.map} +0 -0
  450. /package/dist/cli-bundle/chunks/{delete-PQXJQXQ7.js.map → delete-S3WVK6LP.js.map} +0 -0
  451. /package/dist/cli-bundle/chunks/{deps-XXKBOQUA.js.map → deps-GWSNH7OZ.js.map} +0 -0
  452. /package/dist/cli-bundle/chunks/{deps-S5322EOQ.js.map → deps-YSM4LZQD.js.map} +0 -0
  453. /package/dist/cli-bundle/chunks/{docs-DZRPAW5S.js.map → docs-7RYFBHQD.js.map} +0 -0
  454. /package/dist/cli-bundle/chunks/{docs-C7CCVWAJ.js.map → docs-TG6JMVMY.js.map} +0 -0
  455. /package/dist/cli-bundle/chunks/{extension-CSHP6FZX.js.map → extension-R3LUKMX7.js.map} +0 -0
  456. /package/dist/cli-bundle/chunks/{extension-XNNVUVAY.js.map → extension-VNMRKIHI.js.map} +0 -0
  457. /package/dist/cli-bundle/chunks/{files-OBWYYPKM.js.map → files-KAKU57OT.js.map} +0 -0
  458. /package/dist/cli-bundle/chunks/{files-UPCNKEIZ.js.map → files-QB3EYPMO.js.map} +0 -0
  459. /package/dist/cli-bundle/chunks/{gc-KXK6KBRN.js.map → gc-B747VM4M.js.map} +0 -0
  460. /package/dist/cli-bundle/chunks/{gc-FA2ONELT.js.map → gc-KNUPLPSW.js.map} +0 -0
  461. /package/dist/cli-bundle/chunks/{get-PNTSONGB.js.map → get-GMGLIQ5I.js.map} +0 -0
  462. /package/dist/cli-bundle/chunks/{get-FLHYTOBA.js.map → get-SBL6NHYQ.js.map} +0 -0
  463. /package/dist/cli-bundle/chunks/{history-6624XISO.js.map → history-6UKSZTRT.js.map} +0 -0
  464. /package/dist/cli-bundle/chunks/{history-COQTPBEU.js.map → history-XCWRXBXC.js.map} +0 -0
  465. /package/dist/cli-bundle/chunks/{history-compact-66PSRYL3.js.map → history-compact-IDH7E7VN.js.map} +0 -0
  466. /package/dist/cli-bundle/chunks/{history-compact-PVS2A3FS.js.map → history-compact-KICKUCR7.js.map} +0 -0
  467. /package/dist/cli-bundle/chunks/{history-redact-ZRQTI7NB.js.map → history-redact-HKYBTK6X.js.map} +0 -0
  468. /package/dist/cli-bundle/chunks/{history-redact-DCXAWGTF.js.map → history-redact-JJWH3QWK.js.map} +0 -0
  469. /package/dist/cli-bundle/chunks/{history-repair-TA3NRIFO.js.map → history-repair-7HWBZKXN.js.map} +0 -0
  470. /package/dist/cli-bundle/chunks/{history-repair-SEQDFTGW.js.map → history-repair-N5HXKJOI.js.map} +0 -0
  471. /package/dist/cli-bundle/chunks/{init-ZVE2HMKK.js.map → init-27JLDUO2.js.map} +0 -0
  472. /package/dist/cli-bundle/chunks/{init-IQJE3EKJ.js.map → init-OQA3TWIS.js.map} +0 -0
  473. /package/dist/cli-bundle/chunks/{learnings-XC6EMW5E.js.map → learnings-L7VQUSVI.js.map} +0 -0
  474. /package/dist/cli-bundle/chunks/{learnings-RJPGH2ME.js.map → learnings-Z4GAIZQ5.js.map} +0 -0
  475. /package/dist/cli-bundle/chunks/{list-OO5P472O.js.map → list-6U3CJVXS.js.map} +0 -0
  476. /package/dist/cli-bundle/chunks/{list-NJV6WBT4.js.map → list-W5ROBC5U.js.map} +0 -0
  477. /package/dist/cli-bundle/chunks/{notes-2KWHADK3.js.map → notes-JJDOEDFK.js.map} +0 -0
  478. /package/dist/cli-bundle/chunks/{notes-FNCDMZW2.js.map → notes-SDCK7BEN.js.map} +0 -0
  479. /package/dist/cli-bundle/chunks/{plan-MQO5JTSV.js.map → plan-H5HYHMBB.js.map} +0 -0
  480. /package/dist/cli-bundle/chunks/{plan-CYK2P5PD.js.map → plan-W2B5RYR3.js.map} +0 -0
  481. /package/dist/cli-bundle/chunks/{register-setup-GAQZZRUA.js.map → register-setup-BZ3TNE3G.js.map} +0 -0
  482. /package/dist/cli-bundle/chunks/{register-setup-X2R5CFDV.js.map → register-setup-WLFL3OUF.js.map} +0 -0
  483. /package/dist/cli-bundle/chunks/{restore-F4ALFV4D.js.map → restore-GNI2W5CN.js.map} +0 -0
  484. /package/dist/cli-bundle/chunks/{restore-E3GZKRRK.js.map → restore-RGFSPG4K.js.map} +0 -0
  485. /package/dist/cli-bundle/chunks/{schema-3CPFLDAY.js.map → schema-CCDU3RLC.js.map} +0 -0
  486. /package/dist/cli-bundle/chunks/{schema-7EHBPNXM.js.map → schema-KZASL323.js.map} +0 -0
  487. /package/dist/cli-bundle/chunks/{search-OBZVYJJ2.js.map → search-7KSOLI2E.js.map} +0 -0
  488. /package/dist/cli-bundle/chunks/{search-2T3NCCUR.js.map → search-DTL7CO22.js.map} +0 -0
  489. /package/dist/cli-bundle/chunks/{stats-ULGQACF7.js.map → stats-IOXQMGI6.js.map} +0 -0
  490. /package/dist/cli-bundle/chunks/{stats-6LVK4JER.js.map → stats-QNV7B2CE.js.map} +0 -0
  491. /package/dist/cli-bundle/chunks/{telemetry-6G27FLCP.js.map → telemetry-IV5C6JOM.js.map} +0 -0
  492. /package/dist/cli-bundle/chunks/{telemetry-HHKRTMZA.js.map → telemetry-NHR5RFXT.js.map} +0 -0
  493. /package/dist/cli-bundle/chunks/{test-PPOLRIBA.js.map → test-4Z37CXW4.js.map} +0 -0
  494. /package/dist/cli-bundle/chunks/{test-2PP4YBV6.js.map → test-PIL2CEEB.js.map} +0 -0
  495. /package/dist/cli-bundle/chunks/{test-all-NETGVNM6.js.map → test-all-GRLYHBNP.js.map} +0 -0
  496. /package/dist/cli-bundle/chunks/{test-all-6Z272JRI.js.map → test-all-MFN4MYCV.js.map} +0 -0
  497. /package/dist/cli-bundle/chunks/{test-runs-CRPQVMMG.js.map → test-runs-7LRFWWCA.js.map} +0 -0
  498. /package/dist/cli-bundle/chunks/{test-runs-M24WA6TI.js.map → test-runs-7WCSC3TY.js.map} +0 -0
  499. /package/dist/cli-bundle/chunks/{update-O7TBOUVQ.js.map → update-I4G34LKJ.js.map} +0 -0
  500. /package/dist/cli-bundle/chunks/{update-MCPCPMHV.js.map → update-VI5DBZ3G.js.map} +0 -0
  501. /package/dist/cli-bundle/chunks/{update-many-JSRF5EH5.js.map → update-many-LOTAYUTN.js.map} +0 -0
  502. /package/dist/cli-bundle/chunks/{update-many-Y3HOL7WA.js.map → update-many-UYMTVF42.js.map} +0 -0
  503. /package/dist/cli-bundle/chunks/{upgrade-ECB6GH3M.js.map → upgrade-LT2MLLPS.js.map} +0 -0
  504. /package/dist/cli-bundle/chunks/{upgrade-5RTQVKKE.js.map → upgrade-ZZSC7CLV.js.map} +0 -0
  505. /package/dist/cli-bundle/chunks/{validate-J6Q444SD.js.map → validate-3XRORNMP.js.map} +0 -0
  506. /package/dist/cli-bundle/chunks/{validate-MCNMAXVA.js.map → validate-IQIQSKUX.js.map} +0 -0
@@ -3,7 +3,7 @@
3
3
  import {
4
4
  compareTimestampStrings,
5
5
  isTimestampLiteral
6
- } from "./chunk-PW7C262O.js";
6
+ } from "./chunk-PYULT32I.js";
7
7
  import {
8
8
  CONFIDENCE_TEXT_VALUES,
9
9
  EXIT_CODE,
@@ -19,7 +19,7 @@ import {
19
19
  resolveRuntimeStatusRegistry,
20
20
  runtimeFieldOptionTarget,
21
21
  weekdayOrderIndex
22
- } from "./chunk-5JF76OJF.js";
22
+ } from "./chunk-WNMRICXH.js";
23
23
 
24
24
  // dist/core/schema/runtime-field-values.js
25
25
  function toCamelToken(value) {
@@ -1324,6 +1324,6 @@ export {
1324
1324
  serializeItemDocument,
1325
1325
  canonicalDocument
1326
1326
  };
1327
- //# sourceMappingURL=chunk-5ATRWEZO.js.map
1327
+ //# sourceMappingURL=chunk-SNASEDXB.js.map
1328
1328
 
1329
1329
  //# debugId=8e6380db-298c-5343-b79e-9939444e8ad2
@@ -2,14 +2,14 @@
2
2
  !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="57f95f52-98be-5c1f-b45f-c58fefd14928")}catch(e){}}();
3
3
  import {
4
4
  nowIso
5
- } from "./chunk-PW7C262O.js";
5
+ } from "./chunk-PYULT32I.js";
6
6
  import {
7
7
  EXIT_CODE,
8
8
  PmCliError,
9
9
  pathExists,
10
10
  toErrorMessage,
11
11
  writeFileAtomic
12
- } from "./chunk-5JF76OJF.js";
12
+ } from "./chunk-WNMRICXH.js";
13
13
 
14
14
  // dist/core/checkpoint/mutation-checkpoint.js
15
15
  import { mkdir, readFile } from "node:fs/promises";
@@ -123,6 +123,6 @@ export {
123
123
  loadMutationCheckpoint,
124
124
  restoreCheckpointItems
125
125
  };
126
- //# sourceMappingURL=chunk-KDX6VC3P.js.map
126
+ //# sourceMappingURL=chunk-T6QLB34N.js.map
127
127
 
128
128
  //# debugId=57f95f52-98be-5c1f-b45f-c58fefd14928
@@ -2,7 +2,7 @@
2
2
  !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9d7e4d46-ea22-536a-8a47-90006a264b88")}catch(e){}}();
3
3
  import {
4
4
  BUILTIN_ITEM_TYPE_VALUES
5
- } from "./chunk-5JF76OJF.js";
5
+ } from "./chunk-WNMRICXH.js";
6
6
 
7
7
  // dist/core/schema/item-types-file.js
8
8
  var BUILTIN_NAME_LOOKUP = new Map(BUILTIN_ITEM_TYPE_VALUES.map((name) => [name.toLowerCase(), name]));
@@ -213,6 +213,6 @@ export {
213
213
  buildInvalidTypeHint,
214
214
  buildInvalidTypeError
215
215
  };
216
- //# sourceMappingURL=chunk-6IGTNFE3.js.map
216
+ //# sourceMappingURL=chunk-TALBUVWF.js.map
217
217
 
218
218
  //# debugId=9d7e4d46-ea22-536a-8a47-90006a264b88
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  resolveTypeName
3
- } from "./chunk-U3Z4OCZC.js";
3
+ } from "./chunk-7GYMMDDW.js";
4
4
  import {
5
5
  EXIT_CODE,
6
6
  PmCliError
7
- } from "./chunk-C72IQIBT.js";
7
+ } from "./chunk-OQGJSCZZ.js";
8
8
 
9
9
  // dist/cli/shared-parsers.js
10
10
  !(function() {
@@ -57,4 +57,4 @@ export {
57
57
  parsePriority,
58
58
  parseType
59
59
  };
60
- //# sourceMappingURL=chunk-VDVVOLR6.js.map
60
+ //# sourceMappingURL=chunk-TV6FZGVK.js.map
@@ -1,23 +1,23 @@
1
1
  import {
2
2
  hashDocument,
3
3
  toItemRecord
4
- } from "./chunk-LF2VNLEZ.js";
4
+ } from "./chunk-XRE4CTNP.js";
5
5
  import {
6
6
  canonicalDocument
7
- } from "./chunk-NHRZSYAA.js";
7
+ } from "./chunk-Q6PSD5DZ.js";
8
8
  import {
9
9
  FRONT_MATTER_KEY_ORDER,
10
10
  orderObject,
11
11
  sha256Hex,
12
12
  stableStringify
13
- } from "./chunk-C72IQIBT.js";
13
+ } from "./chunk-OQGJSCZZ.js";
14
14
 
15
15
  // dist/core/history/replay.js
16
16
  import jsonPatch from "fast-json-patch";
17
17
  !(function() {
18
18
  try {
19
19
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
20
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "a11d69ae-cb25-5c08-8722-85d4fe95b973");
20
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "f055f3a6-ee3e-5f79-82f4-55c049f640e9");
21
21
  } catch (e2) {
22
22
  }
23
23
  })();
@@ -66,11 +66,17 @@ function normalizeReplayPatchPath(path) {
66
66
  }
67
67
  return path;
68
68
  }
69
+ function isHistoryPatchOp(value) {
70
+ return typeof value === "object" && value !== null && typeof value.op === "string" && typeof value.path === "string";
71
+ }
69
72
  function normalizeReplayPatchOps(patch) {
70
- return patch.map((operation) => ({
73
+ if (!Array.isArray(patch)) {
74
+ return [];
75
+ }
76
+ return patch.filter(isHistoryPatchOp).map((operation) => ({
71
77
  ...operation,
72
78
  path: normalizeReplayPatchPath(operation.path),
73
- from: operation.from ? normalizeReplayPatchPath(operation.from) : void 0
79
+ from: typeof operation.from === "string" ? normalizeReplayPatchPath(operation.from) : void 0
74
80
  }));
75
81
  }
76
82
  function isReplayDocumentShape(value) {
@@ -231,4 +237,4 @@ export {
231
237
  reanchorHistoryEntries,
232
238
  historyEntriesToRaw
233
239
  };
234
- //# sourceMappingURL=chunk-H37YPWLM.js.map
240
+ //# sourceMappingURL=chunk-TXWMLDMG.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../core/history/replay.ts"],
4
+ "sourcesContent": ["import jsonPatch from \"fast-json-patch\";\nimport { FRONT_MATTER_KEY_ORDER } from \"../shared/constants.js\";\nimport { canonicalDocument } from \"../item/item-format.js\";\nimport { toItemRecord } from \"../item/item-record.js\";\nimport { orderObject, sha256Hex, stableStringify } from \"../shared/serialization.js\";\nimport { hashDocument } from \"./history.js\";\nimport type { HistoryEntry, HistoryPatchOp, ItemDocument, ItemMetadata } from \"../../types/index.js\";\n\n/**\n * Shared history replay/patch mechanics single-sourced for the history, restore,\n * history-redact, and history-repair commands plus the health/validate drift checks.\n *\n * Each command keeps its own thin error-formatting wrapper so the exact CLI error\n * contracts (restore's rich patch-failure context, redact's op tag, history's\n * generic message) are preserved; only the underlying replay/patch logic is shared.\n */\n\nexport interface ReplayDocument {\n metadata: Record<string, unknown>;\n body: string;\n}\n\nexport const EMPTY_REPLAY_DOCUMENT: ReplayDocument = {\n metadata: {},\n body: \"\",\n};\n\nexport function cloneEmptyReplayDocument(): ReplayDocument {\n return structuredClone(EMPTY_REPLAY_DOCUMENT);\n}\n\nexport function replayHash(document: ReplayDocument): string {\n try {\n return hashDocument({\n metadata: document.metadata as unknown as ItemMetadata,\n body: document.body,\n });\n } catch {\n // Legacy/malformed replay states (for example a stream whose first entry never\n // established a full `create` document, so the canonicalizer cannot normalize it)\n // cannot be canonically hashed. Fall back to a deterministic structural hash so\n // re-anchor and verification stay internally consistent for these streams. Fully\n // formed documents always take the canonical path above, so valid streams are\n // unaffected.\n return sha256Hex(stableStringify({ replay_fallback: true, metadata: document.metadata, body: document.body }));\n }\n}\n\nexport function replayToItemDocument(document: ReplayDocument): ItemDocument {\n return {\n metadata: document.metadata as unknown as ItemMetadata,\n body: document.body,\n };\n}\n\n/**\n * Canonicalize an item document into the ordered replay form used when comparing\n * a replayed chain against the on-disk item (restore + history-repair reconciliation).\n */\nexport function toReplayDocument(document: ItemDocument): ReplayDocument {\n if (!document.metadata || Object.keys(document.metadata).length === 0) {\n return {\n metadata: {},\n body: document.body ?? \"\",\n };\n }\n const canonical = canonicalDocument(document);\n return {\n metadata: orderObject(toItemRecord(canonical.metadata), FRONT_MATTER_KEY_ORDER),\n body: canonical.body,\n };\n}\n\nexport function normalizeReplayPatchPath(path: string): string {\n if (path === \"/front_matter\") {\n return \"/metadata\";\n }\n if (path.startsWith(\"/front_matter/\")) {\n return `/metadata/${path.slice(\"/front_matter/\".length)}`;\n }\n return path;\n}\n\nfunction isHistoryPatchOp(value: unknown): value is HistoryPatchOp {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { op?: unknown }).op === \"string\" &&\n typeof (value as { path?: unknown }).path === \"string\"\n );\n}\n\nexport function normalizeReplayPatchOps(patch: HistoryPatchOp[] | unknown): HistoryPatchOp[] {\n if (!Array.isArray(patch)) {\n return [];\n }\n return patch.filter(isHistoryPatchOp).map((operation) => ({\n ...operation,\n path: normalizeReplayPatchPath(operation.path),\n from: typeof operation.from === \"string\" ? normalizeReplayPatchPath(operation.from) : undefined,\n }));\n}\n\nfunction isReplayDocumentShape(value: unknown): value is { metadata: Record<string, unknown>; body: string } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"metadata\" in value &&\n \"body\" in value &&\n typeof (value as { body: unknown }).body === \"string\" &&\n typeof (value as { metadata: unknown }).metadata === \"object\" &&\n (value as { metadata: unknown }).metadata !== null\n );\n}\n\nexport type ReplayApplyResult =\n | { ok: true; document: ReplayDocument }\n | { ok: false; error: unknown };\n\n/**\n * Strictly apply a history patch (front_matter->metadata normalized) to a replay\n * document. Returns a result envelope rather than throwing so each caller can\n * format its own error contract.\n */\nexport function tryApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): ReplayApplyResult {\n try {\n const normalizedPatch = normalizeReplayPatchOps(patch);\n const applied = jsonPatch.applyPatch(\n structuredClone(current),\n normalizedPatch as jsonPatch.Operation[],\n true,\n false,\n ).newDocument as unknown;\n if (!isReplayDocumentShape(applied)) {\n return { ok: false, error: new Error(\"history_replay_invalid_document_shape\") };\n }\n return { ok: true, document: { metadata: applied.metadata, body: applied.body } };\n } catch (error) {\n return { ok: false, error };\n }\n}\n\n/**\n * Deterministically verify a history chain: each entry's before_hash must equal\n * the prior replayed after_hash, the patch must strictly apply, and the recorded\n * after_hash must equal the replayed result.\n */\nexport function verifyHistoryChain(entries: HistoryEntry[]): { ok: boolean; errors: string[] } {\n let replay = cloneEmptyReplayDocument();\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n if (replayHash(replay) !== entry.before_hash) {\n return {\n ok: false,\n errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],\n };\n }\n const applied = tryApplyReplayPatch(replay, entry.patch);\n if (!applied.ok) {\n return {\n ok: false,\n errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],\n };\n }\n replay = applied.document;\n if (replayHash(replay) !== entry.after_hash) {\n return {\n ok: false,\n errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],\n };\n }\n }\n return { ok: true, errors: [] };\n}\n\nexport interface LenientApplyResult {\n document: ReplayDocument;\n convertedReplaceToAdd: number;\n skippedOps: number;\n}\n\nfunction tryApplySingleOp(document: unknown, op: HistoryPatchOp): { ok: true; document: unknown } | { ok: false } {\n try {\n const applied = jsonPatch.applyPatch(\n structuredClone(document),\n [op as jsonPatch.Operation],\n true,\n false,\n ).newDocument as unknown;\n return { ok: true, document: applied };\n } catch {\n return { ok: false };\n }\n}\n\n/**\n * Apply a legacy patch op-by-op, recovering from drift that strict replay rejects:\n * a `replace` whose path no longer exists is retried as `add`, and any op that\n * still cannot apply against the current replay state is skipped. The resulting\n * document is what the repaired entry's recomputed patch should target.\n */\nexport function lenientApplyReplayPatch(current: ReplayDocument, patch: HistoryPatchOp[]): LenientApplyResult {\n let working: unknown = structuredClone(current);\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (const op of normalizeReplayPatchOps(patch)) {\n const direct = tryApplySingleOp(working, op);\n if (direct.ok) {\n working = direct.document;\n continue;\n }\n if (op.op === \"replace\") {\n const asAdd = tryApplySingleOp(working, { ...op, op: \"add\" });\n if (asAdd.ok) {\n working = asAdd.document;\n convertedReplaceToAdd += 1;\n continue;\n }\n }\n skippedOps += 1;\n }\n\n const candidate = working as { metadata?: unknown; body?: unknown };\n const document: ReplayDocument = {\n metadata:\n typeof candidate.metadata === \"object\" && candidate.metadata !== null\n ? (candidate.metadata as Record<string, unknown>)\n : {},\n body: typeof candidate.body === \"string\" ? candidate.body : current.body,\n };\n return { document, convertedReplaceToAdd, skippedOps };\n}\n\nexport interface ReanchorEntryDetail {\n index: number;\n rehashed: boolean;\n patch_repaired: boolean;\n converted_replace_to_add: number;\n skipped_ops: number;\n}\n\nexport interface ReanchorResult {\n entries: HistoryEntry[];\n finalDocument: ReplayDocument;\n entriesRehashed: number;\n entriesPatchRepaired: number;\n convertedReplaceToAdd: number;\n skippedOps: number;\n details: ReanchorEntryDetail[];\n}\n\n/**\n * Re-anchor a drifted history chain: replay every entry from empty, recompute the\n * before/after hashes, and only rewrite a patch when the original op set no longer\n * strictly applies (legacy drift). Clean entries keep their patch verbatim so the\n * on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain.\n */\nexport function reanchorHistoryEntries(entries: HistoryEntry[]): ReanchorResult {\n let replay = cloneEmptyReplayDocument();\n const rewritten: HistoryEntry[] = [];\n const details: ReanchorEntryDetail[] = [];\n let entriesRehashed = 0;\n let entriesPatchRepaired = 0;\n let convertedReplaceToAdd = 0;\n let skippedOps = 0;\n\n for (let index = 0; index < entries.length; index += 1) {\n const entry = entries[index];\n const beforeHash = replayHash(replay);\n const strict = tryApplyReplayPatch(replay, entry.patch);\n\n let next: ReplayDocument;\n let outPatch: HistoryPatchOp[];\n let patchRepaired = false;\n let entryConverted = 0;\n let entrySkipped = 0;\n\n if (strict.ok) {\n next = strict.document;\n outPatch = entry.patch;\n } else {\n const lenient = lenientApplyReplayPatch(replay, entry.patch);\n next = lenient.document;\n outPatch = jsonPatch.compare(replay, next) as HistoryPatchOp[];\n patchRepaired = true;\n entryConverted = lenient.convertedReplaceToAdd;\n entrySkipped = lenient.skippedOps;\n convertedReplaceToAdd += entryConverted;\n skippedOps += entrySkipped;\n entriesPatchRepaired += 1;\n }\n\n const afterHash = replayHash(next);\n const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;\n if (rehashed) {\n entriesRehashed += 1;\n }\n\n rewritten.push({\n ...entry,\n patch: outPatch,\n before_hash: beforeHash,\n after_hash: afterHash,\n });\n details.push({\n index: index + 1,\n rehashed,\n patch_repaired: patchRepaired,\n converted_replace_to_add: entryConverted,\n skipped_ops: entrySkipped,\n });\n replay = next;\n }\n\n return {\n entries: rewritten,\n finalDocument: replay,\n entriesRehashed,\n entriesPatchRepaired,\n convertedReplaceToAdd,\n skippedOps,\n details,\n };\n}\n\nexport function historyEntriesToRaw(entries: HistoryEntry[]): string {\n if (entries.length === 0) {\n return \"\";\n }\n return `${entries.map((entry) => JSON.stringify(entry)).join(\"\\n\")}\\n`;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA,OAAO,eAAe;;;;;;;;AAsBf,IAAM,wBAAwC;EACnD,UAAU,CAAA;EACV,MAAM;;AAGF,SAAU,2BAAwB;AACtC,SAAO,gBAAgB,qBAAqB;AAC9C;AAEM,SAAU,WAAW,UAAwB;AACjD,MAAI;AACF,WAAO,aAAa;MAClB,UAAU,SAAS;MACnB,MAAM,SAAS;KAChB;EACH,QAAQ;AAON,WAAO,UAAU,gBAAgB,EAAE,iBAAiB,MAAM,UAAU,SAAS,UAAU,MAAM,SAAS,KAAI,CAAE,CAAC;EAC/G;AACF;AAEM,SAAU,qBAAqB,UAAwB;AAC3D,SAAO;IACL,UAAU,SAAS;IACnB,MAAM,SAAS;;AAEnB;AAMM,SAAU,iBAAiB,UAAsB;AACrD,MAAI,CAAC,SAAS,YAAY,OAAO,KAAK,SAAS,QAAQ,EAAE,WAAW,GAAG;AACrE,WAAO;MACL,UAAU,CAAA;MACV,MAAM,SAAS,QAAQ;;EAE3B;AACA,QAAM,YAAY,kBAAkB,QAAQ;AAC5C,SAAO;IACL,UAAU,YAAY,aAAa,UAAU,QAAQ,GAAG,sBAAsB;IAC9E,MAAM,UAAU;;AAEpB;AAEM,SAAU,yBAAyB,MAAY;AACnD,MAAI,SAAS,iBAAiB;AAC5B,WAAO;EACT;AACA,MAAI,KAAK,WAAW,gBAAgB,GAAG;AACrC,WAAO,aAAa,KAAK,MAAM,iBAAiB,MAAM,CAAC;EACzD;AACA,SAAO;AACT;AAEA,SAAS,iBAAiB,O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+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  nowIso
3
- } from "./chunk-SAUXUI6U.js";
3
+ } from "./chunk-7TW64BS5.js";
4
4
  import {
5
5
  EXIT_CODE,
6
6
  appendLineAtomic,
@@ -11,7 +11,7 @@ import {
11
11
  resolveTelemetryErrorCategory,
12
12
  writeFileAtomic,
13
13
  writeSettings
14
- } from "./chunk-C72IQIBT.js";
14
+ } from "./chunk-OQGJSCZZ.js";
15
15
 
16
16
  // dist/core/telemetry/observability.js
17
17
  !(function() {
@@ -213,7 +213,7 @@ import path from "node:path";
213
213
  !(function() {
214
214
  try {
215
215
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
216
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "abf7c967-99a9-570a-9c3e-d050d2cd29bd");
216
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "8431b32d-4a71-59da-ace6-b292ce6d0a3a");
217
217
  } catch (e2) {
218
218
  }
219
219
  })();
@@ -1575,9 +1575,10 @@ export {
1575
1575
  deriveTelemetryCommandTaxonomy,
1576
1576
  deriveTelemetryCommandResolution,
1577
1577
  TELEMETRY_SCHEMA_VERSION,
1578
+ TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS,
1578
1579
  flushTelemetryQueueNow,
1579
1580
  startTelemetryCommand,
1580
1581
  finishTelemetryCommand,
1581
1582
  emitTelemetryErrorEvent
1582
1583
  };
1583
- //# sourceMappingURL=chunk-TLD3UYGY.js.map
1584
+ //# sourceMappingURL=chunk-TZLGCTA5.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../core/telemetry/observability.ts", "../../../../../../../../core/telemetry/runtime.ts"],
4
+ "sourcesContent": ["import { EXIT_CODE, type TelemetryErrorCategory } from \"../shared/constants.js\";\n\nexport type TelemetryResolutionStage = \"parse\" | \"preflight\" | \"execute\" | \"unknown\";\n\nexport type TelemetryCommandResolution =\n | \"success\"\n | \"nonexistent_command\"\n | \"invalid_option\"\n | \"missing_required_option\"\n | \"missing_required_argument\"\n | \"invalid_usage\"\n | \"validation_failed\"\n | \"health_findings\"\n | \"validation_findings\"\n | \"conflict\"\n | \"runtime_failed\"\n | \"unknown_failed\";\n\nexport interface TelemetryCommandTaxonomy {\n command_path: string;\n command_root: string;\n command_leaf: string;\n command_depth: number;\n command_family: \"setup\" | \"query\" | \"mutation\" | \"testing\" | \"extension\" | \"diagnostics\" | \"other\";\n}\n\ninterface InferTelemetryErrorCodeParams {\n ok: boolean;\n errorCode?: string;\n errorMessage?: string;\n exitCode?: number;\n}\n\nconst SETUP_ROOT_COMMANDS = new Set([\"init\", \"config\", \"completion\", \"completion-statuses\", \"completion-tags\", \"completion-types\"]);\nconst QUERY_ROOT_COMMANDS = new Set([\n \"list\",\n \"list-all\",\n \"list-open\",\n \"list-in-progress\",\n \"list-blocked\",\n \"list-closed\",\n \"list-canceled\",\n \"list-draft\",\n \"search\",\n \"get\",\n \"context\",\n \"calendar\",\n \"history\",\n \"activity\",\n \"aggregate\",\n \"deps\",\n \"contracts\",\n \"stats\",\n \"dedupe-audit\",\n]);\nconst MUTATION_ROOT_COMMANDS = new Set([\n \"create\",\n \"update\",\n \"update-many\",\n \"close-many\",\n \"append\",\n \"close\",\n \"delete\",\n \"restore\",\n \"claim\",\n \"release\",\n \"comments\",\n \"notes\",\n \"learnings\",\n \"files\",\n \"docs\",\n \"start-task\",\n \"pause-task\",\n \"close-task\",\n]);\nconst TESTING_ROOT_COMMANDS = new Set([\"test\", \"test-all\", \"test-runs\", \"test-verify\", \"trace-test\", \"test-ping\"]);\nconst DIAGNOSTICS_ROOT_COMMANDS = new Set([\"health\", \"validate\", \"normalize\", \"reindex\", \"gc\", \"telemetry\", \"extension-doctor\"]);\n\nfunction normalizeCommandPath(commandPath: string): string {\n return commandPath\n .trim()\n .replaceAll(/\\s+/g, \" \")\n .toLowerCase();\n}\n\nfunction normalizeErrorCode(errorCode: string | undefined): string | undefined {\n const normalized = errorCode?.trim().toLowerCase();\n return normalized && normalized.length > 0 ? normalized : undefined;\n}\n\nexport function deriveTelemetryCommandTaxonomy(commandPath: string): TelemetryCommandTaxonomy {\n const normalizedPath = normalizeCommandPath(commandPath);\n const tokens = normalizedPath.length > 0 ? normalizedPath.split(\" \") : [\"<unknown>\"];\n const root = tokens[0] ?? \"<unknown>\";\n const leaf = tokens[tokens.length - 1] ?? root;\n\n let family: TelemetryCommandTaxonomy[\"command_family\"] = \"other\";\n if (SETUP_ROOT_COMMANDS.has(root)) {\n family = \"setup\";\n } else if (QUERY_ROOT_COMMANDS.has(root)) {\n family = \"query\";\n } else if (MUTATION_ROOT_COMMANDS.has(root)) {\n family = \"mutation\";\n } else if (TESTING_ROOT_COMMANDS.has(root)) {\n family = \"testing\";\n } else if (root === \"extension\") {\n family = \"extension\";\n } else if (DIAGNOSTICS_ROOT_COMMANDS.has(root)) {\n family = \"diagnostics\";\n }\n\n return {\n command_path: normalizedPath.length > 0 ? normalizedPath : \"<unknown>\",\n command_root: root,\n command_leaf: leaf,\n command_depth: tokens.length,\n command_family: family,\n };\n}\n\nexport function inferTelemetryErrorCode(params: InferTelemetryErrorCodeParams): string | undefined {\n if (params.ok) {\n return undefined;\n }\n\n const explicit = normalizeErrorCode(params.errorCode);\n if (explicit) {\n return explicit;\n }\n\n const message = (params.errorMessage ?? \"\").trim().toLowerCase();\n if (message.includes(\"unknown command\")) {\n return \"unknown_command\";\n }\n if (message.includes(\"unknown option\")) {\n return \"unknown_option\";\n }\n if (message.includes(\"missing required options\") || message.includes(\"missing required option\")) {\n return \"missing_required_option\";\n }\n if (message.includes(\"missing required argument\")) {\n return \"missing_required_argument\";\n }\n if (message.includes(\"no update flags provided\")) {\n return \"no_update_fields\";\n }\n if (message.includes(\"is assigned to\") && message.includes(\"use --force\")) {\n return \"ownership_conflict\";\n }\n if (message.includes(\"is locked\")) {\n return \"lock_conflict\";\n }\n if (message.includes(\"already terminal\") && message.includes(\"use --force\")) {\n return \"terminal_state_conflict\";\n }\n if (message.includes(\"tracker is not initialized\")) {\n return \"tracker_not_initialized\";\n }\n if (message.includes(\" not found\")) {\n return \"item_not_found\";\n }\n if (\n message.includes(\"use \\\"pm close <id> <text>\\\" to close an item\") ||\n (message.includes(\"invalid --status value\") && message.includes(\"\\\"closed\\\"\"))\n ) {\n return \"close_through_update\";\n }\n if (message.startsWith(\"invalid \") || message.includes(\" must be \") || message.includes(\" requires \")) {\n return \"invalid_argument_value\";\n }\n if (message.includes(\"strict create mode requires concrete values for --\")) {\n return \"missing_required_option\";\n }\n if (message.includes(\"either as positional\") && message.includes(\"not both\")) {\n return \"invalid_command_usage\";\n }\n\n const exitCode = Number.isFinite(params.exitCode) ? Math.max(0, Math.trunc(params.exitCode ?? 0)) : undefined;\n if (exitCode === EXIT_CODE.USAGE) {\n return \"invalid_command_usage\";\n }\n if (exitCode === EXIT_CODE.NOT_FOUND) {\n return \"item_not_found\";\n }\n if (exitCode === EXIT_CODE.CONFLICT) {\n return \"lock_conflict\";\n }\n if (exitCode === EXIT_CODE.DEPENDENCY_FAILED) {\n return \"dependency_failed\";\n }\n return \"command_failed\";\n}\n\nexport function deriveTelemetryCommandResolution(params: {\n ok: boolean;\n errorCode?: string;\n errorCategory?: TelemetryErrorCategory;\n}): TelemetryCommandResolution {\n if (params.ok) {\n return \"success\";\n }\n\n const normalizedCode = normalizeErrorCode(params.errorCode);\n if (normalizedCode === \"unknown_command\") {\n return \"nonexistent_command\";\n }\n if (normalizedCode === \"unknown_option\") {\n return \"invalid_option\";\n }\n if (normalizedCode === \"missing_required_option\") {\n return \"missing_required_option\";\n }\n if (normalizedCode === \"missing_required_argument\") {\n return \"missing_required_argument\";\n }\n if (normalizedCode === \"health_findings\") {\n return \"health_findings\";\n }\n if (normalizedCode === \"validation_findings\") {\n return \"validation_findings\";\n }\n\n if (params.errorCategory === \"usage\") {\n return \"invalid_usage\";\n }\n if (params.errorCategory === \"validation\") {\n return \"validation_failed\";\n }\n if (params.errorCategory === \"conflict\") {\n return \"conflict\";\n }\n if (params.errorCategory === \"runtime\") {\n return \"runtime_failed\";\n }\n return \"unknown_failed\";\n}\n", "import crypto from \"node:crypto\";\nimport { spawn } from \"node:child_process\";\nimport { mkdirSync, rmSync, statSync } from \"node:fs\";\nimport { mkdir, readdir, rm, stat } from \"node:fs/promises\";\nimport os from \"node:os\";\nimport path from \"node:path\";\nimport type { GlobalOptions } from \"../shared/command-types.js\";\nimport { resolvePmPackageRootFromModule } from \"../packages/root.js\";\nimport { appendLineAtomic, readFileIfExists, writeFileAtomic } from \"../fs/fs-utils.js\";\nimport { resolveTelemetryErrorCategory, type TelemetryErrorCategory } from \"../shared/constants.js\";\nimport { nowIso } from \"../shared/time.js\";\nimport { resolveGlobalPmRoot } from \"../store/paths.js\";\nimport { readSettings, writeSettings } from \"../store/settings.js\";\nimport {\n deriveTelemetryCommandResolution,\n deriveTelemetryCommandTaxonomy,\n inferTelemetryErrorCode,\n type TelemetryCommandResolution,\n type TelemetryCommandTaxonomy,\n type TelemetryResolutionStage,\n} from \"./observability.js\";\n\nconst TELEMETRY_QUEUE_RELATIVE_PATH = path.join(\"runtime\", \"telemetry\", \"events.jsonl\");\nconst TELEMETRY_STATE_RELATIVE_PATH = path.join(\"runtime\", \"telemetry\", \"state.json\");\nexport const TELEMETRY_SCHEMA_VERSION = 1;\nconst TELEMETRY_CLIENT_SCHEMA_VERSION = 1;\nconst TELEMETRY_FLUSH_BATCH_SIZE = 100;\nconst TELEMETRY_MAX_RETRY_DELAY_MS = 3_600_000;\nconst TELEMETRY_RETRY_BASE_DELAY_MS = 30_000;\nconst TELEMETRY_HTTP_TIMEOUT_MS = 5_000;\nconst MILLISECONDS_PER_DAY = 86_400_000;\nconst TELEMETRY_MAX_EVENT_BYTES = 65_536;\nconst TELEMETRY_SANITIZE_MAX_DEPTH = 6;\nconst TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS = 20;\nexport const TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS = 15;\nconst TELEMETRY_RESULT_PREVIEW_MAX_BYTES = 8_192;\nconst TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS = [25, 50, 100, 200] as const;\nconst TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS = 60 * 60 * 1000;\nconst TELEMETRY_FLUSH_LOCK_STALE_MS = 60_000;\nconst TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS = 60_000;\nconst OTEL_TRACES_ENDPOINT_ENV = \"OTEL_EXPORTER_OTLP_TRACES_ENDPOINT\";\nconst OTEL_BASE_ENDPOINT_ENV = \"OTEL_EXPORTER_OTLP_ENDPOINT\";\nconst OTEL_SERVICE_NAME_ENV = \"OTEL_SERVICE_NAME\";\nconst PM_TELEMETRY_DISABLED_ENV = \"PM_TELEMETRY_DISABLED\";\nconst PM_NO_TELEMETRY_ENV = \"PM_NO_TELEMETRY\";\nconst PM_TELEMETRY_DISABLED_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\nconst PM_TELEMETRY_OTEL_DISABLED_ENV = \"PM_TELEMETRY_OTEL_DISABLED\";\nconst PM_TELEMETRY_OTEL_DISABLED_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\nconst PM_TELEMETRY_INLINE_FLUSH_ENV = \"PM_TELEMETRY_INLINE_FLUSH\";\nconst PM_TELEMETRY_FLUSH_CHILD_ENV = \"PM_TELEMETRY_FLUSH_CHILD\";\nconst PM_TELEMETRY_SOURCE_CONTEXT_ENV = \"PM_TELEMETRY_SOURCE_CONTEXT\";\nconst PM_TELEMETRY_SOURCE_CONTEXT_VALUES = [\"user\", \"automation\", \"test\", \"dogfood\", \"audit_smoke\"] as const;\n\nlet _lastFlushPromise: Promise<void> = Promise.resolve();\nlet _queueMutationPromise: Promise<unknown> = Promise.resolve();\n\n/** Wait for the most recent background flush to settle. Test-only helper. */\nexport async function waitForPendingFlush(): Promise<void> {\n await _lastFlushPromise;\n await _queueMutationPromise;\n}\nconst PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set<string>(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);\nconst BOOLEAN_TRUE_VALUES = new Set([\"1\", \"true\", \"yes\", \"on\"]);\nconst PROCESS_SESSION_ID = crypto.randomUUID();\n\nconst SENSITIVE_KEYWORDS = [\n \"token\",\n \"secret\",\n \"password\",\n \"passwd\",\n \"api_key\",\n \"apikey\",\n \"authorization\",\n \"cookie\",\n \"session\",\n \"credentials\",\n \"bearer\",\n] as const;\nconst SENSITIVE_INLINE_KEY_PATTERN =\n \"(?:token|secret|password|passwd|api[_-]?key|apikey|authorization|cookie|session|credentials|bearer)\";\nconst INLINE_SENSITIVE_ASSIGNMENT_PATTERN = new RegExp(\n `\\\\b(${SENSITIVE_INLINE_KEY_PATTERN})\\\\s*([:=])\\\\s*([^\\\\s,;]+)`,\n \"giu\",\n);\nconst INLINE_SENSITIVE_FLAG_PATTERN = new RegExp(\n `(--${SENSITIVE_INLINE_KEY_PATTERN})(=|\\\\s+)([^\\\\s,;]+)`,\n \"giu\",\n);\nconst ABSOLUTE_PATH_TOKEN_PATTERN = /(^|[\\s\"'`(=])\\/(?:[^\\s\"'`),;]+)/g;\nconst BEARER_TOKEN_PATTERN = /bearer\\s+[a-z0-9._=-]+/giu;\nconst PRIVATE_IP_PATTERN =\n /\\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;\n\ninterface TelemetryEvent {\n schema_version: number;\n event_id: string;\n event_type: \"command_start\" | \"command_finish\" | \"command_error\";\n occurred_at: string;\n installation_id: string;\n session_id: string;\n command: string;\n payload: Record<string, unknown>;\n}\n\ninterface QueuedTelemetryEvent {\n client_schema_version?: number;\n event: TelemetryEvent;\n attempts: number;\n last_attempt_at?: string;\n next_attempt_after?: string;\n}\n\ninterface TelemetryRuntimeState {\n last_attempted_flush_at?: string;\n last_successful_flush_at?: string;\n last_failed_flush_at?: string;\n last_failed_flush_error?: string;\n endpoint?: string;\n queue_entries?: number;\n}\n\ntype TelemetryCaptureLevel = \"minimal\" | \"redacted\" | \"max\";\ntype TelemetrySourceContext = (typeof PM_TELEMETRY_SOURCE_CONTEXT_VALUES)[number];\ntype TelemetrySourceContextSource = \"inferred\" | \"env_override\";\n\ninterface ResolvedTelemetrySourceContext {\n source_context: TelemetrySourceContext;\n source_context_source: TelemetrySourceContextSource;\n}\n\nexport interface ActiveTelemetryCommand {\n started_at: string;\n started_at_ms: number;\n command: string;\n command_taxonomy: TelemetryCommandTaxonomy;\n pm_version: string;\n source_context: TelemetrySourceContext;\n source_context_source: TelemetrySourceContextSource;\n installation_id: string;\n pm_root_hash: string;\n cwd_hash: string;\n endpoint: string;\n retention_days: number;\n global_pm_root: string;\n capture_level: TelemetryCaptureLevel;\n otel_traces_endpoint?: string;\n otel_trace_id?: string;\n otel_span_id?: string;\n}\n\nexport interface TelemetryCommandContext {\n command: string;\n pm_version: string;\n args: string[];\n options: Record<string, unknown>;\n global: GlobalOptions;\n pm_root: string;\n}\n\nexport interface TelemetryCommandOutcome {\n ok: boolean;\n error?: string;\n result?: unknown;\n exit_code?: number;\n error_code?: string;\n error_category?: TelemetryErrorCategory;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n}\n\nexport interface TelemetryErrorEventContext {\n command: string;\n args: string[];\n options: Record<string, unknown>;\n global: GlobalOptions;\n pm_version: string;\n pm_root: string;\n error_code: string;\n error_message: string;\n exit_code: number;\n error_category?: TelemetryErrorCategory;\n command_resolution?: TelemetryCommandResolution;\n resolution_stage?: TelemetryResolutionStage;\n}\n\n\nfunction queuePath(globalPmRoot: string): string {\n return path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);\n}\n\nfunction telemetryRuntimeDirectory(globalPmRoot: string): string {\n return path.dirname(queuePath(globalPmRoot));\n}\n\nfunction runtimeStatePath(globalPmRoot: string): string {\n return path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);\n}\n\nfunction flushLockPath(globalPmRoot: string): string {\n return path.join(globalPmRoot, \"runtime\", \"telemetry\", \"flush.lock\");\n}\n\nfunction flushSpawnLockPath(globalPmRoot: string): string {\n return path.join(globalPmRoot, \"runtime\", \"telemetry\", \"flush.spawn.lock\");\n}\n\nfunction telemetryFlushRunnerPath(): string {\n return path.join(resolvePmPackageRootFromModule(import.meta.url, [\"../../..\"]), \"dist\", \"cli\", \"telemetry-flush.js\");\n}\n\nfunction shouldFlushInline(): boolean {\n if (parseBooleanTrueLike(process.env[PM_TELEMETRY_INLINE_FLUSH_ENV])) {\n return true;\n }\n if (parseBooleanTrueLike(process.env[PM_TELEMETRY_FLUSH_CHILD_ENV])) {\n return true;\n }\n const nodeEnv = (process.env.NODE_ENV ?? \"\").trim().toLowerCase();\n return typeof process.env.VITEST === \"string\" || typeof process.env.VITEST_WORKER_ID === \"string\" || nodeEnv === \"test\";\n}\n\nasync function readRuntimeState(globalPmRoot: string): Promise<TelemetryRuntimeState> {\n const raw = await readFileIfExists(runtimeStatePath(globalPmRoot));\n if (!raw || raw.trim().length === 0) {\n return {};\n }\n try {\n const parsed = JSON.parse(raw) as TelemetryRuntimeState;\n if (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) {\n return {};\n }\n return parsed;\n } catch {\n return {};\n }\n}\n\nasync function writeRuntimeState(globalPmRoot: string, patch: TelemetryRuntimeState): Promise<void> {\n try {\n const current = await readRuntimeState(globalPmRoot);\n const next: TelemetryRuntimeState = {\n ...current,\n ...patch,\n };\n const normalized = Object.fromEntries(\n Object.entries(next)\n .filter(([, value]) => value !== undefined)\n .sort((left, right) => left[0].localeCompare(right[0])),\n );\n await writeFileAtomic(runtimeStatePath(globalPmRoot), `${JSON.stringify(normalized, null, 2)}\\n`);\n } catch {\n // Runtime state persistence is best effort and must not block command execution.\n }\n}\n\nfunction isSensitiveKey(key: string): boolean {\n const normalized = key.trim().toLowerCase().replaceAll(\"-\", \"_\").replaceAll(/[^a-z0-9_]+/g, \"_\");\n const tokens = normalized.split(\"_\").filter((token) => token.length > 0);\n return SENSITIVE_KEYWORDS.some(\n (keyword) => normalized === keyword || normalized.endsWith(`_${keyword}`) || tokens.includes(keyword),\n );\n}\n\nfunction redactInlineSensitiveAssignments(input: string): string {\n const withoutAssignments = input.replaceAll(\n INLINE_SENSITIVE_ASSIGNMENT_PATTERN,\n (_match: string, key: string, delimiter: string): string => `${key}${delimiter}[redacted]`,\n );\n return withoutAssignments.replaceAll(\n INLINE_SENSITIVE_FLAG_PATTERN,\n (_match: string, flag: string, delimiter: string): string => `${flag}${delimiter}[redacted]`,\n );\n}\n\nfunction redactAbsolutePathTokens(input: string): string {\n return input.replaceAll(\n ABSOLUTE_PATH_TOKEN_PATTERN,\n (_match: string, prefix: string): string => `${prefix}[redacted_path]`,\n );\n}\n\nfunction isAsciiLetterOrDigitCode(code: number): boolean {\n const isUpper = code >= 65 && code <= 90;\n const isLower = code >= 97 && code <= 122;\n const isDigit = code >= 48 && code <= 57;\n return isUpper || isLower || isDigit;\n}\n\nfunction isEmailLocalCharacter(character: string | undefined): boolean {\n if (!character) {\n return false;\n }\n const code = character.charCodeAt(0);\n if (isAsciiLetterOrDigitCode(code)) {\n return true;\n }\n return character === \".\" || character === \"_\" || character === \"%\" || character === \"+\" || character === \"-\";\n}\n\nfunction isEmailDomainCharacter(character: string | undefined): boolean {\n if (!character) {\n return false;\n }\n const code = character.charCodeAt(0);\n if (isAsciiLetterOrDigitCode(code)) {\n return true;\n }\n return character === \".\" || character === \"-\";\n}\n\nfunction looksLikeEmailToken(token: string): boolean {\n const atIndex = token.indexOf(\"@\");\n if (atIndex <= 0 || atIndex !== token.lastIndexOf(\"@\") || atIndex === token.length - 1) {\n return false;\n }\n const localPart = token.slice(0, atIndex);\n const domainPart = token.slice(atIndex + 1);\n const lastDot = domainPart.lastIndexOf(\".\");\n if (lastDot <= 0 || lastDot === domainPart.length - 1) {\n return false;\n }\n if (domainPart.length - (lastDot + 1) < 2) {\n return false;\n }\n for (const character of localPart) {\n if (!isEmailLocalCharacter(character)) {\n return false;\n }\n }\n for (const character of domainPart) {\n if (!isEmailDomainCharacter(character)) {\n return false;\n }\n }\n return true;\n}\n\nfunction redactEmailTokens(input: string): string {\n let redacted = \"\";\n let cursor = 0;\n while (cursor < input.length) {\n const atIndex = input.indexOf(\"@\", cursor);\n if (atIndex < 0) {\n redacted += input.slice(cursor);\n break;\n }\n let start = atIndex - 1;\n while (start >= cursor && isEmailLocalCharacter(input[start])) {\n start -= 1;\n }\n start += 1;\n let end = atIndex + 1;\n while (end < input.length && isEmailDomainCharacter(input[end])) {\n end += 1;\n }\n const candidate = input.slice(start, end);\n if (looksLikeEmailToken(candidate)) {\n redacted += input.slice(cursor, start);\n redacted += \"[redacted_email]\";\n cursor = end;\n continue;\n }\n redacted += input.slice(cursor, atIndex + 1);\n cursor = atIndex + 1;\n }\n return redacted;\n}\n\nfunction sanitizeCommonSensitiveTokens(input: string): string {\n const withoutEmails = redactEmailTokens(input);\n const withoutBearer = withoutEmails.replaceAll(BEARER_TOKEN_PATTERN, \"bearer [redacted_token]\");\n return withoutBearer.replaceAll(PRIVATE_IP_PATTERN, \"[redacted_ip]\");\n}\n\nfunction sanitizeStringRedacted(input: string): string {\n const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);\n const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);\n const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);\n const trimmed = withoutAbsolutePaths.trim();\n if (trimmed.startsWith(\"/\") && trimmed.length > 1) {\n return \"[redacted_path]\";\n }\n if (withoutAbsolutePaths.length > 512) {\n return `${withoutAbsolutePaths.slice(0, 509)}...`;\n }\n return withoutAbsolutePaths;\n}\n\nfunction sanitizeStringMax(input: string): string {\n const withoutCommonSensitiveTokens = sanitizeCommonSensitiveTokens(input);\n const withoutInlineSecrets = redactInlineSensitiveAssignments(withoutCommonSensitiveTokens);\n const withoutAbsolutePaths = redactAbsolutePathTokens(withoutInlineSecrets);\n const trimmed = withoutAbsolutePaths.trim();\n if (trimmed.startsWith(\"/\") && trimmed.length > 1) {\n return \"[redacted_path]\";\n }\n if (withoutAbsolutePaths.length > 2048) {\n return `${withoutAbsolutePaths.slice(0, 2045)}...`;\n }\n return withoutAbsolutePaths;\n}\n\nfunction sanitizeString(input: string, captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\"): string {\n if (captureLevel === \"max\") {\n return sanitizeStringMax(input);\n }\n return sanitizeStringRedacted(input);\n}\n\nfunction sanitizeValue(\n value: unknown,\n keyHint?: string,\n captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\",\n depth = 0,\n): unknown {\n if (keyHint && isSensitiveKey(keyHint)) {\n return \"[redacted]\";\n }\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"string\") {\n return sanitizeString(value, captureLevel);\n }\n if (typeof value === \"number\" || typeof value === \"boolean\") {\n return value;\n }\n if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {\n return \"[depth_truncated]\";\n }\n if (Array.isArray(value)) {\n return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => sanitizeValue(entry, undefined, captureLevel, depth + 1));\n }\n if (typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n const sanitized: Record<string, unknown> = {};\n for (const [key, nested] of Object.entries(record)) {\n sanitized[key] = sanitizeValue(nested, key, captureLevel, depth + 1);\n }\n return sanitized;\n }\n return String(value);\n}\n\nfunction sanitizeCommandArgs(\n args: string[],\n captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\",\n): string[] {\n const sanitized: string[] = [];\n let nextIsSensitiveValue = false;\n for (const rawArg of args) {\n const arg = sanitizeString(rawArg, captureLevel);\n if (nextIsSensitiveValue) {\n sanitized.push(\"[redacted]\");\n nextIsSensitiveValue = false;\n continue;\n }\n if (arg.startsWith(\"--\")) {\n const withoutPrefix = arg.slice(2);\n const delimiterIndex = withoutPrefix.indexOf(\"=\");\n if (delimiterIndex >= 0) {\n const key = withoutPrefix.slice(0, delimiterIndex);\n const value = withoutPrefix.slice(delimiterIndex + 1);\n if (isSensitiveKey(key)) {\n sanitized.push(`--${key}=[redacted]`);\n } else {\n sanitized.push(`--${key}=${sanitizeString(value, captureLevel)}`);\n }\n continue;\n }\n if (isSensitiveKey(withoutPrefix)) {\n sanitized.push(`--${withoutPrefix}`);\n nextIsSensitiveValue = true;\n continue;\n }\n }\n sanitized.push(arg);\n }\n return sanitized;\n}\n\nfunction normalizeCaptureLevel(value: string | undefined): TelemetryCaptureLevel {\n const normalized = value?.trim().toLowerCase();\n if (normalized === \"minimal\" || normalized === \"redacted\" || normalized === \"max\") {\n return normalized;\n }\n return \"redacted\";\n}\n\nfunction parseBooleanTrueLike(value: string | undefined): boolean {\n return BOOLEAN_TRUE_VALUES.has((value ?? \"\").trim().toLowerCase());\n}\n\nfunction normalizePmVersion(value: string | undefined): string {\n const trimmed = value?.trim() ?? \"\";\n return trimmed.length > 0 ? trimmed : \"0.0.0\";\n}\n\nfunction normalizeTelemetryErrorCode(value: string | undefined): string | undefined {\n const normalized = value?.trim();\n return normalized && normalized.length > 0 ? normalized : undefined;\n}\n\nfunction normalizeTelemetryExitCode(exitCode: number | undefined, ok: boolean): number {\n if (Number.isFinite(exitCode)) {\n return Math.max(0, Math.trunc(exitCode ?? 0));\n }\n return ok ? 0 : 1;\n}\n\nfunction normalizeTelemetryErrorCategory(params: {\n ok: boolean;\n errorCode?: string;\n errorCategory?: TelemetryErrorCategory;\n}): TelemetryErrorCategory | undefined {\n if (params.ok) {\n return undefined;\n }\n if (typeof params.errorCategory === \"string\" && params.errorCategory.trim().length > 0) {\n return params.errorCategory;\n }\n if (typeof params.errorCode === \"string\" && params.errorCode.trim().length > 0) {\n return resolveTelemetryErrorCategory(params.errorCode);\n }\n return \"unknown\";\n}\n\nfunction resolveTelemetrySourceContext(globalOptions: GlobalOptions): ResolvedTelemetrySourceContext {\n const override = (process.env[PM_TELEMETRY_SOURCE_CONTEXT_ENV] ?? \"\").trim().toLowerCase();\n if (PM_TELEMETRY_SOURCE_CONTEXT_SET.has(override)) {\n return {\n source_context: override as TelemetrySourceContext,\n source_context_source: \"env_override\",\n };\n }\n const nodeEnv = (process.env.NODE_ENV ?? \"\").trim().toLowerCase();\n if (typeof process.env.VITEST === \"string\" || typeof process.env.VITEST_WORKER_ID === \"string\" || nodeEnv === \"test\") {\n return {\n source_context: \"test\",\n source_context_source: \"inferred\",\n };\n }\n const nonTty = process.stdin.isTTY !== true || process.stdout.isTTY !== true;\n const ci = parseBooleanTrueLike(process.env.CI);\n const scriptLikeMode = globalOptions.json === true || globalOptions.quiet === true;\n if (nonTty || ci || scriptLikeMode) {\n return {\n source_context: \"automation\",\n source_context_source: \"inferred\",\n };\n }\n return {\n source_context: \"user\",\n source_context_source: \"inferred\",\n };\n}\n\nfunction hashWithInstallationId(installationId: string, value: string): string {\n return crypto.createHash(\"sha256\").update(`${installationId}:${value}`).digest(\"hex\");\n}\n\nfunction normalizeForHash(value: unknown, depth = 0): unknown {\n if (value === null || value === undefined) {\n return value;\n }\n if (typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\") {\n return value;\n }\n if (depth >= TELEMETRY_SANITIZE_MAX_DEPTH) {\n return \"[depth_truncated]\";\n }\n if (Array.isArray(value)) {\n return value.slice(0, TELEMETRY_SANITIZE_MAX_ARRAY_ITEMS).map((entry) => normalizeForHash(entry, depth + 1));\n }\n if (typeof value === \"object\") {\n const record = value as Record<string, unknown>;\n const normalized: Record<string, unknown> = {};\n const sortedKeys = Object.keys(record).sort((left, right) => left.localeCompare(right));\n for (const key of sortedKeys) {\n normalized[key] = normalizeForHash(record[key], depth + 1);\n }\n return normalized;\n }\n return String(value);\n}\n\nfunction hashTelemetryValue(installationId: string, value: unknown): string {\n return hashWithInstallationId(installationId, JSON.stringify(normalizeForHash(value)));\n}\n\nfunction hashCommandArgs(installationId: string, args: string[]): { hashes: string[]; digest: string } {\n return {\n hashes: args.map((arg) => hashWithInstallationId(installationId, arg)),\n digest: hashWithInstallationId(installationId, args.join(\"\\u0000\")),\n };\n}\n\nfunction hashTelemetryErrorFingerprint(\n installationId: string,\n command: string,\n errorCode: string | undefined,\n errorMessage: string | undefined,\n): string {\n const normalizedMessage = sanitizeString(errorMessage ?? \"\", \"redacted\");\n const fingerprintSource = `${command}\\u0000${errorCode ?? \"unknown_error\"}\\u0000${normalizedMessage}`;\n return hashWithInstallationId(installationId, fingerprintSource);\n}\n\nfunction telemetryDisabledByEnvironment(): boolean {\n return (\n PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_TELEMETRY_DISABLED_ENV] ?? \"\").trim().toLowerCase()) ||\n PM_TELEMETRY_DISABLED_VALUES.has((process.env[PM_NO_TELEMETRY_ENV] ?? \"\").trim().toLowerCase())\n );\n}\n\nfunction resolveOtelTracesEndpoint(): string | null {\n if (PM_TELEMETRY_OTEL_DISABLED_VALUES.has((process.env[PM_TELEMETRY_OTEL_DISABLED_ENV] ?? \"\").trim().toLowerCase())) {\n return null;\n }\n\n const directEndpoint = (process.env[OTEL_TRACES_ENDPOINT_ENV] ?? \"\").trim();\n if (directEndpoint.length > 0) {\n try {\n return new URL(directEndpoint).toString();\n } catch {\n return null;\n }\n }\n\n const baseEndpoint = (process.env[OTEL_BASE_ENDPOINT_ENV] ?? \"\").trim();\n if (baseEndpoint.length === 0) {\n return null;\n }\n\n try {\n const url = new URL(baseEndpoint);\n const normalizedPath = url.pathname.replace(/\\/+$/, \"\");\n if (!normalizedPath.endsWith(\"/v1/traces\")) {\n url.pathname = `${normalizedPath.length === 0 ? \"\" : normalizedPath}/v1/traces`;\n }\n return url.toString();\n } catch {\n return null;\n }\n}\n\nfunction isoToUnixNano(iso: string): string {\n const parsedMs = Date.parse(iso);\n const epochMs = Number.isNaN(parsedMs) ? Date.now() : parsedMs;\n return `${BigInt(epochMs) * 1_000_000n}`;\n}\n\nfunction otlpStringAttribute(key: string, value: string): { key: string; value: { stringValue: string } } {\n return {\n key,\n value: { stringValue: value },\n };\n}\n\nfunction otlpBoolAttribute(key: string, value: boolean): { key: string; value: { boolValue: boolean } } {\n return {\n key,\n value: { boolValue: value },\n };\n}\n\nfunction otlpIntAttribute(key: string, value: number): { key: string; value: { intValue: string } } {\n return {\n key,\n value: { intValue: String(Math.max(0, Math.trunc(value))) },\n };\n}\n\nasync function exportLocalOtelSpan(\n activeCommand: ActiveTelemetryCommand,\n outcome: { ok: boolean; error?: string; exit_code?: number; error_code?: string; error_category?: TelemetryErrorCategory },\n finishedAtIso: string,\n durationMs: number,\n): Promise<void> {\n if (\n typeof activeCommand.otel_traces_endpoint !== \"string\" ||\n activeCommand.otel_traces_endpoint.trim().length === 0 ||\n typeof activeCommand.otel_trace_id !== \"string\" ||\n activeCommand.otel_trace_id.length === 0 ||\n typeof activeCommand.otel_span_id !== \"string\" ||\n activeCommand.otel_span_id.length === 0\n ) {\n return;\n }\n\n const serviceNameCandidate = sanitizeString((process.env[OTEL_SERVICE_NAME_ENV] ?? \"\").trim());\n const serviceName = serviceNameCandidate.length > 0 ? serviceNameCandidate : \"pm-cli\";\n const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);\n const normalizedErrorCode = normalizeTelemetryErrorCode(outcome.error_code);\n const normalizedErrorCategory = normalizeTelemetryErrorCategory({\n ok: outcome.ok,\n errorCode: normalizedErrorCode,\n errorCategory: outcome.error_category,\n });\n const attributes: Array<\n | ReturnType<typeof otlpStringAttribute>\n | ReturnType<typeof otlpBoolAttribute>\n | ReturnType<typeof otlpIntAttribute>\n > = [\n otlpStringAttribute(\"pm.command\", sanitizeString(activeCommand.command)),\n otlpStringAttribute(\"pm.version\", activeCommand.pm_version),\n otlpStringAttribute(\"pm.source_context\", activeCommand.source_context),\n otlpStringAttribute(\"pm.source_context_source\", activeCommand.source_context_source),\n otlpStringAttribute(\"pm.installation_id\", activeCommand.installation_id),\n otlpStringAttribute(\"pm.session_id\", PROCESS_SESSION_ID),\n otlpStringAttribute(\"pm.pm_root_hash\", activeCommand.pm_root_hash),\n otlpStringAttribute(\"pm.cwd_hash\", activeCommand.cwd_hash),\n otlpBoolAttribute(\"pm.ok\", outcome.ok),\n otlpIntAttribute(\"pm.exit_code\", normalizedExitCode),\n otlpIntAttribute(\"pm.duration_ms\", durationMs),\n ];\n if (typeof normalizedErrorCode === \"string\") {\n attributes.push(otlpStringAttribute(\"pm.error_code\", normalizedErrorCode));\n }\n if (typeof normalizedErrorCategory === \"string\") {\n attributes.push(otlpStringAttribute(\"pm.error_category\", normalizedErrorCategory));\n }\n if (typeof outcome.error === \"string\" && outcome.error.trim().length > 0) {\n attributes.push(otlpStringAttribute(\"pm.error\", sanitizeString(outcome.error)));\n }\n\n const payload = {\n resourceSpans: [\n {\n resource: {\n attributes: [otlpStringAttribute(\"service.name\", serviceName)],\n },\n scopeSpans: [\n {\n scope: {\n name: \"pm-cli.telemetry\",\n version: \"1\",\n },\n spans: [\n {\n traceId: activeCommand.otel_trace_id,\n spanId: activeCommand.otel_span_id,\n name: `pm.command.${sanitizeString(activeCommand.command)}`,\n kind: 1,\n startTimeUnixNano: isoToUnixNano(activeCommand.started_at),\n endTimeUnixNano: isoToUnixNano(finishedAtIso),\n attributes,\n status: {\n code: outcome.ok ? 1 : 2,\n message: outcome.ok ? \"\" : sanitizeString(outcome.error ?? \"command_failed\"),\n },\n },\n ],\n },\n ],\n },\n ],\n };\n\n const response = await fetch(activeCommand.otel_traces_endpoint, {\n method: \"POST\",\n headers: {\n \"content-type\": \"application/json\",\n },\n body: JSON.stringify(payload),\n signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS),\n });\n if (!response.ok) {\n throw new Error(`local_otel_export_http_${response.status}`);\n }\n}\n\nfunction summarizeResult(\n result: unknown,\n captureLevel: Exclude<TelemetryCaptureLevel, \"minimal\"> = \"redacted\",\n): Record<string, unknown> {\n if (result === null || result === undefined) {\n return { type: \"nullish\" };\n }\n if (typeof result === \"string\") {\n return { type: \"string\", value: sanitizeString(result, captureLevel) };\n }\n if (typeof result === \"number\" || typeof result === \"boolean\") {\n return { type: typeof result, value: result };\n }\n if (Array.isArray(result)) {\n return {\n type: \"array\",\n length: result.length,\n sample: result.slice(0, 5).map((entry) => sanitizeValue(entry, undefined, captureLevel)),\n };\n }\n if (typeof result === \"object\") {\n const record = result as Record<string, unknown>;\n const keys = Object.keys(record).sort((left, right) => left.localeCompare(right));\n const sanitized: Record<string, unknown> = {};\n let previewBytes = 0;\n for (const key of keys.slice(0, 25)) {\n const sanitizedValue = sanitizeValue(record[key], key, captureLevel);\n const entrySize = JSON.stringify(sanitizedValue)?.length ?? 0;\n if (previewBytes + entrySize > TELEMETRY_RESULT_PREVIEW_MAX_BYTES) {\n sanitized[key] = \"[preview_truncated]\";\n break;\n }\n previewBytes += entrySize;\n sanitized[key] = sanitizedValue;\n }\n return {\n type: \"object\",\n key_count: keys.length,\n keys_preview: keys.slice(0, 50),\n preview: sanitized,\n };\n }\n return { type: typeof result, value: String(result) };\n}\n\nfunction buildCommandStartPayload(params: {\n captureLevel: TelemetryCaptureLevel;\n context: TelemetryCommandContext;\n pmVersion: string;\n sourceContext: ResolvedTelemetrySourceContext;\n pmRootHash: string;\n cwdHash: string;\n installationId: string;\n}): Record<string, unknown> {\n const { captureLevel, context, pmVersion, sourceContext, pmRootHash, cwdHash, installationId } = params;\n const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);\n const hashedArgs = hashCommandArgs(installationId, context.args);\n const commandInvocationDigest = hashWithInstallationId(installationId, `${context.command}\\u0000${context.args.join(\"\\u0000\")}`);\n const commandOptionsDigest = hashTelemetryValue(installationId, context.options);\n const globalOptionsDigest = hashTelemetryValue(installationId, context.global);\n if (captureLevel === \"minimal\") {\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_args_digest: hashedArgs.digest,\n command_invocation_digest: commandInvocationDigest,\n command_options_digest: commandOptionsDigest,\n global_options_digest: globalOptionsDigest,\n };\n }\n return {\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_args: sanitizeCommandArgs(context.args, captureLevel),\n command_args_hashes: hashedArgs.hashes,\n command_args_digest: hashedArgs.digest,\n command_invocation_digest: commandInvocationDigest,\n command_options: sanitizeValue(context.options, undefined, captureLevel) as Record<string, unknown>,\n command_options_digest: commandOptionsDigest,\n global_options: sanitizeValue(context.global, undefined, captureLevel) as Record<string, unknown>,\n global_options_digest: globalOptionsDigest,\n pm_root_hash: pmRootHash,\n cwd_hash: cwdHash,\n capture_level: captureLevel,\n runtime: {\n node: process.version,\n platform: process.platform,\n arch: process.arch,\n hostname_hash: hashWithInstallationId(installationId, os.hostname()),\n stdin_tty: process.stdin.isTTY === true,\n stdout_tty: process.stdout.isTTY === true,\n },\n };\n}\n\nfunction buildCommandFinishPayload(params: {\n captureLevel: TelemetryCaptureLevel;\n pmVersion: string;\n sourceContext: ResolvedTelemetrySourceContext;\n outcome: TelemetryCommandOutcome;\n durationMs: number;\n startedAt: string;\n command: string;\n installationId: string;\n commandTaxonomy: TelemetryCommandTaxonomy;\n exitCode: number;\n errorCode?: string;\n errorCategory?: TelemetryErrorCategory;\n commandResolution: TelemetryCommandResolution;\n resolutionStage: TelemetryResolutionStage;\n}): Record<string, unknown> {\n const {\n captureLevel,\n pmVersion,\n sourceContext,\n outcome,\n durationMs,\n startedAt,\n command,\n installationId,\n commandTaxonomy,\n exitCode,\n errorCode,\n errorCategory,\n commandResolution,\n resolutionStage,\n } = params;\n const errorFingerprint =\n outcome.ok === false\n ? hashTelemetryErrorFingerprint(installationId, command, errorCode, outcome.error)\n : undefined;\n if (captureLevel === \"minimal\") {\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n ok: outcome.ok,\n exit_code: exitCode,\n error_code: errorCode,\n error_category: errorCategory,\n error: outcome.error ? sanitizeString(outcome.error, \"redacted\") : undefined,\n error_fingerprint: errorFingerprint,\n duration_ms: durationMs,\n };\n }\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n ok: outcome.ok,\n exit_code: exitCode,\n error_code: errorCode,\n error_category: errorCategory,\n error: outcome.error ? sanitizeString(outcome.error, captureLevel) : undefined,\n error_fingerprint: errorFingerprint,\n duration_ms: durationMs,\n started_at: startedAt,\n result_summary: summarizeResult(outcome.result, captureLevel),\n };\n}\n\nfunction buildCommandErrorPayload(params: {\n captureLevel: TelemetryCaptureLevel;\n pmVersion: string;\n sourceContext: ResolvedTelemetrySourceContext;\n command: string;\n commandTaxonomy: TelemetryCommandTaxonomy;\n commandResolution: TelemetryCommandResolution;\n resolutionStage: TelemetryResolutionStage;\n args: string[];\n options: Record<string, unknown>;\n pmRootHash: string;\n cwdHash: string;\n installationId: string;\n errorCode: string;\n errorMessage: string;\n errorCategory: TelemetryErrorCategory;\n exitCode: number;\n}): Record<string, unknown> {\n const {\n captureLevel,\n pmVersion,\n sourceContext,\n command,\n commandTaxonomy,\n commandResolution,\n resolutionStage,\n args,\n options,\n pmRootHash,\n cwdHash,\n installationId,\n errorCode,\n errorMessage,\n errorCategory,\n exitCode,\n } = params;\n const attemptedArgHashes = hashCommandArgs(installationId, args);\n const attemptedCommandDigest = hashWithInstallationId(installationId, command);\n const attemptedOptionsDigest = hashTelemetryValue(installationId, options);\n const errorFingerprint = hashTelemetryErrorFingerprint(installationId, command, errorCode, errorMessage);\n if (captureLevel === \"minimal\") {\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n attempted_command_digest: attemptedCommandDigest,\n attempted_args_digest: attemptedArgHashes.digest,\n attempted_options_digest: attemptedOptionsDigest,\n error_code: errorCode,\n error_category: errorCategory,\n exit_code: exitCode,\n error: sanitizeString(errorMessage, \"redacted\"),\n error_fingerprint: errorFingerprint,\n };\n }\n\n return {\n capture_level: captureLevel,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n command_taxonomy: commandTaxonomy,\n command_resolution: commandResolution,\n resolution_stage: resolutionStage,\n attempted_command: sanitizeString(command, captureLevel),\n attempted_command_digest: attemptedCommandDigest,\n attempted_args: sanitizeCommandArgs(args, captureLevel),\n attempted_args_hashes: attemptedArgHashes.hashes,\n attempted_args_digest: attemptedArgHashes.digest,\n attempted_options: sanitizeValue(options, undefined, captureLevel) as Record<string, unknown>,\n attempted_options_digest: attemptedOptionsDigest,\n error_code: errorCode,\n error_category: errorCategory,\n exit_code: exitCode,\n error: sanitizeString(errorMessage, captureLevel),\n error_fingerprint: errorFingerprint,\n pm_root_hash: pmRootHash,\n cwd_hash: cwdHash,\n runtime: {\n node: process.version,\n platform: process.platform,\n arch: process.arch,\n hostname_hash: hashWithInstallationId(installationId, os.hostname()),\n stdin_tty: process.stdin.isTTY === true,\n stdout_tty: process.stdout.isTTY === true,\n },\n };\n}\n\nasync function ensureInstallationId(\n globalPmRoot: string,\n): Promise<{ installationId: string; endpoint: string; retentionDays: number }> {\n const settings = await readSettings(globalPmRoot);\n let changed = false;\n if (settings.telemetry.installation_id.trim().length === 0) {\n settings.telemetry.installation_id = crypto.randomUUID();\n changed = true;\n }\n if (changed) {\n await writeSettings(globalPmRoot, settings, \"telemetry:install_id\");\n }\n return {\n installationId: settings.telemetry.installation_id,\n endpoint: settings.telemetry.endpoint,\n retentionDays: Math.max(1, Math.trunc(settings.telemetry.retention_days)),\n };\n}\n\nasync function enqueueTelemetryEvent(globalPmRoot: string, event: TelemetryEvent): Promise<void> {\n const queued: QueuedTelemetryEvent = {\n client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,\n event,\n attempts: 0,\n };\n let serialized = JSON.stringify(queued);\n if (serialized.length > TELEMETRY_MAX_EVENT_BYTES) {\n const trimmed = { ...event, payload: { ...event.payload, result_summary: { truncated: true, reason: \"payload_size_exceeded\", original_bytes: serialized.length } } };\n const trimmedQueued: QueuedTelemetryEvent = {\n client_schema_version: TELEMETRY_CLIENT_SCHEMA_VERSION,\n event: trimmed,\n attempts: 0,\n };\n serialized = JSON.stringify(trimmedQueued);\n }\n await withQueueMutation(async () => {\n await appendLineAtomic(queuePath(globalPmRoot), serialized);\n });\n}\n\nfunction parseQueueLines(raw: string): QueuedTelemetryEvent[] {\n const entries: QueuedTelemetryEvent[] = [];\n for (const line of raw.split(\"\\n\")) {\n const trimmed = line.trim();\n if (trimmed.length === 0) {\n continue;\n }\n try {\n const parsed = JSON.parse(trimmed) as QueuedTelemetryEvent;\n if (\n parsed &&\n typeof parsed === \"object\" &&\n parsed.event &&\n typeof parsed.event === \"object\" &&\n typeof parsed.attempts === \"number\" &&\n (\n parsed.client_schema_version === undefined ||\n (typeof parsed.client_schema_version === \"number\" && Number.isFinite(parsed.client_schema_version))\n )\n ) {\n entries.push(parsed);\n }\n } catch {\n // Drop malformed lines to preserve queue forward progress.\n }\n }\n return entries;\n}\n\nfunction nextRetryIso(attempts: number): string {\n const delay = Math.min(TELEMETRY_RETRY_BASE_DELAY_MS * 2 ** Math.max(attempts - 1, 0), TELEMETRY_MAX_RETRY_DELAY_MS);\n return new Date(Date.now() + delay).toISOString();\n}\n\nfunction isDueForRetry(entry: QueuedTelemetryEvent): boolean {\n if (typeof entry.next_attempt_after !== \"string\" || entry.next_attempt_after.trim().length === 0) {\n return true;\n }\n const dueAtMs = Date.parse(entry.next_attempt_after);\n if (Number.isNaN(dueAtMs)) {\n return true;\n }\n return dueAtMs <= Date.now();\n}\n\nfunction retentionCutoffMs(retentionDays: number): number {\n const normalizedDays = Number.isFinite(retentionDays) ? Math.max(1, Math.trunc(retentionDays)) : 1;\n return Date.now() - normalizedDays * MILLISECONDS_PER_DAY;\n}\n\nfunction isExpiredQueueEntry(entry: QueuedTelemetryEvent, cutoffMs: number): boolean {\n const occurredAt = entry.event?.occurred_at;\n if (typeof occurredAt !== \"string\" || occurredAt.trim().length === 0) {\n return false;\n }\n const occurredAtMs = Date.parse(occurredAt);\n if (Number.isNaN(occurredAtMs)) {\n return false;\n }\n return occurredAtMs < cutoffMs;\n}\n\nfunction pruneExpiredQueueEntries(\n entries: QueuedTelemetryEvent[],\n retentionDays: number,\n): { entries: QueuedTelemetryEvent[]; prunedCount: number } {\n const cutoffMs = retentionCutoffMs(retentionDays);\n const retained: QueuedTelemetryEvent[] = [];\n let prunedCount = 0;\n for (const entry of entries) {\n const serializedSize = JSON.stringify(entry).length;\n const oversized = serializedSize > TELEMETRY_MAX_EVENT_BYTES;\n if (oversized || isExpiredQueueEntry(entry, cutoffMs) || entry.attempts >= TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS) {\n prunedCount += 1;\n continue;\n }\n retained.push(entry);\n }\n return { entries: retained, prunedCount };\n}\n\nasync function rewriteQueue(globalPmRoot: string, entries: QueuedTelemetryEvent[]): Promise<void> {\n const serialized = entries.map((entry) => JSON.stringify(entry)).join(\"\\n\");\n const contents = serialized.length > 0 ? `${serialized}\\n` : \"\";\n for (let attempt = 0; ; attempt += 1) {\n try {\n await writeFileAtomic(queuePath(globalPmRoot), contents);\n return;\n } catch (error: unknown) {\n const retryDelay = TELEMETRY_QUEUE_REWRITE_RETRY_DELAYS_MS[attempt];\n if (retryDelay === undefined || !isRetryableQueueRewriteError(error)) {\n throw error;\n }\n await sleep(retryDelay);\n }\n }\n}\n\nfunction isRetryableQueueRewriteError(error: unknown): boolean {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return false;\n }\n const code = (error as { code?: unknown }).code;\n return code === \"EACCES\" || code === \"EBUSY\" || code === \"EPERM\";\n}\n\nfunction sleep(milliseconds: number): Promise<void> {\n return new Promise((resolve) => {\n setTimeout(resolve, milliseconds);\n });\n}\n\nasync function cleanupTelemetryQueueTempOrphans(\n globalPmRoot: string,\n maxAgeMs = TELEMETRY_QUEUE_TMP_ORPHAN_MAX_AGE_MS,\n): Promise<void> {\n try {\n const dirPath = telemetryRuntimeDirectory(globalPmRoot);\n const entries = await readdir(dirPath, { withFileTypes: true });\n const cutoffMs = Date.now() - Math.max(0, maxAgeMs);\n await Promise.all(\n entries\n .filter((entry) => entry.isFile() && /^\\.events\\.jsonl\\.\\d+\\.\\d+\\.[a-f0-9]+\\.tmp$/.test(entry.name))\n .map(async (entry) => {\n const candidate = path.join(dirPath, entry.name);\n const candidateStats = await stat(candidate);\n if (candidateStats.mtimeMs < cutoffMs) {\n await rm(candidate, { force: true });\n }\n }),\n );\n } catch {\n // Telemetry cleanup is best-effort and must not affect command execution.\n }\n}\n\nasync function withQueueMutation<T>(operation: () => Promise<T>): Promise<T> {\n const run = _queueMutationPromise.catch(() => {}).then(operation);\n _queueMutationPromise = run.catch(() => {});\n return run;\n}\n\nasync function readCurrentQueueEntries(globalPmRoot: string): Promise<QueuedTelemetryEvent[]> {\n const raw = await readFileIfExists(queuePath(globalPmRoot));\n if (raw === null || raw.trim().length === 0) {\n return [];\n }\n return parseQueueLines(raw);\n}\n\nasync function removeFlushedEntriesFromCurrentQueue(\n globalPmRoot: string,\n flushedIds: ReadonlySet<string>,\n retentionDays: number,\n): Promise<QueuedTelemetryEvent[]> {\n return withQueueMutation(async () => {\n const currentEntries = await readCurrentQueueEntries(globalPmRoot);\n const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);\n const remaining = retainedEntries.filter((entry) => !flushedIds.has(entry.event.event_id));\n await rewriteQueue(globalPmRoot, remaining);\n return remaining;\n });\n}\n\nasync function markFailedEntriesInCurrentQueue(\n globalPmRoot: string,\n failedIds: ReadonlySet<string>,\n attemptTime: string,\n retentionDays: number,\n): Promise<QueuedTelemetryEvent[]> {\n return withQueueMutation(async () => {\n const currentEntries = await readCurrentQueueEntries(globalPmRoot);\n const { entries: retainedEntries } = pruneExpiredQueueEntries(currentEntries, retentionDays);\n const retried = retainedEntries.map((entry) => {\n if (!failedIds.has(entry.event.event_id)) {\n return entry;\n }\n const attempts = entry.attempts + 1;\n return {\n ...entry,\n attempts,\n last_attempt_at: attemptTime,\n next_attempt_after: nextRetryIso(attempts),\n };\n });\n await rewriteQueue(globalPmRoot, retried);\n return retried;\n });\n}\n\nasync function flushQueue(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void> {\n await cleanupTelemetryQueueTempOrphans(globalPmRoot);\n const normalizedEndpoint = endpoint.trim();\n if (normalizedEndpoint.length === 0) {\n return;\n }\n const raw = await readFileIfExists(queuePath(globalPmRoot));\n if (raw === null || raw.trim().length === 0) {\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: 0,\n });\n return;\n }\n const queueEntries = parseQueueLines(raw);\n if (queueEntries.length === 0) {\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: 0,\n });\n return;\n }\n const { entries: retainedEntries, prunedCount } = pruneExpiredQueueEntries(queueEntries, retentionDays);\n if (retainedEntries.length === 0) {\n if (prunedCount > 0) {\n await rewriteQueue(globalPmRoot, []);\n }\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: 0,\n });\n return;\n }\n const dueEntries = retainedEntries.filter((entry) => isDueForRetry(entry)).slice(0, TELEMETRY_FLUSH_BATCH_SIZE);\n if (dueEntries.length === 0) {\n if (prunedCount > 0) {\n await rewriteQueue(globalPmRoot, retainedEntries);\n }\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: retainedEntries.length,\n });\n return;\n }\n const dueIds = new Set(dueEntries.map((entry) => entry.event.event_id));\n const attemptTime = nowIso();\n const requestHeaders: Record<string, string> = {\n \"content-type\": \"application/json\",\n };\n const ingestKey = process.env.PM_TELEMETRY_INGEST_KEY?.trim();\n if (ingestKey) {\n requestHeaders[\"x-pm-telemetry-key\"] = ingestKey;\n }\n\n try {\n const response = await fetch(normalizedEndpoint, {\n method: \"POST\",\n headers: requestHeaders,\n body: JSON.stringify({\n schema_version: TELEMETRY_SCHEMA_VERSION,\n events: dueEntries.map((entry) => entry.event),\n }),\n signal: AbortSignal.timeout(TELEMETRY_HTTP_TIMEOUT_MS),\n });\n if (!response.ok) {\n throw new Error(`telemetry_flush_http_${response.status}`);\n }\n } catch (error: unknown) {\n const retried = await markFailedEntriesInCurrentQueue(globalPmRoot, dueIds, attemptTime, retentionDays);\n const errorMessage = (() => {\n if (error instanceof Error) {\n return sanitizeString(error.message, \"redacted\");\n }\n return \"telemetry_flush_failed\";\n })();\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: retried.length,\n last_attempted_flush_at: attemptTime,\n last_failed_flush_at: attemptTime,\n last_failed_flush_error: errorMessage,\n });\n return;\n }\n\n try {\n const remaining = await removeFlushedEntriesFromCurrentQueue(globalPmRoot, dueIds, retentionDays);\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: remaining.length,\n last_attempted_flush_at: attemptTime,\n last_successful_flush_at: attemptTime,\n last_failed_flush_at: undefined,\n last_failed_flush_error: undefined,\n });\n } catch (error: unknown) {\n const errorMessage = (() => {\n if (error instanceof Error) {\n return sanitizeString(error.message, \"redacted\");\n }\n return \"telemetry_flush_failed\";\n })();\n const currentEntries = await readCurrentQueueEntries(globalPmRoot).catch(() => retainedEntries);\n await writeRuntimeState(globalPmRoot, {\n endpoint: normalizedEndpoint,\n queue_entries: currentEntries.length,\n last_attempted_flush_at: attemptTime,\n last_failed_flush_at: attemptTime,\n last_failed_flush_error: errorMessage,\n });\n }\n}\n\nasync function acquireTelemetryFlushLock(globalPmRoot: string): Promise<boolean> {\n const lockPath = flushLockPath(globalPmRoot);\n await mkdir(path.dirname(lockPath), { recursive: true });\n try {\n await mkdir(lockPath);\n return true;\n } catch (error: unknown) {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error) || (error as { code?: unknown }).code !== \"EEXIST\") {\n throw error;\n }\n }\n\n try {\n const lockStats = await stat(lockPath);\n if (Date.now() - lockStats.mtimeMs < TELEMETRY_FLUSH_LOCK_STALE_MS) {\n return false;\n }\n await rm(lockPath, { recursive: true, force: true });\n await mkdir(lockPath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction isFreshDirectoryLock(lockPath: string, staleMs: number): boolean {\n try {\n return Date.now() - statSync(lockPath).mtimeMs < staleMs;\n } catch {\n return false;\n }\n}\n\nfunction removeDirectoryLockBestEffort(lockPath: string): void {\n try {\n rmSync(lockPath, { recursive: true, force: true });\n } catch {\n // Flush scheduling is best effort and must never fail user commands.\n }\n}\n\nfunction errorCode(error: unknown): string | undefined {\n if (typeof error !== \"object\" || error === null || !(\"code\" in error)) {\n return undefined;\n }\n const code = (error as { code?: unknown }).code;\n return typeof code === \"string\" ? code : undefined;\n}\n\nfunction createDirectoryLock(lockPath: string): boolean {\n try {\n mkdirSync(lockPath);\n return true;\n } catch (error: unknown) {\n const code = errorCode(error);\n if (code === \"EEXIST\") {\n return false;\n }\n if (code !== \"ENOENT\") {\n return false;\n }\n }\n\n try {\n mkdirSync(path.dirname(lockPath), { recursive: true });\n mkdirSync(lockPath);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction acquireTelemetryFlushSpawnGate(globalPmRoot: string): boolean {\n if (isFreshDirectoryLock(flushLockPath(globalPmRoot), TELEMETRY_FLUSH_LOCK_STALE_MS)) {\n return false;\n }\n\n const lockPath = flushSpawnLockPath(globalPmRoot);\n try {\n if (Date.now() - statSync(lockPath).mtimeMs < TELEMETRY_FLUSH_SPAWN_LOCK_STALE_MS) {\n return false;\n }\n removeDirectoryLockBestEffort(lockPath);\n } catch (error: unknown) {\n if (errorCode(error) !== \"ENOENT\") {\n return false;\n }\n }\n\n return createDirectoryLock(lockPath);\n}\n\nfunction releaseTelemetryFlushSpawnGate(globalPmRoot: string): void {\n removeDirectoryLockBestEffort(flushSpawnLockPath(globalPmRoot));\n}\n\nexport const _testOnly = {\n acquireTelemetryFlushSpawnGate,\n releaseTelemetryFlushSpawnGate,\n flushLockPath,\n flushSpawnLockPath,\n};\n\nasync function flushQueueWithProcessLock(globalPmRoot: string, endpoint: string, retentionDays: number): Promise<void> {\n const acquired = await acquireTelemetryFlushLock(globalPmRoot);\n releaseTelemetryFlushSpawnGate(globalPmRoot);\n if (!acquired) {\n return;\n }\n try {\n await flushQueue(globalPmRoot, endpoint, retentionDays);\n } finally {\n await rm(flushLockPath(globalPmRoot), { recursive: true, force: true }).catch(() => {});\n }\n}\n\nfunction scheduleTelemetryFlush(globalPmRoot: string, endpoint: string, retentionDays: number): void {\n if (shouldFlushInline()) {\n const previousFlush = _lastFlushPromise;\n const nextFlush = flushQueue(globalPmRoot, endpoint, retentionDays).catch(() => {});\n _lastFlushPromise = Promise.allSettled([previousFlush, nextFlush]).then(() => {});\n return;\n }\n\n try {\n const acquiredSpawnGate = acquireTelemetryFlushSpawnGate(globalPmRoot);\n if (!acquiredSpawnGate) {\n return;\n }\n const child = spawn(process.execPath, [telemetryFlushRunnerPath()], {\n detached: true,\n stdio: \"ignore\",\n env: {\n ...process.env,\n PM_GLOBAL_PATH: globalPmRoot,\n [PM_TELEMETRY_FLUSH_CHILD_ENV]: \"1\",\n },\n });\n child.unref();\n } catch {\n releaseTelemetryFlushSpawnGate(globalPmRoot);\n // Flush scheduling is best effort and must not keep the CLI alive.\n }\n}\n\nexport async function flushTelemetryQueueNow(globalPmRoot = resolveGlobalPmRoot(process.cwd())): Promise<void> {\n if (telemetryDisabledByEnvironment()) {\n return;\n }\n try {\n const settings = await readSettings(globalPmRoot);\n if (!settings.telemetry.enabled) {\n return;\n }\n const { endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);\n await flushQueueWithProcessLock(globalPmRoot, endpoint, retentionDays);\n } catch {\n // Telemetry workers are best effort and must never fail user commands.\n }\n}\n\nexport async function startTelemetryCommand(context: TelemetryCommandContext): Promise<ActiveTelemetryCommand | null> {\n if (telemetryDisabledByEnvironment()) {\n return null;\n }\n if (\n context.command === \"telemetry\" &&\n context.args.some((token) => token.trim().toLowerCase() === \"clear\")\n ) {\n return null;\n }\n try {\n const globalPmRoot = resolveGlobalPmRoot(process.cwd());\n const settings = await readSettings(globalPmRoot);\n if (!settings.telemetry.enabled) {\n return null;\n }\n const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);\n const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);\n const pmVersion = normalizePmVersion(context.pm_version);\n const sourceContext = resolveTelemetrySourceContext(context.global);\n const pmRootHash = hashWithInstallationId(installationId, context.pm_root);\n const cwdHash = hashWithInstallationId(installationId, process.cwd());\n const otelTracesEndpoint = resolveOtelTracesEndpoint();\n const occurredAt = nowIso();\n const event: TelemetryEvent = {\n schema_version: TELEMETRY_SCHEMA_VERSION,\n event_id: crypto.randomUUID(),\n event_type: \"command_start\",\n occurred_at: occurredAt,\n installation_id: installationId,\n session_id: PROCESS_SESSION_ID,\n command: context.command,\n payload: buildCommandStartPayload({\n captureLevel,\n context,\n pmVersion,\n sourceContext,\n pmRootHash,\n cwdHash,\n installationId,\n }),\n };\n await enqueueTelemetryEvent(globalPmRoot, event);\n scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);\n const commandTaxonomy = deriveTelemetryCommandTaxonomy(context.command);\n return {\n started_at: occurredAt,\n started_at_ms: Date.now(),\n command: context.command,\n command_taxonomy: commandTaxonomy,\n pm_version: pmVersion,\n source_context: sourceContext.source_context,\n source_context_source: sourceContext.source_context_source,\n installation_id: installationId,\n pm_root_hash: pmRootHash,\n cwd_hash: cwdHash,\n endpoint,\n retention_days: retentionDays,\n global_pm_root: globalPmRoot,\n capture_level: captureLevel,\n otel_traces_endpoint: otelTracesEndpoint ?? undefined,\n otel_trace_id: otelTracesEndpoint ? crypto.randomBytes(16).toString(\"hex\") : undefined,\n otel_span_id: otelTracesEndpoint ? crypto.randomBytes(8).toString(\"hex\") : undefined,\n };\n } catch {\n // Telemetry must never block command execution.\n return null;\n }\n}\n\nexport async function finishTelemetryCommand(\n activeCommand: ActiveTelemetryCommand | null,\n outcome: TelemetryCommandOutcome,\n): Promise<void> {\n if (!activeCommand) {\n return;\n }\n try {\n const finishedAt = nowIso();\n const durationMs = Math.max(0, Date.now() - activeCommand.started_at_ms);\n const normalizedErrorCode = normalizeTelemetryErrorCode(\n inferTelemetryErrorCode({\n ok: outcome.ok,\n errorCode: outcome.error_code,\n errorMessage: outcome.error,\n exitCode: outcome.exit_code,\n }),\n );\n const normalizedErrorCategory = normalizeTelemetryErrorCategory({\n ok: outcome.ok,\n errorCode: normalizedErrorCode,\n errorCategory: outcome.error_category,\n });\n const normalizedExitCode = normalizeTelemetryExitCode(outcome.exit_code, outcome.ok);\n const commandResolution =\n outcome.command_resolution ??\n deriveTelemetryCommandResolution({\n ok: outcome.ok,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n });\n const resolutionStage = outcome.resolution_stage ?? \"execute\";\n const event: TelemetryEvent = {\n schema_version: TELEMETRY_SCHEMA_VERSION,\n event_id: crypto.randomUUID(),\n event_type: \"command_finish\",\n occurred_at: finishedAt,\n installation_id: activeCommand.installation_id,\n session_id: PROCESS_SESSION_ID,\n command: activeCommand.command,\n payload: buildCommandFinishPayload({\n captureLevel: activeCommand.capture_level,\n pmVersion: activeCommand.pm_version,\n sourceContext: {\n source_context: activeCommand.source_context,\n source_context_source: activeCommand.source_context_source,\n },\n outcome,\n durationMs,\n startedAt: activeCommand.started_at,\n command: activeCommand.command,\n installationId: activeCommand.installation_id,\n commandTaxonomy: activeCommand.command_taxonomy,\n exitCode: normalizedExitCode,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n commandResolution,\n resolutionStage,\n }),\n };\n await enqueueTelemetryEvent(activeCommand.global_pm_root, event);\n scheduleTelemetryFlush(activeCommand.global_pm_root, activeCommand.endpoint, activeCommand.retention_days);\n void exportLocalOtelSpan(\n activeCommand,\n {\n ...outcome,\n exit_code: normalizedExitCode,\n error_code: normalizedErrorCode,\n error_category: normalizedErrorCategory,\n },\n finishedAt,\n durationMs,\n ).catch(() => {});\n } catch {\n // Telemetry must never block command execution.\n }\n}\n\nexport async function emitTelemetryErrorEvent(context: TelemetryErrorEventContext): Promise<void> {\n if (telemetryDisabledByEnvironment()) {\n return;\n }\n try {\n const globalPmRoot = resolveGlobalPmRoot(process.cwd());\n const settings = await readSettings(globalPmRoot);\n if (!settings.telemetry.enabled) {\n return;\n }\n const captureLevel = normalizeCaptureLevel(settings.telemetry.capture_level);\n const { installationId, endpoint, retentionDays } = await ensureInstallationId(globalPmRoot);\n const pmVersion = normalizePmVersion(context.pm_version);\n const sourceContext = resolveTelemetrySourceContext(context.global);\n const pmRootHash = hashWithInstallationId(installationId, context.pm_root);\n const cwdHash = hashWithInstallationId(installationId, process.cwd());\n const occurredAt = nowIso();\n const normalizedErrorCode =\n normalizeTelemetryErrorCode(\n inferTelemetryErrorCode({\n ok: false,\n errorCode: context.error_code,\n errorMessage: context.error_message,\n exitCode: context.exit_code,\n }),\n ) ?? \"unknown_error\";\n const normalizedErrorCategory =\n context.error_category ?? resolveTelemetryErrorCategory(normalizedErrorCode);\n const normalizedExitCode = normalizeTelemetryExitCode(context.exit_code, false);\n const normalizedCommand = context.command.trim().length > 0 ? context.command : \"<unknown>\";\n const commandTaxonomy = deriveTelemetryCommandTaxonomy(normalizedCommand);\n const commandResolution =\n context.command_resolution ??\n deriveTelemetryCommandResolution({\n ok: false,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n });\n const resolutionStage = context.resolution_stage ?? \"unknown\";\n\n const event: TelemetryEvent = {\n schema_version: TELEMETRY_SCHEMA_VERSION,\n event_id: crypto.randomUUID(),\n event_type: \"command_error\",\n occurred_at: occurredAt,\n installation_id: installationId,\n session_id: PROCESS_SESSION_ID,\n command: sanitizeString(normalizedCommand, \"redacted\"),\n payload: buildCommandErrorPayload({\n captureLevel,\n pmVersion,\n sourceContext,\n command: normalizedCommand,\n commandTaxonomy,\n commandResolution,\n resolutionStage,\n args: context.args,\n options: context.options,\n pmRootHash,\n cwdHash,\n installationId,\n errorCode: normalizedErrorCode,\n errorCategory: normalizedErrorCategory,\n exitCode: normalizedExitCode,\n errorMessage: context.error_message,\n }),\n };\n await enqueueTelemetryEvent(globalPmRoot, event);\n scheduleTelemetryFlush(globalPmRoot, endpoint, retentionDays);\n } catch {\n // Telemetry must never block command execution.\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAM,sBAAsB,oBAAI,IAAI,CAAC,QAAQ,UAAU,cAAc,uBAAuB,mBAAmB,kBAAkB,CAAC;AAClI,IAAM,sBAAsB,oBAAI,IAAI;EAClC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,IAAM,yBAAyB,oBAAI,IAAI;EACrC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD,IAAM,wBAAwB,oBAA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chunk-WNMRICXH.js";
7
7
 
8
8
  // dist/core/item/id.js
9
9
  import crypto from "node:crypto";
@@ -70,6 +70,6 @@ export {
70
70
  normalizeItemId,
71
71
  generateItemId
72
72
  };
73
- //# sourceMappingURL=chunk-7CR4GAYN.js.map
73
+ //# sourceMappingURL=chunk-UDWUDUJI.js.map
74
74
 
75
75
  //# debugId=fee16454-2fff-5dc9-8e3e-374148e3e18f
@@ -4,13 +4,13 @@ import {
4
4
  runActiveRendererOverride,
5
5
  runActiveServiceOverrideSync,
6
6
  setActiveCommandResult
7
- } from "./chunk-C72IQIBT.js";
7
+ } from "./chunk-OQGJSCZZ.js";
8
8
 
9
9
  // dist/core/output/mutation-projection.js
10
10
  !(function() {
11
11
  try {
12
12
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
13
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "5de7498f-df5a-5529-9058-a127633bba2d");
13
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "3dd31047-1b72-59b3-a03a-50eed2c86ff3");
14
14
  } catch (e2) {
15
15
  }
16
16
  })();
@@ -52,6 +52,13 @@ function replaceRows(envelope, rows) {
52
52
  return projected;
53
53
  }
54
54
  function projectMutationResult(result, options = {}) {
55
+ if (options.idOnly === true && isPlainObject(result) && isPlainObject(result.item)) {
56
+ const id = typeof result.item.id === "string" ? result.item.id : void 0;
57
+ const status = typeof result.item.status === "string" ? result.item.status : void 0;
58
+ if (id) {
59
+ return status ? { id, status } : { id };
60
+ }
61
+ }
55
62
  const mode = options.changedFields ?? "full";
56
63
  if (mode === "full" || !isPlainObject(result)) {
57
64
  return result;
@@ -89,7 +96,7 @@ function projectMutationResult(result, options = {}) {
89
96
  !(function() {
90
97
  try {
91
98
  var e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
92
- n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "9759da9d-e64a-537d-99ac-6e25ee5357a6");
99
+ n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "e5eeb823-9fe2-5c10-93b8-1d2ab95a411c");
93
100
  } catch (e2) {
94
101
  }
95
102
  })();
@@ -318,7 +325,7 @@ function formatOutput(result, options) {
318
325
  `;
319
326
  }
320
327
  function printResult(result, options) {
321
- const projected = options.noChangedFields ? projectMutationResult(result, { changedFields: "compact" }) : result;
328
+ const projected = options.idOnly ? projectMutationResult(result, { idOnly: true }) : options.noChangedFields ? projectMutationResult(result, { changedFields: "compact" }) : result;
322
329
  const rendered = formatOutput(projected, options);
323
330
  if (options.quiet) {
324
331
  return;
@@ -339,4 +346,4 @@ export {
339
346
  printResult,
340
347
  printError
341
348
  };
342
- //# sourceMappingURL=chunk-YSANBZAE.js.map
349
+ //# sourceMappingURL=chunk-UMWF6ZAS.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../../core/output/mutation-projection.ts", "../../../../../../../../core/output/output.ts"],
4
+ "sourcesContent": ["/**\n * Shared projection helper for mutation command results.\n *\n * Mutation commands (create/update/close/append/update-many) return a result\n * envelope that carries a `changed_fields` string array. On create this array simply\n * re-lists every field the command just set, which the item echo above it already\n * shows, so for high-volume agent loops it is ~50% redundant payload. This helper\n * lets the CLI (`--no-changed-fields`) and the MCP agent path trim that array down\n * to a deterministic `changed_field_count` without losing mutation evidence.\n *\n * Compaction is deliberately scoped to the mutation envelope only:\n * - the envelope's own top-level `changed_fields` (create/update/close/append), and\n * - `rows[*].changed_fields` (update-many reports its delta per row).\n * It does NOT recurse into arbitrary nested objects, so unrelated payloads that\n * legitimately carry `changed_fields` (for example `pm history --diff` entries, or a\n * custom runtime metadata field) are left untouched.\n *\n * The helper is pure and side-effect free, reused by both the output layer and the\n * MCP server, and returns the original reference unchanged when nothing is compacted.\n */\n\nexport type ChangedFieldsMode = \"full\" | \"compact\";\n\nexport interface MutationProjectionOptions {\n /** Defaults to \"full\" (unchanged output). \"compact\" drops the array, keeping a count. */\n changedFields?: ChangedFieldsMode;\n /** Return only id/status for single-item mutation envelopes. */\n idOnly?: boolean;\n}\n\nconst CHANGED_FIELDS_KEY = \"changed_fields\";\nconst CHANGED_FIELD_COUNT_KEY = \"changed_field_count\";\nconst ROWS_KEY = \"rows\";\nconst UPDATE_MANY_MUTATION_MODES = new Set([\"apply\", \"rollback\"]);\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n return proto === null || proto === Object.prototype;\n}\n\n/** Replace a single envelope's own top-level `changed_fields` array with a count. */\nfunction compactOwnChangedFields(envelope: Record<string, unknown>): Record<string, unknown> | null {\n const changedFields = envelope[CHANGED_FIELDS_KEY];\n if (!Array.isArray(changedFields)) {\n return null;\n }\n const projected: Record<string, unknown> =\n Object.getPrototypeOf(envelope) === null ? Object.create(null) : {};\n for (const [key, value] of Object.entries(envelope)) {\n if (key !== CHANGED_FIELDS_KEY) {\n projected[key] = value;\n }\n }\n projected[CHANGED_FIELD_COUNT_KEY] = changedFields.length;\n return projected;\n}\n\nfunction isMutationEnvelope(value: Record<string, unknown>): boolean {\n return \"item\" in value && Array.isArray(value[CHANGED_FIELDS_KEY]);\n}\n\nfunction isUpdateManyMutationEnvelope(value: Record<string, unknown>): boolean {\n return (\n typeof value.mode === \"string\" &&\n UPDATE_MANY_MUTATION_MODES.has(value.mode) &&\n Array.isArray(value[ROWS_KEY])\n );\n}\n\nfunction replaceRows(envelope: Record<string, unknown>, rows: unknown[]): Record<string, unknown> {\n const projected: Record<string, unknown> =\n Object.getPrototypeOf(envelope) === null ? Object.create(null) : {};\n Object.assign(projected, envelope);\n projected[ROWS_KEY] = rows;\n return projected;\n}\n\n/**\n * Returns a copy of a mutation result with the envelope `changed_fields` arrays\n * replaced by `changed_field_count` when compact mode is requested. Inputs that are\n * not a mutation envelope (or full mode) are returned unchanged (same reference).\n */\nexport function projectMutationResult(result: unknown, options: MutationProjectionOptions = {}): unknown {\n if (options.idOnly === true && isPlainObject(result) && isPlainObject(result.item)) {\n const id = typeof result.item.id === \"string\" ? result.item.id : undefined;\n const status = typeof result.item.status === \"string\" ? result.item.status : undefined;\n if (id) {\n return status ? { id, status } : { id };\n }\n }\n\n const mode = options.changedFields ?? \"full\";\n if (mode === \"full\" || !isPlainObject(result)) {\n return result;\n }\n\n let changed = false;\n let projected: Record<string, unknown> = result;\n\n const compactedTop = isMutationEnvelope(result) ? compactOwnChangedFields(result) : null;\n if (compactedTop !== null) {\n projected = compactedTop;\n changed = true;\n }\n\n // update-many reports its per-item delta under rows[*].changed_fields.\n const rows = isUpdateManyMutationEnvelope(projected) ? projected[ROWS_KEY] : undefined;\n if (Array.isArray(rows)) {\n let rowsChanged = false;\n const nextRows = rows.map((row) => {\n if (!isPlainObject(row)) {\n return row;\n }\n const compactedRow = compactOwnChangedFields(row);\n if (compactedRow) {\n rowsChanged = true;\n return compactedRow;\n }\n return row;\n });\n if (rowsChanged) {\n projected = replaceRows(projected, nextRows);\n changed = true;\n }\n }\n\n return changed ? projected : result;\n}\n", "import {\n runActiveCommandOverride,\n runActiveRendererOverride,\n runActiveServiceOverrideSync,\n setActiveCommandResult,\n} from \"../extensions/index.js\";\nimport { EXIT_CODE } from \"../shared/constants.js\";\nimport { projectMutationResult } from \"./mutation-projection.js\";\n\nexport interface OutputOptions {\n json?: boolean;\n quiet?: boolean;\n /** When true, mutation results drop the verbose changed_fields array (keeps changed_field_count). */\n noChangedFields?: boolean;\n /** When true, single-item mutation results print only id and status. */\n idOnly?: boolean;\n defaultOutputFormat?: \"toon\" | \"json\";\n command?: string;\n commandArgs?: string[];\n commandOptions?: Record<string, unknown>;\n pmRoot?: string;\n}\n\ninterface NodeLikeError {\n code?: string;\n}\n\nconst NATIVE_OUTPUT_MARKER = \"__pm_native_output\";\n\nlet streamErrorHandlersInstalled = false;\ntype OutputStreamTarget = \"stdout\" | \"stderr\";\n\nfunction isPlainObject(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction shouldUseNativeOutput(result: unknown): boolean {\n return isPlainObject(result) && result[NATIVE_OUTPUT_MARKER] === true;\n}\n\nfunction stripNativeOutputMarker<T>(result: T): T {\n if (!isPlainObject(result) || result[NATIVE_OUTPUT_MARKER] !== true) {\n return result;\n }\n const { [NATIVE_OUTPUT_MARKER]: _marker, ...rest } = result;\n return rest as T;\n}\n\nfunction isBrokenPipeError(error: unknown): boolean {\n return typeof error === \"object\" && error !== null && (error as NodeLikeError).code === \"EPIPE\";\n}\n\nfunction markStdoutBrokenPipeExitCode(): void {\n if (process.exitCode === undefined || process.exitCode === EXIT_CODE.SUCCESS) {\n process.exitCode = EXIT_CODE.SUCCESS;\n }\n}\n\nfunction markStderrBrokenPipeExitCode(): void {\n if (process.exitCode === undefined || process.exitCode === EXIT_CODE.SUCCESS) {\n process.exitCode = EXIT_CODE.GENERIC_FAILURE;\n }\n}\n\nfunction markBrokenPipeExitCode(target: OutputStreamTarget): void {\n if (target === \"stdout\") {\n markStdoutBrokenPipeExitCode();\n return;\n }\n markStderrBrokenPipeExitCode();\n}\n\nfunction handleUnhandledStreamError(error: unknown): void {\n const unhandled = error instanceof Error ? error : new Error(String(error));\n setImmediate(() => {\n throw unhandled;\n });\n}\n\nfunction installStreamErrorHandlers(): void {\n if (streamErrorHandlersInstalled) {\n return;\n }\n streamErrorHandlersInstalled = true;\n process.stdout.on(\"error\", (error: unknown) => {\n if (isBrokenPipeError(error)) {\n markBrokenPipeExitCode(\"stdout\");\n return;\n }\n handleUnhandledStreamError(error);\n });\n process.stderr.on(\"error\", (error: unknown) => {\n if (isBrokenPipeError(error)) {\n markBrokenPipeExitCode(\"stderr\");\n return;\n }\n handleUnhandledStreamError(error);\n });\n}\n\nfunction writeToStream(target: OutputStreamTarget, text: string): boolean {\n installStreamErrorHandlers();\n try {\n if (target === \"stdout\") {\n process.stdout.write(text);\n } else {\n process.stderr.write(text);\n }\n return true;\n } catch (error: unknown) {\n if (isBrokenPipeError(error)) {\n markBrokenPipeExitCode(target);\n return false;\n }\n throw error;\n }\n}\n\nexport function writeStdout(text: string): boolean {\n return writeToStream(\"stdout\", text);\n}\n\nexport function writeStderr(text: string): boolean {\n return writeToStream(\"stderr\", text);\n}\n\nfunction renderScalar(value: unknown): string {\n if (typeof value === \"string\") return JSON.stringify(value);\n if (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n if (value === null) return \"null\";\n return JSON.stringify(value);\n}\n\nfunction compactToonValue(value: unknown): unknown | undefined {\n if (value === null || value === undefined) {\n return undefined;\n }\n\n if (Array.isArray(value)) {\n const compactedEntries = value\n .map((entry) => compactToonValue(entry))\n .filter((entry): entry is unknown => entry !== undefined);\n return compactedEntries.length > 0 ? compactedEntries : undefined;\n }\n\n if (isPlainObject(value)) {\n const compacted: Record<string, unknown> = {};\n for (const [key, entry] of Object.entries(value)) {\n const compactedEntry = compactToonValue(entry);\n if (compactedEntry !== undefined) {\n compacted[key] = compactedEntry;\n }\n }\n return Object.keys(compacted).length > 0 ? compacted : undefined;\n }\n\n return value;\n}\n\nfunction renderToonValue(value: unknown, depth: number): string {\n const indent = \" \".repeat(depth);\n\n if (Array.isArray(value)) {\n if (value.length === 0) return \"[]\";\n return value\n .map((entry) => {\n if (!isPlainObject(entry) && !Array.isArray(entry)) {\n return `${indent}- ${renderScalar(entry)}`;\n }\n const rendered = renderToonValue(entry, depth + 1);\n const lines = rendered.split(\"\\n\");\n const [firstLine, ...rest] = lines;\n if (rest.length === 0) {\n return `${indent}- ${firstLine.trimStart()}`;\n }\n return `${indent}- ${firstLine.trimStart()}\\n${rest.join(\"\\n\")}`;\n })\n .join(\"\\n\");\n }\n\n if (isPlainObject(value)) {\n const entries = Object.entries(value);\n if (entries.length === 0) return \"{}\";\n return entries\n .map(([key, entry]) => {\n if (!isPlainObject(entry) && !Array.isArray(entry)) {\n return `${indent}${key}: ${renderScalar(entry)}`;\n }\n if (Array.isArray(entry) && entry.length === 0) {\n return `${indent}${key}: []`;\n }\n if (isPlainObject(entry) && Object.keys(entry).length === 0) {\n return `${indent}${key}: {}`;\n }\n return `${indent}${key}:\\n${renderToonValue(entry, depth + 1)}`;\n })\n .join(\"\\n\");\n }\n\n return `${indent}${renderScalar(value)}`;\n}\n\nfunction renderDefaultMarkdownResult(value: unknown): string | null {\n if (!isPlainObject(value) || value.output_default !== \"markdown\") {\n return null;\n }\n if (typeof value.view !== \"string\" || !Array.isArray(value.events) || !Array.isArray(value.days)) {\n return null;\n }\n const lines = [`# pm calendar (${value.view})`, \"\"];\n const summary = isPlainObject(value.summary) ? value.summary : {};\n lines.push(`- events: ${String(summary.events ?? 0)}`);\n lines.push(\"\");\n if (value.events.length === 0) {\n lines.push(\"No calendar events matched the selected filters.\");\n return `${lines.join(\"\\n\")}\\n`;\n }\n for (const event of value.events) {\n if (!isPlainObject(event)) {\n continue;\n }\n const kind = typeof event.kind === \"string\" ? event.kind : \"event\";\n const title = typeof event.item_title === \"string\" ? event.item_title : \"\";\n const itemId = typeof event.item_id === \"string\" ? event.item_id : \"\";\n const reminderText = typeof event.reminder_text === \"string\" && event.reminder_text.length > 0 ? ` ${event.reminder_text}` : \"\";\n lines.push(`- [${kind}] ${itemId} ${title}${reminderText}`.trim());\n }\n return `${lines.join(\"\\n\")}\\n`;\n}\n\nexport function formatOutput(result: unknown, options: OutputOptions): string {\n const commandOverride = runActiveCommandOverride(result);\n const nativeOutput = shouldUseNativeOutput(commandOverride.result);\n const effectiveResult = stripNativeOutputMarker(commandOverride.result);\n setActiveCommandResult(effectiveResult);\n const format =\n options.json === true\n ? \"json\"\n : options.json === false\n ? \"toon\"\n : options.defaultOutputFormat === \"json\"\n ? \"json\"\n : \"toon\";\n const serviceOverride = nativeOutput ? { handled: false, result: effectiveResult } : runActiveServiceOverrideSync(\"output_format\", {\n command: options.command,\n args: options.commandArgs,\n command_options: options.commandOptions,\n global: { ...options },\n pm_root: options.pmRoot,\n format,\n options: { ...options },\n result: effectiveResult,\n });\n if (serviceOverride.handled && typeof serviceOverride.result === \"string\") {\n return serviceOverride.result.endsWith(\"\\n\") ? serviceOverride.result : `${serviceOverride.result}\\n`;\n }\n const outputResult = serviceOverride.handled ? serviceOverride.result : effectiveResult;\n if (format === \"toon\") {\n const markdownDefault = renderDefaultMarkdownResult(outputResult);\n if (markdownDefault !== null) {\n return markdownDefault;\n }\n }\n const rendererOverride = nativeOutput ? { rendered: null } : runActiveRendererOverride(format, outputResult);\n if (rendererOverride.rendered !== null) {\n return rendererOverride.rendered.endsWith(\"\\n\") ? rendererOverride.rendered : `${rendererOverride.rendered}\\n`;\n }\n if (format === \"json\") {\n return `${JSON.stringify(outputResult, null, 2)}\\n`;\n }\n const compactedToon = compactToonValue(outputResult);\n if (compactedToon === undefined) {\n return \"{}\\n\";\n }\n return `${renderToonValue(compactedToon, 0)}\\n`;\n}\n\nexport function printResult(result: unknown, options: OutputOptions): void {\n const projected = options.idOnly\n ? projectMutationResult(result, { idOnly: true })\n : options.noChangedFields\n ? projectMutationResult(result, { changedFields: \"compact\" })\n : result;\n const rendered = formatOutput(projected, options);\n if (options.quiet) {\n return;\n }\n writeStdout(rendered);\n}\n\nexport function printError(message: string): void {\n const override = runActiveServiceOverrideSync(\"error_format\", {\n message,\n });\n const rendered = override.handled && typeof override.result === \"string\" ? override.result : message;\n writeStderr(rendered.endsWith(\"\\n\") ? rendered : `${rendered}\\n`);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;AA8BA,IAAM,qBAAqB;AAC3B,IAAM,0BAA0B;AAChC,IAAM,WAAW;AACjB,IAAM,6BAA6B,oBAAI,IAAI,CAAC,SAAS,UAAU,CAAC;AAEhE,SAAS,cAAc,OAAc;AACnC,MAAI,OAAO,UAAU,Y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