@unbrained/pm-cli 2026.7.13 → 2026.7.14

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 (487) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +28 -0
  3. package/dist/cli/commands/aggregate.d.ts +1 -1
  4. package/dist/cli/commands/aggregate.js +18 -6
  5. package/dist/cli/commands/aggregate.js.map +1 -1
  6. package/dist/cli/commands/context.d.ts +16 -1
  7. package/dist/cli/commands/context.js +98 -16
  8. package/dist/cli/commands/context.js.map +1 -1
  9. package/dist/cli/commands/create.d.ts +1 -1
  10. package/dist/cli/commands/create.js +11 -7
  11. package/dist/cli/commands/create.js.map +1 -1
  12. package/dist/cli/commands/deps.d.ts +6 -96
  13. package/dist/cli/commands/deps.js +4 -214
  14. package/dist/cli/commands/deps.js.map +1 -1
  15. package/dist/cli/commands/docs.d.ts +2 -44
  16. package/dist/cli/commands/docs.js +8 -13
  17. package/dist/cli/commands/docs.js.map +1 -1
  18. package/dist/cli/commands/files.d.ts +6 -134
  19. package/dist/cli/commands/files.js +4 -294
  20. package/dist/cli/commands/files.js.map +1 -1
  21. package/dist/cli/commands/get.js +15 -2
  22. package/dist/cli/commands/get.js.map +1 -1
  23. package/dist/cli/commands/list.js +5 -6
  24. package/dist/cli/commands/list.js.map +1 -1
  25. package/dist/cli/commands/next.d.ts +3 -1
  26. package/dist/cli/commands/next.js +77 -20
  27. package/dist/cli/commands/next.js.map +1 -1
  28. package/dist/cli/commands/update-many.js +6 -3
  29. package/dist/cli/commands/update-many.js.map +1 -1
  30. package/dist/cli/commands/update.js +14 -7
  31. package/dist/cli/commands/update.js.map +1 -1
  32. package/dist/cli/commands/validate.d.ts +1 -1
  33. package/dist/cli/commands/validate.js +32 -35
  34. package/dist/cli/commands/validate.js.map +1 -1
  35. package/dist/cli/main.d.ts +2 -14
  36. package/dist/cli/main.js +27 -8
  37. package/dist/cli/main.js.map +1 -1
  38. package/dist/cli-bundle/chunks/append-DYQWQK2J.js +11 -0
  39. package/dist/cli-bundle/chunks/{append-2FS6MVG7.js → append-PVZJDM6J.js} +5 -5
  40. package/dist/cli-bundle/chunks/{chunk-J2WAWP4U.js → chunk-2FNWQXZ2.js} +4 -4
  41. package/dist/cli-bundle/chunks/{chunk-YFGYDZRP.js → chunk-2GA3NK35.js} +4 -4
  42. package/dist/cli-bundle/chunks/{chunk-XFEIASAC.js → chunk-2QIQGYPW.js} +2 -2
  43. package/dist/cli-bundle/chunks/{chunk-3WCGYH5Q.js → chunk-3CMRNVTO.js} +7 -7
  44. package/dist/cli-bundle/chunks/chunk-3HKUXVKV.js +9 -0
  45. package/dist/cli-bundle/chunks/{chunk-VDAZPPRU.js → chunk-3I3LRT2G.js} +2 -2
  46. package/dist/cli-bundle/chunks/{chunk-3P3RFJIQ.js → chunk-3TL7WOEF.js} +2 -2
  47. package/dist/cli-bundle/chunks/{chunk-4SHJ5JS3.js → chunk-44LNIULG.js} +4 -4
  48. package/dist/cli-bundle/chunks/{chunk-QFOAWBOB.js → chunk-4DY4KPQI.js} +11 -10
  49. package/dist/cli-bundle/chunks/{chunk-QFOAWBOB.js.map → chunk-4DY4KPQI.js.map} +2 -2
  50. package/dist/cli-bundle/chunks/{chunk-BVCF4ULV.js → chunk-4RXTMU57.js} +5 -5
  51. package/dist/cli-bundle/chunks/{chunk-XMI2TRY5.js → chunk-4WREH7RT.js} +4 -4
  52. package/dist/cli-bundle/chunks/{chunk-JYUGUXFW.js → chunk-5CT5BW6E.js} +5 -5
  53. package/dist/cli-bundle/chunks/{chunk-NA5SBIB4.js → chunk-5URI7TPJ.js} +44 -44
  54. package/dist/cli-bundle/chunks/chunk-5URI7TPJ.js.map +7 -0
  55. package/dist/cli-bundle/chunks/{chunk-QGH6WL6L.js → chunk-655STMGA.js} +2 -2
  56. package/dist/cli-bundle/chunks/{chunk-DGKBWCMA.js → chunk-6IIVBC56.js} +4 -4
  57. package/dist/cli-bundle/chunks/{chunk-SRQLQUO6.js → chunk-6MHSBDGD.js} +7 -7
  58. package/dist/cli-bundle/chunks/{chunk-SRQLQUO6.js.map → chunk-6MHSBDGD.js.map} +2 -2
  59. package/dist/cli-bundle/chunks/{chunk-D4GPNYYP.js → chunk-6OTZMORS.js} +6 -6
  60. package/dist/cli-bundle/chunks/{chunk-JVRVXO6M.js → chunk-6PKA3SJQ.js} +6 -6
  61. package/dist/cli-bundle/chunks/{chunk-2PR4ZTRO.js → chunk-6TTOHMTB.js} +8 -8
  62. package/dist/cli-bundle/chunks/{chunk-2PR4ZTRO.js.map → chunk-6TTOHMTB.js.map} +1 -1
  63. package/dist/cli-bundle/chunks/chunk-6X5MZ5R2.js +9 -0
  64. package/dist/cli-bundle/chunks/chunk-76UBY2EE.js +5 -0
  65. package/dist/cli-bundle/chunks/{chunk-ZS2KPCJN.js → chunk-7QDSYUMF.js} +7 -7
  66. package/dist/cli-bundle/chunks/{chunk-Z7TFPIJ6.js → chunk-7TQMR6LK.js} +7 -7
  67. package/dist/cli-bundle/chunks/{chunk-AHA4POA6.js → chunk-ABRCOSDC.js} +3 -3
  68. package/dist/cli-bundle/chunks/{chunk-XY3CC3EM.js → chunk-AFWZRL7M.js} +59 -53
  69. package/dist/cli-bundle/chunks/chunk-AFWZRL7M.js.map +7 -0
  70. package/dist/cli-bundle/chunks/{chunk-KQJVTQVK.js → chunk-ANSJHDOZ.js} +2 -2
  71. package/dist/cli-bundle/chunks/{chunk-OMT4NO7T.js → chunk-B5DZYTT3.js} +113 -24
  72. package/dist/cli-bundle/chunks/chunk-B5DZYTT3.js.map +7 -0
  73. package/dist/cli-bundle/chunks/chunk-B7SWOIP6.js +5 -0
  74. package/dist/cli-bundle/chunks/{chunk-D2LXG7WX.js → chunk-BN62TO2S.js} +5 -5
  75. package/dist/cli-bundle/chunks/chunk-BN62TO2S.js.map +1 -0
  76. package/dist/cli-bundle/chunks/{chunk-ZTSV7P2T.js → chunk-BPD26E3P.js} +357 -42
  77. package/dist/cli-bundle/chunks/chunk-BPD26E3P.js.map +1 -0
  78. package/dist/cli-bundle/chunks/{chunk-RKGFUC4O.js → chunk-CDJYP7OQ.js} +36 -14
  79. package/dist/cli-bundle/chunks/chunk-CDJYP7OQ.js.map +1 -0
  80. package/dist/cli-bundle/chunks/{chunk-VLFLRFJP.js → chunk-CIOZ376P.js} +20 -13
  81. package/dist/cli-bundle/chunks/chunk-CIOZ376P.js.map +1 -0
  82. package/dist/cli-bundle/chunks/{chunk-HXTCZSAI.js → chunk-DBZVUJTK.js} +3 -3
  83. package/dist/cli-bundle/chunks/{chunk-2QNOWOIB.js → chunk-DO5RGJXT.js} +3 -3
  84. package/dist/cli-bundle/chunks/{chunk-MKONZ4UO.js → chunk-DRNJPEPQ.js} +4 -4
  85. package/dist/cli-bundle/chunks/{chunk-XDT2PSXA.js → chunk-DVOLZJ3C.js} +12 -11
  86. package/dist/cli-bundle/chunks/{chunk-XDT2PSXA.js.map → chunk-DVOLZJ3C.js.map} +1 -1
  87. package/dist/cli-bundle/chunks/{chunk-H36FXA7B.js → chunk-DYEX6NFH.js} +4 -4
  88. package/dist/cli-bundle/chunks/{chunk-G3IB5GTD.js → chunk-E2WC6S4P.js} +15 -11
  89. package/dist/cli-bundle/chunks/chunk-E2WC6S4P.js.map +7 -0
  90. package/dist/cli-bundle/chunks/{chunk-GAJ7U7B4.js → chunk-ERL2YFJ2.js} +3 -3
  91. package/dist/cli-bundle/chunks/{chunk-FPEYOFEF.js → chunk-F7PSHRNO.js} +3 -3
  92. package/dist/cli-bundle/chunks/{chunk-UH7OLT6F.js → chunk-FDSBDNYE.js} +2 -2
  93. package/dist/cli-bundle/chunks/{chunk-DGJF32JF.js → chunk-FIGXOCEQ.js} +66 -21
  94. package/dist/cli-bundle/chunks/chunk-FIGXOCEQ.js.map +7 -0
  95. package/dist/cli-bundle/chunks/{chunk-RQAY7C5T.js → chunk-FJZDA6MS.js} +3 -3
  96. package/dist/cli-bundle/chunks/{chunk-B4TVNGRX.js → chunk-FO7GMJKG.js} +3 -3
  97. package/dist/cli-bundle/chunks/chunk-FRQ63VPB.js +5 -0
  98. package/dist/cli-bundle/chunks/{chunk-UTYNQ2WH.js → chunk-FS6UM5WH.js} +48 -27
  99. package/dist/cli-bundle/chunks/chunk-FS6UM5WH.js.map +7 -0
  100. package/dist/cli-bundle/chunks/{chunk-U252II47.js → chunk-FTQLW4JD.js} +4 -4
  101. package/dist/cli-bundle/chunks/{chunk-TNGLCRKS.js → chunk-GSEADLRH.js} +1821 -1809
  102. package/dist/cli-bundle/chunks/chunk-GSEADLRH.js.map +1 -0
  103. package/dist/cli-bundle/chunks/{chunk-TGG7YGMC.js → chunk-GXXC7QSK.js} +53 -47
  104. package/dist/cli-bundle/chunks/chunk-GXXC7QSK.js.map +1 -0
  105. package/dist/cli-bundle/chunks/{chunk-AGD4VZXH.js → chunk-H2QBAKLQ.js} +3 -3
  106. package/dist/cli-bundle/chunks/{chunk-CJVQ4XIG.js → chunk-HAMLIWAF.js} +4 -4
  107. package/dist/cli-bundle/chunks/{chunk-56DX6QYG.js → chunk-HL7V2PHX.js} +19 -13
  108. package/dist/cli-bundle/chunks/chunk-HL7V2PHX.js.map +1 -0
  109. package/dist/cli-bundle/chunks/{chunk-7QOIQTPB.js → chunk-HLHSQ5CA.js} +4 -4
  110. package/dist/cli-bundle/chunks/{chunk-AHC7J6XD.js → chunk-IA3YFTXT.js} +6 -6
  111. package/dist/cli-bundle/chunks/{chunk-5ZCVF4WF.js → chunk-IAPHYPRL.js} +2 -2
  112. package/dist/cli-bundle/chunks/{chunk-OCSQWIOW.js → chunk-IFZA4VB5.js} +4 -4
  113. package/dist/cli-bundle/chunks/{chunk-6O2HJENY.js → chunk-IGED7NH2.js} +61 -48
  114. package/dist/cli-bundle/chunks/chunk-IGED7NH2.js.map +7 -0
  115. package/dist/cli-bundle/chunks/{chunk-RPCCQDG2.js → chunk-ILLUE5DI.js} +36 -14
  116. package/dist/cli-bundle/chunks/chunk-ILLUE5DI.js.map +7 -0
  117. package/dist/cli-bundle/chunks/{chunk-4WMFM77X.js → chunk-J4NZOP3I.js} +5 -5
  118. package/dist/cli-bundle/chunks/{chunk-57JVERX3.js → chunk-JAF4TUQ7.js} +4 -4
  119. package/dist/cli-bundle/chunks/chunk-JAF4TUQ7.js.map +7 -0
  120. package/dist/cli-bundle/chunks/{chunk-MTNKSSSO.js → chunk-JL7WZ4O2.js} +3 -3
  121. package/dist/cli-bundle/chunks/{chunk-AZ52LTCY.js → chunk-K7WNZ7KD.js} +3 -3
  122. package/dist/cli-bundle/chunks/{chunk-2OLSXXIV.js → chunk-KADLSPIU.js} +4 -4
  123. package/dist/cli-bundle/chunks/{chunk-RQKORMM4.js → chunk-KB726FMH.js} +4 -4
  124. package/dist/cli-bundle/chunks/{chunk-WKSFBBZT.js → chunk-L24HCJFC.js} +114 -25
  125. package/dist/cli-bundle/chunks/chunk-L24HCJFC.js.map +1 -0
  126. package/dist/cli-bundle/chunks/{chunk-LDO24J5I.js → chunk-LWTIRS3Y.js} +365 -43
  127. package/dist/cli-bundle/chunks/chunk-LWTIRS3Y.js.map +7 -0
  128. package/dist/cli-bundle/chunks/{chunk-TZTQ4TVV.js → chunk-M6ASXYCU.js} +4 -4
  129. package/dist/cli-bundle/chunks/{chunk-WDDOAU7Z.js → chunk-M7EWN4TF.js} +3 -3
  130. package/dist/cli-bundle/chunks/{chunk-327DSGW2.js → chunk-MD6ULIPJ.js} +3 -3
  131. package/dist/cli-bundle/chunks/{chunk-OKDBHOON.js → chunk-MKL4CP2I.js} +61 -48
  132. package/dist/cli-bundle/chunks/chunk-MKL4CP2I.js.map +1 -0
  133. package/dist/cli-bundle/chunks/{chunk-M52DG2QJ.js → chunk-MQZ3PLCF.js} +2 -2
  134. package/dist/cli-bundle/chunks/{chunk-GQ2CQNGI.js → chunk-N3CMP4NI.js} +2 -2
  135. package/dist/cli-bundle/chunks/{chunk-J7SBFUZC.js → chunk-NAQYVWSQ.js} +4 -4
  136. package/dist/cli-bundle/chunks/{chunk-U2GMYP3L.js → chunk-NKW36AMT.js} +4 -4
  137. package/dist/cli-bundle/chunks/{chunk-5WEYOVZ7.js → chunk-OBDLEQG5.js} +19 -12
  138. package/dist/cli-bundle/chunks/chunk-OBDLEQG5.js.map +7 -0
  139. package/dist/cli-bundle/chunks/{chunk-VL4LYTJN.js → chunk-OI4S4KCI.js} +18 -12
  140. package/dist/cli-bundle/chunks/chunk-OI4S4KCI.js.map +7 -0
  141. package/dist/cli-bundle/chunks/{chunk-FCVVMAEX.js → chunk-P6MYFH6K.js} +60 -22
  142. package/dist/cli-bundle/chunks/chunk-P6MYFH6K.js.map +1 -0
  143. package/dist/cli-bundle/chunks/{chunk-FTQQAPRX.js → chunk-PHKP3AGR.js} +8 -8
  144. package/dist/cli-bundle/chunks/{chunk-WVUXNIYO.js → chunk-Q37E63AM.js} +4 -4
  145. package/dist/cli-bundle/chunks/{chunk-JVXV7ANV.js → chunk-Q7E6OYZK.js} +2 -2
  146. package/dist/cli-bundle/chunks/{chunk-WVUYATII.js → chunk-QABYZYLU.js} +4 -4
  147. package/dist/cli-bundle/chunks/{chunk-QRRUGIJN.js → chunk-QASRVKUQ.js} +45 -45
  148. package/dist/cli-bundle/chunks/chunk-QASRVKUQ.js.map +1 -0
  149. package/dist/cli-bundle/chunks/{chunk-L4262MFB.js → chunk-QK2ZN6UL.js} +14 -5
  150. package/dist/cli-bundle/chunks/{chunk-L4262MFB.js.map → chunk-QK2ZN6UL.js.map} +1 -1
  151. package/dist/cli-bundle/chunks/{chunk-7TQPV7HR.js → chunk-QSPARJWF.js} +2 -2
  152. package/dist/cli-bundle/chunks/{chunk-GTKILM6F.js → chunk-QZ7LT3XE.js} +3 -3
  153. package/dist/cli-bundle/chunks/{chunk-L3VKY6R6.js → chunk-RA5AIAMP.js} +3 -3
  154. package/dist/cli-bundle/chunks/{chunk-BJS27ALI.js → chunk-RGXD5JJR.js} +6 -6
  155. package/dist/cli-bundle/chunks/{chunk-TSEPW2P6.js → chunk-RMF3IOYQ.js} +7 -7
  156. package/dist/cli-bundle/chunks/{chunk-QXYKH56X.js → chunk-T4BRCB6Z.js} +1894 -1875
  157. package/dist/cli-bundle/chunks/chunk-T4BRCB6Z.js.map +7 -0
  158. package/dist/cli-bundle/chunks/{chunk-TGGTXC52.js → chunk-TH7U4KLY.js} +3 -3
  159. package/dist/cli-bundle/chunks/{chunk-LP4UATP6.js → chunk-TWLDBKQU.js} +3 -3
  160. package/dist/cli-bundle/chunks/{chunk-OTZ3C2NE.js → chunk-TZ2PSLLT.js} +49 -28
  161. package/dist/cli-bundle/chunks/chunk-TZ2PSLLT.js.map +1 -0
  162. package/dist/cli-bundle/chunks/{chunk-UK222BHQ.js → chunk-TZRTLMWM.js} +4 -4
  163. package/dist/cli-bundle/chunks/{chunk-6E6S2X6S.js → chunk-UB2QYSTO.js} +8 -8
  164. package/dist/cli-bundle/chunks/{chunk-S6CXUSYC.js → chunk-UGTVWL3E.js} +5 -5
  165. package/dist/cli-bundle/chunks/{chunk-BNS6QHTZ.js → chunk-UJ4HJYWL.js} +2 -2
  166. package/dist/cli-bundle/chunks/{chunk-BYVOEJPQ.js → chunk-UKUIIBDW.js} +4 -4
  167. package/dist/cli-bundle/chunks/{chunk-SGDBVR7X.js → chunk-UVBA6F5A.js} +2 -2
  168. package/dist/cli-bundle/chunks/{chunk-DZRZMBBF.js → chunk-VJTAEIPC.js} +5 -5
  169. package/dist/cli-bundle/chunks/{chunk-74PWVJON.js → chunk-W6HZ55JO.js} +2 -2
  170. package/dist/cli-bundle/chunks/{chunk-HR2MQAO5.js → chunk-WD6MSYMP.js} +13 -4
  171. package/dist/cli-bundle/chunks/{chunk-HR2MQAO5.js.map → chunk-WD6MSYMP.js.map} +2 -2
  172. package/dist/cli-bundle/chunks/{chunk-P7IFURWH.js → chunk-WPAWZW7S.js} +2 -2
  173. package/dist/cli-bundle/chunks/{chunk-36LEOWSX.js → chunk-WQUEHPZB.js} +2 -2
  174. package/dist/cli-bundle/chunks/{chunk-FCKJF7G2.js → chunk-WRKB56FC.js} +3 -3
  175. package/dist/cli-bundle/chunks/{chunk-KR5EHAN4.js → chunk-X3GYR4P2.js} +2 -2
  176. package/dist/cli-bundle/chunks/{chunk-J567OZJY.js → chunk-X6BVXQ52.js} +16 -12
  177. package/dist/cli-bundle/chunks/chunk-X6BVXQ52.js.map +1 -0
  178. package/dist/cli-bundle/chunks/chunk-Y72FV7RM.js +178 -0
  179. package/dist/cli-bundle/chunks/chunk-Y72FV7RM.js.map +7 -0
  180. package/dist/cli-bundle/chunks/{chunk-OWW2KXOV.js → chunk-YQYG2V23.js} +2 -2
  181. package/dist/cli-bundle/chunks/{chunk-G2SCT7BC.js → chunk-YVKE5ZDM.js} +4 -4
  182. package/dist/cli-bundle/chunks/{chunk-QHIN4UTF.js → chunk-ZAYYDNB3.js} +4 -4
  183. package/dist/cli-bundle/chunks/chunk-ZHBI2AP7.js +9 -0
  184. package/dist/cli-bundle/chunks/chunk-ZNP64HOW.js +175 -0
  185. package/dist/cli-bundle/chunks/chunk-ZNP64HOW.js.map +1 -0
  186. package/dist/cli-bundle/chunks/{chunk-GNVBUNJQ.js → chunk-ZTRBSABY.js} +3 -3
  187. package/dist/cli-bundle/chunks/{chunk-PY32KGQU.js → chunk-ZUKSZVBW.js} +5 -5
  188. package/dist/cli-bundle/chunks/{close-CU56F47E.js → close-LZECOMHO.js} +5 -5
  189. package/dist/cli-bundle/chunks/close-RI4JQQHU.js +12 -0
  190. package/dist/cli-bundle/chunks/close-many-LY2XJ52M.js +21 -0
  191. package/dist/cli-bundle/chunks/{close-many-ZQ2WP67J.js → close-many-ZHI6A5TN.js} +12 -12
  192. package/dist/cli-bundle/chunks/comments-35M273DN.js +13 -0
  193. package/dist/cli-bundle/chunks/{comments-UDUMKXL6.js → comments-AJWRTFZ5.js} +7 -7
  194. package/dist/cli-bundle/chunks/{copy-VFHECFBV.js → copy-GMXYKBXT.js} +4 -4
  195. package/dist/cli-bundle/chunks/copy-NPYM7M7U.js +9 -0
  196. package/dist/cli-bundle/chunks/create-F53OBTOU.js +27 -0
  197. package/dist/cli-bundle/chunks/{create-CE2X3SGF.js → create-HU4Q7RJX.js} +11 -9
  198. package/dist/cli-bundle/chunks/{delete-2JXQCHHT.js → delete-GSDZLTRC.js} +4 -4
  199. package/dist/cli-bundle/chunks/delete-ODRWJWAM.js +10 -0
  200. package/dist/cli-bundle/chunks/deps-U57I7EAK.js +16 -0
  201. package/dist/cli-bundle/chunks/{deps-FPXNLO6C.js → deps-WWB7P2GT.js} +7 -4
  202. package/dist/cli-bundle/chunks/docs-G7N4E2JO.js +14 -0
  203. package/dist/cli-bundle/chunks/{docs-AMAR4OHU.js → docs-MQIY2ZQS.js} +7 -7
  204. package/dist/cli-bundle/chunks/files-TBZD7V6H.js +18 -0
  205. package/dist/cli-bundle/chunks/{files-JFHN7DYM.js → files-TTY6N2AV.js} +7 -7
  206. package/dist/cli-bundle/chunks/focus-U5TRVCRS.js +10 -0
  207. package/dist/cli-bundle/chunks/{focus-QFN2RRZ7.js → focus-XT6YVFFX.js} +5 -5
  208. package/dist/cli-bundle/chunks/{history-compact-G34XMABV.js → history-compact-KKVUWB4V.js} +8 -8
  209. package/dist/cli-bundle/chunks/{history-compact-SAHT5D46.js → history-compact-M7GHYVFN.js} +8 -8
  210. package/dist/cli-bundle/chunks/{history-redact-IFJDNKLZ.js → history-redact-3DVZOILD.js} +6 -6
  211. package/dist/cli-bundle/chunks/history-redact-JIHZLHDP.js +16 -0
  212. package/dist/cli-bundle/chunks/{history-repair-NXLQTCVN.js → history-repair-ITDUMK4N.js} +8 -8
  213. package/dist/cli-bundle/chunks/history-repair-NAFCHLH7.js +18 -0
  214. package/dist/cli-bundle/chunks/{learnings-5CZKAMBS.js → learnings-FGO3NSFW.js} +7 -7
  215. package/dist/cli-bundle/chunks/learnings-SONGPSHI.js +13 -0
  216. package/dist/cli-bundle/chunks/notes-BSD53H2W.js +13 -0
  217. package/dist/cli-bundle/chunks/{notes-POMK37UI.js → notes-NQ6RXVW6.js} +7 -7
  218. package/dist/cli-bundle/chunks/{plan-YBNYNT3A.js → plan-2NNEO46V.js} +10 -10
  219. package/dist/cli-bundle/chunks/plan-AWLYGBNV.js +24 -0
  220. package/dist/cli-bundle/chunks/{profile-JNKSU6EQ.js → profile-AAQUU6T3.js} +9 -9
  221. package/dist/cli-bundle/chunks/{profile-A2WPVG6I.js → profile-U725ATWZ.js} +9 -9
  222. package/dist/cli-bundle/chunks/{register-list-query-UG4ZA5AU.js → register-list-query-BUWCYHBT.js} +14 -13
  223. package/dist/cli-bundle/chunks/{register-list-query-UG4ZA5AU.js.map → register-list-query-BUWCYHBT.js.map} +1 -1
  224. package/dist/cli-bundle/chunks/{register-list-query-KJULL4W3.js → register-list-query-KTZ6AGE7.js} +16 -15
  225. package/dist/cli-bundle/chunks/{register-list-query-KJULL4W3.js.map → register-list-query-KTZ6AGE7.js.map} +1 -1
  226. package/dist/cli-bundle/chunks/{register-mutation-3OXYXBKH.js → register-mutation-4FMGJJF7.js} +29 -29
  227. package/dist/cli-bundle/chunks/{register-mutation-WK265BM7.js → register-mutation-UELYYOR7.js} +29 -29
  228. package/dist/cli-bundle/chunks/{register-operations-C5SQH3FJ.js → register-operations-ISUX6LY5.js} +33 -29
  229. package/dist/cli-bundle/chunks/{register-operations-C5SQH3FJ.js.map → register-operations-ISUX6LY5.js.map} +1 -1
  230. package/dist/cli-bundle/chunks/{register-operations-FH3PBHYN.js → register-operations-JVW24J2Y.js} +35 -31
  231. package/dist/cli-bundle/chunks/{register-operations-FH3PBHYN.js.map → register-operations-JVW24J2Y.js.map} +1 -1
  232. package/dist/cli-bundle/chunks/{register-setup-CCK7CJVR.js → register-setup-5XNGKJ22.js} +15 -15
  233. package/dist/cli-bundle/chunks/{register-setup-CPZBGSOJ.js → register-setup-ZTNY6S7R.js} +15 -15
  234. package/dist/cli-bundle/chunks/restore-66GLMHIX.js +14 -0
  235. package/dist/cli-bundle/chunks/{restore-IVS5XGYR.js → restore-B3BAB6X2.js} +6 -6
  236. package/dist/cli-bundle/chunks/{schema-P2MF23JO.js → schema-LZNUYHDB.js} +6 -6
  237. package/dist/cli-bundle/chunks/schema-LZNUYHDB.js.map +7 -0
  238. package/dist/cli-bundle/chunks/{schema-R3U2REY4.js → schema-U7IM2DXV.js} +6 -6
  239. package/dist/cli-bundle/chunks/schema-U7IM2DXV.js.map +1 -0
  240. package/dist/cli-bundle/chunks/update-2XGHIVQ2.js +21 -0
  241. package/dist/cli-bundle/chunks/update-2XGHIVQ2.js.map +7 -0
  242. package/dist/cli-bundle/chunks/{update-YBIQESMH.js → update-Q3UCILNR.js} +12 -12
  243. package/dist/cli-bundle/chunks/update-Q3UCILNR.js.map +1 -0
  244. package/dist/cli-bundle/chunks/{update-many-F3CIV5SQ.js → update-many-75K57FS3.js} +19 -19
  245. package/dist/cli-bundle/chunks/update-many-75K57FS3.js.map +1 -0
  246. package/dist/cli-bundle/chunks/update-many-U42YA445.js +30 -0
  247. package/dist/cli-bundle/chunks/update-many-U42YA445.js.map +7 -0
  248. package/dist/cli-bundle/main.js +39 -16
  249. package/dist/cli-bundle/main.js.map +2 -2
  250. package/dist/cli-bundle/sdk-runtime.js +56 -53
  251. package/dist/cli-bundle/sdk-testing.js +6 -6
  252. package/dist/cli-bundle/sdk.js +115 -55
  253. package/dist/cli-bundle/sdk.js.map +2 -2
  254. package/dist/core/extensions/command-hook-context.d.ts +40 -0
  255. package/dist/core/extensions/command-hook-context.js +14 -0
  256. package/dist/core/extensions/command-hook-context.js.map +1 -0
  257. package/dist/core/extensions/index.d.ts +1 -0
  258. package/dist/core/extensions/index.js +4 -3
  259. package/dist/core/extensions/index.js.map +1 -1
  260. package/dist/core/item/parse.d.ts +2 -0
  261. package/dist/core/item/parse.js +11 -2
  262. package/dist/core/item/parse.js.map +1 -1
  263. package/dist/core/store/paths.d.ts +2 -0
  264. package/dist/core/store/paths.js +10 -2
  265. package/dist/core/store/paths.js.map +1 -1
  266. package/dist/mcp/tool-definitions.js +12 -2
  267. package/dist/mcp/tool-definitions.js.map +1 -1
  268. package/dist/sdk/context-packing.d.ts +114 -0
  269. package/dist/sdk/context-packing.js +219 -0
  270. package/dist/sdk/context-packing.js.map +1 -0
  271. package/dist/sdk/context-relevance.d.ts +1 -1
  272. package/dist/sdk/context-relevance.js +4 -2
  273. package/dist/sdk/context-relevance.js.map +1 -1
  274. package/dist/sdk/context-usage.d.ts +79 -0
  275. package/dist/sdk/context-usage.js +193 -0
  276. package/dist/sdk/context-usage.js.map +1 -0
  277. package/dist/sdk/dependencies.d.ts +145 -0
  278. package/dist/sdk/dependencies.js +327 -0
  279. package/dist/sdk/dependencies.js.map +1 -0
  280. package/dist/sdk/docs.d.ts +48 -0
  281. package/dist/sdk/docs.js +15 -0
  282. package/dist/sdk/docs.js.map +1 -0
  283. package/dist/sdk/files.d.ts +135 -0
  284. package/dist/sdk/files.js +320 -0
  285. package/dist/sdk/files.js.map +1 -0
  286. package/dist/sdk/index.d.ts +6 -0
  287. package/dist/sdk/index.js +8 -2
  288. package/dist/sdk/index.js.map +1 -1
  289. package/dist/{cli/commands → sdk}/linked-artifacts.d.ts +11 -5
  290. package/dist/{cli/commands → sdk}/linked-artifacts.js +49 -25
  291. package/dist/sdk/linked-artifacts.js.map +1 -0
  292. package/dist/sdk/runtime.d.ts +4 -4
  293. package/dist/sdk/runtime.js +7 -4
  294. package/dist/sdk/runtime.js.map +1 -1
  295. package/dist/sdk/workspace.js +3 -2
  296. package/dist/sdk/workspace.js.map +1 -1
  297. package/docs/AGENT_GUIDE.md +1 -1
  298. package/docs/CONFIGURATION.md +1 -0
  299. package/docs/PR_REVIEW_LOOP.md +21 -11
  300. package/docs/SDK.md +94 -0
  301. package/marketplace.json +2 -2
  302. package/package.json +1 -1
  303. package/packages/pm-beads/package.json +1 -1
  304. package/packages/pm-calendar/package.json +1 -1
  305. package/packages/pm-command-kit/package.json +1 -1
  306. package/packages/pm-governance-audit/package.json +1 -1
  307. package/packages/pm-guide-shell/package.json +1 -1
  308. package/packages/pm-kanban/package.json +1 -1
  309. package/packages/pm-lifecycle-hooks/package.json +1 -1
  310. package/packages/pm-linked-test-adapters/package.json +1 -1
  311. package/packages/pm-search-advanced/package.json +1 -1
  312. package/packages/pm-templates/package.json +1 -1
  313. package/packages/pm-todos/package.json +1 -1
  314. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  315. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  316. package/dist/cli/commands/linked-artifacts.js.map +0 -1
  317. package/dist/cli-bundle/chunks/append-CTKFDEAX.js +0 -11
  318. package/dist/cli-bundle/chunks/chunk-56DX6QYG.js.map +0 -1
  319. package/dist/cli-bundle/chunks/chunk-57JVERX3.js.map +0 -7
  320. package/dist/cli-bundle/chunks/chunk-5WEYOVZ7.js.map +0 -7
  321. package/dist/cli-bundle/chunks/chunk-6O2HJENY.js.map +0 -7
  322. package/dist/cli-bundle/chunks/chunk-CCAGZCZK.js +0 -17
  323. package/dist/cli-bundle/chunks/chunk-CCAGZCZK.js.map +0 -7
  324. package/dist/cli-bundle/chunks/chunk-D2LXG7WX.js.map +0 -1
  325. package/dist/cli-bundle/chunks/chunk-DGJF32JF.js.map +0 -7
  326. package/dist/cli-bundle/chunks/chunk-FCVVMAEX.js.map +0 -1
  327. package/dist/cli-bundle/chunks/chunk-FUOK7JZ6.js +0 -14
  328. package/dist/cli-bundle/chunks/chunk-FUOK7JZ6.js.map +0 -1
  329. package/dist/cli-bundle/chunks/chunk-G3IB5GTD.js.map +0 -7
  330. package/dist/cli-bundle/chunks/chunk-J567OZJY.js.map +0 -1
  331. package/dist/cli-bundle/chunks/chunk-LDO24J5I.js.map +0 -7
  332. package/dist/cli-bundle/chunks/chunk-NA5SBIB4.js.map +0 -7
  333. package/dist/cli-bundle/chunks/chunk-OKDBHOON.js.map +0 -1
  334. package/dist/cli-bundle/chunks/chunk-OMT4NO7T.js.map +0 -7
  335. package/dist/cli-bundle/chunks/chunk-OTZ3C2NE.js.map +0 -1
  336. package/dist/cli-bundle/chunks/chunk-QRRUGIJN.js.map +0 -1
  337. package/dist/cli-bundle/chunks/chunk-QXYKH56X.js.map +0 -7
  338. package/dist/cli-bundle/chunks/chunk-RKGFUC4O.js.map +0 -1
  339. package/dist/cli-bundle/chunks/chunk-RPCCQDG2.js.map +0 -7
  340. package/dist/cli-bundle/chunks/chunk-TGG7YGMC.js.map +0 -1
  341. package/dist/cli-bundle/chunks/chunk-TNGLCRKS.js.map +0 -1
  342. package/dist/cli-bundle/chunks/chunk-UTYNQ2WH.js.map +0 -7
  343. package/dist/cli-bundle/chunks/chunk-VL4LYTJN.js.map +0 -7
  344. package/dist/cli-bundle/chunks/chunk-VLFLRFJP.js.map +0 -1
  345. package/dist/cli-bundle/chunks/chunk-WKSFBBZT.js.map +0 -1
  346. package/dist/cli-bundle/chunks/chunk-XY3CC3EM.js.map +0 -7
  347. package/dist/cli-bundle/chunks/chunk-ZTSV7P2T.js.map +0 -1
  348. package/dist/cli-bundle/chunks/close-BWM7FTF4.js +0 -12
  349. package/dist/cli-bundle/chunks/close-many-AUHTVFUQ.js +0 -21
  350. package/dist/cli-bundle/chunks/comments-7D5VPBZI.js +0 -13
  351. package/dist/cli-bundle/chunks/copy-QJ6ZVWZV.js +0 -9
  352. package/dist/cli-bundle/chunks/create-FGMTTYOI.js +0 -25
  353. package/dist/cli-bundle/chunks/delete-L2GMMMPR.js +0 -10
  354. package/dist/cli-bundle/chunks/deps-KTFI4RWD.js +0 -13
  355. package/dist/cli-bundle/chunks/docs-VNURA275.js +0 -14
  356. package/dist/cli-bundle/chunks/files-UNFPZLTG.js +0 -18
  357. package/dist/cli-bundle/chunks/focus-MI2UHBP4.js +0 -10
  358. package/dist/cli-bundle/chunks/history-redact-VAHGBUHI.js +0 -16
  359. package/dist/cli-bundle/chunks/history-repair-DDYQXR43.js +0 -18
  360. package/dist/cli-bundle/chunks/learnings-VWJEKHEO.js +0 -13
  361. package/dist/cli-bundle/chunks/notes-NGVJJJQO.js +0 -13
  362. package/dist/cli-bundle/chunks/plan-U6SQJUFI.js +0 -24
  363. package/dist/cli-bundle/chunks/restore-AX6ZMGHZ.js +0 -14
  364. package/dist/cli-bundle/chunks/update-XYHF3YZF.js +0 -21
  365. package/dist/cli-bundle/chunks/update-many-5HKVHFUL.js +0 -30
  366. /package/dist/cli-bundle/chunks/{append-CTKFDEAX.js.map → append-DYQWQK2J.js.map} +0 -0
  367. /package/dist/cli-bundle/chunks/{append-2FS6MVG7.js.map → append-PVZJDM6J.js.map} +0 -0
  368. /package/dist/cli-bundle/chunks/{chunk-J2WAWP4U.js.map → chunk-2FNWQXZ2.js.map} +0 -0
  369. /package/dist/cli-bundle/chunks/{chunk-YFGYDZRP.js.map → chunk-2GA3NK35.js.map} +0 -0
  370. /package/dist/cli-bundle/chunks/{chunk-XFEIASAC.js.map → chunk-2QIQGYPW.js.map} +0 -0
  371. /package/dist/cli-bundle/chunks/{chunk-3WCGYH5Q.js.map → chunk-3CMRNVTO.js.map} +0 -0
  372. /package/dist/cli-bundle/chunks/{close-BWM7FTF4.js.map → chunk-3HKUXVKV.js.map} +0 -0
  373. /package/dist/cli-bundle/chunks/{chunk-VDAZPPRU.js.map → chunk-3I3LRT2G.js.map} +0 -0
  374. /package/dist/cli-bundle/chunks/{chunk-3P3RFJIQ.js.map → chunk-3TL7WOEF.js.map} +0 -0
  375. /package/dist/cli-bundle/chunks/{chunk-4SHJ5JS3.js.map → chunk-44LNIULG.js.map} +0 -0
  376. /package/dist/cli-bundle/chunks/{chunk-BVCF4ULV.js.map → chunk-4RXTMU57.js.map} +0 -0
  377. /package/dist/cli-bundle/chunks/{chunk-XMI2TRY5.js.map → chunk-4WREH7RT.js.map} +0 -0
  378. /package/dist/cli-bundle/chunks/{chunk-JYUGUXFW.js.map → chunk-5CT5BW6E.js.map} +0 -0
  379. /package/dist/cli-bundle/chunks/{chunk-QGH6WL6L.js.map → chunk-655STMGA.js.map} +0 -0
  380. /package/dist/cli-bundle/chunks/{chunk-DGKBWCMA.js.map → chunk-6IIVBC56.js.map} +0 -0
  381. /package/dist/cli-bundle/chunks/{chunk-D4GPNYYP.js.map → chunk-6OTZMORS.js.map} +0 -0
  382. /package/dist/cli-bundle/chunks/{chunk-JVRVXO6M.js.map → chunk-6PKA3SJQ.js.map} +0 -0
  383. /package/dist/cli-bundle/chunks/{close-many-AUHTVFUQ.js.map → chunk-6X5MZ5R2.js.map} +0 -0
  384. /package/dist/cli-bundle/chunks/{close-CU56F47E.js.map → chunk-76UBY2EE.js.map} +0 -0
  385. /package/dist/cli-bundle/chunks/{chunk-ZS2KPCJN.js.map → chunk-7QDSYUMF.js.map} +0 -0
  386. /package/dist/cli-bundle/chunks/{chunk-Z7TFPIJ6.js.map → chunk-7TQMR6LK.js.map} +0 -0
  387. /package/dist/cli-bundle/chunks/{chunk-AHA4POA6.js.map → chunk-ABRCOSDC.js.map} +0 -0
  388. /package/dist/cli-bundle/chunks/{chunk-KQJVTQVK.js.map → chunk-ANSJHDOZ.js.map} +0 -0
  389. /package/dist/cli-bundle/chunks/{close-many-ZQ2WP67J.js.map → chunk-B7SWOIP6.js.map} +0 -0
  390. /package/dist/cli-bundle/chunks/{chunk-HXTCZSAI.js.map → chunk-DBZVUJTK.js.map} +0 -0
  391. /package/dist/cli-bundle/chunks/{chunk-2QNOWOIB.js.map → chunk-DO5RGJXT.js.map} +0 -0
  392. /package/dist/cli-bundle/chunks/{chunk-MKONZ4UO.js.map → chunk-DRNJPEPQ.js.map} +0 -0
  393. /package/dist/cli-bundle/chunks/{chunk-H36FXA7B.js.map → chunk-DYEX6NFH.js.map} +0 -0
  394. /package/dist/cli-bundle/chunks/{chunk-GAJ7U7B4.js.map → chunk-ERL2YFJ2.js.map} +0 -0
  395. /package/dist/cli-bundle/chunks/{chunk-FPEYOFEF.js.map → chunk-F7PSHRNO.js.map} +0 -0
  396. /package/dist/cli-bundle/chunks/{chunk-UH7OLT6F.js.map → chunk-FDSBDNYE.js.map} +0 -0
  397. /package/dist/cli-bundle/chunks/{chunk-RQAY7C5T.js.map → chunk-FJZDA6MS.js.map} +0 -0
  398. /package/dist/cli-bundle/chunks/{chunk-B4TVNGRX.js.map → chunk-FO7GMJKG.js.map} +0 -0
  399. /package/dist/cli-bundle/chunks/{comments-UDUMKXL6.js.map → chunk-FRQ63VPB.js.map} +0 -0
  400. /package/dist/cli-bundle/chunks/{chunk-U252II47.js.map → chunk-FTQLW4JD.js.map} +0 -0
  401. /package/dist/cli-bundle/chunks/{chunk-AGD4VZXH.js.map → chunk-H2QBAKLQ.js.map} +0 -0
  402. /package/dist/cli-bundle/chunks/{chunk-CJVQ4XIG.js.map → chunk-HAMLIWAF.js.map} +0 -0
  403. /package/dist/cli-bundle/chunks/{chunk-7QOIQTPB.js.map → chunk-HLHSQ5CA.js.map} +0 -0
  404. /package/dist/cli-bundle/chunks/{chunk-AHC7J6XD.js.map → chunk-IA3YFTXT.js.map} +0 -0
  405. /package/dist/cli-bundle/chunks/{chunk-5ZCVF4WF.js.map → chunk-IAPHYPRL.js.map} +0 -0
  406. /package/dist/cli-bundle/chunks/{chunk-OCSQWIOW.js.map → chunk-IFZA4VB5.js.map} +0 -0
  407. /package/dist/cli-bundle/chunks/{chunk-4WMFM77X.js.map → chunk-J4NZOP3I.js.map} +0 -0
  408. /package/dist/cli-bundle/chunks/{chunk-MTNKSSSO.js.map → chunk-JL7WZ4O2.js.map} +0 -0
  409. /package/dist/cli-bundle/chunks/{chunk-AZ52LTCY.js.map → chunk-K7WNZ7KD.js.map} +0 -0
  410. /package/dist/cli-bundle/chunks/{chunk-2OLSXXIV.js.map → chunk-KADLSPIU.js.map} +0 -0
  411. /package/dist/cli-bundle/chunks/{chunk-RQKORMM4.js.map → chunk-KB726FMH.js.map} +0 -0
  412. /package/dist/cli-bundle/chunks/{chunk-TZTQ4TVV.js.map → chunk-M6ASXYCU.js.map} +0 -0
  413. /package/dist/cli-bundle/chunks/{chunk-WDDOAU7Z.js.map → chunk-M7EWN4TF.js.map} +0 -0
  414. /package/dist/cli-bundle/chunks/{chunk-327DSGW2.js.map → chunk-MD6ULIPJ.js.map} +0 -0
  415. /package/dist/cli-bundle/chunks/{chunk-M52DG2QJ.js.map → chunk-MQZ3PLCF.js.map} +0 -0
  416. /package/dist/cli-bundle/chunks/{chunk-GQ2CQNGI.js.map → chunk-N3CMP4NI.js.map} +0 -0
  417. /package/dist/cli-bundle/chunks/{chunk-J7SBFUZC.js.map → chunk-NAQYVWSQ.js.map} +0 -0
  418. /package/dist/cli-bundle/chunks/{chunk-U2GMYP3L.js.map → chunk-NKW36AMT.js.map} +0 -0
  419. /package/dist/cli-bundle/chunks/{chunk-FTQQAPRX.js.map → chunk-PHKP3AGR.js.map} +0 -0
  420. /package/dist/cli-bundle/chunks/{chunk-WVUXNIYO.js.map → chunk-Q37E63AM.js.map} +0 -0
  421. /package/dist/cli-bundle/chunks/{chunk-JVXV7ANV.js.map → chunk-Q7E6OYZK.js.map} +0 -0
  422. /package/dist/cli-bundle/chunks/{chunk-WVUYATII.js.map → chunk-QABYZYLU.js.map} +0 -0
  423. /package/dist/cli-bundle/chunks/{chunk-7TQPV7HR.js.map → chunk-QSPARJWF.js.map} +0 -0
  424. /package/dist/cli-bundle/chunks/{chunk-GTKILM6F.js.map → chunk-QZ7LT3XE.js.map} +0 -0
  425. /package/dist/cli-bundle/chunks/{chunk-L3VKY6R6.js.map → chunk-RA5AIAMP.js.map} +0 -0
  426. /package/dist/cli-bundle/chunks/{chunk-BJS27ALI.js.map → chunk-RGXD5JJR.js.map} +0 -0
  427. /package/dist/cli-bundle/chunks/{chunk-TSEPW2P6.js.map → chunk-RMF3IOYQ.js.map} +0 -0
  428. /package/dist/cli-bundle/chunks/{chunk-TGGTXC52.js.map → chunk-TH7U4KLY.js.map} +0 -0
  429. /package/dist/cli-bundle/chunks/{chunk-LP4UATP6.js.map → chunk-TWLDBKQU.js.map} +0 -0
  430. /package/dist/cli-bundle/chunks/{chunk-UK222BHQ.js.map → chunk-TZRTLMWM.js.map} +0 -0
  431. /package/dist/cli-bundle/chunks/{chunk-6E6S2X6S.js.map → chunk-UB2QYSTO.js.map} +0 -0
  432. /package/dist/cli-bundle/chunks/{chunk-S6CXUSYC.js.map → chunk-UGTVWL3E.js.map} +0 -0
  433. /package/dist/cli-bundle/chunks/{chunk-BNS6QHTZ.js.map → chunk-UJ4HJYWL.js.map} +0 -0
  434. /package/dist/cli-bundle/chunks/{chunk-BYVOEJPQ.js.map → chunk-UKUIIBDW.js.map} +0 -0
  435. /package/dist/cli-bundle/chunks/{chunk-SGDBVR7X.js.map → chunk-UVBA6F5A.js.map} +0 -0
  436. /package/dist/cli-bundle/chunks/{chunk-DZRZMBBF.js.map → chunk-VJTAEIPC.js.map} +0 -0
  437. /package/dist/cli-bundle/chunks/{chunk-74PWVJON.js.map → chunk-W6HZ55JO.js.map} +0 -0
  438. /package/dist/cli-bundle/chunks/{chunk-P7IFURWH.js.map → chunk-WPAWZW7S.js.map} +0 -0
  439. /package/dist/cli-bundle/chunks/{chunk-36LEOWSX.js.map → chunk-WQUEHPZB.js.map} +0 -0
  440. /package/dist/cli-bundle/chunks/{chunk-FCKJF7G2.js.map → chunk-WRKB56FC.js.map} +0 -0
  441. /package/dist/cli-bundle/chunks/{chunk-KR5EHAN4.js.map → chunk-X3GYR4P2.js.map} +0 -0
  442. /package/dist/cli-bundle/chunks/{chunk-OWW2KXOV.js.map → chunk-YQYG2V23.js.map} +0 -0
  443. /package/dist/cli-bundle/chunks/{chunk-G2SCT7BC.js.map → chunk-YVKE5ZDM.js.map} +0 -0
  444. /package/dist/cli-bundle/chunks/{chunk-QHIN4UTF.js.map → chunk-ZAYYDNB3.js.map} +0 -0
  445. /package/dist/cli-bundle/chunks/{comments-7D5VPBZI.js.map → chunk-ZHBI2AP7.js.map} +0 -0
  446. /package/dist/cli-bundle/chunks/{chunk-GNVBUNJQ.js.map → chunk-ZTRBSABY.js.map} +0 -0
  447. /package/dist/cli-bundle/chunks/{chunk-PY32KGQU.js.map → chunk-ZUKSZVBW.js.map} +0 -0
  448. /package/dist/cli-bundle/chunks/{copy-VFHECFBV.js.map → close-LZECOMHO.js.map} +0 -0
  449. /package/dist/cli-bundle/chunks/{copy-QJ6ZVWZV.js.map → close-RI4JQQHU.js.map} +0 -0
  450. /package/dist/cli-bundle/chunks/{create-FGMTTYOI.js.map → close-many-LY2XJ52M.js.map} +0 -0
  451. /package/dist/cli-bundle/chunks/{create-CE2X3SGF.js.map → close-many-ZHI6A5TN.js.map} +0 -0
  452. /package/dist/cli-bundle/chunks/{delete-L2GMMMPR.js.map → comments-35M273DN.js.map} +0 -0
  453. /package/dist/cli-bundle/chunks/{delete-2JXQCHHT.js.map → comments-AJWRTFZ5.js.map} +0 -0
  454. /package/dist/cli-bundle/chunks/{deps-FPXNLO6C.js.map → copy-GMXYKBXT.js.map} +0 -0
  455. /package/dist/cli-bundle/chunks/{deps-KTFI4RWD.js.map → copy-NPYM7M7U.js.map} +0 -0
  456. /package/dist/cli-bundle/chunks/{docs-VNURA275.js.map → create-F53OBTOU.js.map} +0 -0
  457. /package/dist/cli-bundle/chunks/{docs-AMAR4OHU.js.map → create-HU4Q7RJX.js.map} +0 -0
  458. /package/dist/cli-bundle/chunks/{files-JFHN7DYM.js.map → delete-GSDZLTRC.js.map} +0 -0
  459. /package/dist/cli-bundle/chunks/{files-UNFPZLTG.js.map → delete-ODRWJWAM.js.map} +0 -0
  460. /package/dist/cli-bundle/chunks/{focus-MI2UHBP4.js.map → deps-U57I7EAK.js.map} +0 -0
  461. /package/dist/cli-bundle/chunks/{focus-QFN2RRZ7.js.map → deps-WWB7P2GT.js.map} +0 -0
  462. /package/dist/cli-bundle/chunks/{history-compact-SAHT5D46.js.map → docs-G7N4E2JO.js.map} +0 -0
  463. /package/dist/cli-bundle/chunks/{history-compact-G34XMABV.js.map → docs-MQIY2ZQS.js.map} +0 -0
  464. /package/dist/cli-bundle/chunks/{history-redact-VAHGBUHI.js.map → files-TBZD7V6H.js.map} +0 -0
  465. /package/dist/cli-bundle/chunks/{history-redact-IFJDNKLZ.js.map → files-TTY6N2AV.js.map} +0 -0
  466. /package/dist/cli-bundle/chunks/{history-repair-DDYQXR43.js.map → focus-U5TRVCRS.js.map} +0 -0
  467. /package/dist/cli-bundle/chunks/{history-repair-NXLQTCVN.js.map → focus-XT6YVFFX.js.map} +0 -0
  468. /package/dist/cli-bundle/chunks/{learnings-5CZKAMBS.js.map → history-compact-KKVUWB4V.js.map} +0 -0
  469. /package/dist/cli-bundle/chunks/{learnings-VWJEKHEO.js.map → history-compact-M7GHYVFN.js.map} +0 -0
  470. /package/dist/cli-bundle/chunks/{notes-POMK37UI.js.map → history-redact-3DVZOILD.js.map} +0 -0
  471. /package/dist/cli-bundle/chunks/{notes-NGVJJJQO.js.map → history-redact-JIHZLHDP.js.map} +0 -0
  472. /package/dist/cli-bundle/chunks/{plan-YBNYNT3A.js.map → history-repair-ITDUMK4N.js.map} +0 -0
  473. /package/dist/cli-bundle/chunks/{plan-U6SQJUFI.js.map → history-repair-NAFCHLH7.js.map} +0 -0
  474. /package/dist/cli-bundle/chunks/{profile-JNKSU6EQ.js.map → learnings-FGO3NSFW.js.map} +0 -0
  475. /package/dist/cli-bundle/chunks/{profile-A2WPVG6I.js.map → learnings-SONGPSHI.js.map} +0 -0
  476. /package/dist/cli-bundle/chunks/{restore-AX6ZMGHZ.js.map → notes-BSD53H2W.js.map} +0 -0
  477. /package/dist/cli-bundle/chunks/{restore-IVS5XGYR.js.map → notes-NQ6RXVW6.js.map} +0 -0
  478. /package/dist/cli-bundle/chunks/{schema-R3U2REY4.js.map → plan-2NNEO46V.js.map} +0 -0
  479. /package/dist/cli-bundle/chunks/{schema-P2MF23JO.js.map → plan-AWLYGBNV.js.map} +0 -0
  480. /package/dist/cli-bundle/chunks/{update-YBIQESMH.js.map → profile-AAQUU6T3.js.map} +0 -0
  481. /package/dist/cli-bundle/chunks/{update-XYHF3YZF.js.map → profile-U725ATWZ.js.map} +0 -0
  482. /package/dist/cli-bundle/chunks/{register-mutation-3OXYXBKH.js.map → register-mutation-4FMGJJF7.js.map} +0 -0
  483. /package/dist/cli-bundle/chunks/{register-mutation-WK265BM7.js.map → register-mutation-UELYYOR7.js.map} +0 -0
  484. /package/dist/cli-bundle/chunks/{register-setup-CCK7CJVR.js.map → register-setup-5XNGKJ22.js.map} +0 -0
  485. /package/dist/cli-bundle/chunks/{register-setup-CPZBGSOJ.js.map → register-setup-ZTNY6S7R.js.map} +0 -0
  486. /package/dist/cli-bundle/chunks/{update-many-5HKVHFUL.js.map → restore-66GLMHIX.js.map} +0 -0
  487. /package/dist/cli-bundle/chunks/{update-many-F3CIV5SQ.js.map → restore-B3BAB6X2.js.map} +0 -0
@@ -0,0 +1,114 @@
1
+ /**
2
+ * @module sdk/context-packing
3
+ *
4
+ * Deterministic, token-budget-aware packing primitives for ranked context and
5
+ * next-work candidates. The packer is deliberately storage-agnostic so custom
6
+ * tools can reuse the exact selection contract with their own projections.
7
+ */
8
+ /** Detail levels a context candidate may occupy inside a bounded packet. */
9
+ export type ContextProjectionLevel = "identity" | "summary" | "full";
10
+ /** Stable intent-keyed policies for risk, diversity, and safety-aware packing. */
11
+ export declare const CONTEXT_PACKING_PROFILES: {
12
+ readonly balanced: {
13
+ readonly redundancyPenalty: 0.35;
14
+ readonly uncertaintyPenalty: 0.2;
15
+ };
16
+ readonly context: {
17
+ readonly redundancyPenalty: 0.45;
18
+ readonly uncertaintyPenalty: 0.15;
19
+ };
20
+ readonly next: {
21
+ readonly redundancyPenalty: 0.25;
22
+ readonly uncertaintyPenalty: 0.3;
23
+ };
24
+ };
25
+ /** Built-in task-set profiles selected from the triggering command intent. */
26
+ export type ContextPackingProfile = keyof typeof CONTEXT_PACKING_PROFILES;
27
+ /** Token costs for the monotone projection levels of one candidate. */
28
+ export interface ContextProjectionCosts {
29
+ /** Stable identity-only representation cost. */
30
+ identity: number;
31
+ /** Compact summary representation cost. */
32
+ summary: number;
33
+ /** Full representation cost. */
34
+ full: number;
35
+ }
36
+ /** One ranked candidate offered to the context packet optimizer. */
37
+ export interface ContextPackingCandidate<TItem> {
38
+ /** Stable candidate identifier. */
39
+ id: string;
40
+ /** Caller-owned value returned unchanged for selected candidates. */
41
+ item: TItem;
42
+ /** One-based relevance rank; lower is better. */
43
+ rank: number;
44
+ /** Normalized relevance score. */
45
+ score: number;
46
+ /** Projection-specific token estimates. */
47
+ token_costs: ContextProjectionCosts;
48
+ /** Candidates sharing a cluster compete through a redundancy penalty. */
49
+ cluster?: string;
50
+ /** Required anchors are admitted before optional candidates. */
51
+ required?: boolean;
52
+ /** Optional credible-width estimate used for risk-adjusted value. */
53
+ uncertainty?: number;
54
+ /** Optional lineage identity used to suppress superseded duplicates. */
55
+ lineage?: string;
56
+ }
57
+ /** One selected candidate and the projection depth bought for it. */
58
+ export interface PackedContextCandidate<TItem> extends ContextPackingCandidate<TItem> {
59
+ /** Projection depth selected by the packer. */
60
+ projection: ContextProjectionLevel;
61
+ /** Tokens charged to the packet. */
62
+ tokens: number;
63
+ /** Risk- and redundancy-adjusted value used for selection. */
64
+ marginal_value: number;
65
+ }
66
+ /** Accounting and completeness metadata for one packed context packet. */
67
+ export interface ContextPackingReport<TItem> {
68
+ /** Selected candidates in deterministic relevance order. */
69
+ included: PackedContextCandidate<TItem>[];
70
+ /** Ranked candidate identifiers omitted after projection degradation. */
71
+ omitted_ids: string[];
72
+ /** Explicit packet token budget. */
73
+ token_budget: number;
74
+ /** Estimated tokens consumed by selected projections. */
75
+ used_tokens: number;
76
+ /** Tokens left unspent. */
77
+ remaining_tokens: number;
78
+ /** True when every candidate fit at full detail. */
79
+ complete: boolean;
80
+ /** Whether selection inspected every optional candidate before its deadline. */
81
+ selection_complete: boolean;
82
+ /** Machine-readable reason selection stopped. */
83
+ termination_reason: "exhausted" | "latency_budget";
84
+ /** Candidate comparisons completed by the bounded selector. */
85
+ evaluated_candidates: number;
86
+ /** Explicit selection latency budget, or null when unbounded. */
87
+ latency_budget_ms: number | null;
88
+ /** Stable task-set profile disclosed to downstream evaluation. */
89
+ profile: ContextPackingProfile;
90
+ /** Projection degradation order used by the optimizer. */
91
+ degradation_ladder: ContextProjectionLevel[];
92
+ }
93
+ /** Options controlling deterministic packet selection. */
94
+ export interface PackContextCandidatesOptions {
95
+ /** Maximum estimated tokens available to the packet. */
96
+ tokenBudget: number;
97
+ /** Task-set profile disclosed in the result envelope. */
98
+ profile?: ContextPackingProfile;
99
+ /** Penalty applied when a cluster or lineage is already represented. */
100
+ redundancyPenalty?: number;
101
+ /** Risk-aversion coefficient applied to candidate uncertainty. */
102
+ uncertaintyPenalty?: number;
103
+ /** Maximum selector wall-clock time; required anchors remain mask-immune. */
104
+ latencyBudgetMs?: number;
105
+ /** Monotonic clock override for deterministic hosts and tests. */
106
+ readClock?: () => number;
107
+ }
108
+ /**
109
+ * Packs ranked candidates under an explicit token budget. Required anchors are
110
+ * admitted first, optional rows compete by marginal value per token, and then
111
+ * selected rows are upgraded from identity to summary to full detail. This
112
+ * guarantees projection degradation happens before omission.
113
+ */
114
+ export declare function packContextCandidates<TItem>(candidates: readonly ContextPackingCandidate<TItem>[], options: PackContextCandidatesOptions): ContextPackingReport<TItem>;
@@ -0,0 +1,219 @@
1
+ /**
2
+ * @module sdk/context-packing
3
+ *
4
+ * Deterministic, token-budget-aware packing primitives for ranked context and
5
+ * next-work candidates. The packer is deliberately storage-agnostic so custom
6
+ * tools can reuse the exact selection contract with their own projections.
7
+ */
8
+ /** Stable intent-keyed policies for risk, diversity, and safety-aware packing. */
9
+
10
+ !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]="f2b38b30-c8d0-51a2-9444-b2e0db9fa353")}catch(e){}}();
11
+ export const CONTEXT_PACKING_PROFILES = {
12
+ balanced: { redundancyPenalty: 0.35, uncertaintyPenalty: 0.2 },
13
+ context: { redundancyPenalty: 0.45, uncertaintyPenalty: 0.15 },
14
+ next: { redundancyPenalty: 0.25, uncertaintyPenalty: 0.3 },
15
+ };
16
+ const PROJECTION_LEVELS = [
17
+ "identity",
18
+ "summary",
19
+ "full",
20
+ ];
21
+ function assertPackingCandidate(candidate) {
22
+ if (!candidate.id.trim() ||
23
+ !Number.isInteger(candidate.rank) ||
24
+ candidate.rank < 1) {
25
+ throw new TypeError("Context packing candidates require a non-empty id and positive integer rank");
26
+ }
27
+ if (!Number.isFinite(candidate.score) || candidate.score < 0) {
28
+ throw new TypeError("Context packing candidate scores must be finite and non-negative");
29
+ }
30
+ const costs = PROJECTION_LEVELS.map((level) => candidate.token_costs[level]);
31
+ if (costs.some((cost) => !Number.isInteger(cost) || cost < 1) ||
32
+ costs[0] > costs[1] ||
33
+ costs[1] > costs[2]) {
34
+ throw new TypeError("Context projection costs must be positive monotone integers");
35
+ }
36
+ if (candidate.uncertainty !== undefined &&
37
+ (!Number.isFinite(candidate.uncertainty) || candidate.uncertainty < 0)) {
38
+ throw new TypeError("Context packing uncertainty must be finite and non-negative");
39
+ }
40
+ }
41
+ function resolvePackingPenalties(options) {
42
+ if (!Number.isInteger(options.tokenBudget) || options.tokenBudget < 1) {
43
+ throw new TypeError("Context packing tokenBudget must be a positive integer");
44
+ }
45
+ const profile = options.profile ?? "balanced";
46
+ const policy = CONTEXT_PACKING_PROFILES[profile];
47
+ if (!policy)
48
+ throw new TypeError("Unknown context packing profile");
49
+ const redundancy = options.redundancyPenalty ?? policy.redundancyPenalty;
50
+ const uncertainty = options.uncertaintyPenalty ?? policy.uncertaintyPenalty;
51
+ if (!Number.isFinite(redundancy) ||
52
+ redundancy < 0 ||
53
+ redundancy > 1 ||
54
+ !Number.isFinite(uncertainty) ||
55
+ uncertainty < 0) {
56
+ throw new TypeError("Context packing penalties must be finite and within their supported ranges");
57
+ }
58
+ if (options.latencyBudgetMs !== undefined &&
59
+ (!Number.isFinite(options.latencyBudgetMs) || options.latencyBudgetMs <= 0)) {
60
+ throw new TypeError("Context packing latencyBudgetMs must be positive");
61
+ }
62
+ return { redundancy, uncertainty, profile };
63
+ }
64
+ function orderPackingCandidates(candidates) {
65
+ const ids = new Set();
66
+ for (const candidate of candidates) {
67
+ assertPackingCandidate(candidate);
68
+ if (ids.has(candidate.id)) {
69
+ throw new TypeError("Context packing candidates require unique ids");
70
+ }
71
+ ids.add(candidate.id);
72
+ }
73
+ return [...candidates].sort((left, right) => left.rank - right.rank || left.id.localeCompare(right.id));
74
+ }
75
+ function findBestAffordableCandidate(candidates, remaining, valueOf, deadline, readClock) {
76
+ let bestIndex = -1;
77
+ let evaluated = 0;
78
+ for (let index = 0; index < candidates.length; index += 1) {
79
+ if (index % 128 === 0 && readClock() >= deadline) {
80
+ return { index: bestIndex, evaluated, timedOut: true };
81
+ }
82
+ const candidate = candidates[index];
83
+ if (candidate.token_costs.identity > remaining)
84
+ continue;
85
+ evaluated += 1;
86
+ const best = bestIndex < 0 ? undefined : candidates[bestIndex];
87
+ const density = valueOf(candidate) / candidate.token_costs.identity;
88
+ const bestDensity = best === undefined
89
+ ? Number.NEGATIVE_INFINITY
90
+ : valueOf(best) / best.token_costs.identity;
91
+ if (density > bestDensity ||
92
+ (density === bestDensity &&
93
+ best !== undefined &&
94
+ (candidate.rank < best.rank ||
95
+ (candidate.rank === best.rank &&
96
+ candidate.id.localeCompare(best.id) < 0)))) {
97
+ bestIndex = index;
98
+ }
99
+ }
100
+ return { index: bestIndex, evaluated, timedOut: false };
101
+ }
102
+ function selectIdentityCandidates(params) {
103
+ const represented = new Set();
104
+ const included = [];
105
+ let remaining = params.tokenBudget;
106
+ const valueOf = (candidate) => {
107
+ const key = candidate.lineage ?? candidate.cluster;
108
+ const redundancy = key && represented.has(key) ? 1 - params.redundancyPenalty : 1;
109
+ return Math.max(0, (candidate.score -
110
+ params.uncertaintyPenalty * (candidate.uncertainty ?? 0)) *
111
+ redundancy);
112
+ };
113
+ const admit = (candidate) => {
114
+ const tokens = candidate.token_costs.identity;
115
+ included.push({
116
+ ...candidate,
117
+ projection: "identity",
118
+ tokens,
119
+ marginal_value: valueOf(candidate),
120
+ });
121
+ remaining -= tokens;
122
+ const key = candidate.lineage ?? candidate.cluster;
123
+ if (key)
124
+ represented.add(key);
125
+ };
126
+ for (const candidate of params.ordered.filter((entry) => entry.required)) {
127
+ if (candidate.token_costs.identity <= remaining)
128
+ admit(candidate);
129
+ }
130
+ const optional = params.ordered.filter((entry) => !entry.required);
131
+ let selectionComplete = true;
132
+ let evaluatedCandidates = 0;
133
+ while (optional.length > 0) {
134
+ const selection = findBestAffordableCandidate(optional, remaining, valueOf, params.deadline, params.readClock);
135
+ evaluatedCandidates += selection.evaluated;
136
+ if (selection.timedOut)
137
+ selectionComplete = false;
138
+ if (selection.index < 0 || selection.timedOut)
139
+ break;
140
+ admit(optional.splice(selection.index, 1)[0]);
141
+ }
142
+ return {
143
+ included,
144
+ remaining,
145
+ selectionComplete,
146
+ evaluatedCandidates,
147
+ };
148
+ }
149
+ function upgradeSelectedProjections(included, initialRemaining) {
150
+ let remaining = initialRemaining;
151
+ for (const target of ["summary", "full"]) {
152
+ const previous = target === "summary" ? "identity" : "summary";
153
+ const upgrades = [...included].sort((left, right) => {
154
+ const leftCost = left.token_costs[target] - left.token_costs[previous];
155
+ const rightCost = right.token_costs[target] - right.token_costs[previous];
156
+ return (right.marginal_value / Math.max(rightCost, 1) -
157
+ left.marginal_value / Math.max(leftCost, 1) || left.rank - right.rank || left.id.localeCompare(right.id));
158
+ });
159
+ for (const entry of upgrades) {
160
+ if (entry.projection !== previous)
161
+ continue;
162
+ const extra = entry.token_costs[target] - entry.tokens;
163
+ if (extra > remaining)
164
+ continue;
165
+ entry.projection = target;
166
+ entry.tokens += extra;
167
+ remaining -= extra;
168
+ }
169
+ }
170
+ return remaining;
171
+ }
172
+ /**
173
+ * Packs ranked candidates under an explicit token budget. Required anchors are
174
+ * admitted first, optional rows compete by marginal value per token, and then
175
+ * selected rows are upgraded from identity to summary to full detail. This
176
+ * guarantees projection degradation happens before omission.
177
+ */
178
+ export function packContextCandidates(candidates, options) {
179
+ const penalties = resolvePackingPenalties(options);
180
+ const ordered = orderPackingCandidates(candidates);
181
+ const readClock = options.readClock ?? performance.now.bind(performance);
182
+ const deadline = options.latencyBudgetMs === undefined
183
+ ? Number.POSITIVE_INFINITY
184
+ : readClock() + options.latencyBudgetMs;
185
+ const selection = selectIdentityCandidates({
186
+ ordered,
187
+ tokenBudget: options.tokenBudget,
188
+ redundancyPenalty: penalties.redundancy,
189
+ uncertaintyPenalty: penalties.uncertainty,
190
+ deadline,
191
+ readClock,
192
+ });
193
+ const { included } = selection;
194
+ const remaining = upgradeSelectedProjections(included, selection.remaining);
195
+ included.sort((left, right) => left.rank - right.rank || left.id.localeCompare(right.id));
196
+ const selected = new Set(included.map((entry) => entry.id));
197
+ return {
198
+ included,
199
+ omitted_ids: ordered
200
+ .filter((entry) => !selected.has(entry.id))
201
+ .map((entry) => entry.id),
202
+ token_budget: options.tokenBudget,
203
+ used_tokens: options.tokenBudget - remaining,
204
+ remaining_tokens: remaining,
205
+ complete: selection.selectionComplete &&
206
+ included.length === candidates.length &&
207
+ included.every((entry) => entry.projection === "full"),
208
+ selection_complete: selection.selectionComplete,
209
+ termination_reason: selection.selectionComplete
210
+ ? "exhausted"
211
+ : "latency_budget",
212
+ evaluated_candidates: selection.evaluatedCandidates,
213
+ latency_budget_ms: options.latencyBudgetMs ?? null,
214
+ profile: penalties.profile,
215
+ degradation_ladder: ["full", "summary", "identity"],
216
+ };
217
+ }
218
+ //# sourceMappingURL=context-packing.js.map
219
+ //# debugId=f2b38b30-c8d0-51a2-9444-b2e0db9fa353
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context-packing.js","sources":["sdk/context-packing.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module sdk/context-packing\n *\n * Deterministic, token-budget-aware packing primitives for ranked context and\n * next-work candidates. The packer is deliberately storage-agnostic so custom\n * tools can reuse the exact selection contract with their own projections.\n */\n\n/** Detail levels a context candidate may occupy inside a bounded packet. */\nexport type ContextProjectionLevel = \"identity\" | \"summary\" | \"full\";\n\n/** Stable intent-keyed policies for risk, diversity, and safety-aware packing. */\nexport const CONTEXT_PACKING_PROFILES = {\n balanced: { redundancyPenalty: 0.35, uncertaintyPenalty: 0.2 },\n context: { redundancyPenalty: 0.45, uncertaintyPenalty: 0.15 },\n next: { redundancyPenalty: 0.25, uncertaintyPenalty: 0.3 },\n} as const;\n\n/** Built-in task-set profiles selected from the triggering command intent. */\nexport type ContextPackingProfile = keyof typeof CONTEXT_PACKING_PROFILES;\n\n/** Token costs for the monotone projection levels of one candidate. */\nexport interface ContextProjectionCosts {\n /** Stable identity-only representation cost. */\n identity: number;\n /** Compact summary representation cost. */\n summary: number;\n /** Full representation cost. */\n full: number;\n}\n\n/** One ranked candidate offered to the context packet optimizer. */\nexport interface ContextPackingCandidate<TItem> {\n /** Stable candidate identifier. */\n id: string;\n /** Caller-owned value returned unchanged for selected candidates. */\n item: TItem;\n /** One-based relevance rank; lower is better. */\n rank: number;\n /** Normalized relevance score. */\n score: number;\n /** Projection-specific token estimates. */\n token_costs: ContextProjectionCosts;\n /** Candidates sharing a cluster compete through a redundancy penalty. */\n cluster?: string;\n /** Required anchors are admitted before optional candidates. */\n required?: boolean;\n /** Optional credible-width estimate used for risk-adjusted value. */\n uncertainty?: number;\n /** Optional lineage identity used to suppress superseded duplicates. */\n lineage?: string;\n}\n\n/** One selected candidate and the projection depth bought for it. */\nexport interface PackedContextCandidate<\n TItem,\n> extends ContextPackingCandidate<TItem> {\n /** Projection depth selected by the packer. */\n projection: ContextProjectionLevel;\n /** Tokens charged to the packet. */\n tokens: number;\n /** Risk- and redundancy-adjusted value used for selection. */\n marginal_value: number;\n}\n\n/** Accounting and completeness metadata for one packed context packet. */\nexport interface ContextPackingReport<TItem> {\n /** Selected candidates in deterministic relevance order. */\n included: PackedContextCandidate<TItem>[];\n /** Ranked candidate identifiers omitted after projection degradation. */\n omitted_ids: string[];\n /** Explicit packet token budget. */\n token_budget: number;\n /** Estimated tokens consumed by selected projections. */\n used_tokens: number;\n /** Tokens left unspent. */\n remaining_tokens: number;\n /** True when every candidate fit at full detail. */\n complete: boolean;\n /** Whether selection inspected every optional candidate before its deadline. */\n selection_complete: boolean;\n /** Machine-readable reason selection stopped. */\n termination_reason: \"exhausted\" | \"latency_budget\";\n /** Candidate comparisons completed by the bounded selector. */\n evaluated_candidates: number;\n /** Explicit selection latency budget, or null when unbounded. */\n latency_budget_ms: number | null;\n /** Stable task-set profile disclosed to downstream evaluation. */\n profile: ContextPackingProfile;\n /** Projection degradation order used by the optimizer. */\n degradation_ladder: ContextProjectionLevel[];\n}\n\n/** Options controlling deterministic packet selection. */\nexport interface PackContextCandidatesOptions {\n /** Maximum estimated tokens available to the packet. */\n tokenBudget: number;\n /** Task-set profile disclosed in the result envelope. */\n profile?: ContextPackingProfile;\n /** Penalty applied when a cluster or lineage is already represented. */\n redundancyPenalty?: number;\n /** Risk-aversion coefficient applied to candidate uncertainty. */\n uncertaintyPenalty?: number;\n /** Maximum selector wall-clock time; required anchors remain mask-immune. */\n latencyBudgetMs?: number;\n /** Monotonic clock override for deterministic hosts and tests. */\n readClock?: () => number;\n}\n\nconst PROJECTION_LEVELS: ContextProjectionLevel[] = [\n \"identity\",\n \"summary\",\n \"full\",\n];\n\nfunction assertPackingCandidate<TItem>(\n candidate: ContextPackingCandidate<TItem>,\n): void {\n if (\n !candidate.id.trim() ||\n !Number.isInteger(candidate.rank) ||\n candidate.rank < 1\n ) {\n throw new TypeError(\n \"Context packing candidates require a non-empty id and positive integer rank\",\n );\n }\n if (!Number.isFinite(candidate.score) || candidate.score < 0) {\n throw new TypeError(\n \"Context packing candidate scores must be finite and non-negative\",\n );\n }\n const costs = PROJECTION_LEVELS.map((level) => candidate.token_costs[level]);\n if (\n costs.some((cost) => !Number.isInteger(cost) || cost < 1) ||\n costs[0]! > costs[1]! ||\n costs[1]! > costs[2]!\n ) {\n throw new TypeError(\n \"Context projection costs must be positive monotone integers\",\n );\n }\n if (\n candidate.uncertainty !== undefined &&\n (!Number.isFinite(candidate.uncertainty) || candidate.uncertainty < 0)\n ) {\n throw new TypeError(\n \"Context packing uncertainty must be finite and non-negative\",\n );\n }\n}\n\nfunction resolvePackingPenalties(options: PackContextCandidatesOptions): {\n redundancy: number;\n uncertainty: number;\n profile: ContextPackingProfile;\n} {\n if (!Number.isInteger(options.tokenBudget) || options.tokenBudget < 1) {\n throw new TypeError(\n \"Context packing tokenBudget must be a positive integer\",\n );\n }\n const profile = options.profile ?? \"balanced\";\n const policy = CONTEXT_PACKING_PROFILES[profile];\n if (!policy) throw new TypeError(\"Unknown context packing profile\");\n const redundancy = options.redundancyPenalty ?? policy.redundancyPenalty;\n const uncertainty = options.uncertaintyPenalty ?? policy.uncertaintyPenalty;\n if (\n !Number.isFinite(redundancy) ||\n redundancy < 0 ||\n redundancy > 1 ||\n !Number.isFinite(uncertainty) ||\n uncertainty < 0\n ) {\n throw new TypeError(\n \"Context packing penalties must be finite and within their supported ranges\",\n );\n }\n if (\n options.latencyBudgetMs !== undefined &&\n (!Number.isFinite(options.latencyBudgetMs) || options.latencyBudgetMs <= 0)\n ) {\n throw new TypeError(\"Context packing latencyBudgetMs must be positive\");\n }\n return { redundancy, uncertainty, profile };\n}\n\nfunction orderPackingCandidates<TItem>(\n candidates: readonly ContextPackingCandidate<TItem>[],\n): ContextPackingCandidate<TItem>[] {\n const ids = new Set<string>();\n for (const candidate of candidates) {\n assertPackingCandidate(candidate);\n if (ids.has(candidate.id)) {\n throw new TypeError(\"Context packing candidates require unique ids\");\n }\n ids.add(candidate.id);\n }\n return [...candidates].sort(\n (left, right) => left.rank - right.rank || left.id.localeCompare(right.id),\n );\n}\n\nfunction findBestAffordableCandidate<TItem>(\n candidates: ContextPackingCandidate<TItem>[],\n remaining: number,\n valueOf: (candidate: ContextPackingCandidate<TItem>) => number,\n deadline: number,\n readClock: () => number,\n): { index: number; evaluated: number; timedOut: boolean } {\n let bestIndex = -1;\n let evaluated = 0;\n for (let index = 0; index < candidates.length; index += 1) {\n if (index % 128 === 0 && readClock() >= deadline) {\n return { index: bestIndex, evaluated, timedOut: true };\n }\n const candidate = candidates[index]!;\n if (candidate.token_costs.identity > remaining) continue;\n evaluated += 1;\n const best = bestIndex < 0 ? undefined : candidates[bestIndex];\n const density = valueOf(candidate) / candidate.token_costs.identity;\n const bestDensity =\n best === undefined\n ? Number.NEGATIVE_INFINITY\n : valueOf(best) / best.token_costs.identity;\n if (\n density > bestDensity ||\n (density === bestDensity &&\n best !== undefined &&\n (candidate.rank < best.rank ||\n (candidate.rank === best.rank &&\n candidate.id.localeCompare(best.id) < 0)))\n ) {\n bestIndex = index;\n }\n }\n return { index: bestIndex, evaluated, timedOut: false };\n}\n\nfunction selectIdentityCandidates<TItem>(params: {\n ordered: ContextPackingCandidate<TItem>[];\n tokenBudget: number;\n redundancyPenalty: number;\n uncertaintyPenalty: number;\n deadline: number;\n readClock: () => number;\n}): {\n included: PackedContextCandidate<TItem>[];\n remaining: number;\n selectionComplete: boolean;\n evaluatedCandidates: number;\n} {\n const represented = new Set<string>();\n const included: PackedContextCandidate<TItem>[] = [];\n let remaining = params.tokenBudget;\n const valueOf = (candidate: ContextPackingCandidate<TItem>): number => {\n const key = candidate.lineage ?? candidate.cluster;\n const redundancy =\n key && represented.has(key) ? 1 - params.redundancyPenalty : 1;\n return Math.max(\n 0,\n (candidate.score -\n params.uncertaintyPenalty * (candidate.uncertainty ?? 0)) *\n redundancy,\n );\n };\n const admit = (candidate: ContextPackingCandidate<TItem>): void => {\n const tokens = candidate.token_costs.identity;\n included.push({\n ...candidate,\n projection: \"identity\",\n tokens,\n marginal_value: valueOf(candidate),\n });\n remaining -= tokens;\n const key = candidate.lineage ?? candidate.cluster;\n if (key) represented.add(key);\n };\n\n for (const candidate of params.ordered.filter((entry) => entry.required)) {\n if (candidate.token_costs.identity <= remaining) admit(candidate);\n }\n const optional = params.ordered.filter((entry) => !entry.required);\n let selectionComplete = true;\n let evaluatedCandidates = 0;\n while (optional.length > 0) {\n const selection = findBestAffordableCandidate(\n optional,\n remaining,\n valueOf,\n params.deadline,\n params.readClock,\n );\n evaluatedCandidates += selection.evaluated;\n if (selection.timedOut) selectionComplete = false;\n if (selection.index < 0 || selection.timedOut) break;\n admit(optional.splice(selection.index, 1)[0]!);\n }\n return {\n included,\n remaining,\n selectionComplete,\n evaluatedCandidates,\n };\n}\n\nfunction upgradeSelectedProjections<TItem>(\n included: PackedContextCandidate<TItem>[],\n initialRemaining: number,\n): number {\n let remaining = initialRemaining;\n for (const target of [\"summary\", \"full\"] as const) {\n const previous: ContextProjectionLevel =\n target === \"summary\" ? \"identity\" : \"summary\";\n const upgrades = [...included].sort((left, right) => {\n const leftCost = left.token_costs[target] - left.token_costs[previous];\n const rightCost = right.token_costs[target] - right.token_costs[previous];\n return (\n right.marginal_value / Math.max(rightCost, 1) -\n left.marginal_value / Math.max(leftCost, 1) || left.rank - right.rank || left.id.localeCompare(right.id)\n );\n });\n for (const entry of upgrades) {\n if (entry.projection !== previous) continue;\n const extra = entry.token_costs[target] - entry.tokens;\n if (extra > remaining) continue;\n entry.projection = target;\n entry.tokens += extra;\n remaining -= extra;\n }\n }\n return remaining;\n}\n\n/**\n * Packs ranked candidates under an explicit token budget. Required anchors are\n * admitted first, optional rows compete by marginal value per token, and then\n * selected rows are upgraded from identity to summary to full detail. This\n * guarantees projection degradation happens before omission.\n */\nexport function packContextCandidates<TItem>(\n candidates: readonly ContextPackingCandidate<TItem>[],\n options: PackContextCandidatesOptions,\n): ContextPackingReport<TItem> {\n const penalties = resolvePackingPenalties(options);\n const ordered = orderPackingCandidates(candidates);\n const readClock = options.readClock ?? performance.now.bind(performance);\n const deadline =\n options.latencyBudgetMs === undefined\n ? Number.POSITIVE_INFINITY\n : readClock() + options.latencyBudgetMs;\n const selection = selectIdentityCandidates({\n ordered,\n tokenBudget: options.tokenBudget,\n redundancyPenalty: penalties.redundancy,\n uncertaintyPenalty: penalties.uncertainty,\n deadline,\n readClock,\n });\n const { included } = selection;\n const remaining = upgradeSelectedProjections(included, selection.remaining);\n included.sort(\n (left, right) => left.rank - right.rank || left.id.localeCompare(right.id),\n );\n const selected = new Set(included.map((entry) => entry.id));\n return {\n included,\n omitted_ids: ordered\n .filter((entry) => !selected.has(entry.id))\n .map((entry) => entry.id),\n token_budget: options.tokenBudget,\n used_tokens: options.tokenBudget - remaining,\n remaining_tokens: remaining,\n complete:\n selection.selectionComplete &&\n included.length === candidates.length &&\n included.every((entry) => entry.projection === \"full\"),\n selection_complete: selection.selectionComplete,\n termination_reason: selection.selectionComplete\n ? \"exhausted\"\n : \"latency_budget\",\n evaluated_candidates: selection.evaluatedCandidates,\n latency_budget_ms: options.latencyBudgetMs ?? null,\n profile: penalties.profile,\n degradation_ladder: [\"full\", \"summary\", \"identity\"],\n };\n}\n"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH,kFAAkF;;;AAClF,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE;IAC9D,OAAO,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE;IAC9D,IAAI,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,kBAAkB,EAAE,GAAG,EAAE;CAClD,CAAC;AA6FX,MAAM,iBAAiB,GAA6B;IAClD,UAAU;IACV,SAAS;IACT,MAAM;CACP,CAAC;AAEF,SAAS,sBAAsB,CAC7B,SAAyC;IAEzC,IACE,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC;QACjC,SAAS,CAAC,IAAI,GAAG,CAAC,EAClB,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,6EAA6E,CAC9E,CAAC;IACJ,CAAC;IAC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AC,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;aAC1C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,YAAY,EAAE,OAAO,CAAC,WAAW;QACjC,WAAW,EAAE,OAAO,CAAC,WAAW,GAAG,SAAS;QAC5C,gBAAgB,EAAE,SAAS;QAC3B,QAAQ,EACN,SAAS,CAAC,iBAAiB;YAC3B,QAAQ,CAAC,MAAM,KAAK,UAAU,CAAC,MAAM;YACrC,QAAQ,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,MAAM,CAAC;QACxD,kBAAkB,EAAE,SAAS,CAAC,iBAAiB;QAC/C,kBAAkB,EAAE,SAAS,CAAC,iBAAiB;YAC7C,CAAC,CAAC,WAAW;YACb,CAAC,CAAC,gBAAgB;QACpB,oBAAoB,EAAE,SAAS,CAAC,mBAAmB;QACnD,iBAAiB,EAAE,OAAO,CAAC,eAAe,IAAI,IAAI;QAClD,OAAO,EAAE,SAAS,CAAC,OAAO;QAC1B,kBAAkB,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,CAAC;KACpD,CAAC;AACJ,CAAC","debugId":"f2b38b30-c8d0-51a2-9444-b2e0db9fa353"}
@@ -1,5 +1,5 @@
1
1
  /** Canonical signal keys understood by the built-in relevance model. */
2
- export declare const CONTEXT_RELEVANCE_SIGNAL_NAMES: readonly ["structural", "recency", "activity_density", "graph_proximity", "claim_focus", "priority_pressure", "risk_pressure", "deadline_pressure", "knowledge_density", "author_affinity", "semantic_similarity"];
2
+ export declare const CONTEXT_RELEVANCE_SIGNAL_NAMES: readonly ["structural", "recency", "activity_density", "graph_proximity", "claim_focus", "priority_pressure", "risk_pressure", "deadline_pressure", "knowledge_density", "author_affinity", "usage_affinity", "semantic_similarity"];
3
3
  /** A normalized signal consumed by the built-in context relevance scorer. */
4
4
  export type ContextRelevanceSignalName = (typeof CONTEXT_RELEVANCE_SIGNAL_NAMES)[number];
5
5
  /** Normalized candidate features; omitted signals are excluded from weighting. */
@@ -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]="380bb6a4-3d56-5a72-8bc9-236b044012b3")}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]="305d815a-a180-56bf-9a09-b7830e0c3970")}catch(e){}}();
10
10
  import { runActiveServiceOverride } from "../core/extensions/index.js";
11
11
  /** Canonical signal keys understood by the built-in relevance model. */
12
12
  export const CONTEXT_RELEVANCE_SIGNAL_NAMES = [
@@ -20,6 +20,7 @@ export const CONTEXT_RELEVANCE_SIGNAL_NAMES = [
20
20
  "deadline_pressure",
21
21
  "knowledge_density",
22
22
  "author_affinity",
23
+ "usage_affinity",
23
24
  "semantic_similarity",
24
25
  ];
25
26
  /** Governed extension service used to replace or wrap context ranking. */
@@ -35,6 +36,7 @@ const DEFAULT_CONTEXT_RELEVANCE_WEIGHTS = {
35
36
  deadline_pressure: 0.45,
36
37
  knowledge_density: 0.25,
37
38
  author_affinity: 0.2,
39
+ usage_affinity: 0.3,
38
40
  semantic_similarity: 0.5,
39
41
  };
40
42
  const JSON_TOKEN_ENCODER = new TextEncoder();
@@ -340,4 +342,4 @@ export async function runContextEvaluationCorpus(scenarios, reader, thresholds)
340
342
  return summarizeContextEvaluationReports(reports, thresholds);
341
343
  }
342
344
  //# sourceMappingURL=context-relevance.js.map
343
- //# debugId=380bb6a4-3d56-5a72-8bc9-236b044012b3
345
+ //# debugId=305d815a-a180-56bf-9a09-b7830e0c3970
@@ -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\";\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 \"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/** 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 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;AAEvE,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,qBAAqB;CACb,CAAC;AAiFX,0EAA0E;AAC1E,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAA4B,CAAC;AAKtE,MAAM,iCAAiC,GAGnC;IACF,UAAU,EAAE,GAAG;IACf,OAAO,EAAE,IAAI;IACb,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,GAAG;IAChB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,GAAG;IAClB,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,GAAG;IACpB,mBAAmB,EAAE,GAAG;CACzB,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,WAAW,EAAE,CAAC;AAE7C,SAAS,gBAAgB,CACvB,UAAuD;IAEvD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IACE,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ;YAChC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YAChC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,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AClC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACtB,MAAM;QACN,qBAAqB,CACnB,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;YAClE,OAAO,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":"380bb6a4-3d56-5a72-8bc9-236b044012b3"}
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\";\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/** 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;AAEvE,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;AAiFX,0EAA0E;AAC1E,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAA4B,CAAC;AAKtE,MAAM,iCAAiC,GAGnC;IACF,UAAU,EAAE,GAAG;IACf,OAAO,EAAE,IAAI;IACb,gBAAgB,EAAE,IAAI;IACtB,eAAe,EAAE,IAAI;IACrB,WAAW,EAAE,GAAG;IAChB,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,GAAG;IAClB,iBAAiB,EAAE,IAAI;IACvB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,GAAG;IACpB,cAAc,EAAE,GAAG;IACnB,mBAAmB,EAAE,GAAG;CACzB,CAAC;AACF,MAAM,kBAAkB,GAAG,IAAI,WAAW,EAAE,CAAC;AAE7C,SAAS,gBAAgB,CACvB,UAAuD;IAEvD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IACE,OAAO,SAAS,CAAC,EAAE,KAAK,QAAQ;YAChC,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;YAChC,GAAG,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,EACrB,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,2DAA2D,CAC5D,CAAC;QACJ,CAAC;QACD,GAAG,CA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