@unbrained/pm-cli 2026.7.14 → 2026.7.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (708) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +48 -0
  3. package/README.md +14 -11
  4. package/dist/cli/argv-utils.d.ts +1 -4
  5. package/dist/cli/argv-utils.js +3 -13
  6. package/dist/cli/argv-utils.js.map +1 -1
  7. package/dist/cli/bootstrap-args.d.ts +6 -4
  8. package/dist/cli/bootstrap-args.js +51 -16
  9. package/dist/cli/bootstrap-args.js.map +1 -1
  10. package/dist/cli/bundle-integrity.d.ts +49 -0
  11. package/dist/cli/bundle-integrity.js +111 -0
  12. package/dist/cli/bundle-integrity.js.map +1 -0
  13. package/dist/cli/commands/completion.js +7 -2
  14. package/dist/cli/commands/completion.js.map +1 -1
  15. package/dist/cli/commands/config.d.ts +6 -163
  16. package/dist/cli/commands/config.js +4 -1133
  17. package/dist/cli/commands/config.js.map +1 -1
  18. package/dist/cli/commands/context.d.ts +2 -4
  19. package/dist/cli/commands/context.js +10 -85
  20. package/dist/cli/commands/context.js.map +1 -1
  21. package/dist/cli/commands/create.d.ts +1 -0
  22. package/dist/cli/commands/create.js +3 -2
  23. package/dist/cli/commands/create.js.map +1 -1
  24. package/dist/cli/commands/extension/describe.d.ts +2 -91
  25. package/dist/cli/commands/extension/describe.js +4 -142
  26. package/dist/cli/commands/extension/describe.js.map +1 -1
  27. package/dist/cli/commands/extension/scaffold.d.ts +2 -36
  28. package/dist/cli/commands/extension/scaffold.js +4 -2435
  29. package/dist/cli/commands/extension/scaffold.js.map +1 -1
  30. package/dist/cli/commands/extension/shared.d.ts +2 -28
  31. package/dist/cli/commands/extension/shared.js +4 -130
  32. package/dist/cli/commands/extension/shared.js.map +1 -1
  33. package/dist/cli/commands/extension.d.ts +3 -400
  34. package/dist/cli/commands/extension.js +4 -2183
  35. package/dist/cli/commands/extension.js.map +1 -1
  36. package/dist/cli/commands/gc.d.ts +6 -56
  37. package/dist/cli/commands/gc.js +4 -270
  38. package/dist/cli/commands/gc.js.map +1 -1
  39. package/dist/cli/commands/get.d.ts +18 -5
  40. package/dist/cli/commands/get.js +117 -58
  41. package/dist/cli/commands/get.js.map +1 -1
  42. package/dist/cli/commands/health.d.ts +6 -184
  43. package/dist/cli/commands/health.js +4 -1747
  44. package/dist/cli/commands/health.js.map +1 -1
  45. package/dist/cli/commands/history-compact.d.ts +4 -139
  46. package/dist/cli/commands/history-compact.js +5 -510
  47. package/dist/cli/commands/history-compact.js.map +1 -1
  48. package/dist/cli/commands/history-redact.d.ts +8 -120
  49. package/dist/cli/commands/history-redact.js +6 -581
  50. package/dist/cli/commands/history-redact.js.map +1 -1
  51. package/dist/cli/commands/history-repair.d.ts +7 -89
  52. package/dist/cli/commands/history-repair.js +5 -257
  53. package/dist/cli/commands/history-repair.js.map +1 -1
  54. package/dist/cli/commands/history.d.ts +1 -2
  55. package/dist/cli/commands/history.js +6 -48
  56. package/dist/cli/commands/history.js.map +1 -1
  57. package/dist/cli/commands/index.d.ts +1 -0
  58. package/dist/cli/commands/index.js +3 -2
  59. package/dist/cli/commands/index.js.map +1 -1
  60. package/dist/cli/commands/init-agent-guidance.d.ts +6 -113
  61. package/dist/cli/commands/init-agent-guidance.js +4 -431
  62. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  63. package/dist/cli/commands/init.d.ts +6 -181
  64. package/dist/cli/commands/init.js +4 -690
  65. package/dist/cli/commands/init.js.map +1 -1
  66. package/dist/cli/commands/next.js +3 -3
  67. package/dist/cli/commands/next.js.map +1 -1
  68. package/dist/cli/commands/profile.d.ts +4 -174
  69. package/dist/cli/commands/profile.js +4 -425
  70. package/dist/cli/commands/profile.js.map +1 -1
  71. package/dist/cli/commands/restore.d.ts +4 -19
  72. package/dist/cli/commands/restore.js +9 -158
  73. package/dist/cli/commands/restore.js.map +1 -1
  74. package/dist/cli/commands/schema.d.ts +7 -507
  75. package/dist/cli/commands/schema.js +5 -1254
  76. package/dist/cli/commands/schema.js.map +1 -1
  77. package/dist/cli/commands/test.d.ts +2 -4
  78. package/dist/cli/commands/test.js +7 -97
  79. package/dist/cli/commands/test.js.map +1 -1
  80. package/dist/cli/commands/validate.d.ts +9 -249
  81. package/dist/cli/commands/validate.js +9 -2150
  82. package/dist/cli/commands/validate.js.map +1 -1
  83. package/dist/cli/extension-command-help.js +18 -4
  84. package/dist/cli/extension-command-help.js.map +1 -1
  85. package/dist/cli/extension-command-options.js +3 -3
  86. package/dist/cli/extension-command-options.js.map +1 -1
  87. package/dist/cli/help-content.js +7 -3
  88. package/dist/cli/help-content.js.map +1 -1
  89. package/dist/cli/main.js +20 -30
  90. package/dist/cli/main.js.map +1 -1
  91. package/dist/cli/register-list-query.js +4 -2
  92. package/dist/cli/register-list-query.js.map +1 -1
  93. package/dist/cli/register-mutation.js +11 -3
  94. package/dist/cli/register-mutation.js.map +1 -1
  95. package/dist/cli/register-setup.js +4 -2
  96. package/dist/cli/register-setup.js.map +1 -1
  97. package/dist/cli/registration-helpers.js +3 -2
  98. package/dist/cli/registration-helpers.js.map +1 -1
  99. package/dist/cli-bundle/bundle-manifest.json +782 -0
  100. package/dist/cli-bundle/chunks/{append-PVZJDM6J.js → append-OJQFUQ4T.js} +5 -5
  101. package/dist/cli-bundle/chunks/append-UZVHUO74.js +11 -0
  102. package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js → chunk-2IFFUZLC.js} +2 -2
  103. package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js → chunk-2JKGO6QX.js} +4 -4
  104. package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js → chunk-2NCIPMQP.js} +2 -2
  105. package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js → chunk-2VPAVL7O.js} +2 -2
  106. package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js → chunk-2WSE6PO2.js} +4 -4
  107. package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js → chunk-34L5OT3Y.js} +2 -2
  108. package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js → chunk-3AUGG2DP.js} +3 -3
  109. package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js → chunk-3CLU2XZO.js} +4 -4
  110. package/dist/cli-bundle/chunks/{chunk-N3CMP4NI.js → chunk-3S5QVM5H.js} +43 -7
  111. package/dist/cli-bundle/chunks/chunk-3S5QVM5H.js.map +1 -0
  112. package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js +64 -0
  113. package/dist/cli-bundle/chunks/chunk-3U7ZR6M4.js.map +7 -0
  114. package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js → chunk-3WM75PWC.js} +3 -3
  115. package/dist/cli-bundle/chunks/chunk-4223PVZT.js +121 -0
  116. package/dist/cli-bundle/chunks/chunk-4223PVZT.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-5URI7TPJ.js → chunk-4XQ3BDV4.js} +281 -164
  118. package/dist/cli-bundle/chunks/chunk-4XQ3BDV4.js.map +7 -0
  119. package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js → chunk-5JLUII3O.js} +13 -13
  120. package/dist/cli-bundle/chunks/{chunk-MKL4CP2I.js → chunk-5ZSLZLDN.js} +631 -246
  121. package/dist/cli-bundle/chunks/chunk-5ZSLZLDN.js.map +1 -0
  122. package/dist/cli-bundle/chunks/{chunk-Q37E63AM.js → chunk-6CFNAVTF.js} +21 -141
  123. package/dist/cli-bundle/chunks/chunk-6CFNAVTF.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js → chunk-6N2VXVTQ.js} +2 -2
  125. package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js → chunk-6S3YSUYG.js} +3 -3
  126. package/dist/cli-bundle/chunks/{chunk-ZUKSZVBW.js → chunk-7B67ZL4N.js} +8 -7
  127. package/dist/cli-bundle/chunks/chunk-7B67ZL4N.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-IA3YFTXT.js → chunk-7PIWCHTW.js} +11 -13
  129. package/dist/cli-bundle/chunks/chunk-7PIWCHTW.js.map +1 -0
  130. package/dist/cli-bundle/chunks/{chunk-BPD26E3P.js → chunk-7Z4LKRS4.js} +291 -81
  131. package/dist/cli-bundle/chunks/chunk-7Z4LKRS4.js.map +1 -0
  132. package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js → chunk-AHVTB5I5.js} +4 -4
  133. package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js → chunk-APRVSW2O.js} +3 -3
  134. package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js → chunk-B7PE22W6.js} +4 -4
  135. package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js → chunk-BCOFWYW4.js} +3 -3
  136. package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js → chunk-BEP7WJA2.js} +4 -4
  137. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js +1114 -0
  138. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js.map +7 -0
  139. package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js → chunk-BSEQUTQP.js} +2 -2
  140. package/dist/cli-bundle/chunks/{chunk-AFWZRL7M.js.map → chunk-BSEQUTQP.js.map} +2 -2
  141. package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js → chunk-CRVF2JDM.js} +10 -10
  142. package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js → chunk-DM4H7FP4.js} +3 -3
  143. package/dist/cli-bundle/chunks/chunk-DUT67M43.js +5 -0
  144. package/dist/cli-bundle/chunks/{chunk-44LNIULG.js → chunk-DYH63FX7.js} +4 -4
  145. package/dist/cli-bundle/chunks/{chunk-LWTIRS3Y.js → chunk-E2OJMKML.js} +306 -82
  146. package/dist/cli-bundle/chunks/chunk-E2OJMKML.js.map +7 -0
  147. package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js → chunk-EAB64KLB.js} +4 -4
  148. package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js → chunk-EACOH7AU.js} +10 -10
  149. package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js → chunk-EH2OPHBI.js} +10 -10
  150. package/dist/cli-bundle/chunks/{chunk-HL7V2PHX.js.map → chunk-EH2OPHBI.js.map} +1 -1
  151. package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js → chunk-EJEXHTY5.js} +2 -2
  152. package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js → chunk-EYLCSJAI.js} +2 -2
  153. package/dist/cli-bundle/chunks/{chunk-655STMGA.js → chunk-FMBNM2EN.js} +2 -2
  154. package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js → chunk-FNSPG7MU.js} +12 -12
  155. package/dist/cli-bundle/chunks/{chunk-5CT5BW6E.js → chunk-GM5QHQU6.js} +46 -40
  156. package/dist/cli-bundle/chunks/chunk-GM5QHQU6.js.map +7 -0
  157. package/dist/cli-bundle/chunks/{chunk-FTQLW4JD.js → chunk-GOSLKLFE.js} +418 -24
  158. package/dist/cli-bundle/chunks/chunk-GOSLKLFE.js.map +1 -0
  159. package/dist/cli-bundle/chunks/{chunk-KB726FMH.js → chunk-H2Z3FYXQ.js} +4 -4
  160. package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js +162 -0
  161. package/dist/cli-bundle/chunks/chunk-H3EIEWGR.js.map +1 -0
  162. package/dist/cli-bundle/chunks/{chunk-2QIQGYPW.js → chunk-H5APFTHZ.js} +53 -10
  163. package/dist/cli-bundle/chunks/chunk-H5APFTHZ.js.map +7 -0
  164. package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js +118 -0
  165. package/dist/cli-bundle/chunks/chunk-HDH3JUGG.js.map +1 -0
  166. package/dist/cli-bundle/chunks/{chunk-ZAYYDNB3.js → chunk-HO4KXD6I.js} +22 -142
  167. package/dist/cli-bundle/chunks/chunk-HO4KXD6I.js.map +1 -0
  168. package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js → chunk-HYB5AZ63.js} +203 -62
  169. package/dist/cli-bundle/chunks/{chunk-ILLUE5DI.js.map → chunk-HYB5AZ63.js.map} +3 -3
  170. package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js → chunk-IA5FKNII.js} +2 -2
  171. package/dist/cli-bundle/chunks/{chunk-JL7WZ4O2.js → chunk-IG3SWA4A.js} +33 -9
  172. package/dist/cli-bundle/chunks/chunk-IG3SWA4A.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js → chunk-IJIICKVW.js} +2 -2
  174. package/dist/cli-bundle/chunks/{chunk-IGED7NH2.js → chunk-ILX33QXL.js} +668 -251
  175. package/dist/cli-bundle/chunks/chunk-ILX33QXL.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-UGTVWL3E.js → chunk-INU6DKT5.js} +47 -41
  177. package/dist/cli-bundle/chunks/chunk-INU6DKT5.js.map +1 -0
  178. package/dist/cli-bundle/chunks/{chunk-UB2QYSTO.js → chunk-J5AOEGDC.js} +26 -18
  179. package/dist/cli-bundle/chunks/chunk-J5AOEGDC.js.map +1 -0
  180. package/dist/cli-bundle/chunks/{chunk-4DY4KPQI.js → chunk-J6364LFM.js} +1330 -937
  181. package/dist/cli-bundle/chunks/chunk-J6364LFM.js.map +7 -0
  182. package/dist/cli-bundle/chunks/{chunk-DVOLZJ3C.js → chunk-J6EY5V4N.js} +1295 -939
  183. package/dist/cli-bundle/chunks/chunk-J6EY5V4N.js.map +1 -0
  184. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js +1097 -0
  185. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js.map +1 -0
  186. package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js → chunk-JOUQZENX.js} +3 -3
  187. package/dist/cli-bundle/chunks/{chunk-J4NZOP3I.js → chunk-JXQUXVMI.js} +9 -8
  188. package/dist/cli-bundle/chunks/chunk-JXQUXVMI.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js → chunk-JYFOV7FC.js} +4 -4
  190. package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js → chunk-K2X6U4UA.js} +4 -4
  191. package/dist/cli-bundle/chunks/{chunk-6OTZMORS.js → chunk-K3WII2ME.js} +27 -27
  192. package/dist/cli-bundle/chunks/chunk-K3WII2ME.js.map +7 -0
  193. package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js → chunk-KG44YSKD.js} +4 -4
  194. package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js → chunk-KPMKHGEA.js} +4 -4
  195. package/dist/cli-bundle/chunks/{chunk-QASRVKUQ.js → chunk-LPYWLWDS.js} +257 -163
  196. package/dist/cli-bundle/chunks/chunk-LPYWLWDS.js.map +1 -0
  197. package/dist/cli-bundle/chunks/{chunk-RGXD5JJR.js → chunk-LSG2U345.js} +19 -12
  198. package/dist/cli-bundle/chunks/chunk-LSG2U345.js.map +7 -0
  199. package/dist/cli-bundle/chunks/chunk-MIQDDLB5.js +5 -0
  200. package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js → chunk-NLDFBC6J.js} +2 -2
  201. package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js → chunk-NP22ERDF.js} +3 -3
  202. package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js → chunk-NU3IMIEA.js} +2 -2
  203. package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js → chunk-NVPZIJVR.js} +2 -2
  204. package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js → chunk-ODALILG3.js} +2 -2
  205. package/dist/cli-bundle/chunks/{chunk-CDJYP7OQ.js → chunk-ONG5V5CI.js} +190 -63
  206. package/dist/cli-bundle/chunks/chunk-ONG5V5CI.js.map +1 -0
  207. package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js → chunk-ONREO4ST.js} +3 -3
  208. package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js +61 -0
  209. package/dist/cli-bundle/chunks/chunk-OW4JWD5M.js.map +1 -0
  210. package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js → chunk-P74IZQ7A.js} +12 -12
  211. package/dist/cli-bundle/chunks/chunk-PENXZX3U.js +172 -0
  212. package/dist/cli-bundle/chunks/chunk-PENXZX3U.js.map +7 -0
  213. package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js → chunk-PGY23YTC.js} +3 -3
  214. package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js → chunk-PMOSXADO.js} +3 -3
  215. package/dist/cli-bundle/chunks/chunk-PNTULOGU.js +9 -0
  216. package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js → chunk-Q7A43DS4.js} +2 -2
  217. package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js → chunk-QEHQ2GVG.js} +2 -2
  218. package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js → chunk-QIPLHNP7.js} +7 -7
  219. package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js → chunk-QKECXBBG.js} +3 -3
  220. package/dist/cli-bundle/chunks/{chunk-GXXC7QSK.js.map → chunk-QKECXBBG.js.map} +1 -1
  221. package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js → chunk-QKJGPFAF.js} +3 -3
  222. package/dist/cli-bundle/chunks/{chunk-F7PSHRNO.js → chunk-QKXHFPYM.js} +27 -10
  223. package/dist/cli-bundle/chunks/chunk-QKXHFPYM.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js → chunk-RLCHOOHC.js} +2 -2
  225. package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js → chunk-RMLWNPH2.js} +2 -2
  226. package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js → chunk-RRM5JYJC.js} +2 -2
  227. package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js → chunk-S6MQESFR.js} +4 -4
  228. package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js → chunk-SDQLJWBO.js} +4 -4
  229. package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js → chunk-SELVXEZK.js} +2 -2
  230. package/dist/cli-bundle/chunks/{chunk-DYEX6NFH.js → chunk-TD3LVC7D.js} +438 -23
  231. package/dist/cli-bundle/chunks/chunk-TD3LVC7D.js.map +7 -0
  232. package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js → chunk-TKOVBP6C.js} +2 -2
  233. package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js → chunk-TQSZFPIS.js} +4 -4
  234. package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js → chunk-TSMHDIW4.js} +2 -2
  235. package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js → chunk-UFXU44HV.js} +4 -4
  236. package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js → chunk-ULTHRDBP.js} +3 -3
  237. package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js → chunk-UMOPHQSU.js} +9 -9
  238. package/dist/cli-bundle/chunks/{chunk-OI4S4KCI.js.map → chunk-UMOPHQSU.js.map} +2 -2
  239. package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js → chunk-UOHFKBUV.js} +3 -3
  240. package/dist/cli-bundle/chunks/{chunk-PHKP3AGR.js → chunk-UWQHLMEB.js} +35 -18
  241. package/dist/cli-bundle/chunks/chunk-UWQHLMEB.js.map +7 -0
  242. package/dist/cli-bundle/chunks/{chunk-6TTOHMTB.js → chunk-UXONS674.js} +45 -112
  243. package/dist/cli-bundle/chunks/chunk-UXONS674.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js → chunk-UY2ACEMF.js} +7 -7
  245. package/dist/cli-bundle/chunks/{chunk-6PKA3SJQ.js → chunk-WQPUU7XD.js} +19 -28
  246. package/dist/cli-bundle/chunks/chunk-WQPUU7XD.js.map +1 -0
  247. package/dist/cli-bundle/chunks/{chunk-7TQMR6LK.js → chunk-WT3ZEOGH.js} +70 -20
  248. package/dist/cli-bundle/chunks/chunk-WT3ZEOGH.js.map +7 -0
  249. package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js → chunk-WUJQK4YV.js} +4 -4
  250. package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js → chunk-XSJUSQAE.js} +2 -2
  251. package/dist/cli-bundle/chunks/{chunk-6MHSBDGD.js → chunk-XXXF6PAQ.js} +50 -117
  252. package/dist/cli-bundle/chunks/chunk-XXXF6PAQ.js.map +7 -0
  253. package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js → chunk-YAQEBNY7.js} +4 -4
  254. package/dist/cli-bundle/chunks/{chunk-7QDSYUMF.js → chunk-YAROI3PD.js} +44 -21
  255. package/dist/cli-bundle/chunks/chunk-YAROI3PD.js.map +1 -0
  256. package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js → chunk-YBLZ2VE7.js} +13 -13
  257. package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js → chunk-YCQET3OT.js} +2 -2
  258. package/dist/cli-bundle/chunks/chunk-YUSOJDWM.js +9 -0
  259. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js +58 -0
  260. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js → chunk-ZI6VQWQ7.js} +4 -4
  262. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js +68 -0
  263. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js.map +7 -0
  264. package/dist/cli-bundle/chunks/{close-LZECOMHO.js → close-CWODTPKG.js} +5 -5
  265. package/dist/cli-bundle/chunks/close-W6LI2PKM.js +12 -0
  266. package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js → close-many-CQFUY7MR.js} +15 -13
  267. package/dist/cli-bundle/chunks/close-many-DLDDVSH5.js +23 -0
  268. package/dist/cli-bundle/chunks/comments-E3TNTK24.js +13 -0
  269. package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js → comments-WGLHR7LB.js} +7 -7
  270. package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js → copy-LXVDXH7B.js} +4 -4
  271. package/dist/cli-bundle/chunks/copy-Q5ZJPUKR.js +9 -0
  272. package/dist/cli-bundle/chunks/{create-F53OBTOU.js → create-J5U6ND4K.js} +9 -9
  273. package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js → create-LBVCYMEG.js} +9 -9
  274. package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js → delete-PMJBNY5G.js} +4 -4
  275. package/dist/cli-bundle/chunks/delete-WNHB3LYW.js +10 -0
  276. package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js → deps-JZ7TMVCB.js} +7 -4
  277. package/dist/cli-bundle/chunks/{deps-U57I7EAK.js → deps-OA26IS25.js} +7 -4
  278. package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js → docs-FEWB2DQB.js} +6 -6
  279. package/dist/cli-bundle/chunks/docs-HA2AIDBB.js +14 -0
  280. package/dist/cli-bundle/chunks/{files-TBZD7V6H.js → files-6YFBJRBG.js} +6 -6
  281. package/dist/cli-bundle/chunks/{files-TTY6N2AV.js → files-EFIWKFTM.js} +6 -6
  282. package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js → focus-4QJR7FOQ.js} +5 -5
  283. package/dist/cli-bundle/chunks/focus-POIW5LTJ.js +10 -0
  284. package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js → history-compact-CKRPDTJN.js} +6 -10
  285. package/dist/cli-bundle/chunks/history-compact-FWG2C7FZ.js +16 -0
  286. package/dist/cli-bundle/chunks/history-redact-BB3TGDAE.js +15 -0
  287. package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js → history-redact-D225BHOZ.js} +5 -6
  288. package/dist/cli-bundle/chunks/history-repair-6GEAM7HE.js +16 -0
  289. package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js → history-repair-RQXKQHL4.js} +6 -8
  290. package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js → learnings-JLNLCOL5.js} +7 -7
  291. package/dist/cli-bundle/chunks/learnings-RSNLSWDC.js +13 -0
  292. package/dist/cli-bundle/chunks/notes-2WDH6DXU.js +13 -0
  293. package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js → notes-GB47XXQQ.js} +7 -7
  294. package/dist/cli-bundle/chunks/plan-DOVI2VMW.js +24 -0
  295. package/dist/cli-bundle/chunks/{plan-2NNEO46V.js → plan-VDCJ2PCN.js} +10 -10
  296. package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js → profile-FAU7NZML.js} +10 -10
  297. package/dist/cli-bundle/chunks/{profile-U725ATWZ.js → profile-IVXQEL3D.js} +10 -10
  298. package/dist/cli-bundle/chunks/{register-list-query-BUWCYHBT.js → register-list-query-DKA3EH5D.js} +22 -19
  299. package/dist/cli-bundle/chunks/register-list-query-DKA3EH5D.js.map +7 -0
  300. package/dist/cli-bundle/chunks/{register-list-query-KTZ6AGE7.js → register-list-query-UL4UKBBN.js} +23 -20
  301. package/dist/cli-bundle/chunks/register-list-query-UL4UKBBN.js.map +1 -0
  302. package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js → register-mutation-ARFHRW55.js} +36 -32
  303. package/dist/cli-bundle/chunks/{register-mutation-UELYYOR7.js.map → register-mutation-ARFHRW55.js.map} +2 -2
  304. package/dist/cli-bundle/chunks/{register-mutation-4FMGJJF7.js → register-mutation-RBBJ52DK.js} +37 -33
  305. package/dist/cli-bundle/chunks/register-mutation-RBBJ52DK.js.map +1 -0
  306. package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js → register-operations-ZIBBRSED.js} +41 -39
  307. package/dist/cli-bundle/chunks/{register-operations-JVW24J2Y.js.map → register-operations-ZIBBRSED.js.map} +1 -1
  308. package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js → register-operations-ZUJ5JWPE.js} +39 -37
  309. package/dist/cli-bundle/chunks/{register-operations-ISUX6LY5.js.map → register-operations-ZUJ5JWPE.js.map} +1 -1
  310. package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js → register-setup-BCVLFEYS.js} +29 -17
  311. package/dist/cli-bundle/chunks/{register-setup-5XNGKJ22.js.map → register-setup-BCVLFEYS.js.map} +2 -2
  312. package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js → register-setup-TDCGWIOS.js} +19 -18
  313. package/dist/cli-bundle/chunks/{register-setup-ZTNY6S7R.js.map → register-setup-TDCGWIOS.js.map} +1 -1
  314. package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js → restore-25DLT2Q2.js} +6 -6
  315. package/dist/cli-bundle/chunks/restore-YPMVUUEX.js +14 -0
  316. package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js → schema-FNU3WE4O.js} +7 -6
  317. package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js → schema-NBCM3RAD.js} +7 -6
  318. package/dist/cli-bundle/chunks/update-WWBYOPXO.js +21 -0
  319. package/dist/cli-bundle/chunks/update-WWBYOPXO.js.map +7 -0
  320. package/dist/cli-bundle/chunks/{update-Q3UCILNR.js → update-XHSIAIXE.js} +12 -12
  321. package/dist/cli-bundle/chunks/update-XHSIAIXE.js.map +1 -0
  322. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js +32 -0
  323. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js.map +7 -0
  324. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js +36 -0
  325. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js.map +1 -0
  326. package/dist/cli-bundle/main.js +826 -43
  327. package/dist/cli-bundle/main.js.map +4 -4
  328. package/dist/cli-bundle/sdk-runtime.js +70 -57
  329. package/dist/cli-bundle/sdk-testing.js +6 -6
  330. package/dist/cli-bundle/sdk.js +876 -74
  331. package/dist/cli-bundle/sdk.js.map +4 -4
  332. package/dist/cli.js +5 -4
  333. package/dist/cli.js.map +1 -1
  334. package/dist/core/diagnostics/remediation.js +12 -2
  335. package/dist/core/diagnostics/remediation.js.map +1 -1
  336. package/dist/core/history/projection.d.ts +39 -0
  337. package/dist/core/history/projection.js +164 -0
  338. package/dist/core/history/projection.js.map +1 -0
  339. package/dist/core/history/read.d.ts +3 -0
  340. package/dist/core/history/read.js +55 -0
  341. package/dist/core/history/read.js.map +1 -0
  342. package/dist/core/output/output-control.d.ts +18 -0
  343. package/dist/core/output/output-control.js +26 -0
  344. package/dist/core/output/output-control.js.map +1 -0
  345. package/dist/core/output/output.js +20 -8
  346. package/dist/core/output/output.js.map +1 -1
  347. package/dist/core/sentry/helpers.js +10 -2
  348. package/dist/core/sentry/helpers.js.map +1 -1
  349. package/dist/core/shared/command-types.d.ts +2 -0
  350. package/dist/core/shared/command-types.js +2 -2
  351. package/dist/core/shared/command-types.js.map +1 -1
  352. package/dist/core/shared/errors.d.ts +11 -0
  353. package/dist/core/shared/errors.js +2 -2
  354. package/dist/core/shared/errors.js.map +1 -1
  355. package/dist/mcp/server.d.ts +2 -2
  356. package/dist/mcp/tool-definitions.js +5 -5
  357. package/dist/mcp/tool-definitions.js.map +1 -1
  358. package/dist/sdk/author-attribution.d.ts +35 -0
  359. package/dist/sdk/author-attribution.js +118 -0
  360. package/dist/sdk/author-attribution.js.map +1 -0
  361. package/dist/sdk/cli-contracts/command-aliases.d.ts +7 -0
  362. package/dist/sdk/cli-contracts/command-aliases.js +17 -0
  363. package/dist/sdk/cli-contracts/command-aliases.js.map +1 -0
  364. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  365. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  366. package/dist/sdk/cli-contracts/tool-option-contracts.js +6 -2
  367. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  368. package/dist/sdk/cli-contracts/tool-parameter-tables.js +21 -2
  369. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  370. package/dist/sdk/cli-contracts/tool-schema.js +3 -3
  371. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  372. package/dist/sdk/cli-contracts.d.ts +1 -0
  373. package/dist/sdk/cli-contracts.js +3 -2
  374. package/dist/sdk/cli-contracts.js.map +1 -1
  375. package/dist/sdk/cli-program.d.ts +8 -0
  376. package/dist/sdk/cli-program.js +39 -0
  377. package/dist/sdk/cli-program.js.map +1 -0
  378. package/dist/sdk/command-line.d.ts +11 -0
  379. package/dist/sdk/command-line.js +40 -0
  380. package/dist/sdk/command-line.js.map +1 -0
  381. package/dist/sdk/config.d.ts +163 -0
  382. package/dist/sdk/config.js +1087 -0
  383. package/dist/sdk/config.js.map +1 -0
  384. package/dist/sdk/context-relevance.d.ts +21 -0
  385. package/dist/sdk/context-relevance.js +70 -2
  386. package/dist/sdk/context-relevance.js.map +1 -1
  387. package/dist/sdk/dependencies.d.ts +15 -2
  388. package/dist/sdk/dependencies.js +97 -8
  389. package/dist/sdk/dependencies.js.map +1 -1
  390. package/dist/{cli/commands → sdk}/extension/bundled-catalog.d.ts +1 -1
  391. package/dist/{cli/commands → sdk}/extension/bundled-catalog.js +12 -12
  392. package/dist/sdk/extension/bundled-catalog.js.map +1 -0
  393. package/dist/sdk/extension/concurrency.d.ts +7 -0
  394. package/dist/sdk/extension/concurrency.js +26 -0
  395. package/dist/sdk/extension/concurrency.js.map +1 -0
  396. package/dist/sdk/extension/describe.d.ts +91 -0
  397. package/dist/sdk/extension/describe.js +144 -0
  398. package/dist/sdk/extension/describe.js.map +1 -0
  399. package/dist/{cli/commands → sdk}/extension/doctor.d.ts +3 -3
  400. package/dist/{cli/commands → sdk}/extension/doctor.js +7 -7
  401. package/dist/sdk/extension/doctor.js.map +1 -0
  402. package/dist/sdk/extension/install-runtime.d.ts +26 -0
  403. package/dist/sdk/extension/install-runtime.js +269 -0
  404. package/dist/sdk/extension/install-runtime.js.map +1 -0
  405. package/dist/sdk/extension/install-snapshot.d.ts +23 -0
  406. package/dist/sdk/extension/install-snapshot.js +66 -0
  407. package/dist/sdk/extension/install-snapshot.js.map +1 -0
  408. package/dist/{cli/commands → sdk}/extension/install-sources.d.ts +3 -3
  409. package/dist/{cli/commands → sdk}/extension/install-sources.js +15 -12
  410. package/dist/sdk/extension/install-sources.js.map +1 -0
  411. package/dist/{cli/commands → sdk}/extension/managed-state.js +6 -6
  412. package/dist/sdk/extension/managed-state.js.map +1 -0
  413. package/dist/sdk/extension/scaffold.d.ts +36 -0
  414. package/dist/sdk/extension/scaffold.js +2436 -0
  415. package/dist/sdk/extension/scaffold.js.map +1 -0
  416. package/dist/sdk/extension/shared.d.ts +28 -0
  417. package/dist/sdk/extension/shared.js +140 -0
  418. package/dist/sdk/extension/shared.js.map +1 -0
  419. package/dist/sdk/extension/update-check.d.ts +15 -0
  420. package/dist/sdk/extension/update-check.js +68 -0
  421. package/dist/sdk/extension/update-check.js.map +1 -0
  422. package/dist/sdk/extension.d.ts +367 -0
  423. package/dist/sdk/extension.js +2174 -0
  424. package/dist/sdk/extension.js.map +1 -0
  425. package/dist/sdk/governance/gc.d.ts +56 -0
  426. package/dist/sdk/governance/gc.js +276 -0
  427. package/dist/sdk/governance/gc.js.map +1 -0
  428. package/dist/sdk/governance/health.d.ts +187 -0
  429. package/dist/sdk/governance/health.js +1796 -0
  430. package/dist/sdk/governance/health.js.map +1 -0
  431. package/dist/sdk/governance/validate.d.ts +255 -0
  432. package/dist/sdk/governance/validate.js +2175 -0
  433. package/dist/sdk/governance/validate.js.map +1 -0
  434. package/dist/sdk/history-compact.d.ts +142 -0
  435. package/dist/sdk/history-compact.js +508 -0
  436. package/dist/sdk/history-compact.js.map +1 -0
  437. package/dist/sdk/history-mcp.d.ts +17 -0
  438. package/dist/sdk/history-mcp.js +68 -0
  439. package/dist/sdk/history-mcp.js.map +1 -0
  440. package/dist/sdk/history-read.d.ts +31 -0
  441. package/dist/sdk/history-read.js +58 -0
  442. package/dist/sdk/history-read.js.map +1 -0
  443. package/dist/sdk/history-redact.d.ts +120 -0
  444. package/dist/sdk/history-redact.js +577 -0
  445. package/dist/sdk/history-redact.js.map +1 -0
  446. package/dist/sdk/history-repair.d.ts +89 -0
  447. package/dist/sdk/history-repair.js +263 -0
  448. package/dist/sdk/history-repair.js.map +1 -0
  449. package/dist/sdk/index.d.ts +25 -1
  450. package/dist/sdk/index.js +27 -3
  451. package/dist/sdk/index.js.map +1 -1
  452. package/dist/sdk/init-agent-guidance.d.ts +113 -0
  453. package/dist/sdk/init-agent-guidance.js +437 -0
  454. package/dist/sdk/init-agent-guidance.js.map +1 -0
  455. package/dist/sdk/init.d.ts +186 -0
  456. package/dist/sdk/init.js +733 -0
  457. package/dist/sdk/init.js.map +1 -0
  458. package/dist/sdk/invocation-author.d.ts +2 -0
  459. package/dist/sdk/invocation-author.js +39 -0
  460. package/dist/sdk/invocation-author.js.map +1 -0
  461. package/dist/sdk/item-children.d.ts +45 -0
  462. package/dist/sdk/item-children.js +75 -0
  463. package/dist/sdk/item-children.js.map +1 -0
  464. package/dist/sdk/item-schedule.d.ts +26 -0
  465. package/dist/sdk/item-schedule.js +28 -0
  466. package/dist/sdk/item-schedule.js.map +1 -0
  467. package/dist/sdk/output.d.ts +7 -0
  468. package/dist/sdk/output.js +11 -0
  469. package/dist/sdk/output.js.map +1 -0
  470. package/dist/sdk/pagination.d.ts +4 -1
  471. package/dist/sdk/pagination.js +13 -5
  472. package/dist/sdk/pagination.js.map +1 -1
  473. package/dist/sdk/profile.d.ts +176 -0
  474. package/dist/sdk/profile.js +431 -0
  475. package/dist/sdk/profile.js.map +1 -0
  476. package/dist/sdk/relationship-analytics.d.ts +108 -0
  477. package/dist/sdk/relationship-analytics.js +292 -0
  478. package/dist/sdk/relationship-analytics.js.map +1 -0
  479. package/dist/sdk/relationship-context.d.ts +67 -0
  480. package/dist/sdk/relationship-context.js +207 -0
  481. package/dist/sdk/relationship-context.js.map +1 -0
  482. package/dist/sdk/relationship-history.d.ts +109 -0
  483. package/dist/sdk/relationship-history.js +401 -0
  484. package/dist/sdk/relationship-history.js.map +1 -0
  485. package/dist/sdk/relationships.d.ts +145 -0
  486. package/dist/sdk/relationships.js +551 -0
  487. package/dist/sdk/relationships.js.map +1 -0
  488. package/dist/sdk/runtime-input.d.ts +10 -0
  489. package/dist/sdk/runtime-input.js +60 -0
  490. package/dist/sdk/runtime-input.js.map +1 -0
  491. package/dist/sdk/runtime.d.ts +31 -8
  492. package/dist/sdk/runtime.js +61 -57
  493. package/dist/sdk/runtime.js.map +1 -1
  494. package/dist/sdk/schema.d.ts +507 -0
  495. package/dist/sdk/schema.js +1269 -0
  496. package/dist/sdk/schema.js.map +1 -0
  497. package/dist/{cli/commands → sdk}/templates.d.ts +1 -1
  498. package/dist/{cli/commands → sdk}/templates.js +9 -9
  499. package/dist/sdk/templates.js.map +1 -0
  500. package/dist/{cli/commands → sdk}/test/linked-command-detection.d.ts +10 -2
  501. package/dist/sdk/test/linked-command-detection.js +525 -0
  502. package/dist/sdk/test/linked-command-detection.js.map +1 -0
  503. package/docs/COMMANDS.md +58 -40
  504. package/docs/EXTENSIONS.md +10 -1
  505. package/docs/RELATIONSHIP_GRAPH.md +113 -0
  506. package/docs/RELEASING.md +2 -0
  507. package/docs/SDK.md +156 -9
  508. package/docs/SDK_CUSTOMIZATION_PRIMITIVES.md +79 -0
  509. package/marketplace.json +2 -2
  510. package/package.json +3 -2
  511. package/packages/pm-beads/package.json +1 -1
  512. package/packages/pm-calendar/package.json +1 -1
  513. package/packages/pm-command-kit/package.json +1 -1
  514. package/packages/pm-governance-audit/extensions/governance-audit/runtime-utils.ts +76 -16
  515. package/packages/pm-governance-audit/extensions/governance-audit/sdk.ts +8 -0
  516. package/packages/pm-governance-audit/package.json +1 -1
  517. package/packages/pm-guide-shell/package.json +1 -1
  518. package/packages/pm-kanban/package.json +1 -1
  519. package/packages/pm-lifecycle-hooks/package.json +1 -1
  520. package/packages/pm-linked-test-adapters/package.json +1 -1
  521. package/packages/pm-search-advanced/package.json +1 -1
  522. package/packages/pm-templates/package.json +1 -1
  523. package/packages/pm-todos/package.json +1 -1
  524. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  525. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  526. package/scripts/bundle-cli.mjs +66 -23
  527. package/dist/cli/commands/extension/bundled-catalog.js.map +0 -1
  528. package/dist/cli/commands/extension/doctor.js.map +0 -1
  529. package/dist/cli/commands/extension/install-sources.js.map +0 -1
  530. package/dist/cli/commands/extension/managed-state.js.map +0 -1
  531. package/dist/cli/commands/templates.js.map +0 -1
  532. package/dist/cli/commands/test/linked-command-detection.js +0 -248
  533. package/dist/cli/commands/test/linked-command-detection.js.map +0 -1
  534. package/dist/cli-bundle/chunks/append-DYQWQK2J.js +0 -11
  535. package/dist/cli-bundle/chunks/chunk-2GA3NK35.js +0 -530
  536. package/dist/cli-bundle/chunks/chunk-2GA3NK35.js.map +0 -1
  537. package/dist/cli-bundle/chunks/chunk-2QIQGYPW.js.map +0 -7
  538. package/dist/cli-bundle/chunks/chunk-4DY4KPQI.js.map +0 -7
  539. package/dist/cli-bundle/chunks/chunk-4WREH7RT.js +0 -554
  540. package/dist/cli-bundle/chunks/chunk-4WREH7RT.js.map +0 -7
  541. package/dist/cli-bundle/chunks/chunk-5CT5BW6E.js.map +0 -7
  542. package/dist/cli-bundle/chunks/chunk-5URI7TPJ.js.map +0 -7
  543. package/dist/cli-bundle/chunks/chunk-6MHSBDGD.js.map +0 -7
  544. package/dist/cli-bundle/chunks/chunk-6OTZMORS.js.map +0 -7
  545. package/dist/cli-bundle/chunks/chunk-6PKA3SJQ.js.map +0 -1
  546. package/dist/cli-bundle/chunks/chunk-6TTOHMTB.js.map +0 -1
  547. package/dist/cli-bundle/chunks/chunk-7QDSYUMF.js.map +0 -1
  548. package/dist/cli-bundle/chunks/chunk-7TQMR6LK.js.map +0 -7
  549. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js +0 -312
  550. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js.map +0 -7
  551. package/dist/cli-bundle/chunks/chunk-BPD26E3P.js.map +0 -1
  552. package/dist/cli-bundle/chunks/chunk-CDJYP7OQ.js.map +0 -1
  553. package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js +0 -858
  554. package/dist/cli-bundle/chunks/chunk-DBZVUJTK.js.map +0 -1
  555. package/dist/cli-bundle/chunks/chunk-DVOLZJ3C.js.map +0 -1
  556. package/dist/cli-bundle/chunks/chunk-DYEX6NFH.js.map +0 -7
  557. package/dist/cli-bundle/chunks/chunk-F7PSHRNO.js.map +0 -1
  558. package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js +0 -875
  559. package/dist/cli-bundle/chunks/chunk-FO7GMJKG.js.map +0 -7
  560. package/dist/cli-bundle/chunks/chunk-FTQLW4JD.js.map +0 -1
  561. package/dist/cli-bundle/chunks/chunk-IA3YFTXT.js.map +0 -1
  562. package/dist/cli-bundle/chunks/chunk-IGED7NH2.js.map +0 -7
  563. package/dist/cli-bundle/chunks/chunk-J4NZOP3I.js.map +0 -1
  564. package/dist/cli-bundle/chunks/chunk-JL7WZ4O2.js.map +0 -7
  565. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js +0 -309
  566. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js.map +0 -1
  567. package/dist/cli-bundle/chunks/chunk-LWTIRS3Y.js.map +0 -7
  568. package/dist/cli-bundle/chunks/chunk-MKL4CP2I.js.map +0 -1
  569. package/dist/cli-bundle/chunks/chunk-N3CMP4NI.js.map +0 -1
  570. package/dist/cli-bundle/chunks/chunk-PHKP3AGR.js.map +0 -7
  571. package/dist/cli-bundle/chunks/chunk-Q37E63AM.js.map +0 -7
  572. package/dist/cli-bundle/chunks/chunk-QASRVKUQ.js.map +0 -1
  573. package/dist/cli-bundle/chunks/chunk-RGXD5JJR.js.map +0 -7
  574. package/dist/cli-bundle/chunks/chunk-UB2QYSTO.js.map +0 -1
  575. package/dist/cli-bundle/chunks/chunk-UGTVWL3E.js.map +0 -1
  576. package/dist/cli-bundle/chunks/chunk-ZAYYDNB3.js.map +0 -1
  577. package/dist/cli-bundle/chunks/chunk-ZUKSZVBW.js.map +0 -7
  578. package/dist/cli-bundle/chunks/close-RI4JQQHU.js +0 -12
  579. package/dist/cli-bundle/chunks/close-many-LY2XJ52M.js +0 -21
  580. package/dist/cli-bundle/chunks/comments-35M273DN.js +0 -13
  581. package/dist/cli-bundle/chunks/copy-NPYM7M7U.js +0 -9
  582. package/dist/cli-bundle/chunks/delete-ODRWJWAM.js +0 -10
  583. package/dist/cli-bundle/chunks/docs-G7N4E2JO.js +0 -14
  584. package/dist/cli-bundle/chunks/focus-U5TRVCRS.js +0 -10
  585. package/dist/cli-bundle/chunks/history-compact-M7GHYVFN.js +0 -20
  586. package/dist/cli-bundle/chunks/history-redact-JIHZLHDP.js +0 -16
  587. package/dist/cli-bundle/chunks/history-repair-NAFCHLH7.js +0 -18
  588. package/dist/cli-bundle/chunks/learnings-SONGPSHI.js +0 -13
  589. package/dist/cli-bundle/chunks/notes-BSD53H2W.js +0 -13
  590. package/dist/cli-bundle/chunks/plan-AWLYGBNV.js +0 -24
  591. package/dist/cli-bundle/chunks/register-list-query-BUWCYHBT.js.map +0 -7
  592. package/dist/cli-bundle/chunks/register-list-query-KTZ6AGE7.js.map +0 -1
  593. package/dist/cli-bundle/chunks/register-mutation-4FMGJJF7.js.map +0 -1
  594. package/dist/cli-bundle/chunks/restore-66GLMHIX.js +0 -14
  595. package/dist/cli-bundle/chunks/update-2XGHIVQ2.js +0 -21
  596. package/dist/cli-bundle/chunks/update-many-75K57FS3.js +0 -34
  597. package/dist/cli-bundle/chunks/update-many-U42YA445.js +0 -30
  598. /package/dist/cli-bundle/chunks/{append-PVZJDM6J.js.map → append-OJQFUQ4T.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{append-DYQWQK2J.js.map → append-UZVHUO74.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{chunk-MQZ3PLCF.js.map → chunk-2IFFUZLC.js.map} +0 -0
  601. /package/dist/cli-bundle/chunks/{chunk-P6MYFH6K.js.map → chunk-2JKGO6QX.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{chunk-X3GYR4P2.js.map → chunk-2NCIPMQP.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{chunk-Q7E6OYZK.js.map → chunk-2VPAVL7O.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{chunk-DRNJPEPQ.js.map → chunk-2WSE6PO2.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{chunk-FDSBDNYE.js.map → chunk-34L5OT3Y.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{chunk-TH7U4KLY.js.map → chunk-3AUGG2DP.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{chunk-NKW36AMT.js.map → chunk-3CLU2XZO.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{chunk-ABRCOSDC.js.map → chunk-3WM75PWC.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{chunk-X6BVXQ52.js.map → chunk-5JLUII3O.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{chunk-3TL7WOEF.js.map → chunk-6N2VXVTQ.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{chunk-ERL2YFJ2.js.map → chunk-6S3YSUYG.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{chunk-IFZA4VB5.js.map → chunk-AHVTB5I5.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{chunk-DO5RGJXT.js.map → chunk-APRVSW2O.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{chunk-NAQYVWSQ.js.map → chunk-B7PE22W6.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{chunk-MD6ULIPJ.js.map → chunk-BCOFWYW4.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{chunk-KADLSPIU.js.map → chunk-BEP7WJA2.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{chunk-OBDLEQG5.js.map → chunk-CRVF2JDM.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{chunk-FJZDA6MS.js.map → chunk-DM4H7FP4.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{close-LZECOMHO.js.map → chunk-DUT67M43.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{chunk-44LNIULG.js.map → chunk-DYH63FX7.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{chunk-HAMLIWAF.js.map → chunk-EAB64KLB.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{chunk-CIOZ376P.js.map → chunk-EACOH7AU.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{chunk-QK2ZN6UL.js.map → chunk-EJEXHTY5.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{chunk-WQUEHPZB.js.map → chunk-EYLCSJAI.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{chunk-655STMGA.js.map → chunk-FMBNM2EN.js.map} +0 -0
  626. /package/dist/cli-bundle/chunks/{chunk-RMF3IOYQ.js.map → chunk-FNSPG7MU.js.map} +0 -0
  627. /package/dist/cli-bundle/chunks/{chunk-KB726FMH.js.map → chunk-H2Z3FYXQ.js.map} +0 -0
  628. /package/dist/cli-bundle/chunks/{chunk-BN62TO2S.js.map → chunk-IA5FKNII.js.map} +0 -0
  629. /package/dist/cli-bundle/chunks/{chunk-W6HZ55JO.js.map → chunk-IJIICKVW.js.map} +0 -0
  630. /package/dist/cli-bundle/chunks/{chunk-M7EWN4TF.js.map → chunk-JOUQZENX.js.map} +0 -0
  631. /package/dist/cli-bundle/chunks/{chunk-2FNWQXZ2.js.map → chunk-JYFOV7FC.js.map} +0 -0
  632. /package/dist/cli-bundle/chunks/{chunk-HLHSQ5CA.js.map → chunk-K2X6U4UA.js.map} +0 -0
  633. /package/dist/cli-bundle/chunks/{chunk-M6ASXYCU.js.map → chunk-KG44YSKD.js.map} +0 -0
  634. /package/dist/cli-bundle/chunks/{chunk-YVKE5ZDM.js.map → chunk-KPMKHGEA.js.map} +0 -0
  635. /package/dist/cli-bundle/chunks/{close-many-ZHI6A5TN.js.map → chunk-MIQDDLB5.js.map} +0 -0
  636. /package/dist/cli-bundle/chunks/{chunk-UJ4HJYWL.js.map → chunk-NLDFBC6J.js.map} +0 -0
  637. /package/dist/cli-bundle/chunks/{chunk-WRKB56FC.js.map → chunk-NP22ERDF.js.map} +0 -0
  638. /package/dist/cli-bundle/chunks/{chunk-YQYG2V23.js.map → chunk-NU3IMIEA.js.map} +0 -0
  639. /package/dist/cli-bundle/chunks/{chunk-3I3LRT2G.js.map → chunk-NVPZIJVR.js.map} +0 -0
  640. /package/dist/cli-bundle/chunks/{chunk-JAF4TUQ7.js.map → chunk-ODALILG3.js.map} +0 -0
  641. /package/dist/cli-bundle/chunks/{chunk-QZ7LT3XE.js.map → chunk-ONREO4ST.js.map} +0 -0
  642. /package/dist/cli-bundle/chunks/{chunk-3CMRNVTO.js.map → chunk-P74IZQ7A.js.map} +0 -0
  643. /package/dist/cli-bundle/chunks/{chunk-ZTRBSABY.js.map → chunk-PGY23YTC.js.map} +0 -0
  644. /package/dist/cli-bundle/chunks/{chunk-H2QBAKLQ.js.map → chunk-PMOSXADO.js.map} +0 -0
  645. /package/dist/cli-bundle/chunks/{close-RI4JQQHU.js.map → chunk-PNTULOGU.js.map} +0 -0
  646. /package/dist/cli-bundle/chunks/{chunk-GSEADLRH.js.map → chunk-Q7A43DS4.js.map} +0 -0
  647. /package/dist/cli-bundle/chunks/{chunk-QSPARJWF.js.map → chunk-QEHQ2GVG.js.map} +0 -0
  648. /package/dist/cli-bundle/chunks/{chunk-VJTAEIPC.js.map → chunk-QIPLHNP7.js.map} +0 -0
  649. /package/dist/cli-bundle/chunks/{chunk-K7WNZ7KD.js.map → chunk-QKJGPFAF.js.map} +0 -0
  650. /package/dist/cli-bundle/chunks/{chunk-ZNP64HOW.js.map → chunk-RLCHOOHC.js.map} +0 -0
  651. /package/dist/cli-bundle/chunks/{chunk-IAPHYPRL.js.map → chunk-RMLWNPH2.js.map} +0 -0
  652. /package/dist/cli-bundle/chunks/{chunk-UVBA6F5A.js.map → chunk-RRM5JYJC.js.map} +0 -0
  653. /package/dist/cli-bundle/chunks/{chunk-6IIVBC56.js.map → chunk-S6MQESFR.js.map} +0 -0
  654. /package/dist/cli-bundle/chunks/{chunk-QABYZYLU.js.map → chunk-SDQLJWBO.js.map} +0 -0
  655. /package/dist/cli-bundle/chunks/{chunk-ANSJHDOZ.js.map → chunk-SELVXEZK.js.map} +0 -0
  656. /package/dist/cli-bundle/chunks/{chunk-WD6MSYMP.js.map → chunk-TKOVBP6C.js.map} +0 -0
  657. /package/dist/cli-bundle/chunks/{chunk-TZ2PSLLT.js.map → chunk-TQSZFPIS.js.map} +0 -0
  658. /package/dist/cli-bundle/chunks/{chunk-WPAWZW7S.js.map → chunk-TSMHDIW4.js.map} +0 -0
  659. /package/dist/cli-bundle/chunks/{chunk-TZRTLMWM.js.map → chunk-UFXU44HV.js.map} +0 -0
  660. /package/dist/cli-bundle/chunks/{chunk-TWLDBKQU.js.map → chunk-ULTHRDBP.js.map} +0 -0
  661. /package/dist/cli-bundle/chunks/{chunk-RA5AIAMP.js.map → chunk-UOHFKBUV.js.map} +0 -0
  662. /package/dist/cli-bundle/chunks/{chunk-4RXTMU57.js.map → chunk-UY2ACEMF.js.map} +0 -0
  663. /package/dist/cli-bundle/chunks/{chunk-FIGXOCEQ.js.map → chunk-WUJQK4YV.js.map} +0 -0
  664. /package/dist/cli-bundle/chunks/{chunk-T4BRCB6Z.js.map → chunk-XSJUSQAE.js.map} +0 -0
  665. /package/dist/cli-bundle/chunks/{chunk-UKUIIBDW.js.map → chunk-YAQEBNY7.js.map} +0 -0
  666. /package/dist/cli-bundle/chunks/{chunk-E2WC6S4P.js.map → chunk-YBLZ2VE7.js.map} +0 -0
  667. /package/dist/cli-bundle/chunks/{chunk-Y72FV7RM.js.map → chunk-YCQET3OT.js.map} +0 -0
  668. /package/dist/cli-bundle/chunks/{close-many-LY2XJ52M.js.map → chunk-YUSOJDWM.js.map} +0 -0
  669. /package/dist/cli-bundle/chunks/{chunk-FS6UM5WH.js.map → chunk-ZI6VQWQ7.js.map} +0 -0
  670. /package/dist/cli-bundle/chunks/{comments-AJWRTFZ5.js.map → close-CWODTPKG.js.map} +0 -0
  671. /package/dist/cli-bundle/chunks/{comments-35M273DN.js.map → close-W6LI2PKM.js.map} +0 -0
  672. /package/dist/cli-bundle/chunks/{copy-GMXYKBXT.js.map → close-many-CQFUY7MR.js.map} +0 -0
  673. /package/dist/cli-bundle/chunks/{copy-NPYM7M7U.js.map → close-many-DLDDVSH5.js.map} +0 -0
  674. /package/dist/cli-bundle/chunks/{create-F53OBTOU.js.map → comments-E3TNTK24.js.map} +0 -0
  675. /package/dist/cli-bundle/chunks/{create-HU4Q7RJX.js.map → comments-WGLHR7LB.js.map} +0 -0
  676. /package/dist/cli-bundle/chunks/{delete-GSDZLTRC.js.map → copy-LXVDXH7B.js.map} +0 -0
  677. /package/dist/cli-bundle/chunks/{delete-ODRWJWAM.js.map → copy-Q5ZJPUKR.js.map} +0 -0
  678. /package/dist/cli-bundle/chunks/{deps-U57I7EAK.js.map → create-J5U6ND4K.js.map} +0 -0
  679. /package/dist/cli-bundle/chunks/{deps-WWB7P2GT.js.map → create-LBVCYMEG.js.map} +0 -0
  680. /package/dist/cli-bundle/chunks/{docs-MQIY2ZQS.js.map → delete-PMJBNY5G.js.map} +0 -0
  681. /package/dist/cli-bundle/chunks/{docs-G7N4E2JO.js.map → delete-WNHB3LYW.js.map} +0 -0
  682. /package/dist/cli-bundle/chunks/{files-TTY6N2AV.js.map → deps-JZ7TMVCB.js.map} +0 -0
  683. /package/dist/cli-bundle/chunks/{files-TBZD7V6H.js.map → deps-OA26IS25.js.map} +0 -0
  684. /package/dist/cli-bundle/chunks/{focus-XT6YVFFX.js.map → docs-FEWB2DQB.js.map} +0 -0
  685. /package/dist/cli-bundle/chunks/{focus-U5TRVCRS.js.map → docs-HA2AIDBB.js.map} +0 -0
  686. /package/dist/cli-bundle/chunks/{history-compact-M7GHYVFN.js.map → files-6YFBJRBG.js.map} +0 -0
  687. /package/dist/cli-bundle/chunks/{history-compact-KKVUWB4V.js.map → files-EFIWKFTM.js.map} +0 -0
  688. /package/dist/cli-bundle/chunks/{history-redact-3DVZOILD.js.map → focus-4QJR7FOQ.js.map} +0 -0
  689. /package/dist/cli-bundle/chunks/{history-redact-JIHZLHDP.js.map → focus-POIW5LTJ.js.map} +0 -0
  690. /package/dist/cli-bundle/chunks/{history-repair-ITDUMK4N.js.map → history-compact-CKRPDTJN.js.map} +0 -0
  691. /package/dist/cli-bundle/chunks/{history-repair-NAFCHLH7.js.map → history-compact-FWG2C7FZ.js.map} +0 -0
  692. /package/dist/cli-bundle/chunks/{learnings-SONGPSHI.js.map → history-redact-BB3TGDAE.js.map} +0 -0
  693. /package/dist/cli-bundle/chunks/{learnings-FGO3NSFW.js.map → history-redact-D225BHOZ.js.map} +0 -0
  694. /package/dist/cli-bundle/chunks/{notes-BSD53H2W.js.map → history-repair-6GEAM7HE.js.map} +0 -0
  695. /package/dist/cli-bundle/chunks/{notes-NQ6RXVW6.js.map → history-repair-RQXKQHL4.js.map} +0 -0
  696. /package/dist/cli-bundle/chunks/{plan-2NNEO46V.js.map → learnings-JLNLCOL5.js.map} +0 -0
  697. /package/dist/cli-bundle/chunks/{plan-AWLYGBNV.js.map → learnings-RSNLSWDC.js.map} +0 -0
  698. /package/dist/cli-bundle/chunks/{profile-U725ATWZ.js.map → notes-2WDH6DXU.js.map} +0 -0
  699. /package/dist/cli-bundle/chunks/{profile-AAQUU6T3.js.map → notes-GB47XXQQ.js.map} +0 -0
  700. /package/dist/cli-bundle/chunks/{restore-66GLMHIX.js.map → plan-DOVI2VMW.js.map} +0 -0
  701. /package/dist/cli-bundle/chunks/{restore-B3BAB6X2.js.map → plan-VDCJ2PCN.js.map} +0 -0
  702. /package/dist/cli-bundle/chunks/{schema-U7IM2DXV.js.map → profile-FAU7NZML.js.map} +0 -0
  703. /package/dist/cli-bundle/chunks/{schema-LZNUYHDB.js.map → profile-IVXQEL3D.js.map} +0 -0
  704. /package/dist/cli-bundle/chunks/{update-Q3UCILNR.js.map → restore-25DLT2Q2.js.map} +0 -0
  705. /package/dist/cli-bundle/chunks/{update-2XGHIVQ2.js.map → restore-YPMVUUEX.js.map} +0 -0
  706. /package/dist/cli-bundle/chunks/{update-many-75K57FS3.js.map → schema-FNU3WE4O.js.map} +0 -0
  707. /package/dist/cli-bundle/chunks/{update-many-U42YA445.js.map → schema-NBCM3RAD.js.map} +0 -0
  708. /package/dist/{cli/commands → sdk}/extension/managed-state.d.ts +0 -0
@@ -0,0 +1,1796 @@
1
+ /**
2
+ * @module sdk/governance/health
3
+ *
4
+ * Implements the pm health command surface and its agent-facing runtime behavior.
5
+ */
6
+
7
+ !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]="9e3d1799-829e-5a99-b960-a2b809511ef7")}catch(e){}}();
8
+ import fs from "node:fs/promises";
9
+ import path from "node:path";
10
+ import { resolveItemTypeRegistry } from "../../core/item/type-registry.js";
11
+ import { pathExists, readFileIfExists } from "../../core/fs/fs-utils.js";
12
+ import { activateExtensions, getActiveExtensionRegistrations, loadExtensions, runActiveOnReadHooks, } from "../../core/extensions/index.js";
13
+ import { collectRegisteredItemFieldNames } from "../../core/extensions/item-fields.js";
14
+ import { KNOWN_EXTENSION_CAPABILITIES, } from "../../core/extensions/loader.js";
15
+ import { enforceHistoryStreamPolicyForItems } from "../../core/history/history-stream-policy.js";
16
+ import { scanHistoryDrift } from "../../core/history/drift-scan.js";
17
+ import { scanLockHealth } from "../../core/lock/lock-gc.js";
18
+ import { readVectorizationStatusLedger, refreshSemanticEmbeddingsForMutatedItems, } from "../../core/search/cache.js";
19
+ import { resolveEmbeddingProviders, resolveProviderConfigSource, } from "../../core/search/providers.js";
20
+ import { resolveSettingsWithSemanticRuntimeDefaults } from "../../core/search/semantic-defaults.js";
21
+ import { collectStaleVectorizationIds } from "../../core/search/staleness.js";
22
+ import { buildVectorizationEmbeddingIdentity, hasVectorizationEmbeddingIdentityChanged, } from "../../core/search/vectorization-metadata.js";
23
+ import { resolveVectorStores } from "../../core/search/vector-stores.js";
24
+ import { EXIT_CODE, PM_CORE_REQUIRED_SUBDIRS, PM_OPTIONAL_TYPE_SUBDIRS, } from "../../core/shared/constants.js";
25
+ import { findFirstMergeConflictMarker } from "../../core/shared/conflict-markers.js";
26
+ import { PmCliError } from "../../core/shared/errors.js";
27
+ import { toNonEmptyStringOrUndefined } from "../../core/shared/primitives.js";
28
+ import { nowIso } from "../../core/shared/time.js";
29
+ import { parseItemDocument } from "../../core/item/item-format.js";
30
+ import { effectiveItemFormatVersion, scanItemFormatVersions, } from "../../core/item/item-format-version.js";
31
+ import { listAllItemMetadata, listAllItemMetadataWithBody, } from "../../core/store/item-store.js";
32
+ import { PM_TELEMETRY_SOURCE_CONTEXT_VALUES, TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS, TELEMETRY_SCHEMA_VERSION, } from "../../core/telemetry/runtime.js";
33
+ import { getItemFormatFromPath, getSettingsPath, ITEM_FILE_EXTENSIONS, resolveGlobalPmRoot, resolvePmRoot, } from "../../core/store/paths.js";
34
+ import { readSettingsWithMetadata } from "../../core/store/settings.js";
35
+ import { buildRemediationMap } from "../../core/diagnostics/remediation.js";
36
+ import { scanHistoryAuthorAttribution, } from "../author-attribution.js";
37
+ import { readManagedExtensionState } from "../extension.js";
38
+ import { buildCapabilityContractMetadata, buildRegistrationCollisionRemediation, collectUnknownCapabilityGuidance, } from "../extension/doctor.js";
39
+ const PM_TELEMETRY_SOURCE_CONTEXT_SET = new Set(PM_TELEMETRY_SOURCE_CONTEXT_VALUES);
40
+ const STALE_VECTORIZATION_SUMMARY_LIMIT = 25;
41
+ const BRIEF_HEALTH_DETAIL_LIMIT = 8;
42
+ const TELEMETRY_QUEUE_RELATIVE_PATH = path.join("runtime", "telemetry", "events.jsonl");
43
+ const TELEMETRY_STATE_RELATIVE_PATH = path.join("runtime", "telemetry", "state.json");
44
+ const TELEMETRY_ENDPOINT_PROBE_TIMEOUT_MS = 2_500;
45
+ const TELEMETRY_QUEUE_HIGH_WATER_MARK = 500;
46
+ const TELEMETRY_QUEUE_HIGH_RETRY_THRESHOLD = TELEMETRY_MAX_QUEUE_ENTRY_ATTEMPTS - 3;
47
+ const TELEMETRY_SERVER_MAX_SCHEMA_VERSION_HEADERS = [
48
+ "x-pm-telemetry-max-schema-version",
49
+ "x-pm-telemetry-max-version",
50
+ ];
51
+ /** Advisory warnings are surfaced for visibility but never flip overall health to not-ok. Telemetry is opt-out, non-critical observability: a queued/unreachable telemetry endpoint or corrupt local telemetry state is not a project-health failure and must not block agents that gate on `pm health` `ok`. History over-compaction-threshold warnings are likewise advisory maintenance hints — a deep stream is healthy, just a candidate for `pm history-compact`. */
52
+ function isAdvisoryHealthWarning(warning) {
53
+ return (warning.startsWith("telemetry_") ||
54
+ warning.startsWith("history_stream_over_compact_threshold:"));
55
+ }
56
+ function warningCode(value) {
57
+ const normalized = value.trim();
58
+ const separator = normalized.indexOf(":");
59
+ if (separator === -1) {
60
+ return normalized;
61
+ }
62
+ return normalized.slice(0, separator);
63
+ }
64
+ function normalizeExtensionNameForMatch(value) {
65
+ return value.trim().toLowerCase();
66
+ }
67
+ function isExpectedUnmanagedExtension(name, directory) {
68
+ const normalizedName = normalizeExtensionNameForMatch(name);
69
+ const normalizedDirectory = normalizeExtensionNameForMatch(directory);
70
+ if (normalizedName.startsWith("builtin-")) {
71
+ return true;
72
+ }
73
+ return normalizedDirectory === "beads" || normalizedDirectory === "todos";
74
+ }
75
+ async function isDirectory(targetPath) {
76
+ try {
77
+ const stats = await fs.stat(targetPath);
78
+ return stats.isDirectory();
79
+ }
80
+ catch {
81
+ return false;
82
+ }
83
+ }
84
+ async function countHistoryStreams(pmRoot, compactPolicy) {
85
+ const historyDir = path.join(pmRoot, "history");
86
+ if (!(await isDirectory(historyDir))) {
87
+ return { count: 0, warnings: [], over_threshold: [], max_entries: null };
88
+ }
89
+ const historyFiles = (await fs.readdir(historyDir))
90
+ .filter((entry) => entry.endsWith(".jsonl"))
91
+ .sort((left, right) => left.localeCompare(right));
92
+ const policyActive = compactPolicy.enabled;
93
+ const maxEntries = policyActive ? compactPolicy.max_entries : null;
94
+ const warnings = [];
95
+ const overThreshold = [];
96
+ for (const fileName of historyFiles) {
97
+ const streamPath = path.join(historyDir, fileName);
98
+ warnings.push(...(await runActiveOnReadHooks({ path: streamPath, scope: "project" })));
99
+ if (!policyActive) {
100
+ continue;
101
+ }
102
+ const raw = await fs.readFile(streamPath, "utf8");
103
+ let entries = 0;
104
+ for (const line of raw.split(/\r?\n/)) {
105
+ if (line.trim().length > 0) {
106
+ entries += 1;
107
+ }
108
+ }
109
+ if (entries > compactPolicy.max_entries) {
110
+ overThreshold.push(fileName.slice(0, -".jsonl".length));
111
+ }
112
+ }
113
+ return {
114
+ count: historyFiles.length,
115
+ warnings: [
116
+ ...warnings,
117
+ ...overThreshold.map((id) => `history_stream_over_compact_threshold:${id}`),
118
+ ],
119
+ over_threshold: overThreshold,
120
+ max_entries: maxEntries,
121
+ };
122
+ }
123
+ function normalizeRelativePath(pmRoot, targetPath) {
124
+ return path.relative(pmRoot, targetPath).replaceAll("\\", "/");
125
+ }
126
+ async function listItemDocumentPaths(pmRoot, typeToFolder) {
127
+ const folders = [...new Set(Object.values(typeToFolder))].sort((left, right) => left.localeCompare(right));
128
+ const itemPaths = [];
129
+ for (const folder of folders) {
130
+ const directoryPath = path.join(pmRoot, folder);
131
+ let entries = [];
132
+ try {
133
+ entries = await fs.readdir(directoryPath);
134
+ }
135
+ catch (error) {
136
+ if (typeof error === "object" &&
137
+ error !== null &&
138
+ "code" in error &&
139
+ error.code === "ENOENT") {
140
+ continue;
141
+ }
142
+ continue;
143
+ }
144
+ for (const entry of entries) {
145
+ if (!ITEM_FILE_EXTENSIONS.some((extension) => entry.toLowerCase().endsWith(extension))) {
146
+ continue;
147
+ }
148
+ itemPaths.push(path.join(directoryPath, entry));
149
+ }
150
+ }
151
+ itemPaths.sort((left, right) => normalizeRelativePath(pmRoot, left).localeCompare(normalizeRelativePath(pmRoot, right)));
152
+ return itemPaths;
153
+ }
154
+ function shouldReportHistoryDirectoryUnreadable(error) {
155
+ return !(typeof error === "object" &&
156
+ error !== null &&
157
+ "code" in error &&
158
+ error.code === "ENOENT");
159
+ }
160
+ async function buildIntegrityCheck(pmRoot, typeToFolder, schema) {
161
+ const itemPaths = await listItemDocumentPaths(pmRoot, typeToFolder);
162
+ const itemUnreadable = [];
163
+ const itemConflictMarkers = [];
164
+ const itemParseFailures = [];
165
+ const formatVersionEntries = [];
166
+ const extensionFieldNames = collectRegisteredItemFieldNames(getActiveExtensionRegistrations());
167
+ for (const itemPath of itemPaths) {
168
+ const relativePath = normalizeRelativePath(pmRoot, itemPath);
169
+ let raw = "";
170
+ try {
171
+ raw = await fs.readFile(itemPath, "utf8");
172
+ }
173
+ catch {
174
+ itemUnreadable.push(relativePath);
175
+ continue;
176
+ }
177
+ const conflictMarker = findFirstMergeConflictMarker(raw);
178
+ if (conflictMarker) {
179
+ itemConflictMarkers.push({
180
+ path: relativePath,
181
+ line: conflictMarker.line,
182
+ marker: conflictMarker.marker,
183
+ });
184
+ continue;
185
+ }
186
+ try {
187
+ const parsed = parseItemDocument(raw, {
188
+ format: getItemFormatFromPath(itemPath),
189
+ schema,
190
+ extensionFieldNames,
191
+ });
192
+ formatVersionEntries.push({
193
+ ref: relativePath,
194
+ version: effectiveItemFormatVersion(parsed.metadata),
195
+ });
196
+ }
197
+ catch {
198
+ itemParseFailures.push(relativePath);
199
+ }
200
+ }
201
+ const formatVersionScan = scanItemFormatVersions(formatVersionEntries);
202
+ const historyDir = path.join(pmRoot, "history");
203
+ const historyUnreadable = [];
204
+ const historyConflictMarkers = [];
205
+ const historyInvalidJson = [];
206
+ let historyFiles = [];
207
+ try {
208
+ historyFiles = (await fs.readdir(historyDir))
209
+ .filter((entry) => entry.endsWith(".jsonl"))
210
+ .sort((left, right) => left.localeCompare(right));
211
+ }
212
+ catch (error) {
213
+ /* c8 ignore start -- ENOENT/non-ENOENT differentiation requires filesystem fault injection */
214
+ if (shouldReportHistoryDirectoryUnreadable(error)) {
215
+ historyUnreadable.push("history");
216
+ }
217
+ /* c8 ignore stop */
218
+ }
219
+ for (const fileName of historyFiles) {
220
+ const itemId = fileName.slice(0, -".jsonl".length);
221
+ const historyPath = path.join(historyDir, fileName);
222
+ let raw = "";
223
+ try {
224
+ raw = await fs.readFile(historyPath, "utf8");
225
+ }
226
+ catch {
227
+ historyUnreadable.push(itemId);
228
+ continue;
229
+ }
230
+ const conflictMarker = findFirstMergeConflictMarker(raw);
231
+ if (conflictMarker) {
232
+ historyConflictMarkers.push({
233
+ id: itemId,
234
+ line: conflictMarker.line,
235
+ marker: conflictMarker.marker,
236
+ });
237
+ continue;
238
+ }
239
+ const lines = raw.split(/\r?\n/);
240
+ for (let index = 0; index < lines.length; index += 1) {
241
+ const line = lines[index]?.trim();
242
+ if (!line) {
243
+ continue;
244
+ }
245
+ try {
246
+ JSON.parse(line);
247
+ }
248
+ catch {
249
+ historyInvalidJson.push({
250
+ id: itemId,
251
+ line: index + 1,
252
+ });
253
+ }
254
+ }
255
+ }
256
+ const warnings = [
257
+ ...itemUnreadable.map((entry) => `integrity_item_unreadable:${entry}`),
258
+ ...itemConflictMarkers.map((entry) => `integrity_item_conflict_marker:${entry.path}:L${entry.line}`),
259
+ ...itemParseFailures.map((entry) => `integrity_item_parse_failed:${entry}`),
260
+ ...historyUnreadable.map((entry) => `integrity_history_unreadable:${entry}`),
261
+ ...historyConflictMarkers.map((entry) => `integrity_history_conflict_marker:${entry.id}:L${entry.line}`),
262
+ ...historyInvalidJson.map((entry) => `integrity_history_invalid_json:${entry.id}:L${entry.line}`),
263
+ /* c8 ignore start -- outdated-version items are unreachable until CURRENT_ITEM_FORMAT_VERSION advances past the baseline (an effective version below 1 cannot occur); the per-item mapping is covered in item-format-version.spec, and the ahead path below is covered by health-command.spec */
264
+ ...formatVersionScan.outdated.map((entry) => `integrity_item_outdated_format_version:${entry}`),
265
+ /* c8 ignore stop */
266
+ ...formatVersionScan.ahead.map((entry) => `integrity_item_ahead_format_version:${entry}`),
267
+ ];
268
+ const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
269
+ return {
270
+ check: {
271
+ name: "integrity",
272
+ status: normalizedWarnings.length === 0 ? "ok" : "warn",
273
+ details: {
274
+ checked_item_files: itemPaths.length,
275
+ checked_history_streams: historyFiles.length,
276
+ counts: {
277
+ item_unreadable: itemUnreadable.length,
278
+ item_conflict_markers: itemConflictMarkers.length,
279
+ item_parse_failures: itemParseFailures.length,
280
+ history_unreadable: historyUnreadable.length,
281
+ history_conflict_markers: historyConflictMarkers.length,
282
+ history_invalid_json: historyInvalidJson.length,
283
+ item_outdated_format_version: formatVersionScan.outdated.length,
284
+ item_ahead_format_version: formatVersionScan.ahead.length,
285
+ },
286
+ item_unreadable: itemUnreadable,
287
+ item_conflict_markers: itemConflictMarkers,
288
+ item_parse_failures: itemParseFailures,
289
+ item_outdated_format_version: formatVersionScan.outdated,
290
+ item_ahead_format_version: formatVersionScan.ahead,
291
+ history_unreadable: historyUnreadable,
292
+ history_conflict_markers: historyConflictMarkers,
293
+ history_invalid_json: historyInvalidJson,
294
+ },
295
+ },
296
+ warnings: normalizedWarnings,
297
+ };
298
+ }
299
+ /* c8 ignore start -- activate export shape variants are exercised through integration load tests */
300
+ function hasActivateExport(moduleRecord) {
301
+ if (typeof moduleRecord.activate === "function") {
302
+ return true;
303
+ }
304
+ const defaultExport = moduleRecord.default;
305
+ if (typeof defaultExport !== "object" || defaultExport === null) {
306
+ return false;
307
+ }
308
+ return (typeof defaultExport.activate === "function");
309
+ }
310
+ /* c8 ignore stop */
311
+ function summarizeLoadedExtension(extension) {
312
+ const summary = {
313
+ layer: extension.layer,
314
+ directory: extension.directory,
315
+ manifest_path: extension.manifest_path,
316
+ name: extension.name,
317
+ version: extension.version,
318
+ entry: extension.entry,
319
+ priority: extension.priority,
320
+ entry_path: extension.entry_path,
321
+ has_activate: hasActivateExport(extension.module),
322
+ };
323
+ /* c8 ignore start -- capability list optionality is exercised by extension load integration suites */
324
+ if (Array.isArray(extension.capabilities)) {
325
+ summary.capabilities = [...extension.capabilities];
326
+ }
327
+ /* c8 ignore stop */
328
+ return summary;
329
+ }
330
+ function resolveMigrationId(definition, fallbackIndex) {
331
+ const explicitId = toNonEmptyStringOrUndefined(definition.id);
332
+ if (explicitId) {
333
+ return explicitId;
334
+ }
335
+ return `migration-${String(fallbackIndex + 1).padStart(3, "0")}`;
336
+ }
337
+ function resolveMigrationStatus(definition) {
338
+ const rawStatus = toNonEmptyStringOrUndefined(definition.status);
339
+ const normalized = rawStatus?.toLowerCase();
340
+ if (normalized === "failed") {
341
+ return "failed";
342
+ }
343
+ if (normalized === "applied") {
344
+ return "applied";
345
+ }
346
+ return "pending";
347
+ }
348
+ function resolveMigrationFailureReason(definition) {
349
+ return (toNonEmptyStringOrUndefined(definition.reason) ??
350
+ toNonEmptyStringOrUndefined(definition.error) ??
351
+ toNonEmptyStringOrUndefined(definition.message));
352
+ }
353
+ /* c8 ignore start -- comparator tie-break branches are deterministic ordering glue exercised via migration integration tests */
354
+ function compareMigrationEntries(left, right) {
355
+ const byLayer = (left.layer ?? "").localeCompare(right.layer ?? "");
356
+ if (byLayer !== 0) {
357
+ return byLayer;
358
+ }
359
+ const byName = (left.name ?? "").localeCompare(right.name ?? "");
360
+ if (byName !== 0) {
361
+ return byName;
362
+ }
363
+ return (left.id ?? "").localeCompare(right.id ?? "");
364
+ }
365
+ /* c8 ignore stop */
366
+ function summarizeMigrationStatuses(migrations) {
367
+ const applied = [];
368
+ const pending = [];
369
+ const failed = [];
370
+ migrations.forEach((migration, index) => {
371
+ const id = resolveMigrationId(migration.definition, index);
372
+ const status = resolveMigrationStatus(migration.definition);
373
+ if (status === "applied") {
374
+ applied.push({
375
+ layer: migration.layer,
376
+ name: migration.name,
377
+ id,
378
+ status,
379
+ });
380
+ return;
381
+ }
382
+ if (status === "failed") {
383
+ failed.push({
384
+ layer: migration.layer,
385
+ name: migration.name,
386
+ id,
387
+ status,
388
+ reason: resolveMigrationFailureReason(migration.definition),
389
+ });
390
+ return;
391
+ }
392
+ pending.push({
393
+ layer: migration.layer,
394
+ name: migration.name,
395
+ id,
396
+ status,
397
+ });
398
+ });
399
+ applied.sort(compareMigrationEntries);
400
+ pending.sort(compareMigrationEntries);
401
+ failed.sort(compareMigrationEntries);
402
+ const warnings = [
403
+ ...failed.map((entry) => `extension_migration_failed:${entry.layer}:${entry.name}:${entry.id}`),
404
+ ...pending.map((entry) => `extension_migration_pending:${entry.layer}:${entry.name}:${entry.id}`),
405
+ ];
406
+ return {
407
+ summary: {
408
+ applied,
409
+ pending,
410
+ failed,
411
+ applied_count: applied.length,
412
+ pending_count: pending.length,
413
+ failed_count: failed.length,
414
+ },
415
+ warnings,
416
+ };
417
+ }
418
+ function buildExtensionHealthTriageSummary(warnings, loadFailureCount, activationFailureCount, migrationStatus, managedStateWarningCount, managedExtensionEntriesCount, unmanagedLoadedExtensions, unmanagedExpectedExtensions, unmanagedActionRequiredExtensions) {
419
+ const normalizedWarnings = [...new Set(warnings)].sort((left, right) => left.localeCompare(right));
420
+ const warningCodes = [
421
+ ...new Set(normalizedWarnings.map((value) => warningCode(value))),
422
+ ].sort((left, right) => left.localeCompare(right));
423
+ const unknownCapabilityCount = normalizedWarnings.filter((warning) => warning.startsWith("extension_capability_unknown:")).length;
424
+ const updateHealthPartial = unmanagedActionRequiredExtensions.length > 0;
425
+ const updateHealthCoverage = updateHealthPartial ? "partial" : "full";
426
+ const remediation = [];
427
+ const registrationCollisionRemediation = buildRegistrationCollisionRemediation(normalizedWarnings, {
428
+ deactivate: "pm extension --deactivate <name> --project/--global",
429
+ doctor: "pm extension --doctor --project/--global --detail deep --trace",
430
+ });
431
+ if (registrationCollisionRemediation) {
432
+ remediation.push(registrationCollisionRemediation);
433
+ }
434
+ if (loadFailureCount > 0) {
435
+ remediation.push("Run pm extension --explore --project and pm extension --explore --global to inspect load failures.");
436
+ }
437
+ if (activationFailureCount > 0) {
438
+ remediation.push("Review checks[name=extensions].details.activation.failed in pm health --json for activation error details.");
439
+ }
440
+ if (migrationStatus.failed_count > 0 || migrationStatus.pending_count > 0) {
441
+ remediation.push("Resolve pending/failed extension migrations before write commands; use --force only when policy allows.");
442
+ }
443
+ if (managedStateWarningCount > 0) {
444
+ remediation.push("Run pm extension --manage --project and pm extension --manage --global to refresh managed-state diagnostics.");
445
+ }
446
+ if (unknownCapabilityCount > 0) {
447
+ remediation.push(`Unknown extension capabilities detected. Allowed capabilities: ${KNOWN_EXTENSION_CAPABILITIES.join(", ")}. ` +
448
+ "Review extension_capability_unknown warning details for suggested replacements.");
449
+ }
450
+ if (normalizedWarnings.some((warning) => warning.startsWith("extension_capability_legacy_alias:"))) {
451
+ remediation.push("Legacy extension capability aliases were auto-remapped to canonical capabilities. " +
452
+ "Update manifests to canonical names (migration/validation -> schema).");
453
+ }
454
+ if (normalizedWarnings.some((warning) => warning.startsWith("extension_command_definition_legacy_handler_alias:"))) {
455
+ remediation.push("Extension command definitions using legacy handler were auto-remapped. " +
456
+ "Update command definitions to use run: (context) => ... for forward compatibility.");
457
+ }
458
+ if (updateHealthPartial) {
459
+ remediation.push("Update-check coverage is partial because unmanaged extensions need adoption. Adopt existing installs via pm extension --manage --project/--global --fix-managed-state, pm extension --adopt-all --project/--global, or pm extension --adopt <name>.");
460
+ }
461
+ else if (unmanagedLoadedExtensions.length > 0) {
462
+ remediation.push("Loaded unmanaged extensions are currently treated as informational. Use pm extension --manage --project/--global --fix-managed-state to adopt them for update checks.");
463
+ }
464
+ if (remediation.length === 0) {
465
+ remediation.push("No immediate action required. Re-run pm health after extension configuration changes.");
466
+ }
467
+ return {
468
+ status: normalizedWarnings.length === 0 ? "ok" : "warn",
469
+ warning_count: normalizedWarnings.length,
470
+ warning_codes: warningCodes,
471
+ load_failure_count: loadFailureCount,
472
+ activation_failure_count: activationFailureCount,
473
+ migration_failed_count: migrationStatus.failed_count,
474
+ migration_pending_count: migrationStatus.pending_count,
475
+ managed_state_warning_count: managedStateWarningCount,
476
+ managed_extension_entries_count: managedExtensionEntriesCount,
477
+ unmanaged_loaded_extension_count: unmanagedLoadedExtensions.length,
478
+ unmanaged_loaded_extensions: unmanagedLoadedExtensions,
479
+ unmanaged_expected_extension_count: unmanagedExpectedExtensions.length,
480
+ unmanaged_expected_extensions: unmanagedExpectedExtensions,
481
+ unmanaged_action_required_extension_count: unmanagedActionRequiredExtensions.length,
482
+ unmanaged_action_required_extensions: unmanagedActionRequiredExtensions,
483
+ update_health_coverage: updateHealthCoverage,
484
+ update_health_partial: updateHealthPartial,
485
+ unknown_capability_count: unknownCapabilityCount,
486
+ top_warnings: normalizedWarnings.slice(0, 8),
487
+ remediation,
488
+ };
489
+ }
490
+ async function buildExtensionCheck(pmRoot, settings, noExtensionsFlag) {
491
+ const loadResult = await loadExtensions({
492
+ pmRoot,
493
+ settings,
494
+ cwd: process.cwd(),
495
+ noExtensions: noExtensionsFlag,
496
+ });
497
+ const loadedSummaries = loadResult.loaded.map((extension) => summarizeLoadedExtension(extension));
498
+ const activationResult = await activateExtensions({
499
+ ...loadResult,
500
+ loaded: loadResult.loaded,
501
+ });
502
+ const [projectManagedState, globalManagedState] = await Promise.all([
503
+ readManagedExtensionState(loadResult.roots.project),
504
+ readManagedExtensionState(loadResult.roots.global),
505
+ ]);
506
+ const migrationStatus = summarizeMigrationStatuses(activationResult.registrations.migrations);
507
+ const activationDetails = {
508
+ failed: activationResult.failed,
509
+ warnings: activationResult.warnings,
510
+ hook_counts: activationResult.hook_counts,
511
+ command_override_count: activationResult.command_override_count,
512
+ command_handler_count: activationResult.command_handler_count,
513
+ parser_override_count: activationResult.parser_override_count,
514
+ preflight_override_count: activationResult.preflight_override_count,
515
+ service_override_count: activationResult.service_override_count,
516
+ renderer_override_count: activationResult.renderer_override_count,
517
+ registration_counts: activationResult.registration_counts,
518
+ registrations: activationResult.registrations,
519
+ migration_status: migrationStatus.summary,
520
+ managed_extensions: {
521
+ project: {
522
+ path: projectManagedState.path,
523
+ count: projectManagedState.state.entries.length,
524
+ entries: projectManagedState.state.entries,
525
+ },
526
+ global: {
527
+ path: globalManagedState.path,
528
+ count: globalManagedState.state.entries.length,
529
+ entries: globalManagedState.state.entries,
530
+ },
531
+ },
532
+ };
533
+ /* c8 ignore start -- unmanaged/expected grouping matrices are exercised in doctor + extension integration suites */
534
+ const managedProjectNames = new Set(projectManagedState.state.entries.map((entry) => normalizeExtensionNameForMatch(entry.name)));
535
+ const managedGlobalNames = new Set(globalManagedState.state.entries.map((entry) => normalizeExtensionNameForMatch(entry.name)));
536
+ const unmanagedLoadedEntries = [
537
+ ...new Map(loadResult.loaded
538
+ .filter((entry) => {
539
+ const managedNames = entry.layer === "project"
540
+ ? managedProjectNames
541
+ : managedGlobalNames;
542
+ return !managedNames.has(normalizeExtensionNameForMatch(entry.name));
543
+ })
544
+ .map((entry) => [
545
+ `${entry.layer}:${entry.name}`,
546
+ {
547
+ layer: entry.layer,
548
+ name: entry.name,
549
+ directory: entry.directory,
550
+ },
551
+ ])).values(),
552
+ ].sort((left, right) => {
553
+ const leftKey = `${left.layer}:${left.name}`;
554
+ const rightKey = `${right.layer}:${right.name}`;
555
+ return leftKey.localeCompare(rightKey);
556
+ });
557
+ const unmanagedLoadedExtensions = unmanagedLoadedEntries
558
+ .map((entry) => `${entry.layer}:${entry.name}`)
559
+ .sort((left, right) => left.localeCompare(right));
560
+ const unmanagedExpectedExtensions = unmanagedLoadedEntries
561
+ .filter((entry) => isExpectedUnmanagedExtension(entry.name, entry.directory))
562
+ .map((entry) => `${entry.layer}:${entry.name}`)
563
+ .sort((left, right) => left.localeCompare(right));
564
+ const unmanagedActionRequiredExtensions = unmanagedLoadedEntries
565
+ .filter((entry) => !isExpectedUnmanagedExtension(entry.name, entry.directory))
566
+ .map((entry) => `${entry.layer}:${entry.name}`)
567
+ .sort((left, right) => left.localeCompare(right));
568
+ /* c8 ignore stop */
569
+ const updateCoverageWarnings = unmanagedActionRequiredExtensions.length > 0
570
+ ? [
571
+ `extension_update_health_partial_coverage:skipped_unmanaged:${unmanagedActionRequiredExtensions.length}`,
572
+ ]
573
+ : [];
574
+ const extensionWarnings = [
575
+ ...loadResult.warnings,
576
+ ...activationDetails.warnings,
577
+ ...migrationStatus.warnings,
578
+ ...projectManagedState.warnings,
579
+ ...globalManagedState.warnings,
580
+ ...updateCoverageWarnings,
581
+ ];
582
+ const capabilityGuidance = collectUnknownCapabilityGuidance(extensionWarnings);
583
+ const capabilityContract = buildCapabilityContractMetadata();
584
+ const extensionTriage = buildExtensionHealthTriageSummary(extensionWarnings, loadResult.failed.length, activationResult.failed.length, migrationStatus.summary, projectManagedState.warnings.length + globalManagedState.warnings.length, projectManagedState.state.entries.length +
585
+ globalManagedState.state.entries.length, unmanagedLoadedExtensions, unmanagedExpectedExtensions, unmanagedActionRequiredExtensions);
586
+ return {
587
+ check: {
588
+ name: "extensions",
589
+ status: extensionWarnings.length === 0 ? "ok" : "warn",
590
+ details: {
591
+ ...loadResult,
592
+ loaded: loadedSummaries,
593
+ warnings: extensionWarnings,
594
+ activation: activationDetails,
595
+ triage: extensionTriage,
596
+ capability_contract: capabilityContract,
597
+ capability_guidance: capabilityGuidance,
598
+ },
599
+ },
600
+ warnings: extensionWarnings,
601
+ };
602
+ }
603
+ function summarizeList(values, limit) {
604
+ if (values.length <= limit) {
605
+ return { values, truncated: false };
606
+ }
607
+ return {
608
+ values: values.slice(0, limit),
609
+ truncated: true,
610
+ };
611
+ }
612
+ function summarizeRecordList(value, limit) {
613
+ if (!Array.isArray(value)) {
614
+ return {
615
+ count: 0,
616
+ sample: [],
617
+ truncated: false,
618
+ };
619
+ }
620
+ return {
621
+ count: value.length,
622
+ sample: value.slice(0, limit),
623
+ truncated: value.length > limit,
624
+ };
625
+ }
626
+ function summarizeExtensionRecord(value) {
627
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
628
+ return {};
629
+ }
630
+ const record = value;
631
+ return {
632
+ layer: record.layer,
633
+ directory: record.directory,
634
+ name: record.name,
635
+ version: record.version,
636
+ enabled: record.enabled,
637
+ status: record.status,
638
+ has_activate: record.has_activate,
639
+ capabilities: record.capabilities,
640
+ };
641
+ }
642
+ function summarizeExtensionList(value, limit) {
643
+ const summary = summarizeRecordList(value, limit);
644
+ return {
645
+ ...summary,
646
+ sample: summary.sample.map((entry) => summarizeExtensionRecord(entry)),
647
+ };
648
+ }
649
+ function summarizeStringList(value, limit) {
650
+ if (!Array.isArray(value)) {
651
+ return {
652
+ count: 0,
653
+ sample: [],
654
+ truncated: false,
655
+ };
656
+ }
657
+ const strings = value.filter((entry) => typeof entry === "string");
658
+ return {
659
+ count: strings.length,
660
+ sample: strings.slice(0, limit),
661
+ truncated: strings.length > limit,
662
+ };
663
+ }
664
+ function summarizeActivationMigrationStatus(value) {
665
+ if (typeof value !== "object" || value === null) {
666
+ return null;
667
+ }
668
+ const status = value;
669
+ return {
670
+ applied_count: status.applied_count,
671
+ pending_count: status.pending_count,
672
+ failed_count: status.failed_count,
673
+ };
674
+ }
675
+ const HEALTH_DETAIL_SUMMARIZERS = {
676
+ settings: (details, limit) => ({
677
+ version: details.version,
678
+ id_prefix: details.id_prefix,
679
+ locks_ttl_seconds: details.locks_ttl_seconds,
680
+ warnings: summarizeStringList(details.warnings, limit),
681
+ }),
682
+ directories: (details, limit) => ({
683
+ required_count: Array.isArray(details.required)
684
+ ? details.required.length
685
+ : 0,
686
+ optional_count: Array.isArray(details.optional)
687
+ ? details.optional.length
688
+ : 0,
689
+ missing_required: summarizeStringList(details.missing_required, limit),
690
+ missing_optional: summarizeStringList(details.missing_optional, limit),
691
+ missing: summarizeStringList(details.missing, limit),
692
+ strict_directories: details.strict_directories,
693
+ }),
694
+ settings_values: (details, limit) => ({
695
+ warnings: summarizeStringList(details.warnings, limit),
696
+ }),
697
+ telemetry: (details) => ({
698
+ enabled: details.enabled,
699
+ capture_level: details.capture_level,
700
+ endpoint: details.endpoint,
701
+ queue_exists: details.queue_exists,
702
+ queue_entries: details.queue_entries,
703
+ queue_draining: details.queue_draining,
704
+ queue_invalid_rows: details.queue_invalid_rows,
705
+ queue_rows_total: details.queue_rows_total,
706
+ last_successful_flush_at: details.last_successful_flush_at,
707
+ last_failed_flush_at: details.last_failed_flush_at,
708
+ endpoint_probe: details.endpoint_probe,
709
+ env_overrides: details.env_overrides,
710
+ }),
711
+ extensions: (details, limit) => {
712
+ const activation = typeof details.activation === "object" && details.activation !== null
713
+ ? details.activation
714
+ : {};
715
+ return {
716
+ disabled_by_flag: details.disabled_by_flag,
717
+ discovered: summarizeExtensionList(details.discovered, limit),
718
+ effective: summarizeExtensionList(details.effective, limit),
719
+ loaded: summarizeExtensionList(details.loaded, limit),
720
+ failed: summarizeRecordList(details.failed, limit),
721
+ warnings: summarizeStringList(details.warnings, limit),
722
+ activation: {
723
+ failed: summarizeRecordList(activation.failed, limit),
724
+ warnings: summarizeStringList(activation.warnings, limit),
725
+ hook_counts: activation.hook_counts,
726
+ command_handler_count: activation.command_handler_count,
727
+ service_override_count: activation.service_override_count,
728
+ renderer_override_count: activation.renderer_override_count,
729
+ registration_counts: activation.registration_counts,
730
+ migration_status: summarizeActivationMigrationStatus(activation.migration_status),
731
+ },
732
+ triage: details.triage,
733
+ capability_contract: details.capability_contract,
734
+ capability_guidance: summarizeRecordList(details.capability_guidance, limit),
735
+ };
736
+ },
737
+ storage: (details, limit) => {
738
+ // Preserve compatibility with brief payloads from older builds and extensions.
739
+ const authorAttribution = typeof details.author_attribution === "object" &&
740
+ details.author_attribution !== null
741
+ ? details.author_attribution
742
+ : undefined;
743
+ return {
744
+ ...details,
745
+ ...(authorAttribution
746
+ ? {
747
+ author_attribution: {
748
+ ...authorAttribution,
749
+ affected_item_ids: summarizeStringList(authorAttribution.affected_item_ids, limit),
750
+ samples: summarizeRecordList(authorAttribution.samples, limit),
751
+ },
752
+ }
753
+ : {}),
754
+ };
755
+ },
756
+ locks: (details) => ({
757
+ active_lock_count: details.active_lock_count,
758
+ stale_lock_count: details.stale_lock_count,
759
+ unreadable_lock_count: details.unreadable_lock_count,
760
+ unparseable_lock_count: details.unparseable_lock_count,
761
+ }),
762
+ integrity: (details, limit) => ({
763
+ checked_item_files: details.checked_item_files,
764
+ checked_history_streams: details.checked_history_streams,
765
+ counts: details.counts,
766
+ item_unreadable: summarizeStringList(details.item_unreadable, limit),
767
+ item_conflict_markers: summarizeRecordList(details.item_conflict_markers, limit),
768
+ item_parse_failures: summarizeStringList(details.item_parse_failures, limit),
769
+ history_unreadable: summarizeStringList(details.history_unreadable, limit),
770
+ history_conflict_markers: summarizeRecordList(details.history_conflict_markers, limit),
771
+ history_invalid_json: summarizeRecordList(details.history_invalid_json, limit),
772
+ skipped: details.skipped,
773
+ }),
774
+ history_drift: (details, limit) => ({
775
+ checked_items: details.checked_items,
776
+ counts: details.counts,
777
+ drifted_items: summarizeStringList(details.drifted_items, limit),
778
+ missing_streams: summarizeStringList(details.missing_streams, limit),
779
+ unreadable_streams: summarizeStringList(details.unreadable_streams, limit),
780
+ hash_mismatches: summarizeStringList(details.hash_mismatches, limit),
781
+ chain_mismatches: summarizeStringList(details.chain_mismatches, limit),
782
+ skipped: details.skipped,
783
+ }),
784
+ vectorization: (details, limit) => ({
785
+ semantic_runtime_available: details.semantic_runtime_available,
786
+ compatibility_mode_auto_defaults: details.compatibility_mode_auto_defaults,
787
+ auto_ollama_defaults_applied: details.auto_ollama_defaults_applied,
788
+ auto_ollama_defaults_skipped_reason: details.auto_ollama_defaults_skipped_reason,
789
+ auto_ollama_defaults_remediation: details.auto_ollama_defaults_remediation,
790
+ refresh_policy: details.refresh_policy,
791
+ provider_active: details.provider_active,
792
+ vector_store_active: details.vector_store_active,
793
+ items: details.items,
794
+ ledger_entries_before: details.ledger_entries_before,
795
+ stale_items_before_total: details.stale_items_before_total,
796
+ stale_items_before: summarizeStringList(details.stale_items_before, limit),
797
+ refresh_attempted: details.refresh_attempted,
798
+ refresh_skipped_reason: details.refresh_skipped_reason,
799
+ refresh_result: details.refresh_result,
800
+ ledger_entries_after: details.ledger_entries_after,
801
+ stale_items_after_total: details.stale_items_after_total,
802
+ stale_items_after: summarizeStringList(details.stale_items_after, limit),
803
+ skipped: details.skipped,
804
+ }),
805
+ };
806
+ /* c8 ignore start -- brief/summary projection matrix branches are validated in projection integration tests */
807
+ function summarizeHealthCheckDetails(check, limit) {
808
+ const summarize = HEALTH_DETAIL_SUMMARIZERS[check.name];
809
+ return summarize ? summarize(check.details, limit) : check.details;
810
+ }
811
+ /* c8 ignore stop */
812
+ function applyBriefHealthProjection(result) {
813
+ const warningsSummary = summarizeStringList(result.warnings, BRIEF_HEALTH_DETAIL_LIMIT);
814
+ return {
815
+ ok: result.ok,
816
+ checks: result.checks.map((check) => ({
817
+ name: check.name,
818
+ status: check.status,
819
+ details: summarizeHealthCheckDetails(check, BRIEF_HEALTH_DETAIL_LIMIT),
820
+ })),
821
+ warnings: warningsSummary.sample,
822
+ projection: {
823
+ mode: "brief",
824
+ warning_count: warningsSummary.count,
825
+ warnings_truncated: warningsSummary.truncated,
826
+ detail_limit: BRIEF_HEALTH_DETAIL_LIMIT,
827
+ },
828
+ generated_at: result.generated_at,
829
+ };
830
+ }
831
+ function isSkippedHealthCheck(check) {
832
+ return check.details.skipped === true;
833
+ }
834
+ function applySummaryHealthProjection(result) {
835
+ const warningsSummary = summarizeStringList(result.warnings, BRIEF_HEALTH_DETAIL_LIMIT);
836
+ const omittedChecks = result.checks
837
+ .filter(isSkippedHealthCheck)
838
+ .map((check) => check.name);
839
+ return {
840
+ ok: result.ok,
841
+ checks: result.checks
842
+ .filter((check) => !isSkippedHealthCheck(check))
843
+ .map((check) => ({
844
+ name: check.name,
845
+ status: check.status,
846
+ details: {},
847
+ })),
848
+ warning_count: warningsSummary.count,
849
+ warnings: warningsSummary.sample,
850
+ projection: {
851
+ mode: "summary",
852
+ warning_count: warningsSummary.count,
853
+ warnings_truncated: warningsSummary.truncated,
854
+ detail_limit: BRIEF_HEALTH_DETAIL_LIMIT,
855
+ omitted_checks: omittedChecks,
856
+ },
857
+ generated_at: result.generated_at,
858
+ };
859
+ }
860
+ function selectStaleItemDetail(values, verboseStaleItems) {
861
+ if (verboseStaleItems) {
862
+ return {
863
+ values,
864
+ truncated: false,
865
+ total: values.length,
866
+ };
867
+ }
868
+ const summary = summarizeList(values, STALE_VECTORIZATION_SUMMARY_LIMIT);
869
+ return {
870
+ values: summary.values,
871
+ truncated: summary.truncated,
872
+ total: values.length,
873
+ };
874
+ }
875
+ function telemetryEnvFlagEnabled(envKey) {
876
+ const value = (process.env[envKey] ?? "").trim().toLowerCase();
877
+ return value === "1" || value === "true" || value === "yes" || value === "on";
878
+ }
879
+ /* c8 ignore start -- environment override permutations are covered by runtime integration tests */
880
+ function telemetrySourceContextOverride() {
881
+ // Only report an override the runtime actually honours: runtime.ts ignores any
882
+ // value outside the enum and falls back to the inferred context, so health must
883
+ // report null for an unrecognized value rather than implying it took effect.
884
+ const value = (process.env.PM_TELEMETRY_SOURCE_CONTEXT ?? "")
885
+ .trim()
886
+ .toLowerCase();
887
+ return PM_TELEMETRY_SOURCE_CONTEXT_SET.has(value) ? value : null;
888
+ }
889
+ /* c8 ignore stop */
890
+ function normalizeEndpointForDisplay(rawEndpoint) {
891
+ const trimmed = rawEndpoint.trim();
892
+ if (trimmed.length === 0) {
893
+ return "";
894
+ }
895
+ try {
896
+ const parsed = new URL(trimmed);
897
+ parsed.username = "";
898
+ parsed.password = "";
899
+ parsed.search = "";
900
+ parsed.hash = "";
901
+ return parsed.toString();
902
+ }
903
+ catch {
904
+ return trimmed;
905
+ }
906
+ }
907
+ function parseTelemetryQueue(raw) {
908
+ let validEntries = 0;
909
+ let invalidRows = 0;
910
+ let totalRows = 0;
911
+ let highRetryEntries = 0;
912
+ let maxAttempts = 0;
913
+ for (const line of raw.split("\n")) {
914
+ const trimmed = line.trim();
915
+ if (trimmed.length === 0) {
916
+ continue;
917
+ }
918
+ totalRows += 1;
919
+ try {
920
+ const parsed = JSON.parse(trimmed);
921
+ if (typeof parsed === "object" &&
922
+ parsed !== null &&
923
+ typeof parsed.attempts === "number" &&
924
+ Number.isFinite(parsed.attempts)) {
925
+ const attempts = Math.max(0, Math.trunc(parsed.attempts));
926
+ validEntries += 1;
927
+ maxAttempts = Math.max(maxAttempts, attempts);
928
+ if (attempts >= TELEMETRY_QUEUE_HIGH_RETRY_THRESHOLD) {
929
+ highRetryEntries += 1;
930
+ }
931
+ }
932
+ else {
933
+ /* c8 ignore next -- invalid queue rows are covered by end-to-end telemetry fixtures */
934
+ invalidRows += 1;
935
+ }
936
+ }
937
+ catch {
938
+ invalidRows += 1;
939
+ }
940
+ }
941
+ return {
942
+ validEntries,
943
+ invalidRows,
944
+ totalRows,
945
+ highRetryEntries,
946
+ maxAttempts,
947
+ };
948
+ }
949
+ function emptyTelemetryQueueSummary() {
950
+ return {
951
+ validEntries: 0,
952
+ invalidRows: 0,
953
+ totalRows: 0,
954
+ highRetryEntries: 0,
955
+ maxAttempts: 0,
956
+ };
957
+ }
958
+ /* c8 ignore start -- telemetry state corruption and otel-failure branches require runtime-coordinated fixture mutation */
959
+ function parseTelemetryRuntimeState(stateRaw) {
960
+ if (!stateRaw || stateRaw.trim().length === 0) {
961
+ return { runtimeState: {}, stateParseFailed: false };
962
+ }
963
+ try {
964
+ const parsed = JSON.parse(stateRaw);
965
+ if (typeof parsed === "object" &&
966
+ parsed !== null &&
967
+ !Array.isArray(parsed)) {
968
+ return { runtimeState: parsed, stateParseFailed: false };
969
+ }
970
+ return { runtimeState: {}, stateParseFailed: true };
971
+ }
972
+ catch {
973
+ return { runtimeState: {}, stateParseFailed: true };
974
+ }
975
+ }
976
+ async function maybeProbeTelemetryEndpoint(settings, checkTelemetry) {
977
+ const endpoint = settings.telemetry.endpoint.trim();
978
+ if (!checkTelemetry || !settings.telemetry.enabled || endpoint.length === 0) {
979
+ return undefined;
980
+ }
981
+ const probe = await probeTelemetryEndpointHealth(endpoint);
982
+ return {
983
+ attempted: true,
984
+ ...probe,
985
+ };
986
+ }
987
+ function collectTelemetryQueueWarnings(settings, queueSummary, runtimeState) {
988
+ const warnings = [];
989
+ if (queueSummary.invalidRows > 0) {
990
+ warnings.push(`telemetry_queue_invalid_rows:${queueSummary.invalidRows}`);
991
+ }
992
+ if (!settings.telemetry.enabled || queueSummary.validEntries === 0) {
993
+ return warnings;
994
+ }
995
+ const lastSuccess = runtimeState.last_successful_flush_at;
996
+ const lastFailure = runtimeState.last_failed_flush_at;
997
+ const activeFailure = lastFailure && (!lastSuccess || lastFailure > lastSuccess);
998
+ const neverFlushed = !lastSuccess;
999
+ const highWater = queueSummary.validEntries >= TELEMETRY_QUEUE_HIGH_WATER_MARK;
1000
+ if (activeFailure || neverFlushed || highWater) {
1001
+ warnings.push(`telemetry_queue_pending:${queueSummary.validEntries}`);
1002
+ }
1003
+ if (queueSummary.highRetryEntries > 0) {
1004
+ warnings.push(`telemetry_queue_high_retries:${queueSummary.highRetryEntries}`);
1005
+ }
1006
+ return warnings;
1007
+ }
1008
+ function collectTelemetryEndpointWarnings(endpointProbe) {
1009
+ if (!endpointProbe || endpointProbe.ok !== false) {
1010
+ return [];
1011
+ }
1012
+ return typeof endpointProbe.status === "number"
1013
+ ? [`telemetry_endpoint_probe_http_status:${endpointProbe.status}`]
1014
+ : ["telemetry_endpoint_probe_failed"];
1015
+ }
1016
+ function collectTelemetrySchemaWarnings(endpointProbe) {
1017
+ const parsedMaxSchemaVersion = Number.parseInt(endpointProbe?.max_schema_version ?? "", 10);
1018
+ if (endpointProbe?.ok === true &&
1019
+ Number.isInteger(parsedMaxSchemaVersion) &&
1020
+ parsedMaxSchemaVersion > TELEMETRY_SCHEMA_VERSION) {
1021
+ return [`telemetry_schema_version_behind:${parsedMaxSchemaVersion}`];
1022
+ }
1023
+ return [];
1024
+ }
1025
+ function collectTelemetryOtelWarnings(settings, runtimeState) {
1026
+ const pendingOtelSpans = typeof runtimeState.pending_otel_spans === "number"
1027
+ ? runtimeState.pending_otel_spans
1028
+ : 0;
1029
+ const lastOtelSuccess = runtimeState.last_otel_success_at;
1030
+ const lastOtelFailure = runtimeState.last_otel_failure_at;
1031
+ const otelExportFailing = settings.telemetry.enabled &&
1032
+ pendingOtelSpans > 0 &&
1033
+ Boolean(lastOtelFailure) &&
1034
+ // >= so a mixed-outcome batch (success + failure share the same attempt
1035
+ // timestamp) still surfaces the warning rather than being masked by the tie.
1036
+ (!lastOtelSuccess || lastOtelFailure >= lastOtelSuccess);
1037
+ return otelExportFailing
1038
+ ? [`telemetry_otel_export_failing:${pendingOtelSpans}`]
1039
+ : [];
1040
+ }
1041
+ function buildTelemetryEnvOverrideDetails() {
1042
+ return {
1043
+ telemetry_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_DISABLED") ||
1044
+ telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
1045
+ pm_no_telemetry: telemetryEnvFlagEnabled("PM_NO_TELEMETRY"),
1046
+ telemetry_otel_disabled: telemetryEnvFlagEnabled("PM_TELEMETRY_OTEL_DISABLED"),
1047
+ telemetry_inline_flush: telemetryEnvFlagEnabled("PM_TELEMETRY_INLINE_FLUSH"),
1048
+ telemetry_source_context: telemetrySourceContextOverride(),
1049
+ };
1050
+ }
1051
+ /* c8 ignore stop */
1052
+ function telemetryQueueHasEntries(settings, queueSummary) {
1053
+ return settings.telemetry.enabled && queueSummary.validEntries > 0;
1054
+ }
1055
+ function isTelemetryQueueDraining(queueHasEntries, warnings) {
1056
+ return (queueHasEntries &&
1057
+ warnings.every((warning) => !warning.startsWith("telemetry_queue_pending:") &&
1058
+ !warning.startsWith("telemetry_queue_high_retries:")));
1059
+ }
1060
+ async function probeTelemetryEndpointHealth(endpoint) {
1061
+ let probeUrl = endpoint;
1062
+ try {
1063
+ const parsed = new URL(endpoint);
1064
+ parsed.pathname = "/healthz";
1065
+ parsed.search = "";
1066
+ parsed.hash = "";
1067
+ probeUrl = parsed.toString();
1068
+ }
1069
+ catch {
1070
+ // keep original endpoint when URL parsing fails
1071
+ }
1072
+ try {
1073
+ const response = await fetch(probeUrl, {
1074
+ method: "GET",
1075
+ signal: AbortSignal.timeout(TELEMETRY_ENDPOINT_PROBE_TIMEOUT_MS),
1076
+ });
1077
+ return {
1078
+ probe_url: normalizeEndpointForDisplay(probeUrl),
1079
+ ok: response.ok,
1080
+ status: response.status,
1081
+ max_schema_version: (() => {
1082
+ for (const headerName of TELEMETRY_SERVER_MAX_SCHEMA_VERSION_HEADERS) {
1083
+ const value = response.headers.get(headerName)?.trim();
1084
+ if (value && value.length > 0) {
1085
+ return value;
1086
+ }
1087
+ }
1088
+ return undefined;
1089
+ })(),
1090
+ };
1091
+ }
1092
+ catch (error) {
1093
+ return {
1094
+ probe_url: normalizeEndpointForDisplay(probeUrl),
1095
+ ok: false,
1096
+ /* c8 ignore next -- non-Error throwables require transport-layer fault injection */
1097
+ error: error instanceof Error ? error.message : "probe_failed",
1098
+ };
1099
+ }
1100
+ }
1101
+ async function buildTelemetryCheck(settings, options) {
1102
+ const globalPmRoot = resolveGlobalPmRoot(process.cwd());
1103
+ const queuePath = path.join(globalPmRoot, TELEMETRY_QUEUE_RELATIVE_PATH);
1104
+ const statePath = path.join(globalPmRoot, TELEMETRY_STATE_RELATIVE_PATH);
1105
+ const queueRaw = await readFileIfExists(queuePath);
1106
+ const queueExists = queueRaw !== null;
1107
+ const queueSizeBytes = queueRaw ? Buffer.byteLength(queueRaw, "utf8") : 0;
1108
+ const queueSummary = queueRaw
1109
+ ? parseTelemetryQueue(queueRaw)
1110
+ : emptyTelemetryQueueSummary();
1111
+ const stateRaw = await readFileIfExists(statePath);
1112
+ const { runtimeState, stateParseFailed } = parseTelemetryRuntimeState(stateRaw);
1113
+ const endpoint = settings.telemetry.endpoint.trim();
1114
+ const endpointDisplay = normalizeEndpointForDisplay(endpoint);
1115
+ const endpointProbe = await maybeProbeTelemetryEndpoint(settings, options.checkTelemetry);
1116
+ const warnings = [];
1117
+ if (stateParseFailed) {
1118
+ warnings.push("telemetry_state_invalid_json");
1119
+ }
1120
+ warnings.push(...collectTelemetryQueueWarnings(settings, queueSummary, runtimeState), ...collectTelemetryEndpointWarnings(endpointProbe), ...collectTelemetrySchemaWarnings(endpointProbe), ...collectTelemetryOtelWarnings(settings, runtimeState));
1121
+ const queueHasEntries = telemetryQueueHasEntries(settings, queueSummary);
1122
+ const pendingOtelSpans = typeof runtimeState.pending_otel_spans === "number"
1123
+ ? runtimeState.pending_otel_spans
1124
+ : 0;
1125
+ return {
1126
+ check: {
1127
+ name: "telemetry",
1128
+ status: warnings.length === 0 ? "ok" : "warn",
1129
+ details: {
1130
+ enabled: settings.telemetry.enabled,
1131
+ capture_level: settings.telemetry.capture_level,
1132
+ endpoint: endpointDisplay,
1133
+ global_pm_root: globalPmRoot,
1134
+ queue_path: queuePath,
1135
+ queue_exists: queueExists,
1136
+ queue_entries: queueSummary.validEntries,
1137
+ queue_draining: isTelemetryQueueDraining(queueHasEntries, warnings),
1138
+ queue_invalid_rows: queueSummary.invalidRows,
1139
+ queue_rows_total: queueSummary.totalRows,
1140
+ queue_size_bytes: queueSizeBytes,
1141
+ queue_high_retry_entries: queueSummary.highRetryEntries,
1142
+ queue_high_retry_threshold: TELEMETRY_QUEUE_HIGH_RETRY_THRESHOLD,
1143
+ queue_max_attempts: queueSummary.maxAttempts,
1144
+ runtime_state_path: statePath,
1145
+ last_attempted_flush_at: runtimeState.last_attempted_flush_at ?? null,
1146
+ last_successful_flush_at: runtimeState.last_successful_flush_at ?? null,
1147
+ last_failed_flush_at: runtimeState.last_failed_flush_at ?? null,
1148
+ last_failed_flush_error: runtimeState.last_failed_flush_error ?? null,
1149
+ pending_otel_spans: pendingOtelSpans,
1150
+ last_otel_attempt_at: runtimeState.last_otel_attempt_at ?? null,
1151
+ last_otel_success_at: runtimeState.last_otel_success_at ?? null,
1152
+ last_otel_failure_at: runtimeState.last_otel_failure_at ?? null,
1153
+ last_otel_failure_error: runtimeState.last_otel_failure_error ?? null,
1154
+ endpoint_probe: endpointProbe ?? { attempted: false },
1155
+ env_overrides: buildTelemetryEnvOverrideDetails(),
1156
+ },
1157
+ },
1158
+ warnings,
1159
+ };
1160
+ }
1161
+ /** Read-only locks check (pm-xo1n): surfaces active/stale/unreadable/unparseable lock counts using the exact classification `pm gc --scope locks` acts on, so agents can gate on stale item-claim locks before running gc speculatively. */
1162
+ async function buildLocksCheck(pmRoot) {
1163
+ /* c8 ignore start -- scan failure branches require filesystem-level fault injection */
1164
+ let scan;
1165
+ try {
1166
+ scan = await scanLockHealth(pmRoot);
1167
+ }
1168
+ catch (error) {
1169
+ const message = error instanceof Error ? error.message : String(error);
1170
+ return {
1171
+ check: {
1172
+ name: "locks",
1173
+ status: "warn",
1174
+ details: {
1175
+ active_lock_count: 0,
1176
+ stale_lock_count: 0,
1177
+ unreadable_lock_count: 0,
1178
+ unparseable_lock_count: 0,
1179
+ scan_failed: true,
1180
+ error: message,
1181
+ pm_root: pmRoot,
1182
+ },
1183
+ },
1184
+ warnings: [`locks_scan_failed:${message}`],
1185
+ };
1186
+ }
1187
+ const warnings = [];
1188
+ if (scan.stale_lock_count > 0) {
1189
+ warnings.push(`locks_stale_count:${scan.stale_lock_count}`);
1190
+ }
1191
+ if (scan.unreadable_lock_count > 0) {
1192
+ warnings.push(`locks_unreadable:${scan.unreadable_lock_count}`);
1193
+ }
1194
+ /* c8 ignore stop */
1195
+ return {
1196
+ check: {
1197
+ name: "locks",
1198
+ status: warnings.length === 0 ? "ok" : "warn",
1199
+ details: {
1200
+ active_lock_count: scan.active_lock_count,
1201
+ stale_lock_count: scan.stale_lock_count,
1202
+ unreadable_lock_count: scan.unreadable_lock_count,
1203
+ unparseable_lock_count: scan.unparseable_lock_count,
1204
+ },
1205
+ },
1206
+ warnings,
1207
+ };
1208
+ }
1209
+ async function buildHistoryDriftCheck(pmRoot, items) {
1210
+ const cacheHitVerification = "metadata";
1211
+ const { missingStreams, unreadableStreams, hashMismatches, chainMismatches, driftedItems, } = await scanHistoryDrift(pmRoot, items, { cacheHitVerification });
1212
+ const warnings = [
1213
+ ...missingStreams.map((id) => `history_drift_missing_stream:${id}`),
1214
+ ...unreadableStreams.map((id) => `history_drift_unreadable_stream:${id}`),
1215
+ ...hashMismatches.map((id) => `history_drift_hash_mismatch:${id}`),
1216
+ ...chainMismatches.map((id) => `history_drift_chain_mismatch:${id}`),
1217
+ ];
1218
+ return {
1219
+ check: {
1220
+ name: "history_drift",
1221
+ status: warnings.length === 0 ? "ok" : "warn",
1222
+ details: {
1223
+ checked_items: items.length,
1224
+ cache_hit_verification: cacheHitVerification,
1225
+ drifted_items: driftedItems,
1226
+ counts: {
1227
+ drifted: driftedItems.length,
1228
+ missing_streams: missingStreams.length,
1229
+ unreadable_streams: unreadableStreams.length,
1230
+ hash_mismatches: hashMismatches.length,
1231
+ chain_mismatches: chainMismatches.length,
1232
+ },
1233
+ missing_streams: missingStreams,
1234
+ unreadable_streams: unreadableStreams,
1235
+ hash_mismatches: hashMismatches,
1236
+ chain_mismatches: chainMismatches,
1237
+ },
1238
+ },
1239
+ warnings,
1240
+ };
1241
+ }
1242
+ function buildVectorizationRuntimeSnapshot(settings, pmRoot) {
1243
+ const runtimeDefaults = resolveSettingsWithSemanticRuntimeDefaults(settings);
1244
+ const providerResolution = resolveEmbeddingProviders(runtimeDefaults.settings);
1245
+ const vectorStoreResolution = resolveVectorStores(runtimeDefaults.settings, pmRoot);
1246
+ const runtimeEmbeddingIdentity = providerResolution.active
1247
+ ? buildVectorizationEmbeddingIdentity(providerResolution.active.name, providerResolution.active.model)
1248
+ : null;
1249
+ return {
1250
+ runtimeDefaults,
1251
+ providerResolution,
1252
+ vectorStoreResolution,
1253
+ runtimeEmbeddingIdentity,
1254
+ semanticRuntimeAvailable: Boolean(providerResolution.active && vectorStoreResolution.active),
1255
+ };
1256
+ }
1257
+ function emptyVectorizationRefreshResult() {
1258
+ return {
1259
+ refreshed: [],
1260
+ skipped: [],
1261
+ warnings: [],
1262
+ };
1263
+ }
1264
+ async function refreshStaleVectorizationItems(params) {
1265
+ if (!params.refreshPolicy.enabled ||
1266
+ !params.snapshot.semanticRuntimeAvailable ||
1267
+ params.staleBefore.length === 0) {
1268
+ return emptyVectorizationRefreshResult();
1269
+ }
1270
+ return refreshSemanticEmbeddingsForMutatedItems(params.pmRoot, params.staleBefore, {
1271
+ settings: params.snapshot.runtimeDefaults.settings,
1272
+ apply_runtime_defaults: false,
1273
+ });
1274
+ }
1275
+ function vectorizationEmbeddingIdentityChanged(params) {
1276
+ return (params.strictVectorizationWarnings &&
1277
+ params.semanticRuntimeAvailable &&
1278
+ Boolean(params.ledgerBefore.embedding &&
1279
+ params.runtimeEmbeddingIdentity &&
1280
+ hasVectorizationEmbeddingIdentityChanged(params.ledgerBefore.embedding, params.runtimeEmbeddingIdentity)));
1281
+ }
1282
+ /* c8 ignore start -- strict-vectorization warning synthesis branches are integration-only policy permutations */
1283
+ function collectVectorizationWarnings(params) {
1284
+ const warningSet = new Set([
1285
+ ...params.ledgerBefore.warnings,
1286
+ ...params.ledgerAfter.warnings,
1287
+ ]);
1288
+ if (params.strictVectorizationWarnings) {
1289
+ for (const warning of params.refreshResult.warnings) {
1290
+ warningSet.add(warning);
1291
+ }
1292
+ }
1293
+ if (params.embeddingIdentityChanged) {
1294
+ warningSet.add("vectorization_embedding_identity_changed");
1295
+ }
1296
+ if (params.strictVectorizationWarnings &&
1297
+ params.semanticRuntimeAvailable &&
1298
+ params.staleAfter.length > 0) {
1299
+ warningSet.add(`vectorization_stale_items_remaining:${params.staleAfter.length}`);
1300
+ }
1301
+ return [...warningSet].sort((left, right) => left.localeCompare(right));
1302
+ }
1303
+ /* c8 ignore stop */
1304
+ function resolveVectorizationRefreshSkippedReason(refreshPolicy, semanticRuntimeAvailable, staleBefore) {
1305
+ if (refreshPolicy.enabled &&
1306
+ semanticRuntimeAvailable &&
1307
+ staleBefore.length > 0) {
1308
+ return null;
1309
+ }
1310
+ if (!refreshPolicy.enabled) {
1311
+ return "refresh_disabled";
1312
+ }
1313
+ return semanticRuntimeAvailable
1314
+ ? "no_stale_items"
1315
+ : "semantic_runtime_unavailable";
1316
+ }
1317
+ function buildVectorizationProviderDetails(settings, snapshot) {
1318
+ const activeProvider = snapshot.providerResolution.active?.name ?? null;
1319
+ const activeVectorStore = snapshot.vectorStoreResolution.active?.name ?? null;
1320
+ return {
1321
+ provider_active: activeProvider,
1322
+ // GH-244: surface the persisted (possibly empty) configured value and
1323
+ // how the active resolution was sourced, so a config audit can tell
1324
+ // "auto-detected" apart from a genuine misconfiguration when
1325
+ // settings.search.provider / vector_store.adapter are empty strings.
1326
+ provider_configured: typeof settings.search?.provider === "string"
1327
+ ? settings.search.provider
1328
+ : null,
1329
+ provider_source: resolveProviderConfigSource(activeProvider, settings.search?.provider ?? null),
1330
+ vector_store_active: activeVectorStore,
1331
+ vector_store_configured: typeof settings.vector_store?.adapter === "string"
1332
+ ? settings.vector_store.adapter
1333
+ : null,
1334
+ vector_store_source: resolveProviderConfigSource(activeVectorStore, settings.vector_store?.adapter ?? null),
1335
+ };
1336
+ }
1337
+ function buildVectorizationRefreshPolicyDetails(refreshPolicy) {
1338
+ return {
1339
+ enabled: refreshPolicy.enabled,
1340
+ check_only: refreshPolicy.checkOnly,
1341
+ no_refresh: refreshPolicy.noRefresh,
1342
+ refresh_vectors: refreshPolicy.refreshVectors,
1343
+ };
1344
+ }
1345
+ function vectorizationRefreshAttempted(refreshPolicy, semanticRuntimeAvailable, staleBefore) {
1346
+ return (refreshPolicy.enabled && staleBefore.length > 0 && semanticRuntimeAvailable);
1347
+ }
1348
+ async function buildVectorizationCheck(pmRoot, settings, items, refreshPolicy, verboseStaleItems) {
1349
+ const snapshot = buildVectorizationRuntimeSnapshot(settings, pmRoot);
1350
+ const ledgerBefore = await readVectorizationStatusLedger(pmRoot);
1351
+ const staleBefore = snapshot.semanticRuntimeAvailable
1352
+ ? collectStaleVectorizationIds(items, ledgerBefore.entries)
1353
+ : [];
1354
+ const refreshResult = await refreshStaleVectorizationItems({
1355
+ pmRoot,
1356
+ snapshot,
1357
+ refreshPolicy,
1358
+ staleBefore,
1359
+ });
1360
+ const ledgerAfter = await readVectorizationStatusLedger(pmRoot);
1361
+ const staleAfter = snapshot.semanticRuntimeAvailable
1362
+ ? collectStaleVectorizationIds(items, ledgerAfter.entries)
1363
+ : [];
1364
+ const strictVectorizationWarnings = !snapshot.runtimeDefaults.auto_ollama_defaults_applied;
1365
+ const embeddingIdentityChanged = vectorizationEmbeddingIdentityChanged({
1366
+ strictVectorizationWarnings,
1367
+ semanticRuntimeAvailable: snapshot.semanticRuntimeAvailable,
1368
+ ledgerBefore,
1369
+ runtimeEmbeddingIdentity: snapshot.runtimeEmbeddingIdentity,
1370
+ });
1371
+ const warnings = collectVectorizationWarnings({
1372
+ ledgerBefore,
1373
+ ledgerAfter,
1374
+ refreshResult,
1375
+ strictVectorizationWarnings,
1376
+ semanticRuntimeAvailable: snapshot.semanticRuntimeAvailable,
1377
+ embeddingIdentityChanged,
1378
+ staleAfter,
1379
+ });
1380
+ const staleBeforeDetail = selectStaleItemDetail(staleBefore, verboseStaleItems);
1381
+ const staleAfterDetail = selectStaleItemDetail(staleAfter, verboseStaleItems);
1382
+ const refreshAttempted = vectorizationRefreshAttempted(refreshPolicy, snapshot.semanticRuntimeAvailable, staleBefore);
1383
+ return {
1384
+ check: {
1385
+ name: "vectorization",
1386
+ status: warnings.length === 0 ? "ok" : "warn",
1387
+ details: {
1388
+ semantic_runtime_available: snapshot.semanticRuntimeAvailable,
1389
+ compatibility_mode_auto_defaults: snapshot.runtimeDefaults.auto_ollama_defaults_applied,
1390
+ auto_ollama_defaults_applied: snapshot.runtimeDefaults.auto_ollama_defaults_applied,
1391
+ auto_ollama_defaults_skipped_reason: snapshot.runtimeDefaults.auto_ollama_defaults_skipped_reason ?? null,
1392
+ auto_ollama_defaults_remediation: snapshot.runtimeDefaults.auto_ollama_defaults_remediation ?? null,
1393
+ refresh_policy: buildVectorizationRefreshPolicyDetails(refreshPolicy),
1394
+ ...buildVectorizationProviderDetails(settings, snapshot),
1395
+ embedding_identity_changed: embeddingIdentityChanged,
1396
+ embedding_identity_before: ledgerBefore.embedding ?? null,
1397
+ embedding_identity_runtime: snapshot.runtimeEmbeddingIdentity ?? null,
1398
+ items: items.length,
1399
+ ledger_entries_before: Object.keys(ledgerBefore.entries).length,
1400
+ stale_items_detail_mode: verboseStaleItems ? "full" : "summary",
1401
+ stale_items_summary_limit: STALE_VECTORIZATION_SUMMARY_LIMIT,
1402
+ stale_items_before_total: staleBeforeDetail.total,
1403
+ stale_items_before: staleBeforeDetail.values,
1404
+ stale_items_before_truncated: staleBeforeDetail.truncated,
1405
+ refresh_attempted: refreshAttempted,
1406
+ refresh_skipped_reason: resolveVectorizationRefreshSkippedReason(refreshPolicy, snapshot.semanticRuntimeAvailable, staleBefore),
1407
+ refresh_result: refreshResult,
1408
+ ledger_entries_after: Object.keys(ledgerAfter.entries).length,
1409
+ stale_items_after_total: staleAfterDetail.total,
1410
+ stale_items_after: staleAfterDetail.values,
1411
+ stale_items_after_truncated: staleAfterDetail.truncated,
1412
+ },
1413
+ },
1414
+ warnings,
1415
+ };
1416
+ }
1417
+ function validateSettingsValues(settings) {
1418
+ const warnings = [];
1419
+ if (settings.id_prefix.trim().length === 0) {
1420
+ warnings.push("settings:id_prefix_empty");
1421
+ }
1422
+ if (settings.locks.ttl_seconds <= 0) {
1423
+ warnings.push("settings:locks_ttl_non_positive");
1424
+ }
1425
+ return warnings;
1426
+ }
1427
+ function resolveVectorRefreshPolicy(options) {
1428
+ const checkOnly = options.checkOnly === true;
1429
+ const noRefresh = options.noRefresh === true || checkOnly;
1430
+ const refreshVectors = options.refreshVectors === true;
1431
+ if (refreshVectors && checkOnly) {
1432
+ throw new PmCliError("--check-only cannot be combined with --refresh-vectors", EXIT_CODE.USAGE);
1433
+ }
1434
+ if (refreshVectors && options.noRefresh === true) {
1435
+ throw new PmCliError("--no-refresh cannot be combined with --refresh-vectors", EXIT_CODE.USAGE);
1436
+ }
1437
+ return {
1438
+ enabled: refreshVectors || !noRefresh,
1439
+ checkOnly,
1440
+ noRefresh,
1441
+ refreshVectors,
1442
+ };
1443
+ }
1444
+ function resolveHealthDirectoryLists(typeRegistry) {
1445
+ const optionalBuiltinDirs = new Set(PM_OPTIONAL_TYPE_SUBDIRS.filter((entry) => entry.length > 0));
1446
+ const requiredDirSet = new Set(PM_CORE_REQUIRED_SUBDIRS.filter((entry) => entry.length > 0));
1447
+ const optionalDirSet = new Set();
1448
+ for (const folder of typeRegistry.folders) {
1449
+ if (optionalBuiltinDirs.has(folder)) {
1450
+ optionalDirSet.add(folder);
1451
+ continue;
1452
+ }
1453
+ requiredDirSet.add(folder);
1454
+ }
1455
+ return {
1456
+ requiredDirs: [...requiredDirSet].sort((left, right) => left.localeCompare(right)),
1457
+ optionalDirs: [...optionalDirSet].sort((left, right) => left.localeCompare(right)),
1458
+ optionalDirSet,
1459
+ };
1460
+ }
1461
+ async function scanHealthDirectories(pmRoot, typeRegistry, strictDirectories) {
1462
+ const { requiredDirs, optionalDirs, optionalDirSet } = resolveHealthDirectoryLists(typeRegistry);
1463
+ const missingRequiredDirs = [];
1464
+ const missingOptionalDirs = [];
1465
+ const hookWarnings = [];
1466
+ for (const relativeDir of [...requiredDirs, ...optionalDirs]) {
1467
+ const directoryPath = path.join(pmRoot, relativeDir);
1468
+ hookWarnings.push(...(await runActiveOnReadHooks({
1469
+ path: directoryPath,
1470
+ scope: "project",
1471
+ })));
1472
+ if (await isDirectory(directoryPath)) {
1473
+ continue;
1474
+ }
1475
+ if (optionalDirSet.has(relativeDir)) {
1476
+ missingOptionalDirs.push(relativeDir);
1477
+ }
1478
+ else {
1479
+ missingRequiredDirs.push(relativeDir);
1480
+ }
1481
+ }
1482
+ return {
1483
+ requiredDirs,
1484
+ optionalDirs,
1485
+ missingRequiredDirs,
1486
+ missingOptionalDirs,
1487
+ missingDirs: strictDirectories
1488
+ ? [...missingRequiredDirs, ...missingOptionalDirs]
1489
+ : [...missingRequiredDirs],
1490
+ hookWarnings,
1491
+ };
1492
+ }
1493
+ function resolveHealthSkipPolicy(options) {
1494
+ const summaryMode = options.summary === true && options.full !== true;
1495
+ const fastProjectionCheckOnly = options.checkOnly === true &&
1496
+ (options.brief === true || options.summary === true) &&
1497
+ options.full !== true;
1498
+ return {
1499
+ summaryMode,
1500
+ skipIntegrity: (options.skipIntegrity === true || fastProjectionCheckOnly) &&
1501
+ options.full !== true,
1502
+ skipDrift: (options.skipDrift === true || fastProjectionCheckOnly) &&
1503
+ options.full !== true,
1504
+ skipVectors: (options.skipVectors === true || fastProjectionCheckOnly) &&
1505
+ options.full !== true,
1506
+ };
1507
+ }
1508
+ async function readHealthItems(params) {
1509
+ if (params.skipPolicy.skipDrift && params.skipPolicy.skipVectors) {
1510
+ return listAllItemMetadata(params.pmRoot, params.settings.item_format, params.typeRegistry.type_to_folder, params.itemReadWarnings, params.settings.schema);
1511
+ }
1512
+ return listAllItemMetadataWithBody(params.pmRoot, params.settings.item_format, params.typeRegistry.type_to_folder, params.itemReadWarnings, params.settings.schema);
1513
+ }
1514
+ function buildSkippedHealthCheck(name) {
1515
+ return {
1516
+ check: { name, status: "ok", details: { skipped: true } },
1517
+ warnings: [],
1518
+ };
1519
+ }
1520
+ function buildSettingsHealthCheck(settingsPath, settings, normalizedSettingsReadWarnings) {
1521
+ return {
1522
+ name: "settings",
1523
+ /* c8 ignore next -- settings read-warning status split is covered in broader read-settings integration tests */
1524
+ status: normalizedSettingsReadWarnings.length === 0 ? "ok" : "warn",
1525
+ details: {
1526
+ path: settingsPath,
1527
+ version: settings.version,
1528
+ id_prefix: settings.id_prefix,
1529
+ locks_ttl_seconds: settings.locks.ttl_seconds,
1530
+ warnings: normalizedSettingsReadWarnings,
1531
+ },
1532
+ };
1533
+ }
1534
+ function buildDirectoriesHealthCheck(directoryState, strictDirectories) {
1535
+ return {
1536
+ name: "directories",
1537
+ status: directoryState.missingDirs.length === 0 ? "ok" : "warn",
1538
+ details: {
1539
+ required: directoryState.requiredDirs,
1540
+ optional: directoryState.optionalDirs,
1541
+ missing_required: directoryState.missingRequiredDirs,
1542
+ missing_optional: directoryState.missingOptionalDirs,
1543
+ missing: directoryState.missingDirs,
1544
+ strict_directories: strictDirectories,
1545
+ },
1546
+ };
1547
+ }
1548
+ function buildSettingsValuesHealthCheck(settingWarnings) {
1549
+ return {
1550
+ name: "settings_values",
1551
+ status: settingWarnings.length === 0 ? "ok" : "warn",
1552
+ details: { warnings: settingWarnings },
1553
+ };
1554
+ }
1555
+ /** Preserve unknown-author totals for current and legacy scan payloads. */
1556
+ const resolveUnknownAuthorEventCount = (authorAttribution) => authorAttribution.unknown_event_count ?? 0;
1557
+ /** Preserve actionable-author semantics for current and legacy scan payloads. */
1558
+ const resolveActionableUnknownAuthorEventCount = (authorAttribution) => authorAttribution.actionable_unknown_event_count ??
1559
+ resolveUnknownAuthorEventCount(authorAttribution);
1560
+ function buildStorageHealthCheck(items, settings, historySummary, authorAttribution) {
1561
+ const unknownAuthorEventCount = resolveUnknownAuthorEventCount(authorAttribution);
1562
+ const actionableUnknownAuthorEventCount = resolveActionableUnknownAuthorEventCount(authorAttribution);
1563
+ const hasAuthorEvents = unknownAuthorEventCount > 0;
1564
+ const hasActionableAuthorWarnings = actionableUnknownAuthorEventCount > 0;
1565
+ return {
1566
+ name: "storage",
1567
+ status: historySummary.over_threshold.length === 0 && !hasActionableAuthorWarnings
1568
+ ? "ok"
1569
+ : "warn",
1570
+ details: {
1571
+ items: items.length,
1572
+ history_streams: historySummary.count,
1573
+ ...(hasAuthorEvents ? { author_attribution: authorAttribution } : {}),
1574
+ ...(historySummary.max_entries !== null
1575
+ ? {
1576
+ compact_policy: {
1577
+ enabled: settings.history.compact_policy.enabled,
1578
+ max_entries: historySummary.max_entries,
1579
+ trigger: settings.history.compact_policy.trigger,
1580
+ over_threshold_count: historySummary.over_threshold.length,
1581
+ over_threshold: historySummary.over_threshold,
1582
+ },
1583
+ }
1584
+ : {}),
1585
+ },
1586
+ };
1587
+ }
1588
+ function collectHealthWarnings(params) {
1589
+ const warnings = [
1590
+ ...params.directoryState.missingDirs.map((dir) => `missing_directory:${dir}`),
1591
+ ...params.normalizedSettingsReadWarnings,
1592
+ ...params.settingWarnings,
1593
+ ...params.normalizedItemReadWarnings,
1594
+ ...params.telemetryCheck.warnings,
1595
+ ...params.extensionCheck.warnings,
1596
+ ...params.historyPolicyWarnings,
1597
+ ...params.historySummary.warnings,
1598
+ ...params.authorAttributionWarnings,
1599
+ ...params.locksCheck.warnings,
1600
+ ...params.integrityCheck.warnings,
1601
+ ...params.historyDriftCheck.warnings,
1602
+ ...params.vectorizationCheck.warnings,
1603
+ ...params.directoryState.hookWarnings,
1604
+ ];
1605
+ return [...new Set(warnings)];
1606
+ }
1607
+ function extractHistoryDriftedCount(historyDriftCheck) {
1608
+ const counts = historyDriftCheck.check.details.counts;
1609
+ return typeof counts?.drifted === "number" ? counts.drifted : 0;
1610
+ }
1611
+ function buildHealthRemediationSources(params) {
1612
+ return {
1613
+ settings: params.normalizedSettingsReadWarnings,
1614
+ directories: params.directoryState.missingDirs.map((dir) => `missing_directory:${dir}`),
1615
+ settings_values: params.settingWarnings,
1616
+ telemetry: params.telemetryCheck.warnings,
1617
+ extensions: params.extensionCheck.warnings,
1618
+ storage: [
1619
+ ...params.historySummary.over_threshold.map((id) => `history_stream_over_compact_threshold:${id}`),
1620
+ ...params.authorAttributionWarnings,
1621
+ ],
1622
+ locks: params.locksCheck.warnings,
1623
+ integrity: params.integrityCheck.warnings,
1624
+ history_drift: params.historyDriftCheck.warnings,
1625
+ vectorization: params.vectorizationCheck.warnings,
1626
+ };
1627
+ }
1628
+ function rewriteBulkHealthRemediation(params) {
1629
+ if (params.check.name === "history_drift" && params.historyDriftedCount > 1) {
1630
+ for (const code of Object.keys(params.remediationMap)) {
1631
+ params.remediationMap[code] = "pm history-repair --all";
1632
+ }
1633
+ }
1634
+ if (params.check.name === "storage" && params.overThresholdCount > 1) {
1635
+ for (const code of Object.keys(params.remediationMap)) {
1636
+ params.remediationMap[code] = "pm history-compact --all-streams";
1637
+ }
1638
+ }
1639
+ }
1640
+ function attachHealthRemediationMaps(params) {
1641
+ for (const check of params.checks) {
1642
+ const remediationMap = buildRemediationMap(params.remediationSources[check.name]);
1643
+ rewriteBulkHealthRemediation({
1644
+ check,
1645
+ remediationMap,
1646
+ historyDriftedCount: params.historyDriftedCount,
1647
+ overThresholdCount: params.overThresholdCount,
1648
+ });
1649
+ if (Object.keys(remediationMap).length > 0) {
1650
+ check.details = { ...check.details, remediation_map: remediationMap };
1651
+ }
1652
+ }
1653
+ }
1654
+ function projectHealthResult(result, options, summaryMode) {
1655
+ if (summaryMode) {
1656
+ return applySummaryHealthProjection(result);
1657
+ }
1658
+ return options.brief === true ? applyBriefHealthProjection(result) : result;
1659
+ }
1660
+ /** Implements run health for the public runtime surface of this module. */
1661
+ export async function runHealth(global, options = {}) {
1662
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
1663
+ const settingsPath = getSettingsPath(pmRoot);
1664
+ if (!(await pathExists(settingsPath))) {
1665
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
1666
+ }
1667
+ const { settings, warnings: settingsReadWarnings } = await readSettingsWithMetadata(pmRoot);
1668
+ const normalizedSettingsReadWarnings = [...new Set(settingsReadWarnings)];
1669
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
1670
+ const strictDirectories = options.strictDirectories === true;
1671
+ const refreshPolicy = resolveVectorRefreshPolicy(options);
1672
+ const directoryState = await scanHealthDirectories(pmRoot, typeRegistry, strictDirectories);
1673
+ const settingWarnings = validateSettingsValues(settings);
1674
+ const telemetryCheck = await buildTelemetryCheck(settings, {
1675
+ checkTelemetry: options.checkTelemetry === true,
1676
+ });
1677
+ const extensionCheck = await buildExtensionCheck(pmRoot, settings, Boolean(global.noExtensions));
1678
+ const skipPolicy = resolveHealthSkipPolicy(options);
1679
+ const itemReadWarnings = [];
1680
+ const items = await readHealthItems({
1681
+ pmRoot,
1682
+ settings,
1683
+ typeRegistry,
1684
+ skipPolicy,
1685
+ itemReadWarnings,
1686
+ });
1687
+ const itemsWithBody = items;
1688
+ const normalizedItemReadWarnings = [...new Set(itemReadWarnings)];
1689
+ const historyPolicy = skipPolicy.skipDrift
1690
+ ? { warnings: [] }
1691
+ : await enforceHistoryStreamPolicyForItems({
1692
+ pmRoot,
1693
+ settings,
1694
+ itemIds: items.map((item) => item.id),
1695
+ commandLabel: "health",
1696
+ });
1697
+ const historySummary = await countHistoryStreams(pmRoot, settings.history.compact_policy);
1698
+ const authorAttribution = await scanHistoryAuthorAttribution(pmRoot);
1699
+ const actionableUnknownAuthorEventCount = resolveActionableUnknownAuthorEventCount(authorAttribution);
1700
+ const authorAttributionWarnings = actionableUnknownAuthorEventCount > 0
1701
+ ? [`history_unknown_author_events:${actionableUnknownAuthorEventCount}`]
1702
+ : [];
1703
+ const locksCheck = await buildLocksCheck(pmRoot);
1704
+ const integrityCheck = skipPolicy.skipIntegrity
1705
+ ? buildSkippedHealthCheck("integrity")
1706
+ : await buildIntegrityCheck(pmRoot, typeRegistry.type_to_folder, settings.schema);
1707
+ const historyDriftCheck = skipPolicy.skipDrift
1708
+ ? buildSkippedHealthCheck("history_drift")
1709
+ : await buildHistoryDriftCheck(pmRoot, itemsWithBody);
1710
+ const vectorizationCheck = skipPolicy.skipVectors
1711
+ ? buildSkippedHealthCheck("vectorization")
1712
+ : await buildVectorizationCheck(pmRoot, settings, itemsWithBody, refreshPolicy, options.verboseStaleItems === true);
1713
+ const checks = [
1714
+ buildSettingsHealthCheck(settingsPath, settings, normalizedSettingsReadWarnings),
1715
+ buildDirectoriesHealthCheck(directoryState, strictDirectories),
1716
+ buildSettingsValuesHealthCheck(settingWarnings),
1717
+ telemetryCheck.check,
1718
+ extensionCheck.check,
1719
+ buildStorageHealthCheck(items, settings, historySummary, authorAttribution),
1720
+ locksCheck.check,
1721
+ integrityCheck.check,
1722
+ historyDriftCheck.check,
1723
+ vectorizationCheck.check,
1724
+ ];
1725
+ const normalizedWarnings = collectHealthWarnings({
1726
+ directoryState,
1727
+ normalizedSettingsReadWarnings,
1728
+ settingWarnings,
1729
+ normalizedItemReadWarnings,
1730
+ telemetryCheck,
1731
+ extensionCheck,
1732
+ historyPolicyWarnings: historyPolicy.warnings,
1733
+ historySummary,
1734
+ authorAttributionWarnings,
1735
+ locksCheck,
1736
+ integrityCheck,
1737
+ historyDriftCheck,
1738
+ vectorizationCheck,
1739
+ });
1740
+ attachHealthRemediationMaps({
1741
+ checks,
1742
+ remediationSources: buildHealthRemediationSources({
1743
+ directoryState,
1744
+ normalizedSettingsReadWarnings,
1745
+ settingWarnings,
1746
+ telemetryCheck,
1747
+ extensionCheck,
1748
+ historySummary,
1749
+ authorAttributionWarnings,
1750
+ locksCheck,
1751
+ integrityCheck,
1752
+ historyDriftCheck,
1753
+ vectorizationCheck,
1754
+ }),
1755
+ historyDriftedCount: extractHistoryDriftedCount(historyDriftCheck),
1756
+ overThresholdCount: historySummary.over_threshold.length,
1757
+ });
1758
+ // Telemetry is an opt-out, non-critical observability feature. Its operational
1759
+ // state (queue backlog, unreachable endpoint, corrupt local state) is advisory:
1760
+ // it must never flip overall project health to not-ok. Such warnings are still
1761
+ // surfaced in `warnings` and the telemetry check's own `warn` status.
1762
+ const blockingWarnings = normalizedWarnings.filter((warning) => !isAdvisoryHealthWarning(warning));
1763
+ const result = {
1764
+ ok: blockingWarnings.length === 0,
1765
+ checks,
1766
+ warnings: normalizedWarnings,
1767
+ generated_at: nowIso(),
1768
+ };
1769
+ return projectHealthResult(result, options, skipPolicy.summaryMode);
1770
+ }
1771
+ /** Public contract for test only health command, shared by SDK and presentation-layer consumers. */
1772
+ export const _testOnlyHealthCommand = {
1773
+ buildExtensionHealthTriageSummary,
1774
+ buildCapabilityContractMetadata,
1775
+ buildVectorizationProviderDetails,
1776
+ collectUnknownCapabilityGuidance,
1777
+ isAdvisoryHealthWarning,
1778
+ isDirectory,
1779
+ isExpectedUnmanagedExtension,
1780
+ listItemDocumentPaths,
1781
+ normalizeEndpointForDisplay,
1782
+ normalizeExtensionNameForMatch,
1783
+ parseTelemetryQueue,
1784
+ probeTelemetryEndpointHealth,
1785
+ resolveActionableUnknownAuthorEventCount,
1786
+ resolveUnknownAuthorEventCount,
1787
+ selectStaleItemDetail,
1788
+ summarizeHealthCheckDetails,
1789
+ summarizeExtensionList,
1790
+ summarizeRecordList,
1791
+ summarizeStringList,
1792
+ telemetryEnvFlagEnabled,
1793
+ warningCode,
1794
+ };
1795
+ //# sourceMappingURL=health.js.map
1796
+ //# debugId=9e3d1799-829e-5a99-b960-a2b809511ef7