scip-query 0.20.0 → 0.21.0

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 (586) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +255 -884
  3. package/dist/augment-vue-worker.js +1 -1
  4. package/dist/by-kind-CI3O6PQG.js +2 -0
  5. package/dist/call-graph-6QTUTXH7.js +2 -0
  6. package/dist/call-graph-evidence-lZa2dwQA.d.ts +11 -0
  7. package/dist/change-analysis-types-CCtoCHbC.d.ts +9 -0
  8. package/dist/chunk-26CT72HM.js +2 -0
  9. package/dist/{chunk-7PIO7NKH.js → chunk-2COFMIVK.js} +2 -2
  10. package/dist/chunk-2H4IAJHO.js +2 -0
  11. package/dist/chunk-2I3RSUWX.js +16 -0
  12. package/dist/chunk-2RP27XLR.js +2 -0
  13. package/dist/chunk-2ZBMOQGG.js +3 -0
  14. package/dist/{chunk-HX4GQPZP.js → chunk-32A42O5B.js} +3 -3
  15. package/dist/chunk-35ELD3RM.js +2 -0
  16. package/dist/chunk-35IW3P4H.js +2 -0
  17. package/dist/{chunk-DQGFVPUV.js → chunk-3653GTR7.js} +3 -3
  18. package/dist/chunk-3EX7DNBC.js +2 -0
  19. package/dist/chunk-3FQ3KMCD.js +2 -0
  20. package/dist/{chunk-5E4WNAVD.js → chunk-3PII3JI5.js} +2 -2
  21. package/dist/chunk-3TNRNKAT.js +2 -0
  22. package/dist/chunk-3VLJ2DCA.js +2 -0
  23. package/dist/{chunk-XSRF6Q77.js → chunk-46JLFIGA.js} +2 -2
  24. package/dist/chunk-4DCKBY6T.js +5 -0
  25. package/dist/chunk-4EXFZP6H.js +2 -0
  26. package/dist/chunk-4IIMPWMR.js +29 -0
  27. package/dist/chunk-4ILHWBYF.js +2 -0
  28. package/dist/chunk-4N6QSEMZ.js +10 -0
  29. package/dist/chunk-4OE2JO6I.js +2 -0
  30. package/dist/{chunk-7BAVHKMJ.js → chunk-4S4DF62J.js} +9 -9
  31. package/dist/chunk-4UUCUASK.js +554 -0
  32. package/dist/chunk-5236NQV3.js +2 -0
  33. package/dist/chunk-54EOGFBR.js +2 -0
  34. package/dist/{chunk-LY4WC4AD.js → chunk-5H7IWVXJ.js} +2 -2
  35. package/dist/chunk-5IZTXSOL.js +117 -0
  36. package/dist/{chunk-AZJQQKDD.js → chunk-5SE323LF.js} +2 -2
  37. package/dist/chunk-5ZJH6DDE.js +2 -0
  38. package/dist/chunk-63MBA7EG.js +3 -0
  39. package/dist/chunk-6BJ7SOY7.js +2 -0
  40. package/dist/chunk-6GJAP4OE.js +2 -0
  41. package/dist/chunk-6IEVHGWG.js +26 -0
  42. package/dist/chunk-6SWA6B24.js +7 -0
  43. package/dist/chunk-6T7H2AFY.js +3 -0
  44. package/dist/chunk-73Z33VFI.js +4 -0
  45. package/dist/chunk-7COHFNJK.js +38 -0
  46. package/dist/chunk-7HU2IJ2T.js +3 -0
  47. package/dist/chunk-7IOAZRVL.js +60 -0
  48. package/dist/chunk-7KCZELVM.js +2 -0
  49. package/dist/chunk-7PPYXENX.js +2 -0
  50. package/dist/chunk-7TWP3MCP.js +2 -0
  51. package/dist/chunk-AA7K3XLM.js +21 -0
  52. package/dist/chunk-AJVMVE7X.js +7 -0
  53. package/dist/chunk-ANWGXPPN.js +4 -0
  54. package/dist/chunk-APLKXICZ.js +3 -0
  55. package/dist/{chunk-JDOEX4E6.js → chunk-AQDWTCDC.js} +2 -2
  56. package/dist/chunk-AUP6YI5M.js +2 -0
  57. package/dist/chunk-B7ECWJAZ.js +2 -0
  58. package/dist/{chunk-ZHXX42OH.js → chunk-BATIVRU2.js} +4 -4
  59. package/dist/chunk-BBEDPVPB.js +4 -0
  60. package/dist/chunk-BBWPOMGU.js +2 -0
  61. package/dist/chunk-BD6CV7PN.js +2 -0
  62. package/dist/{chunk-XKWKXZKW.js → chunk-BHE44MHT.js} +2 -2
  63. package/dist/chunk-BOJ5SVE2.js +2 -0
  64. package/dist/chunk-BZYSGZRK.js +2 -0
  65. package/dist/chunk-CA5RE6H7.js +2 -0
  66. package/dist/chunk-CKDOY6JA.js +2 -0
  67. package/dist/chunk-CN2WGM7D.js +2 -0
  68. package/dist/chunk-COTMS5KM.js +3 -0
  69. package/dist/chunk-CSDDOUA4.js +3 -0
  70. package/dist/chunk-CT5SI2I4.js +2 -0
  71. package/dist/chunk-D5EKVZPI.js +2 -0
  72. package/dist/{chunk-FKSELJQF.js → chunk-D5W4UZY5.js} +2 -2
  73. package/dist/{chunk-RUJURYSV.js → chunk-DEUGHURX.js} +2 -2
  74. package/dist/chunk-DHKBIOXF.js +7 -0
  75. package/dist/chunk-DMQ7ZKJG.js +81 -0
  76. package/dist/chunk-DMUGTKMD.js +2 -0
  77. package/dist/chunk-DOPCR5BY.js +2 -0
  78. package/dist/chunk-DRENNWRG.js +2 -0
  79. package/dist/chunk-E4EJBGDZ.js +2 -0
  80. package/dist/chunk-E7BJXRNV.js +2 -0
  81. package/dist/chunk-EA4SH4U5.js +5 -0
  82. package/dist/{chunk-L7AW2QB5.js → chunk-EKZRF57O.js} +2 -2
  83. package/dist/chunk-ELNRLMC5.js +29 -0
  84. package/dist/chunk-F4FNK44D.js +2 -0
  85. package/dist/chunk-F7WQ337U.js +308 -0
  86. package/dist/chunk-FEQIQ26E.js +2 -0
  87. package/dist/chunk-FGB567HK.js +23 -0
  88. package/dist/chunk-FHV7NMFU.js +29 -0
  89. package/dist/chunk-FN6EJM6Q.js +2 -0
  90. package/dist/chunk-FTSQNONX.js +2 -0
  91. package/dist/chunk-FUG6RPYY.js +6 -0
  92. package/dist/chunk-G2F6T5BV.js +2 -0
  93. package/dist/chunk-G6OGPXJW.js +9 -0
  94. package/dist/chunk-GFLTPNWV.js +3 -0
  95. package/dist/chunk-GTDP2SKQ.js +2 -0
  96. package/dist/chunk-H46QMB7E.js +2 -0
  97. package/dist/chunk-H5EXS3HM.js +2 -0
  98. package/dist/chunk-HEOMG7IM.js +8 -0
  99. package/dist/chunk-HG5YI7PV.js +2 -0
  100. package/dist/{chunk-7SQQWSY3.js → chunk-HGKEAP7F.js} +2 -2
  101. package/dist/chunk-HUZNZ3H2.js +2 -0
  102. package/dist/chunk-HWLCBKFE.js +2 -0
  103. package/dist/chunk-I3U2FN2T.js +13 -0
  104. package/dist/{chunk-JAYYFEQY.js → chunk-I7PFL5P3.js} +2 -2
  105. package/dist/{chunk-2HPVVXM5.js → chunk-ICHBVITH.js} +2 -2
  106. package/dist/chunk-ICUQONOG.js +38 -0
  107. package/dist/chunk-IDPLC3FI.js +5 -0
  108. package/dist/{chunk-A73XVBCR.js → chunk-IGKKTHJR.js} +2 -2
  109. package/dist/chunk-IOKWFRFQ.js +4 -0
  110. package/dist/chunk-IPAL6DP2.js +3 -0
  111. package/dist/chunk-IUJ3ZFEE.js +7 -0
  112. package/dist/chunk-IXJ26KJJ.js +16 -0
  113. package/dist/chunk-IYV2YBHM.js +2 -0
  114. package/dist/chunk-JVZNWJBH.js +2 -0
  115. package/dist/chunk-K5MZYZV7.js +3 -0
  116. package/dist/{chunk-3G66UZBH.js → chunk-KFK7GF5C.js} +2 -2
  117. package/dist/chunk-KTRGJLY7.js +18 -0
  118. package/dist/chunk-KW6B5OL4.js +2 -0
  119. package/dist/chunk-KWARB5FZ.js +2 -0
  120. package/dist/chunk-LHTT5C3Z.js +2 -0
  121. package/dist/chunk-LPGDO2XA.js +3 -0
  122. package/dist/chunk-LXLD46LH.js +21 -0
  123. package/dist/chunk-MEI3PTUK.js +2 -0
  124. package/dist/chunk-MJNV7OCG.js +5 -0
  125. package/dist/chunk-MO226P4Q.js +4 -0
  126. package/dist/{chunk-3CLX5EOX.js → chunk-MOBF2GH6.js} +2 -2
  127. package/dist/chunk-MXNGIEPU.js +3 -0
  128. package/dist/chunk-MYUKI5VN.js +4 -0
  129. package/dist/{chunk-TFRAYKN6.js → chunk-N5C65OFK.js} +2 -2
  130. package/dist/{chunk-PXY7F6Y4.js → chunk-O2RM7E7L.js} +5 -5
  131. package/dist/chunk-OFUBXBYX.js +3 -0
  132. package/dist/chunk-OFY4HTMI.js +2 -0
  133. package/dist/chunk-OIRWZIYL.js +38 -0
  134. package/dist/chunk-OIVZ7PW6.js +438 -0
  135. package/dist/chunk-ORBKAUCH.js +4 -0
  136. package/dist/chunk-OUB4J26T.js +2 -0
  137. package/dist/chunk-OVPS2ILI.js +20 -0
  138. package/dist/chunk-PHSPBQM6.js +5 -0
  139. package/dist/{chunk-JVYA47YU.js → chunk-PIZY2GX6.js} +2 -2
  140. package/dist/chunk-PNISDVYC.js +3 -0
  141. package/dist/chunk-PQOL42AW.js +2 -0
  142. package/dist/chunk-PUVZNFVY.js +11 -0
  143. package/dist/chunk-PZEI2TVL.js +4 -0
  144. package/dist/{chunk-ZK26BAQL.js → chunk-Q2J2VZZT.js} +2 -2
  145. package/dist/chunk-Q7HB7BFJ.js +2 -0
  146. package/dist/{chunk-ZTETIQ35.js → chunk-QBANU5BQ.js} +2 -2
  147. package/dist/chunk-QD7IFBCR.js +10 -0
  148. package/dist/chunk-QDCCHMVZ.js +2 -0
  149. package/dist/chunk-QLQBZOJH.js +3 -0
  150. package/dist/{chunk-PQCI4SQX.js → chunk-QXR5QPSF.js} +2 -2
  151. package/dist/chunk-R2MOKIVO.js +2 -0
  152. package/dist/{chunk-EN3O7VJA.js → chunk-RFWAUHVW.js} +2 -2
  153. package/dist/chunk-RGCJ4646.js +16 -0
  154. package/dist/{chunk-BPAPWKP6.js → chunk-S3RTPPLQ.js} +8 -8
  155. package/dist/chunk-S73HBCGI.js +11 -0
  156. package/dist/chunk-SDPA5DKN.js +210 -0
  157. package/dist/chunk-SEUJVWT2.js +3 -0
  158. package/dist/chunk-SF7X6QNW.js +2 -0
  159. package/dist/chunk-SKUMCCC5.js +2 -0
  160. package/dist/chunk-SSSJO4RG.js +2 -0
  161. package/dist/chunk-SWFAFA4G.js +49 -0
  162. package/dist/chunk-SYUNTKO2.js +2 -0
  163. package/dist/chunk-T6FRID7Y.js +3 -0
  164. package/dist/chunk-TGWNNMPF.js +3 -0
  165. package/dist/chunk-TM5XEDDR.js +4 -0
  166. package/dist/chunk-TNOHGHZQ.js +2 -0
  167. package/dist/chunk-U2GPTA5U.js +3 -0
  168. package/dist/{chunk-SXP2MBJH.js → chunk-U7DR7MJD.js} +2 -2
  169. package/dist/chunk-U7LRSQG6.js +3 -0
  170. package/dist/chunk-UL4VJUMD.js +2 -0
  171. package/dist/chunk-UNORWZIJ.js +16 -0
  172. package/dist/chunk-UQ7XPRWU.js +2 -0
  173. package/dist/{chunk-6SHPK5ZE.js → chunk-URMZLV2N.js} +2 -2
  174. package/dist/chunk-URTX2BEA.js +6 -0
  175. package/dist/chunk-UZFCZ7SJ.js +2 -0
  176. package/dist/{chunk-KMKTIO2G.js → chunk-V7LQZTTZ.js} +2 -2
  177. package/dist/chunk-VETXXOYU.js +3 -0
  178. package/dist/chunk-VGRUM7JI.js +3 -0
  179. package/dist/{chunk-WXZLAAWK.js → chunk-VNKYRJKN.js} +2 -2
  180. package/dist/chunk-VWLIOEEF.js +11 -0
  181. package/dist/chunk-WB6LGCFB.js +6 -0
  182. package/dist/{chunk-W4ETQAXM.js → chunk-WK4FD4PG.js} +2 -2
  183. package/dist/{chunk-O64IZ6UX.js → chunk-WKPZCQLI.js} +2 -2
  184. package/dist/chunk-WSG3DK5H.js +2 -0
  185. package/dist/chunk-WULAPQUD.js +38 -0
  186. package/dist/chunk-WZQFY5S7.js +4 -0
  187. package/dist/chunk-X434XZAI.js +2 -0
  188. package/dist/chunk-X7PJJYKX.js +29 -0
  189. package/dist/chunk-XDAUYDFT.js +2 -0
  190. package/dist/chunk-XITQLISP.js +2 -0
  191. package/dist/chunk-XRXCANFQ.js +4 -0
  192. package/dist/chunk-XVDMJMES.js +3 -0
  193. package/dist/chunk-XXJ7WL3F.js +35 -0
  194. package/dist/chunk-Y4XQ7LES.js +9 -0
  195. package/dist/chunk-YIEFEPG6.js +16 -0
  196. package/dist/chunk-YRVERHJR.js +49 -0
  197. package/dist/{chunk-CJST5ETY.js → chunk-YUFWLWIC.js} +2 -2
  198. package/dist/chunk-YUKYB54I.js +1 -0
  199. package/dist/chunk-Z3GCK3PD.js +3 -0
  200. package/dist/chunk-ZBNL3QCY.js +4 -0
  201. package/dist/chunk-ZD3Z54IW.js +2 -0
  202. package/dist/chunk-ZDVDSDFG.js +4 -0
  203. package/dist/{chunk-32LVLCLN.js → chunk-ZHSARYVS.js} +3 -3
  204. package/dist/{chunk-BDCC2NPY.js → chunk-ZW44MCJM.js} +2 -2
  205. package/dist/{chunk-N5W4YZMK.js → chunk-ZYREOING.js} +2 -2
  206. package/dist/cli-main.js +8 -0
  207. package/dist/cli.js +1 -3
  208. package/dist/code-CczEvHui.d.ts +121 -0
  209. package/dist/code-EQL6ZBLH.js +2 -0
  210. package/dist/code-result-json-6E4J6LGZ.js +2 -0
  211. package/dist/command-descriptors-QH3G2OVD.js +346 -0
  212. package/dist/{config-types-jVM3D7MA.d.ts → config-types-Cm-VSEBb.d.ts} +189 -23
  213. package/dist/dataflow-2BLMUZBP.js +2 -0
  214. package/dist/{db-B5PM5yNk.d.ts → db-LKJXAlNS.d.ts} +1 -1
  215. package/dist/dependence-slice-MGAJDZXB.js +2 -0
  216. package/dist/deps-GQMUYVKW.js +2 -0
  217. package/dist/direct-navigation-6RUJKLAV.js +3 -0
  218. package/dist/entry-map-V2NQP5JU.js +2 -0
  219. package/dist/exploration-topology-BG4v30HZ.d.ts +256 -0
  220. package/dist/file-dep-graph-Bqg3t3Px.d.ts +4 -0
  221. package/dist/file-kind-BKCVMNUf.d.ts +10 -0
  222. package/dist/files-VM53I4IU.js +2 -0
  223. package/dist/graph-evidence-CbUPCSKV.d.ts +126 -0
  224. package/dist/graph-exploration-contract-CqDsnPQL.d.ts +7 -0
  225. package/dist/{health-Do5TKSJI.d.ts → health-Wl5G_LRt.d.ts} +33 -34
  226. package/dist/hierarchy-D553WRSZ.js +2 -0
  227. package/dist/imports-DOZAJWLW.js +2 -0
  228. package/dist/index.d.ts +4 -31
  229. package/dist/index.js +1 -1
  230. package/dist/members-HE67475K.js +2 -0
  231. package/dist/methods-K5JK4PPH.js +2 -0
  232. package/dist/next-anchor-candidates-BwMczMvX.d.ts +90 -0
  233. package/dist/output-continuation-command-LKBUTNRL.js +3 -0
  234. package/dist/output-pagination-VAWOGX4R.js +19 -0
  235. package/dist/postinstall.js +1 -1
  236. package/dist/project-reindex-4ARU6QCM.js +3 -0
  237. package/dist/queries/affected.d.ts +22 -4
  238. package/dist/queries/affected.js +1 -1
  239. package/dist/queries/anchors.d.ts +123 -0
  240. package/dist/queries/anchors.js +2 -0
  241. package/dist/queries/architecture.d.ts +3 -2
  242. package/dist/queries/architecture.js +1 -1
  243. package/dist/queries/bottlenecks.d.ts +26 -7
  244. package/dist/queries/bottlenecks.js +1 -1
  245. package/dist/queries/by-kind.d.ts +2 -2
  246. package/dist/queries/by-kind.js +1 -1
  247. package/dist/queries/call-graph.d.ts +17 -3
  248. package/dist/queries/call-graph.js +1 -1
  249. package/dist/queries/change-surface.d.ts +2 -2
  250. package/dist/queries/change-surface.js +1 -1
  251. package/dist/queries/cleanup-plan.d.ts +2 -2
  252. package/dist/queries/cleanup-plan.js +1 -1
  253. package/dist/queries/co-change.d.ts +2 -2
  254. package/dist/queries/co-change.js +1 -1
  255. package/dist/queries/code.d.ts +5 -26
  256. package/dist/queries/code.js +1 -1
  257. package/dist/queries/complexity-hotspots.d.ts +2 -2
  258. package/dist/queries/complexity-hotspots.js +1 -1
  259. package/dist/queries/complexity.d.ts +2 -2
  260. package/dist/queries/complexity.js +1 -1
  261. package/dist/queries/context.d.ts +145 -0
  262. package/dist/queries/context.js +2 -0
  263. package/dist/queries/convergence.d.ts +2 -2
  264. package/dist/queries/convergence.js +1 -1
  265. package/dist/queries/coupling.d.ts +8 -3
  266. package/dist/queries/coupling.js +1 -1
  267. package/dist/queries/cycles.d.ts +34 -7
  268. package/dist/queries/cycles.js +1 -1
  269. package/dist/queries/dataflow.d.ts +40 -14
  270. package/dist/queries/dataflow.js +1 -1
  271. package/dist/queries/dead.d.ts +2 -2
  272. package/dist/queries/dead.js +1 -1
  273. package/dist/queries/decorative-checkers.d.ts +3 -3
  274. package/dist/queries/decorative-checkers.js +1 -1
  275. package/dist/queries/deep-chains.d.ts +4 -38
  276. package/dist/queries/deep-chains.js +1 -1
  277. package/dist/queries/dependence-slice.d.ts +47 -0
  278. package/dist/queries/dependence-slice.js +2 -0
  279. package/dist/queries/dependency-depth.d.ts +49 -0
  280. package/dist/queries/dependency-depth.js +2 -0
  281. package/dist/queries/deps.d.ts +4 -2
  282. package/dist/queries/deps.js +1 -1
  283. package/dist/queries/diff-impact.d.ts +3 -3
  284. package/dist/queries/diff-impact.js +1 -1
  285. package/dist/queries/doc-drift.d.ts +4 -4
  286. package/dist/queries/doc-drift.js +1 -1
  287. package/dist/queries/drift.d.ts +2 -2
  288. package/dist/queries/drift.js +1 -1
  289. package/dist/queries/duplicate-bodies.d.ts +2 -2
  290. package/dist/queries/duplicate-bodies.js +1 -1
  291. package/dist/queries/entry-map.d.ts +121 -0
  292. package/dist/queries/entry-map.js +2 -0
  293. package/dist/queries/evidence.d.ts +70 -0
  294. package/dist/queries/evidence.js +2 -0
  295. package/dist/queries/extract-candidates.d.ts +2 -2
  296. package/dist/queries/extract-candidates.js +1 -1
  297. package/dist/queries/fan.d.ts +18 -5
  298. package/dist/queries/fan.js +1 -1
  299. package/dist/queries/files.d.ts +2 -2
  300. package/dist/queries/files.js +1 -1
  301. package/dist/queries/health.d.ts +4 -3
  302. package/dist/queries/health.js +1 -1
  303. package/dist/queries/hierarchy.d.ts +5 -3
  304. package/dist/queries/hierarchy.js +1 -1
  305. package/dist/queries/hotspots.d.ts +11 -5
  306. package/dist/queries/hotspots.js +1 -1
  307. package/dist/queries/imports.d.ts +2 -2
  308. package/dist/queries/imports.js +1 -1
  309. package/dist/queries/incomplete-migration.d.ts +4 -4
  310. package/dist/queries/incomplete-migration.js +1 -1
  311. package/dist/queries/index.d.ts +56 -136
  312. package/dist/queries/index.js +1 -1
  313. package/dist/queries/isolated.d.ts +2 -2
  314. package/dist/queries/isolated.js +1 -1
  315. package/dist/queries/locality-candidates.d.ts +2 -2
  316. package/dist/queries/locality-candidates.js +1 -1
  317. package/dist/queries/members.d.ts +2 -2
  318. package/dist/queries/members.js +1 -1
  319. package/dist/queries/methods.d.ts +2 -2
  320. package/dist/queries/methods.js +1 -1
  321. package/dist/queries/not-implemented.d.ts +3 -3
  322. package/dist/queries/not-implemented.js +1 -1
  323. package/dist/queries/outline.d.ts +2 -2
  324. package/dist/queries/outline.js +1 -1
  325. package/dist/queries/passthrough-candidates.d.ts +5 -9
  326. package/dist/queries/passthrough-candidates.js +1 -1
  327. package/dist/queries/plan-context.d.ts +27 -64
  328. package/dist/queries/plan-context.js +1 -1
  329. package/dist/queries/react-component-duplicates.d.ts +2 -2
  330. package/dist/queries/react-component-duplicates.js +1 -1
  331. package/dist/queries/react-hook-candidates.d.ts +2 -2
  332. package/dist/queries/react-hook-candidates.js +1 -1
  333. package/dist/queries/react-large-component-pressure.d.ts +2 -2
  334. package/dist/queries/react-large-component-pressure.js +1 -1
  335. package/dist/queries/recent-duplicates.d.ts +2 -2
  336. package/dist/queries/recent-duplicates.js +1 -1
  337. package/dist/queries/redundant-reexports.d.ts +2 -2
  338. package/dist/queries/redundant-reexports.js +1 -1
  339. package/dist/queries/reference-neighborhood.d.ts +4 -0
  340. package/dist/queries/reference-neighborhood.js +2 -0
  341. package/dist/queries/reference-reachability.d.ts +48 -0
  342. package/dist/queries/reference-reachability.js +2 -0
  343. package/dist/queries/refs.d.ts +2 -2
  344. package/dist/queries/refs.js +1 -1
  345. package/dist/queries/self-audit.d.ts +2 -2
  346. package/dist/queries/self-audit.js +1 -1
  347. package/dist/queries/similar-chains.d.ts +2 -2
  348. package/dist/queries/similar-chains.js +1 -1
  349. package/dist/queries/similar-files.d.ts +2 -2
  350. package/dist/queries/similar-files.js +1 -1
  351. package/dist/queries/similar-signatures.d.ts +2 -2
  352. package/dist/queries/similar-signatures.js +1 -1
  353. package/dist/queries/similar.d.ts +2 -2
  354. package/dist/queries/similar.js +1 -1
  355. package/dist/queries/slice.d.ts +3 -36
  356. package/dist/queries/slice.js +1 -1
  357. package/dist/queries/source-inspection.d.ts +209 -0
  358. package/dist/queries/source-inspection.js +2 -0
  359. package/dist/queries/source-search.d.ts +13 -0
  360. package/dist/queries/source-search.js +2 -0
  361. package/dist/queries/stale-abstractions.d.ts +2 -2
  362. package/dist/queries/stale-abstractions.js +1 -1
  363. package/dist/queries/stats.d.ts +2 -2
  364. package/dist/queries/surface.d.ts +13 -4
  365. package/dist/queries/surface.js +1 -1
  366. package/dist/queries/symbols.d.ts +2 -2
  367. package/dist/queries/symbols.js +1 -1
  368. package/dist/queries/system-map.d.ts +449 -0
  369. package/dist/queries/system-map.js +2 -0
  370. package/dist/queries/system.d.ts +5 -3
  371. package/dist/queries/system.js +1 -1
  372. package/dist/queries/test-quality.d.ts +2 -2
  373. package/dist/queries/test-quality.js +1 -1
  374. package/dist/queries/trace.d.ts +47 -3
  375. package/dist/queries/trace.js +1 -1
  376. package/dist/queries/twin-ab.d.ts +3 -3
  377. package/dist/queries/twin-ab.js +1 -1
  378. package/dist/queries/twin-drift.d.ts +3 -3
  379. package/dist/queries/twin-drift.js +1 -1
  380. package/dist/queries/unused-imports.d.ts +2 -2
  381. package/dist/queries/unused-imports.js +1 -1
  382. package/dist/queries/unused-params.d.ts +2 -2
  383. package/dist/queries/unused-params.js +1 -1
  384. package/dist/queries/value-flow.d.ts +43 -0
  385. package/dist/queries/value-flow.js +2 -0
  386. package/dist/queries/vue-component-duplicates.d.ts +2 -2
  387. package/dist/queries/vue-component-duplicates.js +1 -1
  388. package/dist/queries/vue-composable-candidates.d.ts +2 -2
  389. package/dist/queries/vue-composable-candidates.js +1 -1
  390. package/dist/queries/vue-large-view-pressure.d.ts +2 -2
  391. package/dist/queries/vue-large-view-pressure.js +1 -1
  392. package/dist/queries/wrapper-candidates.d.ts +2 -2
  393. package/dist/queries/wrapper-candidates.js +1 -1
  394. package/dist/query-service-fastpath.js +6 -0
  395. package/dist/query-service-server.js +5 -0
  396. package/dist/refs-NBHKL4UQ.js +2 -0
  397. package/dist/refs-pagination-BBVTIHMH.js +2 -0
  398. package/dist/reindex-worker.js +27 -45
  399. package/dist/reindex.d.ts +62 -42
  400. package/dist/reindex.js +32 -33
  401. package/dist/repository-text-C0Q8VYdN.d.ts +19 -0
  402. package/dist/runtime.d.ts +286 -7
  403. package/dist/runtime.js +4 -3
  404. package/dist/rust-semantic-session-server.js +1 -1
  405. package/dist/rust-semantic-session-worker.js +1 -1
  406. package/dist/rust-semantic-worker.js +1 -1
  407. package/dist/{scip-cli-BnEwZRLJ.d.ts → scip-cli-CppzF5MK.d.ts} +33 -2
  408. package/dist/slice-U6S6LBSB.js +2 -0
  409. package/dist/source-search-types-Dwz8KeuW.d.ts +79 -0
  410. package/dist/source-snippet-_wrcgmZc.d.ts +15 -0
  411. package/dist/stats-OOJ74B32.js +2 -0
  412. package/dist/surface-C7SS5CDQ.js +2 -0
  413. package/dist/symbol-resolution-3FVEKDTJ.js +2 -0
  414. package/dist/system-6K2NOO5C.js +2 -0
  415. package/dist/trace-II5K2TMH.js +2 -0
  416. package/dist/typescript-mailbox-worker.js +1 -1
  417. package/dist/value-flow-MKFUUE5B.js +2 -0
  418. package/dist/watch-server.js +3 -2
  419. package/docs/AGENT_GUIDE.md +133 -476
  420. package/docs/AI_FAILURE_MODES.md +30 -301
  421. package/docs/API.md +1 -1
  422. package/docs/API_EVOLUTION.md +6 -0
  423. package/docs/CLI_JSON_OUTPUT.md +207 -29
  424. package/docs/COMMAND_REFERENCE.md +255 -154
  425. package/docs/CONFIGURATION_WRITE_SAFETY.md +14 -13
  426. package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +84 -0
  427. package/docs/DETECTOR_GUIDE.md +46 -138
  428. package/docs/DURABILITY.md +7 -1
  429. package/docs/INDEX_GENERATIONS.md +6 -0
  430. package/docs/LOCK_PROTOCOL.md +8 -0
  431. package/docs/REINDEX_METADATA_COMPATIBILITY.md +13 -3
  432. package/docs/SECURITY_MODEL.md +39 -42
  433. package/docs/accuracy-audit-checklist.md +4 -0
  434. package/docs/accuracy-hardening-goal.md +9 -2
  435. package/docs/analyzer-inventory.md +59 -264
  436. package/docs/analyzer-validation-protocol.md +62 -170
  437. package/docs/architecture-coherence-vision.md +18 -12
  438. package/docs/locality-analyzer-design.md +1 -1
  439. package/docs/schemas/cli-json-envelope.schema.json +212 -27
  440. package/docs/schemas/cli-json-export-receipt.schema.json +25 -0
  441. package/docs/schemas/cli-output-page.schema.json +1 -1
  442. package/docs/schemas/observation-receipt.schema.json +164 -0
  443. package/docs/schemas/project-config.schema.json +27 -45
  444. package/docs/schemas/suppression-record.schema.json +1 -34
  445. package/package.json +65 -8
  446. package/skills/concrete-plan/SKILL.md +8 -0
  447. package/skills/concrete-plan/agents/openai.yaml +4 -0
  448. package/skills/scip-explore/SKILL.md +3 -85
  449. package/skills/scip-explore/agents/openai.yaml +3 -3
  450. package/skills/scip-integrity-audit/SKILL.md +185 -0
  451. package/skills/scip-integrity-audit/agents/openai.yaml +4 -0
  452. package/skills/scip-plan/SKILL.md +67 -49
  453. package/skills/scip-plan/agents/openai.yaml +3 -3
  454. package/skills/scip-query/SKILL.md +77 -77
  455. package/skills/scip-query/agents/openai.yaml +3 -3
  456. package/skills/scip-setup/SKILL.md +10 -102
  457. package/skills/scip-setup/agents/openai.yaml +3 -3
  458. package/dist/chunk-26QA6FAI.js +0 -8
  459. package/dist/chunk-2KAZEZ6M.js +0 -2
  460. package/dist/chunk-3ORVDL3H.js +0 -2
  461. package/dist/chunk-46XGSFNI.js +0 -2
  462. package/dist/chunk-4MAK2HOY.js +0 -6
  463. package/dist/chunk-4TURLRL5.js +0 -16
  464. package/dist/chunk-4UQVNCQE.js +0 -2
  465. package/dist/chunk-55Q3WLZX.js +0 -2
  466. package/dist/chunk-5I5G2QOX.js +0 -3
  467. package/dist/chunk-6LDJQXAH.js +0 -2
  468. package/dist/chunk-6O5TICIZ.js +0 -3
  469. package/dist/chunk-7O5IKBTZ.js +0 -16
  470. package/dist/chunk-7S5E7KWT.js +0 -2
  471. package/dist/chunk-7WPLAODU.js +0 -5
  472. package/dist/chunk-AFHORGLH.js +0 -42
  473. package/dist/chunk-AIE7TFJW.js +0 -9
  474. package/dist/chunk-AQOFWNQJ.js +0 -1
  475. package/dist/chunk-B2PX5I6M.js +0 -2
  476. package/dist/chunk-B75HZHUP.js +0 -2
  477. package/dist/chunk-B7PBSLZN.js +0 -2
  478. package/dist/chunk-BBW6JFHN.js +0 -2
  479. package/dist/chunk-BNXCIFVY.js +0 -2
  480. package/dist/chunk-BS2NMXQZ.js +0 -4
  481. package/dist/chunk-C3KV2II6.js +0 -2
  482. package/dist/chunk-C43RDDP4.js +0 -20
  483. package/dist/chunk-DAFAHMNB.js +0 -42
  484. package/dist/chunk-DQLPXMH6.js +0 -8
  485. package/dist/chunk-EKZTZXHZ.js +0 -117
  486. package/dist/chunk-EW2NTSFA.js +0 -18
  487. package/dist/chunk-F3Z4OUDS.js +0 -8
  488. package/dist/chunk-FJH2NW7J.js +0 -66
  489. package/dist/chunk-FTFP6O3L.js +0 -11
  490. package/dist/chunk-FYLK2DEJ.js +0 -2
  491. package/dist/chunk-GH74ASD6.js +0 -11
  492. package/dist/chunk-GMXWZP2B.js +0 -2
  493. package/dist/chunk-GOUBFH5O.js +0 -3
  494. package/dist/chunk-HLF2TX6R.js +0 -2
  495. package/dist/chunk-HX7M4BDI.js +0 -30
  496. package/dist/chunk-HZ72SESS.js +0 -128
  497. package/dist/chunk-IB2N4FIY.js +0 -10
  498. package/dist/chunk-IZYYAFN5.js +0 -2
  499. package/dist/chunk-JFGGXWQF.js +0 -947
  500. package/dist/chunk-JN4NMBEX.js +0 -8
  501. package/dist/chunk-JW56N3KI.js +0 -4
  502. package/dist/chunk-JZ2OXNWB.js +0 -2
  503. package/dist/chunk-KFZNKUNT.js +0 -2
  504. package/dist/chunk-L5GJNV2T.js +0 -8
  505. package/dist/chunk-L7JDSCDF.js +0 -4
  506. package/dist/chunk-LU47HG23.js +0 -14
  507. package/dist/chunk-LVY7NPF7.js +0 -2
  508. package/dist/chunk-MKCDWWGV.js +0 -4
  509. package/dist/chunk-MNE7YG56.js +0 -2
  510. package/dist/chunk-MRXBEXSY.js +0 -26
  511. package/dist/chunk-MV7OWDUX.js +0 -2
  512. package/dist/chunk-NGEXCJJW.js +0 -11
  513. package/dist/chunk-NIW6JDC5.js +0 -29
  514. package/dist/chunk-PBUQFCNB.js +0 -16
  515. package/dist/chunk-POAVPHH7.js +0 -2
  516. package/dist/chunk-QZ4JVECJ.js +0 -2
  517. package/dist/chunk-RDO52JGY.js +0 -2
  518. package/dist/chunk-RJT3TUUZ.js +0 -2
  519. package/dist/chunk-RVLDN63O.js +0 -4
  520. package/dist/chunk-RXOXSKY3.js +0 -2
  521. package/dist/chunk-S7OYBOCK.js +0 -2
  522. package/dist/chunk-SMNXQT5Z.js +0 -3
  523. package/dist/chunk-SRAFT254.js +0 -2
  524. package/dist/chunk-T7YQSHPQ.js +0 -3
  525. package/dist/chunk-UJCOIXDY.js +0 -2
  526. package/dist/chunk-UJPRPGCO.js +0 -13
  527. package/dist/chunk-WCCFZ7V7.js +0 -113
  528. package/dist/chunk-WUPW3UN3.js +0 -3
  529. package/dist/chunk-X54AGLVX.js +0 -2
  530. package/dist/chunk-Y2MVPNKY.js +0 -5
  531. package/dist/chunk-YKUU5AIC.js +0 -3
  532. package/dist/chunk-YLCJLTPL.js +0 -2
  533. package/dist/chunk-YTQVETEO.js +0 -2
  534. package/dist/chunk-Z4N3MZYA.js +0 -38
  535. package/dist/chunk-ZJOOT3BG.js +0 -2
  536. package/dist/command-descriptors-DSS46KXI.js +0 -642
  537. package/dist/diff-gate-types-B0QYpDv1.d.ts +0 -11
  538. package/dist/direct-navigation-6YHV6IB5.js +0 -3
  539. package/dist/queries/diff-gate.d.ts +0 -253
  540. package/dist/queries/diff-gate.js +0 -2
  541. package/docs/COMMITTED_RECORD_COMPATIBILITY.md +0 -154
  542. package/docs/analyzer-validation-ledger.md +0 -516
  543. package/docs/schemas/outcome-event-record.schema.json +0 -95
  544. package/skills/_shared/SKILL.md +0 -101
  545. package/skills/_shared/agents/openai.yaml +0 -4
  546. package/skills/_shared/references/agent-contract-catalog.md +0 -105
  547. package/skills/_shared/references/command-catalog.md +0 -118
  548. package/skills/_shared/references/detector-precision-and-diffgate.md +0 -59
  549. package/skills/_shared/references/evidence-and-dead-code.md +0 -25
  550. package/skills/scip-audit/SKILL.md +0 -77
  551. package/skills/scip-audit/agents/openai.yaml +0 -4
  552. package/skills/scip-audit/references/claims.md +0 -98
  553. package/skills/scip-audit/references/cleanup.md +0 -100
  554. package/skills/scip-audit/references/directory.md +0 -222
  555. package/skills/scip-audit/references/frontend.md +0 -130
  556. package/skills/scip-audit/references/integrity.md +0 -154
  557. package/skills/scip-audit/references/maintainability.md +0 -162
  558. package/skills/scip-audit/references/twin-drift.md +0 -104
  559. package/skills/scip-diagnose/SKILL.md +0 -52
  560. package/skills/scip-diagnose/agents/openai.yaml +0 -4
  561. package/skills/scip-diagnose/references/debug.md +0 -117
  562. package/skills/scip-diagnose/references/probe-reachability.md +0 -77
  563. package/skills/scip-diagnose/references/root-cause.md +0 -145
  564. package/skills/scip-diagnose/references/triage.md +0 -119
  565. package/skills/scip-explore/references/diagrams.md +0 -40
  566. package/skills/scip-explore/references/language-playbook.md +0 -49
  567. package/skills/scip-improve/SKILL.md +0 -56
  568. package/skills/scip-improve/agents/openai.yaml +0 -4
  569. package/skills/scip-improve/references/cleanup-batches.md +0 -53
  570. package/skills/scip-improve/references/directory-moves.md +0 -53
  571. package/skills/scip-improve/references/doc-reconcile.md +0 -30
  572. package/skills/scip-improve/references/frontend-extraction.md +0 -39
  573. package/skills/scip-improve/references/maintainability-mechanism.md +0 -43
  574. package/skills/scip-improve/references/twin-drift.md +0 -35
  575. package/skills/scip-plan/references/api-impact.md +0 -19
  576. package/skills/scip-plan/references/conductor.md +0 -41
  577. package/skills/scip-plan/references/high-assurance.md +0 -43
  578. package/skills/scip-plan/references/hyper-optimization.md +0 -50
  579. package/skills/scip-plan/references/tla-model.md +0 -88
  580. package/skills/scip-setup/references/bootstrap-workflow.md +0 -119
  581. package/skills/scip-setup/references/language-verification.md +0 -61
  582. package/skills/scip-setup/references/lifecycle-commands.md +0 -119
  583. package/skills/scip-setup/references/per-repo-triage.md +0 -24
  584. package/skills/scip-verify/SKILL.md +0 -229
  585. package/skills/scip-verify/agents/openai.yaml +0 -4
  586. package/skills/scip-verify/references/calibrate-detectors.md +0 -170
@@ -0,0 +1,19 @@
1
+ type SourceSemanticFreshnessState = 'aligned' | 'stale' | 'unavailable';
2
+ /**
3
+ * Freshness of one source observation. Exact text is read from the current
4
+ * worktree; semantic alignment compares those bytes with the indexed input
5
+ * fingerprint when the file has compiler facts.
6
+ */
7
+ interface SourceObservationFreshness {
8
+ exactText: {
9
+ state: 'current';
10
+ basis: 'working-tree-read';
11
+ sha256: string;
12
+ };
13
+ semantic: {
14
+ state: SourceSemanticFreshnessState;
15
+ basis: 'indexed-input-fingerprint' | 'no-compiler-document' | 'fingerprint-unavailable';
16
+ };
17
+ }
18
+
19
+ export type { SourceObservationFreshness as S, SourceSemanticFreshnessState as a };
package/dist/runtime.d.ts CHANGED
@@ -1,8 +1,19 @@
1
- import { P as ProjectConfig, a as SupportedLanguage, T as TypeScriptProjectMode } from './config-types-jVM3D7MA.js';
2
- export { O as OBSERVATION_RECEIPT_SCHEMA_VERSION, b as ObservationAuthorityKind, c as ObservationReceipt, d as ObservationReceiptComparison, e as compareObservationReceipts, i as isObservationReceipt } from './config-types-jVM3D7MA.js';
1
+ import { P as ProjectConfig, W as WatchConfig, b as WatchResourceBudgetConfig, a as SupportedLanguage, T as TypeScriptProjectMode, D as DerivedObservationStateAuthority, O as ObservationSourceKind, c as ObservationReceipt } from './config-types-Cm-VSEBb.js';
2
+ export { d as DecodedObservationReceipt, L as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION, e as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION, f as OBSERVATION_IDENTITY_HASH_ALGORITHM, g as OBSERVATION_IDENTITY_SCHEMA_VERSION, h as OBSERVATION_RECEIPT_SCHEMA_VERSION, i as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION, j as ObservationAuthorityKind, k as ObservationComparedFact, l as ObservationComparisonReason, m as ObservationIdentity, n as ObservationReceiptComparison, o as ObservationReceiptV1, p as ObservationReceiptV2, q as ObservationRelationshipJudgment, r as ObservationRelationshipState, s as ObservationSourceFact, t as ObservationStabilityProof, u as ObservationStabilityProofKind, v as ObservationStateAuthority, R as RelevantInputIdentity, w as RelevantInputRelationshipJudgment, x as compareObservationReceipts, y as createObservationIdentity, z as decodeObservationReceipt, A as deriveObservationStateAuthority, B as isObservationReceipt, C as observationReceiptGenerationIdentity, E as observationReceiptStabilityLabel, F as observationReceiptWorkspaceIdentity } from './config-types-Cm-VSEBb.js';
3
3
  import { watch } from 'chokidar';
4
- import { R as RefreshTrigger, W as WatcherStatus } from './scip-cli-BnEwZRLJ.js';
5
- export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-BnEwZRLJ.js';
4
+ import { R as RefreshTrigger, P as ProjectInputChangeJournal, W as WatcherStatus } from './scip-cli-CppzF5MK.js';
5
+ export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-CppzF5MK.js';
6
+
7
+ /**
8
+ * One operating-system process instance. A PID alone names a reusable slot;
9
+ * the start token distinguishes successive processes that occupy that slot.
10
+ */
11
+ interface ProcessIdentity {
12
+ version: 1;
13
+ pid: number;
14
+ platform: NodeJS.Platform;
15
+ startToken: string;
16
+ }
6
17
 
7
18
  declare function resolveIndexStoragePaths(projectRoot: string, config?: ProjectConfig): {
8
19
  cacheDir: string;
@@ -11,6 +22,10 @@ declare function resolveIndexStoragePaths(projectRoot: string, config?: ProjectC
11
22
  metaPath: string;
12
23
  };
13
24
 
25
+ type ResolvedWatchConfig = Omit<Required<WatchConfig>, 'resourceBudget'> & {
26
+ resourceBudget: Required<WatchResourceBudgetConfig>;
27
+ };
28
+
14
29
  /**
15
30
  * Load project config from .scipquery.json in the project root.
16
31
  * Returns defaults for anything not specified.
@@ -22,20 +37,55 @@ declare function loadProjectConfig(projectRoot: string): ProjectConfig;
22
37
  */
23
38
  declare function initProjectConfig(projectRoot: string, languages: string[]): string;
24
39
 
40
+ interface GitReader {
41
+ run(projectRoot: string, args: readonly string[]): string | undefined;
42
+ runResult(projectRoot: string, args: readonly string[]): GitCommandResult;
43
+ }
44
+ type GitCommandResult = {
45
+ kind: 'success';
46
+ output: string;
47
+ } | {
48
+ kind: 'not-repository';
49
+ } | {
50
+ kind: 'error';
51
+ message: string;
52
+ };
53
+
54
+ type ReindexActivityBudgetDecision = {
55
+ state: 'allowed';
56
+ rebuilt: number;
57
+ estimatedWriteBytes: number;
58
+ } | {
59
+ state: 'paused';
60
+ reason: 'rebuild-count' | 'estimated-write-bytes' | 'activity-evidence';
61
+ until: number;
62
+ rebuilt: number;
63
+ estimatedWriteBytes: number;
64
+ detail: string;
65
+ };
66
+
25
67
  interface WatcherOptions {
26
68
  projectRoot: string;
27
69
  config: ProjectConfig;
28
70
  languages?: SupportedLanguage[];
29
71
  reindexRunner?: ReindexRunner;
30
72
  subscriptionFactory?: WatchSubscriptionFactory;
73
+ budgetInspector?: WatchBudgetInspector;
74
+ gitReader?: GitReader;
75
+ outputDb?: string;
31
76
  clock?: WatchClock;
32
77
  stopTimeoutMs?: number;
33
78
  onStatus?: (status: WatcherStatus) => void;
34
- onReindexComplete?: (durationMs: number, trigger: RefreshTrigger) => boolean | void;
79
+ onReindexComplete?: (durationMs: number, trigger: RefreshTrigger, context?: ReindexCompletionContext) => boolean | void;
35
80
  onReindexError?: (error: Error, trigger: RefreshTrigger) => void;
36
81
  onRefreshSuppressed?: (trigger: RefreshTrigger) => void;
37
82
  onError?: (error: Error) => void;
38
83
  }
84
+ interface ReindexCompletionContext {
85
+ /** True when a filesystem or refresh event arrived after this run began. */
86
+ pendingChanges: boolean;
87
+ }
88
+ type WatchBudgetInspector = (outputDb: string, config: ResolvedWatchConfig['resourceBudget'], now: Date) => ReindexActivityBudgetDecision;
39
89
  interface ReindexRunRequest {
40
90
  projectRoot: string;
41
91
  config: ProjectConfig;
@@ -46,6 +96,10 @@ interface ReindexRunRequest {
46
96
  clojureConfigPath?: string;
47
97
  indexerConcurrency?: number;
48
98
  trigger: RefreshTrigger;
99
+ /** Exact watcher changes since the immutable generation named by the journal. */
100
+ changeJournal?: ProjectInputChangeJournal;
101
+ /** When false, skip full language indexers and keep the previous shard. Default true. */
102
+ allowExpensiveRebuild?: boolean;
49
103
  }
50
104
  interface ReindexWorkerLaunch {
51
105
  workerPath: string;
@@ -117,6 +171,7 @@ declare class Watcher {
117
171
  private projectRoot;
118
172
  private config;
119
173
  private watchConfig;
174
+ private outputDb;
120
175
  private languages?;
121
176
  private pnpmWorkspaces;
122
177
  private typescriptProjectMode?;
@@ -130,6 +185,7 @@ declare class Watcher {
130
185
  private onError;
131
186
  private reindexRunner;
132
187
  private subscriptionFactory;
188
+ private budgetInspector;
133
189
  private clock;
134
190
  private activeOperation;
135
191
  private stopPromise;
@@ -137,15 +193,24 @@ declare class Watcher {
137
193
  private status;
138
194
  private debounceTimer;
139
195
  private cooldownTimer;
196
+ private budgetTimer;
140
197
  private dirty;
141
198
  private changedFiles;
142
199
  private pendingTrigger;
200
+ private pendingChanges;
201
+ private pendingChangesComplete;
202
+ private pendingChangesIncompleteReason;
143
203
  private reindexInFlight;
144
204
  private lastReindexEnd;
145
205
  private fsWatchers;
146
206
  private sourcePollingFallbackStarted;
147
207
  private gitPollTimer;
148
208
  private lastGitState;
209
+ /** When unset, idle Git polls read HEAD/index from the filesystem instead of spawning git. */
210
+ private preferFilesystemGitState;
211
+ private watchGitLayout;
212
+ /** Project-relative cache directory; ignored so reindex artifacts do not wake the watcher. */
213
+ private localCacheWatchPath;
149
214
  private gitignoreFilter;
150
215
  private extraIgnore;
151
216
  private stopped;
@@ -167,16 +232,25 @@ declare class Watcher {
167
232
  private triggerReindex;
168
233
  private finishStop;
169
234
  private wallNow;
235
+ private inspectBudget;
170
236
  private reindexRequest;
171
237
  private setStatus;
238
+ private recordPendingChange;
239
+ private markPendingChangesIncomplete;
240
+ private consumePendingChangeJournal;
241
+ private restorePendingChangeJournal;
242
+ private resetPendingChanges;
172
243
  private clearDebounceTimer;
173
244
  private clearCooldownTimer;
245
+ private clearBudgetTimer;
174
246
  private startGitStatePolling;
175
247
  private pollGitState;
176
248
  private readGitState;
249
+ private readFilesystemGitState;
250
+ private readGitStateFromGit;
177
251
  private clearGitPollTimer;
178
252
  }
179
- declare function resolveReindexWorkerLaunch(request: ReindexRunRequest): ReindexWorkerLaunch;
253
+ declare function resolveReindexWorkerLaunch(request: ReindexRunRequest, resolveParentIdentity?: (pid: number) => ProcessIdentity | null): ReindexWorkerLaunch;
180
254
  declare function createReindexRunner(options?: ReindexRunnerOptions): ReindexRunner;
181
255
 
182
256
  interface InstallSkillsResult {
@@ -193,15 +267,215 @@ interface InstallSkillsResult {
193
267
  */
194
268
  declare function installSkills(opts?: {
195
269
  quiet?: boolean;
270
+ homeDir?: string;
196
271
  }): InstallSkillsResult;
197
272
 
273
+ /**
274
+ * What one parsed command invocation does to or learns about the world.
275
+ *
276
+ * A command name is not sufficient: one command can preview in one mode and
277
+ * mutate in another. The selected role follows the invocation's observable
278
+ * effect, not the subsystem that implements it.
279
+ */
280
+ declare const COMMAND_OPERATION_ROLES: readonly ["repository-observation", "repository-preview", "mutation", "composite", "environment-observation", "tool-information"];
281
+ type CommandOperationRole = (typeof COMMAND_OPERATION_ROLES)[number];
282
+ type CommandOperationRuleCondition = {
283
+ kind: 'argument';
284
+ index: number;
285
+ equals: string | number | boolean;
286
+ } | {
287
+ kind: 'option';
288
+ name: string;
289
+ equals: string | number | boolean;
290
+ } | {
291
+ kind: 'option-present';
292
+ name: string;
293
+ };
294
+ interface CommandOperationRule {
295
+ when: CommandOperationRuleCondition;
296
+ role: CommandOperationRole;
297
+ }
298
+ /**
299
+ * Declarative rather than executable so descriptors, docs, validation, and
300
+ * runtime selection all inspect one finite contract.
301
+ */
302
+ interface CommandOperationSelector {
303
+ defaultRole: CommandOperationRole;
304
+ rules?: readonly CommandOperationRule[];
305
+ }
306
+ interface CommandOperationInvocation {
307
+ args: readonly unknown[];
308
+ options: Readonly<Record<string, unknown>>;
309
+ }
310
+ declare function commandOperation(defaultRole: CommandOperationRole, rules?: readonly CommandOperationRule[]): CommandOperationSelector;
311
+ declare function resolveCommandOperationRole(selector: CommandOperationSelector, invocation: CommandOperationInvocation): CommandOperationRole;
312
+ declare function commandOperationRoles(selector: CommandOperationSelector): CommandOperationRole[];
313
+ declare function isCommandOperationRole(value: unknown): value is CommandOperationRole;
314
+ declare function operationObservesRepository(role: CommandOperationRole): boolean;
315
+
316
+ declare const CLAIM_QUALIFICATION_SCHEMA_VERSION: 1;
317
+ declare const CLAIM_ACTION_POLICY_VERSION: 1;
318
+ declare const CLAIM_ORIGINS: readonly ["compiler-graph", "semantic-analysis", "repository-source", "change-history", "runtime-measurement", "heuristic", "mixed", "unknown"];
319
+ type ClaimOrigin = (typeof CLAIM_ORIGINS)[number];
320
+ declare const CLAIM_COVERAGE_STATES: readonly ["complete", "partial", "unknown"];
321
+ type ClaimCoverageState = (typeof CLAIM_COVERAGE_STATES)[number];
322
+ declare const PRODUCER_VALIDATION_STATUSES: readonly ["validated", "failed", "not-evaluated", "not-applicable"];
323
+ type ProducerValidationStatus = (typeof PRODUCER_VALIDATION_STATUSES)[number];
324
+ declare const CLAIM_ACTION_PERMISSIONS: readonly ["observe", "advise", "require-adjudication", "block", "not-established"];
325
+ type ClaimActionPermission = (typeof CLAIM_ACTION_PERMISSIONS)[number];
326
+ /**
327
+ * A producer validation reports how one evidence-producing method performed
328
+ * against a named, versioned corpus. A successful status without that
329
+ * referent would be an assertion about the producer rather than checkable
330
+ * validation evidence.
331
+ */
332
+ type ProducerValidation = {
333
+ status: 'validated' | 'failed';
334
+ certification: {
335
+ id: string;
336
+ version: number;
337
+ corpus: string;
338
+ };
339
+ } | {
340
+ status: 'not-evaluated' | 'not-applicable';
341
+ certification?: never;
342
+ };
343
+ /**
344
+ * One result family is a stable set of result values that share an evidence
345
+ * origin. A fixed binding applies one origin to the selected family. A
346
+ * result-field binding maps the producer's existing per-row provenance field
347
+ * into the public origin vocabulary without copying or flattening the rows.
348
+ */
349
+ type ClaimFamilyOriginBinding = {
350
+ kind: 'fixed';
351
+ origin: Exclude<ClaimOrigin, 'mixed'>;
352
+ } | {
353
+ kind: 'result-field';
354
+ field: string;
355
+ values: Readonly<Record<string, Exclude<ClaimOrigin, 'mixed'>>>;
356
+ };
357
+ interface ClaimFamilyContract {
358
+ id: string;
359
+ /** Repository-relative JSON path rooted at the command-owned result. */
360
+ selector: string;
361
+ origin: ClaimFamilyOriginBinding;
362
+ }
363
+ /**
364
+ * The descriptor-owned facts about a command's evidence producer. These facts
365
+ * identify production and input sources; they do not grant state authority or
366
+ * repository-policy permission.
367
+ */
368
+ interface CommandClaimContract {
369
+ origin: ClaimOrigin;
370
+ observedSources: readonly ObservationSourceKind[];
371
+ producerValidation: ProducerValidation;
372
+ families?: readonly ClaimFamilyContract[];
373
+ }
374
+ interface ClaimCoverage {
375
+ state: ClaimCoverageState;
376
+ returned: number;
377
+ totalKnown: boolean;
378
+ total?: number;
379
+ omitted?: number;
380
+ }
381
+ interface RepositoryPolicyAction {
382
+ policyId: string;
383
+ policyVersion: typeof CLAIM_ACTION_POLICY_VERSION;
384
+ permission: ClaimActionPermission;
385
+ reasons: readonly string[];
386
+ }
387
+ /**
388
+ * A claim qualification is a set of independent facts that determine what one
389
+ * command result can support. Its real referents are the result's production
390
+ * method, enumeration extent, producer validation, observed repository state,
391
+ * and policy-permitted response. Keeping them independent is what prevents a
392
+ * strong fact in one dimension from silently strengthening another.
393
+ */
394
+ interface ClaimQualificationV1 {
395
+ schemaVersion: typeof CLAIM_QUALIFICATION_SCHEMA_VERSION;
396
+ origin: ClaimOrigin;
397
+ coverage: ClaimCoverage;
398
+ producerValidation: ProducerValidation;
399
+ stateAuthority: DerivedObservationStateAuthority;
400
+ repositoryPolicy: RepositoryPolicyAction;
401
+ families?: readonly ClaimFamilyContract[];
402
+ }
403
+ interface ClaimCoverageInput {
404
+ complete: boolean | null;
405
+ totalKnown: boolean;
406
+ returned: number;
407
+ total?: number;
408
+ omitted?: number;
409
+ }
410
+ interface DeriveClaimQualificationInput {
411
+ contract: CommandClaimContract;
412
+ receipt: ObservationReceipt;
413
+ coverage?: ClaimCoverageInput;
414
+ repositoryPolicy?: RepositoryPolicyAction;
415
+ }
416
+ declare const DEFAULT_REPOSITORY_POLICY_ACTION: RepositoryPolicyAction;
417
+ declare function deriveClaimQualification(input: DeriveClaimQualificationInput): ClaimQualificationV1;
418
+ declare function deriveClaimCoverage(coverage: ClaimCoverageInput | undefined): ClaimCoverage;
419
+ interface ClaimQualificationRequirements {
420
+ origins?: readonly ClaimOrigin[];
421
+ coverage?: readonly ClaimCoverageState[];
422
+ producerValidation?: readonly ProducerValidationStatus[];
423
+ stateAuthority?: readonly DerivedObservationStateAuthority['authority'][];
424
+ actionPermission?: readonly ClaimActionPermission[];
425
+ }
426
+ type ClaimQualificationPredicate = 'origin' | 'coverage' | 'producer-validation' | 'state-authority' | 'action-permission';
427
+ interface ClaimQualificationPredicateResult {
428
+ predicate: ClaimQualificationPredicate;
429
+ satisfied: boolean;
430
+ required: readonly string[];
431
+ actual: string;
432
+ }
433
+ interface ClaimQualificationEvaluation {
434
+ satisfied: boolean;
435
+ predicates: readonly ClaimQualificationPredicateResult[];
436
+ }
437
+ /**
438
+ * Evaluate only predicates named by the consumer. This is the consumer-side
439
+ * contract: an omitted requirement grants nothing and a satisfied predicate
440
+ * cannot compensate for an unsatisfied one.
441
+ */
442
+ declare function evaluateClaimQualification(qualification: ClaimQualificationV1, requirements: ClaimQualificationRequirements): ClaimQualificationEvaluation;
443
+ declare function isClaimQualificationV1(value: unknown): value is ClaimQualificationV1;
444
+
198
445
  declare const CLI_JSON_ENVELOPE_KIND: "scip-query-result";
199
446
  declare const LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION: 0;
200
447
  declare const CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION: 1;
448
+ declare const CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION: 1;
449
+ declare const CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION: 1;
201
450
  interface CliJsonProducer {
202
451
  name: 'scip-query';
203
452
  version: string;
204
453
  }
454
+ /**
455
+ * How one CLI result was produced and how much of the possible answer the
456
+ * invocation examined. These fields remain separate from the receipt because
457
+ * changing an analysis budget does not change which repository state was
458
+ * observed.
459
+ */
460
+ interface CliAnalysisManifestV1 {
461
+ schemaVersion: typeof CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION;
462
+ evidence?: 'graph-fact' | 'heuristic' | 'mixed';
463
+ analysisBudget?: unknown;
464
+ coverage?: unknown;
465
+ claimQualification?: ClaimQualificationV1;
466
+ }
467
+ /**
468
+ * The self-contained evidence carried by one repository-observation result.
469
+ * A version-1 receipt supplies local provenance; it does not by itself claim
470
+ * the fixed-snapshot and content relationships required for final completion.
471
+ */
472
+ interface CliEvidenceContextV1 {
473
+ schemaVersion: typeof CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION;
474
+ /** Optional only so evidence contexts written before operation roles remain readable. */
475
+ operationRole?: CommandOperationRole;
476
+ receipt: ObservationReceipt;
477
+ analysisManifest: CliAnalysisManifestV1;
478
+ }
205
479
  /**
206
480
  * One public machine-readable CLI response. The envelope is the stable
207
481
  * transport contract; `result` remains the command-owned payload whose schema
@@ -212,14 +486,19 @@ interface CliJsonEnvelopeV1<Result = unknown> {
212
486
  schemaVersion: typeof CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION;
213
487
  producer: CliJsonProducer;
214
488
  command: string;
489
+ /** Optional only for additive compatibility with envelopes written before this field existed. */
490
+ operationRole?: CommandOperationRole;
215
491
  resultSchemaVersion: number;
216
492
  evidence?: 'graph-fact' | 'heuristic' | 'mixed';
217
493
  analysisBudget?: unknown;
218
494
  args: readonly unknown[];
219
495
  options: Readonly<Record<string, unknown>>;
220
496
  result: Result;
497
+ /** Present only when `result` is the bounded command-owned agent projection. */
498
+ resultProjection?: 'agent';
221
499
  coverage?: unknown;
222
500
  agentResult?: unknown;
501
+ evidenceContext?: CliEvidenceContextV1;
223
502
  }
224
503
  interface LegacyCliJsonEnvelope<Result = unknown> {
225
504
  command: string;
@@ -272,4 +551,4 @@ declare function requireCompatibleCliJsonEnvelope<Result = unknown>(input: unkno
272
551
  */
273
552
  declare function supportedCliResultSchemaVersions(command: string): readonly number[];
274
553
 
275
- export { CLI_JSON_ENVELOPE_KIND, CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION, type CliJsonEnvelopeV1, type CliJsonProducer, type CompatibleCliJsonEnvelope, type DecodedCliJsonEnvelope, LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION, type LegacyCliJsonEnvelope, type ReindexCancellationResult, type ReindexDiagnostics, type ReindexOperation, type ReindexRunRequest, type ReindexRunner, type ReindexRunnerOptions, type ReindexWorkerLaunch, type WatchClock, type WatchSubscription, type WatchSubscriptionFactory, type WatchSubscriptionOptions, Watcher, type WatcherOptions, type WatcherStopResult, createReindexRunner, decodeCliJsonEnvelope, initProjectConfig, installSkills, loadProjectConfig, requireCompatibleCliJsonEnvelope, resolveIndexStoragePaths, resolveReindexWorkerLaunch, supportedCliResultSchemaVersions };
554
+ export { CLAIM_ACTION_PERMISSIONS, CLAIM_ACTION_POLICY_VERSION, CLAIM_COVERAGE_STATES, CLAIM_ORIGINS, CLAIM_QUALIFICATION_SCHEMA_VERSION, CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION, CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION, CLI_JSON_ENVELOPE_KIND, COMMAND_OPERATION_ROLES, CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION, type ClaimActionPermission, type ClaimCoverage, type ClaimCoverageInput, type ClaimCoverageState, type ClaimFamilyContract, type ClaimFamilyOriginBinding, type ClaimOrigin, type ClaimQualificationEvaluation, type ClaimQualificationPredicate, type ClaimQualificationPredicateResult, type ClaimQualificationRequirements, type ClaimQualificationV1, type CliAnalysisManifestV1, type CliEvidenceContextV1, type CliJsonEnvelopeV1, type CliJsonProducer, type CommandClaimContract, type CommandOperationInvocation, type CommandOperationRole, type CommandOperationRule, type CommandOperationRuleCondition, type CommandOperationSelector, type CompatibleCliJsonEnvelope, DEFAULT_REPOSITORY_POLICY_ACTION, type DecodedCliJsonEnvelope, type DeriveClaimQualificationInput, DerivedObservationStateAuthority, LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION, type LegacyCliJsonEnvelope, ObservationReceipt, ObservationSourceKind, PRODUCER_VALIDATION_STATUSES, type ProducerValidation, type ProducerValidationStatus, type ReindexCancellationResult, type ReindexCompletionContext, type ReindexDiagnostics, type ReindexOperation, type ReindexRunRequest, type ReindexRunner, type ReindexRunnerOptions, type ReindexWorkerLaunch, type RepositoryPolicyAction, type WatchClock, type WatchSubscription, type WatchSubscriptionFactory, type WatchSubscriptionOptions, Watcher, type WatcherOptions, type WatcherStopResult, commandOperation, commandOperationRoles, createReindexRunner, decodeCliJsonEnvelope, deriveClaimCoverage, deriveClaimQualification, evaluateClaimQualification, initProjectConfig, installSkills, isClaimQualificationV1, isCommandOperationRole, loadProjectConfig, operationObservesRepository, requireCompatibleCliJsonEnvelope, resolveCommandOperationRole, resolveIndexStoragePaths, resolveReindexWorkerLaunch, supportedCliResultSchemaVersions };
package/dist/runtime.js CHANGED
@@ -1,4 +1,5 @@
1
- import{a as B,b as K,c as Y}from"./chunk-RXOXSKY3.js";import{e as k,i as ke,j as Pe,k as Te,o as q,s as J,t as H}from"./chunk-JN4NMBEX.js";import{a as U}from"./chunk-7PIO7NKH.js";import"./chunk-DHEQMPLW.js";import{e as C,g as F,l as D,o as L,p as V,x as w,y as G}from"./chunk-BS2NMXQZ.js";import{a as f,d as N,f as M,g as A,l as $,n as W}from"./chunk-2KAZEZ6M.js";import"./chunk-C3KV2II6.js";import{existsSync as Le}from"fs";import{isAbsolute as Lt,join as ie,relative as Vt,resolve as Gt}from"path";var h=1,g=2,_e="./node_modules/scip-query/docs/schemas/project-config.schema.json";function z(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${a instanceof Error?a.message:String(a)}`}}if(!f(t))return{kind:"malformed",reason:"project config must be a JSON object"};let r=t.schemaVersion;if(r!==void 0&&!Number.isInteger(r))return{kind:"malformed",reason:"schemaVersion must be an integer"};let n=r===void 0?h:r;if(n!==h&&n!==g)return{kind:"unsupported",schemaVersion:n,direction:n<h?"older":"future"};let i=t.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=P(t),s=n!==g||typeof t.$schema!="string";return n===h?{kind:"legacy",sourceVersion:h,config:o,needsMigration:s}:{kind:"supported",sourceVersion:g,config:o,needsMigration:s}}function P(e){let t=e,{$schema:r,schemaVersion:n,...i}=t;return{$schema:typeof r=="string"&&r.trim()!==""?r:_e,schemaVersion:g,...i}}function X(e){return`${JSON.stringify(P(e),null,2)}
2
- `}import{createHash as Q}from"crypto";import{closeSync as Ie,fstatSync as Z,openSync as Oe,rmSync as je}from"fs";import{dirname as Ne}from"path";var Me=2e3,Ae=10,$e=3,b=class extends Error{constructor(r,n,i){super(`Concurrent edit detected for ${r}; expected revision ${te(n)}, but found ${te(i)}. The latest file was left untouched.`);this.path=r;this.original=n;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function re(e,t,r={}){let n=We(e,r.lockTimeoutMs??Me,r.monotonicNow??C);try{let i=Math.max(0,Math.floor(r.maxRetries??$e));for(let o=0;;o+=1){let s=x(e),a=t(s,o);if(a.kind==="unchanged")return{changed:!1,attempts:o+1,previous:s,current:s};r.onBeforeCommit?.({attempt:o,snapshot:s,mutation:a});let c=x(e);if(!De(s.revision,c.revision)){if(o<i)continue;throw new b(e,s.revision,c.revision)}try{Fe(e,a,s.revision)}catch(u){if(u.code==="EEXIST"){let p=x(e);if(o<i)continue;throw new b(e,s.revision,p.revision)}throw u}return{changed:!0,attempts:o+1,previous:s,current:x(e)}}}finally{n.release()}}function x(e){for(let t=0;t<4;t+=1){let r;try{r=Oe(e,"r");let n=ee(Z(r)),i=W(r,{maxBytes:A,inputKind:"revisioned text file"}),o=ee(Z(r));if(!ne(n,o))continue;return{path:e,text:i,revision:{exists:!0,hash:Q("sha256").update(i).digest("hex"),identity:o}}}catch(n){if(n.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:Q("sha256").update("").digest("hex")}};throw n}finally{r!==void 0&&Ie(r)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function We(e,t,r){let n=`${e}.scip-query-write.lock`,i=r()+Math.max(0,t);for(;;){let o=F(n,{kind:"revisioned-file-mutation",detail:{target:e}});if(o.kind==="acquired")return o.lock;if(r()>=i)throw new Error(`Timed out after ${t}ms waiting to update ${e}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Ae)}}function Fe(e,t,r){if(t.kind==="delete"){if(!r.exists)return;je(e),D(Ne(e));return}let n=t.mode??r.identity?.mode;r.exists?L(e,t.text,{durability:"durable",mode:n}):V(e,t.text,{durability:"durable",mode:n})}function De(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&ne(e.identity,t.identity))}function ee(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function ne(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function te(e){return e.exists?e.hash.slice(0,12):"<absent>"}var S=".scipquery.json",oe=250,se=5e3,ae=10*6e4,Ve={enabled:!1,debounceMs:oe,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:ae,autoRefresh:!0,ignore:[]};var Bt=new Set(N);function T(e){let t=ie(e,S);if(!Le(t))return{};let r;try{r=$(t,{maxBytes:M,inputKind:"scip-query project config"})}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`unable to read ${S} at ${t}: ${i}`,{cause:n})}return Je(z(r),t,"read").config}function ce(e){return{...Ve,...e.watch}}function Ge(e,t){return Ue(e,t).configPath}function Ue(e,t){let r=ie(e,S),n={languages:t,watch:{enabled:!0,debounceMs:oe,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:ae,autoRefresh:!0}},i=re(r,o=>o.revision.exists?{kind:"unchanged"}:{kind:"write",text:qe(n)});return{configPath:r,changed:i.changed}}function qe(e){return X(e)}function Je(e,t,r){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let i=r==="read"?`invalid ${S} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${i} The file was left untouched.`)}let n=r==="read"?`invalid ${S} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${n} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${h} and current v${g}). Upgrade scip-query before retrying; the file was left untouched.`)}import{statSync as He}from"fs";import{basename as Be,isAbsolute as Ke,join as Ye,relative as ze}from"path";import{watch as Xe}from"chokidar";import Qe from"ignore";var pe=5e3,_=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=ce(t.config),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onReindexError=t.onReindexError??(()=>{}),this.onRefreshSuppressed=t.onRefreshSuppressed??(()=>{}),this.onError=t.onError??(r=>console.error(r.message)),this.clock=t.clock??rt,he.set(this,lt(t.stopTimeoutMs??pe,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??ge(),this.subscriptionFactory=t.subscriptionFactory??nt,this.gitignoreFilter=U(t.projectRoot),this.extraIgnore=Qe(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,E(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let t=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let n=[...E(this).closures],i=et(this),o=this.clock.now()+i;return this.stopPromise=this.finishStop(t,n,r,o,i).catch(s=>{throw this.stopInProgress=!1,s}),this.stopPromise}requestRefresh(t,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(t);return}this.pendingTrigger=de(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:t,...t?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{this.stopped||this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,t)),this.fsWatchers.push(r)}handleSourceWatcherError(t,r,n){if(n||this.sourcePollingFallbackStarted||!ct(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==t),tt(E(this),t,i=>this.onError(i));try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(t,r){let n=this.relativeWatchPath(t);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(t){let r=this.relativeWatchPath(t);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Be(r).startsWith(q)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(t){let r=Ke(t)?t:Ye(this.projectRoot,t);return ze(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(t){if(this.pendingTrigger=de(this.pendingTrigger,t),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&t<this.watchConfig.cooldownMs){let o=this.watchConfig.cooldownMs-t;this.dirty=!0;let s=this.wallNow()+o;this.setStatus({state:"cooldown",until:s,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},o);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=this.wallNow();this.setStatus({state:"indexing",startedAt:n});let i=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=i,i.completion.then(o=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let s=!1;try{s=this.onReindexComplete(o,r)===!0}catch(a){this.onError(a instanceof Error?a:new Error(String(a)))}if(this.dirty&&!this.stopped){if(s){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let a=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(o=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let s=o instanceof Error?o:new Error(String(o));this.onReindexError(s,r),this.onError(s),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===i&&(this.activeOperation=null)})}async finishStop(t,r,n,i,o){let s=[],a=t.map(async d=>{try{await d.close()}catch(R){s.push(`watch subscription close failed: ${String(R)}`)}});a.push(...r),n&&a.push((async()=>{try{let d=await n.cancel();d.state==="degraded"&&s.push(d.reason)}catch(d){s.push(`reindex cancellation failed: ${d instanceof Error?d.message:String(d)}`)}})());let c=a.length,u=a.map(d=>d.finally(()=>{c-=1})),p=await Ze(u,i,this.clock),l=E(this);return s.push(...l.errors),l.errors=[],p?this.stopInProgress=!1:(s.push(`watch shutdown exceeded the ${o}ms deadline with ${c} operation(s) still pending`),Promise.all(u).then(()=>{this.stopInProgress=!1})),s.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:s.join("; ")}),{state:"degraded",reasons:s}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(t){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:t}}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let t=this.lastGitState,r=this.readGitState();if(!t||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let n=t.head!==r.head,i=t.indexPath!==r.indexPath||t.indexMtimeMs!==r.indexMtimeMs||t.indexSize!==r.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let t=w(this.projectRoot,["rev-parse","--git-path","index"]);if(!t)return null;let r=G(this.projectRoot,t),n={head:w(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let i=He(r);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Ze(e,t,r){if(e.length===0)return!0;let n=Promise.all(e).then(()=>!0),i=Math.max(0,t-r.now()),o=null,s=new Promise(c=>{o=r.setTimeout(()=>c(!1),i)}),a=await Promise.race([n,s]);return a&&o&&r.clearTimeout(o),a}var le=new WeakMap,he=new WeakMap;function E(e){let t=le.get(e);if(t)return t;let r={closures:new Set,errors:[]};return le.set(e,r),r}function et(e){return he.get(e)??pe}function tt(e,t,r){let n=Promise.resolve().then(()=>t.close()).catch(i=>{let o=`watch subscription close failed during polling fallback: ${String(i)}`;e.errors.push(o),r(new Error(o))});e.closures.add(n),n.then(()=>e.closures.delete(n))}function fe(e){let{projectRoot:t,config:r,languages:n,pnpmWorkspaces:i,typescriptProjectMode:o,typescriptProjects:s,clojureConfigPath:a,indexerConcurrency:c,trigger:u}=e,p=T(t),l=Object.keys(p).length>0?p:r,d=k(t,l),R=l.indexer?.typescript,we=l.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:t,SCIP_REINDEX_OUTPUT_SCIP:d.indexPath,SCIP_REINDEX_OUTPUT_DB:d.dbPath,SCIP_REINDEX_LANGUAGES:(l.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(l.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:R?.pnpmWorkspaces??i?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:R?.projectMode??o,projects:R?.projects??s??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:we?.configPath??a??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var rt={now:C,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nt=(e,t)=>Xe(e,t),it=15*6e4,ot=1e3,st=64*1024;function at(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function ue(e,t){let r=e instanceof Error?e.message:String(e),n=t.stderrTail.trim()||t.stdoutTail.trim();return n?`${r}
3
- ${n}`:r}function ge(e={}){let t=e.timeoutMs??it,r=e.terminationGraceMs??ot,n=e.maxOutputBytes??st,i=e.resolveLaunch??fe;return{start(o){let s=i(o),a=new AbortController,c=at(),u=!1,p=H({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:t,terminationGraceMs:r,maxStdoutBytes:n,maxStderrBytes:n,outputLimitBehavior:"truncate-tail",signal:a.signal,detached:!0}).then(l=>{if(c={stdoutTail:l.stdout,stderrTail:l.stderr,stdoutTruncated:l.stdoutTruncated,stderrTruncated:l.stderrTruncated},l.status!==0)throw new Error(ue(new Error(`Reindex worker exited with ${l.signal?`signal ${l.signal}`:`code ${l.status}`}`),c));return l.durationMs}).catch(l=>{throw l instanceof J&&(c={stdoutTail:l.stdout,stderrTail:l.stderr,stdoutTruncated:l.stdoutTruncated,stderrTruncated:l.stderrTruncated}),new Error(ue(l,c),{cause:l})}).finally(()=>{u=!0});return{completion:p,async cancel(){u||a.abort();try{await p}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function de(e,t){return e?e.kind===t.kind?e.detail===t.detail?e:{kind:e.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${e.kind}, ${t.kind}`}:t}function ct(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}function lt(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}import{existsSync as I,mkdirSync as ut,symlinkSync as dt,readlinkSync as me,unlinkSync as ye,readdirSync as pt}from"fs";import{join as m,dirname as j,resolve as y,relative as ht,isAbsolute as ft}from"path";import{homedir as O,platform as gt}from"os";import{fileURLToPath as mt}from"url";import{createHash as cr}from"crypto";import{resolve as ur}from"path";var yt=gt()==="win32",ve=["_shared","scip-query","scip-setup","scip-explore","scip-plan","scip-diagnose","scip-audit","scip-improve","scip-verify"];function vt(e={}){let t=e.quiet?()=>{}:console.log,r=mt(import.meta.url),n=y(j(r),"..","skills"),i=[m(O(),".claude","skills"),m(O(),".codex","skills"),m(O(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let s of i){let a=j(s);if(!I(a))continue;ut(s,{recursive:!0});let c=Ct(s);Rt(s,n,c,o,t);for(let u of ve){let p=m(n,u),l=m(s,u);if(!I(p)){o.skipped.push(`${c}/${u}`);continue}if(I(l)){try{let d=me(l);if(y(d)===y(p)){o.alreadyLinked.push(`${c}/${u}`),t(` ok: ${u} \u2192 ${c} (already linked)`);continue}}catch{o.skipped.push(`${c}/${u}`),t(` skip: ${u} \u2192 ${c} (exists, not a symlink)`);continue}ye(l)}dt(p,l,yt?"junction":"dir"),o.installed.push(`${c}/${u}`),t(` done: ${u} \u2192 ${c}`)}}return o}function Rt(e,t,r,n,i){let o=new Set(ve);for(let s of pt(e)){if(o.has(s))continue;let a=m(e,s),c;try{c=y(j(a),me(a))}catch{continue}St(c,t)&&(ye(a),n.pruned.push(`${r}/${s}`),i(` prune: ${s} \u2192 ${r} (removed stale scip-query skill link)`))}}function St(e,t){let r=ht(y(t),y(e));return r===""||!r.startsWith("..")&&!ft(r)}function Ct(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var Ce="scip-query-result",xe=0,v=1,xt=1;function be(e){if(!f(e))return{kind:"malformed",reason:"CLI JSON output must be an object."};let t=Object.hasOwn(e,"kind"),r=Object.hasOwn(e,"schemaVersion");if(!t&&!r){let s=Re(e);return s?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${s}`}:{kind:"legacy",schemaVersion:xe,envelope:e}}if(!t||!r)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==Ce)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${kt(e.kind)}.`};let n=e.schemaVersion;if(!Number.isSafeInteger(n)||Number(n)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(n!==v)return{kind:"unsupported",schemaVersion:Number(n),direction:Number(n)<v?"older":"future",...Se(e.producer)?{producer:e.producer}:{}};let i=Re(e);if(i)return{kind:"malformed",reason:`CLI JSON envelope v1: ${i}`};if(!Se(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!wt(e.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};let o=Ee(e.command);return o.includes(e.resultSchemaVersion)?{kind:"supported",schemaVersion:v,envelope:e}:{kind:"unsupported-result",schemaVersion:v,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:o}}function bt(e){let t=be(e);if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="unsupported"){let r=t.producer?` from ${t.producer.name}@${t.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${t.schemaVersion}${r}; this consumer supports the legacy unversioned envelope and schemaVersion ${v}.`)}throw t.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${t.resultSchemaVersion} for scip-query command ${JSON.stringify(t.command)}; this consumer supports ${t.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${t.reason}`)}function Ee(e){return Et[e]??[xt]}var Et={};function Re(e){return typeof e.command!="string"||e.command.length===0?"command must be a non-empty string.":Array.isArray(e.args)?f(e.options)?Object.hasOwn(e,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function Se(e){return f(e)&&e.name==="scip-query"&&typeof e.version=="string"&&e.version.length>0}function wt(e){return Number.isSafeInteger(e)&&Number(e)>0}function kt(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{Ce as CLI_JSON_ENVELOPE_KIND,v as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,xe as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,B as OBSERVATION_RECEIPT_SCHEMA_VERSION,_ as Watcher,K as compareObservationReceipts,ge as createReindexRunner,be as decodeCliJsonEnvelope,Pe as getScipVersion,Ge as initProjectConfig,vt as installSkills,Y as isObservationReceipt,ke as isScipInstalled,T as loadProjectConfig,Te as printScipInstallInstructions,bt as requireCompatibleCliJsonEnvelope,k as resolveIndexStoragePaths,fe as resolveReindexWorkerLaunch,Ee as supportedCliResultSchemaVersions};
1
+ import{b as Me,c as Ve,e as qt,f as Yt,g as Kt,k as De,n as Le}from"./chunk-S73HBCGI.js";import{a as je}from"./chunk-2COFMIVK.js";import{D as Pe,c as xe,e as $,h as Ee,n as ke,o as _e}from"./chunk-MYUKI5VN.js";import"./chunk-DHEQMPLW.js";import{A as Re,B as Se,G as Ie,H as w,I as Oe,R as we,W as Te,Z as z,_ as Ae,ba as Ne,g as be,ga as X,l as u,n as g,o as E,p as N,q as ve,r as m,t as j}from"./chunk-MO226P4Q.js";import{existsSync as On}from"fs";import{randomUUID as xn}from"crypto";import{isAbsolute as Xi,join as rt,relative as Zi,resolve as er}from"path";var S=1,k=2,Qt="./node_modules/scip-query/docs/schemas/project-config.schema.json";function Z(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(c){return{kind:"malformed",reason:`invalid JSON: ${c instanceof Error?c.message:String(c)}`}}if(!u(t))return{kind:"malformed",reason:"project config must be a JSON object"};let n=t.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let i=n===void 0?S:n;if(i!==S&&i!==k)return{kind:"unsupported",schemaVersion:i,direction:i<S?"older":"future"};let r=t.$schema;if(r!==void 0&&(typeof r!="string"||r.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=F(t),s=i!==k||typeof t.$schema!="string";return i===S?{kind:"legacy",sourceVersion:S,config:o,needsMigration:s}:{kind:"supported",sourceVersion:k,config:o,needsMigration:s}}function F(e){let t=e,{$schema:n,schemaVersion:i,...r}=t;return{$schema:typeof n=="string"&&n.trim()!==""?n:Qt,schemaVersion:k,...r}}function $e(e){return`${JSON.stringify(F(e),null,2)}
2
+ `}import{createHash as zt}from"crypto";var h=1,R=2,W=1,V=1,M="sha256",ne=1;function Be(e,t,n){if(!m(e)||!N(t))throw new Error("Observation identity requires a bounded projection name and positive projection version.");return{schemaVersion:W,canonicalizationVersion:V,hashAlgorithm:M,projection:{name:e,version:t},digest:zt(M).update(Xt(e,t,n)).digest("hex")}}function Xt(e,t,n){return`{"canonicalizationVersion":${V},"projection":${JSON.stringify(e)},"projectionVersion":${t},"value":${JSON.stringify(n)}}`}function ie(e){if(!u(e))return{kind:"malformed",reason:"observation receipt must be an object"};let t=e.schemaVersion;if(!Number.isInteger(t))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(t===h)return on(e)?{kind:"legacy",schemaVersion:h,receipt:e}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(t===R)return sn(e)?{kind:"supported",schemaVersion:R,receipt:e}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=t;return{kind:"unsupported",schemaVersion:n,direction:n<h?"older":"future"}}function G(e){let t=ie(e);return t.kind==="legacy"||t.kind==="supported"}function re(e,t){return{collaborationDomain:I(y(e,n=>n.facts.collaborationDomain),y(t,n=>n.facts.collaborationDomain)),repositoryLineage:I(y(e,n=>n.facts.repositoryLineage),y(t,n=>n.facts.repositoryLineage)),workspaceInstance:I(y(e,n=>n.facts.workspaceInstance),y(t,n=>n.facts.workspaceInstance)),wholeContent:I(y(e,n=>n.facts.wholeContent),y(t,n=>n.facts.wholeContent)),relevantInputs:Zt(e,t),indexInput:I(y(e,n=>n.facts.index?.inputs),y(t,n=>n.facts.index?.inputs)),indexGeneration:en(e,t),observationStability:nn(e,t)}}function J(e,t,n=re(e,t)){let i=[["collaborationDomain",n.collaborationDomain],["wholeContent",n.wholeContent],["observationStability",n.observationStability]],r=[];for(let[s,c]of i)c.state!=="established"&&r.push(`${s}:${c.state}`);for(let[s,c]of[["left",e],["right",t]]){let a=rn(c);a!=="not-applicable"&&a!=="established"&&r.push(`${s}IndexAlignment:${a}`)}let o=i.some(([,s])=>s.state==="disproven")||r.some(s=>s.endsWith(":disproven"));return{policyVersion:ne,authority:r.length===0?"completion":o?"none":"advisory",requiredRelationships:["collaborationDomain","wholeContent","observationStability"],reasons:r}}function Ue(e){return e.schemaVersion===h?e.index?.generationIdentity:e.facts.index?.generation.digest}function He(e){return e.schemaVersion===h?void 0:e.facts.workspaceInstance?.digest}function qe(e){if(e.schemaVersion===h)return e.index?.alignment??"not-established";let t=e.stabilityProofs.filter(n=>n.source!=="process");return t.some(n=>n.kind==="invalidated")?"invalidated":t.length>0&&t.every(n=>n.kind==="immutable"||n.kind==="fixed-snapshot")?"fixed":t.some(n=>n.kind==="bracketed")?"bracketed":"not-established"}function Zt(e,t){let n=Fe(e),i=Fe(t);return[...new Set([...n.keys(),...i.keys()])].sort().map(o=>{let s=n.get(o),c=i.get(o),a=s?.subject??c?.subject??o,d=s?.identity.projection.name??c?.identity.projection.name??o;return{subject:a,projection:d,judgment:I(s?.identity,c?.identity)}})}function Fe(e){return e.schemaVersion!==R?new Map:new Map((e.facts.relevantInputs??[]).map(t=>[`${t.subject}\0${t.identity.projection.name}`,t]))}function en(e,t){return e.schemaVersion===h&&t.schemaVersion===h?tn(e.index?.generationIdentity,t.index?.generationIdentity):e.schemaVersion===h||t.schemaVersion===h?C("unknown",["legacy-fact-not-comparable"],Ge(e),Ge(t)):I(e.facts.index?.generation,t.facts.index?.generation)}function tn(e,t){let n=e?[{kind:"legacy-index-generation",value:e}]:[],i=t?[{kind:"legacy-index-generation",value:t}]:[];return e===void 0||t===void 0?Ye(n,i):C(e===t?"established":"disproven",[e===t?"identities-equal":"identities-different"],n,i)}function I(e,t){let n=e?[{kind:"identity",identity:e}]:[],i=t?[{kind:"identity",identity:t}]:[];return!e||!t?Ye(n,i):oe(e,t)?C(e.digest===t.digest?"established":"disproven",[e.digest===t.digest?"identities-equal":"identities-different"],n,i):C("unknown",["identity-projections-not-comparable"],n,i)}function nn(e,t){if(e.schemaVersion===h||t.schemaVersion===h)return C("unknown",["legacy-fact-not-comparable"],[],[]);let n=Je(e),i=Je(t),r=We(e),o=We(t);return r==="invalidated"||o==="invalidated"?C("disproven",[...r==="invalidated"?["left-observation-invalidated"]:[],...o==="invalidated"?["right-observation-invalidated"]:[]],n,i):r!=="fixed"||o!=="fixed"?C("unknown",[...r==="no-repository-source"?["left-observation-has-no-repository-source"]:r!=="fixed"?["left-observation-not-fixed"]:[],...o==="no-repository-source"?["right-observation-has-no-repository-source"]:o!=="fixed"?["right-observation-not-fixed"]:[]],n,i):C("established",["all-observed-sources-fixed"],n,i)}function We(e){let t=e.observedSources.filter(i=>i.kind!=="process");if(t.length===0)return"no-repository-source";let n=new Map(e.stabilityProofs.map(i=>[i.source,i.kind]));return t.some(i=>n.get(i.kind)==="invalidated")?"invalidated":t.every(i=>{let r=n.get(i.kind);return r==="immutable"||r==="fixed-snapshot"})?"fixed":"unknown"}function rn(e){if(e.schemaVersion!==R)return e.index?"unknown":"not-applicable";if(!e.observedSources.some(i=>i.kind==="index-generation"))return"not-applicable";let t=e.facts.index?.inputs;if(!t)return"unknown";let n=(e.facts.relevantInputs??[]).find(i=>oe(i.identity,t))?.identity;return n?n.digest===t.digest?"established":"disproven":"unknown"}function y(e,t){return e.schemaVersion===R?t(e):void 0}function Ge(e){return e.schemaVersion===h&&e.index?[{kind:"legacy-index-generation",value:e.index.generationIdentity}]:e.schemaVersion===R&&e.facts.index?[{kind:"identity",identity:e.facts.index.generation}]:[]}function Je(e){return e.stabilityProofs.map(t=>({kind:"stability",proof:t}))}function Ye(e,t){let n=e.length===0&&t.length===0?"both-facts-missing":e.length===0?"left-fact-missing":"right-fact-missing";return C("unknown",[n],e,t)}function C(e,t,n,i){return{state:e,reasons:t,facts:{left:n,right:i}}}function oe(e,t){return e.schemaVersion===t.schemaVersion&&e.canonicalizationVersion===t.canonicalizationVersion&&e.hashAlgorithm===t.hashAlgorithm&&e.projection.name===t.projection.name&&e.projection.version===t.projection.version}function on(e){if(!u(e))return!1;let t=e.index,n=e.worktree;return Qe(e.observedAt)&&m(e.projectIdentity)&&fn(e.authorityKind)&&(t===void 0||u(t)&&m(t.generationIdentity)&&(t.source==="immutable"||t.source==="legacy")&&(t.alignment==="not-certified"||t.alignment==="leased"))&&(n===void 0||u(n)&&m(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||m(n.headCommit))&&(n.treeOid===void 0||m(n.treeOid)))&&pn(e.authorityKind,t,n)}function sn(e){if(!u(e))return!1;let t=e.facts,n=e.observedSources,i=e.stabilityProofs;if(!Qe(e.observedAt)||!u(t)||!Array.isArray(n)||n.length===0||!n.every(cn)||!te(n,a=>a.kind)||!Array.isArray(i)||!i.every(dn)||!te(i,a=>a.source)||i.some(a=>!n.some(d=>d.kind===a.source))||!i.every(a=>ln(a,t))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(a=>t[a]!==void 0&&!v(t[a])))return!1;let o=t.relevantInputs;if(o!==void 0&&(!Array.isArray(o)||!o.every(an)||!te(o,a=>`${a.subject}\0${a.identity.projection.name}`)))return!1;let s=t.index;if(s!==void 0&&(!u(s)||!v(s.generation)||s.inputs!==void 0&&!v(s.inputs)||s.source!=="immutable"&&s.source!=="legacy"))return!1;let c=e.diagnostics;return(c===void 0||u(c)&&(c.clean===void 0||typeof c.clean=="boolean")&&(c.headCommit===void 0||m(c.headCommit))&&(c.treeOid===void 0||m(c.treeOid)))&&un(t,n)}function v(e){return!u(e)||!u(e.projection)?!1:e.schemaVersion===W&&e.canonicalizationVersion===V&&e.hashAlgorithm===M&&m(e.projection.name)&&N(e.projection.version)&&ve(e.digest)}function an(e){return u(e)&&m(e.subject)&&v(e.identity)}function cn(e){return u(e)&&Ke(e.kind)&&(e.identity===void 0||v(e.identity))}function dn(e){return u(e)&&Ke(e.source)&&(e.kind==="immutable"||e.kind==="fixed-snapshot"||e.kind==="bracketed"||e.kind==="not-established"||e.kind==="invalidated")}function un(e,t){let n=e.index,i=t.find(a=>a.kind==="index-generation");if(i){if(!u(n)||!v(n.generation)||i.identity&&!ee(i.identity,n.generation))return!1}else if(n!==void 0)return!1;let r=e.workspaceInstance,o=t.find(a=>a.kind==="live-workspace");if(o?.identity&&(!v(r)||!ee(o.identity,r)))return!1;let s=e.wholeContent,c=t.find(a=>a.kind==="repository-snapshot");return!(c?.identity&&(!v(s)||!ee(c.identity,s)))}function ln(e,t){return e.kind==="not-established"||e.kind==="invalidated"?!0:e.source==="index-generation"?e.kind==="immutable"&&u(t.index)&&t.index.source==="immutable":e.source==="repository-snapshot"?e.kind==="fixed-snapshot":e.source==="live-workspace"?e.kind==="bracketed":!1}function ee(e,t){return oe(e,t)&&e.digest===t.digest}function pn(e,t,n){return e==="index-worktree"?t!==void 0&&n!==void 0:e==="index-only"?t!==void 0&&n===void 0:e==="worktree-only"?t===void 0&&n!==void 0:e==="process-local"&&t===void 0&&n===void 0}function fn(e){return e==="index-worktree"||e==="index-only"||e==="worktree-only"||e==="process-local"}function Ke(e){return e==="index-generation"||e==="repository-snapshot"||e==="live-workspace"||e==="process"}function Qe(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function te(e,t){return new Set(e.map(t)).size===e.length}import{createHash as ze}from"crypto";import{closeSync as hn,fstatSync as Xe,openSync as mn,rmSync as gn}from"fs";import{dirname as yn}from"path";var Cn=2e3,bn=10,vn=3,U=class extends Error{constructor(n,i,r){super(`Concurrent edit detected for ${n}; expected revision ${et(i)}, but found ${et(r)}. The latest file was left untouched.`);this.path=n;this.original=i;this.latest=r;this.name="FileRevisionConflictError"}path;original;latest};function tt(e,t,n={}){let i=Rn(e,n.lockTimeoutMs??Cn,n.monotonicNow??$);try{let r=Math.max(0,Math.floor(n.maxRetries??vn));for(let o=0;;o+=1){let s=B(e),c=t(s,o);if(c.kind==="unchanged")return{changed:!1,attempts:o+1,previous:s,current:s};n.onBeforeCommit?.({attempt:o,snapshot:s,mutation:c});let a=B(e);if(!In(s.revision,a.revision)){if(o<r)continue;throw new U(e,s.revision,a.revision)}try{Sn(e,c,s.revision)}catch(d){if(d.code==="EEXIST"){let l=B(e);if(o<r)continue;throw new U(e,s.revision,l.revision)}throw d}return{changed:!0,attempts:o+1,previous:s,current:B(e)}}}finally{i.release()}}function B(e){for(let t=0;t<4;t+=1){let n;try{n=mn(e,"r");let i=Ze(Xe(n)),r=Oe(n,{maxBytes:Se,inputKind:"revisioned text file"}),o=Ze(Xe(n));if(!nt(i,o))continue;return{path:e,text:r,revision:{exists:!0,hash:ze("sha256").update(r).digest("hex"),identity:o}}}catch(i){if(i.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:ze("sha256").update("").digest("hex")}};throw i}finally{n!==void 0&&hn(n)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function Rn(e,t,n){let i=`${e}.scip-query-write.lock`,r=n()+Math.max(0,t);for(;;){let o=Ee(i,{kind:"revisioned-file-mutation",detail:{target:e}});if(o.kind==="acquired")return o.lock;if(n()>=r)throw new Error(`Timed out after ${t}ms waiting to update ${e}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,bn)}}function Sn(e,t,n){if(t.kind==="delete"){if(!n.exists)return;gn(e),we(yn(e));return}let i=t.mode??n.identity?.mode;n.exists?ke(e,t.text,{durability:"durable",mode:i}):_e(e,t.text,{durability:"durable",mode:i})}function In(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&nt(e.identity,t.identity))}function Ze(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function nt(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function et(e){return e.exists?e.hash.slice(0,12):"<absent>"}var D=".scipquery.json",ot=2e3,st=5e3,se=st,at=15*6e4,ae={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024},En={enabled:!1,debounceMs:ot,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:at,autoRefresh:!0,ignore:[],resourceBudget:ae};var or=new Set(j);function H(e){let t=rt(e,D);if(!On(t))return{};let n;try{n=Ie(t,{maxBytes:Re,inputKind:"scip-query project config"})}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(`unable to read ${D} at ${t}: ${r}`,{cause:i})}return dt(Z(n),t,"read").config}function ct(e){return{...En,...e.watch,cooldownMs:Math.max(st,e.watch?.cooldownMs??se),resourceBudget:{...ae,...e.watch?.resourceBudget}}}function wn(e,t){return kn(e,t).configPath}function kn(e,t){let n=rt(e,D),i=xn(),r={collaborationDomainId:i,languages:t,watch:{enabled:!0,debounceMs:ot,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:at,autoRefresh:!0,resourceBudget:{...ae}}},o=tt(n,s=>{if(!s.revision.exists)return{kind:"write",text:it(r)};let c=_n(s,r);return c.config.collaborationDomainId?{kind:"unchanged"}:{kind:"write",text:it({...c.config,collaborationDomainId:i})}});return{configPath:n,changed:o.changed}}function _n(e,t){if(!e.revision.exists)return{config:F(t),needsMigration:!0};let n=dt(Z(e.text),e.path,"update");return{config:n.config,needsMigration:n.needsMigration}}function it(e){return $e(e)}function dt(e,t,n){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let r=n==="read"?`invalid ${D} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${r} The file was left untouched.`)}let i=n==="read"?`invalid ${D} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${i} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${S} and current v${k}). Upgrade scip-query before retrying; the file was left untouched.`)}import{existsSync as vt,lstatSync as Tn,statSync as An}from"fs";import{basename as Nn,dirname as jn,isAbsolute as le,join as b,relative as Rt,resolve as St}from"path";import{watch as Mn}from"chokidar";import Vn from"ignore";function ce(e){let t=JSON.stringify(e);return Buffer.byteLength(t)<=65536?t:void 0}var It=5e3,ue=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=ct(t.config),this.outputDb=t.outputDb??b(Ne(this.projectRoot,t.config),"index.db"),this.preferFilesystemGitState=t.gitReader===void 0,this.localCacheWatchPath=Zn(this.projectRoot,jn(this.outputDb)),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onReindexError=t.onReindexError??(()=>{}),this.onRefreshSuppressed=t.onRefreshSuppressed??(()=>{}),this.onError=t.onError??(n=>console.error(n.message)),this.clock=t.clock??Fn,Ot.set(this,ei(t.stopTimeoutMs??It,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??wt(),this.subscriptionFactory=t.subscriptionFactory??Wn,this.budgetInspector=t.budgetInspector??Le,xt.set(this,{gitReader:t.gitReader??Te,languages:kt(t.languages??t.config.languages),stagedIndexEntries:null}),this.gitignoreFilter=je(t.projectRoot),this.extraIgnore=Vn(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,q(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let t=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let n=this.activeOperation;n&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...q(this).closures],r=Ln(this),o=this.clock.now()+r;return this.stopPromise=this.finishStop(t,i,n,o,r).catch(s=>{throw this.stopInProgress=!1,s}),this.stopPromise}requestRefresh(t,n={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${t.kind}`),!n.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(t);return}this.pendingTrigger=ft(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let n=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,r)=>this.isIgnoredWatchPath(i,r?.isDirectory()??!1),usePolling:t,ignorePermissionErrors:!0,...t?{interval:5e3,binaryInterval:1e4}:{}});n.on("all",(i,r)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,r)}),n.on("error",i=>this.handleSourceWatcherError(n,i,t)),this.fsWatchers.push(n)}handleSourceWatcherError(t,n,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Yn(n)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(r=>r!==t),$n(q(this),t,r=>this.onError(r));try{this.startSourceWatcher(!0)}catch(r){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`))}}isIgnoredWatchPath(t,n){let i=this.relativeWatchPath(t);if(!i)return!1;if(ht(i,this.localCacheWatchPath))return!0;let r=n?`${i}/`:i;return this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)}handleFileChange(t,n){let i=this.relativeWatchPath(n);if(!i||i===".."||i.startsWith("../")||ht(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Nn(i).startsWith(De)||(i===".scipquery.json"&&yt(this,this.projectRoot),!Ct(this,i)))return;let r=Hn(t);r||this.markPendingChangesIncomplete(`unsupported-source-event:${t}`),this.scheduleReindex({kind:"watch-source",detail:i},r?[{path:i,kind:r}]:void 0,r!==void 0)}relativeWatchPath(t){let n=le(t)?t:b(this.projectRoot,t);return Rt(this.projectRoot,n).replaceAll("\\","/")}scheduleReindex(t,n,i=!1){this.pendingTrigger=ft(this.pendingTrigger,t),i||this.markPendingChangesIncomplete(`unstructured-trigger:${t.kind}`);for(let o of n??[])this.recordPendingChange(o);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=this.inspectBudget(),n=t.state!=="paused";if(t.state==="paused"&&t.reason!=="rebuild-count"){this.dirty=!0;let a=Math.max(this.wallNow()+1,t.until);this.setStatus({state:"budget-paused",until:a,dirty:!0,reason:t.detail,rebuilt:t.rebuilt,estimatedWriteBytes:t.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,a-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let a=this.watchConfig.cooldownMs-i;this.dirty=!0;let d=this.wallNow()+a;this.setStatus({state:"cooldown",until:d,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},a);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let o=this.consumePendingChangeJournal(),s=this.wallNow();this.setStatus({state:"indexing",startedAt:s});let c=this.reindexRunner.start(this.reindexRequest(r,n,o));this.activeOperation=c,c.completion.then(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let d=!1;try{d=this.onReindexComplete(a,r,{pendingChanges:this.dirty})===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(d){let p=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(p),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(a=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let d=a instanceof Error?a:new Error(String(a));this.restorePendingChangeJournal(o),this.onReindexError(d,r),this.onError(d),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===c&&(this.activeOperation=null)})}async finishStop(t,n,i,r,o){let s=[],c=t.map(async f=>{try{await f.close()}catch(x){s.push(`watch subscription close failed: ${String(x)}`)}});c.push(...n),i&&c.push((async()=>{try{let f=await i.cancel();f.state==="degraded"&&s.push(f.reason)}catch(f){s.push(`reindex cancellation failed: ${f instanceof Error?f.message:String(f)}`)}})());let a=c.length,d=c.map(f=>f.finally(()=>{a-=1})),l=await Dn(d,r,this.clock),p=q(this);return s.push(...p.errors),p.errors=[],l?this.stopInProgress=!1:(s.push(`watch shutdown exceeded the ${o}ms deadline with ${a} operation(s) still pending`),Promise.all(d).then(()=>{this.stopInProgress=!1})),s.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:s.join("; ")}),{state:"degraded",reasons:s}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(t){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${t instanceof Error?t.message:String(t)}`}}}reindexRequest(t,n=!0,i){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:t,changeJournal:i,allowExpensiveRebuild:n}}setStatus(t){this.status=t,this.onStatus(t)}recordPendingChange(t){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(t.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let n=this.pendingChanges.get(t.path),i=qn(n,t.kind);i===null?this.pendingChanges.delete(t.path):this.pendingChanges.set(t.path,i)}markPendingChangesIncomplete(t){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=t}consumePendingChangeJournal(){let t=Pe(this.outputDb),n=[...this.pendingChanges.entries()].map(([s,c])=>({path:s,kind:c})).sort((s,c)=>s.path.localeCompare(c.path)),i=this.pendingChangesComplete,r=this.pendingChangesIncompleteReason;t||(i=!1,r??="accepted-generation-unavailable");let o={version:1,baseGeneration:t,complete:i,...r?{incompleteReason:r}:{},entries:n};return ce(o)||(o={version:1,baseGeneration:t,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),o}restorePendingChangeJournal(t){let n=[...this.pendingChanges.entries()].map(([o,s])=>({path:o,kind:s})),i=this.pendingChangesComplete,r=this.pendingChangesIncompleteReason;this.resetPendingChanges(),t.complete||this.markPendingChangesIncomplete(t.incompleteReason??"failed-reindex");for(let o of t.entries)this.recordPendingChange(o);i||this.markPendingChangesIncomplete(r??"failed-reindex");for(let o of n)this.recordPendingChange(o)}resetPendingChanges(){this.pendingChanges.clear(),this.pendingChangesComplete=!0,this.pendingChangesIncompleteReason=void 0}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(O(this).stagedIndexEntries=bt(this.projectRoot,O(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let t=this.lastGitState,n=this.readGitState();if(!t||!n||this.stopped){this.lastGitState=n;return}this.lastGitState=n;let i=t.head!==n.head,r=t.indexPath!==n.indexPath||t.indexMtimeMs!==n.indexMtimeMs||t.indexSize!==n.indexSize;if(!i&&!r)return;let o=O(this),s=o.stagedIndexEntries,c=bt(this.projectRoot,o.gitReader);o.stagedIndexEntries=c;let a=ti(this.projectRoot,o.gitReader,t,n,s,c,i,r),d=null;if(a!==null&&(a.includes(".scipquery.json")&&yt(this,this.projectRoot),d=a.filter(p=>Ct(this,p)),d.length===0))return;let l=d?.map(p=>({path:p,kind:vt(b(this.projectRoot,p))?"change":"delete"}));i&&r?this.scheduleReindex({kind:"watch-git-state",detail:de("HEAD and index changed",d)},l,l!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:de("HEAD changed",d)},l,l!==void 0):r&&this.scheduleReindex({kind:"watch-git-index",detail:de(n.indexPath??"index changed",d)},l,l!==void 0)}readGitState(){if(this.preferFilesystemGitState){let t=this.readFilesystemGitState();if(t)return t}return this.readGitStateFromGit()}readFilesystemGitState(){let t=this.watchGitLayout??Kn(this.projectRoot);if(!t)return null;this.watchGitLayout=t;let n=Qn(t.gitDir);return n?gt(n,t.indexPath):null}readGitStateFromGit(){let t=O(this).gitReader,n=z(this.projectRoot,["rev-parse","--git-path","index"],t);if(!n)return null;let i=Ae(this.projectRoot,n);return gt(z(this.projectRoot,["rev-parse","--verify","HEAD"],t),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Dn(e,t,n){if(e.length===0)return!0;let i=Promise.all(e).then(()=>!0),r=Math.max(0,t-n.now()),o=null,s=new Promise(a=>{o=n.setTimeout(()=>a(!1),r)}),c=await Promise.race([i,s]);return c&&o&&n.clearTimeout(o),c}var lt=new WeakMap,Ot=new WeakMap,xt=new WeakMap;function q(e){let t=lt.get(e);if(t)return t;let n={closures:new Set,errors:[]};return lt.set(e,n),n}function Ln(e){return Ot.get(e)??It}function O(e){let t=xt.get(e);if(!t)throw new Error("Watcher input state was not initialized.");return t}function $n(e,t,n){let i=Promise.resolve().then(()=>t.close()).catch(r=>{let o=`watch subscription close failed during polling fallback: ${String(r)}`;e.errors.push(o),n(new Error(o))});e.closures.add(i),i.then(()=>e.closures.delete(i))}function Et(e,t=xe){let{projectRoot:n,config:i,languages:r,pnpmWorkspaces:o,typescriptProjectMode:s,typescriptProjects:c,clojureConfigPath:a,indexerConcurrency:d,trigger:l}=e,p=H(n),f=Object.keys(p).length>0?p:i,x=X(n,f),Q=f.indexer?.typescript,Ht=f.indexer?.clojure,Ce=t(process.pid);if(!Ce)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:n,SCIP_REINDEX_OUTPUT_SCIP:x.indexPath,SCIP_REINDEX_OUTPUT_DB:x.dbPath,SCIP_REINDEX_LANGUAGES:(f.languages??r)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(f.indexerConcurrency??d??""),SCIP_REINDEX_PNPM_WORKSPACES:Q?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:Q?.projectMode??s,projects:Q?.projects??c??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:Ht?.configPath??a??"",SCIP_REINDEX_TRIGGER_KIND:l.kind,SCIP_REINDEX_TRIGGER_DETAIL:l.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:e.changeJournal?ce(e.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:e.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(Ce)}}}var Fn={now:$,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Wn=(e,t)=>Mn(e,t),Gn=15*6e4,Jn=1e3,Bn=64*1024;function Un(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function pt(e,t){let n=e instanceof Error?e.message:String(e),i=t.stderrTail.trim()||t.stdoutTail.trim();return i?`${n}
3
+ ${i}`:n}function wt(e={}){let t=e.timeoutMs??Gn,n=e.terminationGraceMs??Jn,i=e.maxOutputBytes??Bn,r=e.resolveLaunch??Et;return{start(o){let s=r(o),c=new AbortController,a=Un(),d=!1,l=Ve({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:t,terminationGraceMs:n,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:c.signal,detached:!0}).then(p=>{if(a={stdoutTail:p.stdout,stderrTail:p.stderr,stdoutTruncated:p.stdoutTruncated,stderrTruncated:p.stderrTruncated},p.status!==0)throw new Error(pt(new Error(`Reindex worker exited with ${p.signal?`signal ${p.signal}`:`code ${p.status}`}`),a));return p.durationMs}).catch(p=>{throw p instanceof Me&&(a={stdoutTail:p.stdout,stderrTail:p.stderr,stdoutTruncated:p.stdoutTruncated,stderrTruncated:p.stderrTruncated}),new Error(pt(p,a),{cause:p})}).finally(()=>{d=!0});return{completion:l,async cancel(){d||c.abort();try{await l}catch{}return{state:"exited",diagnostics:a}},diagnostics:()=>a}}}}function ft(e,t){return e?e.kind===t.kind?e.detail===t.detail?e:{kind:e.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${e.kind}, ${t.kind}`}:t}function Hn(e){if(e==="add")return"add";if(e==="change")return"change";if(e==="unlink")return"delete"}function qn(e,t){return e?e==="add"?t==="delete"?null:"add":e==="delete"&&t==="add"?"change":t:t}function Yn(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}var pe=/^[0-9a-f]{40,64}$/i;function ht(e,t){return e===".git"||e.startsWith(".git/")||e==="node_modules"||e.startsWith("node_modules/")||e.endsWith("/node_modules")||e.includes("/node_modules/")?!0:t!==void 0&&(e===t||e.startsWith(`${t}/`))}function Kn(e){let t=b(e,".git");try{let n=Tn(t),i;if(n.isDirectory())i=t;else if(n.isFile()){let r=/^gitdir:\s*(.+)\s*$/m.exec(w(t,"Git directory marker"));if(!r?.[1])return null;let o=r[1].trim();i=le(o)?o:St(e,o)}else return null;return vt(i)?{gitDir:i,indexPath:b(i,"index")}:null}catch{return null}}function Qn(e){let t;try{t=w(b(e,"HEAD"),"Git HEAD").trim()}catch{return}if(pe.test(t))return t.toLowerCase();let n=/^ref:\s*(.+)$/.exec(t)?.[1]?.trim();if(!n)return;let i=zn(e);return mt(e,n)??mt(i,n)??Xn(i,n)}function zn(e){try{let t=w(b(e,"commondir"),"Git common-directory marker").trim();return t?le(t)?t:St(e,t):e}catch{return e}}function mt(e,t){try{let n=w(b(e,t),"Git reference").trim();return pe.test(n)?n.toLowerCase():void 0}catch{return}}function Xn(e,t){try{for(let n of w(b(e,"packed-refs"),"Git packed references").split(`
4
+ `)){if(n.startsWith("#")||n.startsWith("^"))continue;let i=n.indexOf(" ");if(i===-1)continue;let r=n.slice(0,i);if(n.slice(i+1).trim()===t&&pe.test(r))return r.toLowerCase()}}catch{return}}function gt(e,t){let n={head:e,indexPath:t};try{let i=An(t);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}function Zn(e,t){let n=Rt(e,t).replaceAll("\\","/");if(!(!n||n===".."||n.startsWith("../")))return n}function ei(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}function kt(e){return e&&e.length>0?[...e]:j}function yt(e,t){try{O(e).languages=kt(H(t).languages)}catch{O(e).languages=j}}function Ct(e,t){return be(t,O(e).languages)!=="other"}function ti(e,t,n,i,r,o,s,c){let a=new Set;if(s){if(!n.head||!i.head)return null;let d=t.runResult(e,["diff","--name-only","-z","--no-renames","--relative",n.head,i.head,"--"]);if(d.kind!=="success")return null;for(let l of ni(d.output))a.add(l)}if(c){if(r===null||o===null)return null;for(let d of ri(r,o))a.add(d)}return[...a].sort()}function bt(e,t){let n=t.runResult(e,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return n.kind==="success"?ii(n.output):null}function ni(e){return e.split("\0").filter(t=>t.length>0)}function ii(e){let t=e.split("\0");if(t.at(-1)===""&&t.pop(),t.length%2!==0)return null;let n=new Map;for(let i=0;i<t.length;i+=2){let r=t[i],o=t[i+1];if(!r.startsWith(":")||!o)return null;n.set(o,r)}return n}function ri(e,t){return[...new Set([...e.keys(),...t.keys()])].filter(i=>e.get(i)!==t.get(i))}function de(e,t){return t===null?`${e}; changed paths unavailable`:t.length===0?e:t.length===1?t[0]:`${t.length} compiler inputs changed`}import{existsSync as fe,mkdirSync as oi,symlinkSync as si,readlinkSync as _t,unlinkSync as Pt,readdirSync as ai}from"fs";import{join as _,dirname as he,resolve as P,relative as ci,isAbsolute as di}from"path";import{homedir as ui,platform as li}from"os";import{fileURLToPath as pi}from"url";var fi=li()==="win32";var Tt=["scip-query","scip-plan","scip-setup","scip-integrity-audit","scip-explore","concrete-plan"];function hi(e={}){let t=e.quiet?()=>{}:console.log,n=pi(import.meta.url),i=P(he(n),"..","skills"),r=e.homeDir??process.env.SCIP_QUERY_SKILLS_HOME??ui(),o=[_(r,".claude","skills"),_(r,".codex","skills"),_(r,".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let c of o){let a=he(c);if(!fe(a))continue;oi(c,{recursive:!0});let d=yi(c);mi(c,i,d,s,t);for(let l of Tt){let p=_(i,l),f=_(c,l);if(!fe(p)){s.skipped.push(`${d}/${l}`);continue}if(fe(f)){try{let x=_t(f);if(P(x)===P(p)){s.alreadyLinked.push(`${d}/${l}`),t(` ok: ${l} \u2192 ${d} (already linked)`);continue}}catch{s.skipped.push(`${d}/${l}`),t(` skip: ${l} \u2192 ${d} (exists, not a symlink)`);continue}Pt(f)}si(p,f,fi?"junction":"dir"),s.installed.push(`${d}/${l}`),t(` done: ${l} \u2192 ${d}`)}}return s}function mi(e,t,n,i,r){let o=new Set(Tt);for(let s of ai(e)){if(o.has(s))continue;let c=_(e,s),a;try{a=P(he(c),_t(c))}catch{continue}gi(a,t)&&(Pt(c),i.pruned.push(`${n}/${s}`),r(` prune: ${s} \u2192 ${n} (removed stale scip-query skill link)`))}}function gi(e,t){let n=ci(P(t),P(e));return n===""||!n.startsWith("..")&&!di(n)}function yi(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var At=["repository-observation","repository-preview","mutation","composite","environment-observation","tool-information"];function Ci(e,t=[]){return{defaultRole:e,...t.length>0?{rules:t}:{}}}function bi(e,t){for(let n of e.rules??[]){if(n.when.kind==="option-present"){let r=t.options[n.when.name];if(r!==void 0&&r!==!1)return n.role;continue}if((n.when.kind==="argument"?t.args[n.when.index]:t.options[n.when.name])===n.when.equals)return n.role}return e.defaultRole}function vi(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(t=>t.role)])]}function Y(e){return At.includes(e)}function Ri(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}var me=1,ge=1,K=["compiler-graph","semantic-analysis","repository-source","change-history","runtime-measurement","heuristic","mixed","unknown"],Nt=["complete","partial","unknown"],jt=["validated","failed","not-evaluated","not-applicable"],Mt=["observe","advise","require-adjudication","block","not-established"],Vt={policyId:"scip-query:unresolved-repository-policy",policyVersion:ge,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function Si(e){return{schemaVersion:me,origin:e.contract.origin,coverage:Dt(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:J(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??Vt,...e.contract.families?{families:e.contract.families}:{}}}function Dt(e){return e?e.complete===!0?{state:"complete",returned:e.returned,totalKnown:!0,total:e.total??e.returned,omitted:0}:e.totalKnown?{state:"partial",returned:e.returned,totalKnown:!0,...e.total===void 0?{}:{total:e.total},...e.omitted===void 0?{}:{omitted:e.omitted}}:{state:"unknown",returned:e.returned,totalKnown:!1}:{state:"unknown",returned:0,totalKnown:!1}}function Ii(e,t){let n=[];return L(n,"origin",t.origins,e.origin),L(n,"coverage",t.coverage,e.coverage.state),L(n,"producer-validation",t.producerValidation,e.producerValidation.status),L(n,"state-authority",t.stateAuthority,e.stateAuthority.authority),L(n,"action-permission",t.actionPermission,e.repositoryPolicy.permission),{satisfied:n.every(i=>i.satisfied),predicates:n}}function L(e,t,n,i){n&&e.push({predicate:t,satisfied:n.includes(i),required:n,actual:i})}function ye(e){return!u(e)||e.schemaVersion!==me||!T(e.origin,K)||!Oi(e.coverage)||!xi(e.producerValidation)||!Ei(e.stateAuthority)||!wi(e.repositoryPolicy)?!1:e.families===void 0||ki(e.families)}function Oi(e){return!u(e)||!T(e.state,Nt)||!E(e.returned)||typeof e.totalKnown!="boolean"||e.total!==void 0&&!E(e.total)||e.omitted!==void 0&&!E(e.omitted)?!1:e.state==="complete"?e.totalKnown===!0&&e.total===e.returned&&e.omitted===0:e.state==="partial"?e.totalKnown===!0&&E(e.total)&&E(e.omitted)&&e.total===Number(e.returned)+Number(e.omitted):e.totalKnown===!1}function xi(e){if(!u(e)||!T(e.status,jt))return!1;let t=e.certification;return e.status==="validated"||e.status==="failed"?u(t)&&g(t.id)&&Number.isSafeInteger(t.version)&&Number(t.version)>0&&g(t.corpus):t===void 0}function Ei(e){return u(e)&&Number.isSafeInteger(e.policyVersion)&&(e.authority==="completion"||e.authority==="advisory"||e.authority==="none")&&Array.isArray(e.requiredRelationships)&&e.requiredRelationships.every(g)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function wi(e){return u(e)&&g(e.policyId)&&e.policyVersion===ge&&T(e.permission,Mt)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function ki(e){return Array.isArray(e)&&e.every(t=>u(t)&&g(t.id)&&g(t.selector)&&_i(t.origin))}function _i(e){return u(e)?e.kind==="fixed"?T(e.origin,K)&&e.origin!=="mixed":e.kind!=="result-field"||!g(e.field)||!u(e.values)?!1:Object.values(e.values).every(t=>T(t,K)&&t!=="mixed"):!1}function T(e,t){return typeof e=="string"&&t.includes(e)}var Ft="scip-query-result",Wt=0,A=1,Pi=1,Gt=1,Jt=1;function Bt(e){if(!u(e))return{kind:"malformed",reason:"CLI JSON output must be an object."};let t=Object.hasOwn(e,"kind"),n=Object.hasOwn(e,"schemaVersion");if(!t&&!n){let s=Lt(e);return s?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${s}`}:{kind:"legacy",schemaVersion:Wt,envelope:e}}if(!t||!n)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==Ft)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${ji(e.kind)}.`};let i=e.schemaVersion;if(!Number.isSafeInteger(i)||Number(i)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(i!==A)return{kind:"unsupported",schemaVersion:Number(i),direction:Number(i)<A?"older":"future",...$t(e.producer)?{producer:e.producer}:{}};let r=Lt(e);if(r)return{kind:"malformed",reason:`CLI JSON envelope v1: ${r}`};if(!$t(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!N(e.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};if(e.resultProjection!==void 0&&e.resultProjection!=="agent")return{kind:"malformed",reason:'CLI JSON envelope v1: resultProjection must be "agent" when present.'};let o=Ut(e.command);return o.includes(e.resultSchemaVersion)?e.evidenceContext!==void 0&&!Ni(e.evidenceContext)?{kind:"malformed",reason:"CLI JSON envelope v1: evidenceContext must contain a supported receipt and analysis manifest."}:e.operationRole!==void 0&&!Y(e.operationRole)?{kind:"malformed",reason:"CLI JSON envelope v1: operationRole must be a supported command operation role."}:u(e.evidenceContext)&&e.operationRole!==void 0&&e.evidenceContext.operationRole!==void 0&&e.operationRole!==e.evidenceContext.operationRole?{kind:"malformed",reason:"CLI JSON envelope v1: top-level and evidence-context operation roles must agree."}:{kind:"supported",schemaVersion:A,envelope:e}:{kind:"unsupported-result",schemaVersion:A,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:o}}function Ti(e){let t=Bt(e);if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="unsupported"){let n=t.producer?` from ${t.producer.name}@${t.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${t.schemaVersion}${n}; this consumer supports the legacy unversioned envelope and schemaVersion ${A}.`)}throw t.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${t.resultSchemaVersion} for scip-query command ${JSON.stringify(t.command)}; this consumer supports ${t.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${t.reason}`)}function Ut(e){return Ai[e]??[Pi]}var Ai={};function Lt(e){return typeof e.command!="string"||e.command.length===0?"command must be a non-empty string.":Array.isArray(e.args)?u(e.options)?Object.hasOwn(e,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function $t(e){return u(e)&&e.name==="scip-query"&&typeof e.version=="string"&&e.version.length>0}function Ni(e){if(!u(e)||e.schemaVersion!==Gt||e.operationRole!==void 0&&!Y(e.operationRole)||!G(e.receipt))return!1;let t=e.analysisManifest;return u(t)&&t.schemaVersion===Jt&&(t.evidence===void 0||t.evidence==="graph-fact"||t.evidence==="heuristic"||t.evidence==="mixed")&&(t.claimQualification===void 0||ye(t.claimQualification))}function ji(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{Mt as CLAIM_ACTION_PERMISSIONS,ge as CLAIM_ACTION_POLICY_VERSION,Nt as CLAIM_COVERAGE_STATES,K as CLAIM_ORIGINS,me as CLAIM_QUALIFICATION_SCHEMA_VERSION,Jt as CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION,Gt as CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION,Ft as CLI_JSON_ENVELOPE_KIND,At as COMMAND_OPERATION_ROLES,A as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,Vt as DEFAULT_REPOSITORY_POLICY_ACTION,Wt as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,h as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION,V as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION,M as OBSERVATION_IDENTITY_HASH_ALGORITHM,W as OBSERVATION_IDENTITY_SCHEMA_VERSION,R as OBSERVATION_RECEIPT_SCHEMA_VERSION,ne as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION,jt as PRODUCER_VALIDATION_STATUSES,ue as Watcher,Ci as commandOperation,vi as commandOperationRoles,re as compareObservationReceipts,Be as createObservationIdentity,wt as createReindexRunner,Bt as decodeCliJsonEnvelope,ie as decodeObservationReceipt,Dt as deriveClaimCoverage,Si as deriveClaimQualification,J as deriveObservationStateAuthority,Ii as evaluateClaimQualification,Yt as getScipVersion,wn as initProjectConfig,hi as installSkills,ye as isClaimQualificationV1,Y as isCommandOperationRole,G as isObservationReceipt,qt as isScipInstalled,H as loadProjectConfig,Ue as observationReceiptGenerationIdentity,qe as observationReceiptStabilityLabel,He as observationReceiptWorkspaceIdentity,Ri as operationObservesRepository,Kt as printScipInstallInstructions,Ti as requireCompatibleCliJsonEnvelope,bi as resolveCommandOperationRole,X as resolveIndexStoragePaths,Et as resolveReindexWorkerLaunch,Ut as supportedCliResultSchemaVersions};
4
5
  //# sourceMappingURL=runtime.js.map