@unbrained/pm-cli 2026.7.1 → 2026.7.3

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 (625) hide show
  1. package/.claude-plugin/marketplace.json +3 -3
  2. package/CHANGELOG.md +25 -0
  3. package/CONTRIBUTING.md +2 -2
  4. package/README.md +1 -1
  5. package/dist/cli/commander-usage.d.ts +2 -0
  6. package/dist/cli/commander-usage.js +110 -86
  7. package/dist/cli/commander-usage.js.map +1 -1
  8. package/dist/cli/commands/activity.js +79 -57
  9. package/dist/cli/commands/activity.js.map +1 -1
  10. package/dist/cli/commands/aggregate.js +102 -79
  11. package/dist/cli/commands/aggregate.js.map +1 -1
  12. package/dist/cli/commands/calendar.js +278 -243
  13. package/dist/cli/commands/calendar.js.map +1 -1
  14. package/dist/cli/commands/close-many.js +176 -114
  15. package/dist/cli/commands/close-many.js.map +1 -1
  16. package/dist/cli/commands/close.js +157 -129
  17. package/dist/cli/commands/close.js.map +1 -1
  18. package/dist/cli/commands/comments-audit.js +50 -42
  19. package/dist/cli/commands/comments-audit.js.map +1 -1
  20. package/dist/cli/commands/config.d.ts +2 -0
  21. package/dist/cli/commands/config.js +443 -879
  22. package/dist/cli/commands/config.js.map +1 -1
  23. package/dist/cli/commands/context.js +365 -287
  24. package/dist/cli/commands/context.js.map +1 -1
  25. package/dist/cli/commands/contracts.js +352 -238
  26. package/dist/cli/commands/contracts.js.map +1 -1
  27. package/dist/cli/commands/create.js +32 -17
  28. package/dist/cli/commands/create.js.map +1 -1
  29. package/dist/cli/commands/dedupe-audit.js +46 -39
  30. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  31. package/dist/cli/commands/dedupe-merge.js +88 -69
  32. package/dist/cli/commands/dedupe-merge.js.map +1 -1
  33. package/dist/cli/commands/extension/doctor.js +56 -67
  34. package/dist/cli/commands/extension/doctor.js.map +1 -1
  35. package/dist/cli/commands/extension/shared.js +21 -15
  36. package/dist/cli/commands/extension/shared.js.map +1 -1
  37. package/dist/cli/commands/get.js +114 -81
  38. package/dist/cli/commands/get.js.map +1 -1
  39. package/dist/cli/commands/health.d.ts +17 -0
  40. package/dist/cli/commands/health.js +545 -417
  41. package/dist/cli/commands/health.js.map +1 -1
  42. package/dist/cli/commands/history-compact.js +209 -140
  43. package/dist/cli/commands/history-compact.js.map +1 -1
  44. package/dist/cli/commands/history-redact.js +162 -119
  45. package/dist/cli/commands/history-redact.js.map +1 -1
  46. package/dist/cli/commands/history-repair.js +120 -85
  47. package/dist/cli/commands/history-repair.js.map +1 -1
  48. package/dist/cli/commands/init-agent-guidance.js +32 -19
  49. package/dist/cli/commands/init-agent-guidance.js.map +1 -1
  50. package/dist/cli/commands/init.d.ts +8 -2
  51. package/dist/cli/commands/init.js +263 -162
  52. package/dist/cli/commands/init.js.map +1 -1
  53. package/dist/cli/commands/list.js +152 -102
  54. package/dist/cli/commands/list.js.map +1 -1
  55. package/dist/cli/commands/next.js +60 -40
  56. package/dist/cli/commands/next.js.map +1 -1
  57. package/dist/cli/commands/plan.js +373 -298
  58. package/dist/cli/commands/plan.js.map +1 -1
  59. package/dist/cli/commands/profile.js +23 -15
  60. package/dist/cli/commands/profile.js.map +1 -1
  61. package/dist/cli/commands/recurrence-parsers.js +43 -25
  62. package/dist/cli/commands/recurrence-parsers.js.map +1 -1
  63. package/dist/cli/commands/reindex.d.ts +21 -5
  64. package/dist/cli/commands/reindex.js +345 -205
  65. package/dist/cli/commands/reindex.js.map +1 -1
  66. package/dist/cli/commands/restore.d.ts +8 -7
  67. package/dist/cli/commands/restore.js +105 -69
  68. package/dist/cli/commands/restore.js.map +1 -1
  69. package/dist/cli/commands/schema.js +33 -30
  70. package/dist/cli/commands/schema.js.map +1 -1
  71. package/dist/cli/commands/search.d.ts +10 -2
  72. package/dist/cli/commands/search.js +503 -470
  73. package/dist/cli/commands/search.js.map +1 -1
  74. package/dist/cli/commands/telemetry.js +98 -87
  75. package/dist/cli/commands/telemetry.js.map +1 -1
  76. package/dist/cli/commands/test-all.js +237 -168
  77. package/dist/cli/commands/test-all.js.map +1 -1
  78. package/dist/cli/commands/test.d.ts +6 -5
  79. package/dist/cli/commands/test.js +424 -344
  80. package/dist/cli/commands/test.js.map +1 -1
  81. package/dist/cli/commands/update-many.js +57 -42
  82. package/dist/cli/commands/update-many.js.map +1 -1
  83. package/dist/cli/commands/update.d.ts +1 -1
  84. package/dist/cli/commands/update.js +738 -671
  85. package/dist/cli/commands/update.js.map +1 -1
  86. package/dist/cli/commands/validate.d.ts +20 -1
  87. package/dist/cli/commands/validate.js +478 -343
  88. package/dist/cli/commands/validate.js.map +1 -1
  89. package/dist/cli/error-guidance.js +406 -361
  90. package/dist/cli/error-guidance.js.map +1 -1
  91. package/dist/cli/extension-command-help.js +27 -19
  92. package/dist/cli/extension-command-help.js.map +1 -1
  93. package/dist/cli/help-json-payload.js +57 -49
  94. package/dist/cli/help-json-payload.js.map +1 -1
  95. package/dist/cli/main.d.ts +47 -0
  96. package/dist/cli/main.js +474 -371
  97. package/dist/cli/main.js.map +1 -1
  98. package/dist/cli/migration-gates.js +22 -45
  99. package/dist/cli/migration-gates.js.map +1 -1
  100. package/dist/cli/register-list-query.js +299 -310
  101. package/dist/cli/register-list-query.js.map +1 -1
  102. package/dist/cli/register-mutation.js +763 -779
  103. package/dist/cli/register-mutation.js.map +1 -1
  104. package/dist/cli/register-operations.js +386 -362
  105. package/dist/cli/register-operations.js.map +1 -1
  106. package/dist/cli/register-setup.js +120 -101
  107. package/dist/cli/register-setup.js.map +1 -1
  108. package/dist/cli/registration-helpers.d.ts +4 -0
  109. package/dist/cli/registration-helpers.js +45 -56
  110. package/dist/cli/registration-helpers.js.map +1 -1
  111. package/dist/cli-bundle/chunks/{activity-DBLQVIP6.js → activity-5YWLSPGE.js} +9 -9
  112. package/dist/cli-bundle/chunks/activity-BIML7K2D.js +16 -0
  113. package/dist/cli-bundle/chunks/{aggregate-SDF7DUOD.js → aggregate-2V2M3JZU.js} +107 -83
  114. package/dist/cli-bundle/chunks/{aggregate-SDF7DUOD.js.map → aggregate-2V2M3JZU.js.map} +2 -2
  115. package/dist/cli-bundle/chunks/{aggregate-JTEF4BP7.js → aggregate-EK7DXML7.js} +108 -84
  116. package/dist/cli-bundle/chunks/aggregate-EK7DXML7.js.map +1 -0
  117. package/dist/cli-bundle/chunks/{append-LOVPGVPT.js → append-EZESUVJT.js} +8 -8
  118. package/dist/cli-bundle/chunks/{append-QCFJSDFL.js → append-JFG4WQMG.js} +8 -8
  119. package/dist/cli-bundle/chunks/{chunk-TP5Q5ZD3.js → chunk-32IUNTG4.js} +158 -119
  120. package/dist/cli-bundle/chunks/chunk-32IUNTG4.js.map +1 -0
  121. package/dist/cli-bundle/chunks/{chunk-BHO33VBQ.js → chunk-3W2HJKJX.js} +3 -3
  122. package/dist/cli-bundle/chunks/{chunk-VARHOHYV.js → chunk-4EXFFP7T.js} +86 -52
  123. package/dist/cli-bundle/chunks/chunk-4EXFFP7T.js.map +7 -0
  124. package/dist/cli-bundle/chunks/{chunk-4DUVCVLZ.js → chunk-4PFVUUYV.js} +2 -2
  125. package/dist/cli-bundle/chunks/{chunk-JSU5P7VS.js → chunk-4WB6S4YX.js} +308 -184
  126. package/dist/cli-bundle/chunks/chunk-4WB6S4YX.js.map +1 -0
  127. package/dist/cli-bundle/chunks/{chunk-HXTQJXWT.js → chunk-572FKBRL.js} +61 -102
  128. package/dist/cli-bundle/chunks/chunk-572FKBRL.js.map +1 -0
  129. package/dist/cli-bundle/chunks/{chunk-IJYK2T43.js → chunk-5E7N4T2Z.js} +2 -2
  130. package/dist/cli-bundle/chunks/{chunk-NKZAN7BD.js → chunk-5IZUBZBR.js} +3 -3
  131. package/dist/cli-bundle/chunks/{chunk-NOLPZMSV.js → chunk-5JIWFWOZ.js} +2 -2
  132. package/dist/cli-bundle/chunks/{chunk-FFMQB7WR.js → chunk-67LARBDL.js} +493 -404
  133. package/dist/cli-bundle/chunks/chunk-67LARBDL.js.map +1 -0
  134. package/dist/cli-bundle/chunks/{chunk-6AQZPVHQ.js → chunk-6CDCWKSX.js} +4 -4
  135. package/dist/cli-bundle/chunks/{chunk-3K2M5OYU.js → chunk-6KRFL33E.js} +308 -184
  136. package/dist/cli-bundle/chunks/chunk-6KRFL33E.js.map +7 -0
  137. package/dist/cli-bundle/chunks/{chunk-LB6TP6MC.js → chunk-6NYJGMTY.js} +2 -2
  138. package/dist/cli-bundle/chunks/{chunk-SLMUGTK3.js → chunk-7CLLC75T.js} +4 -4
  139. package/dist/cli-bundle/chunks/{chunk-2466X6E4.js → chunk-7LYO6S5A.js} +8 -8
  140. package/dist/cli-bundle/chunks/{chunk-W4ULYO7Z.js → chunk-A3OQ7TFW.js} +8 -8
  141. package/dist/cli-bundle/chunks/{chunk-5CGRF3L5.js → chunk-AIKU3IIL.js} +153 -90
  142. package/dist/cli-bundle/chunks/chunk-AIKU3IIL.js.map +1 -0
  143. package/dist/cli-bundle/chunks/{chunk-WYDHYJPO.js → chunk-AJHYQCBJ.js} +39 -5
  144. package/dist/cli-bundle/chunks/chunk-AJHYQCBJ.js.map +7 -0
  145. package/dist/cli-bundle/chunks/{chunk-VZDBVEZR.js → chunk-B4O5S7I3.js} +79 -57
  146. package/dist/cli-bundle/chunks/{chunk-VZDBVEZR.js.map → chunk-B4O5S7I3.js.map} +2 -2
  147. package/dist/cli-bundle/chunks/{chunk-OTUHB4HS.js → chunk-BE2SR6QL.js} +92 -77
  148. package/dist/cli-bundle/chunks/chunk-BE2SR6QL.js.map +1 -0
  149. package/dist/cli-bundle/chunks/{chunk-JLM7BHI7.js → chunk-BI4R7HI2.js} +75 -53
  150. package/dist/cli-bundle/chunks/chunk-BI4R7HI2.js.map +7 -0
  151. package/dist/cli-bundle/chunks/{chunk-AXIDKKAT.js → chunk-CXR3CMBQ.js} +33 -6
  152. package/dist/cli-bundle/chunks/chunk-CXR3CMBQ.js.map +1 -0
  153. package/dist/cli-bundle/chunks/{chunk-ZETXE4SE.js → chunk-ECU6MMTQ.js} +713 -613
  154. package/dist/cli-bundle/chunks/chunk-ECU6MMTQ.js.map +1 -0
  155. package/dist/cli-bundle/chunks/{chunk-2D4HATP2.js → chunk-EJ2OCBHF.js} +54 -30
  156. package/dist/cli-bundle/chunks/chunk-EJ2OCBHF.js.map +1 -0
  157. package/dist/cli-bundle/chunks/{chunk-BDTISOSD.js → chunk-EQURFOMH.js} +41 -26
  158. package/dist/cli-bundle/chunks/chunk-EQURFOMH.js.map +7 -0
  159. package/dist/cli-bundle/chunks/{chunk-GJ326ZKX.js → chunk-ER4ME5U2.js} +3 -3
  160. package/dist/cli-bundle/chunks/{chunk-HZZEHPRG.js → chunk-ERG65A2L.js} +2 -2
  161. package/dist/cli-bundle/chunks/{chunk-IZBR4NRW.js → chunk-F6WNBITZ.js} +157 -113
  162. package/dist/cli-bundle/chunks/chunk-F6WNBITZ.js.map +7 -0
  163. package/dist/cli-bundle/chunks/{chunk-L5OEFZQG.js → chunk-FH2H3CBD.js} +3 -3
  164. package/dist/cli-bundle/chunks/{chunk-JPECA746.js → chunk-FUFFPIYA.js} +2 -2
  165. package/dist/cli-bundle/chunks/{chunk-CF7RL6FR.js → chunk-FZJM2TXF.js} +110 -73
  166. package/dist/cli-bundle/chunks/chunk-FZJM2TXF.js.map +1 -0
  167. package/dist/cli-bundle/chunks/{chunk-27BXPBAY.js → chunk-GUYNUXQT.js} +3 -3
  168. package/dist/cli-bundle/chunks/{chunk-MAUKX7JC.js → chunk-GVJE5T7Q.js} +2 -2
  169. package/dist/cli-bundle/chunks/{chunk-3J6JRJ3I.js → chunk-HB4FAT3O.js} +42 -60
  170. package/dist/cli-bundle/chunks/chunk-HB4FAT3O.js.map +7 -0
  171. package/dist/cli-bundle/chunks/{chunk-55SNVXRQ.js → chunk-HQAF23Q2.js} +626 -484
  172. package/dist/cli-bundle/chunks/chunk-HQAF23Q2.js.map +7 -0
  173. package/dist/cli-bundle/chunks/{chunk-ZRP4VG5U.js → chunk-JBZ2NTKX.js} +2 -2
  174. package/dist/cli-bundle/chunks/{chunk-RMMQ74TG.js → chunk-JPATY4SE.js} +54 -30
  175. package/dist/cli-bundle/chunks/chunk-JPATY4SE.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-IPYBJWTE.js → chunk-K5DT2YKM.js} +109 -72
  177. package/dist/cli-bundle/chunks/chunk-K5DT2YKM.js.map +7 -0
  178. package/dist/cli-bundle/chunks/{chunk-EJUDVUYZ.js → chunk-KEZOIPCR.js} +3 -3
  179. package/dist/cli-bundle/chunks/{chunk-RVUALSJF.js → chunk-KHVGM5CS.js} +466 -365
  180. package/dist/cli-bundle/chunks/chunk-KHVGM5CS.js.map +7 -0
  181. package/dist/cli-bundle/chunks/{chunk-YITK2PJ6.js → chunk-KS6ATO47.js} +288 -175
  182. package/dist/cli-bundle/chunks/chunk-KS6ATO47.js.map +7 -0
  183. package/dist/cli-bundle/chunks/{chunk-7R4QEMZZ.js → chunk-L4SLHV6G.js} +463 -362
  184. package/dist/cli-bundle/chunks/chunk-L4SLHV6G.js.map +1 -0
  185. package/dist/cli-bundle/chunks/{chunk-RLDHZHQS.js → chunk-LBE5QFMZ.js} +158 -114
  186. package/dist/cli-bundle/chunks/chunk-LBE5QFMZ.js.map +1 -0
  187. package/dist/cli-bundle/chunks/{chunk-22WKIL3H.js → chunk-LCWQP6NM.js} +76 -54
  188. package/dist/cli-bundle/chunks/chunk-LCWQP6NM.js.map +1 -0
  189. package/dist/cli-bundle/chunks/{chunk-KNPEF7QG.js → chunk-LOWVNZBZ.js} +91 -76
  190. package/dist/cli-bundle/chunks/chunk-LOWVNZBZ.js.map +7 -0
  191. package/dist/cli-bundle/chunks/{chunk-HYTGA6GI.js → chunk-MDHWWBNZ.js} +3 -3
  192. package/dist/cli-bundle/chunks/{chunk-N74UMG5H.js → chunk-MEZZZBYX.js} +2 -2
  193. package/dist/cli-bundle/chunks/{chunk-V3NOKJF2.js → chunk-MHRS5FUX.js} +288 -175
  194. package/dist/cli-bundle/chunks/chunk-MHRS5FUX.js.map +1 -0
  195. package/dist/cli-bundle/chunks/{chunk-3XZCOZ5J.js → chunk-NOIEVOK5.js} +391 -313
  196. package/dist/cli-bundle/chunks/chunk-NOIEVOK5.js.map +1 -0
  197. package/dist/cli-bundle/chunks/{chunk-SDR5J34Q.js → chunk-NZ7QIUP5.js} +4 -4
  198. package/dist/cli-bundle/chunks/{chunk-UYUYDGIB.js → chunk-OGLGI22K.js} +115 -67
  199. package/dist/cli-bundle/chunks/{chunk-UYUYDGIB.js.map → chunk-OGLGI22K.js.map} +1 -1
  200. package/dist/cli-bundle/chunks/{chunk-DDPTYJIM.js → chunk-P5L7Z2O6.js} +2 -2
  201. package/dist/cli-bundle/chunks/{chunk-BZCEN4JA.js → chunk-PULUSQAV.js} +492 -403
  202. package/dist/cli-bundle/chunks/chunk-PULUSQAV.js.map +7 -0
  203. package/dist/cli-bundle/chunks/{chunk-3VGN2UWE.js → chunk-QCDTQCMW.js} +22 -30
  204. package/dist/cli-bundle/chunks/chunk-QCDTQCMW.js.map +1 -0
  205. package/dist/cli-bundle/chunks/{chunk-4A3BJ675.js → chunk-QNNQAAZ5.js} +24 -18
  206. package/dist/cli-bundle/chunks/{chunk-4A3BJ675.js.map → chunk-QNNQAAZ5.js.map} +1 -1
  207. package/dist/cli-bundle/chunks/{chunk-MDPEOIGN.js → chunk-RAHINBVP.js} +60 -101
  208. package/dist/cli-bundle/chunks/chunk-RAHINBVP.js.map +7 -0
  209. package/dist/cli-bundle/chunks/{chunk-CWFNTKQJ.js → chunk-RJH5VQHW.js} +43 -61
  210. package/dist/cli-bundle/chunks/chunk-RJH5VQHW.js.map +1 -0
  211. package/dist/cli-bundle/chunks/{chunk-OGXLACHC.js → chunk-SU2E4AWU.js} +6 -6
  212. package/dist/cli-bundle/chunks/{chunk-HPPFYYOV.js → chunk-SU3TB4NS.js} +2 -2
  213. package/dist/cli-bundle/chunks/{chunk-JWXRETDF.js → chunk-SYE6WMV6.js} +626 -484
  214. package/dist/cli-bundle/chunks/chunk-SYE6WMV6.js.map +1 -0
  215. package/dist/cli-bundle/chunks/{chunk-NWMZWYYB.js → chunk-T3P7PMZP.js} +42 -27
  216. package/dist/cli-bundle/chunks/chunk-T3P7PMZP.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-G7I7DEZA.js → chunk-T4XBKJ3F.js} +4 -4
  218. package/dist/cli-bundle/chunks/{chunk-RH5ZBYFD.js → chunk-T6AXEBOP.js} +23 -17
  219. package/dist/cli-bundle/chunks/{chunk-RH5ZBYFD.js.map → chunk-T6AXEBOP.js.map} +2 -2
  220. package/dist/cli-bundle/chunks/{chunk-5QFDBI4F.js → chunk-TQ6AX5SQ.js} +58 -69
  221. package/dist/cli-bundle/chunks/{chunk-5QFDBI4F.js.map → chunk-TQ6AX5SQ.js.map} +2 -2
  222. package/dist/cli-bundle/chunks/{chunk-4XOIEKSD.js → chunk-U3S2B7TA.js} +86 -52
  223. package/dist/cli-bundle/chunks/chunk-U3S2B7TA.js.map +1 -0
  224. package/dist/cli-bundle/chunks/{chunk-VICZWYGZ.js → chunk-U5TR4N7J.js} +7 -7
  225. package/dist/cli-bundle/chunks/{chunk-EVMTBV6V.js → chunk-UMNQZS4H.js} +3 -3
  226. package/dist/cli-bundle/chunks/{chunk-A7FPBAQS.js → chunk-WJA3PXW7.js} +7 -7
  227. package/dist/cli-bundle/chunks/{chunk-RGEMWD6Q.js → chunk-WRYERRZX.js} +157 -118
  228. package/dist/cli-bundle/chunks/chunk-WRYERRZX.js.map +7 -0
  229. package/dist/cli-bundle/chunks/{chunk-NUHHPVVS.js → chunk-WYOIIFSE.js} +712 -612
  230. package/dist/cli-bundle/chunks/chunk-WYOIIFSE.js.map +7 -0
  231. package/dist/cli-bundle/chunks/{chunk-4DSGXSBL.js → chunk-XRYSCRZR.js} +116 -68
  232. package/dist/cli-bundle/chunks/{chunk-4DSGXSBL.js.map → chunk-XRYSCRZR.js.map} +3 -3
  233. package/dist/cli-bundle/chunks/{chunk-NU2UEROZ.js → chunk-YF746GTH.js} +59 -70
  234. package/dist/cli-bundle/chunks/{chunk-NU2UEROZ.js.map → chunk-YF746GTH.js.map} +1 -1
  235. package/dist/cli-bundle/chunks/{chunk-JMP4E6D7.js → chunk-YPWUSH72.js} +390 -312
  236. package/dist/cli-bundle/chunks/{chunk-JMP4E6D7.js.map → chunk-YPWUSH72.js.map} +2 -2
  237. package/dist/cli-bundle/chunks/{chunk-QCWF6IYD.js → chunk-YSDFIY7N.js} +3 -3
  238. package/dist/cli-bundle/chunks/{chunk-UZIWVBE6.js → chunk-YSGTMDWC.js} +2 -2
  239. package/dist/cli-bundle/chunks/{chunk-NFDPYAIP.js → chunk-YVKZ3ANP.js} +21 -29
  240. package/dist/cli-bundle/chunks/chunk-YVKZ3ANP.js.map +7 -0
  241. package/dist/cli-bundle/chunks/{chunk-OKQ22KTH.js → chunk-Z4DGFQDH.js} +80 -58
  242. package/dist/cli-bundle/chunks/{chunk-OKQ22KTH.js.map → chunk-Z4DGFQDH.js.map} +1 -1
  243. package/dist/cli-bundle/chunks/{chunk-64HNBBFQ.js → chunk-Z5F6XZXE.js} +6 -6
  244. package/dist/cli-bundle/chunks/{chunk-AVEE5EHK.js → chunk-Z7RPDF2Y.js} +3 -3
  245. package/dist/cli-bundle/chunks/{chunk-3S2KT7NG.js → chunk-ZFTKYWIF.js} +152 -89
  246. package/dist/cli-bundle/chunks/chunk-ZFTKYWIF.js.map +7 -0
  247. package/dist/cli-bundle/chunks/{claim-T3GCKV7C.js → claim-2BGBGSVI.js} +8 -8
  248. package/dist/cli-bundle/chunks/{claim-EMQLYPRW.js → claim-5GU7OE67.js} +8 -8
  249. package/dist/cli-bundle/chunks/close-6YODBUIV.js +14 -0
  250. package/dist/cli-bundle/chunks/{close-TQYAAFJP.js → close-AFVKPR57.js} +7 -7
  251. package/dist/cli-bundle/chunks/{close-many-BG5QQIDQ.js → close-many-7KLOSYLP.js} +186 -122
  252. package/dist/cli-bundle/chunks/close-many-7KLOSYLP.js.map +7 -0
  253. package/dist/cli-bundle/chunks/{close-many-LDRVEQY2.js → close-many-JKUJMHLG.js} +187 -123
  254. package/dist/cli-bundle/chunks/close-many-JKUJMHLG.js.map +1 -0
  255. package/dist/cli-bundle/chunks/{comments-YUXJRZPQ.js → comments-DNWHEBOS.js} +9 -9
  256. package/dist/cli-bundle/chunks/{comments-QCKR2YY2.js → comments-RW23R3VE.js} +9 -9
  257. package/dist/cli-bundle/chunks/config-AUM5WBYA.js +1072 -0
  258. package/dist/cli-bundle/chunks/config-AUM5WBYA.js.map +7 -0
  259. package/dist/cli-bundle/chunks/config-OZWSA2NP.js +1062 -0
  260. package/dist/cli-bundle/chunks/config-OZWSA2NP.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{context-B6275WPX.js → context-OYXRGY7S.js} +12 -12
  262. package/dist/cli-bundle/chunks/{context-OCZ3FJ4Z.js → context-PKCEHQY3.js} +12 -12
  263. package/dist/cli-bundle/chunks/{contracts-HN7ABKLP.js → contracts-L6ODXNUM.js} +320 -199
  264. package/dist/cli-bundle/chunks/contracts-L6ODXNUM.js.map +7 -0
  265. package/dist/cli-bundle/chunks/{contracts-W4FZVVD6.js → contracts-X74F2GSM.js} +321 -200
  266. package/dist/cli-bundle/chunks/contracts-X74F2GSM.js.map +1 -0
  267. package/dist/cli-bundle/chunks/{copy-DEM4DATS.js → copy-6XOR3HKN.js} +5 -5
  268. package/dist/cli-bundle/chunks/{copy-BTJOSKKT.js → copy-I4NCLBR4.js} +5 -5
  269. package/dist/cli-bundle/chunks/{create-RLRJMRTM.js → create-PM45M6PE.js} +12 -12
  270. package/dist/cli-bundle/chunks/create-Z7YCH3BE.js +28 -0
  271. package/dist/cli-bundle/chunks/{delete-BHK7VB2Z.js → delete-7YXHYG67.js} +5 -5
  272. package/dist/cli-bundle/chunks/{delete-LSVHAB4Y.js → delete-LPISP43T.js} +5 -5
  273. package/dist/cli-bundle/chunks/{deps-XHYXWEPT.js → deps-N2T26FME.js} +5 -5
  274. package/dist/cli-bundle/chunks/{deps-4UDFJRUA.js → deps-WATKQDE3.js} +5 -5
  275. package/dist/cli-bundle/chunks/{docs-GYZNVS26.js → docs-6LQ3GLM7.js} +7 -7
  276. package/dist/cli-bundle/chunks/{docs-26S44RXU.js → docs-Z3X6JZLT.js} +7 -7
  277. package/dist/cli-bundle/chunks/{eval-UYF3ZPVO.js → eval-6DCLG52D.js} +10 -10
  278. package/dist/cli-bundle/chunks/{eval-PGRVIJQU.js → eval-Y3ZCUTHK.js} +10 -10
  279. package/dist/cli-bundle/chunks/{extension-CPSLJQVE.js → extension-BNINIMT7.js} +11 -11
  280. package/dist/cli-bundle/chunks/{extension-CXJ6RELI.js → extension-QWE4YYK5.js} +11 -11
  281. package/dist/cli-bundle/chunks/{files-NQHEXUZD.js → files-6SGKHS6O.js} +7 -7
  282. package/dist/cli-bundle/chunks/{files-MBNICQFM.js → files-FUYPSOFJ.js} +7 -7
  283. package/dist/cli-bundle/chunks/{focus-DWYIG7GU.js → focus-2Q3K76G2.js} +6 -6
  284. package/dist/cli-bundle/chunks/{focus-XZW5423D.js → focus-ATLBWXXD.js} +6 -6
  285. package/dist/cli-bundle/chunks/{gc-LPVMKJQJ.js → gc-RUYEMNRF.js} +3 -3
  286. package/dist/cli-bundle/chunks/{gc-7GQYOS2G.js → gc-TDWSDR66.js} +3 -3
  287. package/dist/cli-bundle/chunks/{get-A7MAOHCU.js → get-2WGLX74N.js} +120 -80
  288. package/dist/cli-bundle/chunks/get-2WGLX74N.js.map +7 -0
  289. package/dist/cli-bundle/chunks/{get-DSDEKJ3L.js → get-LY6M2JIM.js} +121 -81
  290. package/dist/cli-bundle/chunks/get-LY6M2JIM.js.map +1 -0
  291. package/dist/cli-bundle/chunks/{health-3IPFLKXB.js → health-4RKHYS3T.js} +535 -371
  292. package/dist/cli-bundle/chunks/health-4RKHYS3T.js.map +1 -0
  293. package/dist/cli-bundle/chunks/{health-GZXGBZ36.js → health-TMFVNYRA.js} +534 -370
  294. package/dist/cli-bundle/chunks/health-TMFVNYRA.js.map +7 -0
  295. package/dist/cli-bundle/chunks/history-CGNQJXFE.js +18 -0
  296. package/dist/cli-bundle/chunks/{history-NERDJNUB.js → history-SGRRS72R.js} +8 -8
  297. package/dist/cli-bundle/chunks/{history-compact-2WRZ2WK4.js → history-compact-LOED43R3.js} +213 -134
  298. package/dist/cli-bundle/chunks/history-compact-LOED43R3.js.map +7 -0
  299. package/dist/cli-bundle/chunks/{history-compact-HR7BB4LR.js → history-compact-V5DNAQHH.js} +214 -135
  300. package/dist/cli-bundle/chunks/history-compact-V5DNAQHH.js.map +1 -0
  301. package/dist/cli-bundle/chunks/{history-redact-O3NBCNWC.js → history-redact-IRL7WJ3E.js} +9 -9
  302. package/dist/cli-bundle/chunks/history-redact-N3JK7VBW.js +19 -0
  303. package/dist/cli-bundle/chunks/{history-repair-XA3LC4GA.js → history-repair-4WVBVHFR.js} +124 -84
  304. package/dist/cli-bundle/chunks/history-repair-4WVBVHFR.js.map +1 -0
  305. package/dist/cli-bundle/chunks/{history-repair-LCMOS45X.js → history-repair-PGYQJMGD.js} +123 -83
  306. package/dist/cli-bundle/chunks/history-repair-PGYQJMGD.js.map +7 -0
  307. package/dist/cli-bundle/chunks/{init-64XDLQJB.js → init-4GESW7RM.js} +12 -12
  308. package/dist/cli-bundle/chunks/init-XIDPABA4.js +22 -0
  309. package/dist/cli-bundle/chunks/{learnings-LPKCSJX7.js → learnings-4BHWFFUV.js} +9 -9
  310. package/dist/cli-bundle/chunks/{learnings-JR6MA5TI.js → learnings-4FJY7WIW.js} +9 -9
  311. package/dist/cli-bundle/chunks/{list-G5Y65VF6.js → list-472TIOVK.js} +8 -8
  312. package/dist/cli-bundle/chunks/{list-DNBJVO3E.js → list-D7BF5CL2.js} +8 -8
  313. package/dist/cli-bundle/chunks/{next-FYTQF6HG.js → next-D5STGWI2.js} +71 -46
  314. package/dist/cli-bundle/chunks/next-D5STGWI2.js.map +1 -0
  315. package/dist/cli-bundle/chunks/{next-BCERKDUR.js → next-SFQZVX2B.js} +70 -45
  316. package/dist/cli-bundle/chunks/next-SFQZVX2B.js.map +7 -0
  317. package/dist/cli-bundle/chunks/{notes-2BMU3VVQ.js → notes-6KNOSLIT.js} +9 -9
  318. package/dist/cli-bundle/chunks/{notes-6KTGO2OJ.js → notes-W4UEICGF.js} +9 -9
  319. package/dist/cli-bundle/chunks/{plan-RKZHQVXR.js → plan-JO6V7BXO.js} +373 -279
  320. package/dist/cli-bundle/chunks/plan-JO6V7BXO.js.map +1 -0
  321. package/dist/cli-bundle/chunks/{plan-4WXEQCTN.js → plan-MJQW5XK3.js} +372 -278
  322. package/dist/cli-bundle/chunks/plan-MJQW5XK3.js.map +7 -0
  323. package/dist/cli-bundle/chunks/{profile-4OMM32CD.js → profile-3TOTMUR4.js} +27 -19
  324. package/dist/cli-bundle/chunks/profile-3TOTMUR4.js.map +7 -0
  325. package/dist/cli-bundle/chunks/{profile-QLER5ENE.js → profile-WIQY2KCV.js} +28 -20
  326. package/dist/cli-bundle/chunks/profile-WIQY2KCV.js.map +1 -0
  327. package/dist/cli-bundle/chunks/register-list-query-ELBHCCFI.js +416 -0
  328. package/dist/cli-bundle/chunks/register-list-query-ELBHCCFI.js.map +7 -0
  329. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js +406 -0
  330. package/dist/cli-bundle/chunks/register-list-query-GAPQ6DM3.js.map +1 -0
  331. package/dist/cli-bundle/chunks/{register-mutation-KK7PHYYU.js → register-mutation-ROFE2YPC.js} +729 -702
  332. package/dist/cli-bundle/chunks/register-mutation-ROFE2YPC.js.map +7 -0
  333. package/dist/cli-bundle/chunks/{register-mutation-ENNDUAZG.js → register-mutation-SJWMVIJ2.js} +730 -703
  334. package/dist/cli-bundle/chunks/register-mutation-SJWMVIJ2.js.map +1 -0
  335. package/dist/cli-bundle/chunks/{register-operations-HZ6XERQG.js → register-operations-IADFVH53.js} +389 -365
  336. package/dist/cli-bundle/chunks/register-operations-IADFVH53.js.map +7 -0
  337. package/dist/cli-bundle/chunks/register-operations-MEKU3AKC.js +510 -0
  338. package/dist/cli-bundle/chunks/register-operations-MEKU3AKC.js.map +1 -0
  339. package/dist/cli-bundle/chunks/{register-setup-ZKJ53RS7.js → register-setup-3QJY43CY.js} +128 -103
  340. package/dist/cli-bundle/chunks/register-setup-3QJY43CY.js.map +7 -0
  341. package/dist/cli-bundle/chunks/{register-setup-P67EMBDJ.js → register-setup-AJWUSSQX.js} +129 -104
  342. package/dist/cli-bundle/chunks/register-setup-AJWUSSQX.js.map +1 -0
  343. package/dist/cli-bundle/chunks/{restore-4MHZFJ2E.js → restore-44IHMMZZ.js} +9 -9
  344. package/dist/cli-bundle/chunks/restore-EXHU34EU.js +17 -0
  345. package/dist/cli-bundle/chunks/{scheduling-shortcuts-LB6DOLRL.js → scheduling-shortcuts-OLHNLAZY.js} +12 -12
  346. package/dist/cli-bundle/chunks/{scheduling-shortcuts-UTOYKLXQ.js → scheduling-shortcuts-TSBK4AY5.js} +12 -12
  347. package/dist/cli-bundle/chunks/{schema-73HR2OJW.js → schema-IB2NZZWD.js} +7 -7
  348. package/dist/cli-bundle/chunks/{schema-U6LJKSIR.js → schema-VBCELP5G.js} +7 -7
  349. package/dist/cli-bundle/chunks/{search-AXPXKZER.js → search-7UBETML4.js} +10 -10
  350. package/dist/cli-bundle/chunks/{search-KILGT37L.js → search-R227JOL6.js} +10 -10
  351. package/dist/cli-bundle/chunks/{stats-W5KNVJWQ.js → stats-FAG7COEH.js} +6 -6
  352. package/dist/cli-bundle/chunks/{stats-PSYVVTNZ.js → stats-MCK7PLYS.js} +6 -6
  353. package/dist/cli-bundle/chunks/{telemetry-GAHHQTOS.js → telemetry-DRPDZMAO.js} +84 -70
  354. package/dist/cli-bundle/chunks/telemetry-DRPDZMAO.js.map +7 -0
  355. package/dist/cli-bundle/chunks/{telemetry-BZUF6H7G.js → telemetry-GVVUQSJQ.js} +85 -71
  356. package/dist/cli-bundle/chunks/telemetry-GVVUQSJQ.js.map +1 -0
  357. package/dist/cli-bundle/chunks/{test-PWDIZ255.js → test-QY44WAMR.js} +15 -15
  358. package/dist/cli-bundle/chunks/{test-ACD52Z3S.js → test-SY76DZTO.js} +15 -15
  359. package/dist/cli-bundle/chunks/test-all-QD6QAEG7.js +430 -0
  360. package/dist/cli-bundle/chunks/test-all-QD6QAEG7.js.map +7 -0
  361. package/dist/cli-bundle/chunks/test-all-USPJHXFR.js +427 -0
  362. package/dist/cli-bundle/chunks/test-all-USPJHXFR.js.map +1 -0
  363. package/dist/cli-bundle/chunks/{test-runs-UXIXPDKU.js → test-runs-MG5VIGSK.js} +185 -147
  364. package/dist/cli-bundle/chunks/test-runs-MG5VIGSK.js.map +1 -0
  365. package/dist/cli-bundle/chunks/{test-runs-PLRAZEFW.js → test-runs-QIR5MJPL.js} +184 -146
  366. package/dist/cli-bundle/chunks/test-runs-QIR5MJPL.js.map +7 -0
  367. package/dist/cli-bundle/chunks/update-A7EICML6.js +24 -0
  368. package/dist/cli-bundle/chunks/{update-KFX2SIAC.js → update-IKJZWLQC.js} +15 -15
  369. package/dist/cli-bundle/chunks/{update-many-RNSBX2TA.js → update-many-BEMTDA2X.js} +84 -69
  370. package/dist/cli-bundle/chunks/{update-many-RNSBX2TA.js.map → update-many-BEMTDA2X.js.map} +1 -1
  371. package/dist/cli-bundle/chunks/{update-many-Z5GJS5LC.js → update-many-RATAARHU.js} +83 -68
  372. package/dist/cli-bundle/chunks/{update-many-Z5GJS5LC.js.map → update-many-RATAARHU.js.map} +2 -2
  373. package/dist/cli-bundle/chunks/{upgrade-BRL6KCOJ.js → upgrade-NWMR3VQL.js} +11 -11
  374. package/dist/cli-bundle/chunks/{upgrade-HAK6JG2O.js → upgrade-VU46BLJZ.js} +11 -11
  375. package/dist/cli-bundle/chunks/{validate-X5W76YJL.js → validate-GAJ6FUSI.js} +451 -321
  376. package/dist/cli-bundle/chunks/validate-GAJ6FUSI.js.map +1 -0
  377. package/dist/cli-bundle/chunks/{validate-MTUVL5VC.js → validate-NRY6MFXN.js} +450 -320
  378. package/dist/cli-bundle/chunks/validate-NRY6MFXN.js.map +7 -0
  379. package/dist/cli-bundle/main.js +1107 -916
  380. package/dist/cli-bundle/main.js.map +3 -3
  381. package/dist/core/config/nested-settings.js +89 -67
  382. package/dist/core/config/nested-settings.js.map +1 -1
  383. package/dist/core/governance/metadata-coverage.js +20 -28
  384. package/dist/core/governance/metadata-coverage.js.map +1 -1
  385. package/dist/core/history/drift-scan.js +93 -81
  386. package/dist/core/history/drift-scan.js.map +1 -1
  387. package/dist/core/item/item-type-definition.js +14 -14
  388. package/dist/core/item/item-type-definition.js.map +1 -1
  389. package/dist/core/item/type-registry.js +114 -99
  390. package/dist/core/item/type-registry.js.map +1 -1
  391. package/dist/core/output/mutation-projection.js +42 -26
  392. package/dist/core/output/mutation-projection.js.map +1 -1
  393. package/dist/core/schema/runtime-schema.js +97 -80
  394. package/dist/core/schema/runtime-schema.js.map +1 -1
  395. package/dist/core/schema/status-defs-file.js +26 -3
  396. package/dist/core/schema/status-defs-file.js.map +1 -1
  397. package/dist/core/search/corpus.js +25 -19
  398. package/dist/core/search/corpus.js.map +1 -1
  399. package/dist/core/search/semantic-defaults.js +64 -37
  400. package/dist/core/search/semantic-defaults.js.map +1 -1
  401. package/dist/core/search/vector-stores.js +32 -17
  402. package/dist/core/search/vector-stores.js.map +1 -1
  403. package/dist/core/sentry/helpers.js +31 -28
  404. package/dist/core/sentry/helpers.js.map +1 -1
  405. package/dist/core/sentry/instrument.js +54 -43
  406. package/dist/core/sentry/instrument.js.map +1 -1
  407. package/dist/core/shared/memo.d.ts +12 -0
  408. package/dist/core/shared/memo.js +25 -0
  409. package/dist/core/shared/memo.js.map +1 -0
  410. package/dist/core/shared/serialization.js +24 -14
  411. package/dist/core/shared/serialization.js.map +1 -1
  412. package/dist/core/shared/time.js +26 -4
  413. package/dist/core/shared/time.js.map +1 -1
  414. package/dist/core/store/front-matter-cache.d.ts +5 -0
  415. package/dist/core/store/front-matter-cache.js +316 -171
  416. package/dist/core/store/front-matter-cache.js.map +1 -1
  417. package/dist/core/store/item-store.js +33 -26
  418. package/dist/core/store/item-store.js.map +1 -1
  419. package/dist/core/store/settings.js +247 -203
  420. package/dist/core/store/settings.js.map +1 -1
  421. package/dist/core/test/background-runs.js +189 -160
  422. package/dist/core/test/background-runs.js.map +1 -1
  423. package/dist/sdk/cli-contracts/flag-contracts.js +71 -99
  424. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  425. package/dist/sdk/compose.js +51 -42
  426. package/dist/sdk/compose.js.map +1 -1
  427. package/docs/AGENT_GUIDE.md +2 -2
  428. package/docs/ARCHITECTURE.md +2 -2
  429. package/docs/COMMANDS.md +8 -4
  430. package/docs/CONFIGURATION.md +1 -1
  431. package/docs/EXTENSIONS.md +12 -12
  432. package/docs/ONBOARDING.md +4 -2
  433. package/docs/README.md +2 -0
  434. package/docs/examples/starter-extension/README.md +11 -10
  435. package/marketplace.json +3 -3
  436. package/package.json +2 -2
  437. package/packages/pm-beads/extensions/beads/runtime.ts +240 -167
  438. package/packages/pm-guide-shell/extensions/guide-shell/runtime.ts +65 -58
  439. package/packages/pm-todos/extensions/todos/runtime.ts +65 -42
  440. package/plugins/pm-claude/.claude-plugin/plugin.json +2 -2
  441. package/plugins/pm-claude/README.md +6 -3
  442. package/plugins/pm-claude/commands/pm-init.md +1 -1
  443. package/dist/cli-bundle/chunks/activity-AW6XVFH6.js +0 -16
  444. package/dist/cli-bundle/chunks/aggregate-JTEF4BP7.js.map +0 -1
  445. package/dist/cli-bundle/chunks/chunk-22WKIL3H.js.map +0 -1
  446. package/dist/cli-bundle/chunks/chunk-2D4HATP2.js.map +0 -1
  447. package/dist/cli-bundle/chunks/chunk-3J6JRJ3I.js.map +0 -7
  448. package/dist/cli-bundle/chunks/chunk-3K2M5OYU.js.map +0 -7
  449. package/dist/cli-bundle/chunks/chunk-3S2KT7NG.js.map +0 -7
  450. package/dist/cli-bundle/chunks/chunk-3VGN2UWE.js.map +0 -1
  451. package/dist/cli-bundle/chunks/chunk-3XZCOZ5J.js.map +0 -1
  452. package/dist/cli-bundle/chunks/chunk-4XOIEKSD.js.map +0 -1
  453. package/dist/cli-bundle/chunks/chunk-55SNVXRQ.js.map +0 -7
  454. package/dist/cli-bundle/chunks/chunk-5CGRF3L5.js.map +0 -1
  455. package/dist/cli-bundle/chunks/chunk-7R4QEMZZ.js.map +0 -1
  456. package/dist/cli-bundle/chunks/chunk-AXIDKKAT.js.map +0 -1
  457. package/dist/cli-bundle/chunks/chunk-BDTISOSD.js.map +0 -7
  458. package/dist/cli-bundle/chunks/chunk-BZCEN4JA.js.map +0 -7
  459. package/dist/cli-bundle/chunks/chunk-CF7RL6FR.js.map +0 -1
  460. package/dist/cli-bundle/chunks/chunk-CWFNTKQJ.js.map +0 -1
  461. package/dist/cli-bundle/chunks/chunk-FFMQB7WR.js.map +0 -1
  462. package/dist/cli-bundle/chunks/chunk-HXTQJXWT.js.map +0 -1
  463. package/dist/cli-bundle/chunks/chunk-IPYBJWTE.js.map +0 -7
  464. package/dist/cli-bundle/chunks/chunk-IZBR4NRW.js.map +0 -7
  465. package/dist/cli-bundle/chunks/chunk-JLM7BHI7.js.map +0 -7
  466. package/dist/cli-bundle/chunks/chunk-JSU5P7VS.js.map +0 -1
  467. package/dist/cli-bundle/chunks/chunk-JWXRETDF.js.map +0 -1
  468. package/dist/cli-bundle/chunks/chunk-KNPEF7QG.js.map +0 -7
  469. package/dist/cli-bundle/chunks/chunk-MDPEOIGN.js.map +0 -7
  470. package/dist/cli-bundle/chunks/chunk-NFDPYAIP.js.map +0 -7
  471. package/dist/cli-bundle/chunks/chunk-NUHHPVVS.js.map +0 -7
  472. package/dist/cli-bundle/chunks/chunk-NWMZWYYB.js.map +0 -1
  473. package/dist/cli-bundle/chunks/chunk-OTUHB4HS.js.map +0 -1
  474. package/dist/cli-bundle/chunks/chunk-RGEMWD6Q.js.map +0 -7
  475. package/dist/cli-bundle/chunks/chunk-RLDHZHQS.js.map +0 -1
  476. package/dist/cli-bundle/chunks/chunk-RMMQ74TG.js.map +0 -7
  477. package/dist/cli-bundle/chunks/chunk-RVUALSJF.js.map +0 -7
  478. package/dist/cli-bundle/chunks/chunk-TP5Q5ZD3.js.map +0 -1
  479. package/dist/cli-bundle/chunks/chunk-V3NOKJF2.js.map +0 -1
  480. package/dist/cli-bundle/chunks/chunk-VARHOHYV.js.map +0 -7
  481. package/dist/cli-bundle/chunks/chunk-WYDHYJPO.js.map +0 -7
  482. package/dist/cli-bundle/chunks/chunk-YITK2PJ6.js.map +0 -7
  483. package/dist/cli-bundle/chunks/chunk-ZETXE4SE.js.map +0 -1
  484. package/dist/cli-bundle/chunks/close-E6ZZGCJY.js +0 -14
  485. package/dist/cli-bundle/chunks/close-many-BG5QQIDQ.js.map +0 -7
  486. package/dist/cli-bundle/chunks/close-many-LDRVEQY2.js.map +0 -1
  487. package/dist/cli-bundle/chunks/config-DMSU64QO.js +0 -1541
  488. package/dist/cli-bundle/chunks/config-DMSU64QO.js.map +0 -7
  489. package/dist/cli-bundle/chunks/config-QH2DICD6.js +0 -1531
  490. package/dist/cli-bundle/chunks/config-QH2DICD6.js.map +0 -1
  491. package/dist/cli-bundle/chunks/contracts-HN7ABKLP.js.map +0 -7
  492. package/dist/cli-bundle/chunks/contracts-W4FZVVD6.js.map +0 -1
  493. package/dist/cli-bundle/chunks/create-OH3BDGBB.js +0 -28
  494. package/dist/cli-bundle/chunks/get-A7MAOHCU.js.map +0 -7
  495. package/dist/cli-bundle/chunks/get-DSDEKJ3L.js.map +0 -1
  496. package/dist/cli-bundle/chunks/health-3IPFLKXB.js.map +0 -1
  497. package/dist/cli-bundle/chunks/health-GZXGBZ36.js.map +0 -7
  498. package/dist/cli-bundle/chunks/history-WSZHY3PN.js +0 -18
  499. package/dist/cli-bundle/chunks/history-compact-2WRZ2WK4.js.map +0 -7
  500. package/dist/cli-bundle/chunks/history-compact-HR7BB4LR.js.map +0 -1
  501. package/dist/cli-bundle/chunks/history-redact-MP6CH7U5.js +0 -19
  502. package/dist/cli-bundle/chunks/history-repair-LCMOS45X.js.map +0 -7
  503. package/dist/cli-bundle/chunks/history-repair-XA3LC4GA.js.map +0 -1
  504. package/dist/cli-bundle/chunks/init-PAX32BJA.js +0 -22
  505. package/dist/cli-bundle/chunks/next-BCERKDUR.js.map +0 -7
  506. package/dist/cli-bundle/chunks/next-FYTQF6HG.js.map +0 -1
  507. package/dist/cli-bundle/chunks/plan-4WXEQCTN.js.map +0 -7
  508. package/dist/cli-bundle/chunks/plan-RKZHQVXR.js.map +0 -1
  509. package/dist/cli-bundle/chunks/profile-4OMM32CD.js.map +0 -7
  510. package/dist/cli-bundle/chunks/profile-QLER5ENE.js.map +0 -1
  511. package/dist/cli-bundle/chunks/register-list-query-7LV46VAU.js +0 -400
  512. package/dist/cli-bundle/chunks/register-list-query-7LV46VAU.js.map +0 -1
  513. package/dist/cli-bundle/chunks/register-list-query-SNG5PGA4.js +0 -410
  514. package/dist/cli-bundle/chunks/register-list-query-SNG5PGA4.js.map +0 -7
  515. package/dist/cli-bundle/chunks/register-mutation-ENNDUAZG.js.map +0 -1
  516. package/dist/cli-bundle/chunks/register-mutation-KK7PHYYU.js.map +0 -7
  517. package/dist/cli-bundle/chunks/register-operations-C6OWLDSH.js +0 -486
  518. package/dist/cli-bundle/chunks/register-operations-C6OWLDSH.js.map +0 -1
  519. package/dist/cli-bundle/chunks/register-operations-HZ6XERQG.js.map +0 -7
  520. package/dist/cli-bundle/chunks/register-setup-P67EMBDJ.js.map +0 -1
  521. package/dist/cli-bundle/chunks/register-setup-ZKJ53RS7.js.map +0 -7
  522. package/dist/cli-bundle/chunks/restore-YALDGTQR.js +0 -17
  523. package/dist/cli-bundle/chunks/telemetry-BZUF6H7G.js.map +0 -1
  524. package/dist/cli-bundle/chunks/telemetry-GAHHQTOS.js.map +0 -7
  525. package/dist/cli-bundle/chunks/test-all-L2MDDUCA.js +0 -358
  526. package/dist/cli-bundle/chunks/test-all-L2MDDUCA.js.map +0 -1
  527. package/dist/cli-bundle/chunks/test-all-RBZ6DLU2.js +0 -361
  528. package/dist/cli-bundle/chunks/test-all-RBZ6DLU2.js.map +0 -7
  529. package/dist/cli-bundle/chunks/test-runs-PLRAZEFW.js.map +0 -7
  530. package/dist/cli-bundle/chunks/test-runs-UXIXPDKU.js.map +0 -1
  531. package/dist/cli-bundle/chunks/update-AMRSOIWP.js +0 -24
  532. package/dist/cli-bundle/chunks/validate-MTUVL5VC.js.map +0 -7
  533. package/dist/cli-bundle/chunks/validate-X5W76YJL.js.map +0 -1
  534. /package/dist/cli-bundle/chunks/{activity-DBLQVIP6.js.map → activity-5YWLSPGE.js.map} +0 -0
  535. /package/dist/cli-bundle/chunks/{activity-AW6XVFH6.js.map → activity-BIML7K2D.js.map} +0 -0
  536. /package/dist/cli-bundle/chunks/{append-LOVPGVPT.js.map → append-EZESUVJT.js.map} +0 -0
  537. /package/dist/cli-bundle/chunks/{append-QCFJSDFL.js.map → append-JFG4WQMG.js.map} +0 -0
  538. /package/dist/cli-bundle/chunks/{chunk-BHO33VBQ.js.map → chunk-3W2HJKJX.js.map} +0 -0
  539. /package/dist/cli-bundle/chunks/{chunk-4DUVCVLZ.js.map → chunk-4PFVUUYV.js.map} +0 -0
  540. /package/dist/cli-bundle/chunks/{chunk-IJYK2T43.js.map → chunk-5E7N4T2Z.js.map} +0 -0
  541. /package/dist/cli-bundle/chunks/{chunk-NKZAN7BD.js.map → chunk-5IZUBZBR.js.map} +0 -0
  542. /package/dist/cli-bundle/chunks/{chunk-NOLPZMSV.js.map → chunk-5JIWFWOZ.js.map} +0 -0
  543. /package/dist/cli-bundle/chunks/{chunk-6AQZPVHQ.js.map → chunk-6CDCWKSX.js.map} +0 -0
  544. /package/dist/cli-bundle/chunks/{chunk-LB6TP6MC.js.map → chunk-6NYJGMTY.js.map} +0 -0
  545. /package/dist/cli-bundle/chunks/{chunk-SLMUGTK3.js.map → chunk-7CLLC75T.js.map} +0 -0
  546. /package/dist/cli-bundle/chunks/{chunk-2466X6E4.js.map → chunk-7LYO6S5A.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{chunk-W4ULYO7Z.js.map → chunk-A3OQ7TFW.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-GJ326ZKX.js.map → chunk-ER4ME5U2.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-HZZEHPRG.js.map → chunk-ERG65A2L.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-L5OEFZQG.js.map → chunk-FH2H3CBD.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-JPECA746.js.map → chunk-FUFFPIYA.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-27BXPBAY.js.map → chunk-GUYNUXQT.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{chunk-MAUKX7JC.js.map → chunk-GVJE5T7Q.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{chunk-ZRP4VG5U.js.map → chunk-JBZ2NTKX.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{chunk-EJUDVUYZ.js.map → chunk-KEZOIPCR.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{chunk-HYTGA6GI.js.map → chunk-MDHWWBNZ.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{chunk-N74UMG5H.js.map → chunk-MEZZZBYX.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{chunk-SDR5J34Q.js.map → chunk-NZ7QIUP5.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{chunk-DDPTYJIM.js.map → chunk-P5L7Z2O6.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{chunk-OGXLACHC.js.map → chunk-SU2E4AWU.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{chunk-HPPFYYOV.js.map → chunk-SU3TB4NS.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-G7I7DEZA.js.map → chunk-T4XBKJ3F.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-VICZWYGZ.js.map → chunk-U5TR4N7J.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-EVMTBV6V.js.map → chunk-UMNQZS4H.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-A7FPBAQS.js.map → chunk-WJA3PXW7.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-QCWF6IYD.js.map → chunk-YSDFIY7N.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-UZIWVBE6.js.map → chunk-YSGTMDWC.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{chunk-64HNBBFQ.js.map → chunk-Z5F6XZXE.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{chunk-AVEE5EHK.js.map → chunk-Z7RPDF2Y.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{claim-T3GCKV7C.js.map → claim-2BGBGSVI.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{claim-EMQLYPRW.js.map → claim-5GU7OE67.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{close-E6ZZGCJY.js.map → close-6YODBUIV.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{close-TQYAAFJP.js.map → close-AFVKPR57.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{comments-YUXJRZPQ.js.map → comments-DNWHEBOS.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{comments-QCKR2YY2.js.map → comments-RW23R3VE.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{context-B6275WPX.js.map → context-OYXRGY7S.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{context-OCZ3FJ4Z.js.map → context-PKCEHQY3.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{copy-DEM4DATS.js.map → copy-6XOR3HKN.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{copy-BTJOSKKT.js.map → copy-I4NCLBR4.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{create-RLRJMRTM.js.map → create-PM45M6PE.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{create-OH3BDGBB.js.map → create-Z7YCH3BE.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{delete-BHK7VB2Z.js.map → delete-7YXHYG67.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{delete-LSVHAB4Y.js.map → delete-LPISP43T.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{deps-XHYXWEPT.js.map → deps-N2T26FME.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{deps-4UDFJRUA.js.map → deps-WATKQDE3.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{docs-GYZNVS26.js.map → docs-6LQ3GLM7.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{docs-26S44RXU.js.map → docs-Z3X6JZLT.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{eval-UYF3ZPVO.js.map → eval-6DCLG52D.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{eval-PGRVIJQU.js.map → eval-Y3ZCUTHK.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{extension-CPSLJQVE.js.map → extension-BNINIMT7.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{extension-CXJ6RELI.js.map → extension-QWE4YYK5.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{files-NQHEXUZD.js.map → files-6SGKHS6O.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{files-MBNICQFM.js.map → files-FUYPSOFJ.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{focus-DWYIG7GU.js.map → focus-2Q3K76G2.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{focus-XZW5423D.js.map → focus-ATLBWXXD.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{gc-LPVMKJQJ.js.map → gc-RUYEMNRF.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{gc-7GQYOS2G.js.map → gc-TDWSDR66.js.map} +0 -0
  598. /package/dist/cli-bundle/chunks/{history-WSZHY3PN.js.map → history-CGNQJXFE.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{history-NERDJNUB.js.map → history-SGRRS72R.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{history-redact-O3NBCNWC.js.map → history-redact-IRL7WJ3E.js.map} +0 -0
  601. /package/dist/cli-bundle/chunks/{history-redact-MP6CH7U5.js.map → history-redact-N3JK7VBW.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{init-64XDLQJB.js.map → init-4GESW7RM.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{init-PAX32BJA.js.map → init-XIDPABA4.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{learnings-LPKCSJX7.js.map → learnings-4BHWFFUV.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{learnings-JR6MA5TI.js.map → learnings-4FJY7WIW.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{list-G5Y65VF6.js.map → list-472TIOVK.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{list-DNBJVO3E.js.map → list-D7BF5CL2.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{notes-2BMU3VVQ.js.map → notes-6KNOSLIT.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{notes-6KTGO2OJ.js.map → notes-W4UEICGF.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{restore-4MHZFJ2E.js.map → restore-44IHMMZZ.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{restore-YALDGTQR.js.map → restore-EXHU34EU.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-LB6DOLRL.js.map → scheduling-shortcuts-OLHNLAZY.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{scheduling-shortcuts-UTOYKLXQ.js.map → scheduling-shortcuts-TSBK4AY5.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{schema-73HR2OJW.js.map → schema-IB2NZZWD.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{schema-U6LJKSIR.js.map → schema-VBCELP5G.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{search-AXPXKZER.js.map → search-7UBETML4.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{search-KILGT37L.js.map → search-R227JOL6.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{stats-W5KNVJWQ.js.map → stats-FAG7COEH.js.map} +0 -0
  619. /package/dist/cli-bundle/chunks/{stats-PSYVVTNZ.js.map → stats-MCK7PLYS.js.map} +0 -0
  620. /package/dist/cli-bundle/chunks/{test-PWDIZ255.js.map → test-QY44WAMR.js.map} +0 -0
  621. /package/dist/cli-bundle/chunks/{test-ACD52Z3S.js.map → test-SY76DZTO.js.map} +0 -0
  622. /package/dist/cli-bundle/chunks/{update-AMRSOIWP.js.map → update-A7EICML6.js.map} +0 -0
  623. /package/dist/cli-bundle/chunks/{update-KFX2SIAC.js.map → update-IKJZWLQC.js.map} +0 -0
  624. /package/dist/cli-bundle/chunks/{upgrade-BRL6KCOJ.js.map → upgrade-NWMR3VQL.js.map} +0 -0
  625. /package/dist/cli-bundle/chunks/{upgrade-HAK6JG2O.js.map → upgrade-VU46BLJZ.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"status-defs-file.js","sources":["core/schema/status-defs-file.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/schema/status-defs-file\n *\n * Resolves configurable schema, fields, statuses, and workflows for Status Defs File.\n */\nimport { RUNTIME_STATUS_ROLE_VALUES } from \"../../types/index.js\";\nimport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\nimport { DEFAULT_RUNTIME_STATUS_DEFINITIONS } from \"./runtime-schema.js\";\n\nexport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\n\n/**\n * Pure logic for the `pm schema add-status` / `pm schema remove-status`\n * commands. The CLI command file (schema.ts) owns IO/governance; everything\n * testable and side-effect-free lives here so it can be coverage-gated to 100%.\n *\n * Statuses persist at `.agents/pm/schema/statuses.json` under the shape\n * `{ statuses: RuntimeStatusDefinition[] }`. When the file is absent the runtime\n * merge layer (src/core/store/settings.ts) still supplies the built-in defaults\n * from DEFAULT_RUNTIME_STATUS_DEFINITIONS, so this module never duplicates them\n * into the persisted file.\n */\n\nconst RUNTIME_STATUS_ROLE_SET = new Set<string>(RUNTIME_STATUS_ROLE_VALUES);\n\n/**\n * The 5 lifecycle status ids that ship as built-in defaults and may never be\n * removed (their normalized ids match DEFAULT_RUNTIME_STATUS_DEFINITIONS:\n * open/in_progress/blocked/closed/canceled). `draft` is also a default but the\n * acceptance criteria enumerate the 5 terminal/active ids explicitly, so the\n * guard derives the full set from the canonical defaults to stay in sync.\n */\nexport const BUILTIN_STATUS_IDS: ReadonlySet<string> = new Set(\n DEFAULT_RUNTIME_STATUS_DEFINITIONS.map((definition) => normalizeStatusToken(definition.id)).filter(\n (id) => id.length > 0,\n ),\n);\n\n/**\n * The shape persisted at `.agents/pm/schema/statuses.json`.\n */\nexport interface StatusDefsFile {\n statuses: RuntimeStatusDefinition[];\n}\n\n/**\n * Documents the raw add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface RawAddStatusInput {\n id: string | undefined;\n roles?: string[];\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the normalized add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface NormalizedAddStatusInput {\n id: string;\n /**\n * Normalized roles, or `undefined` when the raw input did not supply a roles\n * field at all. `undefined` means \"leave existing roles untouched\" on upsert;\n * an explicit empty array means \"clear roles\". This distinction is what keeps\n * `add-status review --description x` from wiping a previously-set role.\n */\n roles?: RuntimeStatusRole[];\n /** Same omitted-vs-explicit-empty semantics as `roles`. */\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the upsert status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface UpsertStatusDefResult {\n file: StatusDefsFile;\n /** The definition as stored after the upsert (existing fields preserved). */\n definition: RuntimeStatusDefinition;\n /** True when an existing definition with the same (normalized) id was replaced. */\n replaced: boolean;\n}\n\n/**\n * Documents the remove status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RemoveStatusDefResult {\n file: StatusDefsFile;\n /** True when a matching definition existed and was dropped from the file. */\n removed: boolean;\n /** The removed definition, when one matched the requested id. */\n definition?: RuntimeStatusDefinition;\n}\n\n/**\n * Normalizes a status token using the same rules as runtime-schema.ts: lowercase\n * and collapse any run of whitespace/hyphens into a single underscore.\n */\nexport function normalizeStatusToken(value: unknown): string {\n return typeof value === \"string\" ? value.trim().toLowerCase().replaceAll(/[\\s-]+/g, \"_\") : \"\";\n}\n\nfunction dedupeTokens(values: Iterable<string>): string[] {\n const seen = new Set<string>();\n for (const value of values) {\n const token = normalizeStatusToken(value);\n if (token.length > 0) {\n seen.add(token);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Validates and normalizes raw add-status CLI input. Throws a plain Error with a\n * stable message when the id is missing/empty or a role is not one of\n * RUNTIME_STATUS_ROLE_VALUES; the CLI layer maps these to PmCliError exit codes.\n *\n * Omitted vs explicit-empty is preserved end-to-end: when `raw.roles`/`raw.aliases`\n * is `undefined` (flag not supplied) the normalized field is `undefined` so the\n * upsert leaves the existing value untouched; when supplied (even an empty array)\n * the field is normalized to an array so the upsert can apply an explicit clear.\n */\nexport function normalizeAddStatusInput(raw: RawAddStatusInput): NormalizedAddStatusInput {\n const id = normalizeStatusToken(raw.id);\n if (id.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n // Built-in lifecycle statuses are reserved and cannot be overridden: an\n // add-status override would change reserved metadata yet remove-status refuses\n // to delete a built-in id, leaving no CLI path to undo it. Reject up front,\n // symmetric with removeStatusDef.\n if (BUILTIN_STATUS_IDS.has(id)) {\n throw new Error(\n `Cannot add-status the built-in status \"${id}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n let roles: RuntimeStatusRole[] | undefined;\n if (raw.roles !== undefined) {\n roles = [];\n const seenRoles = new Set<string>();\n for (const rawRole of raw.roles) {\n const role = typeof rawRole === \"string\" ? rawRole.trim().toLowerCase() : \"\";\n if (role.length === 0) {\n continue;\n }\n if (!RUNTIME_STATUS_ROLE_SET.has(role)) {\n throw new Error(\n `Invalid status role \"${rawRole}\". Allowed roles: ${RUNTIME_STATUS_ROLE_VALUES.join(\", \")}.`,\n );\n }\n if (!seenRoles.has(role)) {\n seenRoles.add(role);\n roles.push(role as RuntimeStatusRole);\n }\n }\n }\n const aliases =\n raw.aliases === undefined ? undefined : dedupeTokens(raw.aliases).filter((alias) => alias !== id);\n const description = raw.description?.trim();\n const order =\n typeof raw.order === \"number\" && Number.isFinite(raw.order) ? Math.trunc(raw.order) : undefined;\n return {\n id,\n roles,\n aliases,\n description: description && description.length > 0 ? description : undefined,\n order,\n };\n}\n\nfunction selectStatusesArray(parsed: unknown): unknown[] | undefined {\n if (Array.isArray(parsed)) {\n return parsed;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as Record<string, unknown>;\n if (Array.isArray(record.statuses)) {\n return record.statuses;\n }\n if (Array.isArray(record.definitions)) {\n return record.definitions;\n }\n return undefined;\n}\n\nfunction extractStatusDefinitions(parsed: unknown): RuntimeStatusDefinition[] {\n const candidate = selectStatusesArray(parsed);\n if (!candidate) {\n return [];\n }\n const definitions: RuntimeStatusDefinition[] = [];\n for (const entry of candidate) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n continue;\n }\n const record = entry as Record<string, unknown>;\n if (typeof record.id !== \"string\" || record.id.trim().length === 0) {\n continue;\n }\n definitions.push(record as unknown as RuntimeStatusDefinition);\n }\n return definitions;\n}\n\n/**\n * Coerces an arbitrary parsed value from statuses.json into a StatusDefsFile.\n * Accepts the canonical `{ statuses: [...] }` shape, a bare array of\n * definitions, or a `{ definitions: [...] }` form, and tolerates a\n * missing/invalid file by returning an empty statuses list.\n */\nexport function parseStatusDefsFile(raw: string | null | undefined): StatusDefsFile {\n if (raw === null || raw === undefined || raw.trim().length === 0) {\n return { statuses: [] };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(\"schema/statuses.json contains invalid JSON.\");\n }\n return { statuses: extractStatusDefinitions(parsed) };\n}\n\n/**\n * Serializes the status definitions file with a trailing newline (matches the\n * rest of the schema scaffold files written by pm).\n */\nexport function serializeStatusDefsFile(file: StatusDefsFile): string {\n return `${JSON.stringify({ statuses: file.statuses }, null, 2)}\\n`;\n}\n\n/**\n * Idempotent UPSERT of a status definition into the parsed file. Matching is by\n * normalized id. When a definition already exists, fields supplied in `input`\n * override the previous values (roles/aliases replace when a non-empty array is\n * given, clear when an explicit empty array is given, and are left UNTOUCHED\n * when the field is `undefined` — i.e. the add-status flag was omitted);\n * description/order override when provided. Fields not addressed by add-status\n * flags are preserved untouched, so `add-status <id> --description x` keeps any\n * previously-set roles/aliases.\n */\nexport function upsertStatusDef(\n file: StatusDefsFile,\n input: NormalizedAddStatusInput,\n baseDefinition?: RuntimeStatusDefinition,\n): UpsertStatusDefResult {\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === input.id,\n );\n // A file-backed definition is the primary seed; when the status is not yet in\n // statuses.json fall back to `baseDefinition` (the resolved settings-backed\n // definition) so omitting --role/--alias preserves metadata that lives in\n // settings.schema.statuses rather than the file.\n const existing = existingIndex >= 0 ? statuses[existingIndex] : baseDefinition;\n\n const next: RuntimeStatusDefinition = {\n ...existing,\n id: input.id,\n };\n if (input.roles !== undefined) {\n if (input.roles.length > 0) {\n next.roles = [...input.roles];\n } else if (next.roles !== undefined) {\n delete next.roles;\n }\n }\n if (input.aliases !== undefined) {\n if (input.aliases.length > 0) {\n next.aliases = [...input.aliases];\n } else if (next.aliases !== undefined) {\n delete next.aliases;\n }\n }\n if (input.description !== undefined) {\n next.description = input.description;\n }\n if (input.order !== undefined) {\n next.order = input.order;\n }\n\n if (existingIndex >= 0) {\n statuses[existingIndex] = next;\n } else {\n statuses.push(next);\n }\n\n return {\n file: { statuses },\n definition: next,\n // \"replaced\" reflects whether the status already existed effectively (in the\n // file OR in resolved settings), so the CLI reports \"Updated\" vs \"Registered\"\n // correctly even when the prior definition lived only in settings.\n replaced: existing !== undefined,\n };\n}\n\n/**\n * Removes a status definition from the parsed file by id (normalized). Throws a\n * plain Error when `id` is empty or matches a reserved built-in default status\n * (those are never stored in the file and must never be deletable). Returns\n * `removed: false` when no matching definition exists so the CLI layer can treat\n * the call as an idempotent no-op.\n */\nexport function removeStatusDef(file: StatusDefsFile, id: string | undefined): RemoveStatusDefResult {\n const normalizedId = normalizeStatusToken(id);\n if (normalizedId.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n if (BUILTIN_STATUS_IDS.has(normalizedId)) {\n throw new Error(\n `Cannot remove built-in status \"${normalizedId}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === normalizedId,\n );\n if (existingIndex < 0) {\n return { file: { statuses }, removed: false };\n }\n const [definition] = statuses.splice(existingIndex, 1);\n return { file: { statuses }, removed: true, definition };\n}\n\n/**\n * Throws when the new status id or any explicitly-supplied alias collides with a\n * DIFFERENT existing status's id/alias. `resolvedAliasToId` maps a normalized\n * token to its owning status id (the runtime status registry's alias_to_id map,\n * which stores ids and aliases in one namespace). Re-adding the same status\n * (matching id) is allowed — only cross-status collisions throw. This prevents a\n * custom status from shadowing a built-in lifecycle token (for example\n * `add-status review --alias open`, or a custom id `cancelled` that aliases the\n * built-in `canceled`), which would make `pm update --status open` resolve to the\n * wrong status. The CLI layer maps the thrown Error to a USAGE exit code.\n */\nexport function assertStatusTokensAvailable(\n input: { id: string; aliases?: string[] },\n resolvedAliasToId: ReadonlyMap<string, string>,\n): void {\n const candidates = [input.id, ...(input.aliases ?? [])];\n for (const candidate of candidates) {\n const token = normalizeStatusToken(candidate);\n if (token.length === 0) {\n continue;\n }\n const owner = resolvedAliasToId.get(token);\n if (owner !== undefined && owner !== input.id) {\n throw new Error(\n `Status token \"${token}\" already belongs to status \"${owner}\". Choose a different id/alias to avoid shadowing it.`,\n );\n }\n }\n}\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AAIzE;;;;;;;;;;GAUG;AAEH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,0BAA0B,CAAC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAC5D,kCAAkC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAChG,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CACtB,CACF,CAAC;AA4DF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAChG,CAAC;AAED,SAAS,YAAY,CAAC,MAAwB;IAC5C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI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I,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,iBAAiB,KAAK,gCAAgC,KAAK,uDAAuD,CACnH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","debugId":"672a473b-429a-5039-b5ca-0937c660e6dd"}
1
+ {"version":3,"file":"status-defs-file.js","sources":["core/schema/status-defs-file.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/schema/status-defs-file\n *\n * Resolves configurable schema, fields, statuses, and workflows for Status Defs File.\n */\nimport { RUNTIME_STATUS_ROLE_VALUES } from \"../../types/index.js\";\nimport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\nimport { DEFAULT_RUNTIME_STATUS_DEFINITIONS } from \"./runtime-schema.js\";\nimport { evictOldestMemoEntries } from \"../shared/memo.js\";\n\nexport type { RuntimeStatusDefinition, RuntimeStatusRole } from \"../../types/index.js\";\n\n/**\n * Pure logic for the `pm schema add-status` / `pm schema remove-status`\n * commands. The CLI command file (schema.ts) owns IO/governance; everything\n * testable and side-effect-free lives here so it can be coverage-gated to 100%.\n *\n * Statuses persist at `.agents/pm/schema/statuses.json` under the shape\n * `{ statuses: RuntimeStatusDefinition[] }`. When the file is absent the runtime\n * merge layer (src/core/store/settings.ts) still supplies the built-in defaults\n * from DEFAULT_RUNTIME_STATUS_DEFINITIONS, so this module never duplicates them\n * into the persisted file.\n */\n\nconst RUNTIME_STATUS_ROLE_SET = new Set<string>(RUNTIME_STATUS_ROLE_VALUES);\n\n/**\n * Memo for {@link normalizeStatusToken}. Status ranking inside sort comparators\n * normalizes the same handful of status strings O(n log n) times per corpus scan, and\n * the trim/lowercase/regex pipeline shows up in list/next/context profiles. The cap\n * bounds memory in long-lived hosts against unbounded arbitrary inputs; half-eviction keeps the\n * newest-inserted half when the cap is hit. Declared before\n * BUILTIN_STATUS_IDS, whose module-level initializer already normalizes tokens.\n */\nconst STATUS_TOKEN_MEMO_MAX_ENTRIES = 2_000;\nconst statusTokenMemo = new Map<string, string>();\n\n/**\n * The 5 lifecycle status ids that ship as built-in defaults and may never be\n * removed (their normalized ids match DEFAULT_RUNTIME_STATUS_DEFINITIONS:\n * open/in_progress/blocked/closed/canceled). `draft` is also a default but the\n * acceptance criteria enumerate the 5 terminal/active ids explicitly, so the\n * guard derives the full set from the canonical defaults to stay in sync.\n */\nexport const BUILTIN_STATUS_IDS: ReadonlySet<string> = new Set(\n DEFAULT_RUNTIME_STATUS_DEFINITIONS.map((definition) => normalizeStatusToken(definition.id)).filter(\n (id) => id.length > 0,\n ),\n);\n\n/**\n * The shape persisted at `.agents/pm/schema/statuses.json`.\n */\nexport interface StatusDefsFile {\n statuses: RuntimeStatusDefinition[];\n}\n\n/**\n * Documents the raw add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface RawAddStatusInput {\n id: string | undefined;\n roles?: string[];\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the normalized add status input payload exchanged by command, SDK, and package integrations.\n */\nexport interface NormalizedAddStatusInput {\n id: string;\n /**\n * Normalized roles, or `undefined` when the raw input did not supply a roles\n * field at all. `undefined` means \"leave existing roles untouched\" on upsert;\n * an explicit empty array means \"clear roles\". This distinction is what keeps\n * `add-status review --description x` from wiping a previously-set role.\n */\n roles?: RuntimeStatusRole[];\n /** Same omitted-vs-explicit-empty semantics as `roles`. */\n aliases?: string[];\n description?: string;\n order?: number;\n}\n\n/**\n * Documents the upsert status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface UpsertStatusDefResult {\n file: StatusDefsFile;\n /** The definition as stored after the upsert (existing fields preserved). */\n definition: RuntimeStatusDefinition;\n /** True when an existing definition with the same (normalized) id was replaced. */\n replaced: boolean;\n}\n\n/**\n * Documents the remove status def result payload exchanged by command, SDK, and package integrations.\n */\nexport interface RemoveStatusDefResult {\n file: StatusDefsFile;\n /** True when a matching definition existed and was dropped from the file. */\n removed: boolean;\n /** The removed definition, when one matched the requested id. */\n definition?: RuntimeStatusDefinition;\n}\n\n/**\n * Normalizes a status token using the same rules as runtime-schema.ts: lowercase\n * and collapse any run of whitespace/hyphens into a single underscore.\n */\nexport function normalizeStatusToken(value: unknown): string {\n if (typeof value !== \"string\") {\n return \"\";\n }\n const memoized = statusTokenMemo.get(value);\n if (memoized !== undefined) {\n return memoized;\n }\n const normalized = value.trim().toLowerCase().replaceAll(/[\\s-]+/g, \"_\");\n if (statusTokenMemo.size >= STATUS_TOKEN_MEMO_MAX_ENTRIES) {\n evictOldestMemoEntries(statusTokenMemo);\n }\n statusTokenMemo.set(value, normalized);\n return normalized;\n}\n\nfunction dedupeTokens(values: Iterable<string>): string[] {\n const seen = new Set<string>();\n for (const value of values) {\n const token = normalizeStatusToken(value);\n if (token.length > 0) {\n seen.add(token);\n }\n }\n return [...seen].sort((left, right) => left.localeCompare(right));\n}\n\n/**\n * Validates and normalizes raw add-status CLI input. Throws a plain Error with a\n * stable message when the id is missing/empty or a role is not one of\n * RUNTIME_STATUS_ROLE_VALUES; the CLI layer maps these to PmCliError exit codes.\n *\n * Omitted vs explicit-empty is preserved end-to-end: when `raw.roles`/`raw.aliases`\n * is `undefined` (flag not supplied) the normalized field is `undefined` so the\n * upsert leaves the existing value untouched; when supplied (even an empty array)\n * the field is normalized to an array so the upsert can apply an explicit clear.\n */\nexport function normalizeAddStatusInput(raw: RawAddStatusInput): NormalizedAddStatusInput {\n const id = normalizeStatusToken(raw.id);\n if (id.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n // Built-in lifecycle statuses are reserved and cannot be overridden: an\n // add-status override would change reserved metadata yet remove-status refuses\n // to delete a built-in id, leaving no CLI path to undo it. Reject up front,\n // symmetric with removeStatusDef.\n if (BUILTIN_STATUS_IDS.has(id)) {\n throw new Error(\n `Cannot add-status the built-in status \"${id}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n let roles: RuntimeStatusRole[] | undefined;\n if (raw.roles !== undefined) {\n roles = [];\n const seenRoles = new Set<string>();\n for (const rawRole of raw.roles) {\n const role = typeof rawRole === \"string\" ? rawRole.trim().toLowerCase() : \"\";\n if (role.length === 0) {\n continue;\n }\n if (!RUNTIME_STATUS_ROLE_SET.has(role)) {\n throw new Error(\n `Invalid status role \"${rawRole}\". Allowed roles: ${RUNTIME_STATUS_ROLE_VALUES.join(\", \")}.`,\n );\n }\n if (!seenRoles.has(role)) {\n seenRoles.add(role);\n roles.push(role as RuntimeStatusRole);\n }\n }\n }\n const aliases =\n raw.aliases === undefined ? undefined : dedupeTokens(raw.aliases).filter((alias) => alias !== id);\n const description = raw.description?.trim();\n const order =\n typeof raw.order === \"number\" && Number.isFinite(raw.order) ? Math.trunc(raw.order) : undefined;\n return {\n id,\n roles,\n aliases,\n description: description && description.length > 0 ? description : undefined,\n order,\n };\n}\n\nfunction selectStatusesArray(parsed: unknown): unknown[] | undefined {\n if (Array.isArray(parsed)) {\n return parsed;\n }\n if (typeof parsed !== \"object\" || parsed === null) {\n return undefined;\n }\n const record = parsed as Record<string, unknown>;\n if (Array.isArray(record.statuses)) {\n return record.statuses;\n }\n if (Array.isArray(record.definitions)) {\n return record.definitions;\n }\n return undefined;\n}\n\nfunction extractStatusDefinitions(parsed: unknown): RuntimeStatusDefinition[] {\n const candidate = selectStatusesArray(parsed);\n if (!candidate) {\n return [];\n }\n const definitions: RuntimeStatusDefinition[] = [];\n for (const entry of candidate) {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) {\n continue;\n }\n const record = entry as Record<string, unknown>;\n if (typeof record.id !== \"string\" || record.id.trim().length === 0) {\n continue;\n }\n definitions.push(record as unknown as RuntimeStatusDefinition);\n }\n return definitions;\n}\n\n/**\n * Coerces an arbitrary parsed value from statuses.json into a StatusDefsFile.\n * Accepts the canonical `{ statuses: [...] }` shape, a bare array of\n * definitions, or a `{ definitions: [...] }` form, and tolerates a\n * missing/invalid file by returning an empty statuses list.\n */\nexport function parseStatusDefsFile(raw: string | null | undefined): StatusDefsFile {\n if (raw === null || raw === undefined || raw.trim().length === 0) {\n return { statuses: [] };\n }\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n throw new Error(\"schema/statuses.json contains invalid JSON.\");\n }\n return { statuses: extractStatusDefinitions(parsed) };\n}\n\n/**\n * Serializes the status definitions file with a trailing newline (matches the\n * rest of the schema scaffold files written by pm).\n */\nexport function serializeStatusDefsFile(file: StatusDefsFile): string {\n return `${JSON.stringify({ statuses: file.statuses }, null, 2)}\\n`;\n}\n\n/**\n * Idempotent UPSERT of a status definition into the parsed file. Matching is by\n * normalized id. When a definition already exists, fields supplied in `input`\n * override the previous values (roles/aliases replace when a non-empty array is\n * given, clear when an explicit empty array is given, and are left UNTOUCHED\n * when the field is `undefined` — i.e. the add-status flag was omitted);\n * description/order override when provided. Fields not addressed by add-status\n * flags are preserved untouched, so `add-status <id> --description x` keeps any\n * previously-set roles/aliases.\n */\nexport function upsertStatusDef(\n file: StatusDefsFile,\n input: NormalizedAddStatusInput,\n baseDefinition?: RuntimeStatusDefinition,\n): UpsertStatusDefResult {\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === input.id,\n );\n // A file-backed definition is the primary seed; when the status is not yet in\n // statuses.json fall back to `baseDefinition` (the resolved settings-backed\n // definition) so omitting --role/--alias preserves metadata that lives in\n // settings.schema.statuses rather than the file.\n const existing = existingIndex >= 0 ? statuses[existingIndex] : baseDefinition;\n\n const next: RuntimeStatusDefinition = {\n ...existing,\n id: input.id,\n };\n if (input.roles !== undefined) {\n if (input.roles.length > 0) {\n next.roles = [...input.roles];\n } else if (next.roles !== undefined) {\n delete next.roles;\n }\n }\n if (input.aliases !== undefined) {\n if (input.aliases.length > 0) {\n next.aliases = [...input.aliases];\n } else if (next.aliases !== undefined) {\n delete next.aliases;\n }\n }\n if (input.description !== undefined) {\n next.description = input.description;\n }\n if (input.order !== undefined) {\n next.order = input.order;\n }\n\n if (existingIndex >= 0) {\n statuses[existingIndex] = next;\n } else {\n statuses.push(next);\n }\n\n return {\n file: { statuses },\n definition: next,\n // \"replaced\" reflects whether the status already existed effectively (in the\n // file OR in resolved settings), so the CLI reports \"Updated\" vs \"Registered\"\n // correctly even when the prior definition lived only in settings.\n replaced: existing !== undefined,\n };\n}\n\n/**\n * Removes a status definition from the parsed file by id (normalized). Throws a\n * plain Error when `id` is empty or matches a reserved built-in default status\n * (those are never stored in the file and must never be deletable). Returns\n * `removed: false` when no matching definition exists so the CLI layer can treat\n * the call as an idempotent no-op.\n */\nexport function removeStatusDef(file: StatusDefsFile, id: string | undefined): RemoveStatusDefResult {\n const normalizedId = normalizeStatusToken(id);\n if (normalizedId.length === 0) {\n throw new Error(\"Status id must not be empty.\");\n }\n if (BUILTIN_STATUS_IDS.has(normalizedId)) {\n throw new Error(\n `Cannot remove built-in status \"${normalizedId}\". Built-in statuses are reserved: ${[...BUILTIN_STATUS_IDS].join(\", \")}.`,\n );\n }\n const statuses = file.statuses.slice();\n const existingIndex = statuses.findIndex(\n (definition) => normalizeStatusToken(definition.id) === normalizedId,\n );\n if (existingIndex < 0) {\n return { file: { statuses }, removed: false };\n }\n const [definition] = statuses.splice(existingIndex, 1);\n return { file: { statuses }, removed: true, definition };\n}\n\n/**\n * Throws when the new status id or any explicitly-supplied alias collides with a\n * DIFFERENT existing status's id/alias. `resolvedAliasToId` maps a normalized\n * token to its owning status id (the runtime status registry's alias_to_id map,\n * which stores ids and aliases in one namespace). Re-adding the same status\n * (matching id) is allowed — only cross-status collisions throw. This prevents a\n * custom status from shadowing a built-in lifecycle token (for example\n * `add-status review --alias open`, or a custom id `cancelled` that aliases the\n * built-in `canceled`), which would make `pm update --status open` resolve to the\n * wrong status. The CLI layer maps the thrown Error to a USAGE exit code.\n */\nexport function assertStatusTokensAvailable(\n input: { id: string; aliases?: string[] },\n resolvedAliasToId: ReadonlyMap<string, string>,\n): void {\n const candidates = [input.id, ...(input.aliases ?? [])];\n for (const candidate of candidates) {\n const token = normalizeStatusToken(candidate);\n if (token.length === 0) {\n continue;\n }\n const owner = resolvedAliasToId.get(token);\n if (owner !== undefined && owner !== input.id) {\n throw new Error(\n `Status token \"${token}\" already belongs to status \"${owner}\". Choose a different id/alias to avoid shadowing it.`,\n );\n }\n }\n}\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,OAAO,EAAE,kCAAkC,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAI3D;;;;;;;;;;GAUG;AAEH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAS,0BAA0B,CAAC,CAAC;AAE5E;;;;;;;GAOG;AACH,MAAM,6BAA6B,GAAG,KAAK,CAAC;AAC5C,MAAM,eAAe,GAAG,IAAI,GAAG,EAAkB,CAAC;AAElD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAwB,IAAI,GAAG,CAC5D,kCAAkC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAChG,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CACtB,CACF,CAAC;AA4DF;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC5C,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,C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AI,EAAE,UAAU,EAAE,CAAC;AAC3D,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CACzC,KAAyC,EACzC,iBAA8C;IAE9C,MAAM,UAAU,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,SAAS;QACX,CAAC;QACD,MAAM,KAAK,GAAG,iBAAiB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3C,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,KAAK,CAAC,EAAE,EAAE,CAAC;YAC9C,MAAM,IAAI,KAAK,CACb,iBAAiB,KAAK,gCAAgC,KAAK,uDAAuD,CACnH,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC","debugId":"4ca30149-d989-52dc-8614-81b993d3c9a5"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9a2bb0db-638e-55b9-b8a0-c37fa8fc54fe")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="74066cb9-628c-51d0-b64e-ad12b95a0d1c")}catch(e){}}();
3
3
  import { coercePositiveInteger } from "../shared/primitives.js";
4
4
  /**
5
5
  * Canonical ordered list of corpus field names emitted by {@link buildSearchCorpus}.
@@ -100,24 +100,19 @@ export function buildEventCorpus(item) {
100
100
  event.recurrence?.exdates?.join(" "),
101
101
  ]));
102
102
  }
103
- /**
104
- * Implements build plan flat corpus for the public runtime surface of this module.
105
- */
106
- export function buildPlanFlatCorpus(item) {
107
- const segments = [];
108
- segments.push(item.plan_mode, item.plan_scope, item.plan_harness, item.plan_resume_context);
109
- for (const step of item.plan_steps ?? []) {
110
- segments.push(step.title, step.body, step.status, step.owner, step.evidence, step.blocked_reason, step.superseded_by);
111
- for (const link of step.linked_items ?? []) {
112
- segments.push(`${link.kind} ${link.id}`, link.note);
113
- }
114
- for (const file of step.files ?? [])
115
- segments.push(file.path, file.note);
116
- for (const test of step.tests ?? [])
117
- segments.push(test.command, test.path, test.note);
118
- for (const doc of step.docs ?? [])
119
- segments.push(doc.path, doc.note);
103
+ function appendPlanStepFlatCorpus(segments, step) {
104
+ segments.push(step.title, step.body, step.status, step.owner, step.evidence, step.blocked_reason, step.superseded_by);
105
+ for (const link of step.linked_items ?? []) {
106
+ segments.push(`${link.kind} ${link.id}`, link.note);
120
107
  }
108
+ for (const file of step.files ?? [])
109
+ segments.push(file.path, file.note);
110
+ for (const test of step.tests ?? [])
111
+ segments.push(test.command, test.path, test.note);
112
+ for (const doc of step.docs ?? [])
113
+ segments.push(doc.path, doc.note);
114
+ }
115
+ function appendPlanMetadataFlatCorpus(segments, item) {
121
116
  for (const decision of item.plan_decisions ?? []) {
122
117
  segments.push(decision.decision, decision.rationale, decision.evidence);
123
118
  }
@@ -127,6 +122,17 @@ export function buildPlanFlatCorpus(item) {
127
122
  for (const check of item.plan_validation ?? []) {
128
123
  segments.push(check.text, check.command, check.expected);
129
124
  }
125
+ }
126
+ /**
127
+ * Implements build plan flat corpus for the public runtime surface of this module.
128
+ */
129
+ export function buildPlanFlatCorpus(item) {
130
+ const segments = [];
131
+ segments.push(item.plan_mode, item.plan_scope, item.plan_harness, item.plan_resume_context);
132
+ for (const step of item.plan_steps ?? []) {
133
+ appendPlanStepFlatCorpus(segments, step);
134
+ }
135
+ appendPlanMetadataFlatCorpus(segments, item);
130
136
  return segments.filter((segment) => typeof segment === "string" && segment.length > 0).join(" ");
131
137
  }
132
138
  /**
@@ -279,4 +285,4 @@ export function buildSemanticCorpusInput(document, options = {}) {
279
285
  return `${serialized.slice(0, keepLength)}${SEMANTIC_CORPUS_TRUNCATION_SUFFIX}`;
280
286
  }
281
287
  //# sourceMappingURL=corpus.js.map
282
- //# debugId=9a2bb0db-638e-55b9-b8a0-c37fa8fc54fe
288
+ //# debugId=74066cb9-628c-51d0-b64e-ad12b95a0d1c
@@ -1 +1 @@
1
- {"version":3,"file":"corpus.js","sources":["core/search/corpus.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/corpus\n *\n * Powers search, embeddings, and semantic retrieval behavior for Corpus.\n */\nimport type { ItemDocument, ItemMetadata, PmSettings } from \"../../types/index.js\";\nimport { coercePositiveInteger } from \"../shared/primitives.js\";\n\n/**\n * Canonical ordered list of corpus field names emitted by {@link buildSearchCorpus}.\n *\n * When `search.corpus_fields` is unset/empty the full set is included (backward\n * compatible). When configured, only the named fields are emitted — letting\n * teams opt structured signals in/out for token efficiency. Unknown names in the\n * configured list are ignored (they simply never match a builder).\n *\n * NOTE: `plan` is conditional — it is only emitted when the item has plan\n * content (see {@link buildPlanCorpus}); it is still part of the default set so\n * plan-bearing items keep their plan corpus.\n */\nexport const DEFAULT_SEARCH_CORPUS_FIELDS: readonly string[] = [\n \"title\",\n \"description\",\n \"tags\",\n \"status\",\n \"type\",\n \"priority\",\n \"assignee\",\n \"parent\",\n \"goal\",\n \"value\",\n \"why_now\",\n \"risk\",\n \"confidence\",\n \"estimated_minutes\",\n \"acceptance_criteria\",\n \"resolution\",\n \"expected_result\",\n \"actual_result\",\n \"body\",\n \"comments\",\n \"notes\",\n \"learnings\",\n \"reminders\",\n \"events\",\n \"dependencies\",\n \"plan\",\n] as const;\n\n/**\n * Resolve the effective corpus field list from settings.\n *\n * - unset / not an array / empty array → the full default set (backward compatible).\n * - non-empty array → exactly those names (string entries only; trimmed; empties dropped).\n */\nexport function resolveSearchCorpusFields(settings: Pick<PmSettings, \"search\"> | undefined): string[] {\n const configured = settings?.search?.corpus_fields;\n if (!Array.isArray(configured)) {\n return [...DEFAULT_SEARCH_CORPUS_FIELDS];\n }\n // The type guard is intentional: corpus_fields comes from user-editable\n // settings.json, so entries are not statically guaranteed to be strings.\n // De-duplicate and drop unknown names (they have no builder) so an invalid\n // config cannot produce duplicate or phantom corpus keys.\n const knownFields = new Set<string>(DEFAULT_SEARCH_CORPUS_FIELDS);\n const selected = Array.from(\n new Set(\n configured\n .filter((entry): entry is string => typeof entry === \"string\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0 && knownFields.has(entry)),\n ),\n );\n return selected.length > 0 ? selected : [...DEFAULT_SEARCH_CORPUS_FIELDS];\n}\n\nexport const DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS = 8_000;\nexport const OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS = 3_200;\nexport const SEMANTIC_CORPUS_TRUNCATION_SUFFIX = \"...[semantic corpus truncated]\";\nexport const SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING =\n \"search_embedding_corpus_max_characters_invalid:using_provider_default\";\n\nfunction compactParts(parts: Array<string | boolean | number | null | undefined>): string {\n return parts\n .map((part) => (part === undefined || part === null ? \"\" : String(part).trim()))\n .filter((part) => part.length > 0)\n .join(\" \");\n}\n\n/**\n * Implements build reminder corpus for the public runtime surface of this module.\n */\nexport function buildReminderCorpus(item: ItemMetadata): string[] {\n return (item.reminders ?? []).map((reminder) => compactParts([reminder.at, reminder.text]));\n}\n\n/**\n * Implements build event corpus for the public runtime surface of this module.\n */\nexport function buildEventCorpus(item: ItemMetadata): string[] {\n return (item.events ?? []).map((event) =>\n compactParts([\n event.start_at,\n event.end_at,\n event.title,\n event.description,\n event.location,\n event.all_day === true ? \"all day\" : undefined,\n event.timezone,\n event.recurrence?.freq,\n event.recurrence?.interval,\n event.recurrence?.count,\n event.recurrence?.until,\n event.recurrence?.by_weekday?.join(\" \"),\n event.recurrence?.by_month_day?.join(\" \"),\n event.recurrence?.exdates?.join(\" \"),\n ]),\n );\n}\n\n/**\n * Implements build plan flat corpus for the public runtime surface of this module.\n */\nexport function buildPlanFlatCorpus(item: ItemMetadata): string {\n const segments: Array<string | undefined> = [];\n segments.push(item.plan_mode, item.plan_scope, item.plan_harness, item.plan_resume_context);\n for (const step of item.plan_steps ?? []) {\n segments.push(step.title, step.body, step.status, step.owner, step.evidence, step.blocked_reason, step.superseded_by);\n for (const link of step.linked_items ?? []) {\n segments.push(`${link.kind} ${link.id}`, link.note);\n }\n for (const file of step.files ?? []) segments.push(file.path, file.note);\n for (const test of step.tests ?? []) segments.push(test.command, test.path, test.note);\n for (const doc of step.docs ?? []) segments.push(doc.path, doc.note);\n }\n for (const decision of item.plan_decisions ?? []) {\n segments.push(decision.decision, decision.rationale, decision.evidence);\n }\n for (const discovery of item.plan_discoveries ?? []) {\n segments.push(discovery.text);\n }\n for (const check of item.plan_validation ?? []) {\n segments.push(check.text, check.command, check.expected);\n }\n return segments.filter((segment): segment is string => typeof segment === \"string\" && segment.length > 0).join(\" \");\n}\n\n/**\n * Implements build plan corpus for the public runtime surface of this module.\n */\nexport function buildPlanCorpus(item: ItemMetadata): Record<string, unknown> | undefined {\n const steps = (item.plan_steps ?? []).map((step) =>\n compactParts([\n step.order,\n step.id,\n step.title,\n step.body,\n step.status,\n step.owner,\n step.evidence,\n step.blocked_reason,\n step.superseded_by,\n (step.linked_items ?? []).map((link) => compactParts([link.kind, link.id, link.note])).join(\" \"),\n (step.files ?? []).map((file) => compactParts([file.path, file.note])).join(\" \"),\n (step.tests ?? []).map((test) => compactParts([test.command, test.path, test.note])).join(\" \"),\n (step.docs ?? []).map((doc) => compactParts([doc.path, doc.note])).join(\" \"),\n ]),\n );\n const decisions = (item.plan_decisions ?? []).map((entry) =>\n compactParts([entry.decision, entry.rationale, entry.evidence, entry.step_id]),\n );\n const discoveries = (item.plan_discoveries ?? []).map((entry) => compactParts([entry.text, entry.step_id]));\n const validation = (item.plan_validation ?? []).map((entry) =>\n compactParts([entry.text, entry.command, entry.expected]),\n );\n const hasPlanContent =\n item.plan_mode !== undefined ||\n item.plan_scope !== undefined ||\n item.plan_harness !== undefined ||\n item.plan_resume_context !== undefined ||\n steps.length > 0 ||\n decisions.length > 0 ||\n discoveries.length > 0 ||\n validation.length > 0;\n if (!hasPlanContent) {\n return undefined;\n }\n return {\n mode: item.plan_mode,\n scope: item.plan_scope,\n harness: item.plan_harness,\n resume_context: item.plan_resume_context,\n steps,\n decisions,\n discoveries,\n validation,\n };\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.trim().length > 0;\n}\n\n/**\n * Documents the search corpus options payload exchanged by command, SDK, and package integrations.\n */\nexport interface SearchCorpusOptions {\n /**\n * Field names to include. When omitted, the full default set is used.\n * See {@link DEFAULT_SEARCH_CORPUS_FIELDS} and {@link resolveSearchCorpusFields}.\n */\n fields?: string[];\n}\n\n/**\n * Builders for each corpus field. Each returns the value to emit, or `undefined`\n * to omit the field entirely (keeps the corpus compact / token-efficient — we do\n * not emit empty strings, empty arrays, or nulls for the optional structured\n * fields). Always-present fields (title/status/etc.) emit their raw value.\n */\nconst CORPUS_FIELD_BUILDERS: Record<string, (document: ItemDocument) => unknown> = {\n title: (document) => document.metadata.title,\n description: (document) => document.metadata.description,\n tags: (document) => document.metadata.tags,\n status: (document) => document.metadata.status,\n type: (document) => document.metadata.type,\n priority: (document) =>\n typeof document.metadata.priority === \"number\" ? document.metadata.priority : undefined,\n assignee: (document) => (isNonEmptyString(document.metadata.assignee) ? document.metadata.assignee : undefined),\n parent: (document) => (isNonEmptyString(document.metadata.parent) ? document.metadata.parent : undefined),\n goal: (document) => (isNonEmptyString(document.metadata.goal) ? document.metadata.goal : undefined),\n value: (document) => (isNonEmptyString(document.metadata.value) ? document.metadata.value : undefined),\n why_now: (document) => (isNonEmptyString(document.metadata.why_now) ? document.metadata.why_now : undefined),\n risk: (document) => (isNonEmptyString(document.metadata.risk) ? document.metadata.risk : undefined),\n confidence: (document) =>\n document.metadata.confidence !== undefined && document.metadata.confidence !== null\n ? document.metadata.confidence\n : undefined,\n estimated_minutes: (document) =>\n typeof document.metadata.estimated_minutes === \"number\" ? document.metadata.estimated_minutes : undefined,\n acceptance_criteria: (document) =>\n isNonEmptyString(document.metadata.acceptance_criteria) ? document.metadata.acceptance_criteria : undefined,\n resolution: (document) =>\n isNonEmptyString(document.metadata.resolution) ? document.metadata.resolution : undefined,\n expected_result: (document) =>\n isNonEmptyString(document.metadata.expected_result) ? document.metadata.expected_result : undefined,\n actual_result: (document) =>\n isNonEmptyString(document.metadata.actual_result) ? document.metadata.actual_result : undefined,\n body: (document) => document.body,\n comments: (document) => (document.metadata.comments ?? []).map((entry) => entry.text),\n notes: (document) => (document.metadata.notes ?? []).map((entry) => entry.text),\n learnings: (document) => (document.metadata.learnings ?? []).map((entry) => entry.text),\n reminders: (document) => buildReminderCorpus(document.metadata),\n events: (document) => buildEventCorpus(document.metadata),\n dependencies: (document) =>\n (document.metadata.dependencies ?? []).map((entry) => ({\n id: entry.id,\n kind: entry.kind,\n })),\n plan: (document) => buildPlanCorpus(document.metadata),\n};\n\n/**\n * Implements build search corpus for the public runtime surface of this module.\n */\nexport function buildSearchCorpus(document: ItemDocument, options: SearchCorpusOptions = {}): Record<string, unknown> {\n const fields = options.fields ?? DEFAULT_SEARCH_CORPUS_FIELDS;\n const corpus: Record<string, unknown> = {};\n for (const field of fields) {\n const builder = CORPUS_FIELD_BUILDERS[field];\n if (!builder) {\n continue;\n }\n const value = builder(document);\n if (value === undefined) {\n continue;\n }\n corpus[field] = value;\n }\n return corpus;\n}\n\n/**\n * Implements resolve semantic corpus input character limit for the public runtime surface of this module.\n */\nexport function resolveSemanticCorpusInputCharacterLimit(providerName: string | undefined): number {\n if (providerName?.trim().toLowerCase() === \"ollama\") {\n return OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS;\n }\n return DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS;\n}\n\n/**\n * Documents the semantic corpus character limit resolution payload exchanged by command, SDK, and package integrations.\n */\nexport interface SemanticCorpusCharacterLimitResolution {\n maxCharacters: number;\n warning: string | null;\n}\n\n/**\n * Implements resolve semantic corpus character limit for the public runtime surface of this module.\n */\nexport function resolveSemanticCorpusCharacterLimit(\n providerName: string | undefined,\n configuredMaxCharacters: unknown,\n): SemanticCorpusCharacterLimitResolution {\n const providerDefaultLimit = resolveSemanticCorpusInputCharacterLimit(providerName);\n const parsed = coercePositiveInteger(configuredMaxCharacters);\n if (parsed !== null) {\n return {\n maxCharacters: parsed,\n warning: null,\n };\n }\n return {\n maxCharacters: providerDefaultLimit,\n warning:\n configuredMaxCharacters === undefined || configuredMaxCharacters === null\n ? null\n : SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING,\n };\n}\n\n/**\n * Documents the semantic corpus input options payload exchanged by command, SDK, and package integrations.\n */\nexport interface SemanticCorpusInputOptions {\n providerName?: string;\n maxCharacters?: number;\n /**\n * Corpus field names to include. When omitted, the full default set is used\n * (see {@link DEFAULT_SEARCH_CORPUS_FIELDS}). Thread the resolved list from\n * {@link resolveSearchCorpusFields} so the embedded input honours\n * `search.corpus_fields`.\n */\n fields?: string[];\n}\n\n/**\n * Implements build semantic corpus input for the public runtime surface of this module.\n */\nexport function buildSemanticCorpusInput(document: ItemDocument, options: SemanticCorpusInputOptions = {}): string {\n const serialized = JSON.stringify(buildSearchCorpus(document, { fields: options.fields }));\n const maxCharacters = resolveSemanticCorpusCharacterLimit(options.providerName, options.maxCharacters)\n .maxCharacters;\n if (serialized.length <= maxCharacters) {\n return serialized;\n }\n if (maxCharacters <= SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length) {\n return SEMANTIC_CORPUS_TRUNCATION_SUFFIX.slice(0, maxCharacters);\n }\n const keepLength = Math.max(0, maxCharacters - SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length);\n return `${serialized.slice(0, keepLength)}${SEMANTIC_CORPUS_TRUNCATION_SUFFIX}`;\n}\n"],"names":[],"mappings":";;AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAsB;IAC7D,OAAO;IACP,aAAa;IACb,MAAM;IACN,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,QAAQ;IACR,MAAM;IACN,OAAO;IACP,SAAS;IACT,MAAM;IACN,YAAY;IACZ,mBAAmB;IACnB,qBAAqB;IACrB,YAAY;IACZ,iBAAiB;IACjB,eAAe;IACf,MAAM;IACN,UAAU;IACV,OAAO;IACP,WAAW;IACX,WAAW;IACX,QAAQ;IACR,cAAc;IACd,MAAM;CACE,CAAC;AAEX;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgD;IACxF,MAAM,UAAU,GAAG,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,4BAA4B,CAAC,CAAC;IAC3C,CAAC;IACD,wEAAwE;IACxE,yEAAyE;IACzE,2EAA2E;IAC3E,0DAA0D;IAC1D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,4BAA4B,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CACzB,IAAI,GAAG,CACL,UAAU;SACP,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;SAC7D,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,CAAC,KAA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I,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,GAAG,iCAAiC,CAAC,MAAM,CAAC,CAAC;IACzF,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,iCAAiC,EAAE,CAAC;AAClF,CAAC","debugId":"9a2bb0db-638e-55b9-b8a0-c37fa8fc54fe"}
1
+ {"version":3,"file":"corpus.js","sources":["core/search/corpus.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/corpus\n *\n * Powers search, embeddings, and semantic retrieval behavior for Corpus.\n */\nimport type { ItemDocument, ItemMetadata, PmSettings } from \"../../types/index.js\";\nimport { coercePositiveInteger } from \"../shared/primitives.js\";\n\n/**\n * Canonical ordered list of corpus field names emitted by {@link buildSearchCorpus}.\n *\n * When `search.corpus_fields` is unset/empty the full set is included (backward\n * compatible). When configured, only the named fields are emitted — letting\n * teams opt structured signals in/out for token efficiency. Unknown names in the\n * configured list are ignored (they simply never match a builder).\n *\n * NOTE: `plan` is conditional — it is only emitted when the item has plan\n * content (see {@link buildPlanCorpus}); it is still part of the default set so\n * plan-bearing items keep their plan corpus.\n */\nexport const DEFAULT_SEARCH_CORPUS_FIELDS: readonly string[] = [\n \"title\",\n \"description\",\n \"tags\",\n \"status\",\n \"type\",\n \"priority\",\n \"assignee\",\n \"parent\",\n \"goal\",\n \"value\",\n \"why_now\",\n \"risk\",\n \"confidence\",\n \"estimated_minutes\",\n \"acceptance_criteria\",\n \"resolution\",\n \"expected_result\",\n \"actual_result\",\n \"body\",\n \"comments\",\n \"notes\",\n \"learnings\",\n \"reminders\",\n \"events\",\n \"dependencies\",\n \"plan\",\n] as const;\n\n/**\n * Resolve the effective corpus field list from settings.\n *\n * - unset / not an array / empty array → the full default set (backward compatible).\n * - non-empty array → exactly those names (string entries only; trimmed; empties dropped).\n */\nexport function resolveSearchCorpusFields(settings: Pick<PmSettings, \"search\"> | undefined): string[] {\n const configured = settings?.search?.corpus_fields;\n if (!Array.isArray(configured)) {\n return [...DEFAULT_SEARCH_CORPUS_FIELDS];\n }\n // The type guard is intentional: corpus_fields comes from user-editable\n // settings.json, so entries are not statically guaranteed to be strings.\n // De-duplicate and drop unknown names (they have no builder) so an invalid\n // config cannot produce duplicate or phantom corpus keys.\n const knownFields = new Set<string>(DEFAULT_SEARCH_CORPUS_FIELDS);\n const selected = Array.from(\n new Set(\n configured\n .filter((entry): entry is string => typeof entry === \"string\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0 && knownFields.has(entry)),\n ),\n );\n return selected.length > 0 ? selected : [...DEFAULT_SEARCH_CORPUS_FIELDS];\n}\n\nexport const DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS = 8_000;\nexport const OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS = 3_200;\nexport const SEMANTIC_CORPUS_TRUNCATION_SUFFIX = \"...[semantic corpus truncated]\";\nexport const SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING =\n \"search_embedding_corpus_max_characters_invalid:using_provider_default\";\n\nfunction compactParts(parts: Array<string | boolean | number | null | undefined>): string {\n return parts\n .map((part) => (part === undefined || part === null ? \"\" : String(part).trim()))\n .filter((part) => part.length > 0)\n .join(\" \");\n}\n\n/**\n * Implements build reminder corpus for the public runtime surface of this module.\n */\nexport function buildReminderCorpus(item: ItemMetadata): string[] {\n return (item.reminders ?? []).map((reminder) => compactParts([reminder.at, reminder.text]));\n}\n\n/**\n * Implements build event corpus for the public runtime surface of this module.\n */\nexport function buildEventCorpus(item: ItemMetadata): string[] {\n return (item.events ?? []).map((event) =>\n compactParts([\n event.start_at,\n event.end_at,\n event.title,\n event.description,\n event.location,\n event.all_day === true ? \"all day\" : undefined,\n event.timezone,\n event.recurrence?.freq,\n event.recurrence?.interval,\n event.recurrence?.count,\n event.recurrence?.until,\n event.recurrence?.by_weekday?.join(\" \"),\n event.recurrence?.by_month_day?.join(\" \"),\n event.recurrence?.exdates?.join(\" \"),\n ]),\n );\n}\n\n/**\n * Implements build plan flat corpus for the public runtime surface of this module.\n */\ntype PlanStepCorpusEntry = NonNullable<ItemMetadata[\"plan_steps\"]>[number];\n\nfunction appendPlanStepFlatCorpus(segments: Array<string | undefined>, step: PlanStepCorpusEntry): void {\n segments.push(step.title, step.body, step.status, step.owner, step.evidence, step.blocked_reason, step.superseded_by);\n for (const link of step.linked_items ?? []) {\n segments.push(`${link.kind} ${link.id}`, link.note);\n }\n for (const file of step.files ?? []) segments.push(file.path, file.note);\n for (const test of step.tests ?? []) segments.push(test.command, test.path, test.note);\n for (const doc of step.docs ?? []) segments.push(doc.path, doc.note);\n}\n\nfunction appendPlanMetadataFlatCorpus(segments: Array<string | undefined>, item: ItemMetadata): void {\n for (const decision of item.plan_decisions ?? []) {\n segments.push(decision.decision, decision.rationale, decision.evidence);\n }\n for (const discovery of item.plan_discoveries ?? []) {\n segments.push(discovery.text);\n }\n for (const check of item.plan_validation ?? []) {\n segments.push(check.text, check.command, check.expected);\n }\n}\n\n/**\n * Implements build plan flat corpus for the public runtime surface of this module.\n */\nexport function buildPlanFlatCorpus(item: ItemMetadata): string {\n const segments: Array<string | undefined> = [];\n segments.push(item.plan_mode, item.plan_scope, item.plan_harness, item.plan_resume_context);\n for (const step of item.plan_steps ?? []) {\n appendPlanStepFlatCorpus(segments, step);\n }\n appendPlanMetadataFlatCorpus(segments, item);\n return segments.filter((segment): segment is string => typeof segment === \"string\" && segment.length > 0).join(\" \");\n}\n\n/**\n * Implements build plan corpus for the public runtime surface of this module.\n */\nexport function buildPlanCorpus(item: ItemMetadata): Record<string, unknown> | undefined {\n const steps = (item.plan_steps ?? []).map((step) =>\n compactParts([\n step.order,\n step.id,\n step.title,\n step.body,\n step.status,\n step.owner,\n step.evidence,\n step.blocked_reason,\n step.superseded_by,\n (step.linked_items ?? []).map((link) => compactParts([link.kind, link.id, link.note])).join(\" \"),\n (step.files ?? []).map((file) => compactParts([file.path, file.note])).join(\" \"),\n (step.tests ?? []).map((test) => compactParts([test.command, test.path, test.note])).join(\" \"),\n (step.docs ?? []).map((doc) => compactParts([doc.path, doc.note])).join(\" \"),\n ]),\n );\n const decisions = (item.plan_decisions ?? []).map((entry) =>\n compactParts([entry.decision, entry.rationale, entry.evidence, entry.step_id]),\n );\n const discoveries = (item.plan_discoveries ?? []).map((entry) => compactParts([entry.text, entry.step_id]));\n const validation = (item.plan_validation ?? []).map((entry) =>\n compactParts([entry.text, entry.command, entry.expected]),\n );\n const hasPlanContent =\n item.plan_mode !== undefined ||\n item.plan_scope !== undefined ||\n item.plan_harness !== undefined ||\n item.plan_resume_context !== undefined ||\n steps.length > 0 ||\n decisions.length > 0 ||\n discoveries.length > 0 ||\n validation.length > 0;\n if (!hasPlanContent) {\n return undefined;\n }\n return {\n mode: item.plan_mode,\n scope: item.plan_scope,\n harness: item.plan_harness,\n resume_context: item.plan_resume_context,\n steps,\n decisions,\n discoveries,\n validation,\n };\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n return typeof value === \"string\" && value.trim().length > 0;\n}\n\n/**\n * Documents the search corpus options payload exchanged by command, SDK, and package integrations.\n */\nexport interface SearchCorpusOptions {\n /**\n * Field names to include. When omitted, the full default set is used.\n * See {@link DEFAULT_SEARCH_CORPUS_FIELDS} and {@link resolveSearchCorpusFields}.\n */\n fields?: string[];\n}\n\n/**\n * Builders for each corpus field. Each returns the value to emit, or `undefined`\n * to omit the field entirely (keeps the corpus compact / token-efficient — we do\n * not emit empty strings, empty arrays, or nulls for the optional structured\n * fields). Always-present fields (title/status/etc.) emit their raw value.\n */\nconst CORPUS_FIELD_BUILDERS: Record<string, (document: ItemDocument) => unknown> = {\n title: (document) => document.metadata.title,\n description: (document) => document.metadata.description,\n tags: (document) => document.metadata.tags,\n status: (document) => document.metadata.status,\n type: (document) => document.metadata.type,\n priority: (document) =>\n typeof document.metadata.priority === \"number\" ? document.metadata.priority : undefined,\n assignee: (document) => (isNonEmptyString(document.metadata.assignee) ? document.metadata.assignee : undefined),\n parent: (document) => (isNonEmptyString(document.metadata.parent) ? document.metadata.parent : undefined),\n goal: (document) => (isNonEmptyString(document.metadata.goal) ? document.metadata.goal : undefined),\n value: (document) => (isNonEmptyString(document.metadata.value) ? document.metadata.value : undefined),\n why_now: (document) => (isNonEmptyString(document.metadata.why_now) ? document.metadata.why_now : undefined),\n risk: (document) => (isNonEmptyString(document.metadata.risk) ? document.metadata.risk : undefined),\n confidence: (document) =>\n document.metadata.confidence !== undefined && document.metadata.confidence !== null\n ? document.metadata.confidence\n : undefined,\n estimated_minutes: (document) =>\n typeof document.metadata.estimated_minutes === \"number\" ? document.metadata.estimated_minutes : undefined,\n acceptance_criteria: (document) =>\n isNonEmptyString(document.metadata.acceptance_criteria) ? document.metadata.acceptance_criteria : undefined,\n resolution: (document) =>\n isNonEmptyString(document.metadata.resolution) ? document.metadata.resolution : undefined,\n expected_result: (document) =>\n isNonEmptyString(document.metadata.expected_result) ? document.metadata.expected_result : undefined,\n actual_result: (document) =>\n isNonEmptyString(document.metadata.actual_result) ? document.metadata.actual_result : undefined,\n body: (document) => document.body,\n comments: (document) => (document.metadata.comments ?? []).map((entry) => entry.text),\n notes: (document) => (document.metadata.notes ?? []).map((entry) => entry.text),\n learnings: (document) => (document.metadata.learnings ?? []).map((entry) => entry.text),\n reminders: (document) => buildReminderCorpus(document.metadata),\n events: (document) => buildEventCorpus(document.metadata),\n dependencies: (document) =>\n (document.metadata.dependencies ?? []).map((entry) => ({\n id: entry.id,\n kind: entry.kind,\n })),\n plan: (document) => buildPlanCorpus(document.metadata),\n};\n\n/**\n * Implements build search corpus for the public runtime surface of this module.\n */\nexport function buildSearchCorpus(document: ItemDocument, options: SearchCorpusOptions = {}): Record<string, unknown> {\n const fields = options.fields ?? DEFAULT_SEARCH_CORPUS_FIELDS;\n const corpus: Record<string, unknown> = {};\n for (const field of fields) {\n const builder = CORPUS_FIELD_BUILDERS[field];\n if (!builder) {\n continue;\n }\n const value = builder(document);\n if (value === undefined) {\n continue;\n }\n corpus[field] = value;\n }\n return corpus;\n}\n\n/**\n * Implements resolve semantic corpus input character limit for the public runtime surface of this module.\n */\nexport function resolveSemanticCorpusInputCharacterLimit(providerName: string | undefined): number {\n if (providerName?.trim().toLowerCase() === \"ollama\") {\n return OLLAMA_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS;\n }\n return DEFAULT_SEMANTIC_CORPUS_INPUT_MAX_CHARACTERS;\n}\n\n/**\n * Documents the semantic corpus character limit resolution payload exchanged by command, SDK, and package integrations.\n */\nexport interface SemanticCorpusCharacterLimitResolution {\n maxCharacters: number;\n warning: string | null;\n}\n\n/**\n * Implements resolve semantic corpus character limit for the public runtime surface of this module.\n */\nexport function resolveSemanticCorpusCharacterLimit(\n providerName: string | undefined,\n configuredMaxCharacters: unknown,\n): SemanticCorpusCharacterLimitResolution {\n const providerDefaultLimit = resolveSemanticCorpusInputCharacterLimit(providerName);\n const parsed = coercePositiveInteger(configuredMaxCharacters);\n if (parsed !== null) {\n return {\n maxCharacters: parsed,\n warning: null,\n };\n }\n return {\n maxCharacters: providerDefaultLimit,\n warning:\n configuredMaxCharacters === undefined || configuredMaxCharacters === null\n ? null\n : SEARCH_EMBEDDING_CORPUS_MAX_CHARACTERS_INVALID_WARNING,\n };\n}\n\n/**\n * Documents the semantic corpus input options payload exchanged by command, SDK, and package integrations.\n */\nexport interface SemanticCorpusInputOptions {\n providerName?: string;\n maxCharacters?: number;\n /**\n * Corpus field names to include. When omitted, the full default set is used\n * (see {@link DEFAULT_SEARCH_CORPUS_FIELDS}). Thread the resolved list from\n * {@link resolveSearchCorpusFields} so the embedded input honours\n * `search.corpus_fields`.\n */\n fields?: string[];\n}\n\n/**\n * Implements build semantic corpus input for the public runtime surface of this module.\n */\nexport function buildSemanticCorpusInput(document: ItemDocument, options: SemanticCorpusInputOptions = {}): string {\n const serialized = JSON.stringify(buildSearchCorpus(document, { fields: options.fields }));\n const maxCharacters = resolveSemanticCorpusCharacterLimit(options.providerName, options.maxCharacters)\n .maxCharacters;\n if (serialized.length <= maxCharacters) {\n return serialized;\n }\n if (maxCharacters <= SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length) {\n return SEMANTIC_CORPUS_TRUNCATION_SUFFIX.slice(0, maxCharacters);\n }\n const keepLength = Math.max(0, maxCharacters - SEMANTIC_CORPUS_TRUNCATION_SUFFIX.length);\n return `${serialized.slice(0, keepLength)}${SEMANTIC_CORPUS_TRUNCATION_SUFFIX}`;\n}\n"],"names":[],"mappings":";;AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAsB;IAC7D,OAAO;IACP,aAAa;IACb,MAAM;IACN,QAAQ;IACR,MAAM;IACN,UAAU;IACV,UAAU;IACV,QAAQ;IACR,MAAM;IACN,OAAO;IACP,SAAS;IACT,MAAM;IACN,YAAY;IACZ,mBAAmB;IACnB,qBAAqB;IACrB,YAAY;IACZ,iBAAiB;IACjB,eAAe;IACf,MAAM;IACN,UAAU;IACV,OAAO;IACP,WAAW;IACX,WAAW;IACX,QAAQ;IACR,cAAc;IACd,MAAM;CACE,CAAC;AAEX;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAgD;IACxF,MAAM,UAAU,GAAG,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,4BAA4B,CAAC,CAAC;IAC3C,CAAC;IACD,wEAAwE;IACxE,yEAAyE;IACzE,2EAA2E;IAC3E,0DAA0D;IAC1D,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,4BAA4B,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CACzB,IAAI,GAAG,CACL,UAAU;SACP,MAAM,CAAC,CAAC,KAAK,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,Q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AAa,GAAG,mCAAmC,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,CAAC,aAAa,CAAC;SACnG,aAAa,CAAC;IACjB,IAAI,UAAU,CAAC,MAAM,IAAI,aAAa,EAAE,CAAC;QACvC,OAAO,UAAU,CAAC;IACpB,CAAC;IACD,IAAI,aAAa,IAAI,iCAAiC,CAAC,MAAM,EAAE,CAAC;QAC9D,OAAO,iCAAiC,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,aAAa,GAAG,iCAAiC,CAAC,MAAM,CAAC,CAAC;IACzF,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,CAAC,GAAG,iCAAiC,EAAE,CAAC;AAClF,CAAC","debugId":"74066cb9-628c-51d0-b64e-ad12b95a0d1c"}
@@ -4,7 +4,7 @@
4
4
  * Powers search, embeddings, and semantic retrieval behavior for Semantic Defaults.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="08a4289f-80a8-570e-b3b9-ffcd1c6887cd")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e60fbb33-d9f9-5212-a26d-628e6e2e6fd9")}catch(e){}}();
8
8
  import { spawnSync } from "node:child_process";
9
9
  import { toNonEmptyString } from "../shared/primitives.js";
10
10
  const DISABLE_AUTO_DEFAULTS_ENV = "PM_DISABLE_OLLAMA_AUTO_DEFAULTS";
@@ -25,6 +25,17 @@ function isAutoDefaultsDisabled() {
25
25
  const normalized = raw.toLowerCase();
26
26
  return normalized === "1" || normalized === "true" || normalized === "yes";
27
27
  }
28
+ function hasConfiguredValue(values) {
29
+ return values.some((entry) => toOptionalNonEmptyString(entry) !== null);
30
+ }
31
+ function hasCompetingProvider(provider) {
32
+ const normalized = toOptionalNonEmptyString(provider);
33
+ return Boolean(normalized && normalized.toLowerCase() !== "ollama");
34
+ }
35
+ function hasCompetingVectorAdapter(adapter) {
36
+ const normalized = toOptionalNonEmptyString(adapter);
37
+ return Boolean(normalized && normalized.toLowerCase() !== "lancedb");
38
+ }
28
39
  /**
29
40
  * True only when the user has opted into a provider/store that COMPETES with the
30
41
  * Ollama + LanceDB auto-default stack: an explicit non-Ollama search provider, a
@@ -34,27 +45,23 @@ function isAutoDefaultsDisabled() {
34
45
  * semantic search and then hard-error `pm reindex`.
35
46
  */
36
47
  function hasCompetingSemanticConfiguration(settings) {
37
- const provider = toOptionalNonEmptyString(settings.search?.provider);
38
- if (provider && provider.toLowerCase() !== "ollama") {
48
+ if (hasCompetingProvider(settings.search?.provider)) {
39
49
  return true;
40
50
  }
41
- const adapter = toOptionalNonEmptyString(settings.vector_store?.adapter);
42
- if (adapter && adapter.toLowerCase() !== "lancedb") {
51
+ if (hasCompetingVectorAdapter(settings.vector_store?.adapter)) {
43
52
  return true;
44
53
  }
45
- const openaiConfigured = [
54
+ if (hasConfiguredValue([
46
55
  settings.providers?.openai?.base_url,
47
56
  settings.providers?.openai?.model,
48
57
  settings.providers?.openai?.api_key,
49
- ].some((entry) => toOptionalNonEmptyString(entry) !== null);
50
- if (openaiConfigured) {
58
+ ])) {
51
59
  return true;
52
60
  }
53
- const qdrantConfigured = [
61
+ return hasConfiguredValue([
54
62
  settings.vector_store?.qdrant?.url,
55
63
  settings.vector_store?.qdrant?.api_key,
56
- ].some((entry) => toOptionalNonEmptyString(entry) !== null);
57
- return qdrantConfigured;
64
+ ]);
58
65
  }
59
66
  function isOllamaInstalled() {
60
67
  const result = spawnSync("ollama", ["--version"], {
@@ -109,6 +116,45 @@ function resolveAutoOllamaModel(settings) {
109
116
  }
110
117
  return DEFAULT_OLLAMA_MODEL;
111
118
  }
119
+ function resolveSemanticDefaultNeeds(settings) {
120
+ return {
121
+ baseUrl: toOptionalNonEmptyString(settings.providers?.ollama?.base_url) === null,
122
+ model: toOptionalNonEmptyString(settings.providers?.ollama?.model) === null,
123
+ lancedbPath: toOptionalNonEmptyString(settings.vector_store?.lancedb?.path) === null,
124
+ embeddingModel: toOptionalNonEmptyString(settings.search?.embedding_model) === null,
125
+ };
126
+ }
127
+ function needsAnySemanticDefault(needs) {
128
+ return needs.baseUrl || needs.model || needs.lancedbPath || needs.embeddingModel;
129
+ }
130
+ function applyOllamaProviderDefaults(settings, needs, resolvedModel) {
131
+ if (!needs.baseUrl && !needs.model) {
132
+ return;
133
+ }
134
+ const providers = (settings.providers ??= {});
135
+ const ollama = (providers.ollama ??= {});
136
+ if (needs.baseUrl) {
137
+ ollama.base_url = DEFAULT_OLLAMA_BASE_URL;
138
+ }
139
+ if (needs.model) {
140
+ ollama.model = resolvedModel;
141
+ }
142
+ }
143
+ function applyVectorStoreDefaults(settings, needs) {
144
+ if (!needs.lancedbPath) {
145
+ return;
146
+ }
147
+ const vectorStore = (settings.vector_store ??= {});
148
+ const lancedb = (vectorStore.lancedb ??= {});
149
+ lancedb.path = DEFAULT_LANCEDB_PATH;
150
+ }
151
+ function applySearchEmbeddingDefaults(settings, needs, resolvedModel) {
152
+ if (!needs.embeddingModel) {
153
+ return;
154
+ }
155
+ const search = (settings.search ??= {});
156
+ search.embedding_model = resolvedModel;
157
+ }
112
158
  /**
113
159
  * Implements resolve settings with semantic runtime defaults for the public runtime surface of this module.
114
160
  */
@@ -123,11 +169,8 @@ export function resolveSettingsWithSemanticRuntimeDefaults(settings) {
123
169
  if (hasCompetingSemanticConfiguration(settings)) {
124
170
  return unchanged;
125
171
  }
126
- const needsBaseUrl = toOptionalNonEmptyString(settings.providers?.ollama?.base_url) === null;
127
- const needsModel = toOptionalNonEmptyString(settings.providers?.ollama?.model) === null;
128
- const needsLancedbPath = toOptionalNonEmptyString(settings.vector_store?.lancedb?.path) === null;
129
- const needsEmbeddingModel = toOptionalNonEmptyString(settings.search?.embedding_model) === null;
130
- if (!needsBaseUrl && !needsModel && !needsLancedbPath && !needsEmbeddingModel) {
172
+ const needs = resolveSemanticDefaultNeeds(settings);
173
+ if (!needsAnySemanticDefault(needs)) {
131
174
  // A fully-configured Ollama/LanceDB stack — nothing to fill, and no need to
132
175
  // probe for Ollama at all.
133
176
  return unchanged;
@@ -136,7 +179,7 @@ export function resolveSettingsWithSemanticRuntimeDefaults(settings) {
136
179
  // requires Ollama to be installed. When a model is already configured we mirror it
137
180
  // into the remaining leaves without forcing an Ollama probe; when it is missing we
138
181
  // require Ollama to actually be present rather than writing an unusable default.
139
- if (needsModel && !isOllamaInstalled()) {
182
+ if (needs.model && !isOllamaInstalled()) {
140
183
  return unchanged;
141
184
  }
142
185
  const nextSettings = structuredClone(settings);
@@ -145,29 +188,13 @@ export function resolveSettingsWithSemanticRuntimeDefaults(settings) {
145
188
  // exported and runs on the search hot path with caller-supplied settings, so a
146
189
  // partial object (e.g. providers/vector_store set but no `search` block) must
147
190
  // fill the missing leaf rather than throwing on an undefined parent.
148
- if (needsBaseUrl || needsModel) {
149
- const providers = (nextSettings.providers ??= {});
150
- const ollama = (providers.ollama ??= {});
151
- if (needsBaseUrl) {
152
- ollama.base_url = DEFAULT_OLLAMA_BASE_URL;
153
- }
154
- if (needsModel) {
155
- ollama.model = resolvedModel;
156
- }
157
- }
158
- if (needsLancedbPath) {
159
- const vectorStore = (nextSettings.vector_store ??= {});
160
- const lancedb = (vectorStore.lancedb ??= {});
161
- lancedb.path = DEFAULT_LANCEDB_PATH;
162
- }
163
- if (needsEmbeddingModel) {
164
- const search = (nextSettings.search ??= {});
165
- search.embedding_model = resolvedModel;
166
- }
191
+ applyOllamaProviderDefaults(nextSettings, needs, resolvedModel);
192
+ applyVectorStoreDefaults(nextSettings, needs);
193
+ applySearchEmbeddingDefaults(nextSettings, needs, resolvedModel);
167
194
  return {
168
195
  settings: nextSettings,
169
196
  auto_ollama_defaults_applied: true,
170
197
  };
171
198
  }
172
199
  //# sourceMappingURL=semantic-defaults.js.map
173
- //# debugId=08a4289f-80a8-570e-b3b9-ffcd1c6887cd
200
+ //# debugId=e60fbb33-d9f9-5212-a26d-628e6e2e6fd9
@@ -1 +1 @@
1
- {"version":3,"file":"semantic-defaults.js","sources":["core/search/semantic-defaults.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/semantic-defaults\n *\n * Powers search, embeddings, and semantic retrieval behavior for Semantic Defaults.\n */\nimport { spawnSync } from \"node:child_process\";\nimport type { PmSettings } from \"../../types/index.js\";\nimport { toNonEmptyString } from \"../shared/primitives.js\";\n\nconst DISABLE_AUTO_DEFAULTS_ENV = \"PM_DISABLE_OLLAMA_AUTO_DEFAULTS\";\nconst OLLAMA_MODEL_ENV = \"PM_OLLAMA_MODEL\";\nconst DEFAULT_OLLAMA_BASE_URL = \"http://localhost:11434\";\nconst DEFAULT_OLLAMA_MODEL = \"qwen3-embedding:0.6b\";\nconst DEFAULT_LANCEDB_PATH = \".agents/pm/search/lancedb/\";\nconst OLLAMA_VERSION_TIMEOUT_MS = 1_500;\nconst OLLAMA_LIST_TIMEOUT_MS = 2_500;\nconst QWEN_EMBEDDING_MODEL_PATTERN = /qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i;\nconst EMBEDDING_MODEL_PATTERN = /embed|embedding/i;\n\n/**\n * Documents the semantic runtime defaults resolution payload exchanged by command, SDK, and package integrations.\n */\nexport interface SemanticRuntimeDefaultsResolution {\n settings: PmSettings;\n auto_ollama_defaults_applied: boolean;\n}\n\nconst toOptionalNonEmptyString = toNonEmptyString;\n\nfunction isAutoDefaultsDisabled(): boolean {\n const raw = toOptionalNonEmptyString(process.env[DISABLE_AUTO_DEFAULTS_ENV]);\n if (!raw) {\n return false;\n }\n const normalized = raw.toLowerCase();\n return normalized === \"1\" || normalized === \"true\" || normalized === \"yes\";\n}\n\n/**\n * True only when the user has opted into a provider/store that COMPETES with the\n * Ollama + LanceDB auto-default stack: an explicit non-Ollama search provider, a\n * non-LanceDB vector adapter, or any OpenAI/Qdrant credentials. A partial Ollama\n * setup (e.g. only `ollama.base_url`) is NOT competing — its missing leaves are\n * filled per-field below so a single config write can never silently disable\n * semantic search and then hard-error `pm reindex`.\n */\nfunction hasCompetingSemanticConfiguration(settings: PmSettings): boolean {\n const provider = toOptionalNonEmptyString(settings.search?.provider);\n if (provider && provider.toLowerCase() !== \"ollama\") {\n return true;\n }\n const adapter = toOptionalNonEmptyString(settings.vector_store?.adapter);\n if (adapter && adapter.toLowerCase() !== \"lancedb\") {\n return true;\n }\n const openaiConfigured = [\n settings.providers?.openai?.base_url,\n settings.providers?.openai?.model,\n settings.providers?.openai?.api_key,\n ].some((entry) => toOptionalNonEmptyString(entry) !== null);\n if (openaiConfigured) {\n return true;\n }\n const qdrantConfigured = [\n settings.vector_store?.qdrant?.url,\n settings.vector_store?.qdrant?.api_key,\n ].some((entry) => toOptionalNonEmptyString(entry) !== null);\n return qdrantConfigured;\n}\n\nfunction isOllamaInstalled(): boolean {\n const result = spawnSync(\"ollama\", [\"--version\"], {\n encoding: \"utf8\",\n timeout: OLLAMA_VERSION_TIMEOUT_MS,\n });\n if (result.error) {\n return false;\n }\n return result.status === 0;\n}\n\nfunction parseOllamaModelList(output: string): string | null {\n const lines = output\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n if (lines.length === 0) {\n return null;\n }\n const models = lines\n .map((line) => line.split(/\\s+/)[0]?.trim())\n .filter((entry): entry is string => Boolean(entry && entry.length > 0))\n .filter((entry) => entry.toUpperCase() !== \"NAME\");\n if (models.length === 0) {\n return null;\n }\n const preferredQwenEmbeddingModel = models.find((entry) => QWEN_EMBEDDING_MODEL_PATTERN.test(entry));\n if (preferredQwenEmbeddingModel) {\n return preferredQwenEmbeddingModel;\n }\n const embeddingModel = models.find((entry) => EMBEDDING_MODEL_PATTERN.test(entry));\n return embeddingModel ?? null;\n}\n\nfunction resolveAutoOllamaModel(settings: PmSettings): string {\n const settingsModel = toOptionalNonEmptyString(settings.providers?.ollama?.model);\n if (settingsModel) {\n return settingsModel;\n }\n const envModel = toOptionalNonEmptyString(process.env[OLLAMA_MODEL_ENV]);\n if (envModel) {\n return envModel;\n }\n const listed = spawnSync(\"ollama\", [\"list\"], {\n encoding: \"utf8\",\n timeout: OLLAMA_LIST_TIMEOUT_MS,\n });\n if (!listed.error && listed.status === 0) {\n const listedModel = parseOllamaModelList(typeof listed.stdout === \"string\" ? listed.stdout : \"\");\n if (listedModel) {\n return listedModel;\n }\n }\n return DEFAULT_OLLAMA_MODEL;\n}\n\n/**\n * Implements resolve settings with semantic runtime defaults for the public runtime surface of this module.\n */\nexport function resolveSettingsWithSemanticRuntimeDefaults(settings: PmSettings): SemanticRuntimeDefaultsResolution {\n const unchanged: SemanticRuntimeDefaultsResolution = {\n settings,\n auto_ollama_defaults_applied: false,\n };\n if (isAutoDefaultsDisabled()) {\n return unchanged;\n }\n if (hasCompetingSemanticConfiguration(settings)) {\n return unchanged;\n }\n\n const needsBaseUrl = toOptionalNonEmptyString(settings.providers?.ollama?.base_url) === null;\n const needsModel = toOptionalNonEmptyString(settings.providers?.ollama?.model) === null;\n const needsLancedbPath = toOptionalNonEmptyString(settings.vector_store?.lancedb?.path) === null;\n const needsEmbeddingModel = toOptionalNonEmptyString(settings.search?.embedding_model) === null;\n if (!needsBaseUrl && !needsModel && !needsLancedbPath && !needsEmbeddingModel) {\n // A fully-configured Ollama/LanceDB stack — nothing to fill, and no need to\n // probe for Ollama at all.\n return unchanged;\n }\n\n // Auto-discovering the embedding model (via `ollama list`) is the only step that\n // requires Ollama to be installed. When a model is already configured we mirror it\n // into the remaining leaves without forcing an Ollama probe; when it is missing we\n // require Ollama to actually be present rather than writing an unusable default.\n if (needsModel && !isOllamaInstalled()) {\n return unchanged;\n }\n\n const nextSettings = structuredClone(settings);\n const resolvedModel = resolveAutoOllamaModel(nextSettings);\n // `readSettings` always normalizes these nested objects, but this function is\n // exported and runs on the search hot path with caller-supplied settings, so a\n // partial object (e.g. providers/vector_store set but no `search` block) must\n // fill the missing leaf rather than throwing on an undefined parent.\n if (needsBaseUrl || needsModel) {\n const providers = (nextSettings.providers ??= {} as PmSettings[\"providers\"]);\n const ollama = (providers.ollama ??= {} as PmSettings[\"providers\"][\"ollama\"]);\n if (needsBaseUrl) {\n ollama.base_url = DEFAULT_OLLAMA_BASE_URL;\n }\n if (needsModel) {\n ollama.model = resolvedModel;\n }\n }\n if (needsLancedbPath) {\n const vectorStore = (nextSettings.vector_store ??= {} as PmSettings[\"vector_store\"]);\n const lancedb = (vectorStore.lancedb ??= {} as PmSettings[\"vector_store\"][\"lancedb\"]);\n lancedb.path = DEFAULT_LANCEDB_PATH;\n }\n if (needsEmbeddingModel) {\n const search = (nextSettings.search ??= {} as PmSettings[\"search\"]);\n search.embedding_model = resolvedModel;\n }\n return {\n settings: nextSettings,\n auto_ollama_defaults_applied: true,\n };\n}\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AACpE,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AACpD,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAC1D,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,4BAA4B,GAAG,sDAAsD,CAAC;AAC5F,MAAM,uBAAuB,GAAG,kBAAkB,CAAC;AAUnD,MAAM,wBAAwB,GA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YAAY,IAAI,UAAU,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,CAAC,YAAY,CAAC,SAAS,KAAK,EAA6B,CAAC,CAAC;QAC7E,MAAM,MAAM,GAAG,CAAC,SAAS,CAAC,MAAM,KAAK,EAAuC,CAAC,CAAC;QAC9E,IAAI,YAAY,EAAE,CAAC;YACjB,MAAM,CAAC,QAAQ,GAAG,uBAAuB,CAAC;QAC5C,CAAC;QACD,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,GAAG,aAAa,CAAC;QAC/B,CAAC;IACH,CAAC;IACD,IAAI,gBAAgB,EAAE,CAAC;QACrB,MAAM,WAAW,GAAG,CAAC,YAAY,CAAC,YAAY,KAAK,EAAgC,CAAC,CAAC;QACrF,MAAM,OAAO,GAAG,CAAC,WAAW,CAAC,OAAO,KAAK,EAA2C,CAAC,CAAC;QACtF,OAAO,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACtC,CAAC;IACD,IAAI,mBAAmB,EAAE,CAAC;QACxB,MAAM,MAAM,GAAG,CAAC,YAAY,CAAC,MAAM,KAAK,EAA0B,CAAC,CAAC;QACpE,MAAM,CAAC,eAAe,GAAG,aAAa,CAAC;IACzC,CAAC;IACD,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,4BAA4B,EAAE,IAAI;KACnC,CAAC;AACJ,CAAC","debugId":"08a4289f-80a8-570e-b3b9-ffcd1c6887cd"}
1
+ {"version":3,"file":"semantic-defaults.js","sources":["core/search/semantic-defaults.ts"],"sourceRoot":"/","sourcesContent":["/**\n * @module core/search/semantic-defaults\n *\n * Powers search, embeddings, and semantic retrieval behavior for Semantic Defaults.\n */\nimport { spawnSync } from \"node:child_process\";\nimport type { PmSettings } from \"../../types/index.js\";\nimport { toNonEmptyString } from \"../shared/primitives.js\";\n\nconst DISABLE_AUTO_DEFAULTS_ENV = \"PM_DISABLE_OLLAMA_AUTO_DEFAULTS\";\nconst OLLAMA_MODEL_ENV = \"PM_OLLAMA_MODEL\";\nconst DEFAULT_OLLAMA_BASE_URL = \"http://localhost:11434\";\nconst DEFAULT_OLLAMA_MODEL = \"qwen3-embedding:0.6b\";\nconst DEFAULT_LANCEDB_PATH = \".agents/pm/search/lancedb/\";\nconst OLLAMA_VERSION_TIMEOUT_MS = 1_500;\nconst OLLAMA_LIST_TIMEOUT_MS = 2_500;\nconst QWEN_EMBEDDING_MODEL_PATTERN = /qwen.*(?:embed|embedding)|(?:embed|embedding).*qwen/i;\nconst EMBEDDING_MODEL_PATTERN = /embed|embedding/i;\n\n/**\n * Documents the semantic runtime defaults resolution payload exchanged by command, SDK, and package integrations.\n */\nexport interface SemanticRuntimeDefaultsResolution {\n settings: PmSettings;\n auto_ollama_defaults_applied: boolean;\n}\n\nconst toOptionalNonEmptyString = toNonEmptyString;\n\nfunction isAutoDefaultsDisabled(): boolean {\n const raw = toOptionalNonEmptyString(process.env[DISABLE_AUTO_DEFAULTS_ENV]);\n if (!raw) {\n return false;\n }\n const normalized = raw.toLowerCase();\n return normalized === \"1\" || normalized === \"true\" || normalized === \"yes\";\n}\n\nfunction hasConfiguredValue(values: readonly unknown[]): boolean {\n return values.some((entry) => toOptionalNonEmptyString(entry) !== null);\n}\n\nfunction hasCompetingProvider(provider: unknown): boolean {\n const normalized = toOptionalNonEmptyString(provider);\n return Boolean(normalized && normalized.toLowerCase() !== \"ollama\");\n}\n\nfunction hasCompetingVectorAdapter(adapter: unknown): boolean {\n const normalized = toOptionalNonEmptyString(adapter);\n return Boolean(normalized && normalized.toLowerCase() !== \"lancedb\");\n}\n\n/**\n * True only when the user has opted into a provider/store that COMPETES with the\n * Ollama + LanceDB auto-default stack: an explicit non-Ollama search provider, a\n * non-LanceDB vector adapter, or any OpenAI/Qdrant credentials. A partial Ollama\n * setup (e.g. only `ollama.base_url`) is NOT competing — its missing leaves are\n * filled per-field below so a single config write can never silently disable\n * semantic search and then hard-error `pm reindex`.\n */\nfunction hasCompetingSemanticConfiguration(settings: PmSettings): boolean {\n if (hasCompetingProvider(settings.search?.provider)) {\n return true;\n }\n if (hasCompetingVectorAdapter(settings.vector_store?.adapter)) {\n return true;\n }\n if (hasConfiguredValue([\n settings.providers?.openai?.base_url,\n settings.providers?.openai?.model,\n settings.providers?.openai?.api_key,\n ])) {\n return true;\n }\n return hasConfiguredValue([\n settings.vector_store?.qdrant?.url,\n settings.vector_store?.qdrant?.api_key,\n ]);\n}\n\nfunction isOllamaInstalled(): boolean {\n const result = spawnSync(\"ollama\", [\"--version\"], {\n encoding: \"utf8\",\n timeout: OLLAMA_VERSION_TIMEOUT_MS,\n });\n if (result.error) {\n return false;\n }\n return result.status === 0;\n}\n\nfunction parseOllamaModelList(output: string): string | null {\n const lines = output\n .split(/\\r?\\n/)\n .map((line) => line.trim())\n .filter((line) => line.length > 0);\n if (lines.length === 0) {\n return null;\n }\n const models = lines\n .map((line) => line.split(/\\s+/)[0]?.trim())\n .filter((entry): entry is string => Boolean(entry && entry.length > 0))\n .filter((entry) => entry.toUpperCase() !== \"NAME\");\n if (models.length === 0) {\n return null;\n }\n const preferredQwenEmbeddingModel = models.find((entry) => QWEN_EMBEDDING_MODEL_PATTERN.test(entry));\n if (preferredQwenEmbeddingModel) {\n return preferredQwenEmbeddingModel;\n }\n const embeddingModel = models.find((entry) => EMBEDDING_MODEL_PATTERN.test(entry));\n return embeddingModel ?? null;\n}\n\nfunction resolveAutoOllamaModel(settings: PmSettings): string {\n const settingsModel = toOptionalNonEmptyString(settings.providers?.ollama?.model);\n if (settingsModel) {\n return settingsModel;\n }\n const envModel = toOptionalNonEmptyString(process.env[OLLAMA_MODEL_ENV]);\n if (envModel) {\n return envModel;\n }\n const listed = spawnSync(\"ollama\", [\"list\"], {\n encoding: \"utf8\",\n timeout: OLLAMA_LIST_TIMEOUT_MS,\n });\n if (!listed.error && listed.status === 0) {\n const listedModel = parseOllamaModelList(typeof listed.stdout === \"string\" ? listed.stdout : \"\");\n if (listedModel) {\n return listedModel;\n }\n }\n return DEFAULT_OLLAMA_MODEL;\n}\n\ninterface SemanticDefaultNeeds {\n baseUrl: boolean;\n model: boolean;\n lancedbPath: boolean;\n embeddingModel: boolean;\n}\n\nfunction resolveSemanticDefaultNeeds(settings: PmSettings): SemanticDefaultNeeds {\n return {\n baseUrl: toOptionalNonEmptyString(settings.providers?.ollama?.base_url) === null,\n model: toOptionalNonEmptyString(settings.providers?.ollama?.model) === null,\n lancedbPath: toOptionalNonEmptyString(settings.vector_store?.lancedb?.path) === null,\n embeddingModel: toOptionalNonEmptyString(settings.search?.embedding_model) === null,\n };\n}\n\nfunction needsAnySemanticDefault(needs: SemanticDefaultNeeds): boolean {\n return needs.baseUrl || needs.model || needs.lancedbPath || needs.embeddingModel;\n}\n\nfunction applyOllamaProviderDefaults(settings: PmSettings, needs: SemanticDefaultNeeds, resolvedModel: string): void {\n if (!needs.baseUrl && !needs.model) {\n return;\n }\n const providers = (settings.providers ??= {} as PmSettings[\"providers\"]);\n const ollama = (providers.ollama ??= {} as PmSettings[\"providers\"][\"ollama\"]);\n if (needs.baseUrl) {\n ollama.base_url = DEFAULT_OLLAMA_BASE_URL;\n }\n if (needs.model) {\n ollama.model = resolvedModel;\n }\n}\n\nfunction applyVectorStoreDefaults(settings: PmSettings, needs: SemanticDefaultNeeds): void {\n if (!needs.lancedbPath) {\n return;\n }\n const vectorStore = (settings.vector_store ??= {} as PmSettings[\"vector_store\"]);\n const lancedb = (vectorStore.lancedb ??= {} as PmSettings[\"vector_store\"][\"lancedb\"]);\n lancedb.path = DEFAULT_LANCEDB_PATH;\n}\n\nfunction applySearchEmbeddingDefaults(settings: PmSettings, needs: SemanticDefaultNeeds, resolvedModel: string): void {\n if (!needs.embeddingModel) {\n return;\n }\n const search = (settings.search ??= {} as PmSettings[\"search\"]);\n search.embedding_model = resolvedModel;\n}\n\n/**\n * Implements resolve settings with semantic runtime defaults for the public runtime surface of this module.\n */\nexport function resolveSettingsWithSemanticRuntimeDefaults(settings: PmSettings): SemanticRuntimeDefaultsResolution {\n const unchanged: SemanticRuntimeDefaultsResolution = {\n settings,\n auto_ollama_defaults_applied: false,\n };\n if (isAutoDefaultsDisabled()) {\n return unchanged;\n }\n if (hasCompetingSemanticConfiguration(settings)) {\n return unchanged;\n }\n\n const needs = resolveSemanticDefaultNeeds(settings);\n if (!needsAnySemanticDefault(needs)) {\n // A fully-configured Ollama/LanceDB stack — nothing to fill, and no need to\n // probe for Ollama at all.\n return unchanged;\n }\n\n // Auto-discovering the embedding model (via `ollama list`) is the only step that\n // requires Ollama to be installed. When a model is already configured we mirror it\n // into the remaining leaves without forcing an Ollama probe; when it is missing we\n // require Ollama to actually be present rather than writing an unusable default.\n if (needs.model && !isOllamaInstalled()) {\n return unchanged;\n }\n\n const nextSettings = structuredClone(settings);\n const resolvedModel = resolveAutoOllamaModel(nextSettings);\n // `readSettings` always normalizes these nested objects, but this function is\n // exported and runs on the search hot path with caller-supplied settings, so a\n // partial object (e.g. providers/vector_store set but no `search` block) must\n // fill the missing leaf rather than throwing on an undefined parent.\n applyOllamaProviderDefaults(nextSettings, needs, resolvedModel);\n applyVectorStoreDefaults(nextSettings, needs);\n applySearchEmbeddingDefaults(nextSettings, needs, resolvedModel);\n return {\n settings: nextSettings,\n auto_ollama_defaults_applied: true,\n };\n}\n"],"names":[],"mappings":"AAAA;;;;GAIG;;;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AACpE,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAC3C,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AACzD,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AACpD,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAC1D,MAAM,yBAAyB,GAAG,KAAK,CAAC;AACxC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AACrC,MAAM,4BAA4B,GAAG,sDAAsD,C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KAAK,CAAC,KAAK,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,YAAY,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,aAAa,GAAG,sBAAsB,CAAC,YAAY,CAAC,CAAC;IAC3D,8EAA8E;IAC9E,+EAA+E;IAC/E,8EAA8E;IAC9E,qEAAqE;IACrE,2BAA2B,CAAC,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IAChE,wBAAwB,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;IAC9C,4BAA4B,CAAC,YAAY,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;IACjE,OAAO;QACL,QAAQ,EAAE,YAAY;QACtB,4BAA4B,EAAE,IAAI;KACnC,CAAC;AACJ,CAAC","debugId":"e60fbb33-d9f9-5212-a26d-628e6e2e6fd9"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e3c28b84-e4b3-5274-b132-79ae7bce8876")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e5399bf5-c400-5819-8095-d0f1616785ec")}catch(e){}}();
3
3
  import { mkdir, readFile, stat, unlink } from "node:fs/promises";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  import { executeSearchJsonRequest, normalizeSearchHttpTimeoutMs, resolveSearchHttpFetcher, } from "./http-client.js";
@@ -223,32 +223,47 @@ function parseLanceDbSnapshot(snapshotPath, expectedTable, raw) {
223
223
  }
224
224
  return tableRecords;
225
225
  }
226
- async function loadLanceDbLocalTable(storePath, table) {
227
- const key = getLanceDbLocalTableKey(storePath, table);
228
- const snapshotPath = getLanceDbSnapshotPath(storePath, table);
229
- let snapshotStats = null;
226
+ async function readLanceDbSnapshotStats(snapshotPath) {
230
227
  try {
231
228
  const stats = await stat(snapshotPath);
232
- snapshotStats = { mtimeMs: stats.mtimeMs, size: stats.size };
229
+ return { mtimeMs: stats.mtimeMs, size: stats.size };
233
230
  }
234
231
  catch (error) {
235
232
  if (!isNodeErrorWithCode(error, "ENOENT")) {
236
233
  throw error;
237
234
  }
235
+ return null;
236
+ }
237
+ }
238
+ function resolveMissingLanceDbSnapshotCache(key, cached) {
239
+ if (!cached) {
240
+ return null;
241
+ }
242
+ if (cached.mtimeMs === null && cached.size === null && cached.records.size === 0) {
243
+ return cached.records;
238
244
  }
245
+ const loaded = new Map();
246
+ lanceDbLocalTables.set(key, { records: loaded, mtimeMs: null, size: null });
247
+ return loaded;
248
+ }
249
+ function cachedLanceDbSnapshotMatches(cached, snapshotStats) {
250
+ return (cached !== undefined &&
251
+ snapshotStats !== null &&
252
+ cached.mtimeMs === snapshotStats.mtimeMs &&
253
+ cached.size === snapshotStats.size);
254
+ }
255
+ async function loadLanceDbLocalTable(storePath, table) {
256
+ const key = getLanceDbLocalTableKey(storePath, table);
257
+ const snapshotPath = getLanceDbSnapshotPath(storePath, table);
258
+ const snapshotStats = await readLanceDbSnapshotStats(snapshotPath);
239
259
  const cached = lanceDbLocalTables.get(key);
240
- if (cached && !snapshotStats) {
241
- if (cached.mtimeMs === null && cached.size === null && cached.records.size === 0) {
242
- return cached.records;
260
+ if (!snapshotStats) {
261
+ const resolved = resolveMissingLanceDbSnapshotCache(key, cached);
262
+ if (resolved) {
263
+ return resolved;
243
264
  }
244
- const loaded = new Map();
245
- lanceDbLocalTables.set(key, { records: loaded, mtimeMs: null, size: null });
246
- return loaded;
247
265
  }
248
- if (cached &&
249
- snapshotStats &&
250
- cached.mtimeMs === snapshotStats.mtimeMs &&
251
- cached.size === snapshotStats.size) {
266
+ if (cachedLanceDbSnapshotMatches(cached, snapshotStats)) {
252
267
  return cached.records;
253
268
  }
254
269
  let loaded = new Map();
@@ -633,4 +648,4 @@ export async function executeVectorReset(store, knownIds = [], options = {}, vec
633
648
  return await executeVectorDelete(store, idsToDelete, options);
634
649
  }
635
650
  //# sourceMappingURL=vector-stores.js.map
636
- //# debugId=e3c28b84-e4b3-5274-b132-79ae7bce8876
651
+ //# debugId=e5399bf5-c400-5819-8095-d0f1616785ec