@unbrained/pm-cli 2026.7.21 → 2026.7.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (506) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +25 -0
  3. package/dist/cli/bundle-integrity.js +3 -3
  4. package/dist/cli/bundle-integrity.js.map +1 -1
  5. package/dist/cli/commands/contracts.d.ts +5 -0
  6. package/dist/cli/commands/contracts.js +8 -6
  7. package/dist/cli/commands/contracts.js.map +1 -1
  8. package/dist/cli/commands/copy.js +36 -20
  9. package/dist/cli/commands/copy.js.map +1 -1
  10. package/dist/cli/commands/create.js +48 -24
  11. package/dist/cli/commands/create.js.map +1 -1
  12. package/dist/cli/commands/merge.d.ts +1 -1
  13. package/dist/cli/commands/merge.js +3 -3
  14. package/dist/cli/commands/merge.js.map +1 -1
  15. package/dist/cli/commands/restore.js +40 -22
  16. package/dist/cli/commands/restore.js.map +1 -1
  17. package/dist/cli/commands/update.js +12 -9
  18. package/dist/cli/commands/update.js.map +1 -1
  19. package/dist/cli/extension-command-help.js +3 -4
  20. package/dist/cli/extension-command-help.js.map +1 -1
  21. package/dist/cli/main.d.ts +3 -2
  22. package/dist/cli/main.js +6 -6
  23. package/dist/cli/main.js.map +1 -1
  24. package/dist/cli/register-list-query.js +33 -21
  25. package/dist/cli/register-list-query.js.map +1 -1
  26. package/dist/cli/register-mutation.js +63 -37
  27. package/dist/cli/register-mutation.js.map +1 -1
  28. package/dist/cli/registration-helpers.d.ts +2 -0
  29. package/dist/cli/registration-helpers.js +3 -2
  30. package/dist/cli/registration-helpers.js.map +1 -1
  31. package/dist/cli-bundle/bundle-manifest.json +349 -341
  32. package/dist/cli-bundle/chunks/{append-7OVFYR3C.js → append-CYMA7RJT.js} +5 -5
  33. package/dist/cli-bundle/chunks/append-H53CAPMP.js +11 -0
  34. package/dist/cli-bundle/chunks/{chunk-PFNHX655.js → chunk-2P7OK4WG.js} +3 -3
  35. package/dist/cli-bundle/chunks/{chunk-EJDGV4GR.js → chunk-3EBGHNNQ.js} +3 -3
  36. package/dist/cli-bundle/chunks/{chunk-DZRV2OPA.js → chunk-3EDFN3VV.js} +2 -2
  37. package/dist/cli-bundle/chunks/{chunk-ZOY5K4D3.js → chunk-3PWJWLLQ.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-VXOOB6YX.js → chunk-3SJAR3CY.js} +4 -4
  39. package/dist/cli-bundle/chunks/{chunk-GTLCVJOE.js → chunk-3WVKMF2A.js} +3 -3
  40. package/dist/cli-bundle/chunks/{chunk-LAV26CQG.js → chunk-42SYYKA4.js} +4 -4
  41. package/dist/cli-bundle/chunks/{chunk-NLR32VFS.js → chunk-4IXLNV7W.js} +2 -2
  42. package/dist/cli-bundle/chunks/{chunk-BKIAH72N.js → chunk-4LTPHDKA.js} +39 -23
  43. package/dist/cli-bundle/chunks/chunk-4LTPHDKA.js.map +1 -0
  44. package/dist/cli-bundle/chunks/{chunk-ABWCF646.js → chunk-4YTQVO3V.js} +5 -5
  45. package/dist/cli-bundle/chunks/{chunk-E5XMKOSB.js → chunk-5EBRMHI6.js} +4 -4
  46. package/dist/cli-bundle/chunks/{chunk-IY6VZ3IW.js → chunk-5FAG2JUC.js} +320 -62
  47. package/dist/cli-bundle/chunks/chunk-5FAG2JUC.js.map +7 -0
  48. package/dist/cli-bundle/chunks/{chunk-GKX4NJ7U.js → chunk-5K5LHZZX.js} +6 -6
  49. package/dist/cli-bundle/chunks/{chunk-T6PPNM7V.js → chunk-5K7BOAB6.js} +4 -4
  50. package/dist/cli-bundle/chunks/{chunk-4QOB7L7I.js → chunk-5MUZ54G2.js} +5 -5
  51. package/dist/cli-bundle/chunks/{chunk-SF3DT5HJ.js → chunk-5QME4KX2.js} +3 -3
  52. package/dist/cli-bundle/chunks/{chunk-RMF7LMBS.js → chunk-6PDGFY3P.js} +27 -17
  53. package/dist/cli-bundle/chunks/{chunk-RMF7LMBS.js.map → chunk-6PDGFY3P.js.map} +2 -2
  54. package/dist/cli-bundle/chunks/{chunk-TRSHFPRZ.js → chunk-6PM6CPPP.js} +5 -5
  55. package/dist/cli-bundle/chunks/{chunk-O4BCOJTZ.js → chunk-7AHRY3ZB.js} +21 -16
  56. package/dist/cli-bundle/chunks/chunk-7AHRY3ZB.js.map +7 -0
  57. package/dist/cli-bundle/chunks/{chunk-OR42SO64.js → chunk-7B36A3VT.js} +4 -4
  58. package/dist/cli-bundle/chunks/{chunk-QWRVBJ4D.js → chunk-7OR2YKKD.js} +2 -2
  59. package/dist/cli-bundle/chunks/{chunk-FPBMLYPI.js → chunk-7QUV54XX.js} +4 -4
  60. package/dist/cli-bundle/chunks/{chunk-WWNL6WMH.js → chunk-7WXW6JHG.js} +2 -2
  61. package/dist/cli-bundle/chunks/{chunk-BXNDKOR2.js → chunk-A2VL5SVG.js} +4 -4
  62. package/dist/cli-bundle/chunks/chunk-AXGDUXJW.js +5 -0
  63. package/dist/cli-bundle/chunks/{chunk-IAQE32BI.js → chunk-B2AVNGG3.js} +4 -4
  64. package/dist/cli-bundle/chunks/{chunk-K36WV5J6.js → chunk-B7O44UBR.js} +71 -8
  65. package/dist/cli-bundle/chunks/chunk-B7O44UBR.js.map +1 -0
  66. package/dist/cli-bundle/chunks/{chunk-HCEBZNC3.js → chunk-BRMPF2RM.js} +4 -4
  67. package/dist/cli-bundle/chunks/{chunk-Z7VWXXJM.js → chunk-BTNKMF2A.js} +4 -4
  68. package/dist/cli-bundle/chunks/{chunk-KH44WBAT.js → chunk-CD4643VW.js} +4 -4
  69. package/dist/cli-bundle/chunks/{chunk-OWXOPDHD.js → chunk-CJEEC5O4.js} +4 -4
  70. package/dist/cli-bundle/chunks/{chunk-PZC2FUOQ.js → chunk-CTPKCZCF.js} +2 -2
  71. package/dist/cli-bundle/chunks/{chunk-7W2UAXXT.js → chunk-D4OBQVL3.js} +10 -10
  72. package/dist/cli-bundle/chunks/{chunk-EWJWSNRU.js → chunk-DM4TYC2A.js} +4 -4
  73. package/dist/cli-bundle/chunks/{chunk-VJQG4BIM.js → chunk-DSFTAQ7T.js} +3 -3
  74. package/dist/cli-bundle/chunks/{chunk-AELMUANP.js → chunk-DVB6SQU7.js} +2 -2
  75. package/dist/cli-bundle/chunks/{chunk-KBLZ3AA5.js → chunk-E3ZWOFSO.js} +4 -4
  76. package/dist/cli-bundle/chunks/chunk-EP25DV6P.js +9 -0
  77. package/dist/cli-bundle/chunks/{chunk-GTK4DTEW.js → chunk-F4VCB4WY.js} +10 -10
  78. package/dist/cli-bundle/chunks/{chunk-V22ZPOKN.js → chunk-F4XAQUQA.js} +6 -6
  79. package/dist/cli-bundle/chunks/{chunk-QOOTOD3W.js → chunk-FGR6IBAF.js} +6 -6
  80. package/dist/cli-bundle/chunks/{chunk-JSLT7WVE.js → chunk-FKBMT2Q6.js} +2 -2
  81. package/dist/cli-bundle/chunks/{chunk-QIH77CAG.js → chunk-G5RLSSIX.js} +2 -2
  82. package/dist/cli-bundle/chunks/{chunk-P7MTHPJQ.js → chunk-GEKRVH3G.js} +2 -2
  83. package/dist/cli-bundle/chunks/{chunk-2L6ZP22J.js → chunk-GSP6IZFU.js} +3 -3
  84. package/dist/cli-bundle/chunks/{chunk-ATBCUC7Y.js → chunk-H3MDK2VU.js} +48 -30
  85. package/dist/cli-bundle/chunks/chunk-H3MDK2VU.js.map +1 -0
  86. package/dist/cli-bundle/chunks/{chunk-ZVZGXPQ5.js → chunk-HYZZM3Q2.js} +2 -2
  87. package/dist/cli-bundle/chunks/{chunk-XJTABV3X.js → chunk-IBWG3OSH.js} +22 -17
  88. package/dist/cli-bundle/chunks/chunk-IBWG3OSH.js.map +1 -0
  89. package/dist/cli-bundle/chunks/{chunk-4XGJLADW.js → chunk-IHY5SX7O.js} +3 -3
  90. package/dist/cli-bundle/chunks/{chunk-UCBDQI5E.js → chunk-IMU7JLUI.js} +7 -7
  91. package/dist/cli-bundle/chunks/{chunk-Z75ONV25.js → chunk-IPAQAJWB.js} +77 -7
  92. package/dist/cli-bundle/chunks/chunk-IPAQAJWB.js.map +7 -0
  93. package/dist/cli-bundle/chunks/{chunk-7RW4JCU2.js → chunk-IQCD6OO3.js} +25 -13
  94. package/dist/cli-bundle/chunks/chunk-IQCD6OO3.js.map +7 -0
  95. package/dist/cli-bundle/chunks/{chunk-YQWCZ5AC.js → chunk-J3ZKFEDM.js} +38 -22
  96. package/dist/cli-bundle/chunks/chunk-J3ZKFEDM.js.map +7 -0
  97. package/dist/cli-bundle/chunks/{chunk-PEQGTJ5Q.js → chunk-JCLXCGIL.js} +3 -3
  98. package/dist/cli-bundle/chunks/{chunk-GROYI4RB.js → chunk-JLTHOYR7.js} +3 -3
  99. package/dist/cli-bundle/chunks/{chunk-JHJSFOAM.js → chunk-JMPVHM44.js} +4 -4
  100. package/dist/cli-bundle/chunks/{chunk-MATHDCGG.js → chunk-JWYG36RV.js} +8 -8
  101. package/dist/cli-bundle/chunks/{chunk-ZTVA4KLN.js → chunk-KEGVMZNA.js} +28 -16
  102. package/dist/cli-bundle/chunks/chunk-KEGVMZNA.js.map +7 -0
  103. package/dist/cli-bundle/chunks/{chunk-VLRGDBLY.js → chunk-KEHOPUHH.js} +4 -4
  104. package/dist/cli-bundle/chunks/{chunk-K55VMLSS.js → chunk-KJ4ZF35M.js} +63 -13
  105. package/dist/cli-bundle/chunks/chunk-KJ4ZF35M.js.map +7 -0
  106. package/dist/cli-bundle/chunks/{chunk-CPX275C6.js → chunk-KPCZL2YK.js} +6 -6
  107. package/dist/cli-bundle/chunks/{chunk-POG76WWZ.js → chunk-L7DZV6EZ.js} +319 -61
  108. package/dist/cli-bundle/chunks/chunk-L7DZV6EZ.js.map +1 -0
  109. package/dist/cli-bundle/chunks/{chunk-FO6OSVEN.js → chunk-LANV45W2.js} +8 -8
  110. package/dist/cli-bundle/chunks/{chunk-LVC72YRD.js → chunk-LC5ZUXWE.js} +7 -7
  111. package/dist/cli-bundle/chunks/{chunk-SY4SFZSD.js → chunk-LE522OXA.js} +55 -30
  112. package/dist/cli-bundle/chunks/chunk-LE522OXA.js.map +7 -0
  113. package/dist/cli-bundle/chunks/{chunk-TVYYO5A7.js → chunk-MBHYQYCS.js} +2 -2
  114. package/dist/cli-bundle/chunks/{chunk-FJIFFBJX.js → chunk-MROP2RNT.js} +66 -74
  115. package/dist/cli-bundle/chunks/chunk-MROP2RNT.js.map +1 -0
  116. package/dist/cli-bundle/chunks/{chunk-7656MAUL.js → chunk-MUAJHL2R.js} +2 -2
  117. package/dist/cli-bundle/chunks/{chunk-R3P6FZJW.js → chunk-N6QCY2AX.js} +43 -25
  118. package/dist/cli-bundle/chunks/chunk-N6QCY2AX.js.map +1 -0
  119. package/dist/cli-bundle/chunks/{chunk-7WCE6Y64.js → chunk-NUQCSV4P.js} +2 -2
  120. package/dist/cli-bundle/chunks/{chunk-SZVB53Y3.js → chunk-O3GFE2PX.js} +3 -3
  121. package/dist/cli-bundle/chunks/{chunk-OY7DMU5P.js → chunk-O43LEUSD.js} +2 -2
  122. package/dist/cli-bundle/chunks/{chunk-AMJPSANK.js → chunk-O7RH6BWP.js} +103 -44
  123. package/dist/cli-bundle/chunks/chunk-O7RH6BWP.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-NUF7ROFH.js → chunk-OODR5KYF.js} +26 -27
  125. package/dist/cli-bundle/chunks/chunk-OODR5KYF.js.map +1 -0
  126. package/dist/cli-bundle/chunks/{chunk-LZYP423P.js → chunk-OZ25YD4Q.js} +3 -3
  127. package/dist/cli-bundle/chunks/{chunk-VZIZB6QH.js → chunk-PKYKQCTJ.js} +4 -4
  128. package/dist/cli-bundle/chunks/{chunk-UZLJOEAC.js → chunk-PMRED6QZ.js} +3 -3
  129. package/dist/cli-bundle/chunks/{chunk-ADBTSVGK.js → chunk-PPATPPI6.js} +65 -73
  130. package/dist/cli-bundle/chunks/chunk-PPATPPI6.js.map +7 -0
  131. package/dist/cli-bundle/chunks/{chunk-K4CI6Y45.js → chunk-PWGJCP2V.js} +2 -2
  132. package/dist/cli-bundle/chunks/{chunk-UVN66B3M.js → chunk-Q3Z2Y5WJ.js} +2 -2
  133. package/dist/cli-bundle/chunks/{chunk-RNPZYNHS.js → chunk-Q6YZ3VCI.js} +104 -45
  134. package/dist/cli-bundle/chunks/chunk-Q6YZ3VCI.js.map +1 -0
  135. package/dist/cli-bundle/chunks/{chunk-7DOJC3HS.js → chunk-QE5EUHKN.js} +28 -18
  136. package/dist/cli-bundle/chunks/chunk-QE5EUHKN.js.map +1 -0
  137. package/dist/cli-bundle/chunks/{chunk-AS4SAZ5R.js → chunk-QKMMWESK.js} +25 -26
  138. package/dist/cli-bundle/chunks/chunk-QKMMWESK.js.map +7 -0
  139. package/dist/cli-bundle/chunks/{chunk-R7QV7ICM.js → chunk-QSXN2FAN.js} +4 -4
  140. package/dist/cli-bundle/chunks/{chunk-5NTE36LD.js → chunk-RBECHH5K.js} +4 -4
  141. package/dist/cli-bundle/chunks/{chunk-JXCW2TI2.js → chunk-RPNC7M63.js} +8 -8
  142. package/dist/cli-bundle/chunks/{chunk-ICDAQ4TD.js → chunk-S2QQNTA6.js} +26 -14
  143. package/dist/cli-bundle/chunks/chunk-S2QQNTA6.js.map +1 -0
  144. package/dist/cli-bundle/chunks/{chunk-JFD5LPMI.js → chunk-SP3BAXFF.js} +29 -17
  145. package/dist/cli-bundle/chunks/chunk-SP3BAXFF.js.map +1 -0
  146. package/dist/cli-bundle/chunks/{chunk-F2LBF7XJ.js → chunk-SUSFH6F7.js} +5 -5
  147. package/dist/cli-bundle/chunks/{chunk-VHXHVTUU.js → chunk-TDOPC7UY.js} +2 -2
  148. package/dist/cli-bundle/chunks/{chunk-HYW67VJ5.js → chunk-TLF52ZDP.js} +30 -25
  149. package/dist/cli-bundle/chunks/chunk-TLF52ZDP.js.map +1 -0
  150. package/dist/cli-bundle/chunks/{chunk-FSE2IKJQ.js → chunk-TWHG646K.js} +2 -2
  151. package/dist/cli-bundle/chunks/{chunk-OCUBRA6D.js → chunk-U7U7WGEC.js} +4 -4
  152. package/dist/cli-bundle/chunks/{chunk-PONKZPCJ.js → chunk-UFRVIIJ2.js} +4 -4
  153. package/dist/cli-bundle/chunks/{chunk-VNTCM3VW.js → chunk-VKX2VZZH.js} +8 -8
  154. package/dist/cli-bundle/chunks/{chunk-7AVEY74G.js → chunk-VTOCZ343.js} +29 -24
  155. package/dist/cli-bundle/chunks/chunk-VTOCZ343.js.map +7 -0
  156. package/dist/cli-bundle/chunks/{chunk-6JUTHVQS.js → chunk-W2JDNTN3.js} +2 -2
  157. package/dist/cli-bundle/chunks/{chunk-PQSEQD6E.js → chunk-W35PHE44.js} +62 -12
  158. package/dist/cli-bundle/chunks/chunk-W35PHE44.js.map +1 -0
  159. package/dist/cli-bundle/chunks/{chunk-4QSQ6XDK.js → chunk-WT4KXBUD.js} +68 -31
  160. package/dist/cli-bundle/chunks/chunk-WT4KXBUD.js.map +1 -0
  161. package/dist/cli-bundle/chunks/{chunk-RPESLSO5.js → chunk-XC5RVKHH.js} +69 -32
  162. package/dist/cli-bundle/chunks/chunk-XC5RVKHH.js.map +7 -0
  163. package/dist/cli-bundle/chunks/{chunk-QG4GFLQ6.js → chunk-XD6UF2NB.js} +42 -24
  164. package/dist/cli-bundle/chunks/chunk-XD6UF2NB.js.map +7 -0
  165. package/dist/cli-bundle/chunks/{chunk-AF2CCM5U.js → chunk-XKRVX4B3.js} +4 -4
  166. package/dist/cli-bundle/chunks/{chunk-JGUKMMRS.js → chunk-XN4NQZJK.js} +3 -3
  167. package/dist/cli-bundle/chunks/{chunk-3P7UJQOX.js → chunk-YKFMLQNK.js} +2 -2
  168. package/dist/cli-bundle/chunks/{chunk-YCIUJJOD.js → chunk-YKWKMGL7.js} +2 -2
  169. package/dist/cli-bundle/chunks/{chunk-TOBGV45Y.js → chunk-YUKIFPWK.js} +2 -2
  170. package/dist/cli-bundle/chunks/{chunk-72LQ4TKV.js → chunk-YYEZEP3E.js} +3 -3
  171. package/dist/cli-bundle/chunks/{chunk-X3W65QK3.js → chunk-ZEY3XSZQ.js} +5 -5
  172. package/dist/cli-bundle/chunks/{chunk-MWQ2HC2A.js → chunk-ZKOQHLJP.js} +59 -34
  173. package/dist/cli-bundle/chunks/chunk-ZKOQHLJP.js.map +1 -0
  174. package/dist/cli-bundle/chunks/{chunk-QJIKE24M.js → chunk-ZQ3UMKWE.js} +2 -2
  175. package/dist/cli-bundle/chunks/{chunk-4PUUNQDV.js → chunk-ZVVEWHWK.js} +58 -33
  176. package/dist/cli-bundle/chunks/chunk-ZVVEWHWK.js.map +7 -0
  177. package/dist/cli-bundle/chunks/{chunk-OG5DVFMA.js → chunk-ZXE6SNKO.js} +5 -5
  178. package/dist/cli-bundle/chunks/close-GAUIGOQC.js +12 -0
  179. package/dist/cli-bundle/chunks/{close-QEMOYZN3.js → close-SJIEKNY4.js} +5 -5
  180. package/dist/cli-bundle/chunks/{close-many-RZVTUGBG.js → close-many-B6AIC5OQ.js} +15 -14
  181. package/dist/cli-bundle/chunks/close-many-QCINT6I2.js +24 -0
  182. package/dist/cli-bundle/chunks/comments-4SK5EUEJ.js +13 -0
  183. package/dist/cli-bundle/chunks/{comments-TPU7QRBL.js → comments-DM5KV2RS.js} +7 -7
  184. package/dist/cli-bundle/chunks/copy-4KCCLTYQ.js +10 -0
  185. package/dist/cli-bundle/chunks/{copy-DKTSSCK7.js → copy-HEP5SZHB.js} +5 -4
  186. package/dist/cli-bundle/chunks/create-BDKQFPRE.js +30 -0
  187. package/dist/cli-bundle/chunks/{create-EIFBIVNQ.js → create-VCGBCYL2.js} +11 -10
  188. package/dist/cli-bundle/chunks/delete-JWDXPR3H.js +10 -0
  189. package/dist/cli-bundle/chunks/{delete-LCS3VPDH.js → delete-ZSPBTVJD.js} +4 -4
  190. package/dist/cli-bundle/chunks/{deps-YG7UF3VR.js → deps-BZTWWOIE.js} +6 -6
  191. package/dist/cli-bundle/chunks/{deps-UH5EQQUY.js → deps-OVAJOQIE.js} +6 -6
  192. package/dist/cli-bundle/chunks/{docs-G32TK6XS.js → docs-3GFMSWLL.js} +6 -6
  193. package/dist/cli-bundle/chunks/docs-SY2NPT6Y.js +14 -0
  194. package/dist/cli-bundle/chunks/{files-4ALMCSKB.js → files-2SEL4QIU.js} +6 -6
  195. package/dist/cli-bundle/chunks/{files-3H32UQ4K.js → files-FYMMJGNN.js} +6 -6
  196. package/dist/cli-bundle/chunks/focus-4A27YJ2Z.js +10 -0
  197. package/dist/cli-bundle/chunks/{focus-7SOUT5PZ.js → focus-TEUJKTAT.js} +5 -5
  198. package/dist/cli-bundle/chunks/history-compact-7QOKL2NB.js +16 -0
  199. package/dist/cli-bundle/chunks/{history-compact-77BT2LUB.js → history-compact-U7A37VR6.js} +6 -6
  200. package/dist/cli-bundle/chunks/{history-redact-LJPZPNFA.js → history-redact-TNKUO4ZE.js} +4 -4
  201. package/dist/cli-bundle/chunks/{history-redact-PWTTJ3XS.js → history-redact-ZWRUWQY3.js} +4 -4
  202. package/dist/cli-bundle/chunks/{history-repair-I7CBNCV3.js → history-repair-6IU5VWHN.js} +7 -7
  203. package/dist/cli-bundle/chunks/history-repair-GWCGJUM2.js +17 -0
  204. package/dist/cli-bundle/chunks/learnings-DDFAUUX3.js +13 -0
  205. package/dist/cli-bundle/chunks/{learnings-KTYW3AL7.js → learnings-GOEZXMKL.js} +7 -7
  206. package/dist/cli-bundle/chunks/{notes-ZERD3KB2.js → notes-BZWODAEK.js} +7 -7
  207. package/dist/cli-bundle/chunks/notes-OBJ6FL36.js +13 -0
  208. package/dist/cli-bundle/chunks/{plan-OFJUBIM5.js → plan-V57VQTAG.js} +12 -11
  209. package/dist/cli-bundle/chunks/plan-ZMOBD6FX.js +27 -0
  210. package/dist/cli-bundle/chunks/{profile-3THJPIQY.js → profile-BG3N4ETA.js} +9 -9
  211. package/dist/cli-bundle/chunks/{profile-XEZAMMBW.js → profile-XLM45FKV.js} +9 -9
  212. package/dist/cli-bundle/chunks/{register-list-query-BR435Q2H.js → register-list-query-EYYNTGMF.js} +48 -38
  213. package/dist/cli-bundle/chunks/register-list-query-EYYNTGMF.js.map +1 -0
  214. package/dist/cli-bundle/chunks/{register-list-query-RWTWLOBE.js → register-list-query-WGXJPXXY.js} +47 -37
  215. package/dist/cli-bundle/chunks/register-list-query-WGXJPXXY.js.map +7 -0
  216. package/dist/cli-bundle/chunks/{register-mutation-HLWC2WNP.js → register-mutation-3YSDDVOL.js} +131 -105
  217. package/dist/cli-bundle/chunks/register-mutation-3YSDDVOL.js.map +1 -0
  218. package/dist/cli-bundle/chunks/{register-mutation-ZJX5AZM5.js → register-mutation-VDGUMMUY.js} +131 -105
  219. package/dist/cli-bundle/chunks/register-mutation-VDGUMMUY.js.map +7 -0
  220. package/dist/cli-bundle/chunks/{register-operations-744YBJMV.js → register-operations-H4URGAHX.js} +36 -35
  221. package/dist/cli-bundle/chunks/{register-operations-744YBJMV.js.map → register-operations-H4URGAHX.js.map} +1 -1
  222. package/dist/cli-bundle/chunks/{register-operations-UEBJH6AN.js → register-operations-HSO7X77D.js} +34 -33
  223. package/dist/cli-bundle/chunks/{register-operations-UEBJH6AN.js.map → register-operations-HSO7X77D.js.map} +1 -1
  224. package/dist/cli-bundle/chunks/{register-setup-5DA4UZXI.js → register-setup-HZ2KKXK4.js} +13 -13
  225. package/dist/cli-bundle/chunks/{register-setup-6H25M3BH.js → register-setup-WCBKJ3H3.js} +13 -13
  226. package/dist/cli-bundle/chunks/{restore-6TDVSATY.js → restore-3NGRFDPX.js} +7 -6
  227. package/dist/cli-bundle/chunks/restore-LNVNUWHE.js +15 -0
  228. package/dist/cli-bundle/chunks/{schema-TPVTIJPO.js → schema-LMFZ742C.js} +6 -6
  229. package/dist/cli-bundle/chunks/{schema-HFXFSGPG.js → schema-O34O33UW.js} +6 -6
  230. package/dist/cli-bundle/chunks/update-BN6VZSYX.js +24 -0
  231. package/dist/cli-bundle/chunks/{update-LJZCL5SI.js → update-FDLPLKOB.js} +14 -13
  232. package/dist/cli-bundle/chunks/update-many-WCKOPN3K.js +35 -0
  233. package/dist/cli-bundle/chunks/update-many-WCKOPN3K.js.map +7 -0
  234. package/dist/cli-bundle/chunks/update-many-X6DVGOMM.js +39 -0
  235. package/dist/cli-bundle/chunks/update-many-X6DVGOMM.js.map +1 -0
  236. package/dist/cli-bundle/main.js +65 -64
  237. package/dist/cli-bundle/main.js.map +2 -2
  238. package/dist/cli-bundle/sdk-runtime.js +53 -52
  239. package/dist/cli-bundle/sdk-testing.js +6 -6
  240. package/dist/cli-bundle/sdk.js +362 -56
  241. package/dist/cli-bundle/sdk.js.map +4 -4
  242. package/dist/cli.js +10 -4
  243. package/dist/cli.js.map +1 -1
  244. package/dist/core/diagnostics/remediation.js +7 -2
  245. package/dist/core/diagnostics/remediation.js.map +1 -1
  246. package/dist/core/search/background-refresh.d.ts +3 -1
  247. package/dist/core/search/background-refresh.js +34 -6
  248. package/dist/core/search/background-refresh.js.map +1 -1
  249. package/dist/core/search/cache.js +28 -5
  250. package/dist/core/search/cache.js.map +1 -1
  251. package/dist/core/shared/constants.d.ts +2 -0
  252. package/dist/core/shared/constants.js +29 -24
  253. package/dist/core/shared/constants.js.map +1 -1
  254. package/dist/core/store/item-metadata-cache.d.ts +32 -1
  255. package/dist/core/store/item-metadata-cache.js +289 -21
  256. package/dist/core/store/item-metadata-cache.js.map +1 -1
  257. package/dist/core/store/item-store.js +71 -34
  258. package/dist/core/store/item-store.js.map +1 -1
  259. package/dist/core/store/settings.js +9 -3
  260. package/dist/core/store/settings.js.map +1 -1
  261. package/dist/sdk/cli-bootstrap.js +68 -76
  262. package/dist/sdk/cli-bootstrap.js.map +1 -1
  263. package/dist/sdk/compile-cache.d.ts +16 -0
  264. package/dist/sdk/compile-cache.js +73 -0
  265. package/dist/sdk/compile-cache.js.map +1 -0
  266. package/dist/sdk/context-relevance.d.ts +16 -1
  267. package/dist/sdk/context-relevance.js +20 -8
  268. package/dist/sdk/context-relevance.js.map +1 -1
  269. package/dist/sdk/context-signal-store.d.ts +77 -0
  270. package/dist/sdk/context-signal-store.js +201 -0
  271. package/dist/sdk/context-signal-store.js.map +1 -0
  272. package/dist/sdk/dependency-provenance.d.ts +12 -0
  273. package/dist/sdk/dependency-provenance.js +38 -0
  274. package/dist/sdk/dependency-provenance.js.map +1 -0
  275. package/dist/sdk/governance/storage-integrity.d.ts +1 -1
  276. package/dist/sdk/governance/storage-integrity.js +47 -6
  277. package/dist/sdk/governance/storage-integrity.js.map +1 -1
  278. package/dist/sdk/graph/assembly.d.ts +2 -0
  279. package/dist/sdk/graph/assembly.js +51 -4
  280. package/dist/sdk/graph/assembly.js.map +1 -1
  281. package/dist/sdk/graph/run.js +12 -13
  282. package/dist/sdk/graph/run.js.map +1 -1
  283. package/dist/sdk/index.d.ts +5 -0
  284. package/dist/sdk/index.js +7 -2
  285. package/dist/sdk/index.js.map +1 -1
  286. package/dist/sdk/item-metadata-index.d.ts +11 -0
  287. package/dist/sdk/item-metadata-index.js +15 -0
  288. package/dist/sdk/item-metadata-index.js.map +1 -0
  289. package/dist/sdk/merge/index.d.ts +1 -0
  290. package/dist/sdk/merge/index.js +3 -2
  291. package/dist/sdk/merge/index.js.map +1 -1
  292. package/dist/sdk/merge/install.js +25 -9
  293. package/dist/sdk/merge/install.js.map +1 -1
  294. package/dist/sdk/merge/reconcile.d.ts +46 -0
  295. package/dist/sdk/merge/reconcile.js +46 -0
  296. package/dist/sdk/merge/reconcile.js.map +1 -0
  297. package/dist/sdk/query/list.d.ts +5 -4
  298. package/dist/sdk/query/list.js +22 -14
  299. package/dist/sdk/query/list.js.map +1 -1
  300. package/dist/sdk/relationship-history.d.ts +30 -0
  301. package/dist/sdk/relationship-history.js +75 -7
  302. package/dist/sdk/relationship-history.js.map +1 -1
  303. package/dist/sdk/relationship-migration.d.ts +42 -0
  304. package/dist/sdk/relationship-migration.js +78 -0
  305. package/dist/sdk/relationship-migration.js.map +1 -0
  306. package/dist/sdk/structured-mutations.js +4 -25
  307. package/dist/sdk/structured-mutations.js.map +1 -1
  308. package/docs/COMMANDS.md +26 -3
  309. package/docs/CONFIGURATION.md +1 -1
  310. package/docs/MERGE_SAFETY.md +14 -5
  311. package/docs/PERFORMANCE.md +28 -0
  312. package/docs/RELATIONSHIP_GRAPH.md +47 -1
  313. package/docs/SDK.md +78 -5
  314. package/marketplace.json +2 -2
  315. package/package.json +2 -2
  316. package/packages/pm-beads/package.json +1 -1
  317. package/packages/pm-calendar/package.json +1 -1
  318. package/packages/pm-command-kit/package.json +1 -1
  319. package/packages/pm-governance-audit/package.json +1 -1
  320. package/packages/pm-guide-shell/package.json +1 -1
  321. package/packages/pm-kanban/package.json +1 -1
  322. package/packages/pm-lifecycle-hooks/package.json +1 -1
  323. package/packages/pm-linked-test-adapters/package.json +1 -1
  324. package/packages/pm-search-advanced/package.json +1 -1
  325. package/packages/pm-templates/package.json +1 -1
  326. package/packages/pm-todos/package.json +1 -1
  327. package/packages/pm-vcs/package.json +1 -1
  328. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  329. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  330. package/dist/cli-bundle/chunks/append-DFETHAZL.js +0 -11
  331. package/dist/cli-bundle/chunks/chunk-4PUUNQDV.js.map +0 -7
  332. package/dist/cli-bundle/chunks/chunk-4QSQ6XDK.js.map +0 -1
  333. package/dist/cli-bundle/chunks/chunk-7AVEY74G.js.map +0 -7
  334. package/dist/cli-bundle/chunks/chunk-7DOJC3HS.js.map +0 -1
  335. package/dist/cli-bundle/chunks/chunk-7RW4JCU2.js.map +0 -7
  336. package/dist/cli-bundle/chunks/chunk-ADBTSVGK.js.map +0 -7
  337. package/dist/cli-bundle/chunks/chunk-AMJPSANK.js.map +0 -7
  338. package/dist/cli-bundle/chunks/chunk-AS4SAZ5R.js.map +0 -7
  339. package/dist/cli-bundle/chunks/chunk-ATBCUC7Y.js.map +0 -1
  340. package/dist/cli-bundle/chunks/chunk-BKIAH72N.js.map +0 -1
  341. package/dist/cli-bundle/chunks/chunk-FJIFFBJX.js.map +0 -1
  342. package/dist/cli-bundle/chunks/chunk-HYW67VJ5.js.map +0 -1
  343. package/dist/cli-bundle/chunks/chunk-ICDAQ4TD.js.map +0 -1
  344. package/dist/cli-bundle/chunks/chunk-IY6VZ3IW.js.map +0 -7
  345. package/dist/cli-bundle/chunks/chunk-JFD5LPMI.js.map +0 -1
  346. package/dist/cli-bundle/chunks/chunk-K36WV5J6.js.map +0 -1
  347. package/dist/cli-bundle/chunks/chunk-K55VMLSS.js.map +0 -7
  348. package/dist/cli-bundle/chunks/chunk-MWQ2HC2A.js.map +0 -1
  349. package/dist/cli-bundle/chunks/chunk-NUF7ROFH.js.map +0 -1
  350. package/dist/cli-bundle/chunks/chunk-O4BCOJTZ.js.map +0 -7
  351. package/dist/cli-bundle/chunks/chunk-POG76WWZ.js.map +0 -1
  352. package/dist/cli-bundle/chunks/chunk-PQSEQD6E.js.map +0 -1
  353. package/dist/cli-bundle/chunks/chunk-QG4GFLQ6.js.map +0 -7
  354. package/dist/cli-bundle/chunks/chunk-R3P6FZJW.js.map +0 -1
  355. package/dist/cli-bundle/chunks/chunk-RNPZYNHS.js.map +0 -1
  356. package/dist/cli-bundle/chunks/chunk-RPESLSO5.js.map +0 -7
  357. package/dist/cli-bundle/chunks/chunk-SY4SFZSD.js.map +0 -7
  358. package/dist/cli-bundle/chunks/chunk-XJTABV3X.js.map +0 -1
  359. package/dist/cli-bundle/chunks/chunk-YQWCZ5AC.js.map +0 -7
  360. package/dist/cli-bundle/chunks/chunk-Z75ONV25.js.map +0 -7
  361. package/dist/cli-bundle/chunks/chunk-ZTVA4KLN.js.map +0 -7
  362. package/dist/cli-bundle/chunks/close-O5QVZ6ET.js +0 -12
  363. package/dist/cli-bundle/chunks/close-many-5RZXVN4J.js +0 -23
  364. package/dist/cli-bundle/chunks/comments-Z4KV6FU3.js +0 -13
  365. package/dist/cli-bundle/chunks/copy-M7DDI6LS.js +0 -9
  366. package/dist/cli-bundle/chunks/create-RGSPN5GD.js +0 -29
  367. package/dist/cli-bundle/chunks/delete-MD7YXQLH.js +0 -10
  368. package/dist/cli-bundle/chunks/docs-JWWNRC27.js +0 -14
  369. package/dist/cli-bundle/chunks/focus-DRQ6FQH6.js +0 -10
  370. package/dist/cli-bundle/chunks/history-compact-VCKGTX64.js +0 -16
  371. package/dist/cli-bundle/chunks/history-repair-YTDZRK5E.js +0 -17
  372. package/dist/cli-bundle/chunks/learnings-CYNOICKR.js +0 -13
  373. package/dist/cli-bundle/chunks/notes-FGO63FXL.js +0 -13
  374. package/dist/cli-bundle/chunks/plan-SGCDDTYR.js +0 -26
  375. package/dist/cli-bundle/chunks/register-list-query-BR435Q2H.js.map +0 -1
  376. package/dist/cli-bundle/chunks/register-list-query-RWTWLOBE.js.map +0 -7
  377. package/dist/cli-bundle/chunks/register-mutation-HLWC2WNP.js.map +0 -1
  378. package/dist/cli-bundle/chunks/register-mutation-ZJX5AZM5.js.map +0 -7
  379. package/dist/cli-bundle/chunks/restore-RSL7C7LO.js +0 -14
  380. package/dist/cli-bundle/chunks/update-SIA7LH5Y.js +0 -23
  381. package/dist/cli-bundle/chunks/update-many-BDBZVGQL.js +0 -38
  382. package/dist/cli-bundle/chunks/update-many-MOY3A5B3.js +0 -34
  383. /package/dist/cli-bundle/chunks/{append-7OVFYR3C.js.map → append-CYMA7RJT.js.map} +0 -0
  384. /package/dist/cli-bundle/chunks/{append-DFETHAZL.js.map → append-H53CAPMP.js.map} +0 -0
  385. /package/dist/cli-bundle/chunks/{chunk-PFNHX655.js.map → chunk-2P7OK4WG.js.map} +0 -0
  386. /package/dist/cli-bundle/chunks/{chunk-EJDGV4GR.js.map → chunk-3EBGHNNQ.js.map} +0 -0
  387. /package/dist/cli-bundle/chunks/{chunk-DZRV2OPA.js.map → chunk-3EDFN3VV.js.map} +0 -0
  388. /package/dist/cli-bundle/chunks/{chunk-ZOY5K4D3.js.map → chunk-3PWJWLLQ.js.map} +0 -0
  389. /package/dist/cli-bundle/chunks/{chunk-VXOOB6YX.js.map → chunk-3SJAR3CY.js.map} +0 -0
  390. /package/dist/cli-bundle/chunks/{chunk-GTLCVJOE.js.map → chunk-3WVKMF2A.js.map} +0 -0
  391. /package/dist/cli-bundle/chunks/{chunk-LAV26CQG.js.map → chunk-42SYYKA4.js.map} +0 -0
  392. /package/dist/cli-bundle/chunks/{chunk-NLR32VFS.js.map → chunk-4IXLNV7W.js.map} +0 -0
  393. /package/dist/cli-bundle/chunks/{chunk-ABWCF646.js.map → chunk-4YTQVO3V.js.map} +0 -0
  394. /package/dist/cli-bundle/chunks/{chunk-E5XMKOSB.js.map → chunk-5EBRMHI6.js.map} +0 -0
  395. /package/dist/cli-bundle/chunks/{chunk-GKX4NJ7U.js.map → chunk-5K5LHZZX.js.map} +0 -0
  396. /package/dist/cli-bundle/chunks/{chunk-T6PPNM7V.js.map → chunk-5K7BOAB6.js.map} +0 -0
  397. /package/dist/cli-bundle/chunks/{chunk-4QOB7L7I.js.map → chunk-5MUZ54G2.js.map} +0 -0
  398. /package/dist/cli-bundle/chunks/{chunk-SF3DT5HJ.js.map → chunk-5QME4KX2.js.map} +0 -0
  399. /package/dist/cli-bundle/chunks/{chunk-TRSHFPRZ.js.map → chunk-6PM6CPPP.js.map} +0 -0
  400. /package/dist/cli-bundle/chunks/{chunk-OR42SO64.js.map → chunk-7B36A3VT.js.map} +0 -0
  401. /package/dist/cli-bundle/chunks/{chunk-QWRVBJ4D.js.map → chunk-7OR2YKKD.js.map} +0 -0
  402. /package/dist/cli-bundle/chunks/{chunk-FPBMLYPI.js.map → chunk-7QUV54XX.js.map} +0 -0
  403. /package/dist/cli-bundle/chunks/{chunk-WWNL6WMH.js.map → chunk-7WXW6JHG.js.map} +0 -0
  404. /package/dist/cli-bundle/chunks/{chunk-BXNDKOR2.js.map → chunk-A2VL5SVG.js.map} +0 -0
  405. /package/dist/cli-bundle/chunks/{close-QEMOYZN3.js.map → chunk-AXGDUXJW.js.map} +0 -0
  406. /package/dist/cli-bundle/chunks/{chunk-IAQE32BI.js.map → chunk-B2AVNGG3.js.map} +0 -0
  407. /package/dist/cli-bundle/chunks/{chunk-HCEBZNC3.js.map → chunk-BRMPF2RM.js.map} +0 -0
  408. /package/dist/cli-bundle/chunks/{chunk-Z7VWXXJM.js.map → chunk-BTNKMF2A.js.map} +0 -0
  409. /package/dist/cli-bundle/chunks/{chunk-KH44WBAT.js.map → chunk-CD4643VW.js.map} +0 -0
  410. /package/dist/cli-bundle/chunks/{chunk-OWXOPDHD.js.map → chunk-CJEEC5O4.js.map} +0 -0
  411. /package/dist/cli-bundle/chunks/{chunk-PZC2FUOQ.js.map → chunk-CTPKCZCF.js.map} +0 -0
  412. /package/dist/cli-bundle/chunks/{chunk-7W2UAXXT.js.map → chunk-D4OBQVL3.js.map} +0 -0
  413. /package/dist/cli-bundle/chunks/{chunk-EWJWSNRU.js.map → chunk-DM4TYC2A.js.map} +0 -0
  414. /package/dist/cli-bundle/chunks/{chunk-VJQG4BIM.js.map → chunk-DSFTAQ7T.js.map} +0 -0
  415. /package/dist/cli-bundle/chunks/{chunk-AELMUANP.js.map → chunk-DVB6SQU7.js.map} +0 -0
  416. /package/dist/cli-bundle/chunks/{chunk-KBLZ3AA5.js.map → chunk-E3ZWOFSO.js.map} +0 -0
  417. /package/dist/cli-bundle/chunks/{close-O5QVZ6ET.js.map → chunk-EP25DV6P.js.map} +0 -0
  418. /package/dist/cli-bundle/chunks/{chunk-GTK4DTEW.js.map → chunk-F4VCB4WY.js.map} +0 -0
  419. /package/dist/cli-bundle/chunks/{chunk-V22ZPOKN.js.map → chunk-F4XAQUQA.js.map} +0 -0
  420. /package/dist/cli-bundle/chunks/{chunk-QOOTOD3W.js.map → chunk-FGR6IBAF.js.map} +0 -0
  421. /package/dist/cli-bundle/chunks/{chunk-JSLT7WVE.js.map → chunk-FKBMT2Q6.js.map} +0 -0
  422. /package/dist/cli-bundle/chunks/{chunk-QIH77CAG.js.map → chunk-G5RLSSIX.js.map} +0 -0
  423. /package/dist/cli-bundle/chunks/{chunk-P7MTHPJQ.js.map → chunk-GEKRVH3G.js.map} +0 -0
  424. /package/dist/cli-bundle/chunks/{chunk-2L6ZP22J.js.map → chunk-GSP6IZFU.js.map} +0 -0
  425. /package/dist/cli-bundle/chunks/{chunk-ZVZGXPQ5.js.map → chunk-HYZZM3Q2.js.map} +0 -0
  426. /package/dist/cli-bundle/chunks/{chunk-4XGJLADW.js.map → chunk-IHY5SX7O.js.map} +0 -0
  427. /package/dist/cli-bundle/chunks/{chunk-UCBDQI5E.js.map → chunk-IMU7JLUI.js.map} +0 -0
  428. /package/dist/cli-bundle/chunks/{chunk-PEQGTJ5Q.js.map → chunk-JCLXCGIL.js.map} +0 -0
  429. /package/dist/cli-bundle/chunks/{chunk-GROYI4RB.js.map → chunk-JLTHOYR7.js.map} +0 -0
  430. /package/dist/cli-bundle/chunks/{chunk-JHJSFOAM.js.map → chunk-JMPVHM44.js.map} +0 -0
  431. /package/dist/cli-bundle/chunks/{chunk-MATHDCGG.js.map → chunk-JWYG36RV.js.map} +0 -0
  432. /package/dist/cli-bundle/chunks/{chunk-VLRGDBLY.js.map → chunk-KEHOPUHH.js.map} +0 -0
  433. /package/dist/cli-bundle/chunks/{chunk-CPX275C6.js.map → chunk-KPCZL2YK.js.map} +0 -0
  434. /package/dist/cli-bundle/chunks/{chunk-FO6OSVEN.js.map → chunk-LANV45W2.js.map} +0 -0
  435. /package/dist/cli-bundle/chunks/{chunk-LVC72YRD.js.map → chunk-LC5ZUXWE.js.map} +0 -0
  436. /package/dist/cli-bundle/chunks/{chunk-TVYYO5A7.js.map → chunk-MBHYQYCS.js.map} +0 -0
  437. /package/dist/cli-bundle/chunks/{chunk-7656MAUL.js.map → chunk-MUAJHL2R.js.map} +0 -0
  438. /package/dist/cli-bundle/chunks/{chunk-7WCE6Y64.js.map → chunk-NUQCSV4P.js.map} +0 -0
  439. /package/dist/cli-bundle/chunks/{chunk-SZVB53Y3.js.map → chunk-O3GFE2PX.js.map} +0 -0
  440. /package/dist/cli-bundle/chunks/{chunk-OY7DMU5P.js.map → chunk-O43LEUSD.js.map} +0 -0
  441. /package/dist/cli-bundle/chunks/{chunk-LZYP423P.js.map → chunk-OZ25YD4Q.js.map} +0 -0
  442. /package/dist/cli-bundle/chunks/{chunk-VZIZB6QH.js.map → chunk-PKYKQCTJ.js.map} +0 -0
  443. /package/dist/cli-bundle/chunks/{chunk-UZLJOEAC.js.map → chunk-PMRED6QZ.js.map} +0 -0
  444. /package/dist/cli-bundle/chunks/{chunk-K4CI6Y45.js.map → chunk-PWGJCP2V.js.map} +0 -0
  445. /package/dist/cli-bundle/chunks/{chunk-UVN66B3M.js.map → chunk-Q3Z2Y5WJ.js.map} +0 -0
  446. /package/dist/cli-bundle/chunks/{chunk-R7QV7ICM.js.map → chunk-QSXN2FAN.js.map} +0 -0
  447. /package/dist/cli-bundle/chunks/{chunk-5NTE36LD.js.map → chunk-RBECHH5K.js.map} +0 -0
  448. /package/dist/cli-bundle/chunks/{chunk-JXCW2TI2.js.map → chunk-RPNC7M63.js.map} +0 -0
  449. /package/dist/cli-bundle/chunks/{chunk-F2LBF7XJ.js.map → chunk-SUSFH6F7.js.map} +0 -0
  450. /package/dist/cli-bundle/chunks/{chunk-VHXHVTUU.js.map → chunk-TDOPC7UY.js.map} +0 -0
  451. /package/dist/cli-bundle/chunks/{chunk-FSE2IKJQ.js.map → chunk-TWHG646K.js.map} +0 -0
  452. /package/dist/cli-bundle/chunks/{chunk-OCUBRA6D.js.map → chunk-U7U7WGEC.js.map} +0 -0
  453. /package/dist/cli-bundle/chunks/{chunk-PONKZPCJ.js.map → chunk-UFRVIIJ2.js.map} +0 -0
  454. /package/dist/cli-bundle/chunks/{chunk-VNTCM3VW.js.map → chunk-VKX2VZZH.js.map} +0 -0
  455. /package/dist/cli-bundle/chunks/{chunk-6JUTHVQS.js.map → chunk-W2JDNTN3.js.map} +0 -0
  456. /package/dist/cli-bundle/chunks/{chunk-AF2CCM5U.js.map → chunk-XKRVX4B3.js.map} +0 -0
  457. /package/dist/cli-bundle/chunks/{chunk-JGUKMMRS.js.map → chunk-XN4NQZJK.js.map} +0 -0
  458. /package/dist/cli-bundle/chunks/{chunk-3P7UJQOX.js.map → chunk-YKFMLQNK.js.map} +0 -0
  459. /package/dist/cli-bundle/chunks/{chunk-YCIUJJOD.js.map → chunk-YKWKMGL7.js.map} +0 -0
  460. /package/dist/cli-bundle/chunks/{chunk-TOBGV45Y.js.map → chunk-YUKIFPWK.js.map} +0 -0
  461. /package/dist/cli-bundle/chunks/{chunk-72LQ4TKV.js.map → chunk-YYEZEP3E.js.map} +0 -0
  462. /package/dist/cli-bundle/chunks/{chunk-X3W65QK3.js.map → chunk-ZEY3XSZQ.js.map} +0 -0
  463. /package/dist/cli-bundle/chunks/{chunk-QJIKE24M.js.map → chunk-ZQ3UMKWE.js.map} +0 -0
  464. /package/dist/cli-bundle/chunks/{chunk-OG5DVFMA.js.map → chunk-ZXE6SNKO.js.map} +0 -0
  465. /package/dist/cli-bundle/chunks/{close-many-5RZXVN4J.js.map → close-GAUIGOQC.js.map} +0 -0
  466. /package/dist/cli-bundle/chunks/{close-many-RZVTUGBG.js.map → close-SJIEKNY4.js.map} +0 -0
  467. /package/dist/cli-bundle/chunks/{comments-TPU7QRBL.js.map → close-many-B6AIC5OQ.js.map} +0 -0
  468. /package/dist/cli-bundle/chunks/{comments-Z4KV6FU3.js.map → close-many-QCINT6I2.js.map} +0 -0
  469. /package/dist/cli-bundle/chunks/{copy-M7DDI6LS.js.map → comments-4SK5EUEJ.js.map} +0 -0
  470. /package/dist/cli-bundle/chunks/{copy-DKTSSCK7.js.map → comments-DM5KV2RS.js.map} +0 -0
  471. /package/dist/cli-bundle/chunks/{create-RGSPN5GD.js.map → copy-4KCCLTYQ.js.map} +0 -0
  472. /package/dist/cli-bundle/chunks/{create-EIFBIVNQ.js.map → copy-HEP5SZHB.js.map} +0 -0
  473. /package/dist/cli-bundle/chunks/{delete-MD7YXQLH.js.map → create-BDKQFPRE.js.map} +0 -0
  474. /package/dist/cli-bundle/chunks/{delete-LCS3VPDH.js.map → create-VCGBCYL2.js.map} +0 -0
  475. /package/dist/cli-bundle/chunks/{deps-YG7UF3VR.js.map → delete-JWDXPR3H.js.map} +0 -0
  476. /package/dist/cli-bundle/chunks/{deps-UH5EQQUY.js.map → delete-ZSPBTVJD.js.map} +0 -0
  477. /package/dist/cli-bundle/chunks/{docs-JWWNRC27.js.map → deps-BZTWWOIE.js.map} +0 -0
  478. /package/dist/cli-bundle/chunks/{docs-G32TK6XS.js.map → deps-OVAJOQIE.js.map} +0 -0
  479. /package/dist/cli-bundle/chunks/{files-3H32UQ4K.js.map → docs-3GFMSWLL.js.map} +0 -0
  480. /package/dist/cli-bundle/chunks/{files-4ALMCSKB.js.map → docs-SY2NPT6Y.js.map} +0 -0
  481. /package/dist/cli-bundle/chunks/{focus-DRQ6FQH6.js.map → files-2SEL4QIU.js.map} +0 -0
  482. /package/dist/cli-bundle/chunks/{focus-7SOUT5PZ.js.map → files-FYMMJGNN.js.map} +0 -0
  483. /package/dist/cli-bundle/chunks/{history-compact-VCKGTX64.js.map → focus-4A27YJ2Z.js.map} +0 -0
  484. /package/dist/cli-bundle/chunks/{history-compact-77BT2LUB.js.map → focus-TEUJKTAT.js.map} +0 -0
  485. /package/dist/cli-bundle/chunks/{history-redact-PWTTJ3XS.js.map → history-compact-7QOKL2NB.js.map} +0 -0
  486. /package/dist/cli-bundle/chunks/{history-redact-LJPZPNFA.js.map → history-compact-U7A37VR6.js.map} +0 -0
  487. /package/dist/cli-bundle/chunks/{history-repair-I7CBNCV3.js.map → history-redact-TNKUO4ZE.js.map} +0 -0
  488. /package/dist/cli-bundle/chunks/{history-repair-YTDZRK5E.js.map → history-redact-ZWRUWQY3.js.map} +0 -0
  489. /package/dist/cli-bundle/chunks/{learnings-KTYW3AL7.js.map → history-repair-6IU5VWHN.js.map} +0 -0
  490. /package/dist/cli-bundle/chunks/{learnings-CYNOICKR.js.map → history-repair-GWCGJUM2.js.map} +0 -0
  491. /package/dist/cli-bundle/chunks/{notes-FGO63FXL.js.map → learnings-DDFAUUX3.js.map} +0 -0
  492. /package/dist/cli-bundle/chunks/{notes-ZERD3KB2.js.map → learnings-GOEZXMKL.js.map} +0 -0
  493. /package/dist/cli-bundle/chunks/{plan-OFJUBIM5.js.map → notes-BZWODAEK.js.map} +0 -0
  494. /package/dist/cli-bundle/chunks/{plan-SGCDDTYR.js.map → notes-OBJ6FL36.js.map} +0 -0
  495. /package/dist/cli-bundle/chunks/{profile-3THJPIQY.js.map → plan-V57VQTAG.js.map} +0 -0
  496. /package/dist/cli-bundle/chunks/{profile-XEZAMMBW.js.map → plan-ZMOBD6FX.js.map} +0 -0
  497. /package/dist/cli-bundle/chunks/{restore-6TDVSATY.js.map → profile-BG3N4ETA.js.map} +0 -0
  498. /package/dist/cli-bundle/chunks/{restore-RSL7C7LO.js.map → profile-XLM45FKV.js.map} +0 -0
  499. /package/dist/cli-bundle/chunks/{register-setup-5DA4UZXI.js.map → register-setup-HZ2KKXK4.js.map} +0 -0
  500. /package/dist/cli-bundle/chunks/{register-setup-6H25M3BH.js.map → register-setup-WCBKJ3H3.js.map} +0 -0
  501. /package/dist/cli-bundle/chunks/{schema-TPVTIJPO.js.map → restore-3NGRFDPX.js.map} +0 -0
  502. /package/dist/cli-bundle/chunks/{schema-HFXFSGPG.js.map → restore-LNVNUWHE.js.map} +0 -0
  503. /package/dist/cli-bundle/chunks/{update-LJZCL5SI.js.map → schema-LMFZ742C.js.map} +0 -0
  504. /package/dist/cli-bundle/chunks/{update-SIA7LH5Y.js.map → schema-O34O33UW.js.map} +0 -0
  505. /package/dist/cli-bundle/chunks/{update-many-MOY3A5B3.js.map → update-BN6VZSYX.js.map} +0 -0
  506. /package/dist/cli-bundle/chunks/{update-many-BDBZVGQL.js.map → update-FDLPLKOB.js.map} +0 -0
@@ -15,6 +15,11 @@ export interface ContextRelevanceCandidate<TItem> {
15
15
  /** Value that configures or reports signals for this contract. */
16
16
  signals?: ContextRelevanceSignals;
17
17
  }
18
+ /** Item candidate whose built-in metadata derivation always supplies signals. */
19
+ export interface ItemContextRelevanceCandidate extends ContextRelevanceCandidate<ItemMetadata> {
20
+ /** Complete built-in derivation result, with unavailable signals omitted by value. */
21
+ signals: ContextRelevanceSignals;
22
+ }
18
23
  /** Inputs that make item-signal derivation deterministic and host-configurable. */
19
24
  export interface BuildItemContextRelevanceCandidatesOptions {
20
25
  /** Workspace lifecycle registry, including custom in-progress aliases. */
@@ -27,13 +32,23 @@ export interface BuildItemContextRelevanceCandidatesOptions {
27
32
  usageAffinity?: Readonly<Record<string, number>>;
28
33
  /** Optional caller-derived semantic similarity by item id. */
29
34
  semanticSimilarity?: Readonly<Record<string, number>>;
35
+ /** Optional index-derived activity density by item id. */
36
+ activityDensity?: Readonly<Record<string, number>>;
37
+ /** Optional index-derived graph proximity by item id. */
38
+ graphProximity?: Readonly<Record<string, number>>;
39
+ /** Optional host-derived claim or focus affinity by item id. */
40
+ claimFocus?: Readonly<Record<string, number>>;
41
+ /** Optional index-derived knowledge density by item id. */
42
+ knowledgeDensity?: Readonly<Record<string, number>>;
43
+ /** Optional history-derived author affinity by item id. */
44
+ authorAffinity?: Readonly<Record<string, number>>;
30
45
  }
31
46
  /**
32
47
  * Derive the canonical metadata signals consumed by `pm context` and `pm next`.
33
48
  * Extensions can pair this with {@link scoreContextCandidatesWithActiveExtensions}
34
49
  * to reproduce built-in ranking without private imports or subprocesses.
35
50
  */
36
- export declare function buildItemContextRelevanceCandidates(items: readonly ItemMetadata[], options: BuildItemContextRelevanceCandidatesOptions): ContextRelevanceCandidate<ItemMetadata>[];
51
+ export declare function buildItemContextRelevanceCandidates(items: readonly ItemMetadata[], options: BuildItemContextRelevanceCandidatesOptions): ItemContextRelevanceCandidate[];
37
52
  /** Per-signal weighted contributions used to explain a ranked result. */
38
53
  export type ContextRelevanceContributions = Record<string, number>;
39
54
  /** One ranked candidate with deterministic score and explanation metadata. */
@@ -6,7 +6,7 @@
6
6
  * with core, extension, or project-specific feature stores.
7
7
  */
8
8
 
9
- !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]="833cf230-b0c8-51f0-822e-1f27f0574971")}catch(e){}}();
9
+ !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]="be8706fa-86f8-576a-9e39-475b9681600c")}catch(e){}}();
10
10
  import { runActiveServiceOverride } from "../core/extensions/index.js";
11
11
  import { normalizeStatusForRegistry, normalizeStatusInput, } from "../core/item/status.js";
12
12
  import { compareTimestampStrings, resolveIsoOrRelative } from "../core/shared/time.js";
@@ -25,6 +25,14 @@ export const CONTEXT_RELEVANCE_SIGNAL_NAMES = [
25
25
  "usage_affinity",
26
26
  "semantic_similarity",
27
27
  ];
28
+ const NO_CONTEXT_AUTHOR = Symbol("no-context-author");
29
+ const NO_ITEM_ASSIGNEE = Symbol("no-item-assignee");
30
+ function normalizeContextActor(value, missingValue) {
31
+ if (typeof value !== "string")
32
+ return missingValue;
33
+ const normalized = value.trim().toLowerCase();
34
+ return normalized.length > 0 ? normalized : missingValue;
35
+ }
28
36
  function normalizedPressure(value, maximum) {
29
37
  const parsed = typeof value === "number" ? value : typeof value === "string" ? Number.parseFloat(value) : Number.NaN;
30
38
  return Number.isFinite(parsed) ? 1 - Math.min(Math.max(parsed, 0), maximum) / maximum : 0;
@@ -44,6 +52,9 @@ function riskPressure(risk) {
44
52
  return 0.5;
45
53
  return normalized === "low" ? 0.1 : 0;
46
54
  }
55
+ function derivedSignalOrFallback(values, id, fallback) {
56
+ return values?.[id] ?? fallback;
57
+ }
47
58
  /**
48
59
  * Derive the canonical metadata signals consumed by `pm context` and `pm next`.
49
60
  * Extensions can pair this with {@link scoreContextCandidatesWithActiveExtensions}
@@ -67,24 +78,25 @@ export function buildItemContextRelevanceCandidates(items, options) {
67
78
  });
68
79
  const recencyRank = new Map(recencyOrder.map((item, index) => [item.id, index]));
69
80
  const denominator = Math.max(items.length - 1, 1);
70
- const normalizedAuthor = options.author?.trim().toLowerCase();
81
+ const normalizedAuthor = normalizeContextActor(options.author, NO_CONTEXT_AUTHOR);
71
82
  const inProgressStatus = normalizeStatusInput("in_progress", options.statusRegistry);
72
83
  const nowMs = Date.parse(options.now);
73
84
  return items.map((item) => {
74
- const assigned = normalizedAuthor !== undefined && typeof item.assignee === "string" && item.assignee.trim().toLowerCase() === normalizedAuthor;
85
+ const assigned = normalizeContextActor(item.assignee, NO_ITEM_ASSIGNEE) === normalizedAuthor;
75
86
  const knowledgeEntries = (item.comments?.length ?? 0) + (item.notes?.length ?? 0) + (item.learnings?.length ?? 0);
76
87
  return {
77
88
  id: item.id,
78
89
  item,
79
90
  signals: {
80
91
  recency: items.length === 1 ? 1 : 1 - recencyRank.get(item.id) / denominator,
81
- graph_proximity: item.parent ? 0.3 : 0,
82
- claim_focus: normalizeStatusForRegistry(item.status, options.statusRegistry) === inProgressStatus ? 1 : assigned ? 0.75 : 0,
92
+ activity_density: options.activityDensity?.[item.id],
93
+ graph_proximity: derivedSignalOrFallback(options.graphProximity, item.id, item.parent ? 0.3 : 0),
94
+ claim_focus: derivedSignalOrFallback(options.claimFocus, item.id, normalizeStatusForRegistry(item.status, options.statusRegistry) === inProgressStatus ? 1 : assigned ? 0.75 : 0),
83
95
  priority_pressure: normalizedPressure(item.priority, 4),
84
96
  risk_pressure: riskPressure(item.risk),
85
97
  deadline_pressure: deadlinePressure(item.deadline, nowMs),
86
- knowledge_density: Math.min(knowledgeEntries / 5, 1),
87
- author_affinity: assigned ? 1 : 0,
98
+ knowledge_density: derivedSignalOrFallback(options.knowledgeDensity, item.id, Math.min(knowledgeEntries / 5, 1)),
99
+ author_affinity: derivedSignalOrFallback(options.authorAffinity, item.id, assigned ? 1 : 0),
88
100
  usage_affinity: options.usageAffinity?.[item.id],
89
101
  semantic_similarity: options.semanticSimilarity?.[item.id],
90
102
  },
@@ -410,4 +422,4 @@ export async function runContextEvaluationCorpus(scenarios, reader, thresholds)
410
422
  return summarizeContextEvaluationReports(reports, thresholds);
411
423
  }
412
424
  //# sourceMappingURL=context-relevance.js.map
413
- //# debugId=833cf230-b0c8-51f0-822e-1f27f0574971
425
+ //# debugId=be8706fa-86f8-576a-9e39-475b9681600c
@@ -1 +1 @@
1
- {"version":3,"file":"context-relevance.js","sources":["sdk/context-relevance.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module sdk/context-relevance\n *\n * Public, deterministic context-ranking and evaluation primitives. The scorer\n * accepts already-derived signals so package authors can reuse the same model\n * with core, extension, or project-specific feature stores.\n */\nimport { runActiveServiceOverride } from \"../core/extensions/index.js\";\nimport {\n normalizeStatusForRegistry,\n normalizeStatusInput,\n} from \"../core/item/status.js\";\nimport type { RuntimeStatusRegistry } from \"../core/schema/runtime-schema.js\";\nimport { compareTimestampStrings, resolveIsoOrRelative } from \"../core/shared/time.js\";\nimport type { ItemMetadata } from \"../types/index.js\";\n\n/** Canonical signal keys understood by the built-in relevance model. */\nexport const CONTEXT_RELEVANCE_SIGNAL_NAMES = [\n \"structural\",\n \"recency\",\n \"activity_density\",\n \"graph_proximity\",\n \"claim_focus\",\n \"priority_pressure\",\n \"risk_pressure\",\n \"deadline_pressure\",\n \"knowledge_density\",\n \"author_affinity\",\n \"usage_affinity\",\n \"semantic_similarity\",\n] as const;\n\n/** A normalized signal consumed by the built-in context relevance scorer. */\nexport type ContextRelevanceSignalName =\n (typeof CONTEXT_RELEVANCE_SIGNAL_NAMES)[number];\n\n/** Normalized candidate features; omitted signals are excluded from weighting. */\nexport type ContextRelevanceSignals = Partial<\n Record<Exclude<ContextRelevanceSignalName, \"structural\">, number>\n>;\n\n/** A project-management object and its derived relevance signals. */\nexport interface ContextRelevanceCandidate<TItem> {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports item for this contract. */\n item: TItem;\n /** Value that configures or reports signals for this contract. */\n signals?: ContextRelevanceSignals;\n}\n\n/** Inputs that make item-signal derivation deterministic and host-configurable. */\nexport interface BuildItemContextRelevanceCandidatesOptions {\n /** Workspace lifecycle registry, including custom in-progress aliases. */\n statusRegistry: RuntimeStatusRegistry;\n /** Stable clock used for deadline pressure. */\n now: string;\n /** Optional caller identity used for assignment affinity. */\n author?: string;\n /** Optional derived served-then-used affinity by item id. */\n usageAffinity?: Readonly<Record<string, number>>;\n /** Optional caller-derived semantic similarity by item id. */\n semanticSimilarity?: Readonly<Record<string, number>>;\n}\n\nfunction normalizedPressure(value: unknown, maximum: number): number {\n const parsed = typeof value === \"number\" ? value : typeof value === \"string\" ? Number.parseFloat(value) : Number.NaN;\n return Number.isFinite(parsed) ? 1 - Math.min(Math.max(parsed, 0), maximum) / maximum : 0;\n}\n\nfunction deadlinePressure(deadline: unknown, nowMs: number): number {\n const deadlineMs = typeof deadline === \"string\" ? Date.parse(deadline) : deadline instanceof Date ? deadline.getTime() : typeof deadline === \"number\" ? deadline : Number.NaN;\n if (!Number.isFinite(deadlineMs) || !Number.isFinite(nowMs)) return 0;\n const days = (deadlineMs - nowMs) / 86_400_000;\n return days <= 0 ? 1 : 1 / (1 + days / 30);\n}\n\nfunction riskPressure(risk: ItemMetadata[\"risk\"]): number {\n const normalized = typeof risk === \"string\" ? risk.trim().toLowerCase() : undefined;\n if (normalized === \"critical\" || normalized === \"high\") return 1;\n if (normalized === \"medium\") return 0.5;\n return normalized === \"low\" ? 0.1 : 0;\n}\n\n/**\n * Derive the canonical metadata signals consumed by `pm context` and `pm next`.\n * Extensions can pair this with {@link scoreContextCandidatesWithActiveExtensions}\n * to reproduce built-in ranking without private imports or subprocesses.\n */\nexport function buildItemContextRelevanceCandidates(\n items: readonly ItemMetadata[],\n options: BuildItemContextRelevanceCandidatesOptions,\n): ContextRelevanceCandidate<ItemMetadata>[] {\n const sortableTimestamp = (value: unknown): string => {\n if (typeof value !== \"string\") return \"\";\n try {\n return resolveIsoOrRelative(value, new Date(Number.NaN), \"updated_at\");\n } catch {\n return \"\";\n }\n };\n const recencyOrder = [...items].sort((left, right) => {\n const leftTime = sortableTimestamp(left.updated_at);\n const rightTime = sortableTimestamp(right.updated_at);\n return compareTimestampStrings(rightTime, leftTime) || left.id.localeCompare(right.id);\n });\n const recencyRank = new Map(recencyOrder.map((item, index) => [item.id, index]));\n const denominator = Math.max(items.length - 1, 1);\n const normalizedAuthor = options.author?.trim().toLowerCase();\n const inProgressStatus = normalizeStatusInput(\"in_progress\", options.statusRegistry);\n const nowMs = Date.parse(options.now);\n return items.map((item) => {\n const assigned = normalizedAuthor !== undefined && typeof item.assignee === \"string\" && item.assignee.trim().toLowerCase() === normalizedAuthor;\n const knowledgeEntries = (item.comments?.length ?? 0) + (item.notes?.length ?? 0) + (item.learnings?.length ?? 0);\n return {\n id: item.id,\n item,\n signals: {\n recency: items.length === 1 ? 1 : 1 - (recencyRank.get(item.id) as number) / denominator,\n graph_proximity: item.parent ? 0.3 : 0,\n claim_focus: normalizeStatusForRegistry(item.status, options.statusRegistry) === inProgressStatus ? 1 : assigned ? 0.75 : 0,\n priority_pressure: normalizedPressure(item.priority, 4),\n risk_pressure: riskPressure(item.risk),\n deadline_pressure: deadlinePressure(item.deadline, nowMs),\n knowledge_density: Math.min(knowledgeEntries / 5, 1),\n author_affinity: assigned ? 1 : 0,\n usage_affinity: options.usageAffinity?.[item.id],\n semantic_similarity: options.semanticSimilarity?.[item.id],\n },\n };\n });\n}\n\n/** Per-signal weighted contributions used to explain a ranked result. */\nexport type ContextRelevanceContributions = Record<string, number>;\n\n/** One ranked candidate with deterministic score and explanation metadata. */\nexport interface RankedContextCandidate<\n TItem,\n> extends ContextRelevanceCandidate<TItem> {\n /** Value that configures or reports baseline rank for this contract. */\n baseline_rank: number;\n /** Value that configures or reports rank for this contract. */\n rank: number;\n /** Value that configures or reports score for this contract. */\n score: number;\n /** Value that configures or reports contributions for this contract. */\n contributions: ContextRelevanceContributions;\n}\n\n/** Complete output from a context relevance scorer. */\nexport interface ContextRelevanceReport<TItem> {\n /** Value that configures or reports model for this contract. */\n model: string;\n /** Value that configures or reports available signals for this contract. */\n available_signals: ContextRelevanceSignalName[];\n /** Value that configures or reports ranked for this contract. */\n ranked: RankedContextCandidate<TItem>[];\n /** Value that configures or reports warnings for this contract. */\n warnings?: string[];\n}\n\n/** Minimal custom score returned by a replacement or wrapper scorer. */\nexport interface ContextRelevanceCustomScore {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports score for this contract. */\n score: number;\n}\n\n/** Input provided to a custom scorer, including the deterministic default. */\nexport interface ContextRelevanceScorerInput<TItem> {\n /** Value that configures or reports candidates for this contract. */\n candidates: readonly ContextRelevanceCandidate<TItem>[];\n /** Fallback report used when callers do not provide an override. */\n default_report: ContextRelevanceReport<TItem>;\n}\n\n/** Replaceable package/extension scorer contract. */\nexport type ContextRelevanceScorer<TItem> = (\n input: ContextRelevanceScorerInput<TItem>,\n) =>\n | readonly ContextRelevanceCustomScore[]\n | Promise<readonly ContextRelevanceCustomScore[]>;\n\n/** Options for the built-in or replaceable context relevance scorer. */\nexport interface ScoreContextCandidatesOptions<TItem> {\n /** Value that configures or reports weights for this contract. */\n weights?: Partial<Record<ContextRelevanceSignalName, number>>;\n /** Value that configures or reports scorer for this contract. */\n scorer?: ContextRelevanceScorer<TItem>;\n}\n\n/** Governed extension service used to replace or wrap context ranking. */\nexport const CONTEXT_RELEVANCE_SERVICE = \"context_relevance\" as const;\n\n/** Command surface requesting an active extension relevance override. */\nexport type ContextRelevanceSurface = \"context\" | \"next\";\n\nconst DEFAULT_CONTEXT_RELEVANCE_WEIGHTS: Record<\n ContextRelevanceSignalName,\n number\n> = {\n structural: 0.4,\n recency: 0.35,\n activity_density: 0.25,\n graph_proximity: 0.15,\n claim_focus: 0.6,\n priority_pressure: 0.35,\n risk_pressure: 0.2,\n deadline_pressure: 0.45,\n knowledge_density: 0.25,\n author_affinity: 0.2,\n usage_affinity: 0.3,\n semantic_similarity: 0.5,\n};\nconst JSON_TOKEN_ENCODER = new TextEncoder();\n\nfunction assertCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n): void {\n const ids = new Set<string>();\n for (const candidate of candidates) {\n if (\n typeof candidate.id !== \"string\" ||\n candidate.id.trim().length === 0 ||\n ids.has(candidate.id)\n ) {\n throw new TypeError(\n \"Context relevance candidates require unique non-empty ids\",\n );\n }\n ids.add(candidate.id);\n for (const [signal, value] of Object.entries(candidate.signals ?? {})) {\n if (\n signal === \"structural\" ||\n !CONTEXT_RELEVANCE_SIGNAL_NAMES.includes(\n signal as ContextRelevanceSignalName,\n )\n ) {\n throw new TypeError(`Unknown context relevance signal: ${signal}`);\n }\n if (value === undefined) continue;\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new TypeError(\n `Context relevance signal ${signal} must be a finite number from 0 to 1`,\n );\n }\n }\n }\n}\n\nfunction resolveWeights(\n overrides: Partial<Record<ContextRelevanceSignalName, number>> | undefined,\n): Record<ContextRelevanceSignalName, number> {\n const weights = { ...DEFAULT_CONTEXT_RELEVANCE_WEIGHTS };\n for (const [signal, weight] of Object.entries(overrides ?? {})) {\n if (\n weight !== undefined &&\n CONTEXT_RELEVANCE_SIGNAL_NAMES.includes(\n signal as ContextRelevanceSignalName,\n )\n ) {\n weights[signal as ContextRelevanceSignalName] = weight;\n }\n }\n for (const [signal, weight] of Object.entries(weights)) {\n if (!Number.isFinite(weight) || weight < 0) {\n throw new TypeError(\n `Context relevance weight ${signal} must be a finite non-negative number`,\n );\n }\n }\n return weights;\n}\n\n/** Score candidates with pm's deterministic weighted model. Candidate order is the structural baseline and remains unchanged when no advanced signals exist. */\nexport function defaultScoreContextCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: Pick<ScoreContextCandidatesOptions<TItem>, \"weights\"> = {},\n): ContextRelevanceReport<TItem> {\n assertCandidates(candidates);\n const weights = resolveWeights(options.weights);\n const denominator = Math.max(candidates.length - 1, 1);\n const available = new Set<ContextRelevanceSignalName>([\"structural\"]);\n for (const candidate of candidates) {\n for (const [signal, value] of Object.entries(candidate.signals ?? {})) {\n if (value !== undefined)\n available.add(signal as ContextRelevanceSignalName);\n }\n }\n const availableSignals = CONTEXT_RELEVANCE_SIGNAL_NAMES.filter((signal) =>\n available.has(signal),\n );\n const scored = candidates.map(\n (candidate, index): RankedContextCandidate<TItem> => {\n const signalValues: Partial<Record<ContextRelevanceSignalName, number>> =\n {\n structural: candidates.length === 1 ? 1 : 1 - index / denominator,\n ...candidate.signals,\n };\n const contributions: ContextRelevanceContributions = {};\n let weightedScore = 0;\n let totalWeight = 0;\n for (const signal of availableSignals) {\n const value = signalValues[signal];\n if (value === undefined) continue;\n const contribution = value * weights[signal];\n contributions[signal] = contribution;\n weightedScore += contribution;\n totalWeight += weights[signal];\n }\n return {\n ...candidate,\n baseline_rank: index + 1,\n rank: 0,\n score: totalWeight === 0 ? 0 : weightedScore / totalWeight,\n contributions,\n };\n },\n );\n scored.sort(\n (left, right) =>\n right.score - left.score || left.baseline_rank - right.baseline_rank,\n );\n scored.forEach((entry, index) => {\n entry.rank = index + 1;\n });\n return {\n model: \"default-weighted-v1\",\n available_signals: availableSignals,\n ranked: scored,\n };\n}\n\n/** Score candidates with the default model or a validated replacement/wrapper. */\nexport async function scoreContextCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: ScoreContextCandidatesOptions<TItem> = {},\n): Promise<ContextRelevanceReport<TItem>> {\n const defaultReport = defaultScoreContextCandidates(candidates, options);\n if (!options.scorer) return defaultReport;\n const customScores = await options.scorer({\n candidates,\n default_report: defaultReport,\n });\n const scoreById = new Map<string, number>();\n for (const entry of customScores) {\n if (scoreById.has(entry.id) || !Number.isFinite(entry.score)) {\n throw new TypeError(\n \"Context relevance scorer must return one finite score for every candidate\",\n );\n }\n scoreById.set(entry.id, entry.score);\n }\n if (\n scoreById.size !== candidates.length ||\n candidates.some((candidate) => !scoreById.has(candidate.id))\n ) {\n throw new TypeError(\n \"Context relevance scorer must return one finite score for every candidate\",\n );\n }\n const ranked = defaultReport.ranked.map((entry) => {\n const score = scoreById.get(entry.id) as number;\n return { ...entry, score, contributions: { custom: score } };\n });\n ranked.sort(\n (left, right) =>\n right.score - left.score || left.baseline_rank - right.baseline_rank,\n );\n ranked.forEach((entry, index) => {\n entry.rank = index + 1;\n });\n return {\n model: \"custom\",\n available_signals: defaultReport.available_signals,\n ranked,\n };\n}\n\n/** Score command candidates through the public default model and then the active governed `context_relevance` service override, when one is registered. */\nexport async function scoreContextCandidatesWithActiveExtensions<TItem>(\n surface: ContextRelevanceSurface,\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: Pick<ScoreContextCandidatesOptions<TItem>, \"weights\"> = {},\n): Promise<ContextRelevanceReport<TItem>> {\n const defaultReport = defaultScoreContextCandidates(candidates, options);\n const override = await runActiveServiceOverride(CONTEXT_RELEVANCE_SERVICE, {\n surface,\n candidates,\n default_report: defaultReport,\n });\n if (!override.handled) {\n return override.warnings.length > 0\n ? { ...defaultReport, warnings: override.warnings }\n : defaultReport;\n }\n if (\n !Array.isArray(override.result) ||\n !override.result.every(\n (entry) =>\n typeof entry === \"object\" &&\n entry !== null &&\n typeof (entry as { id?: unknown }).id === \"string\" &&\n typeof (entry as { score?: unknown }).score === \"number\" &&\n Number.isFinite((entry as { score: number }).score),\n )\n ) {\n return {\n ...defaultReport,\n warnings: [\n ...override.warnings,\n \"extension_context_relevance_invalid_result\",\n ],\n };\n }\n try {\n const report = await scoreContextCandidates(candidates, {\n ...options,\n scorer: () => override.result as ContextRelevanceCustomScore[],\n });\n return override.warnings.length > 0\n ? { ...report, warnings: override.warnings }\n : report;\n } catch {\n return {\n ...defaultReport,\n warnings: [\n ...override.warnings,\n \"extension_context_relevance_invalid_result\",\n ],\n };\n }\n}\n\n/** Input for rank-aware context/next quality evaluation. */\nexport interface ContextRankingEvaluationInput {\n /** Value that configures or reports ranked ids for this contract. */\n ranked_ids: string[];\n /** Value that configures or reports judgments for this contract. */\n judgments: Record<string, number>;\n /** Value that configures or reports required ids for this contract. */\n required_ids?: string[];\n /** Value that configures or reports continuity ids for this contract. */\n continuity_ids?: string[];\n /** Value that configures or reports actual tokens for this contract. */\n actual_tokens: number;\n /** Value that configures or reports token budget for this contract. */\n token_budget: number;\n}\n\n/** Rank-quality, continuity, recall, and token-budget metrics for one scenario. */\nexport interface ContextRankingEvaluation {\n /** Value that configures or reports ndcg for this contract. */\n ndcg: number;\n /** Value that configures or reports reciprocal rank for this contract. */\n reciprocal_rank: number;\n /** Value that configures or reports required recall for this contract. */\n required_recall: number;\n /** Value that configures or reports continuity coverage for this contract. */\n continuity_coverage: number;\n /** Value that configures or reports token budget adherence for this contract. */\n token_budget_adherence: number;\n /** Value that configures or reports within token budget for this contract. */\n within_token_budget: boolean;\n}\n\n/** Flexible read options accepted by context evaluation scenarios. */\nexport interface ContextEvaluationReadOptions {\n /** Value that configures or reports explain ranking for this contract. */\n explainRanking?: boolean;\n [key: string]: unknown;\n}\n\n/** Minimal item identity consumed by the context evaluation runner. */\nexport interface ContextEvaluationResultItem {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n}\n\n/** Optional scorer attribution returned by an evaluated read primitive. */\nexport interface ContextEvaluationResultRanking {\n /** Value that configures or reports items for this contract. */\n items?: Array<{ id: string; contributions: ContextRelevanceContributions }>;\n}\n\n/** Structural context result consumed by the evaluation runner. */\nexport interface ContextEvaluationContextResult {\n /** Value that configures or reports high level for this contract. */\n high_level?: ContextEvaluationResultItem[];\n /** Value that configures or reports low level for this contract. */\n low_level?: ContextEvaluationResultItem[];\n /** Value that configures or reports blocked fallback for this contract. */\n blocked_fallback?: ContextEvaluationResultItem[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextEvaluationResultRanking;\n [key: string]: unknown;\n}\n\n/** Structural next result consumed by the evaluation runner. */\nexport interface ContextEvaluationNextResult {\n /** Value that configures or reports recommended for this contract. */\n recommended?: ContextEvaluationResultItem | null;\n /** Value that configures or reports ready for this contract. */\n ready?: ContextEvaluationResultItem[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextEvaluationResultRanking;\n [key: string]: unknown;\n}\n\n/** Read-only SDK surface required by the context evaluation runner. */\nexport interface ContextEvaluationReader {\n /** Value that configures or reports context for this contract. */\n context(\n options?: ContextEvaluationReadOptions,\n ): Promise<ContextEvaluationContextResult>;\n /** Value that configures or reports next for this contract. */\n next(\n options?: ContextEvaluationReadOptions,\n ): Promise<ContextEvaluationNextResult>;\n}\n\n/** One graded context or next scenario evaluated against a real SDK reader. */\nexport interface ContextEvaluationScenario {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports surface for this contract. */\n surface: ContextRelevanceSurface;\n /** Value that configures or reports options for this contract. */\n options?: ContextEvaluationReadOptions;\n /** Value that configures or reports judgments for this contract. */\n judgments: Record<string, number>;\n /** Value that configures or reports required ids for this contract. */\n required_ids?: string[];\n /** Value that configures or reports continuity ids for this contract. */\n continuity_ids?: string[];\n /** Value that configures or reports token budget for this contract. */\n token_budget: number;\n /** Value that configures or reports rationale for this contract. */\n rationale: string;\n}\n\n/** Per-item signal attribution retained by a context evaluation report. */\nexport interface ContextEvaluationAttribution {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports contributions for this contract. */\n contributions: ContextRelevanceContributions;\n}\n\n/** Result of executing and grading one context evaluation scenario. */\nexport interface ContextEvaluationScenarioReport {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports surface for this contract. */\n surface: ContextRelevanceSurface;\n /** Value that configures or reports rationale for this contract. */\n rationale: string;\n /** Value that configures or reports ranked ids for this contract. */\n ranked_ids: string[];\n /** Value that configures or reports actual tokens for this contract. */\n actual_tokens: number;\n /** Value that configures or reports metrics for this contract. */\n metrics: ContextRankingEvaluation;\n /** Value that configures or reports attribution for this contract. */\n attribution: ContextEvaluationAttribution[];\n}\n\n/** Minimum acceptable aggregate metrics for a context evaluation corpus. */\nexport interface ContextEvaluationThresholds {\n /** Value that configures or reports ndcg for this contract. */\n ndcg: number;\n /** Value that configures or reports reciprocal rank for this contract. */\n reciprocal_rank: number;\n /** Value that configures or reports required recall for this contract. */\n required_recall: number;\n /** Value that configures or reports continuity coverage for this contract. */\n continuity_coverage: number;\n /** Value that configures or reports token budget adherence for this contract. */\n token_budget_adherence: number;\n}\n\n/** Canonical aggregate metrics required by every context evaluation corpus. */\nexport const CONTEXT_EVALUATION_METRIC_NAMES = [\n \"ndcg\",\n \"reciprocal_rank\",\n \"required_recall\",\n \"continuity_coverage\",\n \"token_budget_adherence\",\n] as const satisfies readonly (keyof ContextEvaluationThresholds)[];\n\n/** Aggregate context evaluation report suitable for a CI quality gate. */\nexport interface ContextEvaluationCorpusReport {\n /** Number of scenario entries represented by this result. */\n scenario_count: number;\n /** Value that configures or reports aggregate for this contract. */\n aggregate: ContextEvaluationThresholds;\n /** Value that configures or reports scenarios for this contract. */\n scenarios: ContextEvaluationScenarioReport[];\n /** Value that configures or reports passed for this contract. */\n passed: boolean;\n /** Value that configures or reports failures for this contract. */\n failures: string[];\n}\n\nfunction ratioOfPresent(\n expected: readonly string[],\n actual: ReadonlySet<string>,\n): number {\n if (expected.length === 0) return 1;\n return expected.filter((id) => actual.has(id)).length / expected.length;\n}\n\n/** Evaluate one ranked context packet against graded human judgments. */\nexport function evaluateContextRanking(\n input: ContextRankingEvaluationInput,\n): ContextRankingEvaluation {\n if (\n !Number.isFinite(input.actual_tokens) ||\n input.actual_tokens < 0 ||\n !Number.isFinite(input.token_budget) ||\n input.token_budget <= 0\n ) {\n throw new TypeError(\n \"Context ranking token counts require actual_tokens >= 0 and token_budget > 0\",\n );\n }\n const judgments = input.judgments ?? {};\n const gains = input.ranked_ids.map((id) => Math.max(0, judgments[id] ?? 0));\n const idealGains = Object.values(judgments)\n .map((grade) => Math.max(0, grade))\n .sort((left, right) => right - left)\n .slice(0, gains.length || 1);\n const discountedGain = (values: readonly number[]) =>\n values.reduce(\n (total, grade, index) => total + (2 ** grade - 1) / Math.log2(index + 2),\n 0,\n );\n const ideal = discountedGain(idealGains);\n const firstRelevant = gains.findIndex((grade) => grade > 0);\n const actualIds = new Set(input.ranked_ids);\n const withinBudget = input.actual_tokens <= input.token_budget;\n return {\n ndcg: ideal === 0 ? 1 : discountedGain(gains) / ideal,\n reciprocal_rank: firstRelevant < 0 ? 0 : 1 / (firstRelevant + 1),\n required_recall: ratioOfPresent(input.required_ids ?? [], actualIds),\n continuity_coverage: ratioOfPresent(input.continuity_ids ?? [], actualIds),\n token_budget_adherence: withinBudget\n ? 1\n : input.token_budget / input.actual_tokens,\n within_token_budget: withinBudget,\n };\n}\n\nfunction estimateJsonTokens(value: unknown): number {\n return Math.ceil(\n JSON_TOKEN_ENCODER.encode(JSON.stringify(value)).byteLength / 4,\n );\n}\n\nfunction roundEvaluationMetric(value: number): number {\n return Math.round(value * 10_000) / 10_000;\n}\n\nfunction rankingPayloadForScenario(\n result: ContextEvaluationContextResult | ContextEvaluationNextResult,\n surface: ContextRelevanceSurface,\n): { rankedIds: string[]; attribution: ContextEvaluationAttribution[] } {\n const rankedIds =\n surface === \"context\"\n ? [\n ...((result as ContextEvaluationContextResult).high_level ?? []),\n ...((result as ContextEvaluationContextResult).low_level ?? []),\n ...((result as ContextEvaluationContextResult).blocked_fallback ??\n []),\n ].map((item) => item.id)\n : [\n ...((result as ContextEvaluationNextResult).recommended\n ? [\n (result as ContextEvaluationNextResult)\n .recommended as ContextEvaluationResultItem,\n ]\n : []),\n ...((result as ContextEvaluationNextResult).ready ?? []),\n ].map((item) => item.id);\n const servedIds = new Set(rankedIds);\n const attribution = (result.ranking?.items ?? [])\n .filter((item) => servedIds.has(item.id))\n .map((item) => ({ id: item.id, contributions: item.contributions }));\n return { rankedIds, attribution };\n}\n\n/** Execute one graded scenario through public SDK context/next read primitives. */\nexport async function runContextEvaluationScenario(\n scenario: ContextEvaluationScenario,\n reader: ContextEvaluationReader,\n): Promise<ContextEvaluationScenarioReport> {\n if (\n scenario.id.trim().length === 0 ||\n scenario.rationale.trim().length === 0\n ) {\n throw new TypeError(\n \"Context evaluation scenarios require non-empty id and rationale values\",\n );\n }\n const result =\n scenario.surface === \"context\"\n ? await reader.context({ ...scenario.options, explainRanking: true })\n : await reader.next({ ...scenario.options, explainRanking: true });\n const { rankedIds, attribution } = rankingPayloadForScenario(\n result,\n scenario.surface,\n );\n const packet = { ...result, ranking: undefined };\n const actualTokens = estimateJsonTokens(packet);\n return {\n id: scenario.id,\n surface: scenario.surface,\n rationale: scenario.rationale,\n ranked_ids: rankedIds,\n actual_tokens: actualTokens,\n metrics: evaluateContextRanking({\n ranked_ids: rankedIds,\n judgments: scenario.judgments,\n required_ids: scenario.required_ids,\n continuity_ids: scenario.continuity_ids,\n actual_tokens: actualTokens,\n token_budget: scenario.token_budget,\n }),\n attribution,\n };\n}\n\n/** Aggregate scenario reports and evaluate every metric against explicit thresholds. */\nexport function summarizeContextEvaluationReports(\n reports: readonly ContextEvaluationScenarioReport[],\n thresholds: ContextEvaluationThresholds,\n): ContextEvaluationCorpusReport {\n if (reports.length === 0) {\n throw new TypeError(\n \"Context evaluation requires at least one scenario report\",\n );\n }\n const metrics = CONTEXT_EVALUATION_METRIC_NAMES;\n for (const metric of metrics) {\n if (!Number.isFinite(thresholds[metric])) {\n throw new TypeError(\n `Context evaluation threshold ${metric} must be a finite number`,\n );\n }\n }\n const aggregate = Object.fromEntries(\n metrics.map((metric) => [\n metric,\n roundEvaluationMetric(\n reports.reduce((total, report) => total + report.metrics[metric], 0) /\n reports.length,\n ),\n ]),\n ) as unknown as ContextEvaluationThresholds;\n const failures = metrics\n .filter((metric) => aggregate[metric] < thresholds[metric])\n .map((metric) => `${metric}:${aggregate[metric]}<${thresholds[metric]}`);\n return {\n scenario_count: reports.length,\n aggregate,\n scenarios: [...reports],\n passed: failures.length === 0,\n failures,\n };\n}\n\n/** Execute a same-workspace scenario corpus through public SDK read primitives. */\nexport async function runContextEvaluationCorpus(\n scenarios: readonly ContextEvaluationScenario[],\n reader: ContextEvaluationReader,\n thresholds: ContextEvaluationThresholds,\n): Promise<ContextEvaluationCorpusReport> {\n const reports: ContextEvaluationScenarioReport[] = [];\n for (const scenario of scenarios) {\n reports.push(await runContextEvaluationScenario(scenario, reader));\n }\n return summarizeContextEvaluationReports(reports, thresholds);\n}\n"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGvF,wEAAwE;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,YAAY;IACZ,SAAS;IACT,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,mBAAmB;IACnB,eAAe;IACf,mBAAmB;IACnB,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;CACb,CAAC;AAmCX,SAAS,kBAAkB,CAAC,KAAc,EAAE,OAAe;IACzD,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC;IACrH,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,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AAO,CAAC,MAAM,CACjB;KACF,CAAC,CACuC,CAAC;IAC5C,MAAM,QAAQ,GAAG,OAAO;SACrB,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;SAC1D,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3E,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,MAAM;QAC9B,SAAS;QACT,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC;QACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;QAC7B,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,SAA+C,EAC/C,MAA+B,EAC/B,UAAuC;IAEvC,MAAM,OAAO,GAAsC,EAAE,CAAC;IACtD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,MAAM,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,iCAAiC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC","debugId":"833cf230-b0c8-51f0-822e-1f27f0574971"}
1
+ {"version":3,"file":"context-relevance.js","sources":["sdk/context-relevance.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module sdk/context-relevance\n *\n * Public, deterministic context-ranking and evaluation primitives. The scorer\n * accepts already-derived signals so package authors can reuse the same model\n * with core, extension, or project-specific feature stores.\n */\nimport { runActiveServiceOverride } from \"../core/extensions/index.js\";\nimport {\n normalizeStatusForRegistry,\n normalizeStatusInput,\n} from \"../core/item/status.js\";\nimport type { RuntimeStatusRegistry } from \"../core/schema/runtime-schema.js\";\nimport { compareTimestampStrings, resolveIsoOrRelative } from \"../core/shared/time.js\";\nimport type { ItemMetadata } from \"../types/index.js\";\n\n/** Canonical signal keys understood by the built-in relevance model. */\nexport const CONTEXT_RELEVANCE_SIGNAL_NAMES = [\n \"structural\",\n \"recency\",\n \"activity_density\",\n \"graph_proximity\",\n \"claim_focus\",\n \"priority_pressure\",\n \"risk_pressure\",\n \"deadline_pressure\",\n \"knowledge_density\",\n \"author_affinity\",\n \"usage_affinity\",\n \"semantic_similarity\",\n] as const;\n\n/** A normalized signal consumed by the built-in context relevance scorer. */\nexport type ContextRelevanceSignalName =\n (typeof CONTEXT_RELEVANCE_SIGNAL_NAMES)[number];\n\n/** Normalized candidate features; omitted signals are excluded from weighting. */\nexport type ContextRelevanceSignals = Partial<\n Record<Exclude<ContextRelevanceSignalName, \"structural\">, number>\n>;\n\nconst NO_CONTEXT_AUTHOR = Symbol(\"no-context-author\");\nconst NO_ITEM_ASSIGNEE = Symbol(\"no-item-assignee\");\n\nfunction normalizeContextActor(value: unknown, missingValue: symbol): string | symbol {\n if (typeof value !== \"string\") return missingValue;\n const normalized = value.trim().toLowerCase();\n return normalized.length > 0 ? normalized : missingValue;\n}\n\n/** A project-management object and its derived relevance signals. */\nexport interface ContextRelevanceCandidate<TItem> {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports item for this contract. */\n item: TItem;\n /** Value that configures or reports signals for this contract. */\n signals?: ContextRelevanceSignals;\n}\n\n/** Item candidate whose built-in metadata derivation always supplies signals. */\nexport interface ItemContextRelevanceCandidate\n extends ContextRelevanceCandidate<ItemMetadata> {\n /** Complete built-in derivation result, with unavailable signals omitted by value. */\n signals: ContextRelevanceSignals;\n}\n\n/** Inputs that make item-signal derivation deterministic and host-configurable. */\nexport interface BuildItemContextRelevanceCandidatesOptions {\n /** Workspace lifecycle registry, including custom in-progress aliases. */\n statusRegistry: RuntimeStatusRegistry;\n /** Stable clock used for deadline pressure. */\n now: string;\n /** Optional caller identity used for assignment affinity. */\n author?: string;\n /** Optional derived served-then-used affinity by item id. */\n usageAffinity?: Readonly<Record<string, number>>;\n /** Optional caller-derived semantic similarity by item id. */\n semanticSimilarity?: Readonly<Record<string, number>>;\n /** Optional index-derived activity density by item id. */\n activityDensity?: Readonly<Record<string, number>>;\n /** Optional index-derived graph proximity by item id. */\n graphProximity?: Readonly<Record<string, number>>;\n /** Optional host-derived claim or focus affinity by item id. */\n claimFocus?: Readonly<Record<string, number>>;\n /** Optional index-derived knowledge density by item id. */\n knowledgeDensity?: Readonly<Record<string, number>>;\n /** Optional history-derived author affinity by item id. */\n authorAffinity?: Readonly<Record<string, number>>;\n}\n\nfunction normalizedPressure(value: unknown, maximum: number): number {\n const parsed = typeof value === \"number\" ? value : typeof value === \"string\" ? Number.parseFloat(value) : Number.NaN;\n return Number.isFinite(parsed) ? 1 - Math.min(Math.max(parsed, 0), maximum) / maximum : 0;\n}\n\nfunction deadlinePressure(deadline: unknown, nowMs: number): number {\n const deadlineMs = typeof deadline === \"string\" ? Date.parse(deadline) : deadline instanceof Date ? deadline.getTime() : typeof deadline === \"number\" ? deadline : Number.NaN;\n if (!Number.isFinite(deadlineMs) || !Number.isFinite(nowMs)) return 0;\n const days = (deadlineMs - nowMs) / 86_400_000;\n return days <= 0 ? 1 : 1 / (1 + days / 30);\n}\n\nfunction riskPressure(risk: ItemMetadata[\"risk\"]): number {\n const normalized = typeof risk === \"string\" ? risk.trim().toLowerCase() : undefined;\n if (normalized === \"critical\" || normalized === \"high\") return 1;\n if (normalized === \"medium\") return 0.5;\n return normalized === \"low\" ? 0.1 : 0;\n}\n\nfunction derivedSignalOrFallback(\n values: Readonly<Record<string, number>> | undefined,\n id: string,\n fallback: number,\n): number {\n return values?.[id] ?? fallback;\n}\n\n/**\n * Derive the canonical metadata signals consumed by `pm context` and `pm next`.\n * Extensions can pair this with {@link scoreContextCandidatesWithActiveExtensions}\n * to reproduce built-in ranking without private imports or subprocesses.\n */\nexport function buildItemContextRelevanceCandidates(\n items: readonly ItemMetadata[],\n options: BuildItemContextRelevanceCandidatesOptions,\n): ItemContextRelevanceCandidate[] {\n const sortableTimestamp = (value: unknown): string => {\n if (typeof value !== \"string\") return \"\";\n try {\n return resolveIsoOrRelative(value, new Date(Number.NaN), \"updated_at\");\n } catch {\n return \"\";\n }\n };\n const recencyOrder = [...items].sort((left, right) => {\n const leftTime = sortableTimestamp(left.updated_at);\n const rightTime = sortableTimestamp(right.updated_at);\n return compareTimestampStrings(rightTime, leftTime) || left.id.localeCompare(right.id);\n });\n const recencyRank = new Map(recencyOrder.map((item, index) => [item.id, index]));\n const denominator = Math.max(items.length - 1, 1);\n const normalizedAuthor = normalizeContextActor(options.author, NO_CONTEXT_AUTHOR);\n const inProgressStatus = normalizeStatusInput(\"in_progress\", options.statusRegistry);\n const nowMs = Date.parse(options.now);\n return items.map((item) => {\n const assigned = normalizeContextActor(item.assignee, NO_ITEM_ASSIGNEE) === normalizedAuthor;\n const knowledgeEntries = (item.comments?.length ?? 0) + (item.notes?.length ?? 0) + (item.learnings?.length ?? 0);\n return {\n id: item.id,\n item,\n signals: {\n recency: items.length === 1 ? 1 : 1 - (recencyRank.get(item.id) as number) / denominator,\n activity_density: options.activityDensity?.[item.id],\n graph_proximity: derivedSignalOrFallback(options.graphProximity, item.id, item.parent ? 0.3 : 0),\n claim_focus: derivedSignalOrFallback(options.claimFocus, item.id, normalizeStatusForRegistry(item.status, options.statusRegistry) === inProgressStatus ? 1 : assigned ? 0.75 : 0),\n priority_pressure: normalizedPressure(item.priority, 4),\n risk_pressure: riskPressure(item.risk),\n deadline_pressure: deadlinePressure(item.deadline, nowMs),\n knowledge_density: derivedSignalOrFallback(options.knowledgeDensity, item.id, Math.min(knowledgeEntries / 5, 1)),\n author_affinity: derivedSignalOrFallback(options.authorAffinity, item.id, assigned ? 1 : 0),\n usage_affinity: options.usageAffinity?.[item.id],\n semantic_similarity: options.semanticSimilarity?.[item.id],\n },\n };\n });\n}\n\n/** Per-signal weighted contributions used to explain a ranked result. */\nexport type ContextRelevanceContributions = Record<string, number>;\n\n/** One ranked candidate with deterministic score and explanation metadata. */\nexport interface RankedContextCandidate<\n TItem,\n> extends ContextRelevanceCandidate<TItem> {\n /** Value that configures or reports baseline rank for this contract. */\n baseline_rank: number;\n /** Value that configures or reports rank for this contract. */\n rank: number;\n /** Value that configures or reports score for this contract. */\n score: number;\n /** Value that configures or reports contributions for this contract. */\n contributions: ContextRelevanceContributions;\n}\n\n/** Complete output from a context relevance scorer. */\nexport interface ContextRelevanceReport<TItem> {\n /** Value that configures or reports model for this contract. */\n model: string;\n /** Value that configures or reports available signals for this contract. */\n available_signals: ContextRelevanceSignalName[];\n /** Value that configures or reports ranked for this contract. */\n ranked: RankedContextCandidate<TItem>[];\n /** Value that configures or reports warnings for this contract. */\n warnings?: string[];\n}\n\n/** Minimal custom score returned by a replacement or wrapper scorer. */\nexport interface ContextRelevanceCustomScore {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports score for this contract. */\n score: number;\n}\n\n/** Input provided to a custom scorer, including the deterministic default. */\nexport interface ContextRelevanceScorerInput<TItem> {\n /** Value that configures or reports candidates for this contract. */\n candidates: readonly ContextRelevanceCandidate<TItem>[];\n /** Fallback report used when callers do not provide an override. */\n default_report: ContextRelevanceReport<TItem>;\n}\n\n/** Replaceable package/extension scorer contract. */\nexport type ContextRelevanceScorer<TItem> = (\n input: ContextRelevanceScorerInput<TItem>,\n) =>\n | readonly ContextRelevanceCustomScore[]\n | Promise<readonly ContextRelevanceCustomScore[]>;\n\n/** Options for the built-in or replaceable context relevance scorer. */\nexport interface ScoreContextCandidatesOptions<TItem> {\n /** Value that configures or reports weights for this contract. */\n weights?: Partial<Record<ContextRelevanceSignalName, number>>;\n /** Value that configures or reports scorer for this contract. */\n scorer?: ContextRelevanceScorer<TItem>;\n}\n\n/** Governed extension service used to replace or wrap context ranking. */\nexport const CONTEXT_RELEVANCE_SERVICE = \"context_relevance\" as const;\n\n/** Command surface requesting an active extension relevance override. */\nexport type ContextRelevanceSurface = \"context\" | \"next\";\n\nconst DEFAULT_CONTEXT_RELEVANCE_WEIGHTS: Record<\n ContextRelevanceSignalName,\n number\n> = {\n structural: 0.4,\n recency: 0.35,\n activity_density: 0.25,\n graph_proximity: 0.15,\n claim_focus: 0.6,\n priority_pressure: 0.35,\n risk_pressure: 0.2,\n deadline_pressure: 0.45,\n knowledge_density: 0.25,\n author_affinity: 0.2,\n usage_affinity: 0.3,\n semantic_similarity: 0.5,\n};\nconst JSON_TOKEN_ENCODER = new TextEncoder();\n\nfunction assertCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n): void {\n const ids = new Set<string>();\n for (const candidate of candidates) {\n if (\n typeof candidate.id !== \"string\" ||\n candidate.id.trim().length === 0 ||\n ids.has(candidate.id)\n ) {\n throw new TypeError(\n \"Context relevance candidates require unique non-empty ids\",\n );\n }\n ids.add(candidate.id);\n for (const [signal, value] of Object.entries(candidate.signals ?? {})) {\n if (\n signal === \"structural\" ||\n !CONTEXT_RELEVANCE_SIGNAL_NAMES.includes(\n signal as ContextRelevanceSignalName,\n )\n ) {\n throw new TypeError(`Unknown context relevance signal: ${signal}`);\n }\n if (value === undefined) continue;\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new TypeError(\n `Context relevance signal ${signal} must be a finite number from 0 to 1`,\n );\n }\n }\n }\n}\n\nfunction resolveWeights(\n overrides: Partial<Record<ContextRelevanceSignalName, number>> | undefined,\n): Record<ContextRelevanceSignalName, number> {\n const weights = { ...DEFAULT_CONTEXT_RELEVANCE_WEIGHTS };\n for (const [signal, weight] of Object.entries(overrides ?? {})) {\n if (\n weight !== undefined &&\n CONTEXT_RELEVANCE_SIGNAL_NAMES.includes(\n signal as ContextRelevanceSignalName,\n )\n ) {\n weights[signal as ContextRelevanceSignalName] = weight;\n }\n }\n for (const [signal, weight] of Object.entries(weights)) {\n if (!Number.isFinite(weight) || weight < 0) {\n throw new TypeError(\n `Context relevance weight ${signal} must be a finite non-negative number`,\n );\n }\n }\n return weights;\n}\n\n/** Score candidates with pm's deterministic weighted model. Candidate order is the structural baseline and remains unchanged when no advanced signals exist. */\nexport function defaultScoreContextCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: Pick<ScoreContextCandidatesOptions<TItem>, \"weights\"> = {},\n): ContextRelevanceReport<TItem> {\n assertCandidates(candidates);\n const weights = resolveWeights(options.weights);\n const denominator = Math.max(candidates.length - 1, 1);\n const available = new Set<ContextRelevanceSignalName>([\"structural\"]);\n for (const candidate of candidates) {\n for (const [signal, value] of Object.entries(candidate.signals ?? {})) {\n if (value !== undefined)\n available.add(signal as ContextRelevanceSignalName);\n }\n }\n const availableSignals = CONTEXT_RELEVANCE_SIGNAL_NAMES.filter((signal) =>\n available.has(signal),\n );\n const scored = candidates.map(\n (candidate, index): RankedContextCandidate<TItem> => {\n const signalValues: Partial<Record<ContextRelevanceSignalName, number>> =\n {\n structural: candidates.length === 1 ? 1 : 1 - index / denominator,\n ...candidate.signals,\n };\n const contributions: ContextRelevanceContributions = {};\n let weightedScore = 0;\n let totalWeight = 0;\n for (const signal of availableSignals) {\n const value = signalValues[signal];\n if (value === undefined) continue;\n const contribution = value * weights[signal];\n contributions[signal] = contribution;\n weightedScore += contribution;\n totalWeight += weights[signal];\n }\n return {\n ...candidate,\n baseline_rank: index + 1,\n rank: 0,\n score: totalWeight === 0 ? 0 : weightedScore / totalWeight,\n contributions,\n };\n },\n );\n scored.sort(\n (left, right) =>\n right.score - left.score || left.baseline_rank - right.baseline_rank,\n );\n scored.forEach((entry, index) => {\n entry.rank = index + 1;\n });\n return {\n model: \"default-weighted-v1\",\n available_signals: availableSignals,\n ranked: scored,\n };\n}\n\n/** Score candidates with the default model or a validated replacement/wrapper. */\nexport async function scoreContextCandidates<TItem>(\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: ScoreContextCandidatesOptions<TItem> = {},\n): Promise<ContextRelevanceReport<TItem>> {\n const defaultReport = defaultScoreContextCandidates(candidates, options);\n if (!options.scorer) return defaultReport;\n const customScores = await options.scorer({\n candidates,\n default_report: defaultReport,\n });\n const scoreById = new Map<string, number>();\n for (const entry of customScores) {\n if (scoreById.has(entry.id) || !Number.isFinite(entry.score)) {\n throw new TypeError(\n \"Context relevance scorer must return one finite score for every candidate\",\n );\n }\n scoreById.set(entry.id, entry.score);\n }\n if (\n scoreById.size !== candidates.length ||\n candidates.some((candidate) => !scoreById.has(candidate.id))\n ) {\n throw new TypeError(\n \"Context relevance scorer must return one finite score for every candidate\",\n );\n }\n const ranked = defaultReport.ranked.map((entry) => {\n const score = scoreById.get(entry.id) as number;\n return { ...entry, score, contributions: { custom: score } };\n });\n ranked.sort(\n (left, right) =>\n right.score - left.score || left.baseline_rank - right.baseline_rank,\n );\n ranked.forEach((entry, index) => {\n entry.rank = index + 1;\n });\n return {\n model: \"custom\",\n available_signals: defaultReport.available_signals,\n ranked,\n };\n}\n\n/** Score command candidates through the public default model and then the active governed `context_relevance` service override, when one is registered. */\nexport async function scoreContextCandidatesWithActiveExtensions<TItem>(\n surface: ContextRelevanceSurface,\n candidates: readonly ContextRelevanceCandidate<TItem>[],\n options: Pick<ScoreContextCandidatesOptions<TItem>, \"weights\"> = {},\n): Promise<ContextRelevanceReport<TItem>> {\n const defaultReport = defaultScoreContextCandidates(candidates, options);\n const override = await runActiveServiceOverride(CONTEXT_RELEVANCE_SERVICE, {\n surface,\n candidates,\n default_report: defaultReport,\n });\n if (!override.handled) {\n return override.warnings.length > 0\n ? { ...defaultReport, warnings: override.warnings }\n : defaultReport;\n }\n if (\n !Array.isArray(override.result) ||\n !override.result.every(\n (entry) =>\n typeof entry === \"object\" &&\n entry !== null &&\n typeof (entry as { id?: unknown }).id === \"string\" &&\n typeof (entry as { score?: unknown }).score === \"number\" &&\n Number.isFinite((entry as { score: number }).score),\n )\n ) {\n return {\n ...defaultReport,\n warnings: [\n ...override.warnings,\n \"extension_context_relevance_invalid_result\",\n ],\n };\n }\n try {\n const report = await scoreContextCandidates(candidates, {\n ...options,\n scorer: () => override.result as ContextRelevanceCustomScore[],\n });\n return override.warnings.length > 0\n ? { ...report, warnings: override.warnings }\n : report;\n } catch {\n return {\n ...defaultReport,\n warnings: [\n ...override.warnings,\n \"extension_context_relevance_invalid_result\",\n ],\n };\n }\n}\n\n/** Input for rank-aware context/next quality evaluation. */\nexport interface ContextRankingEvaluationInput {\n /** Value that configures or reports ranked ids for this contract. */\n ranked_ids: string[];\n /** Value that configures or reports judgments for this contract. */\n judgments: Record<string, number>;\n /** Value that configures or reports required ids for this contract. */\n required_ids?: string[];\n /** Value that configures or reports continuity ids for this contract. */\n continuity_ids?: string[];\n /** Value that configures or reports actual tokens for this contract. */\n actual_tokens: number;\n /** Value that configures or reports token budget for this contract. */\n token_budget: number;\n}\n\n/** Rank-quality, continuity, recall, and token-budget metrics for one scenario. */\nexport interface ContextRankingEvaluation {\n /** Value that configures or reports ndcg for this contract. */\n ndcg: number;\n /** Value that configures or reports reciprocal rank for this contract. */\n reciprocal_rank: number;\n /** Value that configures or reports required recall for this contract. */\n required_recall: number;\n /** Value that configures or reports continuity coverage for this contract. */\n continuity_coverage: number;\n /** Value that configures or reports token budget adherence for this contract. */\n token_budget_adherence: number;\n /** Value that configures or reports within token budget for this contract. */\n within_token_budget: boolean;\n}\n\n/** Flexible read options accepted by context evaluation scenarios. */\nexport interface ContextEvaluationReadOptions {\n /** Value that configures or reports explain ranking for this contract. */\n explainRanking?: boolean;\n [key: string]: unknown;\n}\n\n/** Minimal item identity consumed by the context evaluation runner. */\nexport interface ContextEvaluationResultItem {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n}\n\n/** Optional scorer attribution returned by an evaluated read primitive. */\nexport interface ContextEvaluationResultRanking {\n /** Value that configures or reports items for this contract. */\n items?: Array<{ id: string; contributions: ContextRelevanceContributions }>;\n}\n\n/** Structural context result consumed by the evaluation runner. */\nexport interface ContextEvaluationContextResult {\n /** Value that configures or reports high level for this contract. */\n high_level?: ContextEvaluationResultItem[];\n /** Value that configures or reports low level for this contract. */\n low_level?: ContextEvaluationResultItem[];\n /** Value that configures or reports blocked fallback for this contract. */\n blocked_fallback?: ContextEvaluationResultItem[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextEvaluationResultRanking;\n [key: string]: unknown;\n}\n\n/** Structural next result consumed by the evaluation runner. */\nexport interface ContextEvaluationNextResult {\n /** Value that configures or reports recommended for this contract. */\n recommended?: ContextEvaluationResultItem | null;\n /** Value that configures or reports ready for this contract. */\n ready?: ContextEvaluationResultItem[];\n /** Value that configures or reports ranking for this contract. */\n ranking?: ContextEvaluationResultRanking;\n [key: string]: unknown;\n}\n\n/** Read-only SDK surface required by the context evaluation runner. */\nexport interface ContextEvaluationReader {\n /** Value that configures or reports context for this contract. */\n context(\n options?: ContextEvaluationReadOptions,\n ): Promise<ContextEvaluationContextResult>;\n /** Value that configures or reports next for this contract. */\n next(\n options?: ContextEvaluationReadOptions,\n ): Promise<ContextEvaluationNextResult>;\n}\n\n/** One graded context or next scenario evaluated against a real SDK reader. */\nexport interface ContextEvaluationScenario {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports surface for this contract. */\n surface: ContextRelevanceSurface;\n /** Value that configures or reports options for this contract. */\n options?: ContextEvaluationReadOptions;\n /** Value that configures or reports judgments for this contract. */\n judgments: Record<string, number>;\n /** Value that configures or reports required ids for this contract. */\n required_ids?: string[];\n /** Value that configures or reports continuity ids for this contract. */\n continuity_ids?: string[];\n /** Value that configures or reports token budget for this contract. */\n token_budget: number;\n /** Value that configures or reports rationale for this contract. */\n rationale: string;\n}\n\n/** Per-item signal attribution retained by a context evaluation report. */\nexport interface ContextEvaluationAttribution {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports contributions for this contract. */\n contributions: ContextRelevanceContributions;\n}\n\n/** Result of executing and grading one context evaluation scenario. */\nexport interface ContextEvaluationScenarioReport {\n /** Stable identifier used to reference this record across commands and storage. */\n id: string;\n /** Value that configures or reports surface for this contract. */\n surface: ContextRelevanceSurface;\n /** Value that configures or reports rationale for this contract. */\n rationale: string;\n /** Value that configures or reports ranked ids for this contract. */\n ranked_ids: string[];\n /** Value that configures or reports actual tokens for this contract. */\n actual_tokens: number;\n /** Value that configures or reports metrics for this contract. */\n metrics: ContextRankingEvaluation;\n /** Value that configures or reports attribution for this contract. */\n attribution: ContextEvaluationAttribution[];\n}\n\n/** Minimum acceptable aggregate metrics for a context evaluation corpus. */\nexport interface ContextEvaluationThresholds {\n /** Value that configures or reports ndcg for this contract. */\n ndcg: number;\n /** Value that configures or reports reciprocal rank for this contract. */\n reciprocal_rank: number;\n /** Value that configures or reports required recall for this contract. */\n required_recall: number;\n /** Value that configures or reports continuity coverage for this contract. */\n continuity_coverage: number;\n /** Value that configures or reports token budget adherence for this contract. */\n token_budget_adherence: number;\n}\n\n/** Canonical aggregate metrics required by every context evaluation corpus. */\nexport const CONTEXT_EVALUATION_METRIC_NAMES = [\n \"ndcg\",\n \"reciprocal_rank\",\n \"required_recall\",\n \"continuity_coverage\",\n \"token_budget_adherence\",\n] as const satisfies readonly (keyof ContextEvaluationThresholds)[];\n\n/** Aggregate context evaluation report suitable for a CI quality gate. */\nexport interface ContextEvaluationCorpusReport {\n /** Number of scenario entries represented by this result. */\n scenario_count: number;\n /** Value that configures or reports aggregate for this contract. */\n aggregate: ContextEvaluationThresholds;\n /** Value that configures or reports scenarios for this contract. */\n scenarios: ContextEvaluationScenarioReport[];\n /** Value that configures or reports passed for this contract. */\n passed: boolean;\n /** Value that configures or reports failures for this contract. */\n failures: string[];\n}\n\nfunction ratioOfPresent(\n expected: readonly string[],\n actual: ReadonlySet<string>,\n): number {\n if (expected.length === 0) return 1;\n return expected.filter((id) => actual.has(id)).length / expected.length;\n}\n\n/** Evaluate one ranked context packet against graded human judgments. */\nexport function evaluateContextRanking(\n input: ContextRankingEvaluationInput,\n): ContextRankingEvaluation {\n if (\n !Number.isFinite(input.actual_tokens) ||\n input.actual_tokens < 0 ||\n !Number.isFinite(input.token_budget) ||\n input.token_budget <= 0\n ) {\n throw new TypeError(\n \"Context ranking token counts require actual_tokens >= 0 and token_budget > 0\",\n );\n }\n const judgments = input.judgments ?? {};\n const gains = input.ranked_ids.map((id) => Math.max(0, judgments[id] ?? 0));\n const idealGains = Object.values(judgments)\n .map((grade) => Math.max(0, grade))\n .sort((left, right) => right - left)\n .slice(0, gains.length || 1);\n const discountedGain = (values: readonly number[]) =>\n values.reduce(\n (total, grade, index) => total + (2 ** grade - 1) / Math.log2(index + 2),\n 0,\n );\n const ideal = discountedGain(idealGains);\n const firstRelevant = gains.findIndex((grade) => grade > 0);\n const actualIds = new Set(input.ranked_ids);\n const withinBudget = input.actual_tokens <= input.token_budget;\n return {\n ndcg: ideal === 0 ? 1 : discountedGain(gains) / ideal,\n reciprocal_rank: firstRelevant < 0 ? 0 : 1 / (firstRelevant + 1),\n required_recall: ratioOfPresent(input.required_ids ?? [], actualIds),\n continuity_coverage: ratioOfPresent(input.continuity_ids ?? [], actualIds),\n token_budget_adherence: withinBudget\n ? 1\n : input.token_budget / input.actual_tokens,\n within_token_budget: withinBudget,\n };\n}\n\nfunction estimateJsonTokens(value: unknown): number {\n return Math.ceil(\n JSON_TOKEN_ENCODER.encode(JSON.stringify(value)).byteLength / 4,\n );\n}\n\nfunction roundEvaluationMetric(value: number): number {\n return Math.round(value * 10_000) / 10_000;\n}\n\nfunction rankingPayloadForScenario(\n result: ContextEvaluationContextResult | ContextEvaluationNextResult,\n surface: ContextRelevanceSurface,\n): { rankedIds: string[]; attribution: ContextEvaluationAttribution[] } {\n const rankedIds =\n surface === \"context\"\n ? [\n ...((result as ContextEvaluationContextResult).high_level ?? []),\n ...((result as ContextEvaluationContextResult).low_level ?? []),\n ...((result as ContextEvaluationContextResult).blocked_fallback ??\n []),\n ].map((item) => item.id)\n : [\n ...((result as ContextEvaluationNextResult).recommended\n ? [\n (result as ContextEvaluationNextResult)\n .recommended as ContextEvaluationResultItem,\n ]\n : []),\n ...((result as ContextEvaluationNextResult).ready ?? []),\n ].map((item) => item.id);\n const servedIds = new Set(rankedIds);\n const attribution = (result.ranking?.items ?? [])\n .filter((item) => servedIds.has(item.id))\n .map((item) => ({ id: item.id, contributions: item.contributions }));\n return { rankedIds, attribution };\n}\n\n/** Execute one graded scenario through public SDK context/next read primitives. */\nexport async function runContextEvaluationScenario(\n scenario: ContextEvaluationScenario,\n reader: ContextEvaluationReader,\n): Promise<ContextEvaluationScenarioReport> {\n if (\n scenario.id.trim().length === 0 ||\n scenario.rationale.trim().length === 0\n ) {\n throw new TypeError(\n \"Context evaluation scenarios require non-empty id and rationale values\",\n );\n }\n const result =\n scenario.surface === \"context\"\n ? await reader.context({ ...scenario.options, explainRanking: true })\n : await reader.next({ ...scenario.options, explainRanking: true });\n const { rankedIds, attribution } = rankingPayloadForScenario(\n result,\n scenario.surface,\n );\n const packet = { ...result, ranking: undefined };\n const actualTokens = estimateJsonTokens(packet);\n return {\n id: scenario.id,\n surface: scenario.surface,\n rationale: scenario.rationale,\n ranked_ids: rankedIds,\n actual_tokens: actualTokens,\n metrics: evaluateContextRanking({\n ranked_ids: rankedIds,\n judgments: scenario.judgments,\n required_ids: scenario.required_ids,\n continuity_ids: scenario.continuity_ids,\n actual_tokens: actualTokens,\n token_budget: scenario.token_budget,\n }),\n attribution,\n };\n}\n\n/** Aggregate scenario reports and evaluate every metric against explicit thresholds. */\nexport function summarizeContextEvaluationReports(\n reports: readonly ContextEvaluationScenarioReport[],\n thresholds: ContextEvaluationThresholds,\n): ContextEvaluationCorpusReport {\n if (reports.length === 0) {\n throw new TypeError(\n \"Context evaluation requires at least one scenario report\",\n );\n }\n const metrics = CONTEXT_EVALUATION_METRIC_NAMES;\n for (const metric of metrics) {\n if (!Number.isFinite(thresholds[metric])) {\n throw new TypeError(\n `Context evaluation threshold ${metric} must be a finite number`,\n );\n }\n }\n const aggregate = Object.fromEntries(\n metrics.map((metric) => [\n metric,\n roundEvaluationMetric(\n reports.reduce((total, report) => total + report.metrics[metric], 0) /\n reports.length,\n ),\n ]),\n ) as unknown as ContextEvaluationThresholds;\n const failures = metrics\n .filter((metric) => aggregate[metric] < thresholds[metric])\n .map((metric) => `${metric}:${aggregate[metric]}<${thresholds[metric]}`);\n return {\n scenario_count: reports.length,\n aggregate,\n scenarios: [...reports],\n passed: failures.length === 0,\n failures,\n };\n}\n\n/** Execute a same-workspace scenario corpus through public SDK read primitives. */\nexport async function runContextEvaluationCorpus(\n scenarios: readonly ContextEvaluationScenario[],\n reader: ContextEvaluationReader,\n thresholds: ContextEvaluationThresholds,\n): Promise<ContextEvaluationCorpusReport> {\n const reports: ContextEvaluationScenarioReport[] = [];\n for (const scenario of scenarios) {\n reports.push(await runContextEvaluationScenario(scenario, reader));\n }\n return summarizeContextEvaluationReports(reports, thresholds);\n}\n"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;AACH,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGvF,wEAAwE;AACxE,MAAM,CAAC,MAAM,8BAA8B,GAAG;IAC5C,YAAY;IACZ,SAAS;IACT,kBAAkB;IAClB,iBAAiB;IACjB,aAAa;IACb,mBAAmB;IACnB,eAAe;IACf,mBAAmB;IACnB,mBAAmB;IACnB,iBAAiB;IACjB,gBAAgB;IAChB,qBAAqB;CACb,CAAC;AAWX,MAAM,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AACtD,MAAM,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEpD,SAAS,qBAAqB,CAAC,KAAc,EAAE,YAAoB;IACjE,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,YAAY,CAAC;IACnD,MAAM,UAA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AC,CAAC,MAAM,EAAE,EAAE,CAAC,GAAG,MAAM,IAAI,SAAS,CAAC,MAAM,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC3E,OAAO;QACL,cAAc,EAAE,OAAO,CAAC,MAAM;QAC9B,SAAS;QACT,SAAS,EAAE,CAAC,GAAG,OAAO,CAAC;QACvB,MAAM,EAAE,QAAQ,CAAC,MAAM,KAAK,CAAC;QAC7B,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,SAA+C,EAC/C,MAA+B,EAC/B,UAAuC;IAEvC,MAAM,OAAO,GAAsC,EAAE,CAAC;IACtD,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,MAAM,4BAA4B,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,iCAAiC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;AAChE,CAAC","debugId":"be8706fa-86f8-576a-9e39-475b9681600c"}
@@ -0,0 +1,77 @@
1
+ import { type BuildItemContextRelevanceCandidatesOptions, type ContextRelevanceCandidate, type ContextRelevanceSignals } from "./context-relevance.js";
2
+ import type { ItemMetadata } from "../types/index.js";
3
+ /** Current serialized feature-store envelope version. */
4
+ export declare const CONTEXT_SIGNAL_STORE_FORMAT_VERSION = 1;
5
+ /** Current canonical signal-vector version. */
6
+ export declare const CONTEXT_SIGNAL_SET_VERSION = 1;
7
+ /** Authoritative substrate used to derive one snapshot. */
8
+ export type ContextSignalSnapshotSource = "derived_index" | "scan_fallback";
9
+ /** One immutable item signal row. */
10
+ export interface ContextSignalSnapshotItem {
11
+ /** Stable item identifier. */
12
+ id: string;
13
+ /** Canonical normalized signal vector. */
14
+ signals: ContextRelevanceSignals;
15
+ }
16
+ /** Rebuildable, deterministic context-signal snapshot. */
17
+ export interface ContextSignalSnapshot {
18
+ /** Serialized envelope version. */
19
+ format_version: number;
20
+ /** Signal algorithm version. */
21
+ signal_set_version: number;
22
+ /** Authoritative history or derived-index cursor folded into this snapshot. */
23
+ source_cursor: string;
24
+ /** Stable clock supplied by the caller. */
25
+ generated_at: string;
26
+ /** Read substrate used for the fold. */
27
+ source: ContextSignalSnapshotSource;
28
+ /** Item rows sorted by canonical id. */
29
+ items: readonly ContextSignalSnapshotItem[];
30
+ }
31
+ /** Pluggable persistence boundary for context-signal snapshots. */
32
+ export interface ContextSignalStoreAdapter {
33
+ /** Read the serialized snapshot, or null when none exists. */
34
+ read(): Promise<unknown | null>;
35
+ /** Atomically replace the serialized snapshot. */
36
+ write(snapshot: ContextSignalSnapshot): Promise<void>;
37
+ }
38
+ /** Options required to fold authoritative items into a snapshot. */
39
+ export interface BuildContextSignalSnapshotOptions extends BuildItemContextRelevanceCandidatesOptions {
40
+ /** Authoritative history or derived-index cursor. */
41
+ sourceCursor: string;
42
+ /** Substrate used to load the authoritative items. */
43
+ source: ContextSignalSnapshotSource;
44
+ }
45
+ /** Result of a feature-store read with explicit degradation metadata. */
46
+ export interface ContextSignalStoreReadResult {
47
+ /** Valid snapshot used for candidate assembly. */
48
+ snapshot: ContextSignalSnapshot;
49
+ /** Candidates joined to the caller's authoritative item objects. */
50
+ candidates: ContextRelevanceCandidate<ItemMetadata>[];
51
+ /** Whether the persisted snapshot was reused or rebuilt. */
52
+ cache_status: "fresh" | "rebuilt";
53
+ /** Non-fatal recovery diagnostics. */
54
+ warnings: readonly string[];
55
+ }
56
+ /** Validate an untrusted serialized snapshot without accepting partial envelopes. */
57
+ export declare function parseContextSignalSnapshot(value: unknown): ContextSignalSnapshot | null;
58
+ /** Fold authoritative items into a deterministic, immutable signal snapshot. */
59
+ export declare function buildContextSignalSnapshot(items: readonly ItemMetadata[], options: BuildContextSignalSnapshotOptions): ContextSignalSnapshot;
60
+ /** Filesystem adapter using same-directory atomic replacement. */
61
+ export declare class JsonFileContextSignalStoreAdapter implements ContextSignalStoreAdapter {
62
+ private readonly filePath;
63
+ /** Create an adapter for an explicit derived-state file path. */
64
+ constructor(filePath: string);
65
+ /** Read and decode the JSON snapshot, returning null when it does not exist. */
66
+ read(): Promise<unknown | null>;
67
+ /** Write a complete snapshot through a unique same-directory temporary file. */
68
+ write(snapshot: ContextSignalSnapshot): Promise<void>;
69
+ }
70
+ /** Cursor-aware feature store that self-heals from absent, stale, or corrupt state. */
71
+ export declare class ContextSignalStore {
72
+ private readonly adapter;
73
+ /** Bind the store to a caller-selected persistence adapter. */
74
+ constructor(adapter: ContextSignalStoreAdapter);
75
+ /** Read matching signals or rebuild them from authoritative items. */
76
+ readOrRebuild(items: readonly ItemMetadata[], options: BuildContextSignalSnapshotOptions): Promise<ContextSignalStoreReadResult>;
77
+ }
@@ -0,0 +1,201 @@
1
+ /**
2
+ * @module sdk/context-signal-store
3
+ *
4
+ * Rebuildable, cursor-stamped feature-store primitives for context relevance.
5
+ * Snapshots are derived read artifacts: callers retain authoritative items and
6
+ * history, while stale, absent, or corrupt snapshots rebuild transparently.
7
+ */
8
+
9
+ !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]="26f26fe2-7795-5447-8a43-6d86f5da0e73")}catch(e){}}();
10
+ import fs from "node:fs/promises";
11
+ import path from "node:path";
12
+ import { randomUUID } from "node:crypto";
13
+ import { buildItemContextRelevanceCandidates, CONTEXT_RELEVANCE_SIGNAL_NAMES, } from "./context-relevance.js";
14
+ /** Current serialized feature-store envelope version. */
15
+ export const CONTEXT_SIGNAL_STORE_FORMAT_VERSION = 1;
16
+ /** Current canonical signal-vector version. */
17
+ export const CONTEXT_SIGNAL_SET_VERSION = 1;
18
+ const STORED_CONTEXT_SIGNAL_NAMES = CONTEXT_RELEVANCE_SIGNAL_NAMES.slice(1);
19
+ function isRecord(value) {
20
+ return typeof value === "object" && value !== null && !Array.isArray(value);
21
+ }
22
+ function isNormalizedSignal(value) {
23
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 1;
24
+ }
25
+ function compactSignals(signals) {
26
+ const compact = {};
27
+ for (const name of STORED_CONTEXT_SIGNAL_NAMES) {
28
+ const value = signals[name];
29
+ if (value === undefined)
30
+ continue;
31
+ if (!isNormalizedSignal(value)) {
32
+ throw new TypeError(`Context relevance signal ${name} must be a finite number from 0 to 1`);
33
+ }
34
+ compact[name] = value;
35
+ }
36
+ return compact;
37
+ }
38
+ function parseSnapshotItem(value) {
39
+ if (!isRecord(value) || typeof value.id !== "string" || !isRecord(value.signals)) {
40
+ return null;
41
+ }
42
+ const signals = {};
43
+ const supportedSignals = new Set(STORED_CONTEXT_SIGNAL_NAMES);
44
+ for (const [name, signal] of Object.entries(value.signals)) {
45
+ if (!supportedSignals.has(name) || !isNormalizedSignal(signal)) {
46
+ return null;
47
+ }
48
+ signals[name] = signal;
49
+ }
50
+ return { id: value.id, signals: signals };
51
+ }
52
+ /** Validate an untrusted serialized snapshot without accepting partial envelopes. */
53
+ export function parseContextSignalSnapshot(value) {
54
+ if (!isRecord(value) ||
55
+ value.format_version !== CONTEXT_SIGNAL_STORE_FORMAT_VERSION ||
56
+ value.signal_set_version !== CONTEXT_SIGNAL_SET_VERSION ||
57
+ typeof value.source_cursor !== "string" ||
58
+ value.source_cursor.trim().length === 0 ||
59
+ typeof value.generated_at !== "string" ||
60
+ !Number.isFinite(Date.parse(value.generated_at)) ||
61
+ (value.source !== "derived_index" && value.source !== "scan_fallback") ||
62
+ !Array.isArray(value.items)) {
63
+ return null;
64
+ }
65
+ const items = value.items.map(parseSnapshotItem);
66
+ if (items.some((item) => item === null)) {
67
+ return null;
68
+ }
69
+ const validItems = items;
70
+ if (new Set(validItems.map((item) => item.id)).size !== validItems.length ||
71
+ validItems.some((item) => item.id.trim().length === 0)) {
72
+ return null;
73
+ }
74
+ return {
75
+ format_version: CONTEXT_SIGNAL_STORE_FORMAT_VERSION,
76
+ signal_set_version: CONTEXT_SIGNAL_SET_VERSION,
77
+ source_cursor: value.source_cursor,
78
+ generated_at: value.generated_at,
79
+ source: value.source,
80
+ items: validItems.sort((left, right) => left.id.localeCompare(right.id)),
81
+ };
82
+ }
83
+ /** Fold authoritative items into a deterministic, immutable signal snapshot. */
84
+ export function buildContextSignalSnapshot(items, options) {
85
+ if (typeof options.sourceCursor !== "string" || options.sourceCursor.trim().length === 0) {
86
+ throw new TypeError("Context signal source cursor must be non-empty");
87
+ }
88
+ if (!Number.isFinite(Date.parse(options.now))) {
89
+ throw new TypeError("Context signal snapshot clock must be a valid timestamp");
90
+ }
91
+ const rows = buildItemContextRelevanceCandidates(items, options)
92
+ .map(({ id, signals }) => ({
93
+ id,
94
+ signals: compactSignals(signals),
95
+ }))
96
+ .sort((left, right) => left.id.localeCompare(right.id));
97
+ return Object.freeze({
98
+ format_version: CONTEXT_SIGNAL_STORE_FORMAT_VERSION,
99
+ signal_set_version: CONTEXT_SIGNAL_SET_VERSION,
100
+ source_cursor: options.sourceCursor,
101
+ generated_at: options.now,
102
+ source: options.source,
103
+ items: Object.freeze(rows.map((row) => Object.freeze(row))),
104
+ });
105
+ }
106
+ /** Filesystem adapter using same-directory atomic replacement. */
107
+ export class JsonFileContextSignalStoreAdapter {
108
+ filePath;
109
+ /** Create an adapter for an explicit derived-state file path. */
110
+ constructor(filePath) {
111
+ if (typeof filePath !== "string" || filePath.trim().length === 0) {
112
+ throw new TypeError("Context signal store path must be non-empty");
113
+ }
114
+ this.filePath = path.resolve(filePath);
115
+ }
116
+ /** Read and decode the JSON snapshot, returning null when it does not exist. */
117
+ async read() {
118
+ try {
119
+ return JSON.parse(await fs.readFile(this.filePath, "utf8"));
120
+ }
121
+ catch (error) {
122
+ if (isRecord(error) && error.code === "ENOENT") {
123
+ return null;
124
+ }
125
+ throw error;
126
+ }
127
+ }
128
+ /** Write a complete snapshot through a unique same-directory temporary file. */
129
+ async write(snapshot) {
130
+ const directory = path.dirname(this.filePath);
131
+ await fs.mkdir(directory, { recursive: true });
132
+ const temporaryPath = path.join(directory, `.${path.basename(this.filePath)}.${randomUUID()}.tmp`);
133
+ try {
134
+ await fs.writeFile(temporaryPath, `${JSON.stringify(snapshot)}\n`, { encoding: "utf8", flag: "wx" });
135
+ await fs.rename(temporaryPath, this.filePath);
136
+ }
137
+ finally {
138
+ try {
139
+ await fs.rm(temporaryPath, { force: true });
140
+ }
141
+ catch {
142
+ // The complete snapshot is already committed; temporary-file cleanup is best effort.
143
+ }
144
+ }
145
+ }
146
+ }
147
+ /** Cursor-aware feature store that self-heals from absent, stale, or corrupt state. */
148
+ export class ContextSignalStore {
149
+ adapter;
150
+ /** Bind the store to a caller-selected persistence adapter. */
151
+ constructor(adapter) {
152
+ this.adapter = adapter;
153
+ }
154
+ /** Read matching signals or rebuild them from authoritative items. */
155
+ async readOrRebuild(items, options) {
156
+ const warnings = [];
157
+ let snapshot = null;
158
+ try {
159
+ const serialized = await this.adapter.read();
160
+ snapshot = parseContextSignalSnapshot(serialized);
161
+ if (serialized !== null && snapshot === null) {
162
+ warnings.push("context_signal_store_invalid");
163
+ }
164
+ }
165
+ catch {
166
+ warnings.push("context_signal_store_invalid");
167
+ }
168
+ const authoritativeIds = items.map((item) => item.id).sort((left, right) => left.localeCompare(right));
169
+ const snapshotIds = snapshot?.items.map((item) => item.id) ?? [];
170
+ const fresh = snapshot !== null &&
171
+ snapshot.source_cursor === options.sourceCursor &&
172
+ snapshot.source === options.source &&
173
+ snapshotIds.length === authoritativeIds.length &&
174
+ snapshotIds.every((id, index) => id === authoritativeIds[index]);
175
+ let resolvedSnapshot;
176
+ if (fresh && snapshot !== null) {
177
+ resolvedSnapshot = snapshot;
178
+ }
179
+ else {
180
+ if (snapshot !== null) {
181
+ warnings.push("context_signal_store_stale");
182
+ }
183
+ resolvedSnapshot = buildContextSignalSnapshot(items, options);
184
+ try {
185
+ await this.adapter.write(resolvedSnapshot);
186
+ }
187
+ catch {
188
+ warnings.push("context_signal_store_write_failed");
189
+ }
190
+ }
191
+ const signalsById = new Map(resolvedSnapshot.items.map((item) => [item.id, item.signals]));
192
+ return {
193
+ snapshot: resolvedSnapshot,
194
+ candidates: items.map((item) => ({ id: item.id, item, signals: signalsById.get(item.id) })),
195
+ cache_status: fresh ? "fresh" : "rebuilt",
196
+ warnings,
197
+ };
198
+ }
199
+ }
200
+ //# sourceMappingURL=context-signal-store.js.map
201
+ //# debugId=26f26fe2-7795-5447-8a43-6d86f5da0e73