scip-query 0.21.0 → 0.22.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.
- package/CHANGELOG.md +72 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-4IYG2SKW.js +2 -0
- package/dist/call-graph-WQNXMNNN.js +2 -0
- package/dist/{chunk-AQDWTCDC.js → chunk-25GWKRUZ.js} +2 -2
- package/dist/chunk-2BTJALUS.js +454 -0
- package/dist/chunk-2KVU55CW.js +11 -0
- package/dist/{chunk-BBWPOMGU.js → chunk-2OXVP5U5.js} +2 -2
- package/dist/{chunk-D5W4UZY5.js → chunk-2RE5OCHZ.js} +2 -2
- package/dist/{chunk-2I3RSUWX.js → chunk-2XCGSDIT.js} +2 -2
- package/dist/{chunk-V7LQZTTZ.js → chunk-2YC7YNKT.js} +2 -2
- package/dist/chunk-3QXC54FQ.js +3 -0
- package/dist/{chunk-32A42O5B.js → chunk-3TJY6M3B.js} +2 -2
- package/dist/chunk-42W3LFUK.js +13 -0
- package/dist/chunk-44T4DUAA.js +2 -0
- package/dist/chunk-4GAQ6FI4.js +43 -0
- package/dist/{chunk-4S4DF62J.js → chunk-4HE7MVWD.js} +2 -2
- package/dist/{chunk-TGWNNMPF.js → chunk-4TQU4TX2.js} +2 -2
- package/dist/{chunk-SKUMCCC5.js → chunk-56NQAEPJ.js} +2 -2
- package/dist/chunk-57N6LN2A.js +3 -0
- package/dist/{chunk-LPGDO2XA.js → chunk-5H5WTJSD.js} +2 -2
- package/dist/{chunk-EA4SH4U5.js → chunk-5YRQIE2B.js} +2 -2
- package/dist/{chunk-O2RM7E7L.js → chunk-5ZMBRQFC.js} +4 -4
- package/dist/{chunk-ICHBVITH.js → chunk-6HRZQLOI.js} +2 -2
- package/dist/{chunk-WULAPQUD.js → chunk-6NC3YSPY.js} +2 -2
- package/dist/{chunk-IDPLC3FI.js → chunk-6VEFRPTD.js} +2 -2
- package/dist/{chunk-IOKWFRFQ.js → chunk-7C26EKLZ.js} +2 -2
- package/dist/{chunk-S3RTPPLQ.js → chunk-7IQXARSQ.js} +2 -2
- package/dist/chunk-7JYHQAH2.js +22 -0
- package/dist/chunk-7KSO2OAP.js +2 -0
- package/dist/{chunk-2ZBMOQGG.js → chunk-7U2YQSDE.js} +2 -2
- package/dist/{chunk-EKZRF57O.js → chunk-7XA3OM44.js} +2 -2
- package/dist/{chunk-4EXFZP6H.js → chunk-7XZGZBSQ.js} +2 -2
- package/dist/chunk-7YQOCABQ.js +2 -0
- package/dist/chunk-A77SCPW2.js +3 -0
- package/dist/chunk-AK3PYTIK.js +5 -0
- package/dist/chunk-AMIMMNA4.js +11 -0
- package/dist/{chunk-MOBF2GH6.js → chunk-AQ2PORIO.js} +2 -2
- package/dist/{chunk-YUFWLWIC.js → chunk-ARVO6TTW.js} +2 -2
- package/dist/chunk-AUY5BL74.js +2 -0
- package/dist/{chunk-RGCJ4646.js → chunk-AYPDH2LU.js} +2 -2
- package/dist/{chunk-73Z33VFI.js → chunk-AZS7YPCB.js} +2 -2
- package/dist/{chunk-SYUNTKO2.js → chunk-BDGTPN27.js} +2 -2
- package/dist/{chunk-BATIVRU2.js → chunk-BDHFVH2M.js} +2 -2
- package/dist/chunk-BECZLYNU.js +8 -0
- package/dist/chunk-BJT7LSPK.js +3 -0
- package/dist/{chunk-6SWA6B24.js → chunk-BTVKZGWT.js} +2 -2
- package/dist/{chunk-QD7IFBCR.js → chunk-BUTEIZKP.js} +2 -2
- package/dist/{chunk-UZFCZ7SJ.js → chunk-BVFYEEBH.js} +2 -2
- package/dist/{chunk-ICUQONOG.js → chunk-BWVQP3LB.js} +2 -2
- package/dist/chunk-BYDAFMSR.js +57 -0
- package/dist/{chunk-BHE44MHT.js → chunk-C76O5MDS.js} +2 -2
- package/dist/chunk-C7IJMOFP.js +134 -0
- package/dist/{chunk-CN2WGM7D.js → chunk-CBBHFNLX.js} +2 -2
- package/dist/{chunk-COTMS5KM.js → chunk-CKRWA452.js} +2 -2
- package/dist/{chunk-ANWGXPPN.js → chunk-CLG6DWVS.js} +2 -2
- package/dist/chunk-D2MVJSP4.js +21 -0
- package/dist/chunk-D35XIZGN.js +2 -0
- package/dist/{chunk-U7DR7MJD.js → chunk-DEAB5TGT.js} +2 -2
- package/dist/{chunk-6GJAP4OE.js → chunk-DJAO2OZJ.js} +2 -2
- package/dist/chunk-DKM723YF.js +79 -0
- package/dist/{chunk-4IIMPWMR.js → chunk-DPWKKNKI.js} +2 -2
- package/dist/chunk-E44IVWIJ.js +367 -0
- package/dist/chunk-EDMB6SSO.js +7 -0
- package/dist/{chunk-KWARB5FZ.js → chunk-EELG7D3Q.js} +2 -2
- package/dist/chunk-EELPBR7E.js +3 -0
- package/dist/chunk-EETGXQY7.js +3 -0
- package/dist/chunk-ENWQWA2R.js +2 -0
- package/dist/{chunk-HUZNZ3H2.js → chunk-ERCYGVAM.js} +2 -2
- package/dist/{chunk-WSG3DK5H.js → chunk-EWWY2ZFL.js} +2 -2
- package/dist/chunk-F24G5NBE.js +3 -0
- package/dist/{chunk-XRXCANFQ.js → chunk-F24QUEQP.js} +2 -2
- package/dist/{chunk-KFK7GF5C.js → chunk-FBCVASUG.js} +2 -2
- package/dist/{chunk-35IW3P4H.js → chunk-FELGD32K.js} +2 -2
- package/dist/{chunk-UNORWZIJ.js → chunk-FFJQZG6J.js} +5 -5
- package/dist/{chunk-5SE323LF.js → chunk-FGNCOQUX.js} +2 -2
- package/dist/chunk-FKGQOTKD.js +2 -0
- package/dist/chunk-GDRJB3SB.js +3 -0
- package/dist/chunk-GH5YSGZL.js +5 -0
- package/dist/{chunk-X7PJJYKX.js → chunk-GIQ6CSL4.js} +2 -2
- package/dist/{chunk-2RP27XLR.js → chunk-GPGRZJ3R.js} +2 -2
- package/dist/{chunk-IYV2YBHM.js → chunk-GQIDEID3.js} +2 -2
- package/dist/chunk-GRX7JOXQ.js +2 -0
- package/dist/{chunk-H46QMB7E.js → chunk-GVOMSPGL.js} +2 -2
- package/dist/{chunk-KTRGJLY7.js → chunk-GY7CCCEZ.js} +2 -2
- package/dist/{chunk-VNKYRJKN.js → chunk-H7CG6LOE.js} +2 -2
- package/dist/chunk-HCVJR2V4.js +3 -0
- package/dist/chunk-HG722PO7.js +3 -0
- package/dist/{chunk-LHTT5C3Z.js → chunk-HISEUIL2.js} +2 -2
- package/dist/{chunk-K5MZYZV7.js → chunk-HXOU4XNH.js} +2 -2
- package/dist/chunk-I6UTXNHU.js +6 -0
- package/dist/{chunk-I7PFL5P3.js → chunk-IJMD6BRI.js} +2 -2
- package/dist/{chunk-XXJ7WL3F.js → chunk-IKVNEGTW.js} +2 -2
- package/dist/chunk-IMKZEXZG.js +2 -0
- package/dist/chunk-ISIQLPJ2.js +61 -0
- package/dist/{chunk-DEUGHURX.js → chunk-ISWFRGJ6.js} +2 -2
- package/dist/chunk-IW5XQG5G.js +2 -0
- package/dist/chunk-IXESDH3J.js +2 -0
- package/dist/{chunk-FGB567HK.js → chunk-JAT6C3VX.js} +2 -2
- package/dist/{chunk-7TWP3MCP.js → chunk-JFQBRL3J.js} +2 -2
- package/dist/{chunk-Q7HB7BFJ.js → chunk-JHH5SCZ3.js} +2 -2
- package/dist/{chunk-ZHSARYVS.js → chunk-JJ62MTQH.js} +2 -2
- package/dist/chunk-JT6XX7QY.js +8 -0
- package/dist/{chunk-5H7IWVXJ.js → chunk-JUN5DOAK.js} +2 -2
- package/dist/{chunk-DOPCR5BY.js → chunk-K3XFWJI2.js} +2 -2
- package/dist/{chunk-Y4XQ7LES.js → chunk-KFOYCQAJ.js} +1 -1
- package/dist/{chunk-N5C65OFK.js → chunk-KFVSJX25.js} +2 -2
- package/dist/chunk-KK7GPALL.js +28 -0
- package/dist/{chunk-DHKBIOXF.js → chunk-KQHJEU6V.js} +2 -2
- package/dist/{chunk-WB6LGCFB.js → chunk-KZYID5KV.js} +2 -2
- package/dist/{chunk-KW6B5OL4.js → chunk-LO5JSW2C.js} +2 -2
- package/dist/{chunk-ZW44MCJM.js → chunk-LRI5OMPE.js} +2 -2
- package/dist/{chunk-HG5YI7PV.js → chunk-LXQUF2RP.js} +2 -2
- package/dist/{chunk-TM5XEDDR.js → chunk-MHIEP7EG.js} +2 -2
- package/dist/{chunk-FHV7NMFU.js → chunk-MSR2QRUE.js} +2 -2
- package/dist/chunk-N7FP5H5U.js +57 -0
- package/dist/{chunk-3653GTR7.js → chunk-NEIQPFBI.js} +2 -2
- package/dist/chunk-NK3JMP22.js +2 -0
- package/dist/{chunk-7IOAZRVL.js → chunk-NRBNAECH.js} +2 -2
- package/dist/{chunk-HGKEAP7F.js → chunk-NVSZNESQ.js} +2 -2
- package/dist/{chunk-R2MOKIVO.js → chunk-OJNK5ALA.js} +2 -2
- package/dist/{chunk-RFWAUHVW.js → chunk-OPSAW5DT.js} +2 -2
- package/dist/chunk-OTSPRVNW.js +2 -0
- package/dist/chunk-OXYAWIEA.js +2 -0
- package/dist/chunk-OZETODHH.js +2 -0
- package/dist/chunk-PBUH2P5S.js +3 -0
- package/dist/{chunk-QBANU5BQ.js → chunk-PIFTZEEM.js} +2 -2
- package/dist/{chunk-CKDOY6JA.js → chunk-PLJUQFQN.js} +2 -2
- package/dist/{chunk-JVZNWJBH.js → chunk-PLYUVM4F.js} +2 -2
- package/dist/chunk-PXXYQK55.js +2 -0
- package/dist/{chunk-WZQFY5S7.js → chunk-Q55NF3ZG.js} +2 -2
- package/dist/{chunk-OVPS2ILI.js → chunk-Q5TA4OY4.js} +2 -2
- package/dist/{chunk-OUB4J26T.js → chunk-Q6T2CAJL.js} +2 -2
- package/dist/chunk-Q7GBK5T7.js +81 -0
- package/dist/chunk-QKT4UI2Y.js +2 -0
- package/dist/{chunk-PIZY2GX6.js → chunk-QLBSG7U5.js} +2 -2
- package/dist/chunk-QWKHW6VZ.js +2 -0
- package/dist/{chunk-E7BJXRNV.js → chunk-R6M456QG.js} +2 -2
- package/dist/{chunk-MJNV7OCG.js → chunk-RDULNRSJ.js} +2 -2
- package/dist/{chunk-SSSJO4RG.js → chunk-RHHCLWQ6.js} +2 -2
- package/dist/chunk-RNKPYYYE.js +4 -0
- package/dist/{chunk-IXJ26KJJ.js → chunk-RPL3ARU7.js} +2 -2
- package/dist/{chunk-3EX7DNBC.js → chunk-RYOYJMGF.js} +2 -2
- package/dist/chunk-SB25YMEQ.js +2 -0
- package/dist/chunk-SV2LEFVM.js +2 -0
- package/dist/{chunk-ZBNL3QCY.js → chunk-SVHTMVA4.js} +3 -3
- package/dist/{chunk-6IEVHGWG.js → chunk-SWK4XPUS.js} +2 -2
- package/dist/chunk-T6QD2ZQB.js +43 -0
- package/dist/{chunk-VETXXOYU.js → chunk-TAYD3AE7.js} +2 -2
- package/dist/chunk-TD7VKJ2Y.js +117 -0
- package/dist/{chunk-UQ7XPRWU.js → chunk-TH6IC56G.js} +2 -2
- package/dist/{chunk-XVDMJMES.js → chunk-TKDNDQA7.js} +2 -2
- package/dist/{chunk-CSDDOUA4.js → chunk-TNG2FYS5.js} +2 -2
- package/dist/chunk-TQZV7KV4.js +2 -0
- package/dist/{chunk-AJVMVE7X.js → chunk-TUQIPUDS.js} +2 -2
- package/dist/chunk-TUSPIVZ3.js +4 -0
- package/dist/{chunk-ORBKAUCH.js → chunk-U2N2KE7A.js} +2 -2
- package/dist/{chunk-3PII3JI5.js → chunk-UAQ4T73O.js} +2 -2
- package/dist/{chunk-OFY4HTMI.js → chunk-UDY7MIAW.js} +2 -2
- package/dist/{chunk-WKPZCQLI.js → chunk-URSGGIZX.js} +2 -2
- package/dist/{chunk-UL4VJUMD.js → chunk-UT7TADJX.js} +2 -2
- package/dist/chunk-V4NG5OMS.js +554 -0
- package/dist/{chunk-2H4IAJHO.js → chunk-VMWUV6WB.js} +2 -2
- package/dist/{chunk-46JLFIGA.js → chunk-VTCIYFEK.js} +2 -2
- package/dist/chunk-VU6LIWHT.js +2 -0
- package/dist/chunk-VUSKPCUB.js +2 -0
- package/dist/{chunk-URMZLV2N.js → chunk-VXJJTQYE.js} +2 -2
- package/dist/{chunk-IPAL6DP2.js → chunk-VZ7NXSHV.js} +2 -2
- package/dist/{chunk-FUG6RPYY.js → chunk-WHADK6OS.js} +2 -2
- package/dist/chunk-WN3TCGJ4.js +2 -0
- package/dist/{chunk-B7ECWJAZ.js → chunk-WOOAY3PA.js} +2 -2
- package/dist/chunk-WRQXLNYE.js +9 -0
- package/dist/chunk-WSLEJSFR.js +2 -0
- package/dist/chunk-WYZIHUPZ.js +16 -0
- package/dist/{chunk-ZYREOING.js → chunk-XE33FV5W.js} +2 -2
- package/dist/chunk-XFMVKFSF.js +2 -0
- package/dist/{chunk-BBEDPVPB.js → chunk-XGGBK66W.js} +2 -2
- package/dist/{chunk-OFUBXBYX.js → chunk-XJX6LGHL.js} +2 -2
- package/dist/{chunk-Z3GCK3PD.js → chunk-XN22RGSR.js} +2 -2
- package/dist/{chunk-HWLCBKFE.js → chunk-XSWYJCAK.js} +2 -2
- package/dist/{chunk-IGKKTHJR.js → chunk-XU75YQN4.js} +2 -2
- package/dist/{chunk-E4EJBGDZ.js → chunk-Y2VM4CJC.js} +2 -2
- package/dist/{chunk-U7LRSQG6.js → chunk-Y334QQU5.js} +2 -2
- package/dist/{chunk-APLKXICZ.js → chunk-YAGYMBEX.js} +2 -2
- package/dist/{chunk-XITQLISP.js → chunk-YIHNPKWD.js} +2 -2
- package/dist/chunk-YXPUP5G2.js +11 -0
- package/dist/{chunk-6BJ7SOY7.js → chunk-Z2AWCTN6.js} +2 -2
- package/dist/{chunk-PHSPBQM6.js → chunk-Z2PZVKPR.js} +2 -2
- package/dist/{chunk-QXR5QPSF.js → chunk-ZAZGGSM3.js} +2 -2
- package/dist/{chunk-5236NQV3.js → chunk-ZGW4HLPD.js} +2 -2
- package/dist/chunk-ZOXKSQQB.js +2 -0
- package/dist/{chunk-BD6CV7PN.js → chunk-ZPASRBLF.js} +2 -2
- package/dist/{chunk-DMUGTKMD.js → chunk-ZYM4HOFA.js} +2 -2
- package/dist/{chunk-4ILHWBYF.js → chunk-ZZ3Z7D56.js} +2 -2
- package/dist/cli-main.js +4 -4
- package/dist/{code-CczEvHui.d.ts → code-B17qEMbt.d.ts} +1 -1
- package/dist/code-EQJFDT6I.js +2 -0
- package/dist/code-result-json-7UWIWBOO.js +2 -0
- package/dist/command-descriptors-ORNTVNYV.js +342 -0
- package/dist/{config-types-Cm-VSEBb.d.ts → config-types-B9B60MiR.d.ts} +10 -0
- package/dist/dataflow-6VL54GX5.js +2 -0
- package/dist/{db-LKJXAlNS.d.ts → db-BwIVAYNB.d.ts} +1 -1
- package/dist/dependence-slice-DT2NUHD2.js +2 -0
- package/dist/deps-DB7H5IKC.js +2 -0
- package/dist/direct-navigation-O3LUAYWQ.js +3 -0
- package/dist/entry-map-6K62RV3D.js +2 -0
- package/dist/files-MSLD7MO6.js +2 -0
- package/dist/{graph-evidence-CbUPCSKV.d.ts → graph-evidence-Bjyky2V4.d.ts} +1 -1
- package/dist/{health-Wl5G_LRt.d.ts → health-CPp2Jf1Z.d.ts} +1 -1
- package/dist/hierarchy-IVBXAKFA.js +2 -0
- package/dist/imports-FRAVZ3Y2.js +2 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/members-KJOJDYGO.js +2 -0
- package/dist/methods-2AYABBT3.js +2 -0
- package/dist/output-continuation-command-JHMPH6NC.js +3 -0
- package/dist/{output-pagination-VAWOGX4R.js → output-pagination-3OFL2MJV.js} +2 -2
- package/dist/project-reindex-HYO4WD7Z.js +3 -0
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +2 -2
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.d.ts +2 -2
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +3 -3
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +13 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +2 -2
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.d.ts +3 -3
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +2 -2
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +2 -2
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +3 -3
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +5 -5
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.d.ts +2 -2
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.d.ts +2 -2
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.d.ts +4 -4
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +2 -2
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +2 -2
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.d.ts +3 -3
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/query-service-fastpath.js +5 -5
- package/dist/query-service-server.js +2 -2
- package/dist/refs-ARMA6XUJ.js +2 -0
- package/dist/refs-pagination-VUGIWN6U.js +2 -0
- package/dist/reindex-worker.js +125 -66
- package/dist/reindex.d.ts +5 -3
- package/dist/reindex.js +135 -76
- package/dist/runtime.d.ts +5 -5
- package/dist/runtime.js +4 -4
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{scip-cli-CppzF5MK.d.ts → scip-cli-H-n59izO.d.ts} +1 -1
- package/dist/slice-YOB5YFAM.js +2 -0
- package/dist/surface-VY5EFWTW.js +2 -0
- package/dist/symbol-resolution-DGQN4XIV.js +2 -0
- package/dist/system-2KQ3QD2P.js +2 -0
- package/dist/trace-HTIPTXAE.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/value-flow-5FV3VQI7.js +2 -0
- package/dist/watch-server.js +3 -3
- package/docs/CLI_JSON_OUTPUT.md +2 -2
- package/docs/COMMAND_REFERENCE.md +2 -2
- package/docs/schemas/project-config.schema.json +11 -1
- package/package.json +6 -5
- package/skills/scip-explore/SKILL.md +73 -3
- package/skills/scip-explore/agents/openai.yaml +3 -3
- package/skills/scip-explore/references/delegated-exploration.md +51 -0
- package/skills/scip-explore/references/external-evidence.md +72 -0
- package/skills/scip-explore/references/information-model.md +51 -0
- package/skills/scip-explore/scripts/capture-evidence.mjs +666 -0
- package/skills/scip-query/SKILL.md +22 -1
- package/dist/by-kind-CI3O6PQG.js +0 -2
- package/dist/call-graph-6QTUTXH7.js +0 -2
- package/dist/chunk-2COFMIVK.js +0 -60
- package/dist/chunk-35ELD3RM.js +0 -2
- package/dist/chunk-3FQ3KMCD.js +0 -2
- package/dist/chunk-3VLJ2DCA.js +0 -2
- package/dist/chunk-4DCKBY6T.js +0 -5
- package/dist/chunk-4N6QSEMZ.js +0 -10
- package/dist/chunk-4OE2JO6I.js +0 -2
- package/dist/chunk-4UUCUASK.js +0 -554
- package/dist/chunk-54EOGFBR.js +0 -2
- package/dist/chunk-5IZTXSOL.js +0 -117
- package/dist/chunk-5ZJH6DDE.js +0 -2
- package/dist/chunk-63MBA7EG.js +0 -3
- package/dist/chunk-6T7H2AFY.js +0 -3
- package/dist/chunk-7COHFNJK.js +0 -38
- package/dist/chunk-7HU2IJ2T.js +0 -3
- package/dist/chunk-7PPYXENX.js +0 -2
- package/dist/chunk-AA7K3XLM.js +0 -21
- package/dist/chunk-AUP6YI5M.js +0 -2
- package/dist/chunk-CA5RE6H7.js +0 -2
- package/dist/chunk-CT5SI2I4.js +0 -2
- package/dist/chunk-D5EKVZPI.js +0 -2
- package/dist/chunk-DMQ7ZKJG.js +0 -81
- package/dist/chunk-ELNRLMC5.js +0 -29
- package/dist/chunk-F7WQ337U.js +0 -308
- package/dist/chunk-FEQIQ26E.js +0 -2
- package/dist/chunk-FN6EJM6Q.js +0 -2
- package/dist/chunk-FTSQNONX.js +0 -2
- package/dist/chunk-G2F6T5BV.js +0 -2
- package/dist/chunk-G6OGPXJW.js +0 -9
- package/dist/chunk-GFLTPNWV.js +0 -3
- package/dist/chunk-GTDP2SKQ.js +0 -2
- package/dist/chunk-HEOMG7IM.js +0 -8
- package/dist/chunk-I3U2FN2T.js +0 -13
- package/dist/chunk-IUJ3ZFEE.js +0 -7
- package/dist/chunk-LXLD46LH.js +0 -21
- package/dist/chunk-MEI3PTUK.js +0 -2
- package/dist/chunk-MO226P4Q.js +0 -4
- package/dist/chunk-MYUKI5VN.js +0 -4
- package/dist/chunk-OIRWZIYL.js +0 -38
- package/dist/chunk-OIVZ7PW6.js +0 -438
- package/dist/chunk-PNISDVYC.js +0 -3
- package/dist/chunk-PQOL42AW.js +0 -2
- package/dist/chunk-PUVZNFVY.js +0 -11
- package/dist/chunk-PZEI2TVL.js +0 -4
- package/dist/chunk-Q2J2VZZT.js +0 -2
- package/dist/chunk-QDCCHMVZ.js +0 -2
- package/dist/chunk-QLQBZOJH.js +0 -3
- package/dist/chunk-S73HBCGI.js +0 -11
- package/dist/chunk-SDPA5DKN.js +0 -210
- package/dist/chunk-SEUJVWT2.js +0 -3
- package/dist/chunk-SF7X6QNW.js +0 -2
- package/dist/chunk-SWFAFA4G.js +0 -49
- package/dist/chunk-T6FRID7Y.js +0 -3
- package/dist/chunk-TNOHGHZQ.js +0 -2
- package/dist/chunk-U2GPTA5U.js +0 -3
- package/dist/chunk-URTX2BEA.js +0 -6
- package/dist/chunk-VGRUM7JI.js +0 -3
- package/dist/chunk-VWLIOEEF.js +0 -11
- package/dist/chunk-WK4FD4PG.js +0 -2
- package/dist/chunk-X434XZAI.js +0 -2
- package/dist/chunk-YIEFEPG6.js +0 -16
- package/dist/chunk-YRVERHJR.js +0 -49
- package/dist/chunk-ZD3Z54IW.js +0 -2
- package/dist/chunk-ZDVDSDFG.js +0 -4
- package/dist/code-EQL6ZBLH.js +0 -2
- package/dist/code-result-json-6E4J6LGZ.js +0 -2
- package/dist/command-descriptors-QH3G2OVD.js +0 -346
- package/dist/dataflow-2BLMUZBP.js +0 -2
- package/dist/dependence-slice-MGAJDZXB.js +0 -2
- package/dist/deps-GQMUYVKW.js +0 -2
- package/dist/direct-navigation-6RUJKLAV.js +0 -3
- package/dist/entry-map-V2NQP5JU.js +0 -2
- package/dist/files-VM53I4IU.js +0 -2
- package/dist/hierarchy-D553WRSZ.js +0 -2
- package/dist/imports-DOZAJWLW.js +0 -2
- package/dist/members-HE67475K.js +0 -2
- package/dist/methods-K5JK4PPH.js +0 -2
- package/dist/output-continuation-command-LKBUTNRL.js +0 -3
- package/dist/project-reindex-4ARU6QCM.js +0 -3
- package/dist/refs-NBHKL4UQ.js +0 -2
- package/dist/refs-pagination-BBVTIHMH.js +0 -2
- package/dist/slice-U6S6LBSB.js +0 -2
- package/dist/surface-C7SS5CDQ.js +0 -2
- package/dist/symbol-resolution-3FVEKDTJ.js +0 -2
- package/dist/system-6K2NOO5C.js +0 -2
- package/dist/trace-II5K2TMH.js +0 -2
- package/dist/value-flow-MKFUUE5B.js +0 -2
package/dist/reindex-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as ut,b as mn}from"./chunk-BZYSGZRK.js";import{a as ke,b as Me,c as Kn}from"./chunk-FFJQZG6J.js";import{a as Rr}from"./chunk-ILMHV3KM.js";import{a as St,b as Pr}from"./chunk-GRX7JOXQ.js";import{e as Gn,f as Bn,g as Un,i as qn}from"./chunk-BYDAFMSR.js";import"./chunk-RYOYJMGF.js";import{b as $n}from"./chunk-FKGQOTKD.js";import"./chunk-FELGD32K.js";import"./chunk-2XCGSDIT.js";import"./chunk-WRQXLNYE.js";import{b as Mn,c as Oe,d as Nn,e as Ln,f as An}from"./chunk-T6QD2ZQB.js";import"./chunk-EELPBR7E.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import{a as de,b as Ce,c as he,d as Tn,e as wn,f as Cn,g as jn,h as Fn,j as xr}from"./chunk-VUSKPCUB.js";import{a as gn,b as fn}from"./chunk-F4FNK44D.js";import{a as $}from"./chunk-C76O5MDS.js";import{b as ue}from"./chunk-TQZV7KV4.js";import"./chunk-C7IJMOFP.js";import{a as Fe}from"./chunk-YXPUP5G2.js";import"./chunk-DRENNWRG.js";import{a as on,b as sn,c as Ie,d as le,e as Wn,f as Hn,h as ht,i as Vn,n as Er}from"./chunk-EDMB6SSO.js";import{a as Ge,b as hr,d as yr}from"./chunk-7YQOCABQ.js";import{a as Pt}from"./chunk-MXNGIEPU.js";import{b as Sr,c as br,d as bt}from"./chunk-BVFYEEBH.js";import"./chunk-JHH5SCZ3.js";import{A as Ae,C as or,E as yt,F as sr,G as cr,H as $e,I as dr,J as lr,K as ur,a as yn,b as A,d as Pn,g as ft,i as Jn,j as X,k as Y,l as De,m as zn,n as Xn,o as Yn,p as Qn,q as Ne,r as Zn,s as er,t as tr,u as nr,v as rr,w as ir,x as ar,y as Le,z as q}from"./chunk-WN3TCGJ4.js";import{a as kn,d as mt,k as Dn}from"./chunk-DKM723YF.js";import{c as ae,d as me,e as _e,g as ct,h as ln}from"./chunk-K3XFWJI2.js";import"./chunk-NRBNAECH.js";import"./chunk-IW5XQG5G.js";import{b as Sn,c as pt,d as bn}from"./chunk-57N6LN2A.js";import{a as oe,c as je,d as On,g as pr,k as gr,l as fr,m as mr}from"./chunk-JT6XX7QY.js";import"./chunk-H5EXS3HM.js";import{a as un,e as E,f as G,g as pn}from"./chunk-HGFDYOVB.js";import{a as Ee,b as J,c as U,d as C}from"./chunk-SB25YMEQ.js";import{$ as z,E as dt,N as lt,P as Te,T as we,_ as hn,a as rn,aa as se,ba as ce,c as xe,ca as Rn,da as xn,ea as gt,f as re,g as ge,h as fe,ha as En,i as an,m as ve,n as cn,o as st,p as dn,r as ie,ra as In,sa as vn,t as M,ta as _n}from"./chunk-AK3PYTIK.js";import{createHash as oc}from"crypto";import{existsSync as L,mkdirSync as et,mkdtempSync as sc,readdirSync as ta,renameSync as na,rmSync as V,statSync as Yt}from"fs";import{basename as Ve,dirname as x,extname as cc,join as F,resolve as Wi}from"path";import{platform as dc}from"os";import{execFileSync as Fa}from"child_process";import{constants as Oa,copyFileSync as Ir,statSync as ka}from"fs";import{platform as Da}from"os";var Ma=Object.freeze({size:e=>ka(e).size,clone:La,copy:(e,t)=>Ir(e,t)}),Na=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function Q(e,t,n=Ma){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(a){if(!$a(a))throw a}return n.copy(e,t),{method:"copy",bytes:r}}function La(e,t){if(Da()!=="darwin"){Ir(e,t,Oa.COPYFILE_FICLONE_FORCE);return}try{Fa("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"]})}catch(n){throw Aa(n)}}function Aa(e){let t=e?.stderr,n=Buffer.isBuffer(t)?t.toString("utf8"):t??"";return/operation not supported|not supported/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"ENOTSUP"}):/cross-device link/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"EXDEV"}):e}function $a(e){let t=e?.code;return t!==void 0&&Na.has(t)}function vr(){return{reflinkedBytes:0,fallbackCopiedBytes:0,incrementalWrittenBytes:0}}function K(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}function Be(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Error("incremental write bytes must be a non-negative integer");e.incrementalWrittenBytes=(e.incrementalWrittenBytes??0)+t}import{dirname as Ga,join as Ba}from"path";function _r(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:async({projectRoot:t,dbPath:n,onStatus:r})=>{let a=new $({projectRoot:t,dbPath:n,indexPath:e.indexPath??Ba(Ga(n),"index.scip"),...e.evidenceDbPath?{evidenceDbPath:e.evidenceDbPath}:{}}),i,o=!1,s=!1;try{let d=e.reuseExisting||e.affectedFiles?qn(a):null;e.reuseExisting&&d?.extractorVersion===Gn?(i=d,o=!0):(i=await Bn(a,{...d?{previousGraph:d}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{},...e.forceDerivedRebuild?{forceDerivedRebuild:!0}:{},profileSpan:E}),s=(i.coverage.filesReused??0)>0)}finally{a.close()}o||Un(n,i);let c={reused:o,incrementallyUpdated:s,observations:i.observations.length,links:i.links.length,frontiers:i.frontiers.length,filesScanned:i.coverage.filesScanned,errors:i.coverage.extractionErrors.length,phases:i.coverage.phases};return r?.(c.reused?`Reused ${c.observations} cached runtime-boundary observation(s) and ${c.links} link(s).`:c.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${c.filesScanned-(i.coverage.filesReused??0)} file(s) extracted, ${i.coverage.filesReused??0} reused) and rebuilt ${c.links} link(s).`:`Extracted ${c.observations} runtime-boundary observation(s), ${c.links} link(s), and ${c.frontiers} unresolved frontier(s).`),!o&&i.coverage.phases&&r?.(`Runtime-boundary phases: ${i.coverage.phases.map(d=>`${d.id} ${d.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as qa}from"crypto";import{existsSync as Wa}from"fs";import{dirname as Ha,join as wr}from"path";function Rt(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function ye(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let a=new Set(n),i=Rt(e),o=new Set(i.reasons);return r.some(s=>!a.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),Tr(r,a,o)):o.size>0?Tr(r,a,o):{mode:"closure",changedFiles:r,affectedFiles:Ua(r,t,a),reasons:[]}}function Tr(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Ua(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let c of s){if(!n.has(c))continue;let d=r.get(c)??new Set;d.add(o),r.set(c,d)}let a=new Set(e),i=[...e];for(let o=0;o<i.length;o+=1){let s=i[o];if(s!==void 0)for(let c of r.get(s)??[])a.has(c)||(a.add(c),i.push(c))}return[...a].sort()}var Ja="<global-symbols>";function za(e){let t=[];for(let n of e.all(`
|
|
2
2
|
SELECT relative_path, language, position_encoding, text
|
|
3
3
|
FROM documents
|
|
4
4
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -25,7 +25,7 @@ import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./c
|
|
|
25
25
|
FROM defn_enclosing_ranges r
|
|
26
26
|
JOIN documents d ON d.id = r.document_id
|
|
27
27
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
28
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
28
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:xt(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
29
29
|
SELECT d.relative_path,
|
|
30
30
|
c.chunk_index,
|
|
31
31
|
m.role,
|
|
@@ -40,7 +40,7 @@ import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./c
|
|
|
40
40
|
JOIN chunks c ON c.id = m.chunk_id
|
|
41
41
|
JOIN documents d ON d.id = c.document_id
|
|
42
42
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
43
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
43
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:xt(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
44
44
|
SELECT g.symbol,
|
|
45
45
|
g.display_name,
|
|
46
46
|
g.kind,
|
|
@@ -54,68 +54,84 @@ import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./c
|
|
|
54
54
|
) AND NOT EXISTS (
|
|
55
55
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
56
56
|
)
|
|
57
|
-
`))t.push({relativePath:
|
|
58
|
-
`);n.set(r,i.digest("hex"))}return n}function _a(e,t){let n=[],r=[],a=[],i=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let c=e.get(s),l=t.get(s);c===void 0?n.push(s):l===void 0?a.push(s):c!==l?r.push(s):i.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:a,changedFiles:[...n,...r,...a].sort(),unchangedFiles:i}}function Ke(e,t,n){let r=new Set(e.affectedFiles),a=new Set(t.changedFiles),i=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),o=e.affectedFiles.filter(c=>!a.has(c)).sort(),s=t.changedFiles.length-i.length;return{passed:i.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:i,extraFiles:o}}function Ze(e,t=Oa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,a=t.wallNow??t.now,i=r(),o=(l,d)=>{let u=r();return Hn(e.refreshResult,l,n?u:a(),Math.max(0,u-i),d)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let l=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),d=de(e.previousSnapshot,e.currentSnapshot),u=new Set(l),p=d.changes.length>0&&!Ve(d).fullProject&&d.changes.every(O=>u.has(O.path)),m=be(d,p?t.dependencyGraph(s):new Map,l),g=_a(t.factDigests(s),t.factDigests(c)),y=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?y:a()).toISOString(),durationMs:Math.max(0,y-i),manifest:d,plan:m,comparison:g,evaluation:Ke(m,g,l.length)}}catch(l){return o("oracle-error",l instanceof Error?l.message:String(l))}finally{Wn(s),Wn(c)}}function qn(e,t,n,r=Date.now()){return Hn(e,t,r,0,n)}function ja(e){let t=va(e);return{latestPath:Bn(t,"affected-shadow-latest.json"),historyPath:Bn(t,"affected-shadow.jsonl")}}function Jn(e,t,n=Aa){let r=ja(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Ta=8*1024*1024,Fa=on;function Da(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function ka(e,t,n=Ta){sn(e,Da(t),{maxSegmentBytes:n,previousSuffix:Fa})}function Ye(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var Oa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>Ra(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>ge(e),dependencyGraph:e=>Vt(e),factDigests:e=>Ea(e)},Aa={appendHistory:ka,writeLatest:(e,t)=>Xt(e,t,{spacing:2,trailingNewline:!0})};function Hn(e,t,n,r,a){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...a?{error:a}:{}}}function Wn(e){try{e?.close()}catch{}}import{readdirSync as Ma}from"fs";import{isAbsolute as zn,join as La,resolve as Ca}from"path";var Pe="@sourcegraph/scip-typescript@0.4.0",Xn="scip-python-plus@0.7.5",Qn="github.com/sourcegraph/scip-go@v0.2.7",Vn="scip-dotnet@0.2.14",Na="scip_dart@1.6.2",$a={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar"]}:{binary:n,args:["index","--output",e,"--no-progress-bar"]},markerFiles:[...I.typescript],installMethods:[{label:"npm",identity:Pe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Pe]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar"]}),markerFiles:[...I.javascript],installMethods:[{label:"npm",identity:Pe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Pe]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...I.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...I.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...I.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:X.language,indexerBinary:X.indexerBinary,checkCommand:`${X.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:X.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...I.rust],installMethods:[],installUrl:X.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...I.python],installMethods:[{label:"npm",identity:Xn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Xn]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let a=["-root",e,"-output",t];return r&&a.push("-config",zn(r)?r:Ca(e,r)),{binary:n,args:a}},markerFiles:[...I.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...I.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...I.go],installMethods:[{label:"go install",identity:Qn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Qn]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...I.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...I.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Yn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.csharp],installMethods:[{label:"dotnet",identity:Vn,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Yn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.vb],installMethods:[{label:"dotnet",identity:Vn,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...I.dart],installMethods:[{label:"dart pub",identity:Na,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>zn(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...I.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Kn(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function et(e){return $a[e]}function Yn(e,t){let n;try{n=Ma(e)}catch{return null}for(let r of t)for(let a of n)if(a.endsWith(r))return La(e,a);return null}import{createHash as Ga}from"crypto";import{existsSync as Zn,rmSync as er}from"fs";import{resolve as Ua}from"path";import rr from"better-sqlite3";var Ba={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},Wa={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function ar(e){let t=P(),n=qa(e.affectedFiles);if(Ja(e.previousDbPath,e.miniDbPath,e.candidateDbPath),er(e.candidateDbPath,{force:!0}),!Zn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Zn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");tr(e.previousDbPath,"previous SQLite generation",!1),tr(e.miniDbPath,"incremental SQLite mini database");let r=B(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&W(e.writeTelemetry,r);let a=null;try{a=new rr(e.candidateDbPath,{fileMustExist:!0}),a.pragma("busy_timeout = 5000"),a.pragma("foreign_keys = ON"),a.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),tt(a,"main","candidate SQLite generation"),tt(a,"incremental","incremental SQLite mini database"),Ha(a,n);let{priorAffectedCount:i}=za(a,n.length),o=nt(a,"main",!0),s=N(a,"SELECT COUNT(*) AS value FROM main.documents");a.transaction(()=>{Xa(a),Qa(a),Va(a),e.onStage?.("after-delete"),Ya(a),e.onStage?.("after-symbol-reconciliation"),Ka(a),e.onStage?.("after-insert"),Za(a),ei(a,n.length,s,i),e.onStage?.("before-commit")}).immediate(),ir(a,"main","candidate SQLite generation");let d=[...ti(a)].filter(([u,p])=>o.get(u)!==p).map(([u])=>u).sort();return a.exec("DETACH DATABASE incremental"),a.close(),a=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:P()-t}}catch(i){try{a?.close()}finally{er(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function qa(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Ja(e,t,n){let r=[e,t,n].map(a=>Ua(a));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function tr(e,t,n=!0){let r=new rr(e,{readonly:!0,fileMustExist:!0});try{tt(r,"main",t),n&&ir(r,"main",t)}finally{r.close()}}function tt(e,t,n){for(let[r,a]of Object.entries(Ba)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:l,pk:d})=>({name:s,type:c.toUpperCase(),notnull:l,pk:d}));if(JSON.stringify(o)!==JSON.stringify(a))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,a]of Object.entries(Wa)){let i=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(i?.tbl_name!==a.table||JSON.stringify(o)!==JSON.stringify(a.columns))throw new Error(`${n} schema changed for index ${r}`)}nr(e,t,"documents",["relative_path"],n),nr(e,t,"global_symbols",["symbol"],n)}function nr(e,t,n,r,a){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(l=>l.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${a} lost the unique ${n}(${r.join(", ")}) constraint`)}function ir(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function Ha(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(a=>{for(let i of a)n.run(i)})(t)}function za(e,t){let n=N(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=N(e,`SELECT COUNT(*) AS value
|
|
57
|
+
`))t.push({relativePath:Ja,kind:"global-symbol",values:xt(n)});return Xa(t)}function Xa(e){let t=new Map;for(let r of e){let a=JSON.stringify([r.kind,r.values]),i=t.get(r.relativePath)??[];i.push(a),t.set(r.relativePath,i)}let n=new Map;for(let[r,a]of[...t].sort(([i],[o])=>i.localeCompare(o))){let i=qa("sha256");for(let o of a.sort())i.update(String(Buffer.byteLength(o))),i.update(":"),i.update(o),i.update(`
|
|
58
|
+
`);n.set(r,i.digest("hex"))}return n}function Ya(e,t){let n=[],r=[],a=[],i=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let c=e.get(s),d=t.get(s);c===void 0?n.push(s):d===void 0?a.push(s):c!==d?r.push(s):i.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:a,changedFiles:[...n,...r,...a].sort(),unchangedFiles:i}}function Et(e,t,n){let r=new Set(e.affectedFiles),a=new Set(t.changedFiles),i=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),o=e.affectedFiles.filter(c=>!a.has(c)).sort(),s=t.changedFiles.length-i.length;return{passed:i.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:i,extraFiles:o}}function It(e,t=to){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,a=t.wallNow??t.now,i=r(),o=(d,l)=>{let g=r();return Or(e.refreshResult,d,n?g:a(),Math.max(0,g-i),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");if(e.refreshResult==="rebuilt"&&ie(e.previousSnapshot,e.currentSnapshot).changes.length===0)return o("no-input-changes");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let d=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=ie(e.previousSnapshot,e.currentSnapshot),g=new Set(d),p=l.changes.length>0&&!Rt(l).fullProject&&l.changes.every(j=>g.has(j.path)),f=ye(l,p?t.dependencyGraph(s):new Map,d),R=Ya(t.factDigests(s),t.factDigests(c)),T=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?T:a()).toISOString(),durationMs:Math.max(0,T-i),manifest:l,plan:f,comparison:R,evaluation:Et(f,R,d.length)}}catch(d){return o("oracle-error",d instanceof Error?d.message:String(d))}finally{Cr(s),Cr(c)}}function jr(e,t,n,r=Date.now()){return Or(e,t,r,0,n)}function Qa(e){let t=Ha(e);return{latestPath:wr(t,"affected-shadow-latest.json"),historyPath:wr(t,"affected-shadow.jsonl")}}function Fr(e,t,n=no){let r=Qa(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Ka=8*1024*1024,Va=Wn;function Za(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function eo(e,t,n=Ka){Hn(e,Za(t),{maxSegmentBytes:n,previousSuffix:Va})}function xt(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var to={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:C,databaseExists:e=>Wa(e),openDatabase:(e,t,n)=>new $({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Fe(e),dependencyGraph:e=>Mn(e),factDigests:e=>za(e)},no={appendHistory:eo,writeLatest:(e,t)=>je(e,t,{spacing:2,trailingNewline:!0})};function Or(e,t,n,r,a){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...a?{error:a}:{}}}function Cr(e){try{e?.close()}catch{}}import{readdirSync as ro}from"fs";import{isAbsolute as kr,join as io,resolve as ao}from"path";var Ue="@sourcegraph/scip-typescript@0.4.0",Dr="scip-python-plus@0.7.5",Mr="github.com/sourcegraph/scip-go@v0.2.7",Nr="scip-dotnet@0.2.14",oo="scip_dart@1.6.2",so={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar","--no-global-caches"]}:{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]},markerFiles:[...M.typescript],installMethods:[{label:"npm",identity:Ue,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ue]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]}),markerFiles:[...M.javascript],installMethods:[{label:"npm",identity:Ue,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ue]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:de.language,indexerBinary:de.indexerBinary,checkCommand:`${de.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:de.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...M.rust],installMethods:[],installUrl:de.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...M.python],installMethods:[{label:"npm",identity:Dr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Dr]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let a=["-root",e,"-output",t];return r&&a.push("-config",kr(r)?r:ao(e,r)),{binary:n,args:a}},markerFiles:[...M.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...M.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...M.go],installMethods:[{label:"go install",identity:Mr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Mr]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...M.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...M.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Lr(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...M.csharp],installMethods:[{label:"dotnet",identity:Nr,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Lr(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...M.vb],installMethods:[{label:"dotnet",identity:Nr,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...M.dart],installMethods:[{label:"dart pub",identity:oo,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>kr(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...M.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Ar(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function vt(e){return so[e]}function Lr(e,t){let n;try{n=ro(e)}catch{return null}for(let r of t)for(let a of n)if(a.endsWith(r))return io(e,a);return null}import{createHash as co}from"crypto";import{existsSync as Tt,rmSync as $r,statSync as lo}from"fs";import{resolve as uo}from"path";import Ur from"better-sqlite3";var po={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},go={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function qr(e){let t=C(),n=Gr(e.affectedFiles),r=Gr(e.deletedFiles??[],!0),a=new Set(n);if(r.some(s=>!a.has(s)))throw new Error("deleted incremental documents must be included in the affected document set");let i=n.length-r.length;if(mo(e.previousDbPath,e.miniDbPath,e.candidateDbPath),!Tt(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Tt(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");E("reindex.publish.sqlite-patch.validate-inputs",()=>{_t(e.previousDbPath,"previous SQLite generation",!1),_t(e.miniDbPath,"incremental SQLite mini database")}),e.reuseCandidate?E("reindex.publish.sqlite-patch.reuse-candidate",()=>_t(e.candidateDbPath,"incremental SQLite candidate",!1)):E("reindex.publish.sqlite-patch.clone",()=>{$r(e.candidateDbPath,{force:!0});let s=Q(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&K(e.writeTelemetry,s)});let o=null;try{o=E("reindex.publish.sqlite-patch.open",()=>{let f=new Ur(e.candidateDbPath,{fileMustExist:!0});return f.pragma("busy_timeout = 5000"),f.pragma("foreign_keys = ON"),f.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),wt(f,"main","candidate SQLite generation"),wt(f,"incremental","incremental SQLite mini database"),f});let{priorAffectedCount:s,previousFactDigests:c}=E("reindex.publish.sqlite-patch.prepare",()=>(So(o,n,r),{...bo(o,n.length,r.length),previousFactDigests:Ct(o,"main",!0)})),d=W(o,"SELECT COUNT(*) AS value FROM main.documents"),l=o.transaction(()=>{E("reindex.publish.sqlite-patch.transaction.symbol-ownership",()=>Po(o)),E("reindex.publish.sqlite-patch.transaction.shared-definitions",()=>Ro(o)),E("reindex.publish.sqlite-patch.transaction.delete",()=>xo(o)),e.onStage?.("after-delete"),E("reindex.publish.sqlite-patch.transaction.reconcile-symbols",()=>Eo(o)),e.onStage?.("after-symbol-reconciliation"),E("reindex.publish.sqlite-patch.transaction.insert",()=>Io(o)),e.onStage?.("after-insert"),E("reindex.publish.sqlite-patch.transaction.prune-symbols",()=>vo(o,e.trustedPriorGeneration===!0)),E("reindex.publish.sqlite-patch.transaction.validate",()=>_o(o,i,d,s)),e.onStage?.("before-commit")});E("reindex.publish.sqlite-patch.transaction",()=>l.immediate()),e.writeTelemetry&&Be(e.writeTelemetry,2*fo(e.candidateDbPath)),E("reindex.publish.sqlite-patch.integrity",()=>yo(o,"candidate SQLite generation",!e.deferIntegrity&&e.trustedPriorGeneration!==!0));let g=E("reindex.publish.sqlite-patch.validate-facts",()=>To(o)),p=[...new Set([...c.keys(),...g.keys()])].filter(f=>c.get(f)!==g.get(f)).sort();return o.exec("DETACH DATABASE incremental"),o.close(),o=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:p,durationMs:C()-t}}catch(s){try{o?.close()}finally{$r(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}function fo(e){let t=0;for(let n of["-wal","-journal"]){let r=`${e}${n}`;Tt(r)&&(t+=lo(r).size)}return t}function Gr(e,t=!1){if(!t&&e.length===0)throw new Error("incremental SQLite publication requires affected documents");let n=[...e].sort();for(let r of n)if(!r||r.startsWith("/")||r.includes("\\")||r.split("/").includes(".."))throw new Error(`invalid affected document path: ${r}`);if(new Set(n).size!==n.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return n}function mo(e,t,n){let r=[e,t,n].map(a=>uo(a));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function _t(e,t,n=!0){let r=new Ur(e,{readonly:!0,fileMustExist:!0});try{wt(r,"main",t),n&&ho(r,"main",t)}finally{r.close()}}function wt(e,t,n){for(let[r,a]of Object.entries(po)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:d,pk:l})=>({name:s,type:c.toUpperCase(),notnull:d,pk:l}));if(JSON.stringify(o)!==JSON.stringify(a))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,a]of Object.entries(go)){let i=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(i?.tbl_name!==a.table||JSON.stringify(o)!==JSON.stringify(a.columns))throw new Error(`${n} schema changed for index ${r}`)}Br(e,t,"documents",["relative_path"],n),Br(e,t,"global_symbols",["symbol"],n)}function Br(e,t,n,r,a){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(d=>d.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${a} lost the unique ${n}(${r.join(", ")}) constraint`)}function ho(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function yo(e,t,n){if(e.pragma("foreign_keys",{simple:!0})!==1)throw new Error(`${t} lost foreign-key enforcement`);if(!n)return;let r=e.prepare("PRAGMA main.quick_check").pluck().get();if(r!=="ok")throw new Error(`${t} failed quick_check: ${String(r)}`)}function So(e,t,n){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID"),e.exec("CREATE TEMP TABLE incremental_deleted_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let r=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)"),a=e.prepare("INSERT INTO temp.incremental_deleted_paths(relative_path) VALUES (?)");e.transaction(o=>{for(let s of o)r.run(s);for(let s of n)a.run(s)})(t)}function bo(e,t,n){let r=W(e,"SELECT COUNT(*) AS value FROM incremental.documents"),a=W(e,`SELECT COUNT(*) AS value
|
|
59
59
|
FROM main.documents d
|
|
60
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
61
|
+
FROM temp.incremental_affected_paths p
|
|
62
|
+
LEFT JOIN incremental.documents d ON d.relative_path = p.relative_path
|
|
63
|
+
LEFT JOIN temp.incremental_deleted_paths deleted ON deleted.relative_path = p.relative_path
|
|
64
|
+
WHERE d.id IS NULL AND deleted.relative_path IS NULL
|
|
65
|
+
LIMIT 1`).pluck().get(),o=e.prepare(`SELECT d.relative_path
|
|
65
66
|
FROM incremental.documents d
|
|
66
67
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
67
68
|
WHERE p.relative_path IS NULL
|
|
68
|
-
LIMIT 1`).pluck().get()
|
|
69
|
+
LIMIT 1`).pluck().get(),s=e.prepare(`SELECT d.relative_path
|
|
70
|
+
FROM incremental.documents d
|
|
71
|
+
JOIN temp.incremental_deleted_paths deleted ON deleted.relative_path = d.relative_path
|
|
72
|
+
LIMIT 1`).pluck().get();if(r!==t-n||i!==void 0||o!==void 0||s!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set");return{priorAffectedCount:a}}function Po(e){e.exec(`
|
|
69
73
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
75
|
+
SELECT g.symbol
|
|
76
|
+
FROM temp.incremental_affected_paths p
|
|
77
|
+
CROSS JOIN main.documents d ON d.relative_path = p.relative_path
|
|
78
|
+
CROSS JOIN main.defn_enclosing_ranges r ON r.document_id = d.id
|
|
79
|
+
CROSS JOIN main.global_symbols g ON g.id = r.symbol_id;
|
|
80
|
+
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
81
|
+
SELECT g.symbol
|
|
82
|
+
FROM temp.incremental_affected_paths p
|
|
83
|
+
CROSS JOIN main.documents d ON d.relative_path = p.relative_path
|
|
84
|
+
CROSS JOIN main.chunks c ON c.document_id = d.id
|
|
85
|
+
CROSS JOIN main.mentions m ON m.chunk_id = c.id
|
|
86
|
+
CROSS JOIN main.global_symbols g ON g.id = m.symbol_id
|
|
87
|
+
WHERE m.role = 1;
|
|
84
88
|
|
|
85
89
|
CREATE TEMP TABLE incremental_new_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
|
|
91
|
+
SELECT g.symbol
|
|
88
92
|
FROM incremental.defn_enclosing_ranges r
|
|
89
93
|
JOIN incremental.global_symbols g ON g.id = r.symbol_id;
|
|
90
94
|
INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
|
|
91
95
|
SELECT g.symbol
|
|
92
96
|
FROM incremental.mentions m
|
|
93
97
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
WHERE m.role = 1;
|
|
99
|
+
|
|
100
|
+
CREATE TEMP TABLE incremental_touched_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
101
|
+
INSERT OR IGNORE INTO temp.incremental_touched_symbols(symbol)
|
|
102
|
+
SELECT symbol FROM temp.incremental_old_defined_symbols;
|
|
103
|
+
INSERT OR IGNORE INTO temp.incremental_touched_symbols(symbol)
|
|
104
|
+
SELECT g.symbol
|
|
105
|
+
FROM temp.incremental_affected_paths p
|
|
106
|
+
CROSS JOIN main.documents d ON d.relative_path = p.relative_path
|
|
107
|
+
CROSS JOIN main.chunks c ON c.document_id = d.id
|
|
108
|
+
CROSS JOIN main.mentions m ON m.chunk_id = c.id
|
|
109
|
+
CROSS JOIN main.global_symbols g ON g.id = m.symbol_id;
|
|
110
|
+
INSERT OR IGNORE INTO temp.incremental_touched_symbols(symbol)
|
|
111
|
+
SELECT symbol FROM incremental.global_symbols;
|
|
112
|
+
`)}function Ro(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
96
113
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
97
114
|
UNION
|
|
98
115
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
99
|
-
)
|
|
100
|
-
|
|
116
|
+
)
|
|
117
|
+
SELECT c.symbol
|
|
118
|
+
FROM changed_symbols c
|
|
119
|
+
CROSS JOIN main.global_symbols g ON g.symbol = c.symbol
|
|
120
|
+
WHERE EXISTS (
|
|
121
|
+
SELECT 1
|
|
101
122
|
FROM main.defn_enclosing_ranges r
|
|
102
123
|
JOIN main.documents d ON d.id = r.document_id
|
|
103
|
-
JOIN main.global_symbols g ON g.id = r.symbol_id
|
|
104
124
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
105
|
-
WHERE p.relative_path IS NULL
|
|
106
|
-
|
|
107
|
-
SELECT
|
|
125
|
+
WHERE r.symbol_id = g.id AND p.relative_path IS NULL
|
|
126
|
+
) OR EXISTS (
|
|
127
|
+
SELECT 1
|
|
108
128
|
FROM main.mentions m
|
|
109
|
-
JOIN main.chunks
|
|
110
|
-
JOIN main.documents d ON d.id =
|
|
111
|
-
JOIN main.global_symbols g ON g.id = m.symbol_id
|
|
129
|
+
JOIN main.chunks chunk ON chunk.id = m.chunk_id
|
|
130
|
+
JOIN main.documents d ON d.id = chunk.document_id
|
|
112
131
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
113
|
-
WHERE m.role = 1 AND p.relative_path IS NULL
|
|
132
|
+
WHERE m.symbol_id = g.id AND m.role = 1 AND p.relative_path IS NULL
|
|
114
133
|
)
|
|
115
|
-
|
|
116
|
-
FROM unaffected_definitions u
|
|
117
|
-
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
118
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Va(e){e.exec(`
|
|
134
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function xo(e){e.exec(`
|
|
119
135
|
DELETE FROM main.mentions
|
|
120
136
|
WHERE chunk_id IN (
|
|
121
137
|
SELECT c.id
|
|
@@ -137,7 +153,7 @@ import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./c
|
|
|
137
153
|
);
|
|
138
154
|
DELETE FROM main.documents
|
|
139
155
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
140
|
-
`)}function
|
|
156
|
+
`)}function Eo(e){e.exec(`
|
|
141
157
|
UPDATE main.global_symbols
|
|
142
158
|
SET display_name = NULL,
|
|
143
159
|
kind = NULL,
|
|
@@ -179,30 +195,31 @@ import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./c
|
|
|
179
195
|
WHERE source.symbol = main.global_symbols.symbol
|
|
180
196
|
)
|
|
181
197
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
182
|
-
`)}function
|
|
198
|
+
`)}function Io(e){let t=W(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=W(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=W(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
|
|
183
199
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
184
200
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
185
201
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
186
202
|
FROM incremental.chunks`).run(n,t),e.prepare(`INSERT INTO main.mentions(chunk_id, symbol_id, role)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
203
|
+
SELECT m.chunk_id + ?, target.id, m.role
|
|
204
|
+
FROM incremental.mentions m
|
|
205
|
+
CROSS JOIN incremental.global_symbols source ON source.id = m.symbol_id
|
|
206
|
+
CROSS JOIN main.global_symbols target ON target.symbol = source.symbol`).run(n),e.prepare(`INSERT INTO main.defn_enclosing_ranges(
|
|
191
207
|
id, document_id, symbol_id, start_line, start_char, end_line, end_char
|
|
192
208
|
)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
209
|
+
SELECT r.id + ?, r.document_id + ?, target.id,
|
|
210
|
+
r.start_line, r.start_char, r.end_line, r.end_char
|
|
211
|
+
FROM incremental.defn_enclosing_ranges r
|
|
212
|
+
CROSS JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
213
|
+
CROSS JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function vo(e,t){let n=t?"symbol IN (SELECT symbol FROM temp.incremental_touched_symbols) AND":"";e.exec(`
|
|
198
214
|
DELETE FROM main.global_symbols
|
|
199
|
-
WHERE
|
|
215
|
+
WHERE ${n}
|
|
216
|
+
NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
200
217
|
AND NOT EXISTS (
|
|
201
218
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
202
219
|
);
|
|
203
|
-
`)}function
|
|
220
|
+
`)}function _o(e,t,n,r){let a=W(e,"SELECT COUNT(*) AS value FROM main.documents"),i=W(e,`SELECT COUNT(*) AS value
|
|
204
221
|
FROM main.documents d
|
|
205
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),o=n-r+t;if(a!==o||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly")
|
|
222
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),o=n-r+t;if(a!==o||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly")}function To(e){let t=Ct(e,"main",!0),n=Ct(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ct(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",a=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
|
|
206
223
|
FROM ${t}.documents d
|
|
207
224
|
${r}
|
|
208
225
|
ORDER BY d.relative_path`).all(),i=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
@@ -224,17 +241,59 @@ import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./c
|
|
|
224
241
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
225
242
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
226
243
|
${r}
|
|
227
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[
|
|
228
|
-
`);
|
|
229
|
-
`;)n+=1;continue}if(i==="/"&&e[n+1]==="*"){for(n+=2;n<a&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=i,n+=1}return t}function ct(e){try{let t=ie(e,{maxBytes:vt,inputKind:"TypeScript project manifest"}),n=JSON.parse(yi(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as ji}from"crypto";import{existsSync as lt,writeFileSync as xr}from"fs";import{join as Ti}from"path";import{randomUUID as Si}from"crypto";import{existsSync as bi}from"fs";var Pi=12e4,xi=5,te=class extends Error{name="TypeScriptIndexMemoryPressureError"},Ie=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;localHost=null;constructor(t,n={}){this.projectRoot=Lt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??wi(),this.runtime=n.runtime??_i,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally}request(t){let n=On(this.cacheDir),r=Fn(this.cacheDir),a=Xe(n.statePath);if(!hr(a,this.projectRoot,this.runtime))return this.requestLocally(t);let i=this.runtime.now(),o=i+this.timeoutMs,s=(this.runtime.monotonicNow??P)()+this.timeoutMs,c=_n("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),l=jn(c),d=Tn(r,{mailboxVersion:wn,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:i,deadlineAtMs:o,protocolVersion:Se,id:l,baseGeneration:this.baseGeneration,request:t},{nowMs:i,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=s;){if(bi(d.responsePath))return Ri(ie(d.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),l,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Xe(n.statePath);if(!hr(u,this.projectRoot,this.runtime))return this.requestLocally(t);this.runtime.sleep(xi)}return this.requestLocally(t)}requestLocally(t){return this.emitLocally?dt(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new An({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),dt(yr(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function hr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null,a=e?Date.parse(e.heartbeatAt):Number.NaN;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Se&&n.isProcessAlive(e.pid)&&Number.isFinite(a)&&n.now()-a<=kn&&(!e.processIdentity||r!=null&&G(e.processIdentity,r))}function Ri(e,t,n,r,a,i){let o=JSON.parse(e);if(o.protocolVersion!==Se||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0){let s=typeof o.error=="string"?o.error:"TypeScript index service request failed.";throw vi(s)?new te(s):new Error(s)}return dt(yr(o.response,a),a,i)}function vi(e){let t=e.toLowerCase();return t.includes("out of memory")||t.includes("memory limit")||t.includes("allocation failed")||t.includes("err_worker_out_of_memory")}function dt(e,t,n){if(e.producerIdentity!==t)throw new Error("TypeScript index service wrote an invalid response.");let r=[...new Set(n)].sort(),a=e.fragments.map(i=>i.relativePath).sort();if(JSON.stringify(a)!==JSON.stringify(r))throw new Error("TypeScript index service omitted or added an affected document.");return e}function yr(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,a=n.fragments.map(i=>{if(!i||typeof i.relativePath!="string"||i.bytesBase64!==null&&typeof i.bytesBase64!="string"||typeof i.occurrences!="number"||!Number.isInteger(i.occurrences)||i.occurrences<0||typeof i.symbols!="number"||!Number.isInteger(i.symbols)||i.symbols<0||!Array.isArray(i.referenceFragments)||!i.referenceFragments.every(Ii)||r.has(i.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(i.relativePath);let o=i.bytesBase64===null?null:Ei(i.bytesBase64);return{relativePath:i.relativePath,bytes:o,occurrences:i.occurrences,symbols:i.symbols,referenceFragments:i.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:a}}function Ii(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function Ei(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function wi(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Pi}var _i={now:Date.now,monotonicNow:P,randomId:Si,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:H,readProcessIdentity:L};function Fi(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=de(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let r=n.changes.filter(y=>y.inputKind==="source"&&We(y.path));if(r.some(y=>y.kind!=="modified"&&y.kind!=="added"))return{eligible:!1,reason:"TypeScript project membership changed"};if(r.length===0)return{eligible:!1,reason:"change is not a modified TypeScript source file"};let a=r.filter(y=>y.kind==="added").map(y=>y.path),i=r.filter(y=>y.kind==="modified"),o={...n,changes:r},s=Di(i,a,e.graph,e.projectFiles);if(!s.eligible)return s;let c=s.plan,l=ki(c,t,e.graph);if(!l)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let d=Sr(e.currentSnapshot,e.projectFiles,e.producerIdentity),u=Sr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(d!==u)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let p=Pr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!p)return{eligible:!1,reason:"prior document identity unavailable"};let m=Pr(e.currentSnapshot,[...new Set([...e.projectFiles,...a])],e.graph,e.producerIdentity,c.affectedFiles);if(!m)return{eligible:!1,reason:"next document identity unavailable"};let g=l.length===1?l[0]:void 0;return{eligible:!0,manifest:o,plan:c,projectIdentity:d,previousFragmentGeneration:br(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:br(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:p,nextDocumentIdentities:m,projects:l,...g?{tsconfigPath:g.tsconfigPath,projectArgument:g.projectArgument}:{}}}function Di(e,t,n,r){if(e.length===0)return t.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...t].sort(),affectedFiles:[...t].sort(),reasons:[]}};let a=be({version:1,changes:[...e],projectIdentityChanged:!1,uncertainty:[]},n,r);return a.mode!=="closure"||a.affectedFiles.length===0?{eligible:!1,reason:a.reasons.length>0?`affected set widened: ${a.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...a.changedFiles,...t])].sort(),affectedFiles:[...new Set([...a.affectedFiles,...t])].sort(),reasons:[]}}}function ki(e,t,n){let r=new Map;for(let i of e.affectedFiles){let o=Oi(i,t);if(!o)return null;let s=r.get(o)??[];s.push(i),r.set(o,s)}let a=[];for(let[i,o]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(o),c=e.changedFiles.filter(l=>s.has(l)||o.some(d=>Ai(d,l,n)));if(c.length===0)return null;a.push({projectArgument:i,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...o].sort()})}return a}function Oi(e,t){let n=t.filter(i=>i==="."||e===i||e.startsWith(`${i}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((i,o)=>Ee(o)-Ee(i)||i.localeCompare(o)),a=r[0];return r[1]&&Ee(r[1])===Ee(a)?null:a}function Ee(e){return e==="."?0:e.split("/").filter(Boolean).length}function Ai(e,t,n){let r=new Set,a=[e];for(let i=0;i<a.length;i+=1){let o=a[i];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||a.push(s)}}}return!1}function Rr(e){let t=P();try{if(!lt(e.previousDbPath)||!lt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ze();if(!r.available)throw new Error(r.reason);let a=performance.now()-n;n=performance.now();let i=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s,c;try{o=ge(i,{includeIgnored:!1}).filter(We).sort(),c=Yt(i),s=c.graph}finally{i.close()}let l=performance.now()-n,d=Fi({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?z(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:lt(Ti(e.projectRoot,"tsconfig.json"))});if(!d.eligible)throw new Error(d.reason);let u=Dn(e.previousDbPath);if(!u)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Ie({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:u}),m=d.projects.map(f=>p.request({kind:"emit-documents",tsconfigPath:f.tsconfigPath,projectArgument:f.projectArgument,projectIdentity:d.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:f.modifiedFiles,affectedFiles:f.affectedFiles})),g=m.flatMap(f=>f.fragments),y=performance.now()-n;n=performance.now();let O=gn(g),F=performance.now()-n;n=performance.now(),mn({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,nextGenerationIdentity:d.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g});let _=performance.now()-n;n=performance.now(),xr(e.candidateAffectedScipPath,O);let b=performance.now()-n,x={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!1,durationMs:P()-t,cold:m.some(f=>f.cold),changedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:d.previousFragmentGeneration,nextFragmentGeneration:d.nextFragmentGeneration,manifest:d.manifest,plan:d.plan,projectFileCount:o.length,dependencyGraphSnapshot:c,referenceFragmentsByFile:new Map(g.map(f=>[f.relativePath,f.referenceFragments])),timings:{runtimeMs:a,graphMs:l,requestMs:y,serviceMs:m.reduce((f,R)=>f+R.durationMs,0),assemblyMs:F,fragmentStoreMs:_,writeMs:b}};return e.onStatus(`Incremental TypeScript index emitted ${x.affectedFiles.length} affected document(s) across ${d.projects.length} project(s) in ${(x.durationMs/1e3).toFixed(3)}s (${x.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${a.toFixed(0)}ms, graph ${l.toFixed(0)}ms, request ${y.toFixed(0)}ms, assembly ${F.toFixed(0)}ms, fragments ${_.toFixed(0)}ms, write ${b.toFixed(0)}ms).`),x}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof te)throw e.onStatus(`Incremental TypeScript index stopped after memory pressure survived one cold Worker retry: ${r}. Preserving the accepted index instead of starting a memory-heavier whole-project rebuild.`),n;return e.onStatus(`Incremental TypeScript index unavailable: ${r}. Falling back to the whole-project indexer.`),null}}function ut(e){let t=ze();if(!t.available)throw new Error(t.reason);let n=hn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:ae(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:It}),packageVersion:t.packageVersion});xr(e.candidateShardPath,n)}function Sr(e,t,n){let r=e.files.filter(a=>{let i=_t(a.path,e.languages);return i==="config"||i==="ambient"}).map(a=>({path:a.path,size:a.size,hash:a.hash})).sort((a,i)=>a.path.localeCompare(i.path));return pt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function br(e,t){return pt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Pr(e,t,n,r,a){let i=new Set(e.files.map(c=>c.path)),o=Zt({projectFiles:t.filter(c=>i.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of a){let l=o.identityFor(c,"typescript-scip-document-v1");if(l.key){s.set(c,l.key);continue}if(i.has(c))return null;s.set(c,pt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function pt(e){return ji("sha256").update(e).digest("hex")}import{closeSync as Mi,existsSync as we,fstatSync as Li,lstatSync as Ci,openSync as Ni,renameSync as ft,rmSync as _e,statSync as $i,writeSync as Gi}from"fs";import{cpus as Ui}from"os";import{join as mt}from"path";function Bi(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=mt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),a;try{a=Ni(n,"wx",384)}catch(i){if(i.code==="EEXIST")return null;throw i}try{Gi(a,r);let i=Li(a);return{path:n,content:r,device:i.dev,inode:i.ino}}finally{Mi(a)}}function Wi(e){if(e)try{let t=Ci(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=ae(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;_e(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function qi(e,t,n){if(!e.defaultOutputPath)return;let r=mt(t,e.defaultOutputPath);n!==r&&we(r)&&ft(r,n)}function Ji(e,t,n){if(!e.defaultOutputPath)return null;let r=mt(t,e.defaultOutputPath);if(r===n)return null;let a=`${n}.default-output-backup`;return _e(a,{force:!0}),we(r)?(ft(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function Hi(e){e&&(_e(e.defaultOutputPath,{force:!0}),e.backupPath&&we(e.backupPath)&&ft(e.backupPath,e.defaultOutputPath))}function zi(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Ui().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Ir(e,t,n,r,a){j(a,"Reindex cancelled by its owner.");let i=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath),s=[],c=zi(o.length,r),l=await Mn(o,c,d=>gt(d,t,n,a));if(c>1){let d=new Map;for(let u of l.filter(p=>p.result.skipped&&p.retryable)){let p=o.find(m=>m.id===u.result.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),j(a,"Reindex cancelled by its owner."),d.set(p.id,(await gt(p,t,n,a)).result))}s.push(...l.map(({result:u})=>d.get(u.id)??u))}else s.push(...l.map(({result:d})=>d));for(let d of i)j(a,"Reindex cancelled by its owner."),s.push((await gt(d,t,n,a)).result);return s.sort((d,u)=>e.findIndex(p=>p.id===d.id)-e.findIndex(p=>p.id===u.id))}async function gt(e,t,n,r){j(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),_e(e.scipPath,{force:!0});let a=Ji(e.config,t,e.scipPath),i=Bi(e,t),o=[e.binary,...e.args].join(" "),s=P();try{e.trustedProjectTool&&Ht(t,e.trustedProjectTool);let l=At(e.binary,e.args),d=await ce({command:l.binary,args:l.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Xi(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(d.status!==0){let u=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${u?`:
|
|
230
|
-
|
|
231
|
-
`)[0]}`,p=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-s,command:o,skipped:{language:e.language,reason:p}},retryable:Qi(l)}}finally{Hi(a),Wi(i)}if(!we(e.scipPath)){let l=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?l:`${e.label}: ${l}`;return n(`Skipping ${e.label}: ${l}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-s,command:o,skipped:{language:e.language,reason:d}},retryable:!1}}let c;try{c=$i(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-s,command:o,outputBytes:c},retryable:!1}}function Xi(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):Et.indexer}function Qi(e){return e instanceof wt?e.kind==="spawn"&&vr(e.cause):vr(e)}function vr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as wr}from"child_process";import{homedir as Er,platform as Vi}from"os";import{delimiter as Yi,join as je}from"path";function _r(e,t){let n=e.installMethods,r=pe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let a of n){if(!a.identity||!a.destination){t(`Refusing ${a.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!Ot(a.prerequisite))continue;let i=Ki(a);t(`Installing immutable ${a.identity} via ${a.label} into ${i}; expected executable: ${r}.`);try{wr(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Vi()==="win32"});let o=Z(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${a.identity} via ${a.label}${s}; resolved executable: ${o}.`),!0}t(`${a.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${a.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Ki(e){if(e.binary==="npm")return ht("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=ht("go",["env","GOBIN"]);if(t)return t;let n=ht("go",["env","GOPATH"]);if(n)return je(n.split(Yi)[0],"bin")}return e.binary==="dotnet"?je(process.env.DOTNET_CLI_HOME??Er(),".dotnet","tools"):e.binary==="dart"?je(process.env.PUB_CACHE??je(Er(),".pub-cache"),"bin"):e.destination}function ht(e,t){try{return wr(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Nr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,a=e.skipAutoInstall===!0||e.installMissing!==!0,i=oo(e),o=Date.now(),s=P();Fe(h(i.outputScip),{recursive:!0}),Fe(h(i.outputDb),{recursive:!0});let c=e.languages??cn(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let l=ke(i.metaPath),d=D("reindex.fingerprint",()=>Bt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},l,e.changeJournal,Be(i.outputDb)),{languages:c.length}),u=d.fingerprint,p=d.mode==="delta"?e.changeJournal?.entries.filter(f=>f.kind!=="add").length??0:0,m=Math.max(0,(l?.files.length??0)-p);r(d.mode==="delta"?`Project fingerprint revalidated ${d.changedPaths.length} changed path(s), reused ${m} accepted file fingerprint(s), and accepted ${u.files.length} input(s)`:`Project fingerprint used full scan: ${d.reason}`);let g,y;if(e.skipIfUnchanged!==!1&&!Pn(t,i.outputDb)&&jr(i.outputScip)===jr(E(h(i.outputDb),"index.scip"))){let f=ue(t);if(g=f?.clean?he(f,u):void 0,f&&!f.clean&&!io(i)){let R=xn(f,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(R)try{ye({snapshot:R.snapshot,manifest:R.manifest,targetCacheDir:h(i.outputDb),targetProjectRoot:t,persistLease:!1}),En(R.snapshot,h(i.outputDb)),r(`Forked shared baseline ${R.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(v){r(`Shared baseline fork failed; continuing locally: ${q(v)}`)}}else if(g){let R=He(g);if(R){if(!ao(i,u))try{ye({snapshot:g,manifest:R,targetCacheDir:h(i.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${g.generationId.slice(0,12)}`)}catch(v){r(`Shared generation attach failed; continuing locally: ${q(v)}`)}}else{let v=await vn(g);if(v.kind==="owner")y=v.release;else if(v.kind==="generation-ready"){let $=He(g);if($)try{ye({snapshot:g,manifest:$,targetCacheDir:h(i.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${g.generationId.slice(0,12)} after waiting`)}catch(M){r(`Shared generation attach failed after waiting; continuing locally: ${q(M)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let F=Gt(E(h(i.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!F)throw y?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${h(i.outputDb)}. A watch daemon or another reindex may hold it. Run "scip-query watch --stop", retry the reindex, then restart with "scip-query watch --daemon".`);let _;try{_=await U("reindex.lock",()=>Mo(E(h(i.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(f){throw F.release(),y?.(),f}let b=null,x=$n();try{d.mode==="delta"&&Be(i.outputDb)!==e.changeJournal?.baseGeneration&&(u=Ue(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),d={mode:"full",fingerprint:u,reason:"accepted-generation-changed-before-lock"},g=void 0,y?.(),y=void 0,r("Project fingerprint used full scan: accepted-generation-changed-before-lock")),bn(i.outputDb,i.outputScip,i.metaPath);let f=uo(h(i.outputDb));f.removed>0&&r(`Removed ${f.removed} abandoned reindex workspace(s)`);for(let re of f.errors)r(`Could not remove abandoned reindex workspace: ${re}`);let R=null,v=D("reindex.reuse-check",()=>(R=so({opts:e,paths:i,languages:c,fingerprint:u,start:o,monotonicStart:s,onStatus:r}),R),()=>({languages:c.length,reused:R!==null}));if(v){Tr({snapshot:g,paths:i,projectRoot:t,fingerprint:u,onStatus:r});let re=qe(i.outputDb,v);return re.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${re.reason}`),Ne(t,h(i.outputDb)),v}await U("reindex.scip-cli-ready",()=>_o(a,r));let $=lo(i);b=$.runDir;let M,S=await U("reindex.fresh",async()=>(M=await po({opts:e,languages:c,projectRoot:t,paths:i,tempPaths:$,fingerprint:u,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:a,onStatus:r,writeTelemetry:x}),M),()=>({languages:c.length,reused:M?.reused,skipped:M?.skipped.length}));Tr({snapshot:g,paths:i,projectRoot:t,fingerprint:u,onStatus:r});let A=qe(i.outputDb,S);return A.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${A.reason}`),Ne(t,h(i.outputDb)),S}catch(f){let R=Ae({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:f instanceof Error?f.message:String(f)});Zr(i.metaPath,R);let v=pn(i.outputDb,R);throw v.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${v.reason}`),f}finally{b&&Q(b,{recursive:!0,force:!0}),_(),F.release(),y?.()}}function Tr(e){if(e.snapshot)try{let t=ue(e.projectRoot),n=t?he(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=Rn({snapshot:e.snapshot,sourceCacheDir:h(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let a=ue(e.projectRoot);return(a?he(a,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});In(e.snapshot,h(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${q(t)}`)}}function ao(e,t){if(!w(e.outputScip)||!w(e.outputDb)||!Kr(e.metaPath,t))return!1;let n=C(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function io(e){if(!w(e.outputScip)||!w(e.outputDb)||!J(e.metaPath))return!1;let t=C(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function q(e){return e instanceof Error?e.message:String(e)}function bt(e,t,n,r,a,i){try{ee(Gn({indexPath:n,reuseExisting:a,affectedFiles:i}),{projectRoot:e,dbPath:t,onStatus:r})}catch(o){r(`Runtime-boundary extraction unavailable: ${o instanceof Error?o.message:String(o)}.`)}}function oo(e){let t=e.outputScip??E(e.projectRoot,"index.scip"),n=e.outputDb??E(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:E(h(n),"meta.json")}}function so(e){let t=C(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!w(e.paths.outputScip)||!w(e.paths.outputDb)||!Kr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;let n=me(e.paths.outputDb,e.fingerprint,e.languages);if(n.state!=="complete")return e.onStatus(Pt("Accepted SQLite index",n)),null;ee(fe(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),bt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),C(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(Je(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let r=P()-e.monotonicStart,a=Ae({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Zr(e.paths.metaPath,a),e.onStatus(`Index unchanged; reused existing SQLite index in ${(r/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:r,reused:!0,skipped:[],lastRefresh:a,shards:co(e.paths,e.languages,e.opts,e.fingerprint)}}function co(e,t,n,r){let a=Vr(r,t,n);return t.map(i=>({id:i,language:i,reused:!0,strategy:"reused",fingerprint:ne(a[i]),outputBytes:V(xt(e.outputDb,i)),durationMs:0}))}function lo(e){let t=eo(E(h(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:E(t,Te(e.outputScip)),tempOutputDb:E(t,Te(e.outputDb)),tempMetaPath:E(t,Te(e.metaPath))}}function uo(e){let t=[],n;try{n=Lr(e,{withFileTypes:!0})}catch(a){return{removed:0,errors:[q(a)]}}let r=0;for(let a of n)if(!(!a.name.startsWith("reindex-")||!a.isDirectory()))try{Q(E(e,a.name),{recursive:!0,force:!0}),r+=1}catch(i){t.push(`${a.name}: ${q(i)}`)}return{removed:r,errors:t}}async function po(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await U("reindex.language-indexers",async()=>(n=await fo(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:a,skippedLanguages:i,reusedLanguages:o,languageFingerprints:s,shards:c,typescriptProjectShardContext:l,incrementalTypeScript:d}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),go({run:e,indexedOutputs:a,skippedLanguages:i,reusedLanguages:o})){let m=D("reindex.publish",()=>vo(e,a,i,o,s,l),{mode:"metadata-only",languages:a.length,reused:o.length}),g=m.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:a.map(y=>y.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:i,lastRefresh:m,shards:c,writeTelemetry:e.writeTelemetry}}let u=await U("reindex.publish",()=>Ro(e,t,a,i,o,s,l,d),{mode:d?"incremental-or-fallback":"full",languages:a.length,reused:o.length,skipped:i.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:a.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:i,lastRefresh:u,shards:c,writeTelemetry:e.writeTelemetry}}function go(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!w(e.run.paths.outputScip)||!w(e.run.paths.outputDb))return!1;let t=C(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(a=>a.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(a=>n.has(a)&&r.has(a))}async function fo(e,t){let n=bo({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,projectFingerprint:e.fingerprint}),r=[],a=new Set;for(let[S,A]of n)A.reused&&(r.push({language:S,scipPath:A.scipPath}),a.add(S));for(let S of a)e.onStatus(`Reusing cached ${S} SCIP shard (language inputs unchanged).`);let i=n.get("typescript"),o=C(e.paths.outputDb,e.paths.metaPath),s=J(e.paths.metaPath),c=o.state==="legacy"||o.state==="current",l=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),d,u=i&&!i.reused&&c?Rr({projectRoot:e.projectRoot,cacheDir:h(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:i.scipPath,candidateShardPath:Y(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Y(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:ke(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus,onUnavailable:S=>{d=S}}):null,p=new Set(u?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1)for(let S of e.languages){if(a.has(S)||p.has(S))continue;let A=n.get(S);A&&w(A.scipPath)&&(r.push({language:S,scipPath:A.scipPath}),a.add(S),e.onStatus(`Skipping expensive ${S} full rebuild because the watch full-rebuild budget is exhausted.`))}let m=u||a.has("typescript")?void 0:mo(e,n),{preparedRuns:g,skippedLanguages:y,languageOutputScipPaths:O}=jo({languages:e.languages.filter(S=>!a.has(S)&&!p.has(S)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:m?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),F=m?g.filter(S=>S.language!=="typescript"||m.missedProjectIds.has(S.id)):g,_=await Ir(F,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(Dt())for(let S of _)kt({type:"span",name:`reindex.language-indexer.${S.id}`,durationMs:Math.round(S.durationMs),ok:!S.skipped,language:S.language,indexerCommand:S.command,outputBytes:S.outputBytes,measurement:"indexer-run-result"});let b=[];if(m){yo(e.paths.outputDb,_,e.writeTelemetry);let S=O.typescript??e.tempPaths.tempOutputScip;b=So({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:S,reusedProjects:m.reusedProjects,writeTelemetry:e.writeTelemetry})}let x=[..._,...b],{indexedOutputs:f}=Fo(x,y),R=u?[{language:"typescript",scipPath:u.scipPath}]:[],v=[...r,...R,...f];Do(v,y,e.languages,e.opts.allowPartial,e.onStatus);let $=u?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:u.scipPath,outputScipPath:u.scipPath,durationMs:u.durationMs,command:"watch-service:typescript-index",outputBytes:V(u.scipPath)??void 0,producedOutputBytes:V(u.affectedScipPath)??void 0}]:[],M=Po(n,[..._,...$],m?{outputDb:e.paths.outputDb,classification:m.classification}:void 0,d);return{indexedOutputs:v,skippedLanguages:y,reusedLanguages:[...a],languageFingerprints:xo(n,e.languages),shards:M,typescriptProjectShardContext:m?{projects:m.allProjects,fingerprints:m.fingerprints}:void 0,incrementalTypeScript:u??void 0}}function mo(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=z(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let a=pr(e.projectRoot,r),i=dr(n.fingerprint.files,r),o=lr(r,a),s=ur(r,i,o),c=J(e.paths.metaPath),d=ho(c,s,g=>w(Oe(e.paths.outputDb,g))),u=[...d.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),m=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:d,reusedProjects:u,missedProjectIds:m}}function ho(e,t,n){let r=new Map;for(let a of Object.keys(t)){let i=t[a];if(!e){r.set(a,{reused:!1,reason:"no reindex metadata found",fingerprint:i});continue}let o=e.version===K&&Le(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[a]:void 0;if(!o){r.set(a,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:i});continue}if(!n(a)){r.set(a,{reused:!1,reason:"cached shard file missing on disk",fingerprint:i});continue}if(T(o)!==T(i)){r.set(a,{reused:!1,reason:"project inputs changed since last index",fingerprint:i});continue}r.set(a,{reused:!0,fingerprint:i})}return r}function yo(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let a=r.id.slice(11),i=Oe(e,a);Fe(h(i),{recursive:!0}),W(n,B(r.scipPath,i))}}function So(e){return e.reusedProjects.map((t,n)=>{let r=Oe(e.outputDb,t),a=Y(e.tempOutputScip,"typescript-project-cached",n);return W(e.writeTelemetry,B(r,a)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:a,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:V(a)??void 0}})}function bo(e){let t=J(e.paths.metaPath),n=Vr(e.projectFingerprint,e.languages,e),r=t&&w(e.paths.outputDb)?me(e.paths.outputDb,e.projectFingerprint,e.languages):null,a=new Map;for(let i of e.languages){let o=xt(e.paths.outputDb,i),s=n[i];if(!t){a.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:o});continue}if(t.version!==K){a.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!Le(t).languageShardReuse||!t.languageFingerprints){a.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:o});continue}let c=t.languageFingerprints[i];if(!c){a.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:o});continue}if(!w(o)){a.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}if(T(c)!==T(s)){a.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:o});continue}if(r?.state==="unavailable"||r?.state==="incomplete"&&r.affectedLanguages.includes(i)){a.set(i,{reused:!1,reason:Pt("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:o});continue}a.set(i,{reused:!0,fingerprint:s,scipPath:o})}return a}function Po(e,t,n,r){let a=[];for(let[i,o]of e)o.reused&&a.push({id:i,language:i,reused:!0,strategy:"reused",fingerprint:ne(o.fingerprint),outputBytes:V(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,c=s?n.classification.get(s):void 0;a.push({id:i.id,language:i.language,reused:!1,strategy:i.command==="watch-service:typescript-index"?"incremental":"full",missReason:c?.reason??o?.reason??i.skipped?.reason,fallbackReason:i.language==="typescript"?r:void 0,fingerprint:c?ne(c.fingerprint):o?ne(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,producedOutputBytes:i.producedOutputBytes,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&a.push({id:`typescript:${i}`,language:"typescript",reused:!0,strategy:"reused",fingerprint:ne(o.fingerprint),outputBytes:V(Oe(n.outputDb,i)),durationMs:0});return a}function ne(e){return Zi("sha256").update(T(e)).digest("hex").slice(0,16)}function V(e){try{return to(e).size}catch{return null}}function xo(e,t){let n={};for(let r of t){let a=e.get(r);a&&(n[r]=a.fingerprint)}return n}async function Ro(e,t,n,r,a,i,o,s){j(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,l=!1;c&&(l=D("reindex.publish.scip-output",()=>{let b=wo({run:e,indexedOutputs:n,incrementalTypeScript:s});return Fr(e.paths.outputDb,b,e.writeTelemetry),Dr(b,e.tempPaths.tempOutputScip,e.onStatus)}));let d=await U("reindex.publish.sqlite-output",()=>ko({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:l,materializeFullFallback:async()=>{if(j(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return l;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),ut({cacheDir:h(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let b=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:s.candidateScipPath}:x);return Fr(e.paths.outputDb,b,e.writeTelemetry),l=Dr(b,e.tempPaths.tempOutputScip,e.onStatus),l}}));j(e.opts.signal,"Reindex cancelled by its owner."),D("reindex.publish.auxiliary-documents",()=>{ee(fe(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),D("reindex.publish.runtime-boundaries",()=>bt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles));let u=D("reindex.publish.sqlite-layout",()=>rt(e.tempPaths.tempOutputDb));if(u.added.length>0&&e.onStatus(`Added SQLite query indexes: ${u.added.join(", ")}`),u.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${u.removed.join(", ")}`),Br(e,e.tempPaths.tempOutputDb,n.map(b=>b.language)),d.mode==="incremental"&&s){let b=null,x=null;try{b=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let f=en(b,e.fingerprint,s.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${f} affected document(s).`)}catch(f){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${f instanceof Error?f.message:String(f)}.`)}finally{b?.close(),x?.close()}}let p=ke(e.paths.metaPath),m=d.mode==="incremental"&&s?Ao(s,d.changedDocumentPaths):Ze({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),g=Ae({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(b=>b.language),skipped:[...r]}),y=d.mode==="incremental"&&d.scipCompanion==="deferred",{metadata:O,pruneProjects:F}=Gr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:g});O.scipCompanion=y?"deferred":"current",Ur(e),Wr(e.paths.outputDb,F),Rt(e.tempPaths.tempMetaPath,O);let _=Sn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:d.mode==="incremental"&&d.scipCompanion==="deferred",publication:d.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:d.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:d.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:d.patchDurationMs,scipCompanion:d.scipCompanion,...d.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:d.converterDurationMs,scipCompanion:"current",...d.fallbackReason?{fallbackReason:d.fallbackReason}:{}}});if(_.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${_.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),d.mode==="incremental"&&s){let b=null;try{b=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=Kt(b,s.dependencyGraphSnapshot,s.affectedFiles);e.onStatus(x?`Carried the dependency graph forward by replacing ${s.affectedFiles.length} affected document(s).`:"Dependency graph carry-forward was ineligible; the next graph consumer will rebuild it.")}catch(x){e.onStatus(`Dependency graph carry-forward unavailable: ${x instanceof Error?x.message:String(x)}. The next graph consumer will rebuild it.`)}finally{b?.close()}}return yn(h(e.paths.outputDb),d.mode==="incremental"&&d.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),fn(h(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),$r(e.paths.outputDb,m,e.onStatus),g}function vo(e,t,n,r,a,i){let o=ke(e.paths.metaPath),s=null;try{W(e.writeTelemetry,B(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=qn("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}ee(fe(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),bt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=rt(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),Br(e,e.paths.outputDb,t.map(p=>p.language)),s??=Ze({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let l=Ae({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:d,pruneProjects:u}=Gr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:a,typescriptProjectShardContext:i,lastRefresh:l});return Ur(e),Wr(e.paths.outputDb,u),Rt(e.paths.metaPath,d),Je(e.paths.outputDb,e.paths.metaPath),$r(e.paths.outputDb,s,e.onStatus),l}function ke(e){return Tt(J(e)?.fingerprint)}function $r(e,t,n){try{Jn(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Gr(e){let t=Io({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:K,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function Ur(e){j(e.opts.signal,"Reindex cancelled by its owner.");let t=Ue(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath});if(T(t)!==T(e.fingerprint))throw new Error("Project inputs changed during reindex; refusing to publish artifacts built from a different filesystem snapshot.")}function Br(e,t,n){let r=me(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${Pt("Candidate SQLite index",r)} Refusing to publish it.`)}function Pt(e,t){if(t.state==="unavailable")return`${e} document coverage could not be verified (${t.reason}); rebuilding cached language shards.`;let n=t.missingPaths.length>0?` First missing path: ${t.missingPaths[0]}.`:"";return`${e} is missing ${t.missingDocumentCount} fingerprinted source document${t.missingDocumentCount===1?"":"s"}; rebuilding affected language shards.${n}`}function Io(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=J(e.metaPath),n=t?.version===K?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Wr(e,t){let n=Yr(e);if(t===null){Q(n,{recursive:!0,force:!0});return}let r;try{r=Lr(n)}catch{return}for(let a of Eo(r,t))Q(E(n,a),{force:!0})}function Eo(e,t){let n=new Set(t.map(r=>`${st(r)}.scip`));return e.filter(r=>!n.has(r))}function wo(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(o=>o.language==="typescript");if(!t)return[...e.indexedOutputs];let n=C(e.run.paths.outputDb,e.run.paths.metaPath),r=n.state==="current"?n.generation.publication?.typescriptOverlayGeneration:void 0;if(!(n.state==="current"?n.generation.publication?.scipCompanion==="deferred":J(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let i=Y(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),ut({cacheDir:h(e.run.paths.outputDb),generationIdentity:r,baseShardPath:t.scipPath,candidateShardPath:i}),e.indexedOutputs.map(o=>o.language==="typescript"?{language:o.language,scipPath:i}:o)}function Fr(e,t,n){for(let r of t){let a=xt(e,r.language);Fe(h(a),{recursive:!0}),r.scipPath!==a&&W(n,B(r.scipPath,a))}}async function _o(e,t){if(!$e()){if(ro()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
244
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,g]of Object.entries({documents:a,chunks:i,definitions:o,mentions:s}))for(let p of g){let f=JSON.stringify([l,p]),R=c.get(p.relative_path)??[];R.push(f),c.set(p.relative_path,R)}let d=new Map;for(let[l,g]of[...c].sort(([p],[f])=>p.localeCompare(f))){let p=co("sha256");for(let f of g.sort())p.update(f).update(`
|
|
245
|
+
`);d.set(l,p.digest("hex"))}return d}function W(e,t){return e.prepare(t).get().value}import wo from"better-sqlite3";var qe="idx_mentions_definitions",Co=["symbol_id","chunk_id"];function jt(e,t={}){let n=new wo(e),r=[],a=[],i=[];try{return n.transaction(()=>{jo(n,r),We(n,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&Wr(n,"global_symbols").some(c=>c.name!=="idx_global_symbols_symbol"&&c.unique&&c.columns.join("\0")==="symbol")?(n.exec('DROP INDEX "idx_global_symbols_symbol"'),a.push("idx_global_symbols_symbol")):We(n,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let o=We(n,"idx_chunks_doc_id"),s=Wr(n,"chunks").some(c=>c.name!=="idx_chunks_doc_id"&&c.columns.length>1&&c.columns[0]==="document_id");o?.join("\0")==="document_id"&&s?(n.exec('DROP INDEX "idx_chunks_doc_id"'),a.push("idx_chunks_doc_id")):o&&i.push("idx_chunks_doc_id"),t.analyze!==!1&&n.exec("ANALYZE")})(),{added:r,removed:a,retained:i,analyzed:t.analyze!==!1}}catch(o){if(o.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw o}finally{n.close()}}function jo(e,t){let n=Hr(e,qe);if(n){let r=n.columns.join("\0")===Co.join("\0"),a=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!a||n.table!=="mentions")throw new Error(`${qe} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${qe}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(qe)}function Wr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:We(e,n.name)??[]}))}function We(e,t){return Hr(e,t)?.columns??null}function Hr(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(a=>a.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{createHash as Fo}from"crypto";import{existsSync as Ft,readdirSync as Oo}from"fs";import{dirname as Ot,join as He,relative as ko,resolve as kt,sep as Jr}from"path";function zr(e,t){let n=t.includes("."),r={};for(let i of t)r[i]=[];let a=[];for(let i of e){let o=Kr(i.path,t);o?r[o].push(i):n?r["."].push(i):a.push(i)}return{files:r,shared:a}}function Xr(e,t){let n=new Map;for(let a of e){let i=t[a]?.packageName;i&&n.set(i,a)}let r=new Map;for(let a of e)r.set(a,new Set);for(let a of e){let i=t[a],o=r.get(a);if(!i||i.parseFailed){for(let s of e)s!==a&&o.add(s);continue}for(let s of i.dependencyNames){let c=n.get(s);c&&c!==a&&o.add(c)}for(let s of[...i.pathsTargets,...i.referencesPaths]){let c=Kr(s,e);c&&c!==a&&o.add(c)}}return Do(e,r)}function Yr(e,t,n){let r={};for(let a of e){let i=new Map;for(let o of t.files[a]??[])i.set(o.path,o);for(let o of n[a]??[])for(let s of t.files[o]??[])i.set(s.path,s);for(let o of t.shared)i.set(o.path,o);r[a]={files:[...i.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function Dt(e){if(e===".")return"root";let t=Fo("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Qr(e,t){let n=kt(e),r={};for(let a of t)r[a]=Mo(n,a);return r}function Kr(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function Do(e,t){let n={};for(let r of e){let a=new Set,i=[...t.get(r)??[]];for(;i.length>0;){let o=i.pop();if(!(o===r||a.has(o))){a.add(o);for(let s of t.get(o)??[])s!==r&&!a.has(s)&&i.push(s)}}n[r]=[...a].sort((o,s)=>o.localeCompare(s))}return n}function Mo(e,t){let n=t==="."?e:He(e,t),r=No(n),a=Lo(n),i=a?Ao(a,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:i.pathsTargets,referencesPaths:i.referencesPaths,parseFailed:r.failed||i.failed}}function No(e){let t=He(e,"package.json");if(!Ft(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Mt(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,a=new Set;for(let i of["dependencies","devDependencies","peerDependencies"]){let o=n.value[i];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))a.add(s)}return{name:r,dependencyNames:[...a],failed:!1}}function Lo(e){let t=He(e,"tsconfig.json");if(Ft(t))return t;let n;try{n=Oo(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,a)=>r.localeCompare(a)),n.length>0?He(e,n[0]):void 0}function Ao(e,t){let n=Mt(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=$o(n.value,e,t),a=Vr(e,n.value,t,0);return{pathsTargets:a.pathsTargets,referencesPaths:r,failed:a.failed}}function $o(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let a=Ot(t),i=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let c=Zr(s,a,n);c&&i.add(c)}return[...i]}function Vr(e,t,n,r){let a=Go(t);if(a)return{pathsTargets:Bo(a,Ot(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let i=Uo(t.extends,e,n);if(!i)return{pathsTargets:[],failed:!1};let o=Mt(i);return o.ok?Vr(i,o.value,n,r+1):{pathsTargets:[],failed:!0}}function Go(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function Bo(e,t,n){let r=new Set;for(let a of Object.values(e))if(Array.isArray(a))for(let i of a){if(typeof i!="string")continue;let o=Zr(i,t,n);o&&r.add(o)}return[...r]}function Uo(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let a=kt(Ot(t),r);if(a.endsWith(".json")||(a=`${a}.json`),!a.split(Jr).includes("node_modules")&&dt(n,a)&&Ft(a))return a}function Zr(e,t,n){let r=e.replace(/\/?\*+$/,""),a=kt(t,r===""?".":r);if(!dt(n,a))return;let o=ko(n,a).split(Jr).join("/");return o===""?".":o}function qo(e){let t="",n=0,r=!1,a=e.length;for(;n<a;){let i=e[n];if(r){if(t+=i,i==="\\"&&n+1<a){t+=e[n+1],n+=2;continue}i==='"'&&(r=!1),n+=1;continue}if(i==='"'){r=!0,t+=i,n+=1;continue}if(i==="/"&&e[n+1]==="/"){for(n+=2;n<a&&e[n]!==`
|
|
246
|
+
`;)n+=1;continue}if(i==="/"&&e[n+1]==="*"){for(n+=2;n<a&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=i,n+=1}return t}function Mt(e){try{let t=ge(e,{maxBytes:rn,inputKind:"TypeScript project manifest"}),n=JSON.parse(qo(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import Wo from"better-sqlite3";import{zstdCompressSync as Ho}from"zlib";import{setImmediate as ei}from"timers/promises";var H=class extends Error{},Jo=200,Lt=2,ti=1,zo=2,Xo=3,Yo=4,Qo=5,Ko=6,oi=1,si=2,ci=3,Vo=7,Zo=1,es=3,ts=5,ns=6,rs=8,is=1,ni=64,as=[`CREATE TABLE documents (
|
|
247
|
+
id INTEGER PRIMARY KEY,
|
|
248
|
+
language TEXT,
|
|
249
|
+
relative_path TEXT NOT NULL UNIQUE,
|
|
250
|
+
position_encoding TEXT,
|
|
251
|
+
text TEXT
|
|
252
|
+
)`,`CREATE TABLE chunks (
|
|
253
|
+
id INTEGER PRIMARY KEY,
|
|
254
|
+
document_id INTEGER NOT NULL,
|
|
255
|
+
chunk_index INTEGER NOT NULL,
|
|
256
|
+
start_line INTEGER NOT NULL,
|
|
257
|
+
end_line INTEGER NOT NULL,
|
|
258
|
+
occurrences BLOB NOT NULL,
|
|
259
|
+
FOREIGN KEY (document_id) REFERENCES documents(id)
|
|
260
|
+
)`,`CREATE TABLE global_symbols (
|
|
261
|
+
id INTEGER PRIMARY KEY,
|
|
262
|
+
symbol TEXT NOT NULL UNIQUE,
|
|
263
|
+
display_name TEXT,
|
|
264
|
+
kind INTEGER,
|
|
265
|
+
documentation TEXT,
|
|
266
|
+
signature BLOB,
|
|
267
|
+
enclosing_symbol TEXT,
|
|
268
|
+
relationships BLOB
|
|
269
|
+
)`,`CREATE TABLE mentions (
|
|
270
|
+
chunk_id INTEGER NOT NULL,
|
|
271
|
+
symbol_id INTEGER NOT NULL,
|
|
272
|
+
role INTEGER NOT NULL,
|
|
273
|
+
PRIMARY KEY (chunk_id, symbol_id, role),
|
|
274
|
+
FOREIGN KEY (chunk_id) REFERENCES chunks(id),
|
|
275
|
+
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
276
|
+
)`,`CREATE TABLE defn_enclosing_ranges (
|
|
277
|
+
id INTEGER PRIMARY KEY,
|
|
278
|
+
document_id INTEGER NOT NULL,
|
|
279
|
+
symbol_id INTEGER NOT NULL,
|
|
280
|
+
start_line INTEGER NOT NULL,
|
|
281
|
+
start_char INTEGER NOT NULL,
|
|
282
|
+
end_line INTEGER NOT NULL,
|
|
283
|
+
end_char INTEGER NOT NULL,
|
|
284
|
+
FOREIGN KEY (document_id) REFERENCES documents(id),
|
|
285
|
+
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
286
|
+
)`],os=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function Nt(e){return e.startsWith("local ")}function ri(e,t,n,r){let a=t,i=0,o=0;for(;a<n;){let s=e[a];a+=1,o<53&&(i+=(s&127)*2**o),(s&128)===0?(r.push(i),i=0,o=0):o+=7}}function ii(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}function ss(e,t){return e.startLine!==t.startLine?e.startLine-t.startLine:e.startChar!==t.startChar?e.startChar-t.startChar:e.endLine!==t.endLine?e.endLine-t.endLine:e.endChar!==t.endChar?e.endChar-t.endChar:e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0}function cs(e,t,n,r){let a=[],i=[],o="",s=0;for(let d of X(e,n,r))d.fieldNumber===oi?d.wireType===2?ri(e,d.valueStart,d.valueEnd,a):d.wireType===0&&a.push(d.varint):d.fieldNumber===si&&d.wireType===2?o=pe.decode(e.subarray(d.valueStart,d.valueEnd)):d.fieldNumber===ci&&d.wireType===0?s=d.varint:d.fieldNumber===Vo&&(d.wireType===2?ri(e,d.valueStart,d.valueEnd,i):d.wireType===0&&i.push(d.varint));let c=ii(a);return c?{startLine:c[0],startChar:c[1],endLine:c[2],endChar:c[3],symbol:o,roles:s,frameStart:t,frameEnd:r,merged:!1,enclosing:ii(i)}:null}function ds(e,t,n){let r={symbol:"",displayName:null,kind:null,documentation:[],enclosingSymbol:null};for(let a of X(e,t,n))if(a.wireType===2){let i=()=>pe.decode(e.subarray(a.valueStart,a.valueEnd));a.fieldNumber===Zo?r.symbol=i():a.fieldNumber===es?r.documentation.push(i()):a.fieldNumber===ns?r.displayName=i():a.fieldNumber===rs&&(r.enclosingSymbol=i())}else a.fieldNumber===ts&&a.wireType===0&&(r.kind=a.varint);return r}var pe=new TextDecoder;function ls(e,t){if(e.length===0)return[];let n=[],r=Math.min(e.length,t);for(let a=0;a<r&&r<=e.length;){for(;r<=e.length-1&&e[r-1].startLine===e[r].startLine;)r+=1;n.push(e.slice(a,r)),a=r,r=Math.min(e.length,r+t)}return n}function us(e){let t=e.startLine===e.endLine?[e.startLine,e.startChar,e.endChar]:[e.startLine,e.startChar,e.endLine,e.endChar],n=[],r=Buffer.concat(t.map(o=>Y(o)));n.push(De(oi),Y(r.length),r);let a=Buffer.from(e.symbol,"utf8");n.push(De(si),Y(a.length),a),e.roles!==0&&n.push(Y(ci*8),Y(e.roles));let i=Buffer.concat(n);return Buffer.concat([De(Lt),Y(i.length),i])}function ps(e,t){let n=[];for(let r of t)r.merged?n.push(us(r)):n.push(e.subarray(r.frameStart,r.frameEnd));return Ho(Buffer.concat(n))}async function di(e,t,n={}){let r=n.chunkSize??Jo,a={documents:0,duplicateDocumentsSkipped:0,occurrences:0,illegalOccurrencesDropped:0,mergedOccurrences:0,chunks:0,mentions:0,globalSymbols:0,enclosingRanges:0},i=new Wo(t);try{i.pragma("synchronous = normal"),i.pragma("temp_store = memory"),i.pragma("foreign_keys = ON"),i.pragma("journal_mode = WAL");for(let v of as)i.exec(v);let o=i.prepare("INSERT INTO documents (id, language, relative_path, position_encoding, text) VALUES (?, ?, ?, ?, ?)"),s=i.prepare("INSERT INTO chunks (id, document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?, ?)"),c=i.prepare("INSERT INTO defn_enclosing_ranges (document_id, symbol_id, start_line, start_char, end_line, end_char) VALUES (?, ?, ?, ?, ?, ?)"),d=i.prepare("INSERT INTO global_symbols (id, symbol, display_name, kind, documentation, enclosing_symbol) VALUES (?, ?, ?, ?, ?, ?)"),l=i.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)"),g=new Map,p=new Map,f=1,R=1,T=1,j=(v,O,_,h,y)=>{let m=T;return T+=1,p.set(v,m),d.run(m,v,O,_,h,y),a.globalSymbols+=1,m};i.exec("BEGIN IMMEDIATE");let D=!1;try{let v=0;for(let _ of X(e)){if(_.fieldNumber!==Lt||_.wireType!==2)continue;ai(n.signal),v+=1,v>=ni&&(v=0,await ei());let h="",y=null,m=null,w=null,S=[];for(let u of X(e,_.valueStart,_.valueEnd))u.wireType===2?u.fieldNumber===ti?h=pe.decode(e.subarray(u.valueStart,u.valueEnd)):u.fieldNumber===Xo?S.push(ds(e,u.valueStart,u.valueEnd)):u.fieldNumber===Yo?y=pe.decode(e.subarray(u.valueStart,u.valueEnd)):u.fieldNumber===Qo&&(m=pe.decode(e.subarray(u.valueStart,u.valueEnd))):u.fieldNumber===Ko&&u.wireType===0&&(w=gs(u.varint));if(h==="")throw new H("relative path must not be empty");if(g.has(h)){a.duplicateDocumentsSkipped+=1;continue}let P=f;f+=1,o.run(P,y===""?null:y,h,w,m===""?null:m),g.set(h,P),a.documents+=1;let I=new Map;for(let u of S){if(u.symbol==="")throw new H(`empty symbol in SymbolInformation for document ${h}`);let b=I.get(u.symbol);if(!b){I.set(u.symbol,u);continue}for(let k of u.documentation)b.documentation.includes(k)||b.documentation.push(k)}for(let u of[...I.values()].sort((b,k)=>b.symbol<k.symbol?-1:b.symbol>k.symbol?1:0))Nt(u.symbol)||p.has(u.symbol)||j(u.symbol,u.displayName===""?null:u.displayName,u.kind===0?null:u.kind,u.documentation.length===0?null:u.documentation.join(`
|
|
287
|
+
`),u.enclosingSymbol===""?null:u.enclosingSymbol)}let O=new Set;v=0;for(let _ of X(e)){if(_.fieldNumber!==Lt||_.wireType!==2)continue;ai(n.signal),v+=1,v>=ni&&(v=0,await ei());let h="",y=[];for(let S of X(e,_.valueStart,_.valueEnd))if(S.wireType===2){if(S.fieldNumber===ti)h=pe.decode(e.subarray(S.valueStart,S.valueEnd));else if(S.fieldNumber===zo){let P=cs(e,S.fieldStart,S.valueStart,S.valueEnd);P?y.push(P):a.illegalOccurrencesDropped+=1}}if(O.has(h))continue;O.add(h);let m=g.get(h);if(m===void 0)continue;y.sort(ss);let w=[];for(let S of y){let P=w[w.length-1];if(P&&P.startLine===S.startLine&&P.startChar===S.startChar&&P.endLine===S.endLine&&P.endChar===S.endChar&&P.symbol===S.symbol){P.roles|=S.roles,P.merged=!0,a.mergedOccurrences+=1;continue}w.push(S)}a.occurrences+=w.length;for(let S of w){if((S.roles&is)===0||Nt(S.symbol)||!S.enclosing)continue;let[P,I,u,b]=S.enclosing;if(P<0||I<0||u<P||u===P&&b<I)throw new H(`bad enclosing range for symbol ${S.symbol} in ${h}`);let k=p.get(S.symbol);if(k===void 0)throw new H(`symbol ${S.symbol} has definition occurrence, but no SymbolInformation`);c.run(m,k,P,I,u,b),a.enclosingRanges+=1}for(let[S,P]of ls(w,r).entries()){let I=R;R+=1,s.run(I,m,S,P[0].startLine,P[P.length-1].startLine,ps(e,P)),a.chunks+=1;let u=new Map;for(let b of P){if(Nt(b.symbol))continue;let k=u.get(b.symbol);k||u.set(b.symbol,k=new Set),k.add(b.roles),p.has(b.symbol)||j(b.symbol,null,null,null,null)}for(let[b,k]of u){let B=p.get(b);for(let ot of k)l.run(I,B,ot),a.mentions+=1}}}i.exec("COMMIT"),D=!0}finally{if(!D)try{i.exec("ROLLBACK")}catch{}}i.exec("BEGIN IMMEDIATE");for(let v of os)i.exec(v);i.exec("COMMIT"),i.pragma("wal_checkpoint(TRUNCATE)")}finally{i.close()}return a}function gs(e){if(e===0)return null;if(e===1)return"UTF-8";if(e===2)return"UTF-16";if(e===3)return"UTF-32";throw new H(`unknown position encoding ${e}`)}function ai(e){if(e?.aborted)throw new H("SCIP SQLite conversion aborted")}import{readdirSync as fs,rmSync as ms}from"fs";import{cpus as hs,totalmem as ys}from"os";import{join as Je}from"path";var Ss=2048,bs=6*1024**3,Ps=4;function At(e=process.env){let t=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_FILES??"",10);return Number.isSafeInteger(t)&&t>0?t:Ss}function ui(e,t){return e>Math.floor(t*1.5)}var Rs=1.25;function pi(e,t,n){if(!Number.isSafeInteger(t)||t<1)throw new Error(`TypeScript compiler shard targetFiles must be a positive safe integer; received ${t}.`);let r=Math.max(1,Math.ceil(e/t));if(r<=1||n<=1)return r;let a=Math.floor(t*Rs),i=new Set([r,n*Math.floor(r/n),n*Math.ceil(r/n)]),o=c=>Math.ceil(c/n)*Math.ceil(e/c),s=r;for(let c of i)c<1||Math.ceil(e/c)>a||(o(c)<o(s)||o(c)===o(s)&&c<s)&&(s=c);return s}function xs(e,t,n=()=>1){if(!Number.isSafeInteger(t)||t<1)throw new Error(`TypeScript compiler shard count must be a positive safe integer; received ${t}.`);let r=[...new Set(e)].sort((d,l)=>d.localeCompare(l));if(t===1||r.length<=t)return r.length<=t&&t>1?r.map(d=>[d]):r.length>0?[r]:[];let a=r.map(d=>Math.max(1,n(d))),i=a.reduce((d,l)=>d+l,0),o=[],s=[],c=0;for(let d=0;d<r.length;d+=1){s.push(r[d]),c+=a[d];let l=t-o.length-1,g=r.length-d-1;l>0&&g>=l&&(c>=i*(o.length+1)/t||g===l)&&(o.push(s),s=[])}return s.length>0&&o.push(s),o}function gi(e){let t=e.targetFiles??At(),n=e.shardCount??Math.max(1,Math.ceil(new Set(e.inputPaths).size/Math.max(1,t)));return xs(e.inputPaths,n,e.weightOf).map((r,a)=>{let i=Je(e.projectRoot,Rn(a)),o=`${JSON.stringify({extends:`./${e.rootConfigPath}`,compilerOptions:{incremental:!1},files:r.map(s=>`./${s}`),include:[],exclude:[]},null,2)}
|
|
288
|
+
`;return{configPath:i,content:o,inputPaths:r}})}var fi="typescript-shard-costs.json",li=4;function mi(e){let t;try{t=JSON.parse(an(Je(e,fi),"shard cost model"))}catch{return null}if(typeof t!="object"||t===null||t.version!==1)return null;let n=t.samples;return Array.isArray(n)&&n.every(a=>typeof a=="object"&&a!==null&&typeof a.firstPath=="string"&&typeof a.lastPath=="string"&&Number.isFinite(a.totalBytes)&&a.totalBytes>0&&Number.isFinite(a.durationMs)&&a.durationMs>0)?{version:1,samples:n}:null}function hi(e,t){je(Je(e,fi),t)}function yi(e){let t=(e?.samples??[]).filter(i=>i.totalBytes>0&&i.durationMs>0);if(t.length<2)return(i,o)=>o;let n=t.map(i=>i.durationMs/i.totalBytes).sort((i,o)=>i-o),r=n[Math.floor(n.length/2)];if(!(r>0))return(i,o)=>o;let a=[...t].sort((i,o)=>i.firstPath.localeCompare(o.firstPath));return(i,o)=>{for(let s of a){if(i.localeCompare(s.firstPath)<0)break;if(i.localeCompare(s.lastPath)>0)continue;let c=s.durationMs/s.totalBytes/r;return o*Math.min(li,Math.max(1/li,c))}return o}}function Si(e,t){let n=[];for(let r of e){let a=r.inputPaths[0],i=r.inputPaths[r.inputPaths.length-1];if(a===void 0||i===void 0||!(r.durationMs>0))return null;let o=r.inputPaths.reduce((s,c)=>s+Math.max(1,t(c)),0);n.push({firstPath:a,lastPath:i,totalBytes:o,durationMs:r.durationMs})}return n.length>0?{version:1,samples:n}:null}function bi(e=process.env,t={totalmemBytes:ys(),cpuCount:hs().length}){let n=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_CONCURRENCY??"",10);if(Number.isSafeInteger(n)&&n>0)return n;let r=Math.floor(t.totalmemBytes/2/bs),a=Math.floor(t.cpuCount/2);return Math.max(1,Math.min(Ps,r,a))}function Pi(e){let t;try{t=fs(e)}catch{return}for(let n of t)if(xn(n))try{ms(Je(e,n))}catch{}}import{createHash as Ut}from"crypto";import{existsSync as Bt,writeFileSync as wi}from"fs";import{join as Os}from"path";import{randomUUID as Es}from"crypto";import{existsSync as Ri,rmSync as $t}from"fs";import{join as Is}from"path";var vs=12e4,_s=5,Se=class extends Error{name="TypeScriptIndexMemoryPressureError"},ze=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;requireService;localHost=null;constructor(t,n={}){this.projectRoot=hn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??js(),this.runtime=n.runtime??Fs,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally,this.requireService=n.requireService===!0}request(t){let n=br(this.cacheDir),r=hr(this.cacheDir),a=bt(n.statePath);if(!xi(a,this.projectRoot,this.runtime))return this.requestLocally(t);let i=this.runtime.now(),o=i+this.timeoutMs,s=(this.runtime.monotonicNow??C)()+this.timeoutMs,c=gr("typescript-index-v5",{baseGeneration:this.baseGeneration,request:t}),d=fr(c),l=mr(r,{mailboxVersion:pr,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:i,deadlineAtMs:o,protocolVersion:Ge,id:d,baseGeneration:this.baseGeneration,request:t},{nowMs:i,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??C)()<=s;){if(Ri(l.responsePath))try{return Ei(ge(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{$t(l.responsePath,{force:!0})}let g=bt(n.statePath);if(!xi(g,this.projectRoot,this.runtime))return this.abandonPendingRequest(r,d),this.requestLocally(t);this.runtime.sleep(_s)}if(Ri(l.responsePath))try{return Ei(ge(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{$t(l.responsePath,{force:!0})}return this.abandonPendingRequest(r,d),this.requestLocally(t)}abandonPendingRequest(t,n){try{$t(Is(t.pendingDir,`${n}.json`),{force:!0})}catch{}}requestLocally(t){if(this.requireService)throw new Error("TypeScript incremental index service unavailable; refusing to load the whole compiler graph inside the reindex process");return this.emitLocally?Gt(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new Pr({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),Gt(Ii(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function xi(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null,a=e?Date.parse(e.heartbeatAt):Number.NaN;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Ge&&n.isProcessAlive(e.pid)&&Number.isFinite(a)&&n.now()-a<=Sr&&(!e.processIdentity||r!=null&&J(e.processIdentity,r))}function Ei(e,t,n,r,a,i){let o=JSON.parse(e);if(o.protocolVersion!==Ge||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0){let s=typeof o.error=="string"?o.error:"TypeScript index service request failed.";throw Ts(s)?new Se(s):new Error(s)}return Gt(Ii(o.response,a),a,i)}function Ts(e){let t=e.toLowerCase();return t.includes("out of memory")||t.includes("memory limit")||t.includes("allocation failed")||t.includes("err_worker_out_of_memory")}function Gt(e,t,n){if(e.producerIdentity!==t)throw new Error("TypeScript index service wrote an invalid response.");let r=[...new Set(n)].sort(),a=e.fragments.map(i=>i.relativePath).sort();if(JSON.stringify(a)!==JSON.stringify(r))throw new Error("TypeScript index service omitted or added an affected document.");return e}function Ii(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,a=n.fragments.map(i=>{if(!i||typeof i.relativePath!="string"||i.bytesBase64!==null&&typeof i.bytesBase64!="string"||typeof i.occurrences!="number"||!Number.isInteger(i.occurrences)||i.occurrences<0||typeof i.symbols!="number"||!Number.isInteger(i.symbols)||i.symbols<0||!Array.isArray(i.referenceFragments)||!i.referenceFragments.every(ws)||r.has(i.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(i.relativePath);let o=i.bytesBase64===null?null:Cs(i.bytesBase64);return{relativePath:i.relativePath,bytes:o,occurrences:i.occurrences,symbols:i.symbols,referenceFragments:i.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:a}}function ws(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function Cs(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function js(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:vs}var Fs={now:Date.now,monotonicNow:C,randomId:Es,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:oe,readProcessIdentity:U};var ks=128,Ds=256;function Ms(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."],n=se(t);if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let r=ie(e.previousSnapshot,e.currentSnapshot);if(r.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let a=r.changes.filter(m=>m.inputKind==="source"&&ue(m.path)),i=Ci(r,n),o={...r,changes:i},s=a.filter(m=>m.kind==="added").map(m=>m.path),c=a.filter(m=>m.kind==="deleted").map(m=>m.path),d=a.filter(m=>m.kind==="modified"),l=Ye(e.currentSnapshot,e.producerIdentity,n),g=Ye(e.previousSnapshot,e.producerIdentity,n),p=ji(r,i,l,g),f=!p&&Oi(r);if(a.length===0&&!p)return{eligible:!1,reason:"change does not affect the configured TypeScript project"};let R=e.currentSnapshot.files.filter(m=>ve(m.path,e.currentSnapshot.languages)==="source"&&ue(m.path)).map(m=>m.path).sort(),T=new Set(R),j=p?e.projectFiles.filter(m=>!T.has(m)).sort():[...c].sort(),D=p?o:{...r,changes:a},v=p?{eligible:!0,plan:{...ye(o,e.graph,[...new Set([...R,...j])]),mode:"full-project"}}:Ls(d,s,j,e.graph,e.projectFiles);if(!v.eligible)return v;let O=v.plan,_=new Set(j),h=As(O,t,e.graph,_);if(!h)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let y=h.length===1?h[0]:void 0;return{eligible:!0,manifest:D,plan:O,projectIdentity:l,previousFragmentGeneration:Ti(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Ti(e.currentSnapshot,e.producerIdentity),projects:h,deletedFiles:j,replaceProject:p,dependencyGraphUnchanged:f,...y?{tsconfigPath:y.tsconfigPath,projectArgument:y.projectArgument}:{}}}function Ci(e,t){return e.changes.filter(n=>n.inputKind==="source"&&ue(n.path)||n.inputKind==="config"&&(!ce(n.path)||t.has(n.path))&&Ns(n)||n.inputKind==="ambient")}function Ns(e){return e.kind!=="modified"||e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function ji(e,t,n,r){return n!==r||e.projectIdentityChanged||e.uncertainty.length>0||t.length>Ds||t.some(a=>a.inputKind==="config"||a.inputKind==="ambient")}function Ls(e,t,n,r,a){if(e.length===0)return t.length===0&&n.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...t,...n])].sort(),affectedFiles:[...new Set([...t,...vi(n,r,a)])].sort(),reasons:[]}};let i=ye({version:1,changes:e.filter(Fi),projectIdentityChanged:!1,uncertainty:[]},r,a);return i.mode==="full-project"?{eligible:!1,reason:i.reasons.length>0?`affected set widened: ${i.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...e.map(o=>o.path),...t,...n])].sort(),affectedFiles:[...new Set([...i.affectedFiles,...e.map(o=>o.path),...t,...vi(n,r,a)])].sort(),reasons:[]}}}function Fi(e){return e.kind!=="modified"?!0:e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function Oi(e){let t=e.changes.filter(n=>n.inputKind==="source"&&ue(n.path));return t.length>0&&t.every(n=>n.kind==="modified"&&!Fi(n))}function As(e,t,n,r){let a=new Map;for(let o of e.affectedFiles){let s=$s(o,t);if(!s)return null;let c=a.get(s)??[];c.push(o),a.set(s,c)}let i=[];for(let[o,s]of[...a].sort(([c],[d])=>c.localeCompare(d))){let c=new Set(s),d=e.changedFiles.filter(p=>!r.has(p)&&(c.has(p)||s.some(f=>_i(f,p,n)))),l=e.changedFiles.filter(p=>r.has(p)&&(c.has(p)||s.some(f=>_i(f,p,n)))),g=s.filter(p=>!r.has(p));if(d.length===0&&l.length===0&&g.length===0)return null;i.push({projectArgument:o,tsconfigPath:o==="."?"tsconfig.json":`${o}/tsconfig.json`,modifiedFiles:d,removedFiles:l,affectedFiles:[...g].sort()})}return i}function vi(e,t,n){let r=new Set(n),a=new Map;for(let[s,c]of t)if(r.has(s))for(let d of c){let l=a.get(d)??new Set;l.add(s),a.set(d,l)}let i=new Set(e),o=[...e];for(let s=0;s<o.length;s+=1){let c=o[s];if(c)for(let d of a.get(c)??[])i.has(d)||(i.add(d),o.push(d))}return[...i].sort()}function $s(e,t){let n=t.filter(i=>i==="."||e===i||e.startsWith(`${i}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((i,o)=>Xe(o)-Xe(i)||i.localeCompare(o)),a=r[0];return r[1]&&Xe(r[1])===Xe(a)?null:a}function Xe(e){return e==="."?0:e.split("/").filter(Boolean).length}function _i(e,t,n){let r=new Set,a=[e];for(let i=0;i<a.length;i+=1){let o=a[i];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||a.push(s)}}}return!1}function ki(e){let t=C();try{if(!Bt(e.previousDbPath)||!Bt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=St();if(!r.available)throw new Error(r.reason);let a=performance.now()-n;n=performance.now();let i=new $({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o=Bs(e.projectRoot,e.previousSnapshot,e.currentSnapshot),s=e.projectMode==="workspace"?z(e.projectRoot,e.currentSnapshot.typescriptProjects):["."],c=se(s),d,l,g;try{d=Fe(i,{includeIgnored:!1}).filter(ue).sort();let I=o?ie(o,e.currentSnapshot):null,u=I&&o&&ji(I,Ci(I,c),Ye(e.currentSnapshot,r.producerIdentity,c),Ye(o,r.producerIdentity,c)),b=I!==null&&!u&&Oi(I);u?(g=Nn(i,"none")??void 0,l=new Map):b?l=new Map:(g=Oe(i),l=g.graph)}finally{i.close()}let p=performance.now()-n,f=Ms({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?s:void 0,previousSnapshot:o,currentSnapshot:e.currentSnapshot,projectFiles:d,graph:l,producerIdentity:r.producerIdentity,rootTsconfigExists:Bt(Os(e.projectRoot,"tsconfig.json"))});if(!f.eligible)throw new Error(f.reason);let R=yr(e.previousDbPath);if(!R)throw new Error("published TypeScript base generation unavailable");n=performance.now();let T=new ze({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:R},{requireService:!0}),j=f.projects.flatMap(I=>{let u=Gs(I.affectedFiles,ks);return(u.length>0?u:[[]]).map((k,B)=>({project:I,affectedFiles:k,removedFiles:B===0?I.removedFiles:[],firstForProject:B===0}))}),D=[],v=new Map,O=[],_=!1,h=0,y=0,m=0,w=f.previousFragmentGeneration;for(let[I,u]of j.entries()){let b=T.request({kind:"emit-documents",tsconfigPath:u.project.tsconfigPath,projectArgument:u.project.projectArgument,projectIdentity:f.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:u.firstForProject?u.project.modifiedFiles:[],removedFiles:u.firstForProject?u.project.removedFiles:[],affectedFiles:u.affectedFiles});_||=b.cold,O.push(b.durationMs);let k=u.removedFiles.map(Re=>({relativePath:Re,bytes:null,occurrences:0,symbols:0,referenceFragments:[]})),B=[...b.fragments,...k];if(!f.replaceProject)for(let Re of B)v.set(Re.relativePath,Re.referenceFragments);let ot=performance.now(),wa=Zn(b.fragments);h+=performance.now()-ot;let tn=I===0?e.candidateAffectedScipPath:`${e.candidateAffectedScipPath}.batch-${I}.scip`,Ca=performance.now();wi(tn,wa),m+=performance.now()-Ca;let ja=performance.now(),nn=I===j.length-1?f.nextFragmentGeneration:Us({previousGenerationIdentity:w,targetGenerationIdentity:f.nextFragmentGeneration,fragments:B});tr({cacheDir:e.cacheDir,previousGenerationIdentity:w,nextGenerationIdentity:nn,producerIdentity:r.producerIdentity,projectIdentity:f.projectIdentity,baseShardCurrent:I===0?e.baseShardCurrent:!1,fragments:B,allowProjectIdentityChange:f.replaceProject&&I===0,allowLegacyProjectIdentityMigration:!0}),y+=performance.now()-ja,w=nn,D.push({scipPath:tn,affectedFiles:[...u.affectedFiles,...u.removedFiles].sort(),deletedFiles:[...u.removedFiles].sort()})}let S=performance.now()-n,P={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,affectedBatches:D,completeScipUpdated:!1,durationMs:C()-t,cold:_,changedFiles:f.plan.changedFiles,affectedFiles:f.plan.affectedFiles,deletedFiles:f.deletedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:f.previousFragmentGeneration,nextFragmentGeneration:f.nextFragmentGeneration,manifest:f.manifest,plan:f.plan,projectFileCount:d.length,dependencyGraphSnapshot:g,dependencyGraphUnchanged:f.dependencyGraphUnchanged,referenceFragmentsByFile:v,timings:{runtimeMs:a,graphMs:p,requestMs:S,serviceMs:O.reduce((I,u)=>I+u,0),assemblyMs:h,fragmentStoreMs:y,writeMs:m}};return e.onStatus(`${f.replaceProject?"Bounded TypeScript project refresh":"Incremental TypeScript index"} emitted ${P.affectedFiles.length-P.deletedFiles.length} document(s), removed ${P.deletedFiles.length}, and produced ${D.length} bounded batch(es) across ${f.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${a.toFixed(0)}ms, graph ${p.toFixed(0)}ms, request ${S.toFixed(0)}ms, assembly ${h.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${m.toFixed(0)}ms).`),P}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof Se)throw e.onStatus(`Incremental TypeScript index stopped after memory pressure survived one cold Worker retry: ${r}. Preserving the accepted index instead of starting a memory-heavier whole-project rebuild.`),n;return e.onStatus(`Incremental TypeScript index unavailable: ${r}.`),null}}function Gs(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function Bs(e,t,n){if(!t)return null;let r=new Map(n.files.map(o=>[o.path,o])),a=!1,i=t.files.map(o=>{let s=r.get(o.path);if(o.semanticHash!==void 0||s?.semanticHash===void 0)return o;let c=Te(e,o.path,o.hash);return c===void 0?o:(a=!0,{...o,semanticHash:c})});return a?{...t,files:i}:t}function Us(e){let t=Ut("sha256");t.update("typescript-overlay-batch-v1\0"),t.update(e.previousGenerationIdentity),t.update("\0"),t.update(e.targetGenerationIdentity);for(let n of[...e.fragments].sort((r,a)=>r.relativePath.localeCompare(a.relativePath)))t.update("\0path\0"),t.update(n.relativePath),n.bytes===null?t.update("\0deleted"):(t.update("\0bytes\0"),t.update(Ut("sha256").update(n.bytes).digest()));return t.digest("hex")}function qt(e){let t=St();if(!t.available)throw new Error(t.reason);let n=nr({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:re(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:xe}),packageVersion:t.packageVersion});wi(e.candidateShardPath,n)}function Ye(e,t,n){let r=e.files.filter(a=>{let i=ve(a.path,e.languages);return i==="ambient"||i==="config"&&(!ce(a.path)||n.has(a.path))}).map(a=>{let o=ve(a.path,e.languages)==="config"?a.semanticHash:void 0;return{path:a.path,size:o===void 0?a.size:0,hash:o??a.hash}}).sort((a,i)=>a.path.localeCompare(i.path));return`typescript-project-v3:${Di(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function Ti(e,t){return Di(JSON.stringify({version:1,producerIdentity:t,snapshot:dn(e)}))}function Di(e){return Ut("sha256").update(e).digest("hex")}import{closeSync as qs,existsSync as Qe,fstatSync as Ws,lstatSync as Hs,openSync as Js,renameSync as Ht,rmSync as be,statSync as zs,writeSync as Xs}from"fs";import{cpus as Ys}from"os";import{join as Jt}from"path";var Mi=8*1024;function Ni(e,t,n){let r=Buffer.from(t,"utf8"),a=()=>Js(e,"wx",384),i;try{i=a()}catch(o){if(o.code!=="EEXIST")throw o;if(n==="skip")return null;be(e,{force:!0}),i=a()}try{Xs(i,r);let o=Ws(i);return{path:e,content:r,device:o.dev,inode:o.ino}}finally{qs(i)}}function Qs(e,t){let n=[];try{if(e.temporaryRootConfigContent!==void 0){let r=Ni(Jt(t,"tsconfig.json"),e.temporaryRootConfigContent,"skip");r&&n.push(r)}for(let r of e.temporaryProjectConfigs??[]){let a=Ni(r.path,r.content,"replace");a&&n.push(a)}return n}catch(r){for(let a of n.reverse())$i(a);throw r}}function $i(e){if(e)try{let t=Hs(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=re(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;be(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function Ks(e,t,n){if(!e.defaultOutputPath)return;let r=Jt(t,e.defaultOutputPath);n!==r&&Qe(r)&&Ht(r,n)}function Vs(e,t,n){if(!e.defaultOutputPath)return null;let r=Jt(t,e.defaultOutputPath);if(r===n)return null;let a=`${n}.default-output-backup`;return be(a,{force:!0}),Qe(r)?(Ht(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function Zs(e){e&&(be(e.defaultOutputPath,{force:!0}),e.backupPath&&Qe(e.backupPath)&&Ht(e.backupPath,e.defaultOutputPath))}function ec(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Ys().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Gi(e,t,n,r,a){A(a,"Reindex cancelled by its owner.");let i=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath&&d.boundedConcurrency!==void 0),s=e.filter(d=>!d.config.defaultOutputPath&&d.boundedConcurrency===void 0),c=[];if(c.push(...await Li(s,ec(s.length,r),t,n,a)),o.length>0){let d=Math.max(1,Math.min(...o.map(l=>l.boundedConcurrency)));c.push(...await Li(o,d,t,n,a))}for(let d of i)A(a,"Reindex cancelled by its owner."),c.push((await Wt(d,t,n,a)).result);return c.sort((d,l)=>e.findIndex(g=>g.id===d.id)-e.findIndex(g=>g.id===l.id))}async function Li(e,t,n,r,a){let i=await Rr(e,Math.max(1,t),s=>Wt(s,n,r,a));if(t<=1)return i.map(({result:s})=>s);let o=new Map;for(let s of i.filter(c=>c.result.skipped&&c.retryable)){let c=e.find(d=>d.id===s.result.id);c&&(r(`Retrying ${c.label} indexer serially after parallel failure...`),A(a,"Reindex cancelled by its owner."),o.set(c.id,(await Wt(c,n,r,a)).result))}return i.map(({result:s})=>o.get(s.id)??s)}async function Wt(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),be(e.scipPath,{force:!0});let a=Vs(e.config,t,e.scipPath),i=[],o=[e.binary,...e.args].join(" "),s=C();try{i=Qs(e,t),e.trustedProjectTool&&jn(t,e.trustedProjectTool);let d=fn(e.binary,e.args),l=await Ie({command:d.binary,args:d.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:tc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let g=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${g?`:
|
|
289
|
+
${g}`:""}`)}Ks(e.config,t,e.scipPath)}catch(d){if(r?.aborted)throw yn(r,"Reindex cancelled by its owner.");let l=d instanceof Error?d.message:String(d),g=l.length<=Mi?l:`${l.slice(0,Mi)}
|
|
290
|
+
[indexer failure detail truncated]`,p=`${e.resolvedBinary} indexer failed: ${g}`,f=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:f}},retryable:nc(d)}}finally{Zs(a);for(let d of i.reverse())$i(d)}if(!Qe(e.scipPath)){let d=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,l=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:l}},retryable:!1}}let c;try{c=zs(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},outputBytes:c},retryable:!1}}function tc(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):on.indexer}function nc(e){return e instanceof sn?e.kind==="spawn"&&Ai(e.cause):Ai(e)}function Ai(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Ui}from"child_process";import{homedir as Bi,platform as rc}from"os";import{delimiter as ic,join as Ke}from"path";function qi(e,t){let n=e.installMethods,r=Ce(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let a of n){if(!a.identity||!a.destination){t(`Refusing ${a.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!gn(a.prerequisite))continue;let i=ac(a);t(`Installing immutable ${a.identity} via ${a.label} into ${i}; expected executable: ${r}.`);try{Ui(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:rc()==="win32"});let o=he(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${a.identity} via ${a.label}${s}; resolved executable: ${o}.`),!0}t(`${a.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${a.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function ac(e){if(e.binary==="npm")return zt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=zt("go",["env","GOBIN"]);if(t)return t;let n=zt("go",["env","GOPATH"]);if(n)return Ke(n.split(ic)[0],"bin")}return e.binary==="dotnet"?Ke(process.env.DOTNET_CLI_HOME??Bi(),".dotnet","tools"):e.binary==="dart"?Ke(process.env.PUB_CACHE??Ke(Bi(),".pub-cache"),"bin"):e.destination}function zt(e,t){try{return Ui(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function ra(e){let{projectRoot:t,onStatus:n=console.log}=e,r=e.maxHeapMb??pc(process.env.NODE_OPTIONS)??8192,a=e.skipAutoInstall===!0||e.installMissing!==!0,i=fc(e),o=Date.now(),s=C();et(x(i.outputScip),{recursive:!0}),et(x(i.outputDb),{recursive:!0});let c=e.languages??Jn(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");n(`Detected languages: ${c.join(", ")}`);let d=nt(i.metaPath),l=E("reindex.fingerprint",()=>_n(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},d,e.changeJournal,ft(i.outputDb)),{languages:c.length}),g=l.fingerprint,p=l.mode==="delta"?e.changeJournal?.entries.filter(y=>y.kind!=="add").length??0:0,f=Math.max(0,(d?.files.length??0)-p);n(l.mode==="delta"?`Project fingerprint revalidated ${l.changedPaths.length} changed path(s), reused ${f} accepted file fingerprint(s), and accepted ${g.files.length} input(s)`:`Project fingerprint used full scan: ${l.reason}`);let R=await lc({opts:e,paths:i,languages:c,fingerprint:g,onStatus:n}),T=R.snapshot,j=R.releaseBuildLock,D=ma(e.trigger),v=Pn(F(x(i.outputDb),"cache-lifecycle.lock"),{waitMs:D?1e3:3e4});if(!v)throw j?.(),new le(D?`Could not acquire scip-query cache lifecycle lock for ${x(i.outputDb)}; another refresh is publishing, so the watcher will retry.`:`Could not acquire scip-query cache lifecycle lock for ${x(i.outputDb)}. A watch daemon or another reindex may hold it. Run "scip-query watch --stop", retry the reindex, then restart with "scip-query watch --daemon".`);let O;try{O=await G("reindex.lock",()=>Hc(F(x(i.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:n}),{languages:c.length})}catch(y){throw v.release(),j?.(),y}let _=null,h=vr();try{l.mode==="delta"&&ft(i.outputDb)!==e.changeJournal?.baseGeneration&&(g=In(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),l={mode:"full",fingerprint:g,reason:"accepted-generation-changed-before-lock"},T=void 0,j?.(),j=void 0,n("Project fingerprint used full scan: accepted-generation-changed-before-lock")),ar(i.outputDb,i.outputScip,i.metaPath);let y=Sc(x(i.outputDb));y.removed>0&&n(`Removed ${y.removed} abandoned reindex workspace(s)`);for(let b of y.errors)n(`Could not remove abandoned reindex workspace: ${b}`);let m=null,w=await G("reindex.reuse-check",async()=>(m=await mc({opts:e,paths:i,languages:c,fingerprint:g,start:o,monotonicStart:s,onStatus:n}),m),()=>({languages:c.length,reused:m!==null}));if(w){Ji({snapshot:T,paths:i,projectRoot:t,fingerprint:g,onStatus:n});let b=ht(i.outputDb,w);return b.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${b.reason}`),lt(t,x(i.outputDb)),w}await G("reindex.scip-cli-ready",()=>Mc(a,n));let S=yc(i);_=S.runDir;let P,I=await G("reindex.fresh",async()=>(P=await bc({opts:e,languages:c,projectRoot:t,paths:i,tempPaths:S,fingerprint:g,start:o,monotonicStart:s,maxHeapMb:r,skipAutoInstall:a,onStatus:n,writeTelemetry:h}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));Ji({snapshot:T,paths:i,projectRoot:t,fingerprint:g,onStatus:n});let u=ht(i.outputDb,I);return u.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${u.reason}`),lt(t,x(i.outputDb)),I}catch(y){let m=at({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:y instanceof Error?y.message:String(y)});ba(i.metaPath,m);let w=Vn(i.outputDb,m);throw w.state==="failed"&&n(`Warning: failed reindex activity telemetry was not recorded: ${w.reason}`),y}finally{_&&V(_,{recursive:!0,force:!0}),O(),v.release(),j?.()}}async function lc(e){let{opts:t,paths:n,languages:r,fingerprint:a,onStatus:i}=e,o=t.projectRoot;if(!(t.skipIfUnchanged!==!1&&!or(o,n.outputDb)&&Wi(n.outputScip)===Wi(F(x(n.outputDb),"index.scip"))))return{snapshot:void 0,releaseBuildLock:void 0};let c=we(o),d=c?.clean?Ae(c,a):void 0;if(c&&!c.clean&&!zi(n))return Hi({context:c,languages:r,opts:t,paths:n,fingerprint:a,projectRoot:o,onStatus:i,successMessage:"dirty worktree reindex",failurePrefix:"Shared baseline fork failed"}),{snapshot:d,releaseBuildLock:void 0};if(!d)return{snapshot:void 0,releaseBuildLock:void 0};let l=yt(d);if(l){if(!uc(n,a))try{$e({snapshot:d,manifest:l,targetCacheDir:x(n.outputDb),targetProjectRoot:o}),i(`Attached shared generation ${d.generationId.slice(0,12)}`)}catch(p){i(`Shared generation attach failed; continuing locally: ${Z(p)}`)}return{snapshot:d,releaseBuildLock:void 0}}c&&!zi(n)&&Hi({context:c,languages:r,opts:t,paths:n,fingerprint:a,projectRoot:o,onStatus:i,successMessage:"cold worktree reindex",failurePrefix:"Compatible shared baseline fork failed",compatible:!0});let g=await dr(d);if(g.kind==="owner")return{snapshot:d,releaseBuildLock:g.release};if(g.kind==="generation-ready"){let p=yt(d);if(p)try{$e({snapshot:d,manifest:p,targetCacheDir:x(n.outputDb),targetProjectRoot:o,action:"waited"}),i(`Attached shared generation ${d.generationId.slice(0,12)} after waiting`)}catch(f){i(`Shared generation attach failed after waiting; continuing locally: ${Z(f)}`)}}else i("Shared generation build lock timed out; continuing with an isolated local reindex");return{snapshot:d,releaseBuildLock:void 0}}function Hi(e){let t=sr(e.context,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath},e.fingerprint);if(t)try{$e({snapshot:t.snapshot,manifest:t.manifest,targetCacheDir:x(e.paths.outputDb),targetProjectRoot:e.projectRoot,persistLease:!1}),ur(t.snapshot,x(e.paths.outputDb)),e.onStatus(`Forked ${e.compatible?"compatible ":""}shared baseline ${t.snapshot.generationId.slice(0,12)} for ${e.successMessage}`)}catch(n){e.onStatus(`${e.failurePrefix}; continuing locally: ${Z(n)}`)}}function Ji(e){if(e.snapshot)try{let t=we(e.projectRoot),n=t?Ae(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=cr({snapshot:e.snapshot,sourceCacheDir:x(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let a=we(e.projectRoot);return(a?Ae(a,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});lr(e.snapshot,x(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${Z(t)}`)}}function uc(e,t){if(!L(e.outputScip)||!L(e.outputDb)||Sa(e.metaPath,t)===null)return!1;let n=q(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function zi(e){if(!L(e.outputScip)||!L(e.outputDb)||!ne(e.metaPath))return!1;let t=q(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function Z(e){return e instanceof Error?e.message:String(e)}function pc(e){let t=e?.match(/--max[-_]old[-_]space[-_]size(?:=|\s+)(\d+)/u);if(!t)return;let n=Number.parseInt(t[1],10);return Number.isInteger(n)&&n>0?n:void 0}function gc(e,t){return[(e??"").replace(/(?:^|\s)--max[-_]old[-_]space[-_]size(?:=|\s+)\d+/gu," ").trim(),`--max-old-space-size=${t}`].filter(Boolean).join(" ")}async function Qt(e,t,n,r,a,i,o,s=!1){try{await Kn(_r({indexPath:n,evidenceDbPath:o,reuseExisting:a,affectedFiles:i,forceDerivedRebuild:s}),{projectRoot:e,dbPath:t,onStatus:r})}catch(c){r(`Runtime-boundary extraction unavailable: ${c instanceof Error?c.message:String(c)}.`)}}function fc(e){let t=e.outputScip??F(e.projectRoot,"index.scip"),n=e.outputDb??F(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:F(x(n),"meta.json")}}async function mc(e){let t=q(e.paths.outputDb,e.paths.metaPath),n=Sa(e.paths.metaPath,e.fingerprint);if(e.opts.skipIfUnchanged===!1||!L(e.paths.outputScip)||!L(e.paths.outputDb)||n===null||t.state==="invalid"||t.state==="drifted")return null;let r=Ne(e.paths.outputDb,e.fingerprint,e.languages);if(r.state!=="complete")return e.onStatus(Kt("Accepted SQLite index",r)),null;Me(ke(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await Qt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),q(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(Le(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation")),n==="operational-config-compatible"&&(Zc(e.paths.metaPath,e.fingerprint,e.languages,e.opts),Le(e.paths.outputDb,e.paths.metaPath),e.onStatus("Migrated operational .scipquery.json metadata without rerunning language indexers."));let a=C()-e.monotonicStart,i=at({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return ba(e.paths.metaPath,i),e.onStatus(`Index unchanged; reused existing SQLite index in ${(a/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:a,reused:!0,skipped:[],lastRefresh:i,shards:hc(e.paths,e.languages,e.opts,e.fingerprint)}}function hc(e,t,n,r){let a=Vt(r,t,n);return t.map(i=>({id:i,language:i,reused:!0,strategy:"reused",fingerprint:Pe(a[i]),outputBytes:ee(Zt(e.outputDb,i)),durationMs:0}))}function yc(e){let t=sc(F(x(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:F(t,Ve(e.outputScip)),tempOutputDb:F(t,Ve(e.outputDb)),tempMetaPath:F(t,Ve(e.metaPath))}}function Sc(e){let t=[],n;try{n=ta(e,{withFileTypes:!0})}catch(a){return{removed:0,errors:[Z(a)]}}let r=0;for(let a of n)if(!(!a.name.startsWith("reindex-")||!a.isDirectory()))try{V(F(e,a.name),{recursive:!0,force:!0}),r+=1}catch(i){t.push(`${a.name}: ${Z(i)}`)}return{removed:r,errors:t}}async function bc(e){let t={...process.env,NODE_OPTIONS:gc(process.env.NODE_OPTIONS,e.maxHeapMb)},n,r=await G("reindex.language-indexers",async()=>(n=await Rc(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:a,skippedLanguages:i,reusedLanguages:o,languageFingerprints:s,shards:c,typescriptProjectShardContext:d,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),Pc({run:e,indexedOutputs:a,skippedLanguages:i,reusedLanguages:o})){let f=await G("reindex.publish",()=>Fc(e,a,i,o,s,d),{mode:"metadata-only",languages:a.length,reused:o.length}),R=f.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(R/1e3).toFixed(1)}s`),{languages:a.map(T=>T.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:R,reused:!0,skipped:i,lastRefresh:f,shards:c,writeTelemetry:e.writeTelemetry}}let g=await G("reindex.publish",()=>Cc(e,t,a,i,o,s,d,l),{mode:l?"incremental-or-fallback":"full",languages:a.length,reused:o.length,skipped:i.length}),p=g.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:a.map(f=>f.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:i,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}function Pc(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!L(e.run.paths.outputScip)||!L(e.run.paths.outputDb))return!1;let t=q(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(a=>a.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(a=>n.has(a)&&r.has(a))}async function Rc(e,t){let n=e.opts.skipIfUnchanged===!1,r=_c({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,projectFingerprint:e.fingerprint});if(n)for(let[u,b]of r)b.reused&&r.set(u,{...b,reused:!1,reason:"forced reindex requested"});let a=[],i=new Set;for(let[u,b]of r)b.reused&&(a.push({language:u,scipPath:b.scipPath}),i.add(u));for(let u of i)e.onStatus(`Reusing cached ${u} SCIP shard (language inputs unchanged).`);let o=r.get("typescript"),s=q(e.paths.outputDb,e.paths.metaPath),c=ne(e.paths.metaPath),d=s.state==="legacy"||s.state==="current",l=c?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),g;n&&o&&!o.reused&&(g="forced reindex rebuilds from the compilers");let p=!n&&o&&!o.reused&&d?ki({projectRoot:e.projectRoot,cacheDir:x(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:te(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:te(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:nt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus,onUnavailable:u=>{g=u}}):null,f=new Set(p?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1){let u=e.languages.filter(b=>!i.has(b)&&!f.has(b));if(u.length>0){let b=u.length===1&&u[0]==="typescript"&&g?`: ${g}`:"";throw new Error(`Incremental indexing is unavailable for ${u.join(", ")}${b}. The accepted index was preserved because whole-project rebuilds are disabled; run scip-query reindex --allow-expensive-rebuild only when you explicitly want that fallback.`)}}let R=p||i.has("typescript")?void 0:xc(e,r),T=R&&n?{...R,classification:new Map([...R.classification].map(([u,b])=>[u,b.reused?{...b,reused:!1,reason:"forced reindex requested"}:b])),reusedProjects:[],missedProjectIds:new Set(R.allProjects.map(u=>`typescript:${u}`))}:R,{preparedRuns:j,skippedLanguages:D,languageOutputScipPaths:v}=Nc({languages:e.languages.filter(u=>!i.has(u)&&!f.has(u)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:T?.allProjects,typescriptShardCostDir:x(e.paths.outputDb),clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),O=T?j.filter(u=>u.language!=="typescript"||T.missedProjectIds.has(u.id)):j,_=await Gi(O,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(un())for(let u of _)pn({type:"span",name:`reindex.language-indexer.${u.id}`,durationMs:Math.round(u.durationMs),ok:!u.skipped,language:u.language,indexerCommand:u.command,outputBytes:u.outputBytes,measurement:"indexer-run-result"});Ac(x(e.paths.outputDb),e.projectRoot,O,_);let h=[];if(T){Ic(e.paths.outputDb,_,e.writeTelemetry);let u=v.typescript??e.tempPaths.tempOutputScip;h=vc({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:u,reusedProjects:T.reusedProjects,writeTelemetry:e.writeTelemetry})}let y=[..._,...h],{indexedOutputs:m}=Gc(y,D),w=p?[{language:"typescript",scipPath:p.scipPath}]:[],S=[...a,...w,...m];Bc(S,D,e.languages,e.opts.allowPartial,e.onStatus);let P=p?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:p.scipPath,outputScipPath:p.scipPath,durationMs:p.durationMs,command:"watch-service:typescript-index",outputBytes:ee(p.scipPath)??void 0,producedOutputBytes:ee(p.affectedScipPath)??void 0}]:[],I=Tc(r,[..._,...P],T?{outputDb:e.paths.outputDb,classification:T.classification}:void 0,g);return{indexedOutputs:S,skippedLanguages:D,reusedLanguages:[...i],languageFingerprints:wc(r,e.languages),shards:I,typescriptProjectShardContext:T?{projects:T.allProjects,fingerprints:T.fingerprints}:void 0,incrementalTypeScript:p??void 0}}function xc(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=z(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let a=Qr(e.projectRoot,r),i=zr(n.fingerprint.files,r),o=Xr(r,a),s=Yr(r,i,o),c=ne(e.paths.metaPath),l=Ec(c,s,R=>L(rt(e.paths.outputDb,R))),g=[...l.entries()].filter(([,R])=>R.reused).map(([R])=>R),p=new Set(g),f=new Set(r.filter(R=>!p.has(R)).map(R=>`typescript:${R}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:g,missedProjectIds:f}}function Ec(e,t,n){let r=new Map;for(let a of Object.keys(t)){let i=t[a];if(!e){r.set(a,{reused:!1,reason:"no reindex metadata found",fingerprint:i});continue}let o=e.version===ae&&ct(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[a]:void 0;if(!o){r.set(a,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:i});continue}if(!n(a)){r.set(a,{reused:!1,reason:"cached shard file missing on disk",fingerprint:i});continue}if(N(o)!==N(i)){r.set(a,{reused:!1,reason:"project inputs changed since last index",fingerprint:i});continue}r.set(a,{reused:!0,fingerprint:i})}return r}function Ic(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let a=r.id.slice(11),i=rt(e,a);et(x(i),{recursive:!0}),K(n,Q(r.scipPath,i))}}function vc(e){return e.reusedProjects.map((t,n)=>{let r=rt(e.outputDb,t),a=te(e.tempOutputScip,"typescript-project-cached",n);return K(e.writeTelemetry,Q(r,a)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:a,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:ee(a)??void 0}})}function _c(e){let t=ne(e.paths.metaPath),n=Vt(e.projectFingerprint,e.languages,e),r=t&&L(e.paths.outputDb)?Ne(e.paths.outputDb,e.projectFingerprint,e.languages):null,a=new Map;for(let i of e.languages){let o=Zt(e.paths.outputDb,i),s=n[i];if(!t){a.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:o});continue}if(t.version!==ae){a.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!ct(t).languageShardReuse||!t.languageFingerprints){a.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:o});continue}let c=t.languageFingerprints[i];if(!c){a.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:o});continue}if(!L(o)){a.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}let d=i==="typescript"?Qc(e.projectRoot,c):c;if(N(d)!==N(s)){a.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:o});continue}if(r?.state==="unavailable"||r?.state==="incomplete"&&r.affectedLanguages.includes(i)){a.set(i,{reused:!1,reason:Kt("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:o});continue}a.set(i,{reused:!0,fingerprint:s,scipPath:o})}return a}function Tc(e,t,n,r){let a=[];for(let[i,o]of e)o.reused&&a.push({id:i,language:i,reused:!0,strategy:"reused",fingerprint:Pe(o.fingerprint),outputBytes:ee(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,c=s?n.classification.get(s):void 0;a.push({id:i.id,language:i.language,reused:!1,strategy:i.command==="watch-service:typescript-index"?"incremental":"full",missReason:c?.reason??o?.reason??i.skipped?.reason,fallbackReason:i.language==="typescript"?r:void 0,fingerprint:c?Pe(c.fingerprint):o?Pe(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,producedOutputBytes:i.producedOutputBytes,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&a.push({id:`typescript:${i}`,language:"typescript",reused:!0,strategy:"reused",fingerprint:Pe(o.fingerprint),outputBytes:ee(rt(n.outputDb,i)),durationMs:0});return a}function Pe(e){return oc("sha256").update(N(e)).digest("hex").slice(0,16)}function ee(e){try{return Yt(e).size}catch{return null}}function wc(e,t){let n={};for(let r of t){let a=e.get(r);a&&(n[r]=a.fingerprint)}return n}async function Cc(e,t,n,r,a,i,o,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,d=!1;c&&(d=E("reindex.publish.scip-output",()=>{let h=Dc({run:e,indexedOutputs:n,incrementalTypeScript:s,typescriptReused:a.includes("typescript")});return Xi(e.paths.outputDb,h,e.writeTelemetry),Yi(h,e.tempPaths.tempOutputScip,e.onStatus)}));let l=await G("reindex.publish.sqlite-output",()=>Uc({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:d,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return d;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),qt({cacheDir:x(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let h=n.map(y=>y.language==="typescript"?{language:y.language,scipPath:s.candidateScipPath}:y);return Xi(e.paths.outputDb,h,e.writeTelemetry),d=Yi(h,e.tempPaths.tempOutputScip,e.onStatus),d}}));A(e.opts.signal,"Reindex cancelled by its owner."),E("reindex.publish.auxiliary-documents",()=>{Me(ke(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),await G("reindex.publish.runtime-boundaries",async()=>{let h=s?.plan.mode==="full-project",y=s?.dependencyGraphUnchanged===!0;h?e.onStatus("Rebuilding compiler-derived runtime-boundary relationships while retaining unchanged per-file extraction facts."):y&&e.onStatus("Reusing runtime-boundary relationships because TypeScript semantics are unchanged."),await Qt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,y,y?void 0:h?s?.changedFiles:s?.affectedFiles,F(x(e.paths.outputDb),kn),h)});let g=E("reindex.publish.sqlite-layout",()=>jt(e.tempPaths.tempOutputDb,{analyze:jc(s,l.mode)}));g.added.length>0&&e.onStatus(`Added SQLite query indexes: ${g.added.join(", ")}`),g.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${g.removed.join(", ")}`),E("reindex.publish.coverage",()=>sa(e,e.tempPaths.tempOutputDb,n.map(h=>h.language)));let p,f=null;l.mode==="incremental"&&s&&E("reindex.publish.reference-fragments",()=>{if(s.dependencyGraphUnchanged){let m=new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});try{f=mt(m),e.onStatus("Preserved exact TypeScript reference fragments and dependency relationships because only trivia changed.")}finally{m.close()}return}let h=null,y=null;try{h=E("reindex.publish.reference-fragments.open-candidate",()=>new $({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip})),y=E("reindex.publish.reference-fragments.open-evidence",()=>new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip})),p=s.dependencyGraphSnapshot?E("reindex.publish.reference-fragments.dependency-graph",()=>An(h,s.dependencyGraphSnapshot,s.affectedFiles,s.deletedFiles))??void 0:void 0;let m=new Set(s.deletedFiles),w=m.size===0?s.referenceFragmentsByFile:new Map([...s.referenceFragmentsByFile].filter(([P])=>!m.has(P))),S=E("reindex.publish.reference-fragments.seed",()=>$n(h,e.fingerprint,w,y,p,new Set(s.affectedFiles)));e.onStatus(`Cached exact TypeScript reference fragments for ${S.affectedFiles} affected document(s) and carried ${S.carriedFiles} unaffected document(s) forward.`),S.skippedAffectedFiles>0&&e.onStatus(`Skipped exact TypeScript reference fragment prefill for ${S.skippedAffectedFiles} affected document(s) whose semantic identity was unavailable.`)}catch(m){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${m instanceof Error?m.message:String(m)}.`)}finally{h?.close(),y?.close()}});let R=nt(e.paths.metaPath),T=E("reindex.publish.affected-shadow",()=>l.mode==="incremental"&&s?Wc(s,l.changedDocumentPaths):It({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:R,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"})),j=at({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(h=>h.language),skipped:[...r]}),D=l.mode==="incremental"&&l.scipCompanion==="deferred",{metadata:v,pruneProjects:O}=aa({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:j});v.scipCompanion=D?"deferred":"current",E("reindex.publish.metadata",()=>{oa(e),ca(e.paths.outputDb,O),it(e.tempPaths.tempMetaPath,v)});let _=E("reindex.publish.generation-handoff",()=>ir({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}));return _.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${_.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),l.mode==="incremental"&&s&&E("reindex.publish.dependency-graph",()=>{let h=null;try{h=new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let y=s.plan.mode==="full-project"&&s.plan.reasons.length===0?s.changedFiles:s.affectedFiles,m=!1;if(s.dependencyGraphUnchanged){let w=mt(h),S=f&&w?Dn(h,"file-dependency-graph",f,w):0;m=S>0,e.onStatus(m?`Carried ${S} unchanged dependency graph product(s) forward without rebuilding them.`:"No persisted dependency graph product required rekeying; the next graph consumer can materialize it.")}else s.dependencyGraphSnapshot?m=Ln(h,s.dependencyGraphSnapshot,y,p):Oe(h);s.dependencyGraphUnchanged||e.onStatus(m?`Carried the dependency graph forward by replacing ${y.length} changed dependency owner(s).`:"Materialized a fresh dependency graph for the accepted generation because no compatible prior graph was available.")}catch(y){e.onStatus(`Dependency graph carry-forward unavailable: ${y instanceof Error?y.message:String(y)}. The next graph consumer will rebuild it.`)}finally{h?.close()}}),E("reindex.publish.cleanup",()=>{rr(x(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),er(x(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[])}),E("reindex.publish.shadow-telemetry",()=>ia(e.paths.outputDb,T,e.onStatus)),j}function jc(e,t){return t!=="incremental"||!e||e.plan.mode==="full-project"?!0:e.affectedFiles.length*20>=e.projectFileCount}async function Fc(e,t,n,r,a,i){let o=nt(e.paths.metaPath),s=null;try{K(e.writeTelemetry,Q(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=jr("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}Me(ke(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await Qt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=jt(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),sa(e,e.paths.outputDb,t.map(p=>p.language)),s??=It({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=at({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:g}=aa({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:a,typescriptProjectShardContext:i,lastRefresh:d});return oa(e),ca(e.paths.outputDb,g),it(e.paths.metaPath,l),Le(e.paths.outputDb,e.paths.metaPath),ia(e.paths.outputDb,s,e.onStatus),d}function nt(e){return st(ne(e)?.fingerprint)}function ia(e,t,n){try{Fr(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function aa(e){let t=Oc({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:ae,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function oa(e){A(e.opts.signal,"Reindex cancelled by its owner.");let t=vn(e.projectRoot,e.fingerprint);if(N(t)===N(e.fingerprint))return;let n=new Map(e.fingerprint.files.map(i=>[i.path,i])),r=new Map(t.files.map(i=>[i.path,i])),a=[...new Set([...n.keys(),...r.keys()])].filter(i=>N(n.get(i))!==N(r.get(i))).slice(0,5);throw new Error(`Project inputs changed during reindex (${a.join(", ")||"unknown path"}); refusing to publish artifacts built from a different filesystem snapshot.`)}function sa(e,t,n){let r=Ne(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${Kt("Candidate SQLite index",r)} Refusing to publish it.`)}function Kt(e,t){if(t.state==="unavailable")return`${e} document coverage could not be verified (${t.reason}); rebuilding cached language shards.`;let n=t.missingPaths.length>0?` First missing path: ${t.missingPaths[0]}.`:"";return`${e} is missing ${t.missingDocumentCount} fingerprinted source document${t.missingDocumentCount===1?"":"s"}; rebuilding affected language shards.${n}`}function Oc(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=ne(e.metaPath),n=t?.version===ae?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function ca(e,t){let n=ya(e);if(t===null){V(n,{recursive:!0,force:!0});return}let r;try{r=ta(n)}catch{return}for(let a of kc(r,t))V(F(n,a),{force:!0})}function kc(e,t){let n=new Set(t.map(r=>`${Dt(r)}.scip`));return e.filter(r=>!n.has(r))}function Dc(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(o=>o.language==="typescript");if(!t)return[...e.indexedOutputs];if(!e.typescriptReused)return[...e.indexedOutputs];let n=q(e.run.paths.outputDb,e.run.paths.metaPath),r=n.state==="current"?n.generation.publication?.typescriptOverlayGeneration:void 0;if(!(n.state==="current"?n.generation.publication?.scipCompanion==="deferred":ne(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let i=te(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),qt({cacheDir:x(e.run.paths.outputDb),generationIdentity:r,baseShardPath:t.scipPath,candidateShardPath:i}),e.indexedOutputs.map(o=>o.language==="typescript"?{language:o.language,scipPath:i}:o)}function Xi(e,t,n){for(let r of t){let a=Zt(e,r.language);et(x(a),{recursive:!0}),r.scipPath!==a&&K(n,Q(r.scipPath,a))}}async function Mc(e,t){if(!ut()){if(dc()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
232
291
|
To install the reviewed version, run: scip-query reindex --install-missing
|
|
233
|
-
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!
|
|
234
|
-
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function
|
|
292
|
+
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!mn(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
293
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Nc(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?te(e.tempOutputScip,i,o):e.tempOutputScip})),a=Object.fromEntries(r.map(({language:i,scipPath:o})=>[i,o]));for(let{language:i,scipPath:o}of r){let s=Lc({...e,language:i,scipPath:o});for(let c of s)"skipped"in c?da(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:a}}function Lc(e){if(e.language!=="typescript")return[Ze({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.typescriptProjectMode==="workspace",n=t?e.preDiscoveredTypeScriptProjects??z(e.projectRoot,e.typescriptProjects):["."];return n.length===0?[Ze({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(t&&e.onStatus(`Indexing TypeScript workspace as ${n.length} project shard(s).`),n.flatMap((r,a)=>{let i=t?`typescript:${r}`:"typescript",o=t?`typescript (${r})`:"typescript",s=t?te(e.tempOutputScip,"typescript-project",a):e.scipPath,c={...e,id:i,label:o,scipPath:s,outputScipPath:e.scipPath,pnpmWorkspaces:!1};if(!t&&r==="."&&!e.pnpmWorkspaces){let d=$c(e,c);if(d)return d}return[Ze({...c,...t?{projectPath:r}:{}})]}))}function Ac(e,t,n,r){let a=n.filter(s=>s.shardInputPaths!==void 0);if(a.length===0)return;let i=new Map(r.filter(s=>!s.skipped).map(s=>[s.id,s.durationMs])),o=[];for(let s of a){let c=i.get(s.id);if(c===void 0||!(c>0))return;o.push({inputPaths:s.shardInputPaths,durationMs:c})}try{let s=Si(o,c=>{try{return Yt(F(t,c)).size}catch{return 1}});s&&hi(e,s)}catch{}}function $c(e,t){let n=At(),r=gt(e.projectRoot,"single");if(!r||!ui(r.size,n))return null;Pi(e.projectRoot);let a=bi(),i=pi(r.size,n,a),o=e.typescriptShardCostDir?mi(e.typescriptShardCostDir):null,s=yi(o),c=gi({projectRoot:e.projectRoot,rootConfigPath:"tsconfig.json",inputPaths:[...r],targetFiles:n,shardCount:i,weightOf:l=>{let g=1;try{g=Yt(F(e.projectRoot,l)).size}catch{}return s(l,g)}}),d=Math.min(a,c.length);return e.onStatus(`Indexing ${r.size} TypeScript inputs as ${c.length} ${o?"cost-balanced":"byte-balanced"} compiler shard(s), ${d} at a time.`),c.map((l,g)=>Ze({...t,id:`typescript-compiler-shard:${g}`,label:`typescript compiler shard ${g+1}/${c.length}`,scipPath:te(e.tempOutputScip,"typescript-compiler-shard",g),projectPath:l.configPath,temporaryProjectConfigs:[{path:l.configPath,content:l.content}],boundedConcurrency:d,outputComposition:"protobuf-concatenate",shardInputPaths:l.inputPaths}))}function Ze(e){let t=vt(e.language),n=Ce(t),r=wn(t,e.projectRoot),a=e.trustProjectTools&&r?Cn(t,e.projectRoot):null,i=he(t);if(!a&&!i&&r){let l=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(!a&&!i&&!Tn(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!qi(t,e.onStatus)){let l=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}}let o=a?.canonicalPath??he(t);if(!o){let l=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),d=Ar({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(a&&!a.executable){let l=`${a.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}return a&&e.onStatus(`Trusted project-local ${e.language} indexer ${a.relativePath} (${a.sha256.slice(0,12)}\u2026, ${a.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:o,binary:s,args:c,env:Fn(t,e.env,o),...d===void 0?{}:{temporaryRootConfigContent:d},...e.temporaryProjectConfigs===void 0?{}:{temporaryProjectConfigs:e.temporaryProjectConfigs},...e.boundedConcurrency===void 0?{}:{boundedConcurrency:e.boundedConcurrency},...e.outputComposition?{outputComposition:e.outputComposition}:{},...e.shardInputPaths===void 0?{}:{shardInputPaths:e.shardInputPaths},...a?{trustedProjectTool:a}:{}}}}function Gc(e,t){let n=new Set(e.filter(i=>i.skipped&&i.outputComposition).map(i=>`${i.language}\0${i.outputScipPath}`)),r=new Map;for(let i of e)if(i.skipped)da(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`;if(n.has(o))continue;let s=r.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[],concatenate:!0};s.scipPaths.push(i.scipPath),i.outputComposition!=="protobuf-concatenate"&&(s.concatenate=!1),r.set(o,s)}let a=[];for(let i of r.values())if(i.scipPaths.length>1)i.concatenate?Yn(i.scipPaths,i.outputScipPath):Xn(i.scipPaths,i.outputScipPath),a.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&na(o,i.outputScipPath),a.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:a}}function da(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function Bc(e,t,n,r,a){if(e.length===0){let i=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
235
294
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
236
295
|
`+i)}if(t.length!==0&&(a(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(i=>i.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
237
296
|
`+t.map(i=>` - ${i.language}: ${i.reason}`).join(`
|
|
238
|
-
`))}function Dr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),a=un(e.map(i=>i.scipPath),t);return Hr(a,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Cr(e[0].scipPath,t);return!1}async function ko(e){let t;if(Oo(e)){let a=E(e.run.tempPaths.runDir,"typescript-affected.db");try{Jr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let i=performance.now();await kr(e.incrementalTypeScript.affectedScipPath,a,e.env,e.run.onStatus,!0,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-i).toFixed(0)}ms.`);let o=ar({previousDbPath:e.run.paths.outputDb,miniDbPath:a,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles,writeTelemetry:e.run.writeTelemetry});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-i,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(i){j(e.run.opts.signal,"Reindex cancelled by its owner."),t=i instanceof Error?i.message:String(i),Q(a,{force:!0}),Q(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await kr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Oo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!w(e.run.paths.outputDb)||!w(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function Ao(e,t){let n=P(),r=[...t].sort(),a=new Set(r),i={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!a.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:P()-n,manifest:e.manifest,plan:e.plan,comparison:i,evaluation:Ke(e.plan,i,e.projectFileCount)}}async function kr(e,t,n,r,a=!1,i){if(j(i,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!w(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{a||Jr(e,r);let o=$e();if(!o)throw new Error("scip CLI is not available");let s=await ce({command:o,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:i});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}catch(o){j(i,"Reindex cancelled by its owner.");let s=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:o})}}function Jr(e,t){let n=dn(e);Hr(n,t)}function Hr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Y(e,t,n){let r=no(e)||".scip",a=Te(e,r);return E(h(e),`${a}.${n+1}.${t}${r}`)}async function Mo(e,t){for(let n=0;n<2;n++){let r=Lo(e,t);if(r)return r;let a=Co(e);if(a&&Qr(t.trigger,a)){t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}.`);let i;try{i=await $o(a)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${a.pid}); refusing to steal an active lock: ${q(s)}`,{cause:s})}if(!i)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${a.pid}) terminated for ${h(e)}; refusing to steal an active lock.`);let o=Ge(e,{parseLegacy:De});if(!$t(e,o,{parseLegacy:De}))throw new Error(`Reindex lock ownership changed before preemption completed for ${h(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${h(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${h(e)}.`)}function Lo(e,t){let n=L(process.pid),r=Nt(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:De});if(r.kind==="acquired"&&r.reclaimed){let a=zr(r.reclaimed,e);a&&Qr(t.trigger,a)?t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${h(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Co(e){return zr(Ge(e,{parseLegacy:De}),e)}var De=e=>{let t=Xr(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function zr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Xr(e.parsed,t)}function Xr(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=se(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Qr(e,t){return e?.kind==="manual-cli"&&No(t?.trigger)}function No(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function $o(e){return!H(e.pid)||(St(e),Or(e,"SIGTERM"),await Ar(e,2e3))?!0:(St(e),Or(e,"SIGKILL"),Ar(e,1e3))}function Or(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!H(e.pid))return;St(e)}try{process.kill(e.pid,t)}catch{}}async function Ar(e,t){let n=P()+t;for(;P()<n;){if(Mr(e))return!0;await Go(50)}return Mr(e)}function St(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=L(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!G(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Mr(e){if(!H(e.pid))return!0;if(!e.processIdentity)return!1;let t=L(e.pid);return t!==null&&!G(e.processIdentity,t)}function Go(e){return new Promise(t=>setTimeout(t,e))}function Vr(e,t,n){return Object.fromEntries(t.map(r=>{let a=r==="typescript"?Ut(n.typescriptProjects):[],i=r==="clojure"?Uo(n.clojureConfigPath):void 0,o=[...et(r).markerFiles,...a,...i?[i]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:a}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Bo(n),...s,clojureConfigPath:i,files:e.files.filter(c=>jt(c.path,r,o))}]}))}function Uo(e){return e?.trim()||void 0}function Bo(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function xt(e,t){return E(h(e),"language-indexes",`${t}.scip`)}function Yr(e){return E(h(e),"language-indexes","typescript-projects")}function Oe(e,t){return E(Yr(e),`${st(t)}.scip`)}function J(e){try{return Me(le(oe(e,"reindex metadata")))}catch{return null}}function Kr(e,t){try{let n=le(oe(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&Ft(r)&&T(r.fingerprint)===T(t)&&T([...r.indexedLanguages??[]].sort())===T(t.languages)}catch{return!1}}function Rt(e,t){Qt(e,t,{spacing:2,trailingNewline:!0})}function Zr(e,t){try{let n=Me(le(oe(e,"reindex metadata")));if(!n)return;Rt(e,{...n,lastRefresh:t})}catch{}}function Ae(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:P()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function T(e){return JSON.stringify(e)}var Wo={readIdentity:L,setInterval(e,t){let n=setInterval(e,t);return n.unref(),n},clearInterval};function ea(e,t,n={}){let r=n.runtime??Wo,a=n.intervalMs??1e3;if(!Number.isSafeInteger(a)||a<=0)throw new TypeError("parent process monitor interval must be a positive safe integer");let i=!0,o,s=()=>{if(!i)return;let c=r.readIdentity(e.pid);c&&G(e,c)||(i=!1,o&&r.clearInterval(o),t(c?`parent process ${e.pid} changed identity`:`parent process ${e.pid} exited`))};return s(),i&&(o=r.setInterval(s,a)),{stop(){i&&(i=!1,o&&r.clearInterval(o))}}}var aa=process.env.SCIP_REINDEX_PROJECT_ROOT,ia=process.env.SCIP_REINDEX_OUTPUT_SCIP,oa=process.env.SCIP_REINDEX_OUTPUT_DB,ta=process.env.SCIP_REINDEX_LANGUAGES,qo=Ln(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),Jo=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",na=is(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Ho=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,zo=as(process.env.SCIP_REINDEX_TRIGGER_KIND),Xo=process.env.SCIP_REINDEX_TRIGGER_DETAIL,Qo=Cn(process.env.SCIP_REINDEX_CHANGE_JOURNAL),Vo=process.env.SCIP_REINDEX_ALLOW_EXPENSIVE!=="0",sa=rs(process.env.SCIP_REINDEX_PARENT_IDENTITY);(!aa||!ia||!oa||!sa)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var Yo=aa,Ko=ia,Zo=oa,es=sa,ra=ta?ta.split(",").filter(Boolean):void 0,ca=new AbortController,ts=ea(es,e=>{ca.abort(new Error(`Reindex worker owner lost: ${e}`))});ns();async function ns(){try{await Nr({projectRoot:Yo,outputScip:Ko,outputDb:Zo,languages:ra?.length?ra:void 0,pnpmWorkspaces:Jo,typescriptProjectMode:na.projectMode,typescriptProjects:na.projects,clojureConfigPath:Ho,indexerConcurrency:qo,trigger:{kind:zo,detail:Xo||void 0},changeJournal:Qo,allowExpensiveRebuild:Vo,signal:ca.signal,onStatus:e=>process.stderr.write(`[reindex] ${Qe(e)}
|
|
239
|
-
`)})}catch(e){console.error(`reindex-worker error: ${
|
|
297
|
+
`))}function Yi(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),a=Qn(e.map(i=>i.scipPath),t);return ua(a,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&na(e[0].scipPath,t);return!1}async function Uc(e){let t;if(qc(e))try{let a=e.incrementalTypeScript.affectedBatches.length>0?e.incrementalTypeScript.affectedBatches:[{scipPath:e.incrementalTypeScript.affectedScipPath,affectedFiles:e.incrementalTypeScript.affectedFiles,deletedFiles:e.incrementalTypeScript.deletedFiles}],i=new Set,o=0,s=0;for(let[c,d]of a.entries()){let l=F(e.run.tempPaths.runDir,`typescript-affected-${c}.db`);la(d.scipPath,e.run.onStatus),e.run.onStatus(`Converting bounded TypeScript batch ${c+1}/${a.length} (${d.affectedFiles.length-d.deletedFiles.length} emitted, ${d.deletedFiles.length} removed) to SQLite...`);let g=performance.now();await Qi(d.scipPath,l,e.env,e.run.onStatus,!0,e.run.opts.signal),o+=performance.now()-g,Be(e.run.writeTelemetry,ee(l)??0);let p=qr({previousDbPath:e.run.paths.outputDb,miniDbPath:l,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:d.affectedFiles,deletedFiles:d.deletedFiles,reuseCandidate:c>0,deferIntegrity:c<a.length-1,trustedPriorGeneration:!0,writeTelemetry:e.run.writeTelemetry});s+=p.durationMs;for(let f of p.changedDocumentPaths)i.add(f);V(l,{force:!0})}return e.run.onStatus(`Patched ${e.incrementalTypeScript.affectedFiles.length} SQLite document path(s) across ${a.length} bounded batch(es) in ${(s/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:[...i].sort(),patchDurationMs:s,converterDurationMs:o,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){if(A(e.run.opts.signal,"Reindex cancelled by its owner."),t=a instanceof Error?a.message:String(a),V(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.opts.allowExpensiveRebuild===!1)throw new Error(`Bounded incremental SQLite publication failed and the whole-project fallback is disabled: ${t}`,{cause:a});e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await Qi(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function qc(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!L(e.run.paths.outputDb)||!L(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function Wc(e,t){let n=C(),r=[...t].sort(),a=new Set(r),i={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!a.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:C()-n,manifest:e.manifest,plan:e.plan,comparison:i,evaluation:Et(e.plan,i,e.projectFileCount)}}async function Qi(e,t,n,r,a=!1,i){if(A(i,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!L(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{if(a||la(e,r),n.SCIP_QUERY_SQLITE_CONVERTER==="scip-cli"){let o=ut();if(!o)throw new Error("scip CLI is not available");let s=await Ie({command:o,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:i});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}else V(t,{force:!0}),await di(re(e,{maxBytes:xe,inputKind:"SCIP index"}),t,{signal:i})}catch(o){A(i,"Reindex cancelled by its owner.");let s=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:o})}}function la(e,t){let n=zn(e);ua(n,t)}function ua(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function te(e,t,n){let r=cc(e)||".scip",a=Ve(e,r);return F(x(e),`${a}.${n+1}.${t}${r}`)}async function Hc(e,t){for(let n=0;n<2;n++){let r=Jc(e,t);if(r)return r;let a=zc(e);if(a&&fa(t.trigger,a)){t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}.`);let i;try{i=await Xc(a)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${a.pid}); refusing to steal an active lock: ${Z(s)}`,{cause:s})}if(!i)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${a.pid}) terminated for ${x(e)}; refusing to steal an active lock.`);let o=pt(e,{parseLegacy:tt});if(!bn(e,o,{parseLegacy:tt}))throw new Error(`Reindex lock ownership changed before preemption completed for ${x(e)}.`);continue}throw new le(`Another scip-query reindex is already running for ${x(e)}.`)}throw new le(`Could not acquire scip-query reindex lock for ${x(e)}.`)}function Jc(e,t){let n=U(process.pid),r=Sn(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:tt});if(r.kind==="acquired"&&r.reclaimed){let a=pa(r.reclaimed,e);a&&fa(t.trigger,a)?t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${x(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function zc(e){return pa(pt(e,{parseLegacy:tt}),e)}var tt=e=>{let t=ga(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function pa(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:x(t),startedAt:e.record.startedAt,trigger:n.trigger}}return ga(e.parsed,t)}function ga(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=Ee(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:x(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function fa(e,t){return e?.kind==="manual-cli"&&ma(t?.trigger)}function ma(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function Xc(e){return!oe(e.pid)||(Xt(e),Ki(e,"SIGTERM"),await Vi(e,2e3))?!0:(Xt(e),Ki(e,"SIGKILL"),Vi(e,1e3))}function Ki(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!oe(e.pid))return;Xt(e)}try{process.kill(e.pid,t)}catch{}}async function Vi(e,t){let n=C()+t;for(;C()<n;){if(Zi(e))return!0;await Yc(50)}return Zi(e)}function Xt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=U(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!J(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Zi(e){if(!oe(e.pid))return!0;if(!e.processIdentity)return!1;let t=U(e.pid);return t!==null&&!J(e.processIdentity,t)}function Yc(e){return new Promise(t=>setTimeout(t,e))}function Vt(e,t,n){return Object.fromEntries(t.map(r=>{let a=r==="typescript"?En(n.typescriptProjects):[],i=r==="clojure"?Kc(n.clojureConfigPath):void 0,o=[...vt(r).markerFiles,...a,...i?[i]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:a}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Vc(n),...s,clojureConfigPath:i,files:e.files.filter(c=>cn(c.path,r,o)).map(c=>ha(c,r))}]}))}function ha(e,t){let n=t==="typescript"&&/(?:^|\/)package\.json$/iu.test(e.path)?e.semanticHash:void 0;return{path:e.path,size:n===void 0?e.size:0,hash:n??e.hash}}function Qc(e,t){let n=st(t);if(!n)return t;let r=n.typescriptProjectMode==="workspace"?z(e,n.typescriptProjects):["."],a=se(r);return{...n,files:n.files.filter(i=>!ce(i.path)||a.has(i.path)).map(i=>{let o=i.semanticHash??Te(e,i.path,i.hash);return ha(o===void 0?i:{...i,semanticHash:o},"typescript")})}}function Kc(e){return e?.trim()||void 0}function Vc(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Zt(e,t){return F(x(e),"language-indexes",`${t}.scip`)}function ya(e){return F(x(e),"language-indexes","typescript-projects")}function rt(e,t){return F(ya(e),`${Dt(t)}.scip`)}function ne(e){try{return _e(me(fe(e,"reindex metadata")))}catch{return null}}function Sa(e,t){try{let n=me(fe(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return null;let r=n.metadata;return!n.capabilities.publishableGeneration||!ln(r)||N([...r.indexedLanguages??[]].sort())!==N(t.languages)?null:N(r.fingerprint)===N(t)?"exact":N(ea(r.fingerprint))===N(ea(t))?"operational-config-compatible":null}catch{return null}}function ea(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t=e;return Array.isArray(t.files)?{...t,files:t.files.filter(n=>typeof n!="object"||n===null||Array.isArray(n)||n.path!==".scipquery.json")}:e}function Zc(e,t,n,r){let a=_e(me(fe(e,"reindex metadata")));a&&it(e,{...a,fingerprint:t,...a.version===ae?{languageFingerprints:Vt(t,n,r)}:{}})}function it(e,t){On(e,t,{spacing:2,trailingNewline:!0})}function ba(e,t){try{let n=_e(me(fe(e,"reindex metadata")));if(!n)return;it(e,{...n,lastRefresh:t})}catch{}}function at(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:C()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function N(e){return JSON.stringify(e)}var ed={readIdentity:U,setInterval(e,t){let n=setInterval(e,t);return n.unref(),n},clearInterval};function Pa(e,t,n={}){let r=n.runtime??ed,a=n.intervalMs??1e3;if(!Number.isSafeInteger(a)||a<=0)throw new TypeError("parent process monitor interval must be a positive safe integer");let i=!0,o,s=()=>{if(!i)return;let c=r.readIdentity(e.pid);c&&J(e,c)||(i=!1,o&&r.clearInterval(o),t(c?`parent process ${e.pid} changed identity`:`parent process ${e.pid} exited`))};return s(),i&&(o=r.setInterval(s,a)),{stop(){i&&(i=!1,o&&r.clearInterval(o))}}}var Ea=process.env.SCIP_REINDEX_PROJECT_ROOT,Ia=process.env.SCIP_REINDEX_OUTPUT_SCIP,va=process.env.SCIP_REINDEX_OUTPUT_DB,Ra=process.env.SCIP_REINDEX_LANGUAGES,nd=xr(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),rd=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",en=yd(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),id=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,ad=hd(process.env.SCIP_REINDEX_TRIGGER_KIND),od=process.env.SCIP_REINDEX_TRIGGER_DETAIL,sd=Er(process.env.SCIP_REINDEX_CHANGE_JOURNAL),cd=process.env.SCIP_REINDEX_ALLOW_EXPENSIVE!=="0",_a=md(process.env.SCIP_REINDEX_PARENT_IDENTITY);(!Ea||!Ia||!va||!_a)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var dd=Ea,ld=Ia,ud=va,pd=_a,xa=Ra?Ra.split(",").filter(Boolean):void 0,Ta=new AbortController,gd=Pa(pd,e=>{Ta.abort(new Error(`Reindex worker owner lost: ${e}`))});fd();async function fd(){try{await ra({projectRoot:dd,outputScip:ld,outputDb:ud,languages:xa?.length?xa:void 0,pnpmWorkspaces:rd,typescriptProjectMode:en.projectMode,typescriptProjects:en.projects,maxHeapMb:en.maxHeapMb,clojureConfigPath:id,indexerConcurrency:nd,trigger:{kind:ad,detail:od||void 0},changeJournal:sd,allowExpensiveRebuild:cd,signal:Ta.signal,onStatus:e=>process.stderr.write(`[reindex] ${Pt(e)}
|
|
298
|
+
`)})}catch(e){console.error(`reindex-worker error: ${Pt(String(e))}`),process.exitCode=e instanceof le?75:1}finally{gd.stop()}}function md(e){if(!e)return null;try{return Ee(JSON.parse(e))}catch{return null}}function hd(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function yd(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,a=Array.isArray(n.projects)?n.projects.filter(o=>typeof o=="string"&&o.trim()!==""):void 0,i=typeof n.maxHeapMb=="number"&&Number.isInteger(n.maxHeapMb)&&n.maxHeapMb>0?n.maxHeapMb:void 0;return{projectMode:r,projects:a&&a.length>0?a:void 0,maxHeapMb:i}}catch{return{}}}
|
|
240
299
|
//# sourceMappingURL=reindex-worker.js.map
|