@unbrained/pm-cli 2026.7.16 → 2026.7.18

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 (620) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +30 -2
  3. package/CONTRIBUTING.md +2 -2
  4. package/dist/cli/bootstrap-args.d.ts +2 -115
  5. package/dist/cli/bootstrap-args.js +4 -831
  6. package/dist/cli/bootstrap-args.js.map +1 -1
  7. package/dist/cli/commands/close.d.ts +1 -1
  8. package/dist/cli/commands/close.js +3 -3
  9. package/dist/cli/commands/close.js.map +1 -1
  10. package/dist/cli/commands/completion.js +47 -5
  11. package/dist/cli/commands/completion.js.map +1 -1
  12. package/dist/cli/commands/context.d.ts +2 -2
  13. package/dist/cli/commands/context.js +42 -28
  14. package/dist/cli/commands/context.js.map +1 -1
  15. package/dist/cli/commands/contracts.js +5 -3
  16. package/dist/cli/commands/contracts.js.map +1 -1
  17. package/dist/cli/commands/eval.d.ts +4 -64
  18. package/dist/cli/commands/eval.js +4 -153
  19. package/dist/cli/commands/eval.js.map +1 -1
  20. package/dist/cli/commands/graph.d.ts +7 -0
  21. package/dist/cli/commands/graph.js +11 -0
  22. package/dist/cli/commands/graph.js.map +1 -0
  23. package/dist/cli/commands/index.d.ts +1 -0
  24. package/dist/cli/commands/index.js +3 -2
  25. package/dist/cli/commands/index.js.map +1 -1
  26. package/dist/cli/commands/linked-test-entry.d.ts +6 -6
  27. package/dist/cli/commands/linked-test-entry.js +4 -65
  28. package/dist/cli/commands/linked-test-entry.js.map +1 -1
  29. package/dist/cli/commands/linked-test-parsers.d.ts +3 -45
  30. package/dist/cli/commands/linked-test-parsers.js +4 -516
  31. package/dist/cli/commands/linked-test-parsers.js.map +1 -1
  32. package/dist/cli/commands/list.d.ts +3 -210
  33. package/dist/cli/commands/list.js +4 -1068
  34. package/dist/cli/commands/list.js.map +1 -1
  35. package/dist/cli/commands/next.d.ts +1 -1
  36. package/dist/cli/commands/next.js +3 -3
  37. package/dist/cli/commands/next.js.map +1 -1
  38. package/dist/cli/commands/search.d.ts +3 -464
  39. package/dist/cli/commands/search.js +4 -2236
  40. package/dist/cli/commands/search.js.map +1 -1
  41. package/dist/cli/commands/stats.d.ts +6 -66
  42. package/dist/cli/commands/stats.js +4 -157
  43. package/dist/cli/commands/stats.js.map +1 -1
  44. package/dist/cli/commands/telemetry.d.ts +6 -14
  45. package/dist/cli/commands/telemetry.js +4 -349
  46. package/dist/cli/commands/telemetry.js.map +1 -1
  47. package/dist/cli/commands/test-all.d.ts +6 -95
  48. package/dist/cli/commands/test-all.js +4 -439
  49. package/dist/cli/commands/test-all.js.map +1 -1
  50. package/dist/cli/commands/test-runs.d.ts +6 -92
  51. package/dist/cli/commands/test-runs.js +4 -189
  52. package/dist/cli/commands/test-runs.js.map +1 -1
  53. package/dist/cli/commands/test.d.ts +6 -244
  54. package/dist/cli/commands/test.js +4 -1780
  55. package/dist/cli/commands/test.js.map +1 -1
  56. package/dist/cli/commands/update-many.d.ts +15 -29
  57. package/dist/cli/commands/update-many.js +355 -259
  58. package/dist/cli/commands/update-many.js.map +1 -1
  59. package/dist/cli/main.js +141 -133
  60. package/dist/cli/main.js.map +1 -1
  61. package/dist/cli/register-list-query.js +49 -7
  62. package/dist/cli/register-list-query.js.map +1 -1
  63. package/dist/cli/register-mutation.js +7 -3
  64. package/dist/cli/register-mutation.js.map +1 -1
  65. package/dist/cli/search-refresh.js +4 -9
  66. package/dist/cli/search-refresh.js.map +1 -1
  67. package/dist/cli/shared-parsers.d.ts +6 -9
  68. package/dist/cli/shared-parsers.js +4 -37
  69. package/dist/cli/shared-parsers.js.map +1 -1
  70. package/dist/cli/telemetry-flush.js +4 -4
  71. package/dist/cli/telemetry-flush.js.map +1 -1
  72. package/dist/cli-bundle/bundle-manifest.json +334 -326
  73. package/dist/cli-bundle/chunks/{append-OJQFUQ4T.js → append-5YF3TO7I.js} +5 -5
  74. package/dist/cli-bundle/chunks/append-JHO5K6RP.js +11 -0
  75. package/dist/cli-bundle/chunks/{chunk-BCOFWYW4.js → chunk-2BX74BAS.js} +3 -3
  76. package/dist/cli-bundle/chunks/{chunk-APRVSW2O.js → chunk-2CXL335K.js} +3 -3
  77. package/dist/cli-bundle/chunks/{chunk-KG44YSKD.js → chunk-2FUOXSRN.js} +4 -4
  78. package/dist/cli-bundle/chunks/{chunk-HDH3JUGG.js → chunk-2IPNL3DR.js} +3 -3
  79. package/dist/cli-bundle/chunks/{chunk-GM5QHQU6.js → chunk-2XOSFSTH.js} +5 -5
  80. package/dist/cli-bundle/chunks/{chunk-UFXU44HV.js → chunk-35FHWD4C.js} +6 -6
  81. package/dist/cli-bundle/chunks/{chunk-2WSE6PO2.js.map → chunk-35FHWD4C.js.map} +1 -7
  82. package/dist/cli-bundle/chunks/{chunk-K3WII2ME.js → chunk-37DRDP2B.js} +5 -5
  83. package/dist/cli-bundle/chunks/{chunk-BKVG6XOA.js → chunk-3CUQZNQ6.js} +67 -509
  84. package/dist/cli-bundle/chunks/chunk-3CUQZNQ6.js.map +7 -0
  85. package/dist/cli-bundle/chunks/chunk-3QDR6ZLU.js +800 -0
  86. package/dist/cli-bundle/chunks/chunk-3QDR6ZLU.js.map +7 -0
  87. package/dist/cli-bundle/chunks/{chunk-5JLUII3O.js → chunk-43UMFKCK.js} +321 -240
  88. package/dist/cli-bundle/chunks/chunk-43UMFKCK.js.map +1 -0
  89. package/dist/cli-bundle/chunks/{chunk-PMOSXADO.js → chunk-47HXN6RX.js} +3 -3
  90. package/dist/cli-bundle/chunks/{chunk-6CFNAVTF.js → chunk-5HGZKQUL.js} +4 -4
  91. package/dist/cli-bundle/chunks/{chunk-2IFFUZLC.js → chunk-5UKQLQM2.js} +2 -2
  92. package/dist/cli-bundle/chunks/{chunk-DM4H7FP4.js → chunk-633PKXLT.js} +3 -3
  93. package/dist/cli-bundle/chunks/{chunk-XSJUSQAE.js → chunk-646MQXFW.js} +2 -2
  94. package/dist/cli-bundle/chunks/{chunk-ZI6VQWQ7.js → chunk-66MKH7SZ.js} +4 -4
  95. package/dist/cli-bundle/chunks/{chunk-S6MQESFR.js → chunk-67RO3H4N.js} +4 -4
  96. package/dist/cli-bundle/chunks/{chunk-34L5OT3Y.js → chunk-6DYOZS6C.js} +2 -2
  97. package/dist/cli-bundle/chunks/{chunk-RRM5JYJC.js → chunk-6O44IN44.js} +2 -2
  98. package/dist/cli-bundle/chunks/{chunk-5ZSLZLDN.js → chunk-6VHUGVNP.js} +608 -456
  99. package/dist/cli-bundle/chunks/chunk-6VHUGVNP.js.map +1 -0
  100. package/dist/cli-bundle/chunks/{chunk-PENXZX3U.js → chunk-74FKFFXO.js} +2 -2
  101. package/dist/cli-bundle/chunks/{chunk-HO4KXD6I.js → chunk-7H5NNCJ5.js} +4 -4
  102. package/dist/cli-bundle/chunks/{chunk-7B67ZL4N.js → chunk-7R6UIHYY.js} +75 -5
  103. package/dist/cli-bundle/chunks/{chunk-7B67ZL4N.js.map → chunk-7R6UIHYY.js.map} +1 -1
  104. package/dist/cli-bundle/chunks/{chunk-3S5QVM5H.js → chunk-7UCY6DR5.js} +193 -22
  105. package/dist/cli-bundle/chunks/chunk-7UCY6DR5.js.map +1 -0
  106. package/dist/cli-bundle/chunks/{chunk-WT3ZEOGH.js → chunk-ADXDCAKP.js} +16 -7
  107. package/dist/cli-bundle/chunks/{chunk-WT3ZEOGH.js.map → chunk-ADXDCAKP.js.map} +1 -1
  108. package/dist/cli-bundle/chunks/{chunk-TQSZFPIS.js → chunk-AFGKSHAM.js} +4 -4
  109. package/dist/cli-bundle/chunks/{chunk-6N2VXVTQ.js → chunk-ARGDWQ4J.js} +2 -2
  110. package/dist/cli-bundle/chunks/{chunk-XXXF6PAQ.js → chunk-AXRT7K5V.js} +83 -62
  111. package/dist/cli-bundle/chunks/chunk-AXRT7K5V.js.map +7 -0
  112. package/dist/cli-bundle/chunks/{chunk-3U7ZR6M4.js → chunk-B57RJHBZ.js} +4 -4
  113. package/dist/cli-bundle/chunks/{chunk-YCQET3OT.js → chunk-BAP7G3N2.js} +2 -2
  114. package/dist/cli-bundle/chunks/{chunk-NLDFBC6J.js → chunk-BDA35QG5.js} +35 -5
  115. package/dist/cli-bundle/chunks/chunk-BDA35QG5.js.map +7 -0
  116. package/dist/cli-bundle/chunks/{chunk-QKXHFPYM.js → chunk-BIRYX32V.js} +3 -3
  117. package/dist/cli-bundle/chunks/{chunk-RMLWNPH2.js → chunk-BVLOMU6O.js} +2 -2
  118. package/dist/cli-bundle/chunks/{chunk-2VPAVL7O.js → chunk-CKX4WOPC.js} +2 -2
  119. package/dist/cli-bundle/chunks/{chunk-TKOVBP6C.js → chunk-D52ZN3BF.js} +2 -2
  120. package/dist/cli-bundle/chunks/{chunk-KPMKHGEA.js → chunk-D53RTYVI.js} +4 -4
  121. package/dist/cli-bundle/chunks/{chunk-ODALILG3.js → chunk-D5XHO4Q7.js} +2 -2
  122. package/dist/cli-bundle/chunks/{chunk-YAQEBNY7.js → chunk-DDFGYUCQ.js} +4 -4
  123. package/dist/cli-bundle/chunks/{chunk-EAB64KLB.js → chunk-DG2EQRIH.js} +4 -4
  124. package/dist/cli-bundle/chunks/{chunk-J6364LFM.js → chunk-DHNG452T.js} +9 -18
  125. package/dist/cli-bundle/chunks/{chunk-J6364LFM.js.map → chunk-DHNG452T.js.map} +1 -1
  126. package/dist/cli-bundle/chunks/{chunk-JXQUXVMI.js → chunk-E4FXM2XB.js} +77 -7
  127. package/dist/cli-bundle/chunks/{chunk-JXQUXVMI.js.map → chunk-E4FXM2XB.js.map} +1 -1
  128. package/dist/cli-bundle/chunks/{chunk-IG3SWA4A.js → chunk-EHJFUOXL.js} +3 -3
  129. package/dist/cli-bundle/chunks/{chunk-P74IZQ7A.js → chunk-EWIT5WIC.js} +7 -7
  130. package/dist/cli-bundle/chunks/chunk-EX7OQT3Y.js +783 -0
  131. package/dist/cli-bundle/chunks/chunk-EX7OQT3Y.js.map +1 -0
  132. package/dist/cli-bundle/chunks/{chunk-ONREO4ST.js → chunk-EY7ZE3TG.js} +3 -3
  133. package/dist/cli-bundle/chunks/{chunk-ILX33QXL.js → chunk-F3VC3GOV.js} +669 -472
  134. package/dist/cli-bundle/chunks/chunk-F3VC3GOV.js.map +7 -0
  135. package/dist/cli-bundle/chunks/{chunk-EJEXHTY5.js → chunk-FHOBCGQO.js} +2 -2
  136. package/dist/cli-bundle/chunks/{chunk-H3EIEWGR.js → chunk-FL4D53ND.js} +2 -2
  137. package/dist/cli-bundle/chunks/{chunk-WUJQK4YV.js → chunk-FVNWHUME.js} +4 -4
  138. package/dist/cli-bundle/chunks/{chunk-INU6DKT5.js → chunk-FXFCFL73.js} +5 -5
  139. package/dist/cli-bundle/chunks/{chunk-QEHQ2GVG.js → chunk-FY4RLHSC.js} +2 -2
  140. package/dist/cli-bundle/chunks/{chunk-AHVTB5I5.js → chunk-G6MYGULG.js} +4 -4
  141. package/dist/cli-bundle/chunks/{chunk-HYB5AZ63.js → chunk-GKPCTQYG.js} +1822 -72
  142. package/dist/cli-bundle/chunks/chunk-GKPCTQYG.js.map +7 -0
  143. package/dist/cli-bundle/chunks/{chunk-TSMHDIW4.js → chunk-GLZKZON6.js} +2 -2
  144. package/dist/cli-bundle/chunks/{chunk-2JKGO6QX.js → chunk-H5IOT54C.js} +4 -4
  145. package/dist/cli-bundle/chunks/{chunk-SELVXEZK.js → chunk-HO4DLBNK.js} +2 -2
  146. package/dist/cli-bundle/chunks/{chunk-CRVF2JDM.js → chunk-HPAYDSR2.js} +8 -8
  147. package/dist/cli-bundle/chunks/{chunk-3CLU2XZO.js → chunk-HSYV4ZYT.js} +4 -4
  148. package/dist/cli-bundle/chunks/{chunk-EH2OPHBI.js → chunk-HTXXXF45.js} +23 -19
  149. package/dist/cli-bundle/chunks/chunk-HTXXXF45.js.map +1 -0
  150. package/dist/cli-bundle/chunks/{chunk-J5AOEGDC.js → chunk-HYTOJW2Q.js} +8 -8
  151. package/dist/cli-bundle/chunks/{chunk-4XQ3BDV4.js → chunk-I3INI567.js} +536 -449
  152. package/dist/cli-bundle/chunks/chunk-I3INI567.js.map +7 -0
  153. package/dist/cli-bundle/chunks/{chunk-NU3IMIEA.js → chunk-I7DIDUSP.js} +2 -2
  154. package/dist/cli-bundle/chunks/{chunk-JYFOV7FC.js → chunk-IE5KRAKN.js} +4 -4
  155. package/dist/cli-bundle/chunks/{chunk-YAROI3PD.js → chunk-IL5SPRMH.js} +7 -7
  156. package/dist/cli-bundle/chunks/{chunk-UY2ACEMF.js → chunk-ILVOOAT4.js} +5 -5
  157. package/dist/cli-bundle/chunks/{chunk-GOSLKLFE.js → chunk-KH6QAHME.js} +3 -3
  158. package/dist/cli-bundle/chunks/{chunk-QKECXBBG.js → chunk-KX62NMZC.js} +3 -3
  159. package/dist/cli-bundle/chunks/{chunk-QKECXBBG.js.map → chunk-KX62NMZC.js.map} +1 -1
  160. package/dist/cli-bundle/chunks/{chunk-WQPUU7XD.js → chunk-L337QKWJ.js} +5 -5
  161. package/dist/cli-bundle/chunks/{chunk-JFTKLTEF.js → chunk-L5BTTDU5.js} +68 -503
  162. package/dist/cli-bundle/chunks/chunk-L5BTTDU5.js.map +1 -0
  163. package/dist/cli-bundle/chunks/{chunk-LSG2U345.js → chunk-L6FVNR7X.js} +5 -5
  164. package/dist/cli-bundle/chunks/{chunk-FMBNM2EN.js → chunk-LSOWTLEM.js} +2 -2
  165. package/dist/cli-bundle/chunks/{chunk-4223PVZT.js → chunk-M7MVOKVV.js} +3 -3
  166. package/dist/cli-bundle/chunks/{chunk-UMOPHQSU.js → chunk-MR4SHYR4.js} +41 -19
  167. package/dist/cli-bundle/chunks/chunk-MR4SHYR4.js.map +7 -0
  168. package/dist/cli-bundle/chunks/{chunk-3WM75PWC.js → chunk-N33FD2UI.js} +3 -3
  169. package/dist/cli-bundle/chunks/{chunk-UXONS674.js → chunk-NCVT6XEL.js} +68 -56
  170. package/dist/cli-bundle/chunks/chunk-NCVT6XEL.js.map +1 -0
  171. package/dist/cli-bundle/chunks/{chunk-6S3YSUYG.js → chunk-NNANAWFH.js} +3 -3
  172. package/dist/cli-bundle/chunks/{chunk-IJIICKVW.js → chunk-NTRQLE2R.js} +2 -2
  173. package/dist/cli-bundle/chunks/{chunk-SDQLJWBO.js → chunk-NVZ6NVHJ.js} +4 -4
  174. package/dist/cli-bundle/chunks/{chunk-E2OJMKML.js → chunk-OGVTB5VO.js} +47 -37
  175. package/dist/cli-bundle/chunks/chunk-OGVTB5VO.js.map +7 -0
  176. package/dist/cli-bundle/chunks/{chunk-H2Z3FYXQ.js → chunk-OWP6QFBV.js} +4 -4
  177. package/dist/cli-bundle/chunks/{chunk-Q7A43DS4.js → chunk-P22HGFFI.js} +2 -2
  178. package/dist/cli-bundle/chunks/{chunk-NVPZIJVR.js → chunk-PT7MCCGD.js} +2 -2
  179. package/dist/cli-bundle/chunks/{chunk-ONG5V5CI.js → chunk-QPGQNLPI.js} +1751 -70
  180. package/dist/cli-bundle/chunks/chunk-QPGQNLPI.js.map +1 -0
  181. package/dist/cli-bundle/chunks/{chunk-J6EY5V4N.js → chunk-QRZNCRNA.js} +9 -9
  182. package/dist/cli-bundle/chunks/{chunk-QIPLHNP7.js → chunk-QWBKN3QC.js} +5 -5
  183. package/dist/cli-bundle/chunks/{chunk-7PIWCHTW.js → chunk-R5XTTZSJ.js} +5 -5
  184. package/dist/cli-bundle/chunks/{chunk-JOUQZENX.js → chunk-RC4UOUXA.js} +3 -3
  185. package/dist/cli-bundle/chunks/{chunk-BEP7WJA2.js → chunk-RGMWJLXF.js} +4 -4
  186. package/dist/cli-bundle/chunks/{chunk-NP22ERDF.js → chunk-RTBX3C4C.js} +3 -3
  187. package/dist/cli-bundle/chunks/{chunk-FNSPG7MU.js → chunk-RXPQ5Q23.js} +7 -7
  188. package/dist/cli-bundle/chunks/{chunk-LPYWLWDS.js → chunk-SIPOACV5.js} +534 -447
  189. package/dist/cli-bundle/chunks/chunk-SIPOACV5.js.map +1 -0
  190. package/dist/cli-bundle/chunks/chunk-TGBTLGPX.js +851 -0
  191. package/dist/cli-bundle/chunks/chunk-TGBTLGPX.js.map +7 -0
  192. package/dist/cli-bundle/chunks/{chunk-2WSE6PO2.js → chunk-TLWJP5BF.js} +5 -5
  193. package/dist/cli-bundle/chunks/chunk-TLWJP5BF.js.map +7 -0
  194. package/dist/cli-bundle/chunks/{chunk-ULTHRDBP.js → chunk-TM5CIO3F.js} +3 -3
  195. package/dist/cli-bundle/chunks/{chunk-UWQHLMEB.js → chunk-TZAE66GQ.js} +8 -8
  196. package/dist/cli-bundle/chunks/{chunk-OW4JWD5M.js → chunk-VAHZIPWS.js} +4 -4
  197. package/dist/cli-bundle/chunks/{chunk-DYH63FX7.js → chunk-VE6ZSTQW.js} +4 -4
  198. package/dist/cli-bundle/chunks/{chunk-3AUGG2DP.js → chunk-W5E2UUSH.js} +3 -3
  199. package/dist/cli-bundle/chunks/{chunk-BSEQUTQP.js → chunk-WACRQ26A.js} +2 -2
  200. package/dist/cli-bundle/chunks/{chunk-BSEQUTQP.js.map → chunk-WACRQ26A.js.map} +1 -1
  201. package/dist/cli-bundle/chunks/{chunk-UOHFKBUV.js → chunk-WL3SS45P.js} +3 -3
  202. package/dist/cli-bundle/chunks/{chunk-H5APFTHZ.js → chunk-WQXRZMFN.js} +204 -33
  203. package/dist/cli-bundle/chunks/chunk-WQXRZMFN.js.map +7 -0
  204. package/dist/cli-bundle/chunks/{chunk-QKJGPFAF.js → chunk-WU3KAN6A.js} +3 -3
  205. package/dist/cli-bundle/chunks/{chunk-IA5FKNII.js → chunk-X2MGQMZO.js} +2 -2
  206. package/dist/cli-bundle/chunks/{chunk-TD3LVC7D.js → chunk-X5YCTFKT.js} +3 -3
  207. package/dist/cli-bundle/chunks/{chunk-B7PE22W6.js → chunk-XC2HEEOV.js} +4 -4
  208. package/dist/cli-bundle/chunks/{chunk-7Z4LKRS4.js → chunk-XPUTSGJU.js} +38 -37
  209. package/dist/cli-bundle/chunks/chunk-XPUTSGJU.js.map +1 -0
  210. package/dist/cli-bundle/chunks/{chunk-YBLZ2VE7.js → chunk-XWBD6DSR.js} +320 -239
  211. package/dist/cli-bundle/chunks/chunk-XWBD6DSR.js.map +7 -0
  212. package/dist/cli-bundle/chunks/chunk-XWYQ2LT4.js +834 -0
  213. package/dist/cli-bundle/chunks/chunk-XWYQ2LT4.js.map +1 -0
  214. package/dist/cli-bundle/chunks/{chunk-K2X6U4UA.js → chunk-XXLXJL7V.js} +4 -4
  215. package/dist/cli-bundle/chunks/{chunk-2NCIPMQP.js → chunk-YFE7JHX3.js} +27 -6
  216. package/dist/cli-bundle/chunks/chunk-YFE7JHX3.js.map +1 -0
  217. package/dist/cli-bundle/chunks/{chunk-EACOH7AU.js → chunk-YIIIAKCE.js} +8 -8
  218. package/dist/cli-bundle/chunks/{chunk-RLCHOOHC.js → chunk-YJSURTBB.js} +2 -2
  219. package/dist/cli-bundle/chunks/{chunk-PGY23YTC.js → chunk-YKFHF37B.js} +3 -3
  220. package/dist/cli-bundle/chunks/{chunk-EYLCSJAI.js → chunk-YQEZWI3R.js} +2 -2
  221. package/dist/cli-bundle/chunks/close-GPD7DTJV.js +12 -0
  222. package/dist/cli-bundle/chunks/{close-CWODTPKG.js → close-X3CF6FQP.js} +5 -5
  223. package/dist/cli-bundle/chunks/{close-many-CQFUY7MR.js → close-many-J7A5EHOQ.js} +14 -14
  224. package/dist/cli-bundle/chunks/close-many-NQLYGPYW.js +23 -0
  225. package/dist/cli-bundle/chunks/comments-2AOZQ5D2.js +13 -0
  226. package/dist/cli-bundle/chunks/{comments-WGLHR7LB.js → comments-TMHMALA5.js} +7 -7
  227. package/dist/cli-bundle/chunks/{copy-LXVDXH7B.js → copy-FWQA5OU4.js} +4 -4
  228. package/dist/cli-bundle/chunks/copy-N3LCQBMC.js +9 -0
  229. package/dist/cli-bundle/chunks/{create-LBVCYMEG.js → create-AQ5SIGZC.js} +9 -9
  230. package/dist/cli-bundle/chunks/{create-J5U6ND4K.js → create-KOGQ3JKD.js} +9 -9
  231. package/dist/cli-bundle/chunks/delete-6G3MBZ6S.js +10 -0
  232. package/dist/cli-bundle/chunks/{delete-PMJBNY5G.js → delete-YYYFOSEA.js} +4 -4
  233. package/dist/cli-bundle/chunks/{deps-JZ7TMVCB.js → deps-MQ4ZIGZB.js} +16 -7
  234. package/dist/cli-bundle/chunks/deps-NIIKXLPB.js +28 -0
  235. package/dist/cli-bundle/chunks/{docs-FEWB2DQB.js → docs-53NUGMIQ.js} +6 -6
  236. package/dist/cli-bundle/chunks/docs-OWRGDMNY.js +14 -0
  237. package/dist/cli-bundle/chunks/{files-EFIWKFTM.js → files-3PXGXYDB.js} +6 -6
  238. package/dist/cli-bundle/chunks/{files-6YFBJRBG.js → files-EGLKHD7O.js} +6 -6
  239. package/dist/cli-bundle/chunks/focus-KZLIA6WS.js +10 -0
  240. package/dist/cli-bundle/chunks/{focus-4QJR7FOQ.js → focus-SRPASFTN.js} +5 -5
  241. package/dist/cli-bundle/chunks/{history-compact-CKRPDTJN.js → history-compact-G4DULDCX.js} +6 -6
  242. package/dist/cli-bundle/chunks/history-compact-HHIUOMZ7.js +16 -0
  243. package/dist/cli-bundle/chunks/{history-redact-BB3TGDAE.js → history-redact-IUSJ6X3E.js} +4 -4
  244. package/dist/cli-bundle/chunks/{history-redact-D225BHOZ.js → history-redact-THHGRQXV.js} +4 -4
  245. package/dist/cli-bundle/chunks/history-repair-KG7SWXI6.js +16 -0
  246. package/dist/cli-bundle/chunks/{history-repair-RQXKQHL4.js → history-repair-LUQWRS7X.js} +6 -6
  247. package/dist/cli-bundle/chunks/{learnings-JLNLCOL5.js → learnings-2MRNBFJF.js} +7 -7
  248. package/dist/cli-bundle/chunks/learnings-ZVHSALJY.js +13 -0
  249. package/dist/cli-bundle/chunks/{notes-GB47XXQQ.js → notes-73JWKWUD.js} +7 -7
  250. package/dist/cli-bundle/chunks/notes-BAKUL5DJ.js +13 -0
  251. package/dist/cli-bundle/chunks/{plan-VDCJ2PCN.js → plan-AZPMCG37.js} +10 -10
  252. package/dist/cli-bundle/chunks/plan-LEAGLPGP.js +24 -0
  253. package/dist/cli-bundle/chunks/{profile-FAU7NZML.js → profile-AVCIIZID.js} +9 -9
  254. package/dist/cli-bundle/chunks/{profile-IVXQEL3D.js → profile-LFYO3HHX.js} +9 -9
  255. package/dist/cli-bundle/chunks/{register-list-query-UL4UKBBN.js → register-list-query-MZUF2EEC.js} +50 -22
  256. package/dist/cli-bundle/chunks/register-list-query-MZUF2EEC.js.map +1 -0
  257. package/dist/cli-bundle/chunks/{register-list-query-DKA3EH5D.js → register-list-query-UKMF55FT.js} +49 -21
  258. package/dist/cli-bundle/chunks/register-list-query-UKMF55FT.js.map +7 -0
  259. package/dist/cli-bundle/chunks/{register-mutation-RBBJ52DK.js → register-mutation-2PBW2GEX.js} +35 -33
  260. package/dist/cli-bundle/chunks/register-mutation-2PBW2GEX.js.map +1 -0
  261. package/dist/cli-bundle/chunks/{register-mutation-ARFHRW55.js → register-mutation-T6RVNJC4.js} +34 -32
  262. package/dist/cli-bundle/chunks/{register-mutation-ARFHRW55.js.map → register-mutation-T6RVNJC4.js.map} +2 -2
  263. package/dist/cli-bundle/chunks/{register-operations-ZIBBRSED.js → register-operations-KHZYR6MG.js} +35 -35
  264. package/dist/cli-bundle/chunks/{register-operations-ZUJ5JWPE.js → register-operations-WPQ2LWZJ.js} +35 -35
  265. package/dist/cli-bundle/chunks/{register-setup-BCVLFEYS.js → register-setup-PGDNOXDQ.js} +15 -15
  266. package/dist/cli-bundle/chunks/{register-setup-TDCGWIOS.js → register-setup-TDN7WAO6.js} +15 -15
  267. package/dist/cli-bundle/chunks/{restore-25DLT2Q2.js → restore-E3PRGDN3.js} +6 -6
  268. package/dist/cli-bundle/chunks/restore-KIUYTAEJ.js +14 -0
  269. package/dist/cli-bundle/chunks/{schema-FNU3WE4O.js → schema-5JNFQFUW.js} +6 -6
  270. package/dist/cli-bundle/chunks/{schema-NBCM3RAD.js → schema-TMIW4XZC.js} +6 -6
  271. package/dist/cli-bundle/chunks/{update-XHSIAIXE.js → update-SQYZA3ZW.js} +12 -12
  272. package/dist/cli-bundle/chunks/update-XZJYS5X7.js +21 -0
  273. package/dist/cli-bundle/chunks/update-many-R24B3GBK.js +36 -0
  274. package/dist/cli-bundle/chunks/update-many-WQ3R3J6N.js +32 -0
  275. package/dist/cli-bundle/main.js +170 -856
  276. package/dist/cli-bundle/main.js.map +4 -4
  277. package/dist/cli-bundle/sdk-runtime.js +57 -54
  278. package/dist/cli-bundle/sdk-testing.js +6 -6
  279. package/dist/cli-bundle/sdk.js +266 -340
  280. package/dist/cli-bundle/sdk.js.map +4 -4
  281. package/dist/core/extensions/item-fields.js +2 -2
  282. package/dist/core/extensions/item-fields.js.map +1 -1
  283. package/dist/core/item/actionability.d.ts +12 -0
  284. package/dist/core/item/actionability.js +39 -4
  285. package/dist/core/item/actionability.js.map +1 -1
  286. package/dist/core/sentry/instrument.d.ts +11 -0
  287. package/dist/core/sentry/instrument.js +21 -2
  288. package/dist/core/sentry/instrument.js.map +1 -1
  289. package/dist/mcp/server.d.ts +16 -18
  290. package/dist/mcp/server.js +84 -31
  291. package/dist/mcp/server.js.map +1 -1
  292. package/dist/mcp/tool-definitions.js +17 -4
  293. package/dist/mcp/tool-definitions.js.map +1 -1
  294. package/dist/sdk/actionability.d.ts +10 -0
  295. package/dist/sdk/actionability.js +14 -0
  296. package/dist/sdk/actionability.js.map +1 -0
  297. package/dist/sdk/cli-bootstrap.d.ts +122 -0
  298. package/dist/sdk/cli-bootstrap.js +879 -0
  299. package/dist/sdk/cli-bootstrap.js.map +1 -0
  300. package/dist/sdk/cli-contracts/enum-contracts.d.ts +6 -2
  301. package/dist/sdk/cli-contracts/enum-contracts.js +19 -2
  302. package/dist/sdk/cli-contracts/enum-contracts.js.map +1 -1
  303. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  304. package/dist/sdk/cli-contracts/flag-contracts.js +21 -2
  305. package/dist/sdk/cli-contracts/flag-contracts.js.map +1 -1
  306. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +2 -0
  307. package/dist/sdk/cli-contracts/tool-option-contracts.js +16 -2
  308. package/dist/sdk/cli-contracts/tool-option-contracts.js.map +1 -1
  309. package/dist/sdk/cli-contracts/tool-parameter-tables.js +80 -3
  310. package/dist/sdk/cli-contracts/tool-parameter-tables.js.map +1 -1
  311. package/dist/sdk/cli-contracts/tool-schema.d.ts +20 -0
  312. package/dist/sdk/cli-contracts/tool-schema.js +97 -9
  313. package/dist/sdk/cli-contracts/tool-schema.js.map +1 -1
  314. package/dist/sdk/cli-contracts.d.ts +2 -2
  315. package/dist/sdk/cli-contracts.js +4 -4
  316. package/dist/sdk/cli-contracts.js.map +1 -1
  317. package/dist/sdk/dependencies.d.ts +42 -53
  318. package/dist/sdk/dependencies.js +177 -125
  319. package/dist/sdk/dependencies.js.map +1 -1
  320. package/dist/sdk/eval.d.ts +66 -0
  321. package/dist/sdk/eval.js +186 -0
  322. package/dist/sdk/eval.js.map +1 -0
  323. package/dist/sdk/governance/validate.js +3 -3
  324. package/dist/sdk/governance/validate.js.map +1 -1
  325. package/dist/sdk/graph/analytics.d.ts +124 -0
  326. package/dist/sdk/graph/analytics.js +464 -0
  327. package/dist/sdk/graph/analytics.js.map +1 -0
  328. package/dist/sdk/graph/assembly.d.ts +97 -0
  329. package/dist/sdk/graph/assembly.js +146 -0
  330. package/dist/sdk/graph/assembly.js.map +1 -0
  331. package/dist/sdk/graph/cache.d.ts +66 -0
  332. package/dist/sdk/graph/cache.js +148 -0
  333. package/dist/sdk/graph/cache.js.map +1 -0
  334. package/dist/sdk/graph/governance.d.ts +108 -0
  335. package/dist/sdk/graph/governance.js +360 -0
  336. package/dist/sdk/graph/governance.js.map +1 -0
  337. package/dist/sdk/graph/index.d.ts +16 -0
  338. package/dist/sdk/graph/index.js +20 -0
  339. package/dist/sdk/graph/index.js.map +1 -0
  340. package/dist/sdk/graph/remediation.d.ts +52 -0
  341. package/dist/sdk/graph/remediation.js +148 -0
  342. package/dist/sdk/graph/remediation.js.map +1 -0
  343. package/dist/sdk/graph/run.d.ts +295 -0
  344. package/dist/sdk/graph/run.js +468 -0
  345. package/dist/sdk/graph/run.js.map +1 -0
  346. package/dist/sdk/graph/traversal.d.ts +77 -0
  347. package/dist/sdk/graph/traversal.js +262 -0
  348. package/dist/sdk/graph/traversal.js.map +1 -0
  349. package/dist/sdk/index.d.ts +19 -5
  350. package/dist/sdk/index.js +21 -7
  351. package/dist/sdk/index.js.map +1 -1
  352. package/dist/{cli/commands → sdk/query}/item-filter-options.d.ts +1 -1
  353. package/dist/{cli/commands → sdk/query}/item-filter-options.js +3 -3
  354. package/dist/sdk/query/item-filter-options.js.map +1 -0
  355. package/dist/sdk/query/list.d.ts +262 -0
  356. package/dist/sdk/query/list.js +1089 -0
  357. package/dist/sdk/query/list.js.map +1 -0
  358. package/dist/sdk/query/parsers.d.ts +9 -0
  359. package/dist/sdk/query/parsers.js +45 -0
  360. package/dist/sdk/query/parsers.js.map +1 -0
  361. package/dist/{cli/commands → sdk/query}/search-pagination.js +4 -4
  362. package/dist/sdk/query/search-pagination.js.map +1 -0
  363. package/dist/{cli/commands → sdk/query}/search-rendering.js +3 -3
  364. package/dist/sdk/query/search-rendering.js.map +1 -0
  365. package/dist/sdk/query/search.d.ts +469 -0
  366. package/dist/sdk/query/search.js +2247 -0
  367. package/dist/sdk/query/search.js.map +1 -0
  368. package/dist/sdk/relationship-context.d.ts +42 -0
  369. package/dist/sdk/relationship-context.js +99 -20
  370. package/dist/sdk/relationship-context.js.map +1 -1
  371. package/dist/sdk/relationships.d.ts +13 -0
  372. package/dist/sdk/relationships.js +30 -2
  373. package/dist/sdk/relationships.js.map +1 -1
  374. package/dist/sdk/runtime-input.d.ts +41 -0
  375. package/dist/sdk/runtime-input.js +422 -2
  376. package/dist/sdk/runtime-input.js.map +1 -1
  377. package/dist/sdk/runtime.d.ts +19 -30
  378. package/dist/sdk/runtime.js +30 -376
  379. package/dist/sdk/runtime.js.map +1 -1
  380. package/dist/sdk/search-refresh-worker.d.ts +2 -0
  381. package/dist/sdk/search-refresh-worker.js +19 -0
  382. package/dist/sdk/search-refresh-worker.js.map +1 -0
  383. package/dist/sdk/stats.d.ts +66 -0
  384. package/dist/sdk/stats.js +151 -0
  385. package/dist/sdk/stats.js.map +1 -0
  386. package/dist/sdk/telemetry-flush.d.ts +2 -0
  387. package/dist/sdk/telemetry-flush.js +14 -0
  388. package/dist/sdk/telemetry-flush.js.map +1 -0
  389. package/dist/sdk/telemetry.d.ts +14 -0
  390. package/dist/sdk/telemetry.js +398 -0
  391. package/dist/sdk/telemetry.js.map +1 -0
  392. package/dist/sdk/test/batch.d.ts +94 -0
  393. package/dist/sdk/test/batch.js +492 -0
  394. package/dist/sdk/test/batch.js.map +1 -0
  395. package/dist/sdk/test/entry.d.ts +6 -0
  396. package/dist/sdk/test/entry.js +74 -0
  397. package/dist/sdk/test/entry.js.map +1 -0
  398. package/dist/sdk/test/execution.d.ts +282 -0
  399. package/dist/sdk/test/execution.js +1817 -0
  400. package/dist/sdk/test/execution.js.map +1 -0
  401. package/dist/sdk/test/linked-command-detection.js +12 -3
  402. package/dist/sdk/test/linked-command-detection.js.map +1 -1
  403. package/dist/sdk/test/parsers.d.ts +48 -0
  404. package/dist/sdk/test/parsers.js +522 -0
  405. package/dist/sdk/test/parsers.js.map +1 -0
  406. package/dist/sdk/test/runs.d.ts +92 -0
  407. package/dist/sdk/test/runs.js +195 -0
  408. package/dist/sdk/test/runs.js.map +1 -0
  409. package/docs/AGENT_GUIDE.md +1 -0
  410. package/docs/COMMANDS.md +19 -1
  411. package/docs/RELATIONSHIP_GRAPH.md +99 -3
  412. package/docs/SDK.md +139 -3
  413. package/docs/SDK_PRIMITIVE_INVENTORY.md +5 -3
  414. package/docs/examples/sdk-custom-tool/README.md +27 -0
  415. package/docs/examples/sdk-custom-tool/package.json +13 -0
  416. package/docs/examples/sdk-custom-tool/src/cli.ts +36 -0
  417. package/docs/examples/sdk-custom-tool/src/entry.ts +15 -0
  418. package/docs/examples/sdk-custom-tool/src/index.ts +223 -0
  419. package/marketplace.json +2 -2
  420. package/package.json +4 -4
  421. package/packages/pm-beads/package.json +1 -1
  422. package/packages/pm-calendar/package.json +1 -1
  423. package/packages/pm-command-kit/package.json +1 -1
  424. package/packages/pm-governance-audit/extensions/governance-audit/comments-audit.ts +77 -57
  425. package/packages/pm-governance-audit/extensions/governance-audit/dedupe-audit.ts +202 -194
  426. package/packages/pm-governance-audit/extensions/governance-audit/dedupe-merge.ts +227 -153
  427. package/packages/pm-governance-audit/extensions/governance-audit/normalize.ts +169 -125
  428. package/packages/pm-governance-audit/extensions/governance-audit/runtime-utils.ts +130 -81
  429. package/packages/pm-governance-audit/extensions/governance-audit/sdk.ts +53 -4
  430. package/packages/pm-governance-audit/package.json +1 -1
  431. package/packages/pm-guide-shell/package.json +1 -1
  432. package/packages/pm-kanban/package.json +1 -1
  433. package/packages/pm-lifecycle-hooks/package.json +1 -1
  434. package/packages/pm-linked-test-adapters/package.json +1 -1
  435. package/packages/pm-search-advanced/package.json +1 -1
  436. package/packages/pm-templates/package.json +1 -1
  437. package/packages/pm-todos/package.json +1 -1
  438. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  439. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  440. package/dist/cli/commands/item-filter-options.js.map +0 -1
  441. package/dist/cli/commands/search-pagination.js.map +0 -1
  442. package/dist/cli/commands/search-rendering.js.map +0 -1
  443. package/dist/cli-bundle/chunks/append-UZVHUO74.js +0 -11
  444. package/dist/cli-bundle/chunks/chunk-2NCIPMQP.js.map +0 -1
  445. package/dist/cli-bundle/chunks/chunk-3S5QVM5H.js.map +0 -1
  446. package/dist/cli-bundle/chunks/chunk-4XQ3BDV4.js.map +0 -7
  447. package/dist/cli-bundle/chunks/chunk-5JLUII3O.js.map +0 -1
  448. package/dist/cli-bundle/chunks/chunk-5ZSLZLDN.js.map +0 -1
  449. package/dist/cli-bundle/chunks/chunk-7Z4LKRS4.js.map +0 -1
  450. package/dist/cli-bundle/chunks/chunk-BKVG6XOA.js.map +0 -7
  451. package/dist/cli-bundle/chunks/chunk-E2OJMKML.js.map +0 -7
  452. package/dist/cli-bundle/chunks/chunk-EH2OPHBI.js.map +0 -1
  453. package/dist/cli-bundle/chunks/chunk-H5APFTHZ.js.map +0 -7
  454. package/dist/cli-bundle/chunks/chunk-HYB5AZ63.js.map +0 -7
  455. package/dist/cli-bundle/chunks/chunk-ILX33QXL.js.map +0 -7
  456. package/dist/cli-bundle/chunks/chunk-JFTKLTEF.js.map +0 -1
  457. package/dist/cli-bundle/chunks/chunk-LPYWLWDS.js.map +0 -1
  458. package/dist/cli-bundle/chunks/chunk-NLDFBC6J.js.map +0 -7
  459. package/dist/cli-bundle/chunks/chunk-ONG5V5CI.js.map +0 -1
  460. package/dist/cli-bundle/chunks/chunk-UFXU44HV.js.map +0 -1
  461. package/dist/cli-bundle/chunks/chunk-UMOPHQSU.js.map +0 -7
  462. package/dist/cli-bundle/chunks/chunk-UXONS674.js.map +0 -1
  463. package/dist/cli-bundle/chunks/chunk-XXXF6PAQ.js.map +0 -7
  464. package/dist/cli-bundle/chunks/chunk-YBLZ2VE7.js.map +0 -7
  465. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js +0 -58
  466. package/dist/cli-bundle/chunks/chunk-YXSHIAUJ.js.map +0 -1
  467. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js +0 -68
  468. package/dist/cli-bundle/chunks/chunk-ZKRZY773.js.map +0 -7
  469. package/dist/cli-bundle/chunks/close-W6LI2PKM.js +0 -12
  470. package/dist/cli-bundle/chunks/close-many-DLDDVSH5.js +0 -23
  471. package/dist/cli-bundle/chunks/comments-E3TNTK24.js +0 -13
  472. package/dist/cli-bundle/chunks/copy-Q5ZJPUKR.js +0 -9
  473. package/dist/cli-bundle/chunks/delete-WNHB3LYW.js +0 -10
  474. package/dist/cli-bundle/chunks/deps-OA26IS25.js +0 -19
  475. package/dist/cli-bundle/chunks/docs-HA2AIDBB.js +0 -14
  476. package/dist/cli-bundle/chunks/focus-POIW5LTJ.js +0 -10
  477. package/dist/cli-bundle/chunks/history-compact-FWG2C7FZ.js +0 -16
  478. package/dist/cli-bundle/chunks/history-repair-6GEAM7HE.js +0 -16
  479. package/dist/cli-bundle/chunks/learnings-RSNLSWDC.js +0 -13
  480. package/dist/cli-bundle/chunks/notes-2WDH6DXU.js +0 -13
  481. package/dist/cli-bundle/chunks/plan-DOVI2VMW.js +0 -24
  482. package/dist/cli-bundle/chunks/register-list-query-DKA3EH5D.js.map +0 -7
  483. package/dist/cli-bundle/chunks/register-list-query-UL4UKBBN.js.map +0 -1
  484. package/dist/cli-bundle/chunks/register-mutation-RBBJ52DK.js.map +0 -1
  485. package/dist/cli-bundle/chunks/restore-YPMVUUEX.js +0 -14
  486. package/dist/cli-bundle/chunks/update-WWBYOPXO.js +0 -21
  487. package/dist/cli-bundle/chunks/update-many-OUGIU5SF.js +0 -32
  488. package/dist/cli-bundle/chunks/update-many-TA7NGQBO.js +0 -36
  489. /package/dist/cli-bundle/chunks/{append-OJQFUQ4T.js.map → append-5YF3TO7I.js.map} +0 -0
  490. /package/dist/cli-bundle/chunks/{append-UZVHUO74.js.map → append-JHO5K6RP.js.map} +0 -0
  491. /package/dist/cli-bundle/chunks/{chunk-BCOFWYW4.js.map → chunk-2BX74BAS.js.map} +0 -0
  492. /package/dist/cli-bundle/chunks/{chunk-APRVSW2O.js.map → chunk-2CXL335K.js.map} +0 -0
  493. /package/dist/cli-bundle/chunks/{chunk-KG44YSKD.js.map → chunk-2FUOXSRN.js.map} +0 -0
  494. /package/dist/cli-bundle/chunks/{chunk-HDH3JUGG.js.map → chunk-2IPNL3DR.js.map} +0 -0
  495. /package/dist/cli-bundle/chunks/{chunk-GM5QHQU6.js.map → chunk-2XOSFSTH.js.map} +0 -0
  496. /package/dist/cli-bundle/chunks/{chunk-K3WII2ME.js.map → chunk-37DRDP2B.js.map} +0 -0
  497. /package/dist/cli-bundle/chunks/{chunk-PMOSXADO.js.map → chunk-47HXN6RX.js.map} +0 -0
  498. /package/dist/cli-bundle/chunks/{chunk-6CFNAVTF.js.map → chunk-5HGZKQUL.js.map} +0 -0
  499. /package/dist/cli-bundle/chunks/{chunk-2IFFUZLC.js.map → chunk-5UKQLQM2.js.map} +0 -0
  500. /package/dist/cli-bundle/chunks/{chunk-DM4H7FP4.js.map → chunk-633PKXLT.js.map} +0 -0
  501. /package/dist/cli-bundle/chunks/{chunk-XSJUSQAE.js.map → chunk-646MQXFW.js.map} +0 -0
  502. /package/dist/cli-bundle/chunks/{chunk-ZI6VQWQ7.js.map → chunk-66MKH7SZ.js.map} +0 -0
  503. /package/dist/cli-bundle/chunks/{chunk-S6MQESFR.js.map → chunk-67RO3H4N.js.map} +0 -0
  504. /package/dist/cli-bundle/chunks/{chunk-34L5OT3Y.js.map → chunk-6DYOZS6C.js.map} +0 -0
  505. /package/dist/cli-bundle/chunks/{chunk-RRM5JYJC.js.map → chunk-6O44IN44.js.map} +0 -0
  506. /package/dist/cli-bundle/chunks/{chunk-PENXZX3U.js.map → chunk-74FKFFXO.js.map} +0 -0
  507. /package/dist/cli-bundle/chunks/{chunk-HO4KXD6I.js.map → chunk-7H5NNCJ5.js.map} +0 -0
  508. /package/dist/cli-bundle/chunks/{chunk-TQSZFPIS.js.map → chunk-AFGKSHAM.js.map} +0 -0
  509. /package/dist/cli-bundle/chunks/{chunk-6N2VXVTQ.js.map → chunk-ARGDWQ4J.js.map} +0 -0
  510. /package/dist/cli-bundle/chunks/{chunk-3U7ZR6M4.js.map → chunk-B57RJHBZ.js.map} +0 -0
  511. /package/dist/cli-bundle/chunks/{chunk-YCQET3OT.js.map → chunk-BAP7G3N2.js.map} +0 -0
  512. /package/dist/cli-bundle/chunks/{chunk-QKXHFPYM.js.map → chunk-BIRYX32V.js.map} +0 -0
  513. /package/dist/cli-bundle/chunks/{chunk-RMLWNPH2.js.map → chunk-BVLOMU6O.js.map} +0 -0
  514. /package/dist/cli-bundle/chunks/{chunk-2VPAVL7O.js.map → chunk-CKX4WOPC.js.map} +0 -0
  515. /package/dist/cli-bundle/chunks/{chunk-TKOVBP6C.js.map → chunk-D52ZN3BF.js.map} +0 -0
  516. /package/dist/cli-bundle/chunks/{chunk-KPMKHGEA.js.map → chunk-D53RTYVI.js.map} +0 -0
  517. /package/dist/cli-bundle/chunks/{chunk-ODALILG3.js.map → chunk-D5XHO4Q7.js.map} +0 -0
  518. /package/dist/cli-bundle/chunks/{chunk-YAQEBNY7.js.map → chunk-DDFGYUCQ.js.map} +0 -0
  519. /package/dist/cli-bundle/chunks/{chunk-EAB64KLB.js.map → chunk-DG2EQRIH.js.map} +0 -0
  520. /package/dist/cli-bundle/chunks/{chunk-IG3SWA4A.js.map → chunk-EHJFUOXL.js.map} +0 -0
  521. /package/dist/cli-bundle/chunks/{chunk-P74IZQ7A.js.map → chunk-EWIT5WIC.js.map} +0 -0
  522. /package/dist/cli-bundle/chunks/{chunk-ONREO4ST.js.map → chunk-EY7ZE3TG.js.map} +0 -0
  523. /package/dist/cli-bundle/chunks/{chunk-EJEXHTY5.js.map → chunk-FHOBCGQO.js.map} +0 -0
  524. /package/dist/cli-bundle/chunks/{chunk-H3EIEWGR.js.map → chunk-FL4D53ND.js.map} +0 -0
  525. /package/dist/cli-bundle/chunks/{chunk-WUJQK4YV.js.map → chunk-FVNWHUME.js.map} +0 -0
  526. /package/dist/cli-bundle/chunks/{chunk-INU6DKT5.js.map → chunk-FXFCFL73.js.map} +0 -0
  527. /package/dist/cli-bundle/chunks/{chunk-QEHQ2GVG.js.map → chunk-FY4RLHSC.js.map} +0 -0
  528. /package/dist/cli-bundle/chunks/{chunk-AHVTB5I5.js.map → chunk-G6MYGULG.js.map} +0 -0
  529. /package/dist/cli-bundle/chunks/{chunk-TSMHDIW4.js.map → chunk-GLZKZON6.js.map} +0 -0
  530. /package/dist/cli-bundle/chunks/{chunk-2JKGO6QX.js.map → chunk-H5IOT54C.js.map} +0 -0
  531. /package/dist/cli-bundle/chunks/{chunk-SELVXEZK.js.map → chunk-HO4DLBNK.js.map} +0 -0
  532. /package/dist/cli-bundle/chunks/{chunk-CRVF2JDM.js.map → chunk-HPAYDSR2.js.map} +0 -0
  533. /package/dist/cli-bundle/chunks/{chunk-3CLU2XZO.js.map → chunk-HSYV4ZYT.js.map} +0 -0
  534. /package/dist/cli-bundle/chunks/{chunk-J5AOEGDC.js.map → chunk-HYTOJW2Q.js.map} +0 -0
  535. /package/dist/cli-bundle/chunks/{chunk-NU3IMIEA.js.map → chunk-I7DIDUSP.js.map} +0 -0
  536. /package/dist/cli-bundle/chunks/{chunk-JYFOV7FC.js.map → chunk-IE5KRAKN.js.map} +0 -0
  537. /package/dist/cli-bundle/chunks/{chunk-YAROI3PD.js.map → chunk-IL5SPRMH.js.map} +0 -0
  538. /package/dist/cli-bundle/chunks/{chunk-UY2ACEMF.js.map → chunk-ILVOOAT4.js.map} +0 -0
  539. /package/dist/cli-bundle/chunks/{chunk-GOSLKLFE.js.map → chunk-KH6QAHME.js.map} +0 -0
  540. /package/dist/cli-bundle/chunks/{chunk-WQPUU7XD.js.map → chunk-L337QKWJ.js.map} +0 -0
  541. /package/dist/cli-bundle/chunks/{chunk-LSG2U345.js.map → chunk-L6FVNR7X.js.map} +0 -0
  542. /package/dist/cli-bundle/chunks/{chunk-FMBNM2EN.js.map → chunk-LSOWTLEM.js.map} +0 -0
  543. /package/dist/cli-bundle/chunks/{chunk-4223PVZT.js.map → chunk-M7MVOKVV.js.map} +0 -0
  544. /package/dist/cli-bundle/chunks/{chunk-3WM75PWC.js.map → chunk-N33FD2UI.js.map} +0 -0
  545. /package/dist/cli-bundle/chunks/{chunk-6S3YSUYG.js.map → chunk-NNANAWFH.js.map} +0 -0
  546. /package/dist/cli-bundle/chunks/{chunk-IJIICKVW.js.map → chunk-NTRQLE2R.js.map} +0 -0
  547. /package/dist/cli-bundle/chunks/{chunk-SDQLJWBO.js.map → chunk-NVZ6NVHJ.js.map} +0 -0
  548. /package/dist/cli-bundle/chunks/{chunk-H2Z3FYXQ.js.map → chunk-OWP6QFBV.js.map} +0 -0
  549. /package/dist/cli-bundle/chunks/{chunk-Q7A43DS4.js.map → chunk-P22HGFFI.js.map} +0 -0
  550. /package/dist/cli-bundle/chunks/{chunk-NVPZIJVR.js.map → chunk-PT7MCCGD.js.map} +0 -0
  551. /package/dist/cli-bundle/chunks/{chunk-J6EY5V4N.js.map → chunk-QRZNCRNA.js.map} +0 -0
  552. /package/dist/cli-bundle/chunks/{chunk-QIPLHNP7.js.map → chunk-QWBKN3QC.js.map} +0 -0
  553. /package/dist/cli-bundle/chunks/{chunk-7PIWCHTW.js.map → chunk-R5XTTZSJ.js.map} +0 -0
  554. /package/dist/cli-bundle/chunks/{chunk-JOUQZENX.js.map → chunk-RC4UOUXA.js.map} +0 -0
  555. /package/dist/cli-bundle/chunks/{chunk-BEP7WJA2.js.map → chunk-RGMWJLXF.js.map} +0 -0
  556. /package/dist/cli-bundle/chunks/{chunk-NP22ERDF.js.map → chunk-RTBX3C4C.js.map} +0 -0
  557. /package/dist/cli-bundle/chunks/{chunk-FNSPG7MU.js.map → chunk-RXPQ5Q23.js.map} +0 -0
  558. /package/dist/cli-bundle/chunks/{chunk-ULTHRDBP.js.map → chunk-TM5CIO3F.js.map} +0 -0
  559. /package/dist/cli-bundle/chunks/{chunk-UWQHLMEB.js.map → chunk-TZAE66GQ.js.map} +0 -0
  560. /package/dist/cli-bundle/chunks/{chunk-OW4JWD5M.js.map → chunk-VAHZIPWS.js.map} +0 -0
  561. /package/dist/cli-bundle/chunks/{chunk-DYH63FX7.js.map → chunk-VE6ZSTQW.js.map} +0 -0
  562. /package/dist/cli-bundle/chunks/{chunk-3AUGG2DP.js.map → chunk-W5E2UUSH.js.map} +0 -0
  563. /package/dist/cli-bundle/chunks/{chunk-UOHFKBUV.js.map → chunk-WL3SS45P.js.map} +0 -0
  564. /package/dist/cli-bundle/chunks/{chunk-QKJGPFAF.js.map → chunk-WU3KAN6A.js.map} +0 -0
  565. /package/dist/cli-bundle/chunks/{chunk-IA5FKNII.js.map → chunk-X2MGQMZO.js.map} +0 -0
  566. /package/dist/cli-bundle/chunks/{chunk-TD3LVC7D.js.map → chunk-X5YCTFKT.js.map} +0 -0
  567. /package/dist/cli-bundle/chunks/{chunk-B7PE22W6.js.map → chunk-XC2HEEOV.js.map} +0 -0
  568. /package/dist/cli-bundle/chunks/{chunk-K2X6U4UA.js.map → chunk-XXLXJL7V.js.map} +0 -0
  569. /package/dist/cli-bundle/chunks/{chunk-EACOH7AU.js.map → chunk-YIIIAKCE.js.map} +0 -0
  570. /package/dist/cli-bundle/chunks/{chunk-RLCHOOHC.js.map → chunk-YJSURTBB.js.map} +0 -0
  571. /package/dist/cli-bundle/chunks/{chunk-PGY23YTC.js.map → chunk-YKFHF37B.js.map} +0 -0
  572. /package/dist/cli-bundle/chunks/{chunk-EYLCSJAI.js.map → chunk-YQEZWI3R.js.map} +0 -0
  573. /package/dist/cli-bundle/chunks/{close-W6LI2PKM.js.map → close-GPD7DTJV.js.map} +0 -0
  574. /package/dist/cli-bundle/chunks/{close-CWODTPKG.js.map → close-X3CF6FQP.js.map} +0 -0
  575. /package/dist/cli-bundle/chunks/{close-many-CQFUY7MR.js.map → close-many-J7A5EHOQ.js.map} +0 -0
  576. /package/dist/cli-bundle/chunks/{close-many-DLDDVSH5.js.map → close-many-NQLYGPYW.js.map} +0 -0
  577. /package/dist/cli-bundle/chunks/{comments-E3TNTK24.js.map → comments-2AOZQ5D2.js.map} +0 -0
  578. /package/dist/cli-bundle/chunks/{comments-WGLHR7LB.js.map → comments-TMHMALA5.js.map} +0 -0
  579. /package/dist/cli-bundle/chunks/{copy-LXVDXH7B.js.map → copy-FWQA5OU4.js.map} +0 -0
  580. /package/dist/cli-bundle/chunks/{copy-Q5ZJPUKR.js.map → copy-N3LCQBMC.js.map} +0 -0
  581. /package/dist/cli-bundle/chunks/{create-LBVCYMEG.js.map → create-AQ5SIGZC.js.map} +0 -0
  582. /package/dist/cli-bundle/chunks/{create-J5U6ND4K.js.map → create-KOGQ3JKD.js.map} +0 -0
  583. /package/dist/cli-bundle/chunks/{delete-WNHB3LYW.js.map → delete-6G3MBZ6S.js.map} +0 -0
  584. /package/dist/cli-bundle/chunks/{delete-PMJBNY5G.js.map → delete-YYYFOSEA.js.map} +0 -0
  585. /package/dist/cli-bundle/chunks/{deps-JZ7TMVCB.js.map → deps-MQ4ZIGZB.js.map} +0 -0
  586. /package/dist/cli-bundle/chunks/{deps-OA26IS25.js.map → deps-NIIKXLPB.js.map} +0 -0
  587. /package/dist/cli-bundle/chunks/{docs-FEWB2DQB.js.map → docs-53NUGMIQ.js.map} +0 -0
  588. /package/dist/cli-bundle/chunks/{docs-HA2AIDBB.js.map → docs-OWRGDMNY.js.map} +0 -0
  589. /package/dist/cli-bundle/chunks/{files-EFIWKFTM.js.map → files-3PXGXYDB.js.map} +0 -0
  590. /package/dist/cli-bundle/chunks/{files-6YFBJRBG.js.map → files-EGLKHD7O.js.map} +0 -0
  591. /package/dist/cli-bundle/chunks/{focus-POIW5LTJ.js.map → focus-KZLIA6WS.js.map} +0 -0
  592. /package/dist/cli-bundle/chunks/{focus-4QJR7FOQ.js.map → focus-SRPASFTN.js.map} +0 -0
  593. /package/dist/cli-bundle/chunks/{history-compact-CKRPDTJN.js.map → history-compact-G4DULDCX.js.map} +0 -0
  594. /package/dist/cli-bundle/chunks/{history-compact-FWG2C7FZ.js.map → history-compact-HHIUOMZ7.js.map} +0 -0
  595. /package/dist/cli-bundle/chunks/{history-redact-BB3TGDAE.js.map → history-redact-IUSJ6X3E.js.map} +0 -0
  596. /package/dist/cli-bundle/chunks/{history-redact-D225BHOZ.js.map → history-redact-THHGRQXV.js.map} +0 -0
  597. /package/dist/cli-bundle/chunks/{history-repair-6GEAM7HE.js.map → history-repair-KG7SWXI6.js.map} +0 -0
  598. /package/dist/cli-bundle/chunks/{history-repair-RQXKQHL4.js.map → history-repair-LUQWRS7X.js.map} +0 -0
  599. /package/dist/cli-bundle/chunks/{learnings-JLNLCOL5.js.map → learnings-2MRNBFJF.js.map} +0 -0
  600. /package/dist/cli-bundle/chunks/{learnings-RSNLSWDC.js.map → learnings-ZVHSALJY.js.map} +0 -0
  601. /package/dist/cli-bundle/chunks/{notes-GB47XXQQ.js.map → notes-73JWKWUD.js.map} +0 -0
  602. /package/dist/cli-bundle/chunks/{notes-2WDH6DXU.js.map → notes-BAKUL5DJ.js.map} +0 -0
  603. /package/dist/cli-bundle/chunks/{plan-VDCJ2PCN.js.map → plan-AZPMCG37.js.map} +0 -0
  604. /package/dist/cli-bundle/chunks/{plan-DOVI2VMW.js.map → plan-LEAGLPGP.js.map} +0 -0
  605. /package/dist/cli-bundle/chunks/{profile-FAU7NZML.js.map → profile-AVCIIZID.js.map} +0 -0
  606. /package/dist/cli-bundle/chunks/{profile-IVXQEL3D.js.map → profile-LFYO3HHX.js.map} +0 -0
  607. /package/dist/cli-bundle/chunks/{register-operations-ZIBBRSED.js.map → register-operations-KHZYR6MG.js.map} +0 -0
  608. /package/dist/cli-bundle/chunks/{register-operations-ZUJ5JWPE.js.map → register-operations-WPQ2LWZJ.js.map} +0 -0
  609. /package/dist/cli-bundle/chunks/{register-setup-BCVLFEYS.js.map → register-setup-PGDNOXDQ.js.map} +0 -0
  610. /package/dist/cli-bundle/chunks/{register-setup-TDCGWIOS.js.map → register-setup-TDN7WAO6.js.map} +0 -0
  611. /package/dist/cli-bundle/chunks/{restore-25DLT2Q2.js.map → restore-E3PRGDN3.js.map} +0 -0
  612. /package/dist/cli-bundle/chunks/{restore-YPMVUUEX.js.map → restore-KIUYTAEJ.js.map} +0 -0
  613. /package/dist/cli-bundle/chunks/{schema-FNU3WE4O.js.map → schema-5JNFQFUW.js.map} +0 -0
  614. /package/dist/cli-bundle/chunks/{schema-NBCM3RAD.js.map → schema-TMIW4XZC.js.map} +0 -0
  615. /package/dist/cli-bundle/chunks/{update-XHSIAIXE.js.map → update-SQYZA3ZW.js.map} +0 -0
  616. /package/dist/cli-bundle/chunks/{update-WWBYOPXO.js.map → update-XZJYS5X7.js.map} +0 -0
  617. /package/dist/cli-bundle/chunks/{update-many-TA7NGQBO.js.map → update-many-R24B3GBK.js.map} +0 -0
  618. /package/dist/cli-bundle/chunks/{update-many-OUGIU5SF.js.map → update-many-WQ3R3J6N.js.map} +0 -0
  619. /package/dist/{cli/commands → sdk/query}/search-pagination.d.ts +0 -0
  620. /package/dist/{cli/commands → sdk/query}/search-rendering.d.ts +0 -0
@@ -1,8 +1,20 @@
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]="9a21d12c-d2fd-5325-930c-dfc8bbfe8247")}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]="2289448d-a087-55eb-a092-70c2f25227d6")}catch(e){}}();
3
+ import {
4
+ computeWorkspaceGraphFingerprint,
5
+ parseDirection,
6
+ parseKinds,
7
+ parseMaxDepth,
8
+ parsePositiveInteger,
9
+ workspaceGraphCache
10
+ } from "./chunk-EX7OQT3Y.js";
3
11
  import {
4
12
  collectStaleVectorizationIds
5
- } from "./chunk-7Z4LKRS4.js";
13
+ } from "./chunk-XPUTSGJU.js";
14
+ import {
15
+ assembleWorkspaceRelationshipGraph,
16
+ createRelationshipKindRegistry
17
+ } from "./chunk-L5BTTDU5.js";
6
18
  import {
7
19
  buildListQueryFilters
8
20
  } from "./chunk-N7V7TI6J.js";
@@ -21,28 +33,28 @@ import {
21
33
  resolveContentFieldFilters,
22
34
  resolveMissingMetadataFilters,
23
35
  runList
24
- } from "./chunk-UXONS674.js";
36
+ } from "./chunk-NCVT6XEL.js";
25
37
  import {
26
38
  createQueryFingerprint,
27
39
  paginateQueryRows
28
- } from "./chunk-HDH3JUGG.js";
40
+ } from "./chunk-2IPNL3DR.js";
29
41
  import {
30
42
  getItemAt
31
- } from "./chunk-OW4JWD5M.js";
43
+ } from "./chunk-VAHZIPWS.js";
32
44
  import {
33
45
  hasMissingMetadataFilter,
34
46
  itemMatchesMissingMetadata,
35
47
  lifecycleClassifierFromStatusRegistry
36
- } from "./chunk-2VPAVL7O.js";
48
+ } from "./chunk-CKX4WOPC.js";
37
49
  import {
38
50
  readHistoryEntries
39
- } from "./chunk-GOSLKLFE.js";
51
+ } from "./chunk-KH6QAHME.js";
40
52
  import {
41
53
  parseLimit
42
- } from "./chunk-NVPZIJVR.js";
54
+ } from "./chunk-PT7MCCGD.js";
43
55
  import {
44
56
  recordContextUsageTouches
45
- } from "./chunk-RLCHOOHC.js";
57
+ } from "./chunk-YJSURTBB.js";
46
58
  import {
47
59
  resolveRegisteredSearchProvider,
48
60
  resolveRegisteredVectorStoreAdapter
@@ -59,7 +71,10 @@ import {
59
71
  resolveSearchCorpusFields,
60
72
  resolveSettingsWithSemanticRuntimeDefaults,
61
73
  resolveVectorStores
62
- } from "./chunk-JXQUXVMI.js";
74
+ } from "./chunk-E4FXM2XB.js";
75
+ import {
76
+ GRAPH_SUBCOMMAND_VALUES
77
+ } from "./chunk-7UCY6DR5.js";
63
78
  import {
64
79
  splitCommaList
65
80
  } from "./chunk-NETP4DY4.js";
@@ -81,7 +96,7 @@ import {
81
96
  resolveIsoOrRelative,
82
97
  runActiveOnReadHooks,
83
98
  toItemRecord
84
- } from "./chunk-Q7A43DS4.js";
99
+ } from "./chunk-P22HGFFI.js";
85
100
  import {
86
101
  EXIT_CODE,
87
102
  ITEM_METADATA_KEY_ORDER,
@@ -102,7 +117,7 @@ import {
102
117
  resolveRuntimeStatusRegistry,
103
118
  toNonEmptyString,
104
119
  toNonEmptyStringOrUndefined
105
- } from "./chunk-QKECXBBG.js";
120
+ } from "./chunk-KX62NMZC.js";
106
121
 
107
122
  // dist/cli/commands/aggregate.js
108
123
  var AGGREGATE_GROUP_FIELDS = [
@@ -446,7 +461,7 @@ async function runAggregate(options, global) {
446
461
  };
447
462
  }
448
463
 
449
- // dist/cli/commands/search.js
464
+ // dist/sdk/query/search.js
450
465
  import fs from "node:fs/promises";
451
466
  import path from "node:path";
452
467
 
@@ -768,7 +783,7 @@ function resolveBm25Params(settings) {
768
783
  };
769
784
  }
770
785
 
771
- // dist/cli/commands/search-rendering.js
786
+ // dist/sdk/query/search-rendering.js
772
787
  function isAllStatuses(value) {
773
788
  if (typeof value !== "string")
774
789
  return false;
@@ -858,7 +873,7 @@ function buildVerboseSearchFilters(params) {
858
873
  };
859
874
  }
860
875
 
861
- // dist/cli/commands/search-pagination.js
876
+ // dist/sdk/query/search-pagination.js
862
877
  function createSearchCursorFingerprint(options) {
863
878
  const normalizedOptions = {
864
879
  ...options.searchOptions
@@ -893,7 +908,7 @@ function resolveSearchPage(options) {
893
908
  };
894
909
  }
895
910
 
896
- // dist/cli/commands/search.js
911
+ // dist/sdk/query/search.js
897
912
  var DEFAULT_COMPACT_SEARCH_FIELDS = [
898
913
  "id",
899
914
  "title",
@@ -1483,6 +1498,7 @@ function highlightFieldSnippet(text, tokens) {
1483
1498
  }
1484
1499
  const lowerText = text.toLowerCase();
1485
1500
  let firstMatchIndex = -1;
1501
+ let firstMatchLength = 0;
1486
1502
  for (const token of tokens) {
1487
1503
  if (token.length === 0) {
1488
1504
  continue;
@@ -1490,13 +1506,14 @@ function highlightFieldSnippet(text, tokens) {
1490
1506
  const index = lowerText.indexOf(token);
1491
1507
  if (index >= 0 && (firstMatchIndex < 0 || index < firstMatchIndex)) {
1492
1508
  firstMatchIndex = index;
1509
+ firstMatchLength = token.length;
1493
1510
  }
1494
1511
  }
1495
1512
  if (firstMatchIndex < 0) {
1496
1513
  return null;
1497
1514
  }
1498
1515
  const windowStart = Math.max(0, firstMatchIndex - HIGHLIGHT_SNIPPET_RADIUS);
1499
- const windowEnd = Math.min(text.length, firstMatchIndex + HIGHLIGHT_SNIPPET_RADIUS);
1516
+ const windowEnd = Math.min(text.length, firstMatchIndex + firstMatchLength + HIGHLIGHT_SNIPPET_RADIUS);
1500
1517
  const marked = markTokenRuns(text.slice(windowStart, windowEnd), tokens);
1501
1518
  const prefix = windowStart > 0 ? "\u2026" : "";
1502
1519
  const suffix = windowEnd < text.length ? "\u2026" : "";
@@ -2269,7 +2286,7 @@ function readSearchFieldValue(hit, field) {
2269
2286
  }
2270
2287
  function projectSearchHits(hits, projection) {
2271
2288
  if (projection.mode === "full") {
2272
- return hits.map(({ matched_all_terms: _matchedAllTerms, ...hit }) => hit);
2289
+ return hits.map(({ matched_all_terms: _matchedAllTerms, exact_id_match: _exactIdMatch, ...hit }) => hit);
2273
2290
  }
2274
2291
  return hits.map((hit) => {
2275
2292
  const projected = {};
@@ -2668,7 +2685,7 @@ async function runSearch(rawQuery, rawOptions, global) {
2668
2685
  warnings,
2669
2686
  runtimeFieldFilters: runtime.runtimeFieldFilters
2670
2687
  };
2671
- if (runtime.effectiveMode === "keyword" && (corpus.filteredDocuments.length === 0 || prepared.limit === 0)) {
2688
+ if (runtime.effectiveMode === "keyword" && (corpus.filteredDocuments.length === 0 || prepared.limit === 0 && !prepared.countOnly)) {
2672
2689
  return buildEmptySearchResultFromContext({ ...responseBase, effectiveMode: runtime.effectiveMode }, prepared.countOnly);
2673
2690
  }
2674
2691
  const keywordHits = await computeKeywordSearchHits(prepared, runtime, corpus.filteredDocuments);
@@ -2680,7 +2697,7 @@ async function runSearch(rawQuery, rawOptions, global) {
2680
2697
  warnings,
2681
2698
  modeWasExplicit: prepared.modeWasExplicit
2682
2699
  });
2683
- if (modeResult.effectiveMode !== "keyword" && modeResult.hits.length === 0 && (corpus.filteredDocuments.length === 0 || prepared.limit === 0)) {
2700
+ if (modeResult.effectiveMode !== "keyword" && modeResult.hits.length === 0 && (corpus.filteredDocuments.length === 0 || prepared.limit === 0 && !prepared.countOnly)) {
2684
2701
  return buildEmptySearchResultFromContext({ ...responseBase, effectiveMode: modeResult.effectiveMode }, prepared.countOnly);
2685
2702
  }
2686
2703
  const thresholded = modeResult.hits.filter((entry) => entry.exact_id_match === true || entry.score >= runtime.scoreThreshold);
@@ -2702,7 +2719,7 @@ async function runSearch(rawQuery, rawOptions, global) {
2702
2719
  return buildSearchResultForHits(response, projectedItems, total, page.limited.length, effectiveProjection, page.pageExtras);
2703
2720
  }
2704
2721
 
2705
- // dist/cli/commands/eval.js
2722
+ // dist/sdk/eval.js
2706
2723
  import fs2 from "node:fs/promises";
2707
2724
  import path2 from "node:path";
2708
2725
 
@@ -2842,14 +2859,14 @@ function parseEvalQuerySet(raw) {
2842
2859
  };
2843
2860
  }
2844
2861
 
2845
- // dist/cli/commands/eval.js
2862
+ // dist/sdk/eval.js
2846
2863
  var DEFAULT_EVAL_QUERIES_RELATIVE_PATH = path2.join("search", "eval-queries.json");
2847
2864
  var VALID_EVAL_MODES2 = /* @__PURE__ */ new Set([
2848
2865
  "keyword",
2849
2866
  "semantic",
2850
2867
  "hybrid"
2851
2868
  ]);
2852
- function parseEvalMode(raw) {
2869
+ var parseEvalMode = (raw) => {
2853
2870
  if (raw === void 0) {
2854
2871
  return "keyword";
2855
2872
  }
@@ -2858,8 +2875,8 @@ function parseEvalMode(raw) {
2858
2875
  throw new PmCliError("Eval --mode must be one of keyword|semantic|hybrid", EXIT_CODE.USAGE);
2859
2876
  }
2860
2877
  return normalized;
2861
- }
2862
- function parseEvalK(raw) {
2878
+ };
2879
+ var parseEvalK = (raw) => {
2863
2880
  if (raw === void 0 || raw === "") {
2864
2881
  return DEFAULT_EVAL_K;
2865
2882
  }
@@ -2868,28 +2885,31 @@ function parseEvalK(raw) {
2868
2885
  throw new PmCliError("Eval --k must be a positive integer", EXIT_CODE.USAGE);
2869
2886
  }
2870
2887
  return parsed;
2871
- }
2872
- function parseFailUnder(raw) {
2888
+ };
2889
+ var parseFailUnder = (raw) => {
2873
2890
  if (raw === void 0 || raw === "") {
2874
2891
  return void 0;
2875
2892
  }
2876
- const parsed = typeof raw === "number" ? raw : Number(String(raw).trim());
2877
- if (!Number.isFinite(parsed) || parsed < 0 || parsed > 1) {
2893
+ const normalized = String(raw).trim();
2894
+ const parsed = Number(normalized);
2895
+ if ([
2896
+ normalized.length === 0,
2897
+ !Number.isFinite(parsed),
2898
+ parsed < 0,
2899
+ parsed > 1
2900
+ ].includes(true)) {
2878
2901
  throw new PmCliError("Eval --fail-under must be a number in the range [0, 1]", EXIT_CODE.USAGE);
2879
2902
  }
2880
2903
  return parsed;
2881
- }
2882
- function roundMetric(value) {
2883
- return Math.round(value * 1e4) / 1e4;
2884
- }
2885
- async function loadEvalQuerySet(queriesPath) {
2886
- let raw;
2904
+ };
2905
+ var roundMetric = (value) => Math.round(value * 1e4) / 1e4;
2906
+ var readEvalQuerySetFile = async (queriesPath) => {
2887
2907
  try {
2888
- raw = await fs2.readFile(queriesPath, "utf8");
2908
+ return await fs2.readFile(queriesPath, "utf8");
2889
2909
  } catch {
2890
2910
  throw new PmCliError(`Eval query set not found at ${queriesPath}`, EXIT_CODE.NOT_FOUND, {
2891
2911
  examples: [
2892
- `echo '[{"query":"offline search","relevant_ids":["pm-75k9"]}]' > ` + queriesPath,
2912
+ `echo '[{"query":"offline search","relevant_ids":["pm-75k9"]}]' > ${queriesPath}`,
2893
2913
  "pm eval --queries ./my-eval.json"
2894
2914
  ],
2895
2915
  nextSteps: [
@@ -2897,37 +2917,39 @@ async function loadEvalQuerySet(queriesPath) {
2897
2917
  ]
2898
2918
  });
2899
2919
  }
2900
- let parsed;
2920
+ };
2921
+ var parseEvalQuerySetJson = (raw, queriesPath) => {
2901
2922
  try {
2902
- parsed = JSON.parse(raw);
2923
+ return JSON.parse(raw);
2903
2924
  } catch (error) {
2904
- throw new PmCliError(`Eval query set at ${queriesPath} is not valid JSON: ${error.message}`, EXIT_CODE.USAGE);
2925
+ throw new PmCliError(
2926
+ /* c8 ignore next -- JSON.parse throws Error instances; String fallback protects nonstandard hosts. */
2927
+ `Eval query set at ${queriesPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,
2928
+ EXIT_CODE.USAGE
2929
+ );
2905
2930
  }
2931
+ };
2932
+ var validateEvalQuerySet = (parsed) => {
2906
2933
  try {
2907
2934
  return parseEvalQuerySet(parsed);
2908
2935
  } catch (error) {
2909
- throw new PmCliError(error.message, EXIT_CODE.USAGE);
2910
- }
2911
- }
2912
- async function runEval(options, global) {
2913
- const pmRoot = resolvePmRoot(process.cwd(), global.path);
2914
- if (!await pathExists(getSettingsPath(pmRoot))) {
2915
- throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
2936
+ throw new PmCliError(
2937
+ /* c8 ignore next -- parseEvalQuerySet throws Error instances; String fallback protects nonstandard hosts. */
2938
+ error instanceof Error ? error.message : String(error),
2939
+ EXIT_CODE.USAGE
2940
+ );
2916
2941
  }
2917
- const k = parseEvalK(options.k);
2918
- const defaultMode = parseEvalMode(options.mode);
2919
- const failUnder = parseFailUnder(options.failUnder);
2920
- const queriesPath = options.queries ? path2.resolve(process.cwd(), options.queries) : path2.join(pmRoot, DEFAULT_EVAL_QUERIES_RELATIVE_PATH);
2921
- const querySet = await loadEvalQuerySet(queriesPath);
2922
- const reports = [];
2923
- const rawMetrics = [];
2924
- for (const evalQuery of querySet.queries) {
2925
- const mode = evalQuery.mode ?? defaultMode;
2926
- const searchResult = await runSearch(evalQuery.query, { mode, limit: String(k), fields: "id" }, global);
2927
- const rankedIds = searchResult.items.map((item) => item.id).filter((id) => typeof id === "string");
2928
- const metrics = evaluateRanking(rankedIds, new Set(evalQuery.relevant_ids), k);
2929
- rawMetrics.push(metrics);
2930
- reports.push({
2942
+ };
2943
+ var loadEvalQuerySet = async (queriesPath) => validateEvalQuerySet(parseEvalQuerySetJson(await readEvalQuerySetFile(queriesPath), queriesPath));
2944
+ var resolveEvalQueriesPath = (pmRoot, queries) => queries ? path2.resolve(process.cwd(), queries) : path2.join(pmRoot, DEFAULT_EVAL_QUERIES_RELATIVE_PATH);
2945
+ var evaluateEvalQuery = async (evalQuery, defaultMode, k, global) => {
2946
+ const mode = evalQuery.mode ?? defaultMode;
2947
+ const searchResult = await runSearch(evalQuery.query, { mode, limit: String(k), fields: "id" }, global);
2948
+ const rankedIds = searchResult.items.map((item) => item.id).filter((id) => typeof id === "string");
2949
+ const metrics = evaluateRanking(rankedIds, new Set(evalQuery.relevant_ids), k);
2950
+ return {
2951
+ metrics,
2952
+ report: {
2931
2953
  query: evalQuery.query,
2932
2954
  mode,
2933
2955
  relevant_total: metrics.relevant_total,
@@ -2936,13 +2958,14 @@ async function runEval(options, global) {
2936
2958
  mrr: roundMetric(metrics.mrr),
2937
2959
  precision: roundMetric(metrics.precision),
2938
2960
  recall: roundMetric(metrics.recall)
2939
- });
2940
- }
2961
+ }
2962
+ };
2963
+ };
2964
+ var buildEvalResult = (k, reports, rawMetrics, failUnder) => {
2941
2965
  const aggregate = aggregateEvalMetrics(rawMetrics);
2942
- const passed = failUnder === void 0 || aggregate.ndcg >= failUnder;
2943
2966
  return {
2944
2967
  k,
2945
- query_count: querySet.queries.length,
2968
+ query_count: reports.length,
2946
2969
  aggregate: {
2947
2970
  ndcg: roundMetric(aggregate.ndcg),
2948
2971
  mrr: roundMetric(aggregate.mrr),
@@ -2951,9 +2974,28 @@ async function runEval(options, global) {
2951
2974
  },
2952
2975
  queries: reports,
2953
2976
  ...failUnder !== void 0 ? { fail_under: failUnder } : {},
2954
- passed
2977
+ passed: failUnder === void 0 || aggregate.ndcg >= failUnder
2955
2978
  };
2956
- }
2979
+ };
2980
+ var runEval = async (options, global) => {
2981
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
2982
+ if (!await pathExists(getSettingsPath(pmRoot))) {
2983
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
2984
+ }
2985
+ const k = parseEvalK(options.k);
2986
+ const defaultMode = parseEvalMode(options.mode);
2987
+ const failUnder = parseFailUnder(options.failUnder);
2988
+ const queriesPath = resolveEvalQueriesPath(pmRoot, options.queries);
2989
+ const querySet = await loadEvalQuerySet(queriesPath);
2990
+ const reports = [];
2991
+ const rawMetrics = [];
2992
+ for (const evalQuery of querySet.queries) {
2993
+ const { report, metrics } = await evaluateEvalQuery(evalQuery, defaultMode, k, global);
2994
+ rawMetrics.push(metrics);
2995
+ reports.push(report);
2996
+ }
2997
+ return buildEvalResult(k, reports, rawMetrics, failUnder);
2998
+ };
2957
2999
 
2958
3000
  // dist/sdk/item-children.js
2959
3001
  var MAX_CHILD_PROJECTION_ITEMS = 1e6;
@@ -3342,17 +3384,1656 @@ async function runGet(id, global, options = {}) {
3342
3384
  return result;
3343
3385
  }
3344
3386
 
3387
+ // dist/sdk/relationship-analytics.js
3388
+ function appendNeighbor(adjacency, source, target) {
3389
+ adjacency.get(source).add(target);
3390
+ }
3391
+ function createAdjacency(nodes) {
3392
+ return new Map(nodes.map((node) => [node, /* @__PURE__ */ new Set()]));
3393
+ }
3394
+ function sortComponents(components) {
3395
+ for (const component of components)
3396
+ component.sort();
3397
+ return components.sort((left, right) => right.length - left.length || left[0].localeCompare(right[0]));
3398
+ }
3399
+ function stableJsonValue(value) {
3400
+ if (Array.isArray(value))
3401
+ return value.map((entry) => stableJsonValue(entry));
3402
+ if (value === null || typeof value !== "object")
3403
+ return value;
3404
+ const toJSON = value.toJSON;
3405
+ if (typeof toJSON === "function")
3406
+ return stableJsonValue(toJSON.call(value));
3407
+ return Object.fromEntries(Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => [key, stableJsonValue(entry)]));
3408
+ }
3409
+ function relationshipEdgeKey(edge) {
3410
+ return JSON.stringify(stableJsonValue(edge));
3411
+ }
3412
+ function appendFinishingOrder(start, adjacency, visited, order) {
3413
+ const stack = [{ id: start, expanded: false }];
3414
+ while (stack.length > 0) {
3415
+ const current = stack.pop();
3416
+ if (current.expanded) {
3417
+ order.push(current.id);
3418
+ continue;
3419
+ }
3420
+ if (visited.has(current.id))
3421
+ continue;
3422
+ visited.add(current.id);
3423
+ stack.push({ id: current.id, expanded: true });
3424
+ const neighbors = [...adjacency.get(current.id)].sort().reverse();
3425
+ for (const neighbor of neighbors)
3426
+ if (!visited.has(neighbor))
3427
+ stack.push({ id: neighbor, expanded: false });
3428
+ }
3429
+ }
3430
+ function computeFinishingOrder(nodes, adjacency) {
3431
+ const visited = /* @__PURE__ */ new Set();
3432
+ const order = [];
3433
+ for (const start of nodes)
3434
+ if (!visited.has(start))
3435
+ appendFinishingOrder(start, adjacency, visited, order);
3436
+ return order;
3437
+ }
3438
+ function collectReverseComponents(order, reverse) {
3439
+ const visited = /* @__PURE__ */ new Set();
3440
+ const components = [];
3441
+ for (const start of [...order].reverse()) {
3442
+ if (visited.has(start))
3443
+ continue;
3444
+ const component = [];
3445
+ const stack = [start];
3446
+ visited.add(start);
3447
+ while (stack.length > 0) {
3448
+ const current = stack.pop();
3449
+ component.push(current);
3450
+ for (const neighbor of reverse.get(current)) {
3451
+ if (visited.has(neighbor))
3452
+ continue;
3453
+ visited.add(neighbor);
3454
+ stack.push(neighbor);
3455
+ }
3456
+ }
3457
+ components.push(component);
3458
+ }
3459
+ return sortComponents(components);
3460
+ }
3461
+ function stronglyConnectedComponents(nodes, adjacency) {
3462
+ const reverse = createAdjacency(nodes);
3463
+ for (const [source, targets] of adjacency)
3464
+ for (const target of targets)
3465
+ appendNeighbor(reverse, target, source);
3466
+ return collectReverseComponents(computeFinishingOrder(nodes, adjacency), reverse);
3467
+ }
3468
+ function buildExecutionAdjacency(graph, registry) {
3469
+ const adjacency = createAdjacency(graph.nodes());
3470
+ for (const edge of graph.edges()) {
3471
+ const definition = registry.require(edge.kind);
3472
+ if (!definition.ordering)
3473
+ continue;
3474
+ const sourceFirst = (definition.precedence ?? "source_before_target") === "source_before_target";
3475
+ appendNeighbor(adjacency, sourceFirst ? edge.source : edge.target, sourceFirst ? edge.target : edge.source);
3476
+ }
3477
+ return adjacency;
3478
+ }
3479
+ function topologicalLayers(nodes, adjacency) {
3480
+ const indegree = new Map(nodes.map((node) => [node, 0]));
3481
+ for (const targets of adjacency.values())
3482
+ for (const target of targets)
3483
+ indegree.set(target, indegree.get(target) + 1);
3484
+ let frontier = nodes.filter((node) => indegree.get(node) === 0).sort();
3485
+ const layers = [];
3486
+ while (frontier.length > 0) {
3487
+ layers.push(frontier);
3488
+ const next = [];
3489
+ for (const source of frontier) {
3490
+ for (const target of adjacency.get(source)) {
3491
+ const remaining = indegree.get(target) - 1;
3492
+ indegree.set(target, remaining);
3493
+ if (remaining === 0)
3494
+ next.push(target);
3495
+ }
3496
+ }
3497
+ frontier = next.sort();
3498
+ }
3499
+ return layers;
3500
+ }
3501
+ function longestPath(order, adjacency) {
3502
+ const depth = new Map(order.map((node) => [node, 0]));
3503
+ const parent = /* @__PURE__ */ new Map();
3504
+ for (const source of order) {
3505
+ for (const target of adjacency.get(source)) {
3506
+ if (!depth.has(target))
3507
+ continue;
3508
+ const candidate = depth.get(source) + 1;
3509
+ const currentParent = parent.get(target);
3510
+ if (candidate > depth.get(target) || candidate === depth.get(target) && (currentParent === void 0 || source.localeCompare(currentParent) < 0)) {
3511
+ depth.set(target, candidate);
3512
+ parent.set(target, source);
3513
+ }
3514
+ }
3515
+ }
3516
+ const end = [...order].sort((left, right) => depth.get(right) - depth.get(left) || left.localeCompare(right))[0];
3517
+ const path3 = end === void 0 ? [] : [end];
3518
+ while (path3[0] !== void 0 && parent.has(path3[0]))
3519
+ path3.unshift(parent.get(path3[0]));
3520
+ return { depth: Object.fromEntries(depth), path: path3 };
3521
+ }
3522
+ function reconstructImpactPath(root, target, parents) {
3523
+ const path3 = [target];
3524
+ let cursor = target;
3525
+ while (cursor !== root) {
3526
+ cursor = parents.get(cursor);
3527
+ path3.push(cursor);
3528
+ }
3529
+ return path3.reverse();
3530
+ }
3531
+ function analyzeRelationshipExecution(graph, options = {}) {
3532
+ const registry = options.registry ?? createRelationshipKindRegistry();
3533
+ const nodes = [...graph.nodes()];
3534
+ const adjacency = buildExecutionAdjacency(graph, registry);
3535
+ const layers = topologicalLayers(nodes, adjacency);
3536
+ const order = layers.flat();
3537
+ const acyclic = order.length === nodes.length;
3538
+ const cycles = acyclic ? [] : stronglyConnectedComponents(nodes, adjacency).filter((component) => component.length > 1 || adjacency.get(component[0]).has(component[0]));
3539
+ const longest = longestPath(order, adjacency);
3540
+ return {
3541
+ exact: true,
3542
+ acyclic,
3543
+ order,
3544
+ layers,
3545
+ frontier: layers[0] ?? [],
3546
+ depth: longest.depth,
3547
+ criticalPath: longest.path,
3548
+ criticalPathLength: Math.max(0, longest.path.length - 1),
3549
+ cycles,
3550
+ provenance: { algorithm: "kahn-longest-path", edgeFamily: "ordering" }
3551
+ };
3552
+ }
3553
+ function analyzeGraphImpact(graph, root, options = {}) {
3554
+ const direction = options.direction ?? "outgoing";
3555
+ const maxDepth = options.maxDepth ?? Number.POSITIVE_INFINITY;
3556
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
3557
+ const queue = [{ id: root, depth: 0 }];
3558
+ const seen = /* @__PURE__ */ new Set([root]);
3559
+ const parents = /* @__PURE__ */ new Map();
3560
+ const affected = [];
3561
+ let visitedNodes = 0;
3562
+ let inspectedEdges = 0;
3563
+ let truncated = false;
3564
+ traversal: for (let index = 0; index < queue.length; index += 1) {
3565
+ options.signal?.throwIfAborted();
3566
+ const current = queue[index];
3567
+ visitedNodes += 1;
3568
+ const adjacent = graph.adjacency(current.id, {
3569
+ direction,
3570
+ kinds: options.kinds,
3571
+ signal: options.signal
3572
+ });
3573
+ inspectedEdges += adjacent.meta.inspectedEdges;
3574
+ if (current.depth >= maxDepth) {
3575
+ if (adjacent.value.some((id) => !seen.has(id)))
3576
+ truncated = true;
3577
+ continue;
3578
+ }
3579
+ for (const id of adjacent.value) {
3580
+ if (seen.has(id))
3581
+ continue;
3582
+ if (affected.length >= limit) {
3583
+ truncated = true;
3584
+ break traversal;
3585
+ }
3586
+ seen.add(id);
3587
+ parents.set(id, current.id);
3588
+ const depth = current.depth + 1;
3589
+ affected.push({
3590
+ id,
3591
+ distance: depth,
3592
+ path: reconstructImpactPath(root, id, parents)
3593
+ });
3594
+ queue.push({ id, depth });
3595
+ }
3596
+ }
3597
+ return {
3598
+ root,
3599
+ affected,
3600
+ exact: true,
3601
+ truncated,
3602
+ cost: { visitedNodes, inspectedEdges }
3603
+ };
3604
+ }
3605
+ function analyzeKnowledgeGraph(graph) {
3606
+ const nodes = [...graph.nodes()];
3607
+ const weak = createAdjacency(nodes);
3608
+ const directed = createAdjacency(nodes);
3609
+ for (const edge of graph.edges()) {
3610
+ appendNeighbor(weak, edge.source, edge.target);
3611
+ appendNeighbor(weak, edge.target, edge.source);
3612
+ appendNeighbor(directed, edge.source, edge.target);
3613
+ }
3614
+ const components = [];
3615
+ const visited = /* @__PURE__ */ new Set();
3616
+ for (const start of nodes) {
3617
+ if (visited.has(start))
3618
+ continue;
3619
+ const component = [];
3620
+ const stack = [start];
3621
+ visited.add(start);
3622
+ while (stack.length > 0) {
3623
+ const current = stack.pop();
3624
+ component.push(current);
3625
+ for (const neighbor of weak.get(current)) {
3626
+ if (visited.has(neighbor))
3627
+ continue;
3628
+ visited.add(neighbor);
3629
+ stack.push(neighbor);
3630
+ }
3631
+ }
3632
+ components.push(component);
3633
+ }
3634
+ const degrees = nodes.map((id) => ({ id, degree: weak.get(id).size }));
3635
+ const maximum = Math.max(0, ...degrees.map(({ degree }) => degree));
3636
+ return {
3637
+ components: sortComponents(components),
3638
+ stronglyConnected: stronglyConnectedComponents(nodes, directed),
3639
+ orphans: degrees.filter(({ degree }) => degree === 0).map(({ id }) => id),
3640
+ hubs: degrees.filter(({ degree }) => degree > 0 && degree === maximum),
3641
+ exact: true,
3642
+ provenance: { algorithm: "component-degree", edgeFamily: "all" }
3643
+ };
3644
+ }
3645
+ function compareRelationshipSnapshots(before, after) {
3646
+ const earlier = new Map(before.edges.map((edge) => [relationshipEdgeKey(edge), edge]));
3647
+ const later = new Map(after.edges.map((edge) => [relationshipEdgeKey(edge), edge]));
3648
+ return {
3649
+ fromVersion: before.version,
3650
+ toVersion: after.version,
3651
+ added: [...later].filter(([key]) => !earlier.has(key)).map(([, edge]) => edge),
3652
+ removed: [...earlier].filter(([key]) => !later.has(key)).map(([, edge]) => edge),
3653
+ unchangedCount: [...earlier.keys()].filter((key) => later.has(key)).length,
3654
+ exact: true
3655
+ };
3656
+ }
3657
+
3658
+ // dist/sdk/graph/traversal.js
3659
+ var DEFAULT_MAX_PATHS = 5;
3660
+ var DEFAULT_MAX_VISITED_PATHS = 1e4;
3661
+ var DEFAULT_PATH_MAX_DEPTH = 8;
3662
+ function assertPathBound(name, value) {
3663
+ if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0)
3664
+ throw new TypeError(`Invalid path ${name} bound: ${String(value)}`);
3665
+ }
3666
+ function hierarchyParentEndpoint(edge, definition) {
3667
+ return definition.hierarchyDirection === "target_parent" ? edge.target : edge.source;
3668
+ }
3669
+ function orderingPredecessorEndpoint(edge, definition) {
3670
+ return (definition.precedence ?? "source_before_target") === "target_before_source" ? edge.target : edge.source;
3671
+ }
3672
+ function resolveFamilyKinds(graph, kinds, family) {
3673
+ if (kinds === void 0)
3674
+ return void 0;
3675
+ const registry = graph.registry();
3676
+ const resolved = /* @__PURE__ */ new Set();
3677
+ for (const kind of kinds) {
3678
+ const definition = registry.require(kind);
3679
+ if (!definition[family])
3680
+ throw new TypeError(`Relationship kind ${definition.kind} is not a ${family} kind`);
3681
+ resolved.add(definition.kind);
3682
+ }
3683
+ return resolved;
3684
+ }
3685
+ function expandSemanticNeighbors(graph, nodeId, familyKinds, family, matches) {
3686
+ const registry = graph.registry();
3687
+ const rows = graph.neighborEdges(nodeId, {
3688
+ direction: "both",
3689
+ ...familyKinds === void 0 ? {} : { kinds: [...familyKinds] }
3690
+ });
3691
+ const neighbors = [];
3692
+ const seen = /* @__PURE__ */ new Set();
3693
+ for (const row of rows.value) {
3694
+ const definition = registry.require(row.edge.kind);
3695
+ if (!definition[family])
3696
+ continue;
3697
+ if (!matches(row, definition, nodeId))
3698
+ continue;
3699
+ if (seen.has(row.id))
3700
+ continue;
3701
+ seen.add(row.id);
3702
+ neighbors.push(row.id);
3703
+ }
3704
+ return { neighbors, inspectedEdges: rows.meta.inspectedEdges };
3705
+ }
3706
+ function appendSemanticExpansion(expansion, currentDepth, maxDepth, limit, after, state) {
3707
+ if (currentDepth >= maxDepth) {
3708
+ if (expansion.neighbors.some((neighbor) => !state.seen.has(neighbor)))
3709
+ state.truncated = true;
3710
+ return false;
3711
+ }
3712
+ for (const neighbor of expansion.neighbors) {
3713
+ if (state.seen.has(neighbor))
3714
+ continue;
3715
+ state.seen.add(neighbor);
3716
+ state.queue.push({ id: neighbor, depth: currentDepth + 1 });
3717
+ if (!state.resumed) {
3718
+ if (neighbor === after)
3719
+ state.resumed = true;
3720
+ continue;
3721
+ }
3722
+ if (state.value.length >= limit) {
3723
+ state.truncated = true;
3724
+ return true;
3725
+ }
3726
+ state.value.push(neighbor);
3727
+ }
3728
+ return false;
3729
+ }
3730
+ function boundedSemanticWalk(graph, start, options, family, matches) {
3731
+ if (!graph.hasNode(start))
3732
+ throw new TypeError(`Relationship node not found: ${start}`);
3733
+ const familyKinds = resolveFamilyKinds(graph, options.kinds, family);
3734
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
3735
+ const maxDepth = options.maxDepth ?? Number.POSITIVE_INFINITY;
3736
+ const after = options.after;
3737
+ const state = {
3738
+ seen: /* @__PURE__ */ new Set([start]),
3739
+ value: [],
3740
+ queue: [{ id: start, depth: 0 }],
3741
+ resumed: after === void 0,
3742
+ truncated: false
3743
+ };
3744
+ let visitedNodes = 0;
3745
+ let inspectedEdges = 0;
3746
+ for (let index = 0; index < state.queue.length; index += 1) {
3747
+ options.signal?.throwIfAborted();
3748
+ const current = state.queue[index];
3749
+ visitedNodes += 1;
3750
+ const expansion = expandSemanticNeighbors(graph, current.id, familyKinds, family, matches);
3751
+ inspectedEdges += expansion.inspectedEdges;
3752
+ if (appendSemanticExpansion(expansion, current.depth, maxDepth, limit, after, state))
3753
+ break;
3754
+ }
3755
+ if (!state.resumed)
3756
+ throw new TypeError(`Traversal cursor not found in sequence: ${after}`);
3757
+ return {
3758
+ value: state.value,
3759
+ meta: {
3760
+ visitedNodes,
3761
+ inspectedEdges,
3762
+ truncated: state.truncated,
3763
+ nextCursor: state.value.at(-1)
3764
+ }
3765
+ };
3766
+ }
3767
+ function assertPathEndpoint(graph, id) {
3768
+ if (!graph.hasNode(id))
3769
+ throw new TypeError(`Relationship node not found: ${id}`);
3770
+ }
3771
+ function readPathContinuations(graph, partial, options, direction, state) {
3772
+ const rows = graph.neighborEdges(partial.nodes.at(-1), {
3773
+ direction,
3774
+ ...options.kinds === void 0 ? {} : { kinds: options.kinds }
3775
+ });
3776
+ state.inspectedEdges += rows.meta.inspectedEdges;
3777
+ return rows.value.filter((row) => !partial.nodeSet.has(row.id));
3778
+ }
3779
+ function expandPartialPath(graph, partial, target, options, direction, probeLimit, state) {
3780
+ for (const row of readPathContinuations(graph, partial, options, direction, state)) {
3781
+ const nodes = [...partial.nodes, row.id];
3782
+ const nodeSet = new Set(partial.nodeSet).add(row.id);
3783
+ const edges = [...partial.edges, row.edge];
3784
+ if (row.id === target) {
3785
+ state.value.push({ nodes, edges, length: edges.length });
3786
+ if (state.value.length >= probeLimit)
3787
+ return true;
3788
+ } else {
3789
+ state.queue.push({ nodes, nodeSet, edges });
3790
+ }
3791
+ }
3792
+ return false;
3793
+ }
3794
+ function hierarchyAncestors(graph, id, options = {}) {
3795
+ return boundedSemanticWalk(graph, id, options, "hierarchy", (row, definition) => hierarchyParentEndpoint(row.edge, definition) === row.id);
3796
+ }
3797
+ function hierarchyDescendants(graph, id, options = {}) {
3798
+ return boundedSemanticWalk(graph, id, options, "hierarchy", (row, definition, nodeId) => hierarchyParentEndpoint(row.edge, definition) === nodeId);
3799
+ }
3800
+ function orderingPredecessors(graph, id, options = {}) {
3801
+ return boundedSemanticWalk(graph, id, options, "ordering", (row, definition) => orderingPredecessorEndpoint(row.edge, definition) === row.id);
3802
+ }
3803
+ function orderingSuccessors(graph, id, options = {}) {
3804
+ return boundedSemanticWalk(graph, id, options, "ordering", (row, definition, nodeId) => orderingPredecessorEndpoint(row.edge, definition) === nodeId);
3805
+ }
3806
+ function enumerateNonZeroRelationshipPaths(graph, source, target, options, maxPaths, maxVisitedPaths, maxDepth, direction) {
3807
+ const state = {
3808
+ value: [],
3809
+ queue: [{ nodes: [source], nodeSet: /* @__PURE__ */ new Set([source]), edges: [] }],
3810
+ inspectedEdges: 0
3811
+ };
3812
+ let visitedNodes = 0;
3813
+ let truncated = false;
3814
+ const probeLimit = maxPaths + 1;
3815
+ for (let index = 0; index < state.queue.length; index += 1) {
3816
+ options.signal?.throwIfAborted();
3817
+ if (state.value.length >= probeLimit || visitedNodes >= maxVisitedPaths) {
3818
+ truncated = true;
3819
+ break;
3820
+ }
3821
+ const partial = state.queue[index];
3822
+ visitedNodes += 1;
3823
+ if (partial.edges.length >= maxDepth) {
3824
+ if (readPathContinuations(graph, partial, options, direction, state).length > 0)
3825
+ truncated = true;
3826
+ continue;
3827
+ }
3828
+ if (expandPartialPath(graph, partial, target, options, direction, probeLimit, state)) {
3829
+ truncated = true;
3830
+ break;
3831
+ }
3832
+ }
3833
+ return {
3834
+ value: state.value.slice(0, maxPaths),
3835
+ meta: { visitedNodes, inspectedEdges: state.inspectedEdges, truncated }
3836
+ };
3837
+ }
3838
+ function enumerateRelationshipPaths(graph, source, target, options = {}) {
3839
+ assertPathEndpoint(graph, source);
3840
+ assertPathEndpoint(graph, target);
3841
+ const maxPaths = options.maxPaths ?? DEFAULT_MAX_PATHS;
3842
+ const maxVisitedPaths = options.maxVisitedPaths ?? DEFAULT_MAX_VISITED_PATHS;
3843
+ const maxDepth = options.maxDepth ?? DEFAULT_PATH_MAX_DEPTH;
3844
+ assertPathBound("maxPaths", maxPaths);
3845
+ assertPathBound("maxVisitedPaths", maxVisitedPaths);
3846
+ assertPathBound("maxDepth", maxDepth);
3847
+ const direction = options.direction ?? "outgoing";
3848
+ options.signal?.throwIfAborted();
3849
+ for (const kind of options.kinds ?? [])
3850
+ graph.registry().require(kind);
3851
+ if (source === target) {
3852
+ if (maxPaths === 0) {
3853
+ return {
3854
+ value: [],
3855
+ meta: { visitedNodes: 1, inspectedEdges: 0, truncated: true }
3856
+ };
3857
+ }
3858
+ return {
3859
+ value: [{ nodes: [source], edges: [], length: 0 }],
3860
+ meta: { visitedNodes: 1, inspectedEdges: 0, truncated: false }
3861
+ };
3862
+ }
3863
+ return enumerateNonZeroRelationshipPaths(graph, source, target, options, maxPaths, maxVisitedPaths, maxDepth, direction);
3864
+ }
3865
+
3866
+ // dist/sdk/graph/analytics.js
3867
+ var DEFAULT_MAX_ITERATIONS = 16;
3868
+ var DEFAULT_MIN_COMMUNITY_SIZE = 2;
3869
+ var DEFAULT_REDUNDANCY_MAX_DEPTH = 8;
3870
+ function assertPositiveBound(name, value) {
3871
+ if (!Number.isInteger(value) || value < 1)
3872
+ throw new TypeError(`Invalid ${name} bound: ${String(value)}`);
3873
+ }
3874
+ function buildUndirectedAdjacency(graph, kinds) {
3875
+ const registry = graph.registry();
3876
+ const wanted = kinds === void 0 ? void 0 : new Set(kinds.map((kind) => registry.require(kind).kind));
3877
+ const adjacency = /* @__PURE__ */ new Map();
3878
+ for (const edge of graph.edges()) {
3879
+ if (edge.source === edge.target)
3880
+ continue;
3881
+ if (wanted !== void 0) {
3882
+ const definition = registry.require(edge.kind);
3883
+ const matches = wanted.has(definition.kind) || definition.inverse !== void 0 && wanted.has(definition.inverse);
3884
+ if (!matches)
3885
+ continue;
3886
+ }
3887
+ appendAdjacency(adjacency, edge.source, edge.target);
3888
+ appendAdjacency(adjacency, edge.target, edge.source);
3889
+ }
3890
+ for (const neighbors of adjacency.values())
3891
+ neighbors.sort();
3892
+ return adjacency;
3893
+ }
3894
+ function appendAdjacency(adjacency, from, to) {
3895
+ const neighbors = adjacency.get(from);
3896
+ if (neighbors === void 0)
3897
+ adjacency.set(from, [to]);
3898
+ else
3899
+ neighbors.push(to);
3900
+ }
3901
+ function dominantNeighborLabel(neighbors, labels) {
3902
+ const counts = /* @__PURE__ */ new Map();
3903
+ for (const neighbor of neighbors) {
3904
+ const label = labels.get(neighbor);
3905
+ counts.set(label, (counts.get(label) ?? 0) + 1);
3906
+ }
3907
+ let best;
3908
+ let bestCount = 0;
3909
+ for (const [label, count] of counts) {
3910
+ if (count > bestCount || count === bestCount && label < best) {
3911
+ best = label;
3912
+ bestCount = count;
3913
+ }
3914
+ }
3915
+ return best;
3916
+ }
3917
+ function collectCommunities(labels, minSize) {
3918
+ const groups = /* @__PURE__ */ new Map();
3919
+ for (const [id, label] of labels) {
3920
+ const members = groups.get(label);
3921
+ if (members === void 0)
3922
+ groups.set(label, [id]);
3923
+ else
3924
+ members.push(id);
3925
+ }
3926
+ const communities = [];
3927
+ for (const members of groups.values()) {
3928
+ if (members.length < minSize)
3929
+ continue;
3930
+ members.sort();
3931
+ communities.push({
3932
+ representative: members[0],
3933
+ size: members.length,
3934
+ members
3935
+ });
3936
+ }
3937
+ return communities.sort((left, right) => right.size - left.size || left.representative.localeCompare(right.representative));
3938
+ }
3939
+ function detectRelationshipCommunities(graph, options = {}) {
3940
+ const maxIterations = options.maxIterations ?? DEFAULT_MAX_ITERATIONS;
3941
+ const minSize = options.minSize ?? DEFAULT_MIN_COMMUNITY_SIZE;
3942
+ assertPositiveBound("maxIterations", maxIterations);
3943
+ assertPositiveBound("minSize", minSize);
3944
+ const adjacency = buildUndirectedAdjacency(graph, options.kinds);
3945
+ const nodes = graph.nodes();
3946
+ const labels = new Map(nodes.map((id) => [id, id]));
3947
+ let iterations = 0;
3948
+ let converged = false;
3949
+ let visitedNodes = 0;
3950
+ let inspectedEdges = 0;
3951
+ while (iterations < maxIterations && !converged) {
3952
+ options.signal?.throwIfAborted();
3953
+ iterations += 1;
3954
+ converged = true;
3955
+ for (const id of nodes) {
3956
+ visitedNodes += 1;
3957
+ const neighbors = adjacency.get(id);
3958
+ if (neighbors === void 0)
3959
+ continue;
3960
+ inspectedEdges += neighbors.length;
3961
+ const dominant = dominantNeighborLabel(neighbors, labels);
3962
+ if (dominant !== labels.get(id)) {
3963
+ labels.set(id, dominant);
3964
+ converged = false;
3965
+ }
3966
+ }
3967
+ }
3968
+ return {
3969
+ value: {
3970
+ communities: collectCommunities(labels, minSize),
3971
+ iterations,
3972
+ converged
3973
+ },
3974
+ meta: { visitedNodes, inspectedEdges, truncated: !converged }
3975
+ };
3976
+ }
3977
+ function isTransitiveKind(definition) {
3978
+ return definition.direction === "directed" && (definition.ordering || definition.hierarchy);
3979
+ }
3980
+ function transitiveFamilyKey(definition) {
3981
+ return definition.inverse !== void 0 && definition.inverse < definition.kind ? definition.inverse : definition.kind;
3982
+ }
3983
+ function orientTransitiveEdge(edge, definition) {
3984
+ const head = definition.hierarchy ? hierarchyParentEndpoint(edge, definition) : edge.source === orderingPredecessorEndpoint(edge, definition) ? edge.target : edge.source;
3985
+ return head === edge.target ? { from: edge.source, to: edge.target } : { from: edge.target, to: edge.source };
3986
+ }
3987
+ function resolveRedundancyFamilies(graph, kinds) {
3988
+ if (kinds === void 0)
3989
+ return void 0;
3990
+ const registry = graph.registry();
3991
+ const families = /* @__PURE__ */ new Set();
3992
+ for (const kind of kinds) {
3993
+ const definition = registry.require(kind);
3994
+ if (!isTransitiveKind(definition))
3995
+ throw new TypeError(`Relationship kind ${definition.kind} is not a directed ordering or hierarchy kind`);
3996
+ families.add(transitiveFamilyKey(definition));
3997
+ }
3998
+ return families;
3999
+ }
4000
+ function collectTransitiveFamilies(graph, wanted) {
4001
+ const registry = graph.registry();
4002
+ const families = /* @__PURE__ */ new Map();
4003
+ for (const edge of graph.edges()) {
4004
+ const definition = registry.require(edge.kind);
4005
+ if (!isTransitiveKind(definition))
4006
+ continue;
4007
+ const key = transitiveFamilyKey(definition);
4008
+ if (wanted !== void 0 && !wanted.has(key))
4009
+ continue;
4010
+ const oriented = orientTransitiveEdge(edge, definition);
4011
+ if (oriented.from === oriented.to)
4012
+ continue;
4013
+ let family = families.get(key);
4014
+ if (family === void 0) {
4015
+ family = { adjacency: /* @__PURE__ */ new Map(), records: [] };
4016
+ families.set(key, family);
4017
+ }
4018
+ const targets = family.adjacency.get(oriented.from);
4019
+ if (targets === void 0)
4020
+ family.adjacency.set(oriented.from, /* @__PURE__ */ new Set([oriented.to]));
4021
+ else
4022
+ targets.add(oriented.to);
4023
+ family.records.push({ ...oriented, edge });
4024
+ }
4025
+ return families;
4026
+ }
4027
+ function sortedFamilyAdjacency(family) {
4028
+ const sorted = /* @__PURE__ */ new Map();
4029
+ for (const [from, targets] of family.adjacency)
4030
+ sorted.set(from, [...targets].sort());
4031
+ return sorted;
4032
+ }
4033
+ function reconstructWitness(parents, from, tail, head) {
4034
+ const witness = [head];
4035
+ for (let node = tail; node !== from; node = parents.get(node))
4036
+ witness.push(node);
4037
+ witness.push(from);
4038
+ return witness.reverse();
4039
+ }
4040
+ function expandWitnessFrontier(adjacency, record, current, parents, queue, cost) {
4041
+ for (const next of adjacency.get(current.id) ?? []) {
4042
+ cost.inspectedEdges += 1;
4043
+ if (current.depth === 0 && next === record.to)
4044
+ continue;
4045
+ if (parents.has(next))
4046
+ continue;
4047
+ parents.set(next, current.id);
4048
+ if (next === record.to)
4049
+ return reconstructWitness(parents, record.from, current.id, next);
4050
+ queue.push({ id: next, depth: current.depth + 1 });
4051
+ }
4052
+ return void 0;
4053
+ }
4054
+ function findWitnessPath(adjacency, record, maxDepth, cost) {
4055
+ const parents = /* @__PURE__ */ new Map([[record.from, record.from]]);
4056
+ const queue = [{ id: record.from, depth: 0 }];
4057
+ for (let index = 0; index < queue.length; index += 1) {
4058
+ const current = queue[index];
4059
+ cost.visitedNodes += 1;
4060
+ if (current.depth >= maxDepth)
4061
+ continue;
4062
+ const witness = expandWitnessFrontier(adjacency, record, current, parents, queue, cost);
4063
+ if (witness !== void 0)
4064
+ return witness;
4065
+ }
4066
+ return void 0;
4067
+ }
4068
+ function findRedundantRelationshipEdges(graph, options = {}) {
4069
+ const maxDepth = options.maxDepth ?? DEFAULT_REDUNDANCY_MAX_DEPTH;
4070
+ assertPositiveBound("maxDepth", maxDepth);
4071
+ if (options.limit !== void 0)
4072
+ assertPositiveBound("limit", options.limit);
4073
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
4074
+ const wanted = resolveRedundancyFamilies(graph, options.kinds);
4075
+ const families = collectTransitiveFamilies(graph, wanted);
4076
+ const value = [];
4077
+ const cost = { visitedNodes: 0, inspectedEdges: 0 };
4078
+ let truncated = false;
4079
+ scan: for (const key of [...families.keys()].sort()) {
4080
+ const family = families.get(key);
4081
+ const adjacency = sortedFamilyAdjacency(family);
4082
+ for (const record of family.records) {
4083
+ options.signal?.throwIfAborted();
4084
+ const witness = findWitnessPath(adjacency, record, maxDepth, cost);
4085
+ if (witness === void 0)
4086
+ continue;
4087
+ if (value.length >= limit) {
4088
+ truncated = true;
4089
+ break scan;
4090
+ }
4091
+ value.push({ edge: record.edge, witness });
4092
+ }
4093
+ }
4094
+ return {
4095
+ value,
4096
+ meta: {
4097
+ visitedNodes: cost.visitedNodes,
4098
+ inspectedEdges: cost.inspectedEdges,
4099
+ truncated
4100
+ }
4101
+ };
4102
+ }
4103
+ function expandReachableNode(id, depth, rows, maxDepth, state) {
4104
+ const nextSet = /* @__PURE__ */ new Set();
4105
+ const nexts = [];
4106
+ for (const row of rows) {
4107
+ if (row.id === id || nextSet.has(row.id))
4108
+ continue;
4109
+ if (!state.seen.has(row.id)) {
4110
+ if (depth >= maxDepth) {
4111
+ state.truncated = true;
4112
+ continue;
4113
+ }
4114
+ state.seen.add(row.id);
4115
+ state.queue.push({ id: row.id, depth: depth + 1 });
4116
+ }
4117
+ nextSet.add(row.id);
4118
+ nexts.push(row.id);
4119
+ let incoming = state.predecessors.get(row.id);
4120
+ if (incoming === void 0) {
4121
+ incoming = /* @__PURE__ */ new Set();
4122
+ state.predecessors.set(row.id, incoming);
4123
+ }
4124
+ incoming.add(id);
4125
+ }
4126
+ return nexts;
4127
+ }
4128
+ function indexReachableSubgraph(graph, root, options) {
4129
+ const direction = options.direction ?? "outgoing";
4130
+ const maxDepth = options.maxDepth ?? Number.POSITIVE_INFINITY;
4131
+ const order = [];
4132
+ const successors = /* @__PURE__ */ new Map();
4133
+ const state = {
4134
+ seen: /* @__PURE__ */ new Set([root]),
4135
+ queue: [{ id: root, depth: 0 }],
4136
+ predecessors: /* @__PURE__ */ new Map(),
4137
+ truncated: false
4138
+ };
4139
+ let inspectedEdges = 0;
4140
+ for (let index = 0; index < state.queue.length; index += 1) {
4141
+ options.signal?.throwIfAborted();
4142
+ const { id, depth } = state.queue[index];
4143
+ order.push(id);
4144
+ const rows = graph.neighborEdges(id, {
4145
+ direction,
4146
+ ...options.kinds === void 0 ? {} : { kinds: options.kinds }
4147
+ });
4148
+ inspectedEdges += rows.meta.inspectedEdges;
4149
+ successors.set(id, expandReachableNode(id, depth, rows.value, maxDepth, state));
4150
+ }
4151
+ return {
4152
+ order,
4153
+ successors,
4154
+ predecessors: state.predecessors,
4155
+ inspectedEdges,
4156
+ truncated: state.truncated
4157
+ };
4158
+ }
4159
+ function reversePostorder(subgraph, root) {
4160
+ const postorder = [];
4161
+ const visited = /* @__PURE__ */ new Set([root]);
4162
+ const stack = [{ id: root, index: 0 }];
4163
+ while (stack.length > 0) {
4164
+ const frame = stack.at(-1);
4165
+ const nexts = subgraph.successors.get(frame.id);
4166
+ if (frame.index < nexts.length) {
4167
+ const next = nexts[frame.index];
4168
+ frame.index += 1;
4169
+ if (!visited.has(next)) {
4170
+ visited.add(next);
4171
+ stack.push({ id: next, index: 0 });
4172
+ }
4173
+ } else {
4174
+ postorder.push(frame.id);
4175
+ stack.pop();
4176
+ }
4177
+ }
4178
+ return postorder.reverse();
4179
+ }
4180
+ function intersectDominators(left, right, idom, ordinal) {
4181
+ let first = left;
4182
+ let second = right;
4183
+ while (first !== second) {
4184
+ while (ordinal.get(first) > ordinal.get(second))
4185
+ first = idom.get(first);
4186
+ while (ordinal.get(second) > ordinal.get(first))
4187
+ second = idom.get(second);
4188
+ }
4189
+ return first;
4190
+ }
4191
+ function dominatorCandidate(predecessors, idom, ordinal) {
4192
+ let candidate;
4193
+ for (const pred of [...predecessors].sort()) {
4194
+ if (!idom.has(pred))
4195
+ continue;
4196
+ candidate = candidate === void 0 ? pred : intersectDominators(candidate, pred, idom, ordinal);
4197
+ }
4198
+ return candidate;
4199
+ }
4200
+ function solveImmediateDominators(subgraph, root, order, ordinal, signal) {
4201
+ const idom = /* @__PURE__ */ new Map([[root, root]]);
4202
+ let changed = true;
4203
+ while (changed) {
4204
+ changed = false;
4205
+ for (const id of order) {
4206
+ signal?.throwIfAborted();
4207
+ if (id === root)
4208
+ continue;
4209
+ const candidate = dominatorCandidate(subgraph.predecessors.get(id), idom, ordinal);
4210
+ if (candidate !== void 0 && idom.get(id) !== candidate) {
4211
+ idom.set(id, candidate);
4212
+ changed = true;
4213
+ }
4214
+ }
4215
+ }
4216
+ return idom;
4217
+ }
4218
+ function computeRelationshipDominators(graph, root, options = {}) {
4219
+ if (!graph.hasNode(root))
4220
+ throw new TypeError(`Relationship node not found: ${root}`);
4221
+ if (options.maxDepth !== void 0 && (!Number.isInteger(options.maxDepth) || options.maxDepth < 0))
4222
+ throw new TypeError(`Invalid maxDepth bound: ${String(options.maxDepth)}`);
4223
+ const subgraph = indexReachableSubgraph(graph, root, options);
4224
+ const order = reversePostorder(subgraph, root);
4225
+ const ordinal = new Map(order.map((id, index) => [id, index]));
4226
+ const idom = solveImmediateDominators(subgraph, root, order, ordinal, options.signal);
4227
+ const subtreeSizes = new Map(order.map((id) => [id, 1]));
4228
+ for (let index = order.length - 1; index >= 0; index -= 1) {
4229
+ const id = order[index];
4230
+ if (id === root)
4231
+ continue;
4232
+ const parent = idom.get(id);
4233
+ subtreeSizes.set(parent, subtreeSizes.get(parent) + subtreeSizes.get(id));
4234
+ }
4235
+ const rows = order.filter((id) => id !== root).map((id) => ({
4236
+ id,
4237
+ idom: idom.get(id),
4238
+ dominatedCount: subtreeSizes.get(id) - 1
4239
+ })).sort((left, right) => right.dominatedCount - left.dominatedCount || left.id.localeCompare(right.id));
4240
+ return {
4241
+ value: { root, reachableCount: subgraph.order.length, rows },
4242
+ meta: {
4243
+ visitedNodes: subgraph.order.length,
4244
+ inspectedEdges: subgraph.inspectedEdges,
4245
+ truncated: subgraph.truncated
4246
+ }
4247
+ };
4248
+ }
4249
+
4250
+ // dist/sdk/graph/governance.js
4251
+ var DEFAULT_MAX_SAMPLE_SIZE = 25;
4252
+ var SEVERITY_RANK = {
4253
+ error: 0,
4254
+ warning: 1,
4255
+ info: 2
4256
+ };
4257
+ function buildFinding(code, severity, policy, describe, subjects, maxSampleSize, remediation) {
4258
+ const sorted = [...subjects].sort((left, right) => left.localeCompare(right));
4259
+ return {
4260
+ code,
4261
+ severity,
4262
+ policy,
4263
+ message: describe(sorted.length),
4264
+ count: sorted.length,
4265
+ sample: sorted.slice(0, maxSampleSize),
4266
+ sample_truncated: sorted.length > maxSampleSize,
4267
+ remediation
4268
+ };
4269
+ }
4270
+ function buildOrderingAdjacency(assembly) {
4271
+ const registry = assembly.graph.registry();
4272
+ const successors = /* @__PURE__ */ new Map();
4273
+ for (const edge of assembly.graph.edges()) {
4274
+ const definition = registry.require(edge.kind);
4275
+ if (!definition.ordering)
4276
+ continue;
4277
+ const [predecessor, successor] = (definition.precedence ?? "source_before_target") === "target_before_source" ? [edge.target, edge.source] : [edge.source, edge.target];
4278
+ const adjacent = successors.get(predecessor);
4279
+ if (adjacent)
4280
+ adjacent.push(successor);
4281
+ else
4282
+ successors.set(predecessor, [successor]);
4283
+ }
4284
+ for (const adjacent of successors.values())
4285
+ adjacent.sort((left, right) => left.localeCompare(right));
4286
+ return successors;
4287
+ }
4288
+ function registerTarjanNode(node, state) {
4289
+ state.indexes.set(node, state.nextIndex);
4290
+ state.lowLinks.set(node, state.nextIndex);
4291
+ state.nextIndex += 1;
4292
+ state.stack.push(node);
4293
+ state.onStack.add(node);
4294
+ }
4295
+ function visitNextTarjanNeighbor(frame, frames, successors, state) {
4296
+ const neighbors = successors.get(frame.node) ?? [];
4297
+ if (frame.neighborIndex >= neighbors.length)
4298
+ return false;
4299
+ const neighbor = neighbors[frame.neighborIndex];
4300
+ frame.neighborIndex += 1;
4301
+ if (!state.indexes.has(neighbor)) {
4302
+ registerTarjanNode(neighbor, state);
4303
+ frames.push({ node: neighbor, neighborIndex: 0 });
4304
+ } else if (state.onStack.has(neighbor)) {
4305
+ state.lowLinks.set(frame.node, Math.min(state.lowLinks.get(frame.node), state.indexes.get(neighbor)));
4306
+ }
4307
+ return true;
4308
+ }
4309
+ function completeTarjanFrame(frame, frames, successors, state) {
4310
+ frames.pop();
4311
+ const parent = frames.at(-1);
4312
+ if (parent)
4313
+ state.lowLinks.set(parent.node, Math.min(state.lowLinks.get(parent.node), state.lowLinks.get(frame.node)));
4314
+ if (state.lowLinks.get(frame.node) !== state.indexes.get(frame.node))
4315
+ return;
4316
+ const component = [];
4317
+ while (true) {
4318
+ const member = state.stack.pop();
4319
+ state.onStack.delete(member);
4320
+ component.push(member);
4321
+ if (member === frame.node)
4322
+ break;
4323
+ }
4324
+ if (component.length > 1 || component.length === 1 && successors.get(component[0])?.includes(component[0]))
4325
+ state.components.push(component.sort((left, right) => left.localeCompare(right)));
4326
+ }
4327
+ function collectOrderingCycles(successors) {
4328
+ const state = {
4329
+ indexes: /* @__PURE__ */ new Map(),
4330
+ lowLinks: /* @__PURE__ */ new Map(),
4331
+ onStack: /* @__PURE__ */ new Set(),
4332
+ stack: [],
4333
+ components: [],
4334
+ nextIndex: 0
4335
+ };
4336
+ const roots = [...successors.keys()].sort((left, right) => left.localeCompare(right));
4337
+ for (const root of roots) {
4338
+ if (state.indexes.has(root))
4339
+ continue;
4340
+ const frames = [{ node: root, neighborIndex: 0 }];
4341
+ registerTarjanNode(root, state);
4342
+ while (frames.length > 0) {
4343
+ const frame = frames.at(-1);
4344
+ if (visitNextTarjanNeighbor(frame, frames, successors, state))
4345
+ continue;
4346
+ completeTarjanFrame(frame, frames, successors, state);
4347
+ }
4348
+ }
4349
+ return state.components.sort((left, right) => left[0].localeCompare(right[0]));
4350
+ }
4351
+ function formatDanglingReference(reference) {
4352
+ return `${reference.holder_id} -> ${reference.target_id} (${reference.kind})`;
4353
+ }
4354
+ function appendFinding(findings, subjects, maxSampleSize, code, severity, policy, describe, remediation) {
4355
+ if (subjects.length === 0)
4356
+ return;
4357
+ findings.push(buildFinding(code, severity, policy, describe, subjects, maxSampleSize, remediation));
4358
+ }
4359
+ function collectIntegrityFindings(assembly, isTerminal, maxSampleSize) {
4360
+ const findings = [];
4361
+ const references = [
4362
+ ...assembly.dangling.active,
4363
+ ...assembly.dangling.legacy_terminal
4364
+ ].filter((reference) => !reference.no_active_blocker_sentinel);
4365
+ appendFinding(findings, references.filter((reference) => !isTerminal(reference.holder_status)).map(formatDanglingReference), maxSampleSize, "missing_reference_active", "error", "Active items must not reference absent targets; missing prerequisites distort scheduling.", (count) => `${count} active dangling reference(s) to absent items`, "Restore or re-create the referenced item, or remove/retype the reference on the holder.");
4366
+ appendFinding(findings, references.filter((reference) => isTerminal(reference.holder_status)).map(formatDanglingReference), maxSampleSize, "missing_reference_terminal", "info", "Terminal items may retain historical references, but absent targets remain unexplainable context.", (count) => `${count} terminal dangling reference(s) to absent items`, "Leave as history debt or clean up in a dedicated changelog-safe closed-item batch.");
4367
+ appendFinding(findings, assembly.dangling.no_active_blocker_sentinels.map(formatDanglingReference), maxSampleSize, "legacy_no_blocker_sentinel", "info", "The pre-structured-dependency no-active-blocker sentinel is retired; real edges carry blocker state.", (count) => `${count} legacy no-active-blocker sentinel reference(s)`, "Delete the sentinel reference; blocker state is derived from blocked_by edges.");
4368
+ return findings;
4369
+ }
4370
+ function isActiveAuditMember(member, nodeStates) {
4371
+ const state = nodeStates.get(member);
4372
+ if (!state)
4373
+ return true;
4374
+ return !state.terminal;
4375
+ }
4376
+ function collectOrderingFindings(assembly, nodeStates, isBlocked, maxSampleSize) {
4377
+ const findings = [];
4378
+ const orderingAdjacency = buildOrderingAdjacency(assembly);
4379
+ for (const cycle of collectOrderingCycles(orderingAdjacency)) {
4380
+ const active = cycle.some((member) => isActiveAuditMember(member, nodeStates));
4381
+ findings.push(active ? buildFinding("ordering_cycle", "error", "Order-bearing relationship kinds must stay acyclic; a cycle makes every member unschedulable.", (count) => `execution-order cycle across ${count} item(s)`, cycle, maxSampleSize, "Remove or retype one ordering edge inside the cycle, or split the work so precedence is linear.") : buildFinding("legacy_ordering_cycle", "info", "Ordering cycles between exclusively terminal items are historical contradictions with no scheduling effect.", (count) => `terminal-only execution-order cycle across ${count} item(s)`, cycle, maxSampleSize, "Leave as history debt, or clean up in a dedicated changelog-safe closed-item batch; never repair closed items ad hoc."));
4382
+ }
4383
+ const predecessorsByNode = /* @__PURE__ */ new Map();
4384
+ for (const [predecessor, adjacent] of orderingAdjacency)
4385
+ for (const successor of adjacent) {
4386
+ const predecessors = predecessorsByNode.get(successor);
4387
+ if (predecessors)
4388
+ predecessors.push(predecessor);
4389
+ else
4390
+ predecessorsByNode.set(successor, [predecessor]);
4391
+ }
4392
+ const staleLifecycleBlocks = [...nodeStates.values()].filter((state) => !state.missing && !state.terminal && isBlocked(state.status) && !(predecessorsByNode.get(state.id) ?? []).some((predecessor) => {
4393
+ const predecessorState = nodeStates.get(predecessor);
4394
+ return predecessorState === void 0 || !predecessorState.terminal;
4395
+ })).map((state) => state.id);
4396
+ appendFinding(findings, staleLifecycleBlocks, maxSampleSize, "stale_lifecycle_block", "warning", "A blocked lifecycle status must be backed by at least one open ordering predecessor.", (count) => `${count} status-blocked item(s) with no open blocker edge`, "Re-open the missing prerequisite as an edge, or move the item back to an active status.");
4397
+ return findings;
4398
+ }
4399
+ function formatDuplicateEdgeGroup(group) {
4400
+ const kinds = group.edges.map((edge) => edge.kind).sort((left, right) => left.localeCompare(right));
4401
+ return `${group.from} -> ${group.to} (${kinds.join(" + ")})`;
4402
+ }
4403
+ function collectDuplicateRelationshipEdgeGroups(assembly) {
4404
+ const registry = assembly.graph.registry();
4405
+ const groups = /* @__PURE__ */ new Map();
4406
+ for (const edge of assembly.graph.edges()) {
4407
+ const definition = registry.require(edge.kind);
4408
+ if (!isTransitiveKind(definition))
4409
+ continue;
4410
+ const oriented = orientTransitiveEdge(edge, definition);
4411
+ if (oriented.from === oriented.to)
4412
+ continue;
4413
+ const key = `${transitiveFamilyKey(definition)}::${oriented.from}::${oriented.to}`;
4414
+ const group = groups.get(key);
4415
+ if (group)
4416
+ group.edges.push(edge);
4417
+ else
4418
+ groups.set(key, { ...oriented, edges: [edge] });
4419
+ }
4420
+ const duplicated = [...groups.values()].filter((group) => group.edges.length >= 2);
4421
+ for (const group of duplicated)
4422
+ group.edges.sort((left, right) => left.kind.localeCompare(right.kind));
4423
+ return duplicated.sort((left, right) => left.from.localeCompare(right.from) || left.to.localeCompare(right.to));
4424
+ }
4425
+ function collectDuplicateEdgeFindings(assembly, nodeStates, maxSampleSize) {
4426
+ const active = [];
4427
+ const legacy = [];
4428
+ for (const group of collectDuplicateRelationshipEdgeGroups(assembly)) {
4429
+ const subjects = isActiveAuditMember(group.from, nodeStates) || isActiveAuditMember(group.to, nodeStates) ? active : legacy;
4430
+ subjects.push(formatDuplicateEdgeGroup(group));
4431
+ }
4432
+ const findings = [];
4433
+ appendFinding(findings, active, maxSampleSize, "duplicate_edge", "info", "One semantic relationship should be stored once; parallel same-family spellings (reciprocal inverse pairs included) add no information and skew degree metrics.", (count) => `${count} duplicated relationship(s) between active endpoints`, "Remove all but one stored spelling of the relationship; keep the canonical direction the holder declared first.");
4434
+ appendFinding(findings, legacy, maxSampleSize, "legacy_duplicate_edge", "info", "Duplicated spellings between exclusively terminal items are historical noise with no scheduling effect.", (count) => `${count} duplicated relationship(s) between terminal endpoints`, "Leave as history debt or clean up in a dedicated changelog-safe closed-item batch.");
4435
+ return findings;
4436
+ }
4437
+ function collectCoverageReport(assembly, nodeStates, exemptIsolates, maxSampleSize, edgesByKind) {
4438
+ let activeNodes = 0;
4439
+ let missingNodes = 0;
4440
+ let isolatedActiveNodes = 0;
4441
+ let degreeLeqOneActive = 0;
4442
+ const isolates = [];
4443
+ const sparse = [];
4444
+ for (const id of assembly.graph.nodes()) {
4445
+ const state = nodeStates.get(id);
4446
+ if (!state)
4447
+ continue;
4448
+ if (state.missing) {
4449
+ missingNodes += 1;
4450
+ continue;
4451
+ }
4452
+ if (state.terminal)
4453
+ continue;
4454
+ activeNodes += 1;
4455
+ const degree = assembly.graph.incidentEdges(id).length;
4456
+ if (degree > 1)
4457
+ continue;
4458
+ degreeLeqOneActive += 1;
4459
+ if (degree === 0)
4460
+ isolatedActiveNodes += 1;
4461
+ if (exemptIsolates.has(id.toLowerCase()))
4462
+ continue;
4463
+ if (degree === 0)
4464
+ isolates.push(id);
4465
+ else
4466
+ sparse.push(id);
4467
+ }
4468
+ const findings = [];
4469
+ appendFinding(findings, isolates, maxSampleSize, "isolated_active_node", "warning", "Active work should be reachable from the graph unless explicitly declared a valid isolate.", (count) => `${count} active item(s) with no relationships`, "Link the item to its parent, prerequisite, or origin \u2014 or register it as an exempt isolate.");
4470
+ appendFinding(findings, sparse, maxSampleSize, "sparse_active_node", "info", "Active items with a single edge often miss an honest semantic partner; sparse is not automatically defective.", (count) => `${count} active item(s) with exactly one relationship`, "Investigate for an honest second edge (story->task, defect family, cross-epic complement); do not fabricate one.");
4471
+ return {
4472
+ findings,
4473
+ profile: {
4474
+ nodes: assembly.graph.nodes().length,
4475
+ edges: assembly.graph.edges().length,
4476
+ edges_by_kind: Object.fromEntries(Object.entries(edgesByKind).sort(([left], [right]) => left.localeCompare(right))),
4477
+ active_nodes: activeNodes,
4478
+ missing_nodes: missingNodes,
4479
+ isolated_active_nodes: isolatedActiveNodes,
4480
+ degree_leq_one_active_nodes: degreeLeqOneActive
4481
+ }
4482
+ };
4483
+ }
4484
+ function auditWorkspaceRelationshipGraph(assembly, options = {}) {
4485
+ const isTerminal = options.isTerminal ?? ((status) => status === "closed" || status === "canceled");
4486
+ const isBlocked = options.isBlocked ?? ((status) => status === "blocked");
4487
+ const maxSampleSize = options.maxSampleSize ?? DEFAULT_MAX_SAMPLE_SIZE;
4488
+ if (!Number.isInteger(maxSampleSize) || maxSampleSize < 1)
4489
+ throw new TypeError(`Invalid audit sample bound: ${String(options.maxSampleSize)}`);
4490
+ const exemptIsolates = new Set((options.exemptIsolates ?? []).filter((id) => typeof id === "string").map((id) => id.trim().toLowerCase()));
4491
+ const nodeStates = new Map(assembly.details.map((detail) => [
4492
+ detail.id,
4493
+ {
4494
+ id: detail.id,
4495
+ status: detail.status,
4496
+ missing: assembly.missingIdSet.has(detail.id.toLowerCase()),
4497
+ terminal: isTerminal(detail.status)
4498
+ }
4499
+ ]));
4500
+ options.signal?.throwIfAborted();
4501
+ const edgesByKind = {};
4502
+ for (const edge of assembly.graph.edges())
4503
+ edgesByKind[edge.kind] = (edgesByKind[edge.kind] ?? 0) + 1;
4504
+ const findings = collectIntegrityFindings(assembly, isTerminal, maxSampleSize);
4505
+ options.signal?.throwIfAborted();
4506
+ findings.push(...collectOrderingFindings(assembly, nodeStates, isBlocked, maxSampleSize));
4507
+ options.signal?.throwIfAborted();
4508
+ findings.push(...collectDuplicateEdgeFindings(assembly, nodeStates, maxSampleSize));
4509
+ options.signal?.throwIfAborted();
4510
+ const coverage = collectCoverageReport(assembly, nodeStates, exemptIsolates, maxSampleSize, edgesByKind);
4511
+ findings.push(...coverage.findings);
4512
+ findings.sort((left, right) => SEVERITY_RANK[left.severity] - SEVERITY_RANK[right.severity] || left.code.localeCompare(right.code) || left.sample[0].localeCompare(right.sample[0]));
4513
+ return {
4514
+ findings,
4515
+ profile: coverage.profile
4516
+ };
4517
+ }
4518
+
4519
+ // dist/sdk/graph/remediation.js
4520
+ var FINDING_STEP_TEMPLATES = {
4521
+ missing_reference_active: {
4522
+ op: "investigate",
4523
+ confidence: "medium",
4524
+ rationale: "Restore or re-create the referenced item, or remove/retype the reference on the active holder; the correct fix depends on why the target is absent."
4525
+ },
4526
+ missing_reference_terminal: {
4527
+ op: "waive",
4528
+ confidence: "high",
4529
+ rationale: "Terminal-holder reference to an absent item is historical debt; waive it or clean it up only in a dedicated changelog-safe closed-item batch."
4530
+ },
4531
+ legacy_no_blocker_sentinel: {
4532
+ op: "remove",
4533
+ confidence: "high",
4534
+ rationale: "The pre-structured-dependency no-active-blocker sentinel is retired and carries no information; blocker state derives from blocked_by edges."
4535
+ },
4536
+ ordering_cycle: {
4537
+ op: "investigate",
4538
+ confidence: "low",
4539
+ rationale: "Every cycle member is unschedulable until one ordering edge is removed or retyped; the planner never chooses which edge to cut."
4540
+ },
4541
+ legacy_ordering_cycle: {
4542
+ op: "waive",
4543
+ confidence: "high",
4544
+ rationale: "Terminal-only ordering cycles have no scheduling effect; repairing them would mutate closed history (changelog drag)."
4545
+ },
4546
+ // duplicate_edge findings are expanded into per-stored-edge remove steps by
4547
+ // the planner itself (see stepsFromDuplicateGroup); this template documents
4548
+ // the family for exhaustiveness and backs any future sample-only fallback.
4549
+ duplicate_edge: {
4550
+ op: "remove",
4551
+ confidence: "high",
4552
+ rationale: "Parallel same-family spellings state one relationship twice; remove all but one stored spelling, keeping the holder's canonical direction."
4553
+ },
4554
+ legacy_duplicate_edge: {
4555
+ op: "waive",
4556
+ confidence: "high",
4557
+ rationale: "Duplicated spellings between terminal items are historical noise; waive or batch changelog-safe cleanup."
4558
+ },
4559
+ stale_lifecycle_block: {
4560
+ op: "investigate",
4561
+ confidence: "medium",
4562
+ rationale: "Re-open the missing prerequisite as an ordering edge, or move the item back to an active status; only the holder's owner knows which is true."
4563
+ },
4564
+ isolated_active_node: {
4565
+ op: "investigate",
4566
+ confidence: "medium",
4567
+ rationale: "Link the item to its parent, prerequisite, or origin \u2014 or register it as an explicitly exempt isolate; the audit never fabricates an edge."
4568
+ },
4569
+ sparse_active_node: {
4570
+ op: "investigate",
4571
+ confidence: "low",
4572
+ rationale: "Investigate for an honest second edge (story-to-task, defect family, cross-epic complement); sparse is not automatically defective."
4573
+ }
4574
+ };
4575
+ function formatStoredEdge(edge) {
4576
+ return `${edge.source} -${edge.kind}-> ${edge.target}`;
4577
+ }
4578
+ function stepsFromDuplicateGroup(group) {
4579
+ const [keeper, ...extras] = group.edges;
4580
+ return extras.map((edge) => ({
4581
+ op: "remove",
4582
+ code: "duplicate_edge",
4583
+ subject: formatStoredEdge(edge),
4584
+ rationale: "This stored spelling restates the kept canonical edge of the same semantic family; removing it leaves the relationship stated exactly once.",
4585
+ evidence: [
4586
+ `keep: ${formatStoredEdge(keeper)}`,
4587
+ `group: ${formatDuplicateEdgeGroup(group)}`
4588
+ ],
4589
+ confidence: "high"
4590
+ }));
4591
+ }
4592
+ function stepsFromFinding(finding, duplicateGroups) {
4593
+ if (finding.code === "duplicate_edge") {
4594
+ return finding.sample.flatMap((subject) => stepsFromDuplicateGroup(duplicateGroups.get(subject)));
4595
+ }
4596
+ const template = FINDING_STEP_TEMPLATES[finding.code];
4597
+ return finding.sample.map((subject) => ({
4598
+ op: template.op,
4599
+ code: finding.code,
4600
+ subject,
4601
+ rationale: template.rationale,
4602
+ evidence: [finding.policy],
4603
+ confidence: template.confidence
4604
+ }));
4605
+ }
4606
+ function planRelationshipRemediation(assembly, options = {}) {
4607
+ const { redundancyLimit, ...auditOptions } = options;
4608
+ const report = auditWorkspaceRelationshipGraph(assembly, auditOptions);
4609
+ const duplicateGroups = new Map(collectDuplicateRelationshipEdgeGroups(assembly).map((group) => [
4610
+ formatDuplicateEdgeGroup(group),
4611
+ group
4612
+ ]));
4613
+ const steps = report.findings.flatMap((finding) => stepsFromFinding(finding, duplicateGroups));
4614
+ let truncated = report.findings.some((finding) => finding.sample_truncated);
4615
+ options.signal?.throwIfAborted();
4616
+ const redundancy = findRedundantRelationshipEdges(assembly.graph, {
4617
+ limit: redundancyLimit ?? options.maxSampleSize ?? 25,
4618
+ ...options.signal === void 0 ? {} : { signal: options.signal }
4619
+ });
4620
+ for (const row of redundancy.value) {
4621
+ steps.push({
4622
+ op: "remove",
4623
+ code: "redundant_edge",
4624
+ subject: `${row.edge.source} -> ${row.edge.target} (${row.edge.kind})`,
4625
+ rationale: "The stored edge is implied by a longer same-family witness path; shortcut edges are sometimes deliberate emphasis, so confirm intent before removing.",
4626
+ evidence: [`witness: ${row.witness.join(" -> ")}`],
4627
+ confidence: "medium"
4628
+ });
4629
+ }
4630
+ truncated = truncated || redundancy.meta.truncated;
4631
+ return {
4632
+ steps,
4633
+ report,
4634
+ truncated,
4635
+ cost: {
4636
+ visitedNodes: redundancy.meta.visitedNodes,
4637
+ inspectedEdges: redundancy.meta.inspectedEdges
4638
+ }
4639
+ };
4640
+ }
4641
+
4642
+ // dist/sdk/graph/run.js
4643
+ var ROOTED_SUBCOMMANDS = /* @__PURE__ */ new Set([
4644
+ "ancestors",
4645
+ "descendants",
4646
+ "predecessors",
4647
+ "successors",
4648
+ "paths",
4649
+ "impact",
4650
+ "dominators"
4651
+ ]);
4652
+ var DEFAULT_SAMPLE_LIMIT = 10;
4653
+ function normalizeIdList(raw) {
4654
+ if (raw === void 0)
4655
+ return [];
4656
+ return (Array.isArray(raw) ? raw : [raw]).flatMap((value) => value.split(",")).map((value) => value.trim()).filter((value) => value.length > 0);
4657
+ }
4658
+ function parseGraphSubcommand(raw, id, target) {
4659
+ const candidate = raw.trim().toLowerCase();
4660
+ if (!GRAPH_SUBCOMMAND_VALUES.includes(candidate)) {
4661
+ throw new PmCliError(`Invalid graph subcommand "${raw}". Use one of: ${GRAPH_SUBCOMMAND_VALUES.join(", ")}.`, EXIT_CODE.USAGE);
4662
+ }
4663
+ const subcommand = candidate;
4664
+ if (ROOTED_SUBCOMMANDS.has(subcommand) && !id?.trim()) {
4665
+ throw new PmCliError(`graph ${subcommand} requires an item id.`, EXIT_CODE.USAGE);
4666
+ }
4667
+ if (subcommand === "paths" && !target?.trim()) {
4668
+ throw new PmCliError("graph paths requires a source and a target item id.", EXIT_CODE.USAGE);
4669
+ }
4670
+ return subcommand;
4671
+ }
4672
+ function rethrowGraphUsage(error) {
4673
+ if (error instanceof TypeError)
4674
+ throw new PmCliError(error.message, EXIT_CODE.USAGE);
4675
+ throw error;
4676
+ }
4677
+ function projectQueryMeta(meta) {
4678
+ return {
4679
+ truncated: meta.truncated,
4680
+ cost: {
4681
+ visited_nodes: meta.visitedNodes,
4682
+ inspected_edges: meta.inspectedEdges
4683
+ }
4684
+ };
4685
+ }
4686
+ function canonicalizeGraphId(assembly, raw) {
4687
+ const wanted = raw.trim().toLowerCase();
4688
+ for (const detail of assembly.details) {
4689
+ if (detail.id.trim().toLowerCase() === wanted && !assembly.missingIdSet.has(detail.id.toLowerCase())) {
4690
+ return detail.id;
4691
+ }
4692
+ }
4693
+ throw new PmCliError(`Item ${raw} not found`, EXIT_CODE.NOT_FOUND);
4694
+ }
4695
+ function runGraphTraversal(subcommand, root, invocation) {
4696
+ const walk = {
4697
+ ancestors: hierarchyAncestors,
4698
+ descendants: hierarchyDescendants,
4699
+ predecessors: orderingPredecessors,
4700
+ successors: orderingSuccessors
4701
+ }[subcommand];
4702
+ let result;
4703
+ try {
4704
+ result = walk(invocation.assembly.graph, root, {
4705
+ ...invocation.kinds === void 0 ? {} : { kinds: invocation.kinds },
4706
+ ...invocation.maxDepth === void 0 ? {} : { maxDepth: invocation.maxDepth },
4707
+ ...invocation.limit === void 0 ? {} : { limit: invocation.limit },
4708
+ ...invocation.after === void 0 ? {} : { after: invocation.after }
4709
+ });
4710
+ } catch (error) {
4711
+ rethrowGraphUsage(error);
4712
+ }
4713
+ const meta = projectQueryMeta(result.meta);
4714
+ return {
4715
+ subcommand,
4716
+ root,
4717
+ count: result.value.length,
4718
+ ...meta,
4719
+ ...result.meta.nextCursor === void 0 ? {} : { next_cursor: result.meta.nextCursor },
4720
+ ...invocation.summary ? {} : { ids: result.value }
4721
+ };
4722
+ }
4723
+ function runGraphPaths(root, target, invocation) {
4724
+ const result = enumerateRelationshipPaths(invocation.assembly.graph, root, target, {
4725
+ direction: invocation.direction,
4726
+ ...invocation.kinds === void 0 ? {} : { kinds: invocation.kinds },
4727
+ ...invocation.maxDepth === void 0 ? {} : { maxDepth: invocation.maxDepth },
4728
+ ...invocation.maxPaths === void 0 ? {} : { maxPaths: invocation.maxPaths }
4729
+ });
4730
+ return {
4731
+ subcommand: "paths",
4732
+ root,
4733
+ target,
4734
+ direction: invocation.direction,
4735
+ count: result.value.length,
4736
+ ...projectQueryMeta(result.meta),
4737
+ ...invocation.summary ? {} : {
4738
+ paths: result.value.map((path3) => ({
4739
+ nodes: path3.nodes,
4740
+ kinds: path3.edges.map((edge) => edge.kind),
4741
+ length: path3.length
4742
+ }))
4743
+ }
4744
+ };
4745
+ }
4746
+ function runGraphImpact(root, invocation) {
4747
+ const analysis = analyzeGraphImpact(invocation.assembly.graph, root, {
4748
+ direction: invocation.direction,
4749
+ ...invocation.kinds === void 0 ? {} : { kinds: invocation.kinds },
4750
+ ...invocation.maxDepth === void 0 ? {} : { maxDepth: invocation.maxDepth },
4751
+ ...invocation.limit === void 0 ? {} : { limit: invocation.limit }
4752
+ });
4753
+ return {
4754
+ subcommand: "impact",
4755
+ root,
4756
+ direction: invocation.direction,
4757
+ count: analysis.affected.length,
4758
+ truncated: analysis.truncated,
4759
+ cost: {
4760
+ visited_nodes: analysis.cost.visitedNodes,
4761
+ inspected_edges: analysis.cost.inspectedEdges
4762
+ },
4763
+ ...invocation.summary ? {} : { affected: analysis.affected }
4764
+ };
4765
+ }
4766
+ function runGraphAnalyze(invocation) {
4767
+ const graph = invocation.assembly.graph;
4768
+ const sampleLimit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
4769
+ const execution = analyzeRelationshipExecution(graph, {
4770
+ registry: graph.registry()
4771
+ });
4772
+ const knowledge = analyzeKnowledgeGraph(graph);
4773
+ return {
4774
+ subcommand: "analyze",
4775
+ node_count: graph.nodes().length,
4776
+ edge_count: graph.edges().length,
4777
+ sample_limit: sampleLimit,
4778
+ execution: {
4779
+ acyclic: execution.acyclic,
4780
+ ordered_node_count: execution.order.length,
4781
+ layer_count: execution.layers.length,
4782
+ frontier_count: execution.frontier.length,
4783
+ critical_path_length: execution.criticalPathLength,
4784
+ cycle_count: execution.cycles.length,
4785
+ ...invocation.summary ? {} : {
4786
+ frontier: execution.frontier.slice(0, sampleLimit),
4787
+ critical_path: execution.criticalPath.slice(0, sampleLimit),
4788
+ cycles: execution.cycles.slice(0, sampleLimit)
4789
+ }
4790
+ },
4791
+ knowledge: {
4792
+ component_count: knowledge.components.length,
4793
+ largest_component_size: knowledge.components[0]?.length ?? 0,
4794
+ orphan_count: knowledge.orphans.length,
4795
+ ...invocation.summary ? {} : {
4796
+ orphans: knowledge.orphans.slice(0, sampleLimit),
4797
+ hubs: knowledge.hubs.slice(0, sampleLimit)
4798
+ }
4799
+ }
4800
+ };
4801
+ }
4802
+ function runGraphAudit(invocation, isTerminal) {
4803
+ const report = auditWorkspaceRelationshipGraph(invocation.assembly, {
4804
+ isTerminal,
4805
+ ...invocation.sample === void 0 ? {} : { maxSampleSize: invocation.sample },
4806
+ ...invocation.exemptIsolates.length === 0 ? {} : { exemptIsolates: invocation.exemptIsolates }
4807
+ });
4808
+ const bySeverity = {};
4809
+ const byCode = {};
4810
+ for (const finding of report.findings) {
4811
+ bySeverity[finding.severity] = (bySeverity[finding.severity] ?? 0) + 1;
4812
+ byCode[finding.code] = (byCode[finding.code] ?? 0) + finding.count;
4813
+ }
4814
+ return {
4815
+ subcommand: "audit",
4816
+ finding_count: report.findings.length,
4817
+ findings_by_severity: bySeverity,
4818
+ findings_by_code: byCode,
4819
+ profile: report.profile,
4820
+ ...invocation.summary ? {} : { findings: report.findings }
4821
+ };
4822
+ }
4823
+ function runGraphCommunities(invocation) {
4824
+ const sampleLimit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
4825
+ const result = detectRelationshipCommunities(invocation.assembly.graph, {
4826
+ ...invocation.kinds === void 0 ? {} : { kinds: invocation.kinds }
4827
+ });
4828
+ const analysis = result.value;
4829
+ return {
4830
+ subcommand: "communities",
4831
+ community_count: analysis.communities.length,
4832
+ largest_community_size: analysis.communities[0]?.size ?? 0,
4833
+ iterations: analysis.iterations,
4834
+ converged: analysis.converged,
4835
+ truncated: !analysis.converged || analysis.communities.length > sampleLimit,
4836
+ cost: {
4837
+ visited_nodes: result.meta.visitedNodes,
4838
+ inspected_edges: result.meta.inspectedEdges
4839
+ },
4840
+ ...invocation.summary ? {} : {
4841
+ communities: analysis.communities.slice(0, sampleLimit).map((community) => ({
4842
+ representative: community.representative,
4843
+ size: community.size,
4844
+ members: community.members.slice(0, sampleLimit)
4845
+ }))
4846
+ }
4847
+ };
4848
+ }
4849
+ function runGraphRedundancy(invocation) {
4850
+ let result;
4851
+ try {
4852
+ result = findRedundantRelationshipEdges(invocation.assembly.graph, {
4853
+ ...invocation.kinds === void 0 ? {} : { kinds: invocation.kinds },
4854
+ ...invocation.maxDepth === void 0 ? {} : { maxDepth: invocation.maxDepth },
4855
+ ...invocation.limit === void 0 ? {} : { limit: invocation.limit }
4856
+ });
4857
+ } catch (error) {
4858
+ rethrowGraphUsage(error);
4859
+ }
4860
+ return {
4861
+ subcommand: "redundancy",
4862
+ redundant_count: result.value.length,
4863
+ ...projectQueryMeta(result.meta),
4864
+ ...invocation.summary ? {} : {
4865
+ redundant: result.value.map((row) => ({
4866
+ source: row.edge.source,
4867
+ target: row.edge.target,
4868
+ kind: row.edge.kind,
4869
+ witness: row.witness
4870
+ }))
4871
+ }
4872
+ };
4873
+ }
4874
+ function runGraphDominators(root, invocation) {
4875
+ const limit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
4876
+ const result = computeRelationshipDominators(invocation.assembly.graph, root, {
4877
+ direction: invocation.direction,
4878
+ ...invocation.kinds === void 0 ? {} : { kinds: invocation.kinds },
4879
+ ...invocation.maxDepth === void 0 ? {} : { maxDepth: invocation.maxDepth }
4880
+ });
4881
+ const bottlenecks = result.value.rows.filter((row) => row.dominatedCount > 0);
4882
+ return {
4883
+ subcommand: "dominators",
4884
+ root,
4885
+ direction: invocation.direction,
4886
+ reachable_count: result.value.reachableCount,
4887
+ bottleneck_count: bottlenecks.length,
4888
+ truncated: result.meta.truncated || bottlenecks.length > limit,
4889
+ cost: {
4890
+ visited_nodes: result.meta.visitedNodes,
4891
+ inspected_edges: result.meta.inspectedEdges
4892
+ },
4893
+ ...invocation.summary ? {} : {
4894
+ bottlenecks: bottlenecks.slice(0, limit).map((row) => ({
4895
+ id: row.id,
4896
+ idom: row.idom,
4897
+ dominated_count: row.dominatedCount
4898
+ }))
4899
+ }
4900
+ };
4901
+ }
4902
+ function runGraphPlan(invocation, isTerminal) {
4903
+ const limit = invocation.limit ?? DEFAULT_SAMPLE_LIMIT;
4904
+ const plan = planRelationshipRemediation(invocation.assembly, {
4905
+ isTerminal,
4906
+ redundancyLimit: limit,
4907
+ ...invocation.sample === void 0 ? {} : { maxSampleSize: invocation.sample },
4908
+ ...invocation.exemptIsolates.length === 0 ? {} : { exemptIsolates: invocation.exemptIsolates }
4909
+ });
4910
+ const byOp = {};
4911
+ const byCode = {};
4912
+ for (const step of plan.steps) {
4913
+ byOp[step.op] = (byOp[step.op] ?? 0) + 1;
4914
+ byCode[step.code] = (byCode[step.code] ?? 0) + 1;
4915
+ }
4916
+ return {
4917
+ subcommand: "plan",
4918
+ step_count: plan.steps.length,
4919
+ steps_by_op: byOp,
4920
+ steps_by_code: byCode,
4921
+ finding_count: plan.report.findings.length,
4922
+ truncated: plan.truncated || plan.steps.length > limit,
4923
+ cost: {
4924
+ visited_nodes: plan.cost.visitedNodes,
4925
+ inspected_edges: plan.cost.inspectedEdges
4926
+ },
4927
+ ...invocation.summary ? {} : { steps: plan.steps.slice(0, limit) }
4928
+ };
4929
+ }
4930
+ function buildGraphQueryKey(subcommand, root, pathsTarget, invocation) {
4931
+ return JSON.stringify({
4932
+ subcommand,
4933
+ root: root ?? null,
4934
+ target: pathsTarget ?? null,
4935
+ kinds: invocation.kinds ?? null,
4936
+ maxDepth: invocation.maxDepth ?? null,
4937
+ limit: invocation.limit ?? null,
4938
+ after: invocation.after ?? null,
4939
+ direction: invocation.direction,
4940
+ maxPaths: invocation.maxPaths ?? null,
4941
+ sample: invocation.sample ?? null,
4942
+ // The audit consumes exemptions as a case-insensitive set, so the key
4943
+ // must not distinguish logically identical spellings or orderings.
4944
+ exemptIsolates: [
4945
+ ...new Set(invocation.exemptIsolates.map((id) => id.toLowerCase()))
4946
+ ].sort(),
4947
+ summary: invocation.summary
4948
+ });
4949
+ }
4950
+ function executeGraphSubcommand(subcommand, root, pathsTarget, invocation, isTerminal) {
4951
+ if (subcommand === "analyze")
4952
+ return runGraphAnalyze(invocation);
4953
+ if (subcommand === "audit")
4954
+ return runGraphAudit(invocation, isTerminal);
4955
+ if (subcommand === "plan")
4956
+ return runGraphPlan(invocation, isTerminal);
4957
+ if (subcommand === "communities")
4958
+ return runGraphCommunities(invocation);
4959
+ if (subcommand === "redundancy")
4960
+ return runGraphRedundancy(invocation);
4961
+ if (subcommand === "dominators")
4962
+ return runGraphDominators(root, invocation);
4963
+ if (subcommand === "paths")
4964
+ return runGraphPaths(root, pathsTarget, invocation);
4965
+ if (subcommand === "impact")
4966
+ return runGraphImpact(root, invocation);
4967
+ return runGraphTraversal(subcommand, root, invocation);
4968
+ }
4969
+ async function runGraph(subcommandRaw, id, target, options, global) {
4970
+ const subcommand = parseGraphSubcommand(subcommandRaw, id, target);
4971
+ const pmRoot = resolvePmRoot(process.cwd(), global.path);
4972
+ if (!await pathExists(getSettingsPath(pmRoot))) {
4973
+ throw new PmCliError(`Tracker is not initialized at ${pmRoot}. Run pm init first.`, EXIT_CODE.NOT_FOUND);
4974
+ }
4975
+ const settings = await readSettings(pmRoot);
4976
+ const typeRegistry = resolveItemTypeRegistry(settings, getActiveExtensionRegistrations());
4977
+ const items = await listAllItemMetadataLight(pmRoot, settings.item_format, typeRegistry.type_to_folder, void 0, settings.schema);
4978
+ const statusRegistry = resolveRuntimeStatusRegistry(settings.schema);
4979
+ const isTerminal = (status) => isTerminalStatus(status, statusRegistry);
4980
+ const kinds = parseKinds(options.kind);
4981
+ const lookup = workspaceGraphCache().lookup(pmRoot, computeWorkspaceGraphFingerprint(items, isTerminal), () => assembleWorkspaceRelationshipGraph(items, isTerminal));
4982
+ const invocation = {
4983
+ assembly: lookup.assembly,
4984
+ ...kinds === void 0 ? {} : { kinds },
4985
+ maxDepth: parseMaxDepth(options.maxDepth),
4986
+ limit: parsePositiveInteger(options.limit, "limit"),
4987
+ after: options.after?.trim() || void 0,
4988
+ direction: parseDirection(options.direction),
4989
+ maxPaths: parsePositiveInteger(options.maxPaths, "max-paths"),
4990
+ sample: parsePositiveInteger(options.sample, "sample"),
4991
+ exemptIsolates: normalizeIdList(options.exemptIsolate),
4992
+ summary: options.summary === true
4993
+ };
4994
+ const root = ROOTED_SUBCOMMANDS.has(subcommand) ? canonicalizeGraphId(invocation.assembly, id) : void 0;
4995
+ const pathsTarget = subcommand === "paths" ? canonicalizeGraphId(invocation.assembly, target) : void 0;
4996
+ const memo = lookup.memoize(buildGraphQueryKey(subcommand, root, pathsTarget, invocation), () => executeGraphSubcommand(subcommand, root, pathsTarget, invocation, isTerminal));
4997
+ return {
4998
+ ...memo.value,
4999
+ cache: {
5000
+ fingerprint: lookup.fingerprint.slice(0, 12),
5001
+ assembly: lookup.assemblyReused ? "hit" : "miss",
5002
+ result: memo.reused ? "hit" : "miss"
5003
+ }
5004
+ };
5005
+ }
5006
+
3345
5007
  export {
3346
5008
  runAggregate,
3347
5009
  runSearch,
5010
+ DEFAULT_EVAL_QUERIES_RELATIVE_PATH,
3348
5011
  runEval,
3349
5012
  MAX_CHILD_PROJECTION_ITEMS,
3350
5013
  DEFAULT_CHILD_SAMPLE_LIMIT,
3351
5014
  buildItemChildrenRollup,
3352
5015
  itemHasSchedule,
3353
5016
  buildItemSchedule,
3354
- runGet
5017
+ runGet,
5018
+ analyzeRelationshipExecution,
5019
+ analyzeGraphImpact,
5020
+ analyzeKnowledgeGraph,
5021
+ compareRelationshipSnapshots,
5022
+ hierarchyAncestors,
5023
+ hierarchyDescendants,
5024
+ orderingPredecessors,
5025
+ orderingSuccessors,
5026
+ enumerateRelationshipPaths,
5027
+ detectRelationshipCommunities,
5028
+ findRedundantRelationshipEdges,
5029
+ computeRelationshipDominators,
5030
+ formatDuplicateEdgeGroup,
5031
+ collectDuplicateRelationshipEdgeGroups,
5032
+ auditWorkspaceRelationshipGraph,
5033
+ planRelationshipRemediation,
5034
+ parseGraphSubcommand,
5035
+ runGraph
3355
5036
  };
3356
- //# sourceMappingURL=chunk-ONG5V5CI.js.map
5037
+ //# sourceMappingURL=chunk-QPGQNLPI.js.map
3357
5038
 
3358
- //# debugId=9a21d12c-d2fd-5325-930c-dfc8bbfe8247
5039
+ //# debugId=2289448d-a087-55eb-a092-70c2f25227d6