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