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
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
var gu=Symbol.for("scip-query.project-file-listing-context.v1"),yu=globalThis,Us=yu[gu],G=Us&&typeof Us=="object"?Us:{};yu[gu]=G;function ED(e){if(G.active)return e();let t=G.active,n=G.canonicalProjectRoots;G.active=new Map,G.canonicalProjectRoots=new Map;try{return e()}finally{G.active=t,G.canonicalProjectRoots=n}}function RD(){let e=G.active,t=G.canonicalProjectRoots;G.active=new Map,G.canonicalProjectRoots=new Map;let n=!1;return()=>{n||(n=!0,G.active=e,G.canonicalProjectRoots=t)}}function hu(e,t){let n=G.active?G.canonicalProjectRoots:void 0,r=n?.get(e);if(r!==void 0)return r;let i=t();return n?.set(e,i),i}function Su(){return G.sequence??0}function Hi(e,t,n){let r=G.active,i=r?.get(e);if(i&&i.pathBytes<=t)return i;let o=Oh(n(),(G.sequence??0)+1);if(G.sequence=o.sequence,o.pathBytes>t)throw new RangeError(`Git project file listing exceeded ${t} path bytes.`);return r?.set(e,o),o}function bu(e,t){let n=G.active?.get(e);return n&&n.sequence>t?n.indexAllowsTreeFingerprintReuse:void 0}function*Wi(e){let t=0;for(;t<e.taggedOutput.length;){let n=e.taggedOutput.indexOf("\0",t);if(n<0)return;yield e.taggedOutput.slice(t+2,n),t=n+1}}function Oh(e,t){let n=0,r=0,i=!0;for(;n<e.length;){let o=e.indexOf("\0",n);if(o<0||o<=n+2||e[n+1]!==" ")throw new Error("Git returned a malformed tagged project file listing.");let s=e[n];i&&=s==="H"||s==="?",r+=1,n=o+1}return{taggedOutput:e,pathBytes:Buffer.byteLength(e,"utf8")-r*2,indexAllowsTreeFingerprintReuse:i,sequence:t}}import{createRequire as Mh}from"module";var jh=Mh(import.meta.url),qi=Bh().version;function Bh(){for(let e of["../package.json","../../package.json"])try{return jh(e)}catch{}return{version:"0.0.0"}}import{createHash as Zh}from"crypto";import{existsSync as eS,mkdirSync as tS}from"fs";import{dirname as ju,join as nS}from"path";import Ys from"better-sqlite3";function jt(e,t,n=[]){let r=Ks(e);if(Pu.has(r)||n.some(o=>zi(r,o))||t.some(o=>wu(r,o)))return"config";if(t.some(Fu)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return"ambient";let i=Cu(r);return t.some(o=>(Tu[o]??[]).includes(i))?"source":"other"}function Ru(e,t,n){let r=Ks(e);if(Pu.has(r)||n?.some(o=>zi(r,o))||wu(r,t)||Fu(t)&&/\.d\.(?:ts|mts|cts)$/.test(r.toLowerCase()))return!0;let i=Cu(r);return(Tu[t]??[]).includes(i)}function Rr(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.version!="number"||!xu(t.languages)||typeof t.pnpmWorkspaces!="boolean"||typeof t.typescriptProjectMode!="string"||!xu(t.typescriptProjects)||t.clojureConfigPath!==void 0&&typeof t.clojureConfigPath!="string"||!Array.isArray(t.files)||!t.files.every(zs)?null:t}function Ui(e){return{...e,files:e.files.map(({semanticHash:t,...n})=>n)}}function Pr(e,t){return!e||!t?e===t:JSON.stringify(Ui(e))===JSON.stringify(Ui(t))}function FD(e,t){let n=new Map((e?.files??[]).map(a=>[a.path,a])),r=new Map(t.files.map(a=>[a.path,a])),i=new Set([...n.keys(),...r.keys()]),o=[];for(let a of[...i].sort()){let c=n.get(a),l=r.get(a),u=jt(a,t.languages);!c&&l?o.push({kind:"added",path:a,inputKind:u,after:l}):c&&!l?o.push({kind:"deleted",path:a,inputKind:u,before:c}):c&&l&&(c.hash!==l.hash||c.size!==l.size)&&o.push({kind:"modified",path:a,inputKind:u,before:c,after:l})}let s=new Set;return e||s.add("prior-snapshot-unavailable"),e&&e.version!==t.version&&s.add("snapshot-version-changed"),(vu(e?.files??[])||vu(t.files))&&s.add("duplicate-input-path"),[...e?.files??[],...t.files].some($h)&&s.add("unreadable-input"),{version:1,changes:o,projectIdentityChanged:e?!Gh(e,t):!0,uncertainty:[...s].sort()}}function xu(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function vu(e){return new Set(e.map(t=>t.path)).size!==e.length}function zs(e){if(typeof e!="object"||e===null)return!1;let t=e;return typeof t.path=="string"&&typeof t.size=="number"&&Number.isFinite(t.size)&&typeof t.hash=="string"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}function $h(e){return e.hash==="unreadable"||e.size<0}function Gh(e,t){return Iu(e.languages,t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&Iu(e.typescriptProjects,t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function Iu(e,t){if(e.length!==t.length)return!1;let n=[...e].sort(),r=[...t].sort();return n.every((i,o)=>i===r[o])}var Pu=new Set([".scipquery.json"]),Vh={typescript:["tsconfig.json"],javascript:["package.json"],java:["pom.xml","build.gradle"],scala:["build.sbt"],kotlin:["build.gradle.kts"],rust:["Cargo.toml"],python:["pyproject.toml","setup.py"],ruby:["Gemfile"],go:["go.mod"],cpp:["CMakeLists.txt","Makefile"],c:["CMakeLists.txt","Makefile"],csharp:["*.csproj","*.sln"],vb:["*.vbproj","*.sln"],dart:["pubspec.yaml"],php:["composer.json"],clojure:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"]},Hh={typescript:["package.json","package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],javascript:["package-lock.json","pnpm-lock.yaml","yarn.lock","bun.lock","bun.lockb","tsconfig.json","tsconfig.*.json","jsconfig.json","jsconfig.*.json"],java:["build.gradle.kts","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],scala:["plugins.sbt","build.properties"],kotlin:["pom.xml","build.gradle","settings.gradle","settings.gradle.kts","gradle.properties","gradle.lockfile","gradle-wrapper.properties"],rust:["Cargo.lock","rust-project.json","rust-toolchain","rust-toolchain.toml"],python:["setup.cfg","requirements*.txt","Pipfile","Pipfile.lock","poetry.lock","uv.lock"],ruby:["Gemfile.lock","gems.locked"],go:["go.sum","go.work","go.work.sum"],cpp:["compile_commands.json"],c:["compile_commands.json"],csharp:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],vb:["Directory.Build.props","Directory.Build.targets","Directory.Packages.props","packages.lock.json","NuGet.Config","global.json"],dart:["pubspec.lock","analysis_options.yaml"],php:["composer.lock"],clojure:[]},Eu=new Map;function wu(e,t){return Vh[t].some(n=>zi(e,n))||Hh[t].some(n=>zi(e,n))}function zi(e,t){let n=Ks(t).replace(/^\.\//,"");if(!n)return!1;let r=e.split("/").at(-1)??e,i=n.includes("/")?e:r;if(!n.includes("*")&&!n.includes("?"))return i===n;let o=Eu.get(n);if(!o){let s=n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]");o=new RegExp(`^${s}$`),Eu.set(n,o)}return o.test(i)}function Ks(e){return e.replaceAll("\\","/").replace(/^\.\//,"")}function Cu(e){return e.includes(".")?`.${e.split(".").at(-1).toLowerCase()}`:""}function Fu(e){return e==="typescript"||e==="javascript"}var Tu={typescript:[".ts",".tsx",".mts",".cts"],javascript:[".js",".jsx",".mjs",".cjs",".vue"],java:[".java"],scala:[".scala"],kotlin:[".kt",".kts"],rust:[".rs"],python:[".py",".pyi"],ruby:[".rb"],go:[".go"],cpp:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"],c:[".c",".h"],csharp:[".cs"],vb:[".vb"],dart:[".dart"],php:[".php"],clojure:[".clj",".cljs",".cljc"]};function yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ki(e){return typeof e=="string"&&Number.isFinite(Date.parse(e))}function ND(e){return yt(e)&&Object.values(e).every(t=>typeof t=="string"||t===null)}function w(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function _D(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}var Wh=/^[a-f0-9]{64}$/u;function kD(e){return typeof e=="string"&&Wh.test(e)}function LD(e){return typeof e=="string"&&e.length>0&&e.length<=256&&!/[\0\r\n]/u.test(e)}function Nu(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0}var Ji=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],AD=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Js=2,sn=3;var Xs=new Set(Ji);function Bt(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${Yh(s)}`}}if(!yt(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let n=t.version;if(!Number.isInteger(n))return{kind:"malformed",reason:"version must be an integer"};if(n!==Js&&n!==sn)return{kind:"unsupported",version:n,direction:n<Js?"older":"future"};let r=Uh(t,n);if(r)return{kind:"malformed",reason:r};let i=t,o={metadata:i,capabilities:qh(i)};return n===Js?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function GD(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function _u(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===sn?t.sqliteLayoutVersion:void 0})}function qh(e){let t=e.fingerprint!==void 0,n=yt(e.fingerprint),r=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===sn?e:null;return{usableForQuery:r,usableForEvidenceCache:t,publishableGeneration:i&&n&&r,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function Uh(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Ki(e.updatedAt))return"updatedAt must be a valid timestamp";for(let n of["requestedLanguages","indexedLanguages"])if(e[n]!==void 0&&!zh(e[n]))return`${n} must contain unique supported languages`;return e.skipped!==void 0&&!Kh(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===sn&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===sn&&e.languageFingerprints!==void 0&&!Jh(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===sn&&e.typescriptProjectShards!==void 0&&!Xh(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function VD(e){return e.version===sn&&e.sqliteLayoutVersion===1}function zh(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Xs.has(t))?!1:new Set(e).size===e.length}function Kh(e){return Array.isArray(e)&&e.every(t=>yt(t)&&typeof t.language=="string"&&Xs.has(t.language)&&typeof t.reason=="string")}function Jh(e){return yt(e)&&Object.entries(e).every(([t,n])=>Xs.has(t)&&yt(n))}function Xh(e){return yt(e)&&Object.values(e).every(t=>yt(t)&&Array.isArray(t.files)&&t.files.every(zs))}function Yh(e){return e instanceof Error?e.message:String(e)}var ku=[];function Bn(e){e.groups.length>0&&ku.push(e)}function WD(e,t){let n=new Set(t.groups);for(let r of ku)r.groups.some(i=>n.has(i))&&(t.file!==void 0&&r.clearFile?r.clearFile(e,t.file):r.clearAll(e))}var Lu=256;function Du(e){let t=e.maxEntries;if(t!==void 0){if(!Number.isSafeInteger(t)||t<1)throw new Error(`Per-database cache maxEntries must be a positive safe integer; received ${t}.`);return t}return e.clearGroups.includes("source-file")?Lu:void 0}function Au(e,t,n){e.delete(t),e.set(t,n)}function Ou(e,t){if(t!==void 0)for(;e.size>t;){let n=e.keys().next().value;if(n===void 0)return;e.delete(n)}}function Mu(){let e=new WeakMap;return{cache:e,ensure(t){let n=e.get(t);return n||(n=new Map,e.set(t,n)),n}}}function C(e,t){let{cache:n,ensure:r}=Mu(),i=Du(t),o={get(s,a,c){let l=r(s);if(l.has(a)){let d=l.get(a);return Au(l,a,d),d}let u=c();return l.set(a,u),Ou(l,i),u},has(s,a){return n.get(s)?.has(a)??!1},invalidate(s,a){n.get(s)?.delete(a)},invalidateAll(s){n.delete(s)},size(s){return n.get(s)?.size??0}};return Bn({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}function rt(e,t){let n=new WeakMap,r={get(i,o){let s=n.get(i);if(s)return s.value;let a=o();return n.set(i,{value:a}),a},invalidate(i){n.delete(i)},has(i){return n.has(i)}};return Bn({name:e,groups:t.clearGroups,clearAll:i=>r.invalidate(i)}),r}var Qh={clearGroups:["whole-project","source-file"],maxEntries:Lu};function $t(e){return an(e,Qh)}function an(e,t){let{cache:n,ensure:r}=Mu(),i=Du(t),o={get(s,a,c,l){let u=r(s),d=u.get(a);if(d&&d.source===c)return Au(u,a,d),d.value;let p=l();return u.set(a,{source:c,value:p}),Ou(u,i),p},invalidate(s,a){n.get(s)?.delete(a)},invalidateAll(s){n.delete(s)}};return Bn({name:e,groups:t.clearGroups,clearAll:s=>o.invalidateAll(s),clearFile:(s,a)=>o.invalidate(s,a)}),o}var rS="evidence.db";var iS=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],Qs=new Set(iS),oS=25e4,sS=512*1024*1024,aS=6e4,Xi=new WeakMap,cS=C("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),lS=C("evidence-project-fingerprint",{clearGroups:["whole-project"]}),ve="evidence-v1",$n="version NOT LIKE 'evidence-%'";function U(e){return Zh("sha256").update(e).digest("hex")}function fe(e,t,n){return cS.get(e,t,()=>U(n))}function ht(e){return lS.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=Bt(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=t.metadata,r=[...n.indexedLanguages??[]].sort();return U(JSON.stringify({fingerprint:n.fingerprint,indexedLanguages:r,status:n.status}))}catch(t){return cn("project fingerprint unavailable",t),null}})}function cn(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function it(e){if(Xi.has(e))return Xi.get(e)??null;let t=null;try{let n=new Ys(e.config.evidenceDbPath??nS(ju(e.config.dbPath),rS));n.pragma("journal_mode = WAL"),n.pragma("busy_timeout = 5000"),n.pragma("synchronous = NORMAL"),n.exec(`
|
|
3
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
4
|
+
kind TEXT NOT NULL,
|
|
5
|
+
relative_path TEXT NOT NULL,
|
|
6
|
+
content_hash TEXT NOT NULL,
|
|
7
|
+
version TEXT NOT NULL,
|
|
8
|
+
payload TEXT NOT NULL,
|
|
9
|
+
PRIMARY KEY (kind, relative_path)
|
|
10
|
+
);
|
|
11
|
+
CREATE TABLE IF NOT EXISTS project_evidence (
|
|
12
|
+
kind TEXT NOT NULL,
|
|
13
|
+
cache_key TEXT NOT NULL,
|
|
14
|
+
project_fingerprint TEXT NOT NULL,
|
|
15
|
+
version TEXT NOT NULL,
|
|
16
|
+
payload TEXT NOT NULL,
|
|
17
|
+
PRIMARY KEY (kind, cache_key)
|
|
18
|
+
);
|
|
19
|
+
CREATE TABLE IF NOT EXISTS semantic_callees (
|
|
20
|
+
relative_path TEXT NOT NULL,
|
|
21
|
+
symbol TEXT NOT NULL,
|
|
22
|
+
content_hash TEXT NOT NULL,
|
|
23
|
+
deps_digest TEXT NOT NULL,
|
|
24
|
+
version TEXT NOT NULL,
|
|
25
|
+
payload TEXT NOT NULL,
|
|
26
|
+
PRIMARY KEY (relative_path, symbol)
|
|
27
|
+
);
|
|
28
|
+
CREATE TABLE IF NOT EXISTS semantic_references (
|
|
29
|
+
relative_path TEXT NOT NULL,
|
|
30
|
+
symbol TEXT NOT NULL,
|
|
31
|
+
project_fingerprint TEXT NOT NULL,
|
|
32
|
+
version TEXT NOT NULL,
|
|
33
|
+
payload TEXT NOT NULL,
|
|
34
|
+
PRIMARY KEY (relative_path, symbol)
|
|
35
|
+
);
|
|
36
|
+
`),t={evidence:n,shared:uS(e.config.sharedEvidenceDbPath),readFileEvidence:n.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:n.prepare(`SELECT payload FROM file_evidence
|
|
37
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${$n}
|
|
38
|
+
ORDER BY version DESC
|
|
39
|
+
LIMIT 1`),writeFileEvidence:n.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),rekeyFileEvidence:n.prepare("UPDATE file_evidence SET content_hash = ?, version = ? WHERE kind = ? AND relative_path = ? AND content_hash = ?"),readProjectEvidence:n.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:n.prepare(`SELECT payload FROM project_evidence
|
|
40
|
+
WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${$n}
|
|
41
|
+
ORDER BY version DESC
|
|
42
|
+
LIMIT 1`),writeProjectEvidence:n.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),rekeyProjectEvidenceKind:n.prepare("UPDATE project_evidence SET project_fingerprint = ?, version = ? WHERE kind = ? AND project_fingerprint = ?"),readCallees:n.prepare(`SELECT payload FROM semantic_callees
|
|
43
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:n.prepare(`SELECT payload FROM semantic_callees
|
|
44
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${$n}
|
|
45
|
+
ORDER BY version DESC
|
|
46
|
+
LIMIT 1`),readCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
47
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:n.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
48
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${$n}
|
|
49
|
+
ORDER BY symbol, version DESC`),writeCallees:n.prepare(`INSERT OR REPLACE INTO semantic_callees
|
|
50
|
+
(relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:n.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:n.prepare(`SELECT payload FROM semantic_references
|
|
51
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:n.prepare(`SELECT payload FROM semantic_references
|
|
52
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${$n}
|
|
53
|
+
ORDER BY version DESC
|
|
54
|
+
LIMIT 1`),readReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
|
|
55
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:n.prepare(`SELECT symbol, payload FROM semantic_references
|
|
56
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND ${$n}
|
|
57
|
+
ORDER BY symbol, version DESC`),writeReferences:n.prepare(`INSERT OR REPLACE INTO semantic_references
|
|
58
|
+
(relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:n.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?")}}catch(n){cn("disabled (open failed)",n)}return Xi.set(e,t),t}function ot(e,t,n){cn(`disabled (${t})`,n),Xi.set(e,null)}function uS(e){if(!e)return null;try{tS(ju(e),{recursive:!0});let t=new Ys(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
|
|
59
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
60
|
+
kind TEXT NOT NULL,
|
|
61
|
+
relative_path TEXT NOT NULL,
|
|
62
|
+
content_hash TEXT NOT NULL,
|
|
63
|
+
version TEXT NOT NULL,
|
|
64
|
+
payload TEXT NOT NULL,
|
|
65
|
+
last_accessed_at INTEGER NOT NULL,
|
|
66
|
+
PRIMARY KEY (kind, relative_path, content_hash, version)
|
|
67
|
+
);
|
|
68
|
+
CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
|
|
69
|
+
ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version);
|
|
70
|
+
`),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
|
|
71
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
72
|
+
ON CONFLICT(kind, relative_path, content_hash, version)
|
|
73
|
+
DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`),touchFileEvidence:t.prepare(`UPDATE file_evidence
|
|
74
|
+
SET last_accessed_at = ?
|
|
75
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?
|
|
76
|
+
AND last_accessed_at < ?`)}}catch(t){return cn("shared cache disabled (open failed)",t),null}}function Zs(e,t,n){cn(`shared cache disabled (${t})`,n);try{e.shared?.evidence.close()}catch{}e.shared=null}function eA(e,t={}){if(!eS(e))return null;let n;try{n=new Ys(e),n.pragma("busy_timeout = 50"),n.exec(`CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
|
|
77
|
+
ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version)`),n.pragma("wal_checkpoint(TRUNCATE)");let r=n.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??oS,o=t.budgetBytes??sS,s=Number(n.pragma("page_size",{simple:!0})),a=Number(n.pragma("page_count",{simple:!0})),c=Number(n.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,u=r>0&&l>o?Math.min(r,Math.ceil((l-o)/Math.max(1,l/r))):0,d=Math.max(r-i,u);return d>0&&(n.prepare(`DELETE FROM file_evidence WHERE rowid IN (
|
|
78
|
+
SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
|
|
79
|
+
)`).run(d),n.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:d,remainingRows:r-d}}catch(r){return cn("shared cache maintenance skipped",r),null}finally{try{n?.close()}catch{}}}function Bu(e,t,n,r){let i=it(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,n,r,ve)??i.readLegacyFileEvidence.get(t,n,r);if(o?.payload!==void 0)return o.payload;if(!Qs.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,n,r,ve);return s?.payload!==void 0&&dS(i.shared,t,n,r),s?.payload??null}catch(s){return Zs(i,"file_evidence read",s),null}}catch(o){return ot(e,"file_evidence read",o),null}}function dS(e,t,n,r){let i=Date.now();try{e.touchFileEvidence.run(i,t,n,r,ve,i-aS)}catch(o){cn("shared file_evidence recency touch skipped",o)}}function $u(e,t,n,r,i){let o=it(e);if(o)try{if(o.writeFileEvidence.run(t,n,r,ve,i),Qs.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,n,r,ve,i,Date.now())}catch(s){Zs(o,"file_evidence write",s)}}catch(s){ot(e,"file_evidence write",s)}}function Gu(e,t){if(t.length===0)return;let n=it(e);if(n)try{n.evidence.transaction(()=>{for(let i of t)n.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,ve,i.payload)})();try{n.evidence.pragma("wal_checkpoint(TRUNCATE)")}catch{}let r=t.filter(i=>Qs.has(i.kind));if(r.length>0&&n.shared)try{n.shared.evidence.transaction(()=>{for(let i of r)n.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,ve,i.payload,Date.now())})()}catch(i){Zs(n,"file_evidence batch write",i)}}catch(r){ot(e,"file_evidence batch write",r)}}function Vu(e,t,n,r){let i=it(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,n,r,ve)??i.readLegacyProjectEvidence.get(t,n,r))?.payload??null}catch(o){return ot(e,"project_evidence read",o),null}}function Hu(e,t,n,r,i){let o=it(e);if(o)try{o.writeProjectEvidence.run(t,n,r,ve,i)}catch(s){ot(e,"project_evidence write",s)}}function tA(e,t,n,r){if(n===r)return 0;let i=it(e);if(!i)return 0;try{return i.rekeyProjectEvidenceKind.run(r,ve,t,n).changes}catch(o){return ot(e,"project_evidence kind rekey",o),0}}function nA(e,t,n,r){let i=it(e);if(!i)return new Map;try{let o=i.readCalleesForFile.all(t,n,r,ve),s=i.readLegacyCalleesForFile.all(t,n,r);return Wu([...s,...o])}catch(o){return ot(e,"semantic_callees bulk read",o),new Map}}function rA(e,t,n){let r=it(e);if(!r)return new Map;try{let i=r.readReferencesForFile.all(t,n,ve),o=r.readLegacyReferencesForFile.all(t,n);return Wu([...o,...i])}catch(i){return ot(e,"semantic_references bulk read",i),new Map}}function Wu(e){let t=new Map;for(let n of e)t.set(n.symbol,n.payload);return t}function iA(e,t){if(t.length===0)return;let n=it(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.contentHash}`;r.has(o)||(r.add(o),n.dropStaleCallees.run(i.relativePath,i.contentHash)),n.writeCallees.run(i.relativePath,i.symbol,i.contentHash,i.depsDigest,ve,i.payload)}})()}catch(r){ot(e,"semantic_callees write",r)}}function oA(e,t){if(t.length===0)return;let n=it(e);if(n)try{n.evidence.transaction(()=>{let r=new Set;for(let i of t){let o=`${i.relativePath}\0${i.projectFingerprint}`;r.has(o)||(r.add(o),n.dropStaleReferences.run(i.relativePath,i.projectFingerprint)),n.writeReferences.run(i.relativePath,i.symbol,i.projectFingerprint,ve,i.payload)}})()}catch(r){ot(e,"semantic_references write",r)}}import{appendFileSync as pS,mkdirSync as fS}from"fs";import{createHash as mS,randomUUID as gS}from"crypto";import{dirname as yS}from"path";import{performance as Gn}from"perf_hooks";var Ku="SCIP_QUERY_PROFILE",Ju="SCIP_QUERY_PROFILE_OUT",Xu="SCIP_QUERY_PROFILE_COMMAND",Yu="SCIP_QUERY_PROFILE_CACHE_STATE",ea="SCIP_QUERY_PROFILE_RUN_ID",ta="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY",na="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND",Qu=[Ku,Ju,Xu,Yu,ea,ta,na],dA=new Set(Qu),qu=new Set,Uu=new Map,zu=!1;function Gt(){let e=process.env[Ku];return e==="1"||e==="true"}function hS(){return process.env[Ju]}function Zu(){return process.env[Xu]}function SS(){return process.env[Yu]}function ed(){let e=process.env[ea];if(e)return e;if(!Gt())return;let t=gS();return process.env[ea]=t,t}function td(){return process.env[ta]}function bS(e){let t=td();if(t)return t;if(!Gt())return;let n=ed();if(!n)return;let r=e.projectFingerprint?"published-project":"run-only",i=wr(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??n]);return process.env[ta]=i,process.env[na]=r,i}function wr(e){return mS("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function pA(){return Object.fromEntries(Qu.flatMap(e=>{let t=process.env[e];return t===void 0?[]:[[e,t]]}))}function z(e,t,n){if(!Gt())return t();let r=Gn.now();try{let i=t();return Yi({type:"span",name:e,durationMs:Math.round(Gn.now()-r),ok:!0,...Qi(n)??{}}),i}catch(i){throw Yi({type:"span",name:e,durationMs:Math.round(Gn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...Qi(n)??{}}),i}}async function fA(e,t,n){if(!Gt())return t();let r=Gn.now();try{let i=await t();return Yi({type:"span",name:e,durationMs:Math.round(Gn.now()-r),ok:!0,...Qi(n)??{}}),i}catch(i){throw Yi({type:"span",name:e,durationMs:Math.round(Gn.now()-r),ok:!1,error:i instanceof Error?i.message:String(i),...Qi(n)??{}}),i}}function Yi(e,t=hS()){let n=xS(e),r={timestamp:new Date().toISOString(),pid:process.pid,runId:ed(),command:Zu(),cacheState:SS(),...n,...e},i=`${JSON.stringify(r)}
|
|
80
|
+
`;if(t)try{let o=yS(t);qu.has(o)||(fS(o,{recursive:!0}),qu.add(o)),pS(t,i);return}catch(o){zu||(zu=!0,process.stderr.write(`[profile] failed to write ${t}: ${o instanceof Error?o.message:String(o)}
|
|
81
|
+
`));return}Gt()&&process.stderr.write(i)}function xS(e){let t=td()??bS({command:Zu()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!t)return{};let n=process.env[na],r=typeof e.name=="string"?e.name:void 0;if(!r)return{workloadIdentity:t,workloadIdentityKind:n};let i=r.split(/[.:]/,1)[0]??r,o=`${t}\0${r}`,s=Uu.get(o);return s||(s=wr(["profile-subsystem-v1",t,r]),Uu.set(o,s)),{workloadIdentity:t,workloadIdentityKind:n,subsystem:i,subsystemWorkIdentity:s}}function Qi(e){return typeof e=="function"?e():e}import{isAbsolute as nd,relative as vS}from"path";var H=class extends Error{constructor(n,r){super(`refusing unsafe project file path ${JSON.stringify(n)} (${r})`);this.relativePath=n;this.reason=r;this.name="UnsafeProjectPathError"}relativePath;reason;code="SCIP_QUERY_UNSAFE_PROJECT_PATH"};function Vt(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function Z(e){return e.replace(/\\/g,"/")}function ln(e,t){return Vt(e)===Vt(t)}function Ae(e,t){let n=vS(e,t);return n===""||!n.startsWith("..")&&!nd(n)}function Ie(e){if(!e)throw new H(e,"empty-path");if(e.includes("\0"))throw new H(e,"nul-byte");if(nd(e)||/^[A-Za-z]:/.test(e)||e.startsWith("//")||e.startsWith("\\\\"))throw new H(e,"absolute-path");let t=Vt(e);if(t.split("/").some(r=>r===".."))throw new H(e,"parent-traversal");if(!t||t===".")throw new H(e,"empty-path");return t}import{closeSync as ra,fstatSync as Zi,openSync as ia,readFileSync as IS,readSync as rd}from"fs";import{createHash as ES}from"crypto";var ne=8*1024*1024,un=64*1024*1024,ae=512*1024*1024,RS=256*1024*1024,st=class extends Error{constructor(n,r,i,o,s){let a=i==="too-large"?`is ${o} bytes; the safety limit is ${s} bytes`:i==="not-regular"?"is not a regular file":"changed while it was being read";super(`${n} ${JSON.stringify(r)} ${a}`);this.inputKind=n;this.inputPath=r;this.reason=i;this.observedBytes=o;this.limitBytes=s;this.name="BoundedFileReadError"}inputKind;inputPath;reason;observedBytes;limitBytes;code="SCIP_QUERY_BOUNDED_FILE_READ"};function ee(e,t){pn(t.maxBytes);let n=String(e),r=ia(e,"r");try{let i=Zi(r);od(i,t,n);let o=IS(r),s=Zi(r);if(s.dev!==i.dev||s.ino!==i.ino||s.size!==i.size||o.byteLength!==i.size)throw new st(t.inputKind,n,"changed-during-read",s.size,t.maxBytes);return o}finally{ra(r)}}function j(e,t,n="utf8"){return ee(e,t).toString(n)}function T(e,t){return j(e,{maxBytes:ne,inputKind:t})}function PS(e,t){return j(e,{maxBytes:un,inputKind:t})}function oa(e,t){pn(t.maxBytes);let n=[],r=Buffer.allocUnsafe(64*1024),i=0;for(;;){let o=rd(e,r,0,r.length,null);if(o===0)break;if(i+=o,!Number.isSafeInteger(i)||i>t.maxBytes)throw new st(t.inputKind,`file descriptor ${e}`,"too-large",i,t.maxBytes);n.push(Buffer.from(r.subarray(0,o)))}return Buffer.concat(n,i)}function wS(e,t,n="utf8"){return oa(e,t).toString(n)}function id(e,t){let n=ia(e,"r");try{return oa(n,t)}finally{ra(n)}}function sa(e,t,n="utf8"){return id(e,t).toString(n)}function Vn(e,t,n){pn(t.maxBytes);let r=String(e),i=ia(e,"r");try{let o=Zi(i);od(o,t,r);let s=Buffer.allocUnsafe(Math.min(1024*1024,Math.max(1,o.size))),a=0;for(;a<o.size;){let l=rd(i,s,0,Math.min(s.length,o.size-a),a);if(l===0)break;n(s.subarray(0,l)),a+=l}let c=Zi(i);if(c.dev!==o.dev||c.ino!==o.ino||c.size!==o.size||a!==o.size)throw new st(t.inputKind,r,"changed-during-read",c.size,t.maxBytes);return a}finally{ra(i)}}function dn(e,t){let n=ES("sha256");return Vn(e,t,r=>n.update(r)),n.digest("hex")}function od(e,t,n){if(!e.isFile())throw new st(t.inputKind,n,"not-regular",Number(e.size),t.maxBytes);if(e.size>t.maxBytes)throw new st(t.inputKind,n,"too-large",Number(e.size),t.maxBytes)}function pn(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}import{spawnSync as CS}from"child_process";import{createHash as FS}from"crypto";import{existsSync as TS,lstatSync as to,realpathSync as NS}from"fs";import{dirname as _S,isAbsolute as ad,join as la,relative as kS,resolve as fn,sep as LS}from"path";var Ke={run(e,t){let n=sd(e,t);return n.kind==="success"?n.output:void 0},runResult:sd},DS=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],ua=["status","--porcelain=v2","--branch","-z","--untracked-files=all"],Hn=/^[0-9a-f]{40,64}$/;function wA(e,t,n=Ke){if(!t||t.startsWith("-")||/[\0\r\n]/.test(t))throw new Error(`Invalid Git revision ${JSON.stringify(t)}.`);let r=n.runResult(e,["rev-parse","--verify","--end-of-options",`${t}^{commit}`]);if(r.kind!=="success"||!Hn.test(r.output))throw new Error(`Git revision ${JSON.stringify(t)} does not resolve to exactly one commit.`);return r.output}function Fr(e,t=Ke){return AS(e,t)?.context}function AS(e,t=Ke){let n=t.runResult(e,DS);if(n.kind==="success"){let i=MS(n.output);if(i){let o=jS(i,t);if(o)return aa(o)}}let r=BS(e,t);return r?aa(r):void 0}function OS(e,t=Ke){if(!e.headCommit)return;let n=t.run(e.projectRoot,ua);if(n===void 0)return;let r=da(n);if(!(!r?.headCommit||r.headCommit!==e.headCommit))return{...e,clean:r.clean}}function CA(e,t,n=Ke){if(!t.headCommit||!t.treeOid||!Hn.test(t.headCommit)||!Hn.test(t.treeOid)||n===Ke&&!qS()||!GS(e,t))return;let r=OS({projectRoot:t.projectRoot,gitDir:t.gitDir,commonDir:t.commonDir,repositoryId:t.repositoryId,worktreeId:t.worktreeId,headCommit:t.headCommit,treeOid:t.treeOid,clean:!0},n);return r?aa(r):void 0}function FA(e,t=Ke,n={}){let r=t===Ke&&n.cachedInventoryAfterSequence!==void 0?bu(e,n.cachedInventoryAfterSequence):void 0;if(r!==void 0)return r;let i=t.run(e,["ls-files","-v","-z"]);return i===void 0?!1:i.split("\0").filter(Boolean).every(o=>o.startsWith("H "))}function aa(e){return{context:e,projectFileInventorySequence:Su()}}function da(e){let t=e.split("\0").filter(Boolean),n=t.find(i=>i.startsWith("# branch.oid "))?.slice(13),r=n==="(initial)"?void 0:n;if(!(r!==void 0&&!Hn.test(r))&&n!==void 0)return{headCommit:r,clean:t.every(i=>i.startsWith("# "))}}function MS(e){let t=e.split(`
|
|
82
|
+
`).map(c=>c.trim());if(t.length!==5)return;let[n,r,i,o,s]=t;if(!n||!r||!i||!o||!s||!Hn.test(o)||!Hn.test(s))return;let a=Ee(n);return{root:a,gitDir:Ee(eo(a,r)),commonDir:Ee(eo(a,i)),headCommit:o,treeOid:s}}function jS(e,t){let n=t.run(e.root,ua);if(n===void 0)return;let r=da(n);return r?.headCommit!==e.headCommit?void 0:{...cd(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:Cr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.clean}}function BS(e,t){let n=$S(e,t);if(n.kind!=="worktree")return;let r=n.identity,i=r.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=Ee(eo(i,o)),a=ca(t.run(i,["rev-parse","--verify","HEAD"])),c=ca(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,ua);if(l===void 0)return;let u=da(l);if(!(!u||u.headCommit!==a))return{...r,commonDir:s,repositoryId:Cr("repository",s),headCommit:a,treeOid:c,clean:u.clean}}function $S(e,t=Ke){let n=t.runResult(e,["rev-parse","--show-toplevel"]);if(n.kind==="not-repository")return{kind:"non-git"};if(n.kind==="error")return n;let r=n.output.trim();if(!r)return{kind:"error",message:"Git returned an empty worktree root."};let i=Ee(r),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=Ee(eo(i,o));return{kind:"worktree",identity:cd(i,s)}}function cd(e,t){return{projectRoot:e,gitDir:t,worktreeId:Cr("worktree",`${e}\0${t}`)}}function GS(e,t){try{let n=Ee(t.projectRoot),r=fn(e)===n?n:Ee(e);if(t.projectRoot!==n||!WS(n,r))return!1;let i=la(n,".git"),o=to(i);if(o.isSymbolicLink())return!1;let s=o.isDirectory()?Ee(i):o.isFile()?VS(i,n,o):void 0;if(!s||s!==t.gitDir)return!1;let a=HS(s);return!a||a!==t.commonDir?!1:t.worktreeId===Cr("worktree",`${n}\0${s}`)&&t.repositoryId===Cr("repository",a)}catch{return!1}}function VS(e,t,n){let r=ld(e,"gitdir: ",n);return r?Ee(fn(t,r)):void 0}function HS(e){let t=la(e,"commondir");try{let n=to(t);if(n.isSymbolicLink()||!n.isFile())return;let r=ld(t,"",n);return r?Ee(fn(e,r)):void 0}catch(n){let r=n.code;return r==="ENOENT"||r==="ENOTDIR"?e:void 0}}function ld(e,t="",n=to(e)){if(!n.isFile()||n.isSymbolicLink()||n.size>4*1024)return;let r=j(e,{inputKind:"Git control path",maxBytes:4*1024}).split(/\r?\n/).filter(o=>o.length>0);if(r.length!==1||!r[0].startsWith(t))return;let i=r[0].slice(t.length);return i&&!i.includes("\0")?i:void 0}function WS(e,t){let n=kS(e,t);return n===""||!n.startsWith(`..${LS}`)&&n!==".."&&!ad(n)}function qS(e=process.env){return!(["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_REPLACE_REF_BASE","GIT_NO_REPLACE_OBJECTS","GIT_SHALLOW_FILE","GIT_GRAFT_FILE"].some(n=>e[n]!==void 0)||Object.keys(e).some(n=>n.startsWith("GIT_CONFIG_")))}function ud(e,t=Ke){let n=t.run(e,["worktree","list","--porcelain","-z"]);return n===void 0?[]:US(n)}function US(e){let t=[],n;for(let r of e.split("\0")){if(r===""){n&&t.push(n),n=void 0;continue}let i=r.indexOf(" "),o=i<0?r:r.slice(0,i),s=i<0?"":r.slice(i+1);if(o==="worktree"){n&&t.push(n),n={path:Ee(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}n&&(o==="HEAD"?n.head=s:o==="branch"?n.branch=s:o==="detached"?n.detached=!0:o==="bare"?n.bare=!0:o==="prunable"?n.prunable=!0:o==="locked"&&(n.locked=!0))}return n&&t.push(n),t}function TA(e,t,n=Ke){return ca(n.run(e,t))}function eo(e,t){return ad(t)?t:fn(e,t)}function Ee(e){try{return NS(e)}catch{return fn(e)}}function Cr(e,t){return FS("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function ca(e){return e?.trim()||void 0}function sd(e,t){let n=CS("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(n.status===0)return{kind:"success",output:n.stdout.trimEnd()};let i=(typeof n.stderr=="string"?n.stderr.trim():"")||n.error?.message||`git exited with status ${n.status??"unknown"}`,o=n.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&TS(fn(e)))&&!zS(e)?{kind:"not-repository"}:{kind:"error",message:i}}function zS(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=fn(e);for(;;){try{return to(la(t,".git")),!0}catch(r){let i=r.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let n=_S(t);if(n===t)return!1;t=n}}import{createRequire as XS}from"module";import{existsSync as YS,lstatSync as pd,readdirSync as QS,statSync as ZS}from"fs";import N from"path";import{AsyncLocalStorage as KS}from"async_hooks";var JS=new KS;function mn(e,t){let n=no(e);if(!n||n.missing.has(t))return;let r=n.files.get(t);if(r)return r;let i=n.readBaseFile?.(t);return i&&n.files.set(t,i),i}function gn(e,t){let n=no(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function dd(e,t){return no(e)?.fingerprints.get(t)}function yn(e){return no(e)?.paths}function no(e){let t=JS.getStore();if(t)return t.projectRoot===Ee(e)?t:void 0}var eb=XS(import.meta.url),fd=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]),tb=18003;function ro(e,t=[]){let n=N.resolve(e),r=t.flatMap(c=>ib(n,c));if(r.length>0)return md(n,yd(r));let i=rb(n),o=yd(i),s=ob(n,o)?[n,...o]:o,a=s.length>0?s:[n];return md(n,a)}function hd(e){return new Set(e.map(t=>t==="."?"tsconfig.json":`${t.replace(/\/$/u,"")}/tsconfig.json`))}function Sd(e){let t=e.split("/").at(-1)?.toLowerCase();return t?.startsWith("tsconfig")===!0&&t.endsWith(".json")}var nb=/^\.scipquery-compiler-shard-\d+\.tsconfig\.json$/;function HA(e){return`.scipquery-compiler-shard-${e}.tsconfig.json`}function bd(e){return nb.test(e)}function xd(e,t,n=[]){let r;try{r=eb("@ts-morph/common/dist/typescript.js")}catch{return null}let i=N.resolve(e),o=t==="workspace"?ro(i,n):["."],s=new Set;for(let a of o){let c=a==="."?i:N.join(i,a),l=N.join(c,"tsconfig.json"),u=ab(r,i);if(!u.fileExists(l))return null;let d=r.readConfigFile(l,u.readFile);if(d.error)return null;let p=r.parseJsonConfigFileContent(d.config,u,c);if(p.errors.some(f=>f.code!==tb))return null;for(let f of p.fileNames){let g=N.resolve(f);Ae(i,g)&&s.add(N.relative(i,g).split(N.sep).join("/"))}}return s}function WA(e,t,n,r){let i=N.resolve(e),o=new Set(r);for(let a of n){let c=N.resolve(i,a);if(Ae(i,c))try{let l=pd(c);if(l.isSymbolicLink()||l.isFile()&&!o.has(hn(i,c)))return!1}catch{}}let s=t==="workspace"?ro(i,n):["."];for(let a of s){let c=a==="."?i:N.join(i,a),l=N.join(c,"tsconfig.json");if(!Id(i,l))continue;let u=hn(i,l);if(!o.has(u))return!1;try{if(pd(l).isSymbolicLink())return!1;let d=Ed(i,l);if(d.includes("extends")||d.includes("\\"))return!1}catch{return!1}}return!0}function md(e,t){return[...new Set(t.map(n=>hn(e,n)))].sort((n,r)=>n.localeCompare(r))}function rb(e){let t=yn(e);if(t)return t.flatMap(i=>{if(i.split("/").some(s=>fd.has(s)))return[];let o=N.join(e,...i.split("/"));return gd(e,o)?[N.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=QS(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=N.join(i,s.name);if(s.isDirectory()){!fd.has(s.name)&&!s.name.startsWith(".")&&r.push(a);continue}s.isFile()&&gd(e,a)&&n.push(N.dirname(a))}}return n}function ib(e,t){let n=t.trim();if(!n)return[];let r=N.resolve(e,n);if(!Ae(e,r))return[];let i=yn(e);if(i){let o=hn(e,r);if(i.includes(o)&&pa(N.basename(r)))return[N.dirname(r)];let s=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(s))?[r]:[]}try{let o=ZS(r);if(o.isDirectory())return[r];if(o.isFile()&&pa(N.basename(r)))return[N.dirname(r)]}catch{return[]}return[]}function gd(e,t){if(!pa(N.basename(t)))return!1;let n=vd(e,t);return n?N.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function pa(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function yd(e){let t=[...new Set(e.map(n=>N.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&lb(n,r)))}function ob(e,t){if(t.length===0||t.some(r=>N.resolve(r)===e))return!1;let n=N.join(e,"tsconfig.json");return Id(e,n)&&sb(e,n)}function sb(e,t){let r=vd(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!N.extname(i))):!1}function vd(e,t){try{let n=JSON.parse(Ed(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Id(e,t){let n=hn(e,t),r=gn(e,n);return r?r==="present":YS(t)}function Ed(e,t){let n=hn(e,t);if(yn(e)){let i=mn(e,n);if(!i)throw Object.assign(new Error(`Snapshot file ${n} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return T(t,"TypeScript project config")}function ab(e,t){let n=yn(t);if(!n)return e.sys;let r=N.resolve(t),i=new Set(n),o=cb(r,n),s=e,a=c=>{let l=N.resolve(c);return Ae(r,l)?hn(r,l):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(c){let l=a(c);return l===null?e.sys.fileExists(c):i.has(l)},readFile(c){let l=a(c);return l===null?e.sys.readFile(c):mn(r,l)?.content.toString("utf8")},readDirectory(c,l,u,d,p){let f=N.resolve(c);return Ae(r,f)?s.matchFiles(f,l,u,d,e.sys.useCaseSensitiveFileNames,r,p,g=>o.get(N.resolve(g))??{files:[],directories:[]},g=>g):e.sys.readDirectory(c,l,u,d,p)}}}function cb(e,t){let n=new Map,r=new Map,i=o=>{n.has(o)||n.set(o,new Set),r.has(o)||r.set(o,new Set)};i(e);for(let o of t){let s=o.split("/"),a=e;for(let c=0;c<s.length-1;c+=1){let l=s[c];i(a),r.get(a).add(l),a=N.join(a,l),i(a)}n.get(a).add(s.at(-1))}return new Map([...n].map(([o,s])=>[o,{files:[...s].sort(),directories:[...r.get(o)??[]].sort()}]))}function hn(e,t){let n=N.relative(e,t);return n?n.split(N.sep).join("/"):"."}function lb(e,t){let n=N.relative(e,t);return!!n&&!n.startsWith("..")&&!N.isAbsolute(n)}import{createHash as ga}from"crypto";import{execFileSync as Rd}from"child_process";import{createRequire as ub}from"module";var db=ub(import.meta.url),pb=/\.(?:[cm]?[jt]sx?)$/iu,fb=/\.[jt]sx$/iu,Pd=/(?:^|\/)package\.json$/iu,Tr,fa=new Map;function wd(e,t){if(!ya(e))return;let n=mb();if(n)try{let r=typeof t=="string"?t:t.toString("utf8"),i=fb.test(e)?n.LanguageVariant.JSX:n.LanguageVariant.Standard,o=n.createScanner(n.ScriptTarget.Latest,!1,i,r),s=ga("sha256").update(`typescript-semantic-v1\0${i}\0`),a=!1,c=!1;for(;;){let l=o.scan();if(l===n.SyntaxKind.EndOfFileToken)break;if(l===n.SyntaxKind.WhitespaceTrivia)continue;if(l===n.SyntaxKind.NewLineTrivia){a&&(c=!0);continue}c&&s.update("line-break\0");let u=o.getTokenText();s.update(`${l}\0${Buffer.byteLength(u)}\0`).update(u).update("\0"),a=!0,c=!1}return s.digest("hex")}catch{return}}function ya(e){return pb.test(e)}function ha(e,t){if(Pd.test(e))try{let n=JSON.parse(typeof t=="string"?t:t.toString("utf8"));if(typeof n!="object"||n===null||Array.isArray(n))return;let{scripts:r,...i}=n;return ga("sha256").update("typescript-package-json-v1\0").update(ma(i)).digest("hex")}catch{return}}function Sa(e){return Pd.test(e)}function JA(e,t,n){if(!Sa(t)||!/^[a-f0-9]{64}$/u.test(n))return;let r=`${e}\0${t}\0${n}`;if(fa.has(r))return fa.get(r);let i;try{let o=Rd("git",["-C",e,"log","--all","--format=%H","--max-count=64","--",t],{encoding:"utf8",maxBuffer:1048576,timeout:5e3}).split(/\r?\n/u).filter(Boolean);for(let s of o){let a=Rd("git",["-C",e,"show",`${s}:${t}`],{encoding:null,maxBuffer:4194304,timeout:5e3});if(ga("sha256").update(a).digest("hex")===n){i=ha(t,a);break}}}catch{i=void 0}return fa.set(r,i),i}function mb(){if(Tr!==void 0)return Tr;try{Tr=db("typescript")}catch{Tr=null}return Tr}function ma(e){return Array.isArray(e)?`[${e.map(ma).join(",")}]`:typeof e=="object"&&e!==null?`{${Object.entries(e).sort(([t],[n])=>t.localeCompare(n)).map(([t,n])=>`${JSON.stringify(t)}:${ma(n)}`).join(",")}}`:JSON.stringify(e)}import{createHash as Nd,randomUUID as xb}from"crypto";import{chmodSync as _d,existsSync as qn,linkSync as vb,lstatSync as Nr,readdirSync as xa,realpathSync as Oe,unlinkSync as Ib,writeSync as Eb}from"fs";import{homedir as Rb}from"os";import{basename as Pb,dirname as oo,isAbsolute as Fd,join as Fe,resolve as so}from"path";import{closeSync as gb,existsSync as yb,fsyncSync as hb,mkdirSync as Sb,openSync as bb}from"fs";import{dirname as Cd}from"path";function St(e,t,n,r){let i=0;for(;i<t.length;){let o=n.writeFile(e,t,i,t.length-i);if(!Number.isSafeInteger(o)||o<=0||o>t.length-i)throw new Error(`${r} write did not make valid forward progress`);i+=o}}function Wn(e,t){if(t!=="win32")return!1;let n=e.code;return n==="EACCES"||n==="EBADF"||n==="EINVAL"||n==="EISDIR"||n==="EPERM"}var Sn=Object.freeze({platform:process.platform,pathExists:e=>yb(e),makeDirectory:e=>Sb(e,{recursive:!0}),openFile:(e,t,n)=>bb(e,t,n),syncFile:e=>hb(e),closeFile:e=>gb(e)});function me(e,t=Sn){let n=[],r=e;for(;!t.pathExists(r);){n.push(r);let o=Cd(r);if(o===r)throw new Error(`Cannot establish a durable directory path without an existing ancestor: ${e}`);r=o}let i="synced";for(let o of n.reverse())t.makeDirectory(o),i=W(i,D(Cd(o),t));return i}function D(e,t=Sn){let n;try{n=t.openFile(e,"r")}catch(r){if(Wn(r,t.platform))return"unsupported";throw r}try{t.syncFile(n)}catch(r){try{t.closeFile(n)}catch{}if(Wn(r,t.platform))return"unsupported";throw r}return t.closeFile(n),"synced"}function W(...e){return e.every(t=>t==="not-requested")?"not-requested":e.includes("unsupported")?"unsupported":"synced"}var kd=1,kr=".scip-query-cache-owner.json",wb=16*1024,Ld=Object.freeze({...Sn,randomToken:()=>xb(),linkFile:(e,t)=>vb(e,t),removeFile:e=>Ib(e),writeFile:(e,t,n,r)=>Eb(e,t,n,r)});function io(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function Je(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function Cb(e,t){let n=Oe(e);return Fb(n,va(n,t))}function va(e,t){let n=Oe(e),r=process.env.SCIP_QUERY_CACHE_DIR;return r?so(r):t?.dbPath?Nb(n,t.dbPath):co(n)}function ao(){let e=process.env.XDG_CACHE_HOME;return Fe(e||Fe(Rb(),".cache"),"scip-query")}function co(e){let t=so(e);try{t=Oe(t)}catch{}let n=Nd("sha256").update(t).digest("hex").slice(0,12);return Fe(ao(),"projects",n)}function lo(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=Fe(ao(),"repositories",e);return Md(t),Oe(t)}function Ia(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function dO(e,t){let n=Cb(e,t);return{cacheDir:n,dbPath:Fe(n,"index.db"),indexPath:Fe(n,"index.scip"),metaPath:Fe(n,"meta.json")}}function Fb(e,t,n=Ld){return Tb(e,t,n).cacheDir}function Tb(e,t,n=Ld){let r=Oe(e),i=qn(t)?"synced":Md(t,n),o=Oe(t),s=Fe(o,kr);if(qn(s))return ba(r,o),Ea(s),_r(o),{kind:"existing",cacheDir:o};Td(o),Db(o),Td(o);let c=`${JSON.stringify({schemaVersion:kd,canonicalProjectRoot:r,canonicalCacheDir:o,creatorVersion:qi},null,2)}
|
|
83
|
+
`;try{let l=Ab(s,c,n),u=W(i,l);return{kind:"published",cacheDir:o,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}catch(l){if(Mb(l))return ba(r,o),{kind:"existing",cacheDir:o};throw l}}function ba(e,t){let n=Oe(e),r=Oe(t);return Dd(r,n,r)}function pO(e){let t=Nr(e);if(t.isSymbolicLink()||!t.isDirectory())throw Je(e,"cache path is not a regular directory");let n=Oe(e);return Dd(n,void 0,n)}function fO(e,t){return qn(Fe(t,kr))?(ba(e,t),Ad(t),!0):!1}function Nb(e,t){let n;try{n=Ie(t)}catch(s){throw s instanceof H?io(t,s.reason):s}let r=so(e,...n.split("/"));if(r===e||!Ae(e,r))throw io(t,"outside-project");let i=_b(r),o=Oe(i);if(!Ae(e,o)&&o!==e)throw io(t,"symlink-escape");return r}function _b(e){let t=e;for(;!qn(t);){let n=oo(t);if(n===t)throw io(e,"no-existing-ancestor");t=n}return t}function Dd(e,t,n){let r=Fe(e,kr);if(!qn(r)||Nr(r).isSymbolicLink())throw Je(e,"missing regular ownership record");let i=Nr(r);if(!i.isFile()||i.size>wb)throw Je(e,"invalid ownership record file");let o=T(r,"cache ownership record"),s=kb(o,e);if(t!==void 0&&s.canonicalProjectRoot!==t)throw Je(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==n)throw Je(e,"ownership record names a different cache directory");return{record:s,ownerSha256:Nd("sha256").update(o).digest("hex"),physicalCacheDir:e}}function kb(e,t){try{let n=JSON.parse(e);if(n.schemaVersion!==kd||typeof n.canonicalProjectRoot!="string"||typeof n.canonicalCacheDir!="string"||typeof n.creatorVersion!="string"||!Fd(n.canonicalProjectRoot)||!Fd(n.canonicalCacheDir))throw new Error("invalid fields");return n}catch(n){throw Je(t,`malformed ownership record: ${n instanceof Error?n.message:String(n)}`)}}function Td(e){let t=xa(e).filter(n=>n!==kr&&!Lb(n));if(t.length>0)throw Je(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function Lb(e){return e.startsWith(`${kr}.tmp-`)||e.startsWith("git-worktree-context.json.tmp-")||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","git-worktree-context.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","typescript-shard-costs.json","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function Db(e){for(let t of xa(e)){let n=Fe(e,t);try{let r=Nr(n);if(r.isSymbolicLink())throw Je(e,`legacy cache entry ${t} is a symlink`);if(r.isDirectory())_r(n);else if(r.isFile())Ea(n);else throw Je(e,`legacy cache entry ${t} is not a file or directory`)}catch(r){if(Od(r))continue;throw r}}_r(e)}function Ad(e,t=!1){try{let n=Nr(e);if(n.isSymbolicLink())throw Je(e,"managed cache tree contains a symlink");if(n.isFile()){Ea(e);return}if(!n.isDirectory())throw Je(e,"managed cache tree contains a special file");_r(e);for(let r of xa(e))Ad(Fe(e,r),!0)}catch(n){if(t&&Od(n))return;throw n}}function Od(e){let t=e?.code;return t==="ENOENT"||t==="ENOTDIR"}function Md(e,t=Sn){let n=me(e,t);return _r(e),n}function Ab(e,t,n){let r=`${e}.tmp-${process.pid}-${n.randomToken()}`,i,o=!1;try{i=n.openFile(r,"wx",384),o=!0,St(i,Buffer.from(t),n,"cache ownership record"),n.syncFile(i),n.closeFile(i),i=void 0,n.linkFile(r,e);let s=D(oo(e),n);return n.removeFile(r),o=!1,W(s,D(oo(e),n))}finally{if(i!==void 0)try{n.closeFile(i)}catch{}if(o)try{n.removeFile(r)}catch{}}}function _r(e){process.platform!=="win32"&&_d(e,448)}function Ea(e){process.platform!=="win32"&&_d(e,384)}function Ob(e){if(qn(e))return Oe(e);let t=Oe(oo(e));return Fe(t,Pb(e))}function Ra(e){return Ob(so(e))}function Mb(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{execFileSync as Zb}from"child_process";import{isUtf8 as Wd}from"buffer";import{createHash as Na}from"crypto";import{closeSync as zd,fstatSync as Lr,lstatSync as ka,openSync as Kd,readdirSync as ex,readFileSync as tx,readSync as qd,readlinkSync as nx,realpathSync as Ar}from"fs";import{isAbsolute as rx,join as La,relative as ix,resolve as ox,sep as sx}from"path";import{closeSync as jd,existsSync as wa,openSync as jb,realpathSync as Bb,renameSync as $b,unlinkSync as Bd,writeSync as Gb}from"fs";import{dirname as Vb,join as Hb}from"path";var Wb="fingerprint-stat-cache.json",$d=1,qb=8*1024*1024,Pa=new Map;function Ca(e,t,n,r){let i=Gd(e),o=i.files.get(t);if(!(!o||!Vd(o,n,r)))return i.hits+=1,{hash:o.hash,size:o.fingerprintSize,...o.semanticHash===void 0?{}:{semanticHash:o.semanticHash}}}function Fa(e,t,n,r,i){if(i.hash==="unreadable"||i.size<0||!Number.isFinite(i.size))return;let o=Gd(e),s={kind:n,dev:r.dev,ino:r.ino,mtimeMs:r.mtimeMs,ctimeMs:r.ctimeMs,size:r.size,hash:i.hash,fingerprintSize:i.size,...i.semanticHash===void 0?{}:{semanticHash:i.semanticHash}},a=o.files.get(t);a&&Yb(a,s)||(o.files.set(t,s),o.stores+=1,o.dirty=!0)}function Ta(e){let t=Pa.get(Hd(e));if(!(!t?.dirty||!t.cachePath))try{let n=Vb(t.cachePath);if(!wa(n))return;Qb(t.cachePath,Kb(t)),t.dirty=!1}catch{}}function Gd(e){let t=Hd(e),n=Pa.get(t);if(n)return n;let r=Ub(t),i=zb(r),o={cachePath:r,files:i,dirty:!1,hits:0,stores:0};return Pa.set(t,o),o}function Ub(e){try{let t=va(e);return wa(t)?Hb(t,Wb):null}catch{return null}}function zb(e){let t=new Map;if(!e||!wa(e))return t;try{let n=JSON.parse(ee(e,{inputKind:"fingerprint stat cache",maxBytes:qb}).toString("utf8"));if(!Jb(n))return t;for(let[r,i]of Object.entries(n.files))i&&t.set(r,i)}catch{return t}return t}function Kb(e){return{version:$d,files:Object.fromEntries(e.files)}}function Jb(e){if(typeof e!="object"||e===null)return!1;let t=e;return t.version!==$d||typeof t.files!="object"||t.files===null?!1:Object.values(t.files).every(Xb)}function Xb(e){if(typeof e!="object"||e===null)return!1;let t=e;return(t.kind==="file"||t.kind==="symlink")&&Number.isFinite(t.dev)&&Number.isFinite(t.ino)&&Number.isFinite(t.mtimeMs)&&Number.isFinite(t.ctimeMs)&&Number.isFinite(t.size)&&Number.isFinite(t.fingerprintSize)&&typeof t.hash=="string"&&t.hash!=="unreadable"&&(t.semanticHash===void 0||typeof t.semanticHash=="string")}function Vd(e,t,n){return e.kind===t&&e.dev===n.dev&&e.ino===n.ino&&e.mtimeMs===n.mtimeMs&&e.ctimeMs===n.ctimeMs&&e.size===n.size}function Yb(e,t){return Vd(e,t.kind,t)&&e.hash===t.hash&&e.fingerprintSize===t.fingerprintSize&&e.semanticHash===t.semanticHash}function Qb(e,t){let n=`${e}.${process.pid}.tmp`;try{Bd(n)}catch{}let r=Buffer.from(`${JSON.stringify(t)}
|
|
84
|
+
`,"utf8"),i=jb(n,"wx",384);try{St(i,r,{writeFile:(o,s,a,c)=>Gb(o,s,a,c)},"fingerprint stat cache")}catch(o){throw jd(i),Bd(n),o}jd(i),$b(n,e)}function Hd(e){return Bb(e)}var Un=64*1024*1024,ax=1024*1024,cx=1024,bn=class extends Error{constructor(n,r,i,o){super(`${n} ${JSON.stringify(r)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="SCIP_QUERY_INPUT_TOO_LARGE"};function lx(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function zn(e,t,n={}){let r=Ie(t),i=hu(e,()=>Ar(e)),o=ox(i,...r.split("/"));if(!Ae(i,o)||o===i)throw new H(t,"outside-project");let s=Ar(o);if(!Ae(i,s)||s===i)throw new H(t,"outside-project");let a=ka(s);if(!a.isFile())throw new H(t,"not-a-file");let c={projectRoot:i,relativePath:r,absolutePath:s,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},l=n.maxBytes??Un;if(pn(l),c.size>l)throw new bn(n.inputKind??"project file",c.relativePath,c.size,l);return c}function fo(e,t,n={}){let r=Ie(t),i=gn(e,r);if(i){if(i==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(r)} does not exist.`),{code:"ENOENT"});let c=mn(e,r);if(!c)throw new H(r,"changed-during-read");let l=n.maxBytes??Un;if(pn(l),c.size>l)throw new bn(n.inputKind??"project file",r,c.size,l);return Buffer.from(c.content)}let o=zn(e,t,n),s=n.maxBytes??Un,a=Kd(o.absolutePath,"r");try{let c=Lr(a);if(Dr(c,o,t),c.size>s)throw new bn(n.inputKind??"project file",o.relativePath,c.size,s);let l=tx(a),u=Lr(a);if(Dr(u,o,t),l.byteLength!==c.size)throw new H(t,"changed-during-read");return l}finally{zd(a)}}function ux(e,t,n,r={}){if(n.byteLength===0)throw new Error("Project file probe literal must not be empty.");let{matchedLiteralIndexes:i,...o}=Jd(e,t,[n],r);return{...o,includesLiteral:i.length>0}}function Jd(e,t,n,r={}){if(n.length===0||n.some(c=>c.byteLength===0))throw new Error("Project file probe literals must not be empty.");let i=Ie(t),o=gn(e,i);if(o){if(o==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(i)} does not exist.`),{code:"ENOENT"});let c=mn(e,i);if(!c)throw new H(i,"changed-during-read");let l=r.maxBytes??Un;if(pn(l),c.size>l)throw new bn(r.inputKind??"project file",i,c.size,l);let u=!c.content.includes(0)&&Wd(c.content),d=n.map(Ud),p=u?px(c.content,n,d):[];return{byteLength:c.size,isUtf8Text:u,matchedLiteralIndexes:p,bytes:p.length>0?Buffer.from(c.content):null,...r.computeSha256?{sha256:c.sha256}:{}}}let s=zn(e,t,r),a=Kd(s.absolutePath,"r");try{let c=Lr(a);Dr(c,s,t);let l=r.computeSha256?Na("sha256"):null,u=r.scratchBuffer??Buffer.allocUnsafe(ax);if(u.byteLength===0)throw new Error("Project file probe scratch buffer must not be empty.");let d=0,p=n.map(()=>!1),f=!1,g=!0,y=Buffer.alloc(0),m=n.map(()=>Buffer.alloc(0)),S=n.map(Ud);for(;d<c.size;){let x=qd(a,u,0,Math.min(u.byteLength,c.size-d),d);if(x<=0)throw new H(t,"changed-during-read");let b=u.subarray(0,x);if(l?.update(b),f||=b.includes(0),g){let I=y.byteLength>0?Buffer.concat([y,b]):b,P=dx(I);g=Wd(I.subarray(0,P)),y=Buffer.from(I.subarray(P))}for(let I=0;I<n.length;I+=1){if(p[I])continue;let P=n[I],k=m[I];p[I]=fx(b,P,k,S[I]),m[I]=mx(b,P,k)}d+=x}g&&=y.byteLength===0,Dr(Lr(a),s,t);let h=!f&&g,v=h?p.flatMap((x,b)=>x?[b]:[]):[],E=null;if(v.length>0){E=Buffer.allocUnsafe(c.size);let x=0;for(;x<E.byteLength;){let b=qd(a,E,x,E.byteLength-x,x);if(b<=0)throw new H(t,"changed-during-read");x+=b}Dr(Lr(a),s,t)}return{byteLength:c.size,isUtf8Text:h,matchedLiteralIndexes:v,bytes:E,...l?{sha256:l.digest("hex")}:{}}}finally{zd(a)}}function Or(e,t,n={}){return fo(e,t,n).toString("utf8")}function Dr(e,t,n){if(!e.isFile()||e.dev!==t.device||e.ino!==t.inode||e.size!==t.size)throw new H(n,"changed-during-read")}function dx(e){if(e.byteLength===0)return 0;let t=e.byteLength-1,n=0;for(;t>=0&&n<3&&(e[t]&192)===128;)n+=1,t-=1;if(t<0)return e.byteLength;let r=e[t];return((r&128)===0?1:(r&224)===192?2:(r&240)===224?3:(r&248)===240?4:0)>e.byteLength-t?t:e.byteLength}function px(e,t,n){return t.flatMap((r,i)=>_a(e,r,n[i])?[i]:[])}function fx(e,t,n,r){if(_a(e,t,r))return!0;if(n.byteLength===0||t.byteLength===1)return!1;let i=e.subarray(0,Math.min(e.byteLength,t.byteLength-1));return _a(Buffer.concat([n,i]),t,r)}function _a(e,t,n){if(n<0)return e.includes(t);let r=t[n],i=e.indexOf(r),o=0;for(;i>=0;){if(o+=1,o>cx)return e.includes(t);let s=i-n;if(s>=0&&s+t.byteLength<=e.byteLength&&e.compare(t,0,t.byteLength,s,s+t.byteLength)===0)return!0;i=e.indexOf(r,i+1)}return!1}function Ud(e){for(let n=1;n<e.byteLength;n+=1){let r=e[n];if(r>=65&&r<=90)return n}let t=e[0];return t>=65&&t<=90?0:-1}function mx(e,t,n){let r=t.byteLength-1;if(r===0)return Buffer.alloc(0);if(e.byteLength>=r)return Buffer.from(e.subarray(e.byteLength-r));let i=Buffer.concat([n,e]);return Buffer.from(i.subarray(Math.max(0,i.byteLength-r)))}function Ht(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function gx(e,t){try{return zn(e,t),!0}catch(n){if(Ht(n))return!1;throw n}}function yx(e){let t=yn(e);return t?t.filter(n=>n&&!po(n)).sort():(Ix(e)??Ex(e)).filter(n=>n&&!po(n)).sort()}function hx(e,t={}){let n=(t.includePaths??[]).map(Ie),r=[...new Set([...yx(e),...n])].filter(s=>!po(s)).filter(s=>!t.language||Ru(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort((s,a)=>s.localeCompare(a)),i=Ar(e),o=r.flatMap(s=>Xd(e,i,s));return Ta(i),o}function Xd(e,t,n){let r=dd(e,n);if(r)return[{path:n,size:r.fingerprintSize??r.size,hash:r.sha256}];if(gn(e,n)==="present"){let o=mn(e,n);if(o)return[{path:n,size:o.fingerprintSize??o.size,hash:o.sha256}]}let i=La(e,n);try{let o=ka(i);if(o.isSymbolicLink()){let y=Ca(t,n,"symlink",uo(o));if(y)return[{path:n,size:y.size,hash:y.hash}];let m=Ar(i),S=ix(t,m);if(S===".."||S.startsWith(`..${sx}`)||rx(S))throw new Error("external symlink");let h=nx(i),v=Na("sha256").update("symlink\0").update(h).digest("hex"),E=Buffer.byteLength(h);return Fa(t,n,"symlink",uo(o),{hash:v,size:E}),[{path:n,size:E,hash:v}]}let s=ya(n)||Sa(n),a=Ca(t,n,"file",uo(o));if(a&&(!s||a.semanticHash!==void 0))return[{path:n,size:a.size,hash:a.hash,...a.semanticHash===void 0?{}:{semanticHash:a.semanticHash}}];let c=Na("sha256"),l=s,u=[],d=Vn(i,{inputKind:"project fingerprint input",maxBytes:Un},y=>{c.update(y),l&&u.push(Buffer.from(y))}),p=c.digest("hex"),f=l?Buffer.concat(u,d):void 0,g=f?wd(n,f)??ha(n,f):void 0;return Fa(t,n,"file",uo(o),{hash:p,size:d,...g===void 0?{}:{semanticHash:g}}),[{path:n,size:d,hash:p,...g===void 0?{}:{semanticHash:g}}]}catch(o){return Ht(o)?[]:[{path:n,size:-1,hash:"unreadable"}]}}function uo(e){return{dev:e.dev,ino:e.ino,mtimeMs:e.mtimeMs,ctimeMs:e.ctimeMs,size:e.size}}function Kn(e,t,n){let r=Jn(t,n),i=[...r.typescriptProjects.filter(c=>xx(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?xd(e,r.typescriptProjectMode,r.typescriptProjects):null,s=r.languages.includes("typescript")?r.typescriptProjectMode==="workspace"?ro(e,r.typescriptProjects):["."]:[],a=hd(s);return{...r,files:hx(e,{includePath:c=>{if(c===".scipquery.json")return!1;let l=jt(c,t,i);return l==="other"||l==="config"&&Sd(c)&&!a.has(c)?!1:l!=="source"||!bx(c)||!o?!0:o.has(c)},includePaths:i})}}function DO(e,t){let n=new Set(t.files.map(o=>o.path)),r=Kn(e,t.languages,t),i=new Map(r.files.map(o=>[o.path,o]));return{...Jn(t.languages,t),files:[...t.files.flatMap(o=>{let s=i.get(o.path);return s?[s]:[]}),...r.files.filter(o=>!n.has(o.path))]}}function AO(e,t,n,r,i,o){let s=d=>({mode:"full",fingerprint:Kn(e,t,n),reason:d});if(!i)return s("change-journal-unavailable");if(!i.complete)return s(`change-journal-incomplete:${i.incompleteReason??"unknown"}`);if(!o)return s("accepted-generation-unavailable");if(i.baseGeneration!==o)return s("change-journal-base-mismatch");if(!r)return s("prior-project-input-snapshot-unavailable");let a=Jn(t,n);if(!Sx(r,a))return s("project-input-configuration-changed");if(new Set(r.files.map(d=>d.path)).size!==r.files.length)return s("prior-project-input-snapshot-has-duplicate-paths");if(i.entries.length===0)return{mode:"delta",fingerprint:{...a,files:[...r.files].sort((d,p)=>d.path.localeCompare(p.path))},changedPaths:[]};let c=[...a.typescriptProjects,...a.clojureConfigPath?[a.clojureConfigPath]:[]],l=new Map(r.files.map(d=>[d.path,d]));for(let d of i.entries){let p=l.get(d.path);if(jt(d.path,t,c)!=="source")return s("non-source-project-input-changed");if(d.kind==="add"&&p)return s("added-path-already-in-prior-project-input-snapshot");if(d.kind==="delete"&&!p)return s("deleted-path-not-in-prior-project-input-snapshot");if(d.kind==="change"&&!p)return s("changed-path-not-in-prior-project-input-snapshot");if(p&&(p.hash==="unreadable"||p.size<0))return s("changed-path-was-unreadable")}let u=Ar(e);for(let d of i.entries){let p=Xd(e,u,d.path);if(d.kind==="delete"){if(p.length!==0)return s("deleted-source-is-still-readable");l.delete(d.path);continue}if(p.length!==1||p[0].hash==="unreadable"||p[0].size<0)return s(d.kind==="add"?"added-source-is-not-readable":"changed-source-no-longer-readable");l.set(d.path,p[0])}return Ta(u),{mode:"delta",fingerprint:{...a,files:[...l.values()].sort((d,p)=>d.path.localeCompare(p.path))},changedPaths:i.entries.map(d=>d.path).sort()}}function Sx(e,t){return e.version===t.version&&JSON.stringify([...e.languages].sort())===JSON.stringify(t.languages)&&e.pnpmWorkspaces===t.pnpmWorkspaces&&e.typescriptProjectMode===t.typescriptProjectMode&&JSON.stringify([...e.typescriptProjects].sort())===JSON.stringify(t.typescriptProjects)&&e.clojureConfigPath===t.clojureConfigPath}function bx(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function xx(e,t){let n;try{n=Ie(t)}catch{return!1}let r=gn(e,n);if(r)return r==="present";try{return ka(La(e,n)).isFile()}catch(i){if(Ht(i))return!1;throw i}}function Jn(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:lx(t.typescriptProjects),clojureConfigPath:vx(t.clojureConfigPath)}}function vx(e){return e?.trim()||void 0}function Ix(e){try{let t=Hi(e,52428800,()=>Zb("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:104857600,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}));return[...Wi(t)]}catch{return null}}function Ex(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?La(e,r):e,o;try{o=ex(i,{withFileTypes:!0})}catch{continue}for(let s of o){let a=r?`${r}/${s.name}`:s.name;if(s.isDirectory()){po(a)||n.push(a);continue}t.push(a)}}return t}function po(e){let t=e.split("/");return e==="meta.json"||bd(e)||t[0]===".scipquery"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(n=>Rx.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var Rx=new Set([".git","node_modules",".scipquery-cache",".scipquery-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);import{basename as Yd}from"path";var Px=C("indexed-document-paths",{clearGroups:["whole-project"]});function Re(e,t={}){let n=wx(t);return[...Px.get(e,n,()=>{let i=t.scope?"AND relative_path LIKE ?":"",o=t.like?"AND relative_path LIKE ?":"",s=[...t.scope?[`%${t.scope}%`]:[],...t.like?[t.like]:[]],a=e.all(`SELECT relative_path
|
|
85
|
+
FROM documents
|
|
86
|
+
WHERE 1 = 1
|
|
87
|
+
${e.pathExclusionsFor("documents")}
|
|
88
|
+
${i}
|
|
89
|
+
${o}
|
|
90
|
+
ORDER BY relative_path`,...s).map(l=>l.relative_path),c=t.extensions?a.filter(l=>t.extensions.some(u=>l.toLowerCase().endsWith(u.toLowerCase()))):a;return t.includeIgnored===!1?c.filter(l=>!e.isIgnored(l)):c})]}function wx(e){let t=e.extensions?[...new Set(e.extensions.map(n=>n.toLowerCase()))].sort():null;return JSON.stringify({scope:e.scope??null,like:e.like??null,extensions:t,includeIgnored:e.includeIgnored!==!1})}function Zd(e,t,n){let r=ep(t);if(!r)return[];let i=e.all(`SELECT relative_path
|
|
91
|
+
FROM documents
|
|
92
|
+
WHERE relative_path = ?
|
|
93
|
+
${e.pathExclusionsFor("documents")}`,r).filter(c=>!e.isIgnored(c.relative_path)).map(c=>({relativePath:c.relative_path,score:Qd(c.relative_path,r)}));if(i.length>0)return i;let o=Re(e,{includeIgnored:!1}).map(c=>({relativePath:c,score:Qd(c,r)})).filter(c=>c.score>0).sort((c,l)=>l.score-c.score||c.relativePath.localeCompare(l.relativePath)),s=o.filter(c=>c.score>=1100);if(s.length>0)return n.allowMultiple?s:[s[0]];if(n.requirePathMatch)return[];let a=o.filter(c=>c.score>=800);return a.length>0?n.allowMultiple?a:[a[0]]:n.allowMultiple?o:o.slice(0,1)}function Qd(e,t){let n=ep(e),r=Yd(n),i=Yd(t),o=0;return n===t&&(o+=1200),n.endsWith(`/${t}`)&&(o+=1100),r===i&&(o+=900),n.startsWith(`${t}/`)&&(o+=850),n.includes(t)&&(o+=250),o}function ep(e){return e.trim().replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"").replace(/\/+$/,"")}var Cx=[re("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),re("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),re("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),re("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),re("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),re("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),re("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),re("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),re("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),re("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),re("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),re("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),re("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),re("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),re("runtime-boundary-http-roles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/http-summaries.ts"}),re("runtime-boundary-source-hashes",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/graph.ts"}),re("runtime-boundary-direct-extraction",{dependsOn:["content-hash","direct-deps-digest","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/analysis/runtime-boundaries.test.ts",owner:"src/analysis/runtime-boundaries/graph.ts"}),mo("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),mo("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),mo("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),mo("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function ce(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if(Gt()){let c=ht(n);if(c){let l=`${c}\0${r}\0${i}`;a=t.get(l),a||(a=wr(["evidence-product-file-read-v1",e.kind,c,r,i]),t.set(l,a))}}return z("evidence-product.file.read",()=>{let c=Bu(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){$u(n,e.kind,r,i,e.serialize(o))},writeBatch(n,r){Gu(n,r.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function tp(e){let t=new Map;return{kind:e.kind,read(n,r,i){let o=!1,s=0,a;if(Gt()){let c=`${i}\0${r}`;a=t.get(c),a||(a=wr(["evidence-product-project-read-v1",e.kind,i,r]),t.set(c,a))}return z("evidence-product.project.read",()=>{let c=Vu(n,e.kind,r,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(n,r,i,o){Hu(n,e.kind,r,i,e.serialize(o))}}}function te(e){let t=Cx.find(n=>n.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function re(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function mo(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var go=null;function Mr(e){go?.(e)}function np(e,t){let n=go;go=e;try{return t()}finally{go=n}}var Fx=C("source-text",{clearGroups:["whole-project","source-file"]}),Tx=C("source-lines",{clearGroups:["whole-project","source-file"]});function F(e,t){let n=t.replace(/\\/g,"/");return Mr(n),Fx.get(e,n,()=>yo(e,n))}function yo(e,t){let n=t.replace(/\\/g,"/");Mr(n);try{return Or(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(r){if(Ht(r))return"";throw r}}function JO(e){if(e.length===0)return[];let t=e.split(`
|
|
94
|
+
`);return e.endsWith(`
|
|
95
|
+
`)&&t.pop(),t}function jr(e,t){let n=t.replace(/\\/g,"/");return Tx.get(e,n,()=>{let r=F(e,n);return r?r.split(`
|
|
96
|
+
`):[]})}var Nx=/^\s*(?:\/\/|#|\/\*+|\*)\s*scip-query[\s:-]*ignore(?:[\s:-]+(dead(?:-code)?|stale|wrapper|passthrough|drift|extract|similar|twin))?\b/i;function _x(e){let t=Nx.exec(e);return t?t[1]??"":null}function XO(e,t,n){return rp(e,t,n).length>0}function YO(e,t,n,r){let i=r.toLowerCase();return rp(e,t,n).some(o=>o.toLowerCase()===i)}function rp(e,t,n){if(n<=0)return[];let r=jr(e,t);if(r.length===0)return[];let i=[];for(let o=n-1;o>=0&&o>=n-5;o-=1){let s=(r[o]??"").trim();if(s==="")continue;let a=_x(s);if(a!==null){i.push(a);continue}if(!s.startsWith("//")&&!s.startsWith("*")&&!s.startsWith("/*")&&!s.startsWith("@")&&!s.startsWith("#"))return i}return i}import{readdirSync as kx}from"fs";import{execFileSync as Lx}from"child_process";import{extname as ho,join as Dx}from"path";var Ax=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue",".rs",".py",".pyi",".java",".kt",".kts",".scala",".sc",".clj",".cljs",".cljc",".rb",".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx",".cs",".vb",".php",".dart"],iM=[".vue"],ip=[".tsx",".jsx"],op=[".vue"],Ox=[...ip,...op],Mx=new Set(ip),jx=new Set(op),sp=new Set(Ax.map(e=>e.toLowerCase())),Bx=[...sp].sort().join(","),ap=new Set(["node_modules",".git","target","dist","build",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs","out","coverage",".scipquery-cache","__pycache__",".venv","venv",".idea",".vscode"]);function Me(e,t={}){let n=t.includeIndexed??!0,r=t.includeAuxiliary??!0,i=t.extensions?.map(c=>c.toLowerCase()),o=i?new Set(i):sp,s=i?[...o].sort().join(","):Bx,a=`${n?"1":"0"}|${r?"1":"0"}|${s}`;return $x.get(e,a,()=>{let c=new Set;if(n)for(let l of Re(e,{includeIgnored:!1}))o.has(ho(l).toLowerCase())&&c.add(l);if(r)for(let l of Gx(e.config.projectRoot,o))e.isIgnored(l)||n&&c.has(l)||c.add(l);return[...c].sort()})}function oM(e,t={}){let n=!1,r=!1;for(let i of Me(e,{extensions:Ox})){if(t.scope&&!i.includes(t.scope))continue;let o=ho(i).toLowerCase();if(n||=Mx.has(o),r||=jx.has(o),n&&r)break}return{react:n,vue:r}}var $x=C("source-files",{clearGroups:[]});function Gx(e,t){return Vx(e,t)??Wx(e,t)}function Vx(e,t){try{let n=Lx("git",["ls-files","--cached","--others","--exclude-standard"],{cwd:e,encoding:"utf-8",timeout:1e4,killSignal:"SIGKILL",stdio:["ignore","pipe","ignore"]}),r=new Set;for(let i of n.split(`
|
|
97
|
+
`)){let o=i.trim();o&&(Hx(o)||t.has(ho(o).toLowerCase())&&r.add(o))}return r}catch{return null}}function Hx(e){return e.split("/").some(t=>ap.has(t))}function Wx(e,t){let n=new Set,r=i=>{let o=i?Dx(e,i):e,s;try{s=kx(o,{withFileTypes:!0})}catch{return}for(let a of s)if(!ap.has(a.name)){if(a.isDirectory()){r(i?`${i}/${a.name}`:a.name);continue}t.has(ho(a.name).toLowerCase())&&n.add(i?`${i}/${a.name}`:a.name)}};return r(""),n}import{createRequire as tv}from"module";import{existsSync as In}from"fs";import{basename as lp,dirname as Te,extname as bt,join as je,relative as xn,resolve as ie,sep as nv}from"path";import{existsSync as Aa,readdirSync as qx,statSync as Ux}from"fs";import{join as Xn,relative as zx}from"path";function cp(e){let t=Kx(e)??Qx(e);if(!t||t.length===0)return[];let n=[],r=new Set;for(let i of t)for(let o of Zx(e,i)){if(r.has(o))continue;r.add(o);let s=ev(e,o);s&&n.push(s)}return n}function Kx(e){let t=Xn(e,"pnpm-workspace.yaml");if(!Aa(t))return null;try{return Jx(T(t,"pnpm workspace manifest"))}catch{return null}}function Jx(e){let t=[],n=!1;for(let r of e.split(/\r?\n/)){let i=Xx(r);if(!n){/^packages\s*:\s*$/.test(i.trim())&&(n=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=Yx(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function Xx(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function Yx(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Qx(e){let t=Xn(e,"package.json");if(!Aa(t))return null;try{let n=JSON.parse(T(t,"workspace package manifest"));return n.workspaces?Array.isArray(n.workspaces)?n.workspaces:n.workspaces.packages??[]:null}catch{return null}}function Zx(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Xn(e,t);return Da(s)?[s]:[]}let n=t.indexOf("*"),r=t.slice(0,n).replace(/\/$/,""),i=t.slice(n+1).replace(/^\//,""),o=Xn(e,r||".");return Da(o)?qx(o).map(s=>Xn(o,s,i)).filter(Da):[]}function Da(e){try{return Ux(e).isDirectory()}catch{return!1}}function ev(e,t){let n=Xn(t,"package.json");if(!Aa(n))return null;try{let r=JSON.parse(T(n,"workspace package manifest"));return typeof r.name!="string"||r.name.length===0?null:{name:r.name,relativeDir:zx(e,t).replace(/\\/g,"/"),exports:r.exports}}catch{return null}}var rv=rt("indexed-paths",{clearGroups:[]}),iv=rt("indexed-path-digest",{clearGroups:[]}),ov=C("tsconfig-alias-config",{clearGroups:["whole-project"]}),sv=C("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),av=tv(import.meta.url),Br;function cv(){if(Br!==void 0)return Br;try{Br=av("typescript")}catch{Br=null}return Br}var lv=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],uv=rt("workspace-packages",{clearGroups:["whole-project"]}),vn=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],So=[".py",".pyi"],Ne=[".java",".scala",".kt",".kts"],bo=[".rs"],xo=[".rb"],vo=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],Wt=[".cs",".vb"],Io=[".dart"],En=[".php"],Yn=[".clj",".cljs",".cljc"],dv=new Set(vn),Oa=new Set(So),up=new Set(Ne),Ma=new Set(bo),ja=new Set(xo),dp=new Set(vo),pp=new Set(Wt),Ba=new Set(Io),fp=new Set(En),mp=new Set(Yn),pv=[{extensions:vn,lookup:dv},{extensions:So,lookup:Oa},{extensions:Ne,lookup:up},{extensions:bo,lookup:Ma},{extensions:xo,lookup:ja},{extensions:vo,lookup:dp},{extensions:Wt,lookup:pp},{extensions:Io,lookup:Ba},{extensions:En,lookup:fp},{extensions:Yn,lookup:mp}];function xt(e,t){return t.has(bt(e).toLowerCase())}function fv(e){return xt(e,Oa)}function mv(e){return xt(e,up)}function gv(e){return xt(e,Ma)}function yv(e){return xt(e,ja)}function hv(e){return xt(e,dp)}function Sv(e){return xt(e,pp)}function gp(e){return bt(e).toLowerCase()===".vb"}function bv(e){return xt(e,Ba)}function xv(e){return xt(e,fp)}function vv(e){return xt(e,mp)}function $a(e){let t=bt(e).toLowerCase();for(let n of pv)if(n.lookup.has(t))return n.extensions;return vn}function Iv(e){return mv(e)||Sv(e)||xv(e)}function at(e,t,n){return fv(t)?Qn(e,t,n):gv(t)?vt(e,t,n):yv(t)?Eo(e,t,n):hv(t)?Ro(e,t,n):Iv(t)?K(e,n.replace(/\\/g,"."),$a(t)):bv(t)?Po(e,t,n):vv(t)?Ga(e,n):Ev(e,t,n)}function Ev(e,t,n){if(!n.startsWith(".")&&!n.startsWith("/"))return Rv(e,t,n)??wv(e,n);let r=Te(je(e.config.projectRoot,t)),i=ie(r,n),o=It(e);for(let s of Ha(i)){let a=Z(xn(e.config.projectRoot,s));if(o.has(a)||In(s))return a}return Z(xn(e.config.projectRoot,i))}function Rv(e,t,n){let r=kv(e,t);if(!r)return null;let i=It(e);for(let o of Pv(r,n)){let s=ie(r.baseUrl,o);for(let a of Ha(s)){let c=Z(xn(e.config.projectRoot,a));if(i.has(c)||In(a))return c}}return null}function Pv(e,t){let n=[];for(let[r,i]of Object.entries(e.paths)){let o=r.indexOf("*");if(o===-1){if(t!==r)continue;n.push(...i);continue}let s=r.slice(0,o),a=r.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)n.push(l.includes("*")?l.replace("*",c):l)}return n}function wv(e,t){let n=Fv(Cv(e),t);if(!n)return null;let r=It(e);for(let i of Tv(n)){let o=ie(e.config.projectRoot,n.pkg.relativeDir,i);for(let s of Ha(o)){let a=Z(xn(e.config.projectRoot,s));if(r.has(a)||In(s))return a}}return null}function Cv(e){return uv.get(e,()=>cp(e.config.projectRoot))}function Fv(e,t){let n=null;for(let r of e){let i=null;t===r.name?i="":t.startsWith(`${r.name}/`)&&(i=t.slice(r.name.length+1)),i!==null&&(!n||r.name.length>n.pkg.name.length)&&(n={pkg:r,subpath:i})}return n}function Tv(e){let t=[],n=Nv(e.pkg.exports,e.subpath);if(n){let r=_v(n);r&&t.push(r)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function Nv(e,t){if(!e||typeof e!="object")return null;let n=t===""?".":`./${t}`;return yp(e[n])}function yp(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let n of["types","import","default","require","node"]){let r=yp(t[n]);if(r)return r}return null}function _v(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function kv(e,t){let n=Z(Te(t));return sv.get(e,n,()=>Lv(e,n))}function Lv(e,t){let n=cv();if(!n)return null;let r=ie(e.config.projectRoot),i=ie(r,t);for(;i===r||i.startsWith(r+nv);){for(let s of lv){let a=je(i,s);if(!In(a))continue;let c=ov.get(e,a,()=>Dv(n,a));if(c)return c}let o=Te(i);if(o===i)break;i=o}return null}function Dv(e,t){try{let n=e.readConfigFile(t,e.sys.readFile);if(n.error||!n.config)return null;let r=e.parseJsonConfigFileContent(n.config,e.sys,Te(t)),i=r.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:r.options.baseUrl?ie(Te(t),r.options.baseUrl):Te(t),paths:i}}catch{return null}}function Qn(e,t,n){let r=It(e),i;if(n.startsWith(".")){let o=n.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=Te(je(e.config.projectRoot,t));for(let l=1;l<s;l++)c=Te(c);i=a?ie(c,a.replace(/\./g,"/")):c}else i=ie(e.config.projectRoot,n.replace(/\./g,"/"));for(let o of Av(i)){let s=Z(xn(e.config.projectRoot,o));if(r.has(s)||In(o))return s}return null}function vt(e,t,n){if(!n)return null;let r=n.replace(/\s+as\s+.+$/,"").trim();if(!r.startsWith("crate::")&&!r.startsWith("self::")&&!r.startsWith("super::"))return null;let i=Te(je(e.config.projectRoot,t)),o;return r.startsWith("crate::")?o=ie(e.config.projectRoot,"src",r.slice(7).replace(/::/g,"/")):r.startsWith("self::")?o=ie(i,r.slice(6).replace(/::/g,"/")):o=ie(Te(i),r.slice(7).replace(/::/g,"/")),Va(e,Ov(o))}function Eo(e,t,n){let r=Te(je(e.config.projectRoot,t)),i=ie(r,n);return Va(e,Mv(i))}function Ro(e,t,n){let r=Te(je(e.config.projectRoot,t)),i=[ie(r,n),ie(e.config.projectRoot,n),ie(e.config.projectRoot,"include",n),ie(e.config.projectRoot,"src",n)];return Va(e,i)}function K(e,t,n){let r=It(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of n){let l=`${o}${c}`,u=[...r].find(d=>d.endsWith(l));if(u)return u}for(let c of n){let l=[...r].find(u=>lp(u)===`${s}${c}`);if(l)return l}let a=[...r].filter(c=>n.includes(bt(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function Po(e,t,n){let r=It(e);if(n.startsWith("package:")){let s=n.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=Z(c.startsWith("lib/")?c:`lib/${c}`);return r.has(l)?l:null}let i=Te(je(e.config.projectRoot,t)),o=ie(i,n);for(let s of jv(o)){let a=Z(xn(e.config.projectRoot,s));if(r.has(a)||In(s))return a}return null}function Ga(e,t){let n=t.replace(/-/g,"_").replace(/\./g,"/"),r=It(e);for(let i of Yn){let o=`${n}${i}`,s=[...r].find(a=>a.endsWith(o));if(s)return s}for(let i of Yn){let o=[...r].find(s=>lp(s)===`${n.split("/").pop()}${i}`);if(o)return o}return null}function Av(e){let t=bt(e);return Oa.has(t)?[e]:[`${e}.py`,`${e}.pyi`,je(e,"__init__.py"),je(e,"__init__.pyi")]}function Va(e,t){let n=It(e);for(let r of t){let i=Z(xn(e.config.projectRoot,r));if(n.has(i)||In(r))return i}return null}function Ov(e){let t=bt(e);return Ma.has(t)?[e]:[`${e}.rs`,je(e,"mod.rs")]}function Mv(e){let t=bt(e);return ja.has(t)?[e]:[`${e}.rb`,je(e,"index.rb")]}function jv(e){let t=bt(e);return Ba.has(t)?[e]:[`${e}.dart`,e]}function Ha(e){let t=bt(e),n=new Set;if(t){n.add(e);for(let r of vn)n.add(e.slice(0,-t.length)+r)}else for(let r of vn)n.add(`${e}${r}`),n.add(je(e,`index${r}`));return[...n]}function It(e){return rv.get(e,()=>new Set(Re(e,{includeIgnored:!1}).map(Z)))}function Wa(e){return iv.get(e,()=>U([...It(e)].sort().join(`
|
|
98
|
+
`)))}function qt(e){return typeof e=="object"&&e!==null}function Be(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{basename as ff}from"path";function le(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ua(e){return e.replace(/'''[\s\S]*?'''/g,Ut).replace(/"""[\s\S]*?"""/g,Ut).replace(/#.*$/gm,Ut).replace(/\/\/.*$/gm,Ut).replace(/\/\*[\s\S]*?\*\//g,Ut).replace(/`(?:\\[\s\S]|[^`])*`/g,Ut).replace(/'(?:\\.|[^'\\\r\n])*'/g,Ut).replace(/"(?:\\.|[^"\\\r\n])*"/g,Ut)}function PM(e){return hp(e,{maskStrings:!1})}function wM(e){return hp(e,{maskStrings:!0})}function hp(e,t){let n="",r=0,i=e.length;for(;r<i;){if(e[r]==="/"&&e[r+1]==="/"){let s=e.indexOf(`
|
|
99
|
+
`,r),a=s===-1?i:s;n+=qa(e,r,a),r=a;continue}if(e[r]==="/"&&e[r+1]==="*"){let s=e.indexOf("*/",r+2),a=s===-1?i:s+2;n+=qa(e,r,a),r=a;continue}let o=e[r];if(o==="`"||o==="'"||o==='"'){let s=o,a=r+1;for(;a<i;){if(e[a]==="\\"){a+=2;continue}if(e[a]===s){a+=1;break}if(s!=="`"&&e[a]===`
|
|
100
|
+
`)break;a+=1}n+=t.maskStrings?qa(e,r,a):e.slice(r,a),r=a;continue}n+=o,r+=1}return n}function qa(e,t,n){let r="";for(let i=t;i<n;i+=1)r+=e[i]===`
|
|
101
|
+
`?`
|
|
102
|
+
`:" ";return r}function Ut(e){return e.replace(/[^\r\n]/g," ")}var CM=an("stripped-lines",{clearGroups:["whole-project","source-file"]});Bn({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{wo=null,$r=""},clearFile:()=>{wo=null,$r=""}});var wo=null,$r="";function Bv(e){return wo===e||(wo=e,$r=Ua(e)),$r}function zt(e,t,n){let r=Bv(e);return`${r.slice(0,t)}${" ".repeat(n-t)}${r.slice(n)}`}function Pe(e,t){return new RegExp(`\\b${le(t)}\\b`,"m").test(e)}function Zn(e,t){let n=new Set,r=new RegExp(`\\b${le(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function za(e){let t=0;for(let n of e)n==="("&&(t+=1),n===")"&&(t-=1);return t}import{extname as Sp}from"path";var $v={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function oe(e){return $v[Sp(e).toLowerCase()]??null}function Xe(e){return Sp(e).toLowerCase()===".vue"}var bp=new WeakMap,xp=new Set(["call_expression","call","decorator","pair","string","string_literal","template_string","variable_declarator"]);function Gr(e,t){let n=Array.isArray(t)?t:[t];if(!n.every(o=>xp.has(o)))return e.descendantsOfType(t);let r=Gv(e);return n.length===1?r.get(n[0])??[]:n.flatMap(o=>r.get(o)??[]).sort((o,s)=>o.startIndex-s.startIndex)}function Ka(e,t){let n=e.walk(),r=0,i=!1;for(;!i;){if(t(n),n.gotoFirstChild()){r+=1;continue}for(;;){if(r===0){i=!0;break}if(n.gotoNextSibling())break;n.gotoParent(),r-=1}}}function Gv(e){let t=bp.get(e);if(t)return t;let n=new Map;return Ka(e,r=>{let i=r.nodeType;if(!xp.has(i))return;let o=n.get(i);o?o.push(r.currentNode):n.set(i,[r.currentNode])}),bp.set(e,n),n}function ge(e,t){t(e);for(let n of e.namedChildren)ge(n,t)}var Vv=/(?:function|method|lambda)/u,vp=new WeakMap;function Hv(e){let t=vp.get(e);if(t)return t;let n=[];return Ka(e,r=>{if(!r.nodeIsNamed)return;let i=r.nodeType;(i==="arrow_function"||Vv.test(i))&&n.push(r.currentNode)}),vp.set(e,n),n}function $e(e,t,n){let r=null;for(let i of Hv(e))i.startPosition.row>t||i.endPosition.row<n||(!r||i.endIndex-i.startIndex<r.endIndex-r.startIndex)&&(r=i);return r}function Ip(e,t,n){if(e.startPosition.row>t||e.endPosition.row<n)return null;for(let r of e.namedChildren){let i=Ip(r,t,n);if(i)return i}return e}function Ge(e){let t=e;for(;["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(t.type)&&t.namedChildren.length>0;)t=t.namedChildren[0];return t}function Vr(e){if(e.type==="identifier")return e.text;let t=e.childForFieldName("name")??e.childForFieldName("pattern");return t?Vr(t):e.namedChildren.find(n=>n.type==="identifier")?.text??null}function Kt(e){return(e.childForFieldName("parameters")??e.namedChildren.find(n=>/parameters/u.test(n.type)))?.namedChildren.map(Vr)??[]}import{createRequire as Kv}from"module";import{setFlagsFromString as Ep}from"v8";import{runInNewContext as Wv}from"vm";var Rn;function qv(){if(Rn!==void 0)return Rn;let e=globalThis.gc;if(typeof e=="function")return Rn=e,Rn;try{Ep("--expose_gc");let t=Wv("gc");Ep("--no-expose_gc"),Rn=typeof t=="function"?t:null}catch{Rn=null}return Rn}function Uv(){let e=qv();return e?(e(),!0):!1}var zv=512*1024*1024,Ja=0;function Rp(e,t=Uv){!Number.isFinite(e)||e<=0||(Ja+=e,!(Ja<zv)&&(Ja=0,t()))}var ye=Kv(import.meta.url),Hr=null,Xa=!1;function Pp(){if(Xa)return null;if(Hr)return Hr;try{return Hr=ye("tree-sitter"),Hr}catch{return Xa=!0,null}}function BM(e){if(e==="clojure")return"reader";let t=Pp();if(!t)return"unavailable";let n=wp(e);if(!n)return"unavailable";try{return new t().setLanguage(n),"ast"}catch{return er.add(e),"unavailable"}}var Ya=new Map,er=new Set;function wp(e){if(er.has(e))return null;let t=Ya.get(e);if(t)return t;let n;try{switch(e){case"rust":n=ye("tree-sitter-rust");break;case"typescript":n=ye("tree-sitter-typescript").typescript;break;case"tsx":n=ye("tree-sitter-typescript").tsx;break;case"javascript":n=ye("tree-sitter-javascript");break;case"python":n=ye("tree-sitter-python");break;case"java":n=ye("tree-sitter-java");break;case"kotlin":n=ye("tree-sitter-kotlin");break;case"scala":n=ye("tree-sitter-scala");break;case"ruby":n=ye("tree-sitter-ruby");break;case"c":n=ye("tree-sitter-c");break;case"cpp":n=ye("tree-sitter-cpp");break;case"csharp":n=ye("tree-sitter-c-sharp");break;case"php":n=ye("tree-sitter-php").php;break;case"vb":{let r=ye("tree-sitter-vb-dotnet");n=r.language??r;break}case"clojure":return er.add(e),null}}catch{return er.add(e),null}return Ya.set(e,n),n}var Qa=new Map;function $M(){Hr=null,Xa=!1,Ya.clear(),er.clear(),Qa.clear(),Yv.clear()}function Jv(e){let t=Qa.get(e);if(t)return t;let n=wp(e);if(!n)return null;let r=Pp();if(!r)return null;let i=new r;try{i.setLanguage(n)}catch{return er.add(e),null}return Qa.set(e,i),i}function Xv(e,t){return e.parse(r=>r>=t.length?null:t.slice(r,Math.min(t.length,r+16384)))}function Et(e,t){let n=Jv(e);if(!n)return null;try{let r=Xv(n,t);return Rp(t.length*10),r}catch{return null}}var Yv=new Map;import{createRequire as Qv}from"module";import{posix as Za}from"path";var Zv=$t("vue-sfc-units"),eI=Qv(import.meta.url),tI;function nI(){return tI??=eI("@vue/compiler-sfc")}function Tp(...e){return nI().parse(...e)}function tr(e,t){let n=Np(t),r=F(e,n);return Zv.get(e,n,r,()=>ec(e,n,r))}function Np(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function rI(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Pn(e){return!e||e.body.length===0?0:e.body.split(`
|
|
103
|
+
`).length}function ec(e,t,n){let r={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!n)return r;let i;try{i=Tp(n,{filename:t})}catch(s){return r.errors.push(Fp(s)),r}r.errors.push(...i.errors.map(Fp));let{descriptor:o}=i;return o.template&&(r.template=Co(e,t,"template",o.template)),o.script&&r.scripts.push(Cp(e,t,o.script,!1)),o.scriptSetup&&r.scripts.push(Cp(e,t,o.scriptSetup,!0)),r.styles=o.styles.map(s=>Co(e,t,"style",s)),r.customBlocks=o.customBlocks.map(s=>Co(e,t,"custom",s)),r.errors.push(...[r.template,...r.scripts,...r.styles,...r.customBlocks].flatMap(s=>s?.errors??[])),r}function Cp(e,t,n,r){let i=Co(e,t,"script",n);return{...i,kind:"script",setup:r,astLanguage:rI(i.lang)}}function Co(e,t,n,r){let i=oI(r.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof r.src=="string"?r.src:void 0;if(s){let c=iI(t,s);if(!c)return{kind:n,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${n} block source: ${s}`]};let l=F(e,c),u=l?Math.max(0,l.split(`
|
|
104
|
+
`).length-1):0;return{kind:n,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:u,errors:l?[]:[`Vue ${n} block source not found: ${c}`]}}let a=Math.max(0,r.loc.start.line-1);return{kind:n,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:r.content,startLine:a,endLine:Math.max(a,r.loc.end.line-1),errors:[]}}function iI(e,t){let n=t.split(/[?#]/,1)[0];if(!n||n.startsWith("/")||n.includes("://"))return null;let r=Np(Za.normalize(Za.join(Za.dirname(e),n)));return r===".."||r.startsWith("../")?null:r}function oI(e){return{...e}}function Fp(e){return e instanceof Error?e.message:String(e)}function nr(e,t,n){let i=ec(e,t,n).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
|
|
105
|
+
`.repeat(s.startLine)}${s.body}`).join(`
|
|
106
|
+
`),startLine:0,language:o}:null}var Fo=an("ast-trees",{clearGroups:["whole-project","source-file"]});function M(e,t){if(Xe(t))return sI(e,t);let n=oe(t);if(!n)return null;let r=F(e,t);return r?Fo.get(e,t,r,()=>Et(n,r)):null}function _p(e,t,n){if(Xe(t))return Fo.get(e,t,n,()=>{let i=nr(e,t,n);return i?Et(i.language,`
|
|
107
|
+
`.repeat(i.startLine)+i.body):null});let r=oe(t);return r?Fo.get(e,t,n,()=>Et(r,n)):null}function Wr(e,t,n){if(Xe(t)){let o=nr(e,t,n);if(!o)return null;let s=Et(o.language,`
|
|
108
|
+
`.repeat(o.startLine)+o.body);return s?{tree:s,language:o.language}:null}let r=oe(t);if(!r)return null;let i=Et(r,n);return i?{tree:i,language:r}:null}function sI(e,t){let n=F(e,t);return n?Fo.get(e,t,n,()=>{let r=nr(e,t,n);if(!r)return null;let i=`
|
|
109
|
+
`.repeat(r.startLine)+r.body;return Et(r.language,i)}):null}function rr(e,t){let n=cI(e,t);if(!n)return null;let r=Rt(n);if(!r)return null;let i=lI(n);return{calleeLeaf:r,calleeQualifier:i?aI(n):void 0,calleeText:n.text,memberAccess:i,line:e.startPosition.row}}function aI(e){return(e.childForFieldName("object")??e.childForFieldName("value")??e.namedChild(0)??void 0)?.text||void 0}function cI(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function lI(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function Rt(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"private_property_identifier":case"shorthand_property_identifier":return e.text.replace(/^#/u,"");case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?Rt(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?Rt(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?Rt(t):null}case"super":case"self":case"this":return null;default:return null}}function qr(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var jp=["function_declaration","generator_function_declaration","method_definition","method_signature","function_signature"],uI=new Set(jp),dI=[...jp,"variable_declarator","public_field_definition"],pI=["function_item","function_signature_item"],fI=["function_definition"],mI=[],kp=new Set(["arrow_function","function_expression","generator_function"]);function Bp(e){return e==="rust"?pI:e==="python"?fI:e==="typescript"||e==="tsx"||e==="javascript"?dI:mI}function ir(e,t){let n=yI(e,t);if(n)return{name:n.name,startLine:n.definitionNode.startPosition.row,endLine:n.definitionNode.endPosition.row,paramCount:Op(n.functionNode),params:Lp(n.functionNode),paramsEndLine:Dp(n.functionNode),isLiteralPassthrough:Mp(n.functionNode,t)};if(!gI(e.type,t))return null;let r=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return r?{name:r.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:Op(e),params:Lp(e),paramsEndLine:Dp(e),isLiteralPassthrough:Mp(e,t)}:null}function $p(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function Lp(e){let t=$p(e);if(!t)return[];let n=[];for(let r of t.namedChildren){if(qr(r))continue;if(r.type==="identifier"){n.push({name:r.text,simple:!0});continue}let i=r.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(r.text),o=r.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){n.push({name:o.text,simple:!0});continue}let s=r.namedChildren.find(a=>a.type==="identifier");n.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return n}function Dp(e){let t=$p(e);return t?t.endPosition.row:e.startPosition.row}function gI(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?uI.has(e):!1}function yI(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(!n||!r)return null;let i=Ap(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}if(e.type==="public_field_definition"){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(!n||!r)return null;let i=Ap(r);return i?{name:n.text,definitionNode:e,functionNode:i}:null}return null}function Ap(e){if(kp.has(e.type))return e;if(e.type!=="call_expression"||(e.childForFieldName("function")??e.namedChild(0))?.type!=="call_expression")return null;let r=((e.childForFieldName("arguments")??e.namedChildren.find(i=>i.type==="arguments"))?.namedChildren??[]).filter(i=>kp.has(i.type));return r.length===1?r[0]:null}function Op(e){let t=e.namedChildren.find(r=>r.type==="parameters"||r.type==="formal_parameters");if(!t)return 0;let n=0;for(let r of t.namedChildren)qr(r)||(n+=1);return n}function Mp(e,t){let n=e.namedChildren.find(d=>d.type==="block"||d.type==="statement_block");if(!n)return!1;let r=n.namedChildren.filter(d=>!qr(d));if(r.length!==1)return!1;let i=r[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(d=>d.type==="arguments"||d.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(d=>!qr(d)),l=e.namedChildren.find(d=>d.type==="parameters"||d.type==="formal_parameters");if(!l)return!1;let u=[];for(let d of l.namedChildren){if(d.type==="identifier"){u.push(d.text);continue}let p=d.namedChildren.find(f=>f.type==="identifier");p&&u.push(p.text)}if(c.length!==u.length)return!1;for(let d=0;d<u.length;d+=1){let p=c[d];if(p.type!=="identifier"||p.text!==u[d])return!1}return!0}function ij(e,t){return e.filter(n=>n.startLine<=t&&n.endLine>=t).sort((n,r)=>n.endLine-n.startLine-(r.endLine-r.startLine)||n.startLine-r.startLine)[0]??null}var hI=new Set(["identifier","type_identifier","field_identifier"]),SI=new Set(["identifier"]),bI=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),xI=new Set(["rust","python"]),vI=/\{([^{}]*)\}/g,II=/\b([A-Za-z_][\w]*)\b/g;function Gp(e,t){return EI(t).has(e.type)}function Vp(e,t){return xI.has(t)&&e.type==="string_content"}function tc(e){let t=0;for(let r of e.values()){let i=r[r.length-1];i!==void 0&&i>t&&(t=i)}let n=new Array(t+1);for(let r=0;r<=t;r+=1)n[r]=new Set;for(let[r,i]of e)for(let o of i)n[o].add(r);return n}function EI(e){return e==="rust"?hI:e==="python"?SI:bI}function Hp(e,t){let n=e.startPosition.row;for(let r of e.text.matchAll(vI)){let i=r[1]??"";for(let o of i.matchAll(II))o[1]&&t(o[1],n)}}var RI=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],PI=/^#!?\[\s*serde\s*\(/,wI=/^#!?\[\s*schemars\s*\(/,CI=/^#!?\[\s*validate\s*\(/,FI=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Wp(e,t,n){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let r=e.childForFieldName("function")??e.namedChild(0);if(!r)return;let i=Rt(r);if(!i||!FI.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&n.add(a.text)}function qp(e,t){let n=PI.test(e),r=wI.test(e),i=CI.test(e);if(!(!n&&!r&&!i))for(let o of RI){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function Up(e,t){let n=new Map,r=(s,a)=>{if(s===a)return;let c=n.get(s);c||(c=new Set,n.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&r(l.text,a);for(let u of l.children)c(u)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(u=>u.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(u=>u.type==="block");if(l)for(let u of l.descendantsOfType("type"))for(let d of u.descendantsOfType("identifier"))d.text!==a&&r(d.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return n}var TI=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),nc=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function zp(e){let t=[],n=[],r=[],i=new Map,o=[],s=0,a=0,c=(l,u)=>{let d=i.get(l);if(!d){i.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)};for(;a<e.length;){let l=e[a];if(l===`
|
|
110
|
+
`){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=No(e,a);continue}if(l==='"'){let g=zr(e,a,s);s=g.line,a=g.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let g=o.pop();g&&(g.endLine=s,NI(g,{callables:t,callSites:n,clojureMembers:r,recordIdentifier:c}),o[o.length-1]?.children.push(g)),a+=1;continue}if(rc(l)){a+=1;continue}let u=s,d=a;for(;a<e.length&&!ic(e[a]);)a+=1;let p=e.slice(d,a);if(!p)continue;let f={text:p,line:u};_I(o[o.length-1],f),c(Ve(p),u)}return{language:"clojure",callables:t,callSites:n,clojureMembers:r,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:OI(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function NI(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let n=e.headTokens[0],r=Ve(n.text),i=TI.get(n.text);if(i){let s=e.headTokens[1];if(s){let a=Ve(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(kI(e,t),!r||nc.has(n.text)||nc.has(r)||r.startsWith(":"))return;let o=AI(n.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:n.line})}function _I(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function kI(e,t){let n=Ve(e.tokens[0]?.text??"");if(n==="defprotocol"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;for(let i of To(e))Ur(t,r,"protocol",i,"protocol-method");return}if(n==="defrecord"||n==="deftype"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;let i=n==="defrecord"?"record":"type",o=n==="defrecord"?"record-method":"type-method";for(let s of To(e))Ur(t,r,i,s,o);return}if(n==="extend-type"){let r=Ve(e.tokens[1]?.text??"");if(!r)return;for(let i of To(e))Ur(t,r,"extension",i,"extension-method");return}if(n==="extend-protocol"){let r=Ve(e.tokens[1]?.text??"");for(let i of To(e)){r&&Ur(t,r,"extension",i,"extension-method");let o=DI(e,i.startLine);o&&o!==r&&Ur(t,o,"extension",i,"extension-method")}}}function To(e){return e.children.filter(LI)}function LI(e){if(e.kind!=="(")return!1;let t=Ve(e.tokens[0]?.text??"");return!!(t&&!nc.has(t)&&!t.startsWith(":"))}function Ur(e,t,n,r,i){let o=r.tokens[0],s=Ve(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:n,memberName:s,memberKind:i,startLine:r.startLine,endLine:r.endLine}))}function DI(e,t){let n=null;for(let r=2;r<e.tokens.length;r+=1){let i=e.tokens[r];if(i.line>t)break;let o=Ve(i.text);o&&!o.startsWith(":")&&(n=o)}return n}function Ve(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function AI(e){let t=e.replace(/^#?['`~@]+/,""),n=t.lastIndexOf("/"),r=Ve(t);if(n<=0)return{leaf:r,text:t};let i=t.slice(0,n);return{leaf:r,qualifier:i,text:t}}function No(e,t){let n=t;for(;n<e.length&&e[n]!==`
|
|
111
|
+
`;)n+=1;return n}function zr(e,t,n){let r=t+1,i=n;for(;r<e.length;){let o=e[r];if(o==="\\"){r+=2;continue}if(o===`
|
|
112
|
+
`&&(i+=1),r+=1,o==='"')break}return{index:r,line:i}}function rc(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function ic(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function OI(e){let t=[];for(let[n,r]of e)for(let i of r)t[i]??=new Set,t[i].add(n);return t}var Kp=6,MI=an("source-facts",{clearGroups:["whole-project","source-file"]}),oc=ce({kind:"source-facts",invalidation:te("source-facts"),serialize:$I,deserialize:GI});function he(e,t){return sc(e,t).facts}function sc(e,t){let n=F(e,t);if(!n)return{facts:null};let r=jI(e,t,n);return r?MI.get(e,t,n,()=>BI(e,t,r,n)):{facts:null}}function jI(e,t,n){return Xe(t)?nr(e,t,n)?.language??null:oe(t)}function BI(e,t,n,r){let i=fe(e,t,r),o=oc.read(e,t,i);if(o&&o.language===n)return{facts:o};if(n==="clojure"){let c=zp(r);return oc.write(e,t,i,c),{facts:c}}let s=M(e,t);if(!s)return{facts:null,unavailable:{language:n,reason:"parser-unavailable"}};let a=qI(s,n);return oc.write(e,t,i,a),{facts:a}}function $I(e){let t={version:Kp,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([n,r])=>[n,[...r]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function GI(e){try{let t=JSON.parse(e);if(t.version!==Kp||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(r=>r.calleeText===void 0)))return null;let n=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([r,i])=>[r,new Set(i)])),identifierLineMap:n,identifiersByLine:tc(n),fileIdentifiers:new Set(n.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function VI(e,t,n,r){let i=he(e,t);return i?WI(i,n,r)?.isLiteralPassthrough??!0:!0}function HI(e,t){return t.relativePath.includes(".clj-kondo/hooks/")?!0:he(e,t.relativePath)?.callables.find(r=>r.startLine===t.startLine&&r.endLine===t.endLine)?.clojureKind==="macro"}function WI(e,t,n){return e.callables.find(r=>r.startLine===t&&r.endLine===n)??null}function qI(e,t){let n=[],r=[],i=new Set,o=new Set,s=new Map,a=(l,u)=>{let d=s.get(l);if(!d){s.set(l,[u]);return}d[d.length-1]!==u&&d.push(u)},c=l=>{let u=ir(l,t);u&&n.push(u);let d=rr(l,t);d&&r.push(d),Wp(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&qp(l.text,i),Gp(l,t)&&a(l.text,l.startPosition.row),Vp(l,t)&&Hp(l,a);for(let p of l.children)c(p)};return c(e.rootNode),{language:t,callables:n,callSites:r,clojureMembers:[],typeContainerMap:Up(e,t),identifierLineMap:s,identifiersByLine:tc(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var Jp=new Set(["rust","typescript","tsx","javascript","python","clojure"]),UI=new Set(["rust","typescript","tsx","javascript","python"]);function Kr(e,t){let n=he(e,t);return!n||!Jp.has(n.language)?null:n.callables.map(r=>({name:r.name,startLine:r.startLine,endLine:r.endLine}))}function ac(e,t){if(!UI.has(t))return null;let n=[];for(let r of e.descendantsOfType([...Bp(t)])){let i=ir(r,t);i&&n.push({name:i.name,startLine:i.startLine,endLine:i.endLine})}return n}function zI(e,t){let n=he(e,t);return!n||!Jp.has(n.language)?null:n.callSites}function KI(e,t){return he(e,t)?.typeContainerMap??new Map}import{createRequire as XI}from"module";var JI=new Set(["children","className","data","e","err","error","ev","event","false","id","idx","index","item","key","null","props","res","result","state","style","true","undefined","val","value"]);function _o(e){return e.length<=2||JI.has(e)}function ko(e,t){return e.split(t).filter(Boolean).map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("")}var YI=$t("vue-template-facts"),QI=XI(import.meta.url),ZI;function Jr(){return ZI??=QI("@vue/compiler-dom")}var eE=new Set(["component","keep-alive","slot","suspense","teleport","template","transition","transition-group"]),tE=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","label","legend","li","link","main","map","mark","menu","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","search","section","select","slot","small","source","span","strong","style","sub","summary","sup","svg","table","tbody","td","template","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr"]),nE=new Set(["div","span","template"]),rE=new Set(["as","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","false","finally","for","from","function","if","import","in","instanceof","let","new","null","of","return","super","switch","this","throw","true","try","typeof","undefined","var","void","while","with","yield"]);function Lo(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return YI.get(e,n,r,()=>iE(n,tr(e,n).template))}function iE(e,t){let n={relativePath:e,template:t?{startLine:t.startLine,endLine:t.endLine}:null,componentTags:[],nativeTags:[],builtinTags:[],props:[],events:[],directives:[],slots:[],expressionIdentifiers:[],structuralTokens:[]};if(!t)return n;let r;try{r=Jr().parse(t.body,{comments:!1})}catch{return n}let i=new Set,o=s=>{s.trim()&&i.add(s)};return Yp(r.children,t.startLine,n,o),n.structuralTokens=[...i].sort(),n}function Yp(e,t,n,r){for(let i of e)if(i.type===Jr().NodeTypes.ELEMENT)oE(i,t,n,r),Yp(i.children,t,n,r);else if(i.type===Jr().NodeTypes.INTERPOLATION){r("interpolation");let o=cc(i.content);o&&Qp(o,t,i.loc.start.line,n,r)}}function oE(e,t,n,r){let i=pE(e.tag),o={tag:e.tag,normalized:i,kind:dE(e),startLine:or(t,e.loc.start.line),endLine:or(t,e.loc.end.line)};o.kind==="component"?(n.componentTags.push(o),r(`component:${i}`)):o.kind==="builtin"?(n.builtinTags.push(o),r(`builtin:${i}`)):(n.nativeTags.push(o),nE.has(e.tag)||r(`native:${e.tag}`));for(let s of e.props)sE(s,t,n,r)}function sE(e,t,n,r){if(e.type===Jr().NodeTypes.ATTRIBUTE){let a=e.value?.content??null,c=Xp("prop",e.name,a,t,e.loc.start.line,e.loc.end.line);n.props.push(c),r(`prop:${e.name}`);return}let i=cE(e),o=cc(e.exp),s=Xp(aE(e.name),i,o,t,e.loc.start.line,e.loc.end.line);switch(s.kind){case"prop":n.props.push(s),r(`prop:${i}`);break;case"event":n.events.push(s),r(`event:${i}`);break;case"slot":n.slots.push(s),r(`slot:${i}`);break;case"directive":n.directives.push(s),r(`directive:${i}`);break}o&&Qp(o,t,e.loc.start.line,n,r)}function Xp(e,t,n,r,i,o){return{kind:e,name:t,value:n,startLine:or(r,i),endLine:or(r,o)}}function aE(e){switch(e){case"bind":case"model":return"prop";case"on":return"event";case"slot":return"slot";default:return"directive"}}function cE(e){let t=cc(e.arg);return t||e.name}function cc(e){if(!e)return null;let t=("content"in e&&typeof e.content=="string"?e.content:e.loc.source).trim();return t||null}function Qp(e,t,n,r,i){for(let o of lE(e)){let s={name:o,startLine:or(t,n),endLine:or(t,n)};r.expressionIdentifiers.push(s),i(`id:${o}`)}}function lE(e){let t=new Set,n=uE(e),r=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,i;for(;i=r.exec(n);){let o=i[0];rE.has(o)||_o(o)||/^[A-Z_]+$/.test(o)||t.add(o)}return[...t].sort()}function uE(e){return e.replace(/\/\*[\s\S]*?\*\//g," ").replace(/\/\/.*$/gm," ").replace(/`(?:\\[\s\S]|\$\{([^}]*)\}|[^`\\])*`/g,(t,n)=>n??" ").replace(/'(?:\\[\s\S]|[^'\\])*'/g," ").replace(/"(?:\\[\s\S]|[^"\\])*"/g," ")}function dE(e){let t=e.tag;return e.tagType===Jr().ElementTypes.COMPONENT?"component":eE.has(t)?"builtin":tE.has(t)?"native":/^[A-Z]/.test(t)||t.includes("-")?"component":"native"}function pE(e){return ko(e,/[-_:]/)}function or(e,t){return e+Math.max(0,t-1)}var fE=new Set(["ref","shallowRef","reactive","computed","watch","watchEffect"]),mE=new Set(["onBeforeMount","onMounted","onBeforeUpdate","onUpdated","onBeforeUnmount","onUnmounted","onActivated","onDeactivated","onErrorCaptured"]),gE=new Set(["axios","fetch","runRequest","useAsyncData","useFetch","useResource"]),yE=new Set(["defineEmits","defineExpose","defineModel","defineOptions","defineProps","withDefaults"]),hE=new Set(["catch","for","function","if","return","switch","while"]);function Ao(e){let t={imports:[],functions:[],calls:[],composables:[],stores:[],reactivity:[],lifecycle:[],requests:[],macros:[],lineCount:0,externalLineCount:0,externalScriptPaths:[],unresolvedScripts:[]};for(let n of e.scripts){t.lineCount+=Pn(n),n.external&&(t.externalLineCount+=Pn(n),t.externalScriptPaths.push(n.sourcePath));for(let i of n.errors)t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:i});if(!n.body||!n.astLanguage){n.astLanguage||t.unresolvedScripts.push({sourcePath:n.sourcePath,reason:`Unsupported Vue script language: ${n.lang??"unknown"}`});continue}t.imports.push(...vE(n));let r=Et(n.astLanguage,n.body);r?bE(n,r.rootNode,t):xE(n,t)}return SE(t),t.externalScriptPaths=ef(t.externalScriptPaths),t}function SE(e){e.composables=sr(e,"composable"),e.stores=sr(e,"store"),e.reactivity=sr(e,"reactivity"),e.lifecycle=sr(e,"lifecycle"),e.requests=sr(e,"request"),e.macros=sr(e,"macro")}function sr(e,t){return ef(e.calls.filter(n=>n.categories.includes(t)).map(n=>n.name))}function bE(e,t,n){let r=new Set,i=new Set,o=s=>{let a=ir(s,e.astLanguage);if(a){let l=`${a.name}:${a.startLine}:${a.endLine}`;i.has(l)||(i.add(l),n.functions.push({name:a.name,sourcePath:e.sourcePath,startLine:e.startLine+a.startLine,endLine:e.startLine+a.endLine,setup:e.setup}))}let c=rr(s,e.astLanguage);if(c){let l=`${c.calleeLeaf}:${c.line}`;r.has(l)||(r.add(l),n.calls.push({name:c.calleeLeaf,sourcePath:e.sourcePath,line:e.startLine+c.line,categories:Zp(c.calleeLeaf),setup:e.setup}))}for(let l of s.children)o(l)};o(t)}function xE(e,t){for(let n of e.body.matchAll(/\b([A-Za-z_$][\w$]*)\s*\(/g)){let r=n[1];!r||hE.has(r)||t.calls.push({name:r,sourcePath:e.sourcePath,line:e.startLine+Do(e.body,n.index??0),categories:Zp(r),setup:e.setup})}for(let n of e.body.matchAll(/\bfunction\s+([A-Za-z_$][\w$]*)\b/g)){let r=n[1];if(!r)continue;let i=e.startLine+Do(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}for(let n of e.body.matchAll(/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(?:async\s*)?(?:function\b|\([^)]*\)\s*=>|[A-Za-z_$][\w$]*\s*=>)/g)){let r=n[1];if(!r)continue;let i=e.startLine+Do(e.body,n.index??0);t.functions.push({name:r,sourcePath:e.sourcePath,startLine:i,endLine:i,setup:e.setup})}}function vE(e){let t=[];for(let n of e.body.matchAll(/\bimport\s+(?:type\s+)?([^'";]+?)\s+from\s+['"]([^'"]+)['"]/g)){let r=n[1]?.trim(),i=n[2];if(!r||!i)continue;let o=e.startLine+Do(e.body,n.index??0);for(let s of IE(r))t.push({local:s,source:i,sourcePath:e.sourcePath,line:o,setup:e.setup})}return t}function IE(e){let t=[],r=e.split(",").map(s=>s.trim()).filter(Boolean)[0];r&&!r.startsWith("{")&&!r.startsWith("*")&&t.push(r);let i=/\{([^}]*)\}/.exec(e)?.[1];if(i)for(let s of i.split(",")){let a=s.trim();if(!a)continue;let c=/\bas\s+([A-Za-z_$][\w$]*)$/.exec(a)?.[1];t.push(c??a.replace(/^type\s+/,"").trim())}let o=/\*\s+as\s+([A-Za-z_$][\w$]*)/.exec(e)?.[1];return o&&t.push(o),t.filter(s=>/^[A-Za-z_$][\w$]*$/.test(s))}function Zp(e){let t=["call"];return/^use[A-Z0-9_]/.test(e)&&t.push("composable"),/^use[A-Z0-9_].*Store$/.test(e)&&t.push("store"),fE.has(e)&&t.push("reactivity"),mE.has(e)&&t.push("lifecycle"),gE.has(e)&&t.push("request"),yE.has(e)&&t.push("macro"),t}function Do(e,t){let n=0;for(let r=0;r<t&&r<e.length;r+=1)e.charCodeAt(r)===10&&(n+=1);return n}function ef(e){return[...new Set(e)].sort()}var EE=new Set(["in","key","of"]),RE=new Set(["computed","defineEmits","defineProps","reactive","ref","watch","watchEffect"]),PE=$t("vue-component-behavior-profiles");function tf(e,t={}){let n=Me(e,{extensions:[".vue"]}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).map(i=>lc(e,i)).filter(i=>(t.minTemplateTokens===void 0||i.templateTokens.size>=t.minTemplateTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function lc(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n),i=PE.get(e,n,r,()=>wE(e,n,r));return FE(i)}function wE(e,t,n){let r=tr(e,t),i=Lo(e,t),o=Ao(r),s=_E(i),a=i.expressionIdentifiers.map(m=>m.name).filter(m=>!s.includes(m)).filter((m,S,h)=>h.indexOf(m)===S).sort(),c=i.componentTags.map(m=>m.normalized).filter((m,S,h)=>h.indexOf(m)===S).sort(),l=n?n.split(`
|
|
113
|
+
`).length:0,u=Pn(r.template),d=o.lineCount,p=r.styles.reduce((m,S)=>m+Pn(S),0),f=r.customBlocks.reduce((m,S)=>m+Pn(S),0),{lines:g,paths:y}=CE(e,t,o);return{file:t,sfc:r,templateFacts:i,scriptFacts:o,templateTokens:new Set(i.structuralTokens),behaviorTokens:NE(i,o,a),templateBindingNames:a,templateLocalNames:s,componentNames:c,sfcLines:l,totalLines:l+o.externalLineCount,templateLines:u,scriptLines:d,styleLines:p,externalScriptLines:o.externalLineCount,externalScriptPaths:o.externalScriptPaths,customBlockLines:f,delegatedComposableLines:g,delegatedComposablePaths:y}}function CE(e,t,n){let r=new Set;for(let s of n.composables){let a=n.imports.find(l=>l.local===s);if(!a)continue;let c=at(e,a.sourcePath,a.source);!c||c===t||r.add(c)}let i=[...r].sort();return{lines:i.reduce((s,a)=>{let c=F(e,a);return s+(c?c.split(`
|
|
114
|
+
`).length:0)},0),paths:i}}function FE(e){let t=TE(e.scriptFacts);return{...e,scriptFacts:t,templateTokens:new Set(e.templateTokens),behaviorTokens:new Set(e.behaviorTokens),templateBindingNames:[...e.templateBindingNames],templateLocalNames:[...e.templateLocalNames],componentNames:[...e.componentNames],externalScriptPaths:t.externalScriptPaths,delegatedComposablePaths:[...e.delegatedComposablePaths]}}function TE(e){return{...e,imports:e.imports.map(t=>({...t})),functions:e.functions.map(t=>({...t})),calls:e.calls.map(t=>({...t,categories:[...t.categories]})),composables:[...e.composables],stores:[...e.stores],reactivity:[...e.reactivity],lifecycle:[...e.lifecycle],requests:[...e.requests],macros:[...e.macros],externalScriptPaths:[...e.externalScriptPaths],unresolvedScripts:e.unresolvedScripts.map(t=>({...t}))}}function NE(e,t,n){let r=new Set;for(let i of t.composables)r.add(`composable:${i}`);for(let i of t.stores)r.add(`store:${i}`);for(let i of t.reactivity)r.add(`reactivity:${i}`);for(let i of t.lifecycle)r.add(`lifecycle:${i}`);for(let i of t.requests)r.add(`request:${i}`);for(let i of t.macros)r.add(`macro:${i}`);for(let i of t.functions){if(RE.has(i.name))continue;r.add(`function:${i.name}`);let o=/^[a-z]+/.exec(i.name)?.[0]??null;o&&o.length>2&&o!==i.name&&r.add(`function-verb:${o}`)}for(let i of e.events)r.add(`template-event:${i.name}`);for(let i of n)r.add(`template-binding:${i}`);return r}function _E(e){let t=new Set;for(let n of e.directives)if(n.name==="for"&&n.value)for(let r of kE(n.value))t.add(r);for(let n of e.slots)if(n.value)for(let r of nf(n.value))t.add(r);return[...t].sort()}function kE(e){let t=/^(.*?)\s+(?:in|of)\s+/.exec(e.trim());return t?nf(t[1]??""):[]}function nf(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];EE.has(r)||t.push(r)}return t}import{extname as LE}from"path";var DE=[".tsx",".jsx"],rf=new Set(["useActionState","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useOptimistic","useReducer","useRef","useState","useSyncExternalStore","useTransition"]),AE=new Set(["useEffect","useInsertionEffect","useLayoutEffect"]),OE=new Set(["useActionState","useOptimistic","useReducer","useRef","useState"]),ME=new Set(["useLocation","useNavigate","useParams","useSearchParams","useTranslation"]),jE=new Set(["axios","fetch","gql","graphql","mutate","query","request","useMutation","useQuery","useSuspenseQuery"]),BE=new Set(["add","apply","cancel","change","clear","close","create","delete","fetch","filter","handle","load","open","refresh","remove","render","reset","save","select","submit","toggle","update"]),$E=new Set(["aria-hidden","className","clipRule","d","fill","fillRule","height","role","stroke","strokeLinecap","strokeLinejoin","strokeWidth","style","viewBox","width","xmlns"]),GE=$t("react-component-behavior-profiles"),of=ce({kind:"react-component-behavior-profiles",invalidation:te("react-component-behavior-profiles"),serialize:qE,deserialize:UE});function lf(e,t={}){let n=Me(e,{extensions:DE}).filter(i=>!t.scope||i.includes(t.scope)).sort();return(typeof t.scanLimit=="number"&&t.scanLimit>0?n.slice(0,t.scanLimit):n).flatMap(i=>dc(e,i)).filter(i=>(t.minJsxTokens===void 0||i.jsxTokens.size>=t.minJsxTokens)&&(t.minBehaviorTokens===void 0||i.behaviorTokens.size>=t.minBehaviorTokens))}function dc(e,t){let n=t.replace(/\\/g,"/"),r=F(e,n);return GE.get(e,n,r,()=>VE(e,n,r)).map(WE)}function VE(e,t,n){let r=fe(e,t,n),i=of.read(e,t,r);if(i)return i;let o=HE(e,t);return of.write(e,t,r,o),o}function HE(e,t){let n=KE(t);if(!n)return[];let r=M(e,t);if(!r)return[];let i=jr(e,t).length;return JE(r.rootNode,n).filter(s=>s.kind==="hook"||pc(s.bodyNode)).map(s=>{let a=nR(s.bodyNode),c=aR(s.bodyNode,n);return{file:t,name:s.name,kind:s.kind,startLine:s.node.startPosition.row,endLine:s.node.endPosition.row,loc:Math.max(1,s.node.endPosition.row-s.node.startPosition.row+1),fileLines:i,jsxTokens:a.tokens,behaviorTokens:c.tokens,componentNames:Pt(a.componentNames),nativeTags:Pt(a.nativeTags),propNames:Pt(a.propNames),eventNames:Pt(a.eventNames),hookNames:Pt(c.hookNames),requestNames:Pt(c.requestNames),stateNames:Pt(c.stateNames),effectNames:Pt(c.effectNames),handlerNames:Pt(c.handlerNames)}})}function WE(e){return{...e,jsxTokens:new Set(e.jsxTokens),behaviorTokens:new Set(e.behaviorTokens),componentNames:[...e.componentNames],nativeTags:[...e.nativeTags],propNames:[...e.propNames],eventNames:[...e.eventNames],hookNames:[...e.hookNames],requestNames:[...e.requestNames],stateNames:[...e.stateNames],effectNames:[...e.effectNames],handlerNames:[...e.handlerNames]}}function qE(e){return JSON.stringify(e.map(t=>({...t,jsxTokens:[...t.jsxTokens],behaviorTokens:[...t.behaviorTokens]})))}function UE(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return null;let n=[];for(let r of t){let i=zE(r);if(!i)return null;n.push(i)}return n}catch{return null}}function zE(e){if(!qt(e))return null;let{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:c,behaviorTokens:l,componentNames:u,nativeTags:d,propNames:p,eventNames:f,hookNames:g,requestNames:y,stateNames:m,effectNames:S,handlerNames:h}=e;if(typeof t!="string"||typeof n!="string"||r!=="component"&&r!=="hook"||!Oo(i)||!Oo(o)||!Oo(s)||!Oo(a))return null;let v={jsxTokens:Be(c),behaviorTokens:Be(l),componentNames:Be(u),nativeTags:Be(d),propNames:Be(p),eventNames:Be(f),hookNames:Be(g),requestNames:Be(y),stateNames:Be(m),effectNames:Be(S),handlerNames:Be(h)};return Object.values(v).some(E=>E===null)?null:{file:t,name:n,kind:r,startLine:i,endLine:o,loc:s,fileLines:a,jsxTokens:new Set(v.jsxTokens),behaviorTokens:new Set(v.behaviorTokens),componentNames:v.componentNames,nativeTags:v.nativeTags,propNames:v.propNames,eventNames:v.eventNames,hookNames:v.hookNames,requestNames:v.requestNames,stateNames:v.stateNames,effectNames:v.effectNames,handlerNames:v.handlerNames}}function Oo(e){return typeof e=="number"&&Number.isFinite(e)}function KE(e){let t=LE(e).toLowerCase();return t!==".tsx"&&t!==".jsx"?null:oe(e)}function JE(e,t){let n=[],r=new Set,i=o=>{let s=XE(o);if(s&&(!eR(o)||s.kind==="component")){let a=`${s.name}:${s.node.startIndex}:${s.node.endIndex}`;r.has(a)||(r.add(a),n.push(s))}for(let a of o.namedChildren)i(a)};return(t==="tsx"||t==="javascript")&&i(e),n}function XE(e){if(e.type==="class_declaration"){let o=uc(e);if(!o||!/^[A-Z]/.test(o))return null;let s=YE(e);return!s||!QE(e)&&!pc(s)?null:{name:o,kind:"component",node:e,bodyNode:s}}if(e.type==="function_declaration"){let o=uc(e);return!o||!sf(o)?null:{name:o,kind:af(o),node:e,bodyNode:e}}if(e.type!=="variable_declarator")return null;let t=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1),r=Xr(t);if(!r||!n||!sf(r))return null;let i=ZE(n);return i?{name:r,kind:af(r),node:e,bodyNode:i}:null}function YE(e){for(let t of e.namedChildren)if(t.type==="class_body")for(let n of t.namedChildren){if(n.type!=="method_definition")continue;if((n.childForFieldName("name")??n.namedChild(0))?.text==="render")return n}return null}function QE(e){return/\b(?:React\.)?(?:Pure)?Component\b/.test(e.text)}function sf(e){return/^[A-Z]/.test(e)||/^use[A-Z0-9_]/.test(e)}function af(e){return/^use[A-Z0-9_]/.test(e)?"hook":"component"}function ZE(e){if(e.type==="arrow_function"||e.type==="function_expression")return e;if(e.type!=="call_expression")return null;let t=tR(e);return t!=="memo"&&t!=="forwardRef"?null:e.namedChildren.find(i=>i.type==="arguments")?.namedChildren.find(i=>i.type==="arrow_function"||i.type==="function_expression")??null}function eR(e){let t=e.parent;for(;t;){if(t.type==="function_declaration"||t.type==="function_expression"||t.type==="arrow_function"||t.type==="method_definition")return!0;t=t.parent}return!1}function uc(e){return Xr(e.childForFieldName("name")??e.namedChild(0))}function tR(e){let t=e.childForFieldName("function")??e.namedChild(0);return t?t.text.split(".").pop()??t.text:null}function pc(e){return e.type.startsWith("jsx_")?!0:e.namedChildren.some(pc)}function nR(e){let t={tokens:new Set,componentNames:new Set,nativeTags:new Set,propNames:new Set,eventNames:new Set},n=r=>{r.type==="jsx_opening_element"||r.type==="jsx_self_closing_element"?rR(r,t):r.type==="jsx_element"&&r.text.trimStart().startsWith("<>")?t.tokens.add("jsx:fragment"):r.type==="jsx_expression"?iR(r,t):r.type==="jsx_fragment"&&t.tokens.add("jsx:fragment");for(let i of r.children)n(i)};return n(e),t}function rR(e,t){let n=oR(e),r=!1;if(n){let i=cf(n),o=i==="Fragment"||i==="React.Fragment";r=pR(i)&&!o,o?t.tokens.add("jsx:fragment"):r?(t.componentNames.add(i),t.tokens.add(`component:${i}`)):(t.nativeTags.add(i),t.tokens.add(`native:${i}`))}for(let i of e.namedChildren)if(i.type==="jsx_attribute"){let o=sR(i);if(!o)continue;let s=cf(o);if(s.startsWith("on")&&s.length>2){let a=s.slice(2).replace(/^[A-Z]/,c=>c.toLowerCase());t.eventNames.add(a),t.tokens.add(`event:${a}`)}else $E.has(s)||(t.propNames.add(s),t.tokens.add(`${r?"prop":"native-prop"}:${s}`))}else i.type==="jsx_spread_attribute"&&t.tokens.add(uf(i))}function iR(e,t){let n=e.text;/^\{\s*\.\.\./.test(n)&&t.tokens.add(uf(e)),df(e)&&t.tokens.add("jsx:conditional"),(n.includes(".map(")||n.includes(".flatMap("))&&t.tokens.add("jsx:list");for(let r of fR(n))_o(r)||t.tokens.add(`binding:${r}`)}function uf(e){let t=/^\{\s*\.\.\.\s*([^}]+)\s*\}$/.exec(e.text)?.[1],n=e.namedChildren.find(o=>o.type!=="comment"),r=t??n?.text??"",i=/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.exec(r.trim())?.[0];return i?`prop:spread:${i}`:"prop:spread"}function df(e){return e.type==="ternary_expression"||e.type==="conditional_expression"?!0:e.namedChildren.some(df)}function oR(e){for(let t of e.namedChildren)if(t.type==="identifier"||t.type==="jsx_identifier"||t.type==="property_identifier"||t.type==="member_expression"||t.type==="jsx_member_expression")return t.text;return/^<\s*([A-Za-z][\w$.]*)/.exec(e.text)?.[1]??null}function sR(e){for(let t of e.namedChildren)if(t.type==="property_identifier"||t.type==="identifier"||t.type==="jsx_identifier")return t.text;return/^([A-Za-z_$][\w$:-]*)/.exec(e.text)?.[1]??null}function aR(e,t){let n={tokens:new Set,hookNames:new Set,requestNames:new Set,stateNames:new Set,effectNames:new Set,handlerNames:new Set},r=i=>{if(i.type==="call_expression"){let o=rr(i,t);o&&cR(o.calleeLeaf,n)}else if(i.type==="variable_declarator")uR(i,n);else if(i.type==="function_declaration"){let o=uc(i);o&&pf(o,n)}for(let o of i.namedChildren)r(o)};return r(e),n}function cR(e,t){/^use[A-Z0-9_]/.test(e)&&(t.hookNames.add(e),!rf.has(e)&&!ME.has(e)&&t.tokens.add(`hook:${e}`)),rf.has(e)&&t.tokens.add(`react-hook:${e}`),AE.has(e)&&(t.effectNames.add(e),t.tokens.add(`effect:${e}`)),OE.has(e)&&t.tokens.add(`state-hook:${e}`),lR(e)&&(t.requestNames.add(e),t.tokens.add(`request:${e}`))}function lR(e){if(jE.has(e))return!0;let t=/^use([A-Z0-9_].*)$/.exec(e)?.[1];return t?/(Query|Mutation|Fetch|Resource)$/.test(t):!1}function uR(e,t){let n=e.childForFieldName("name")??e.namedChild(0),r=e.childForFieldName("value")??e.namedChild(1);if(n?.type==="array_pattern"&&r?.text.includes("useState")){let o=n.namedChildren.find(a=>Xr(a)),s=Xr(o);s&&(t.stateNames.add(s),t.tokens.add(`state:${s}`))}let i=Xr(n);i&&pf(i,t)}function pf(e,t){let n=dR(e);!n||!BE.has(n)||(t.handlerNames.add(e),t.tokens.add(`handler:${e}`),t.tokens.add(`handler-verb:${n}`))}function dR(e){let t=e.startsWith("handle")&&e.length>6?e.slice(6).replace(/^[A-Z]/,n=>n.toLowerCase()):e;return/^[a-z]+/.exec(t)?.[0]??null}function pR(e){return/^[A-Z]/.test(e)||e.includes(".")}function cf(e){return e.replace(/^this\./,"").replace(/\$/g,".")}function Xr(e){return e&&(e.type==="identifier"||e.type==="property_identifier"||e.type==="shorthand_property_identifier"||/^[A-Za-z_$][\w$]*$/.test(e.text))?e.text:null}function fR(e){let t=[];for(let n of e.matchAll(/\b[A-Za-z_$][\w$]*\b/g)){let r=n[0];t.includes(r)||t.push(r)}return t}function Pt(e){return[...e].sort()}function f0(e){return{capability:(t,n)=>mR(t,n),reactProfiles:(t={})=>lf(e,t),reactProfilesForFile:t=>dc(e,t),vueProfiles:(t={})=>tf(e,t),vueProfileForFile:t=>lc(e,t),vueTemplateFacts:t=>Lo(e,t),vueScriptFacts:t=>Ao(tr(e,t))}}function mR(e,t){let n=e.startsWith("react-")?"react":"vue";if(t===void 0)return{slot:e,available:!0,framework:n};let r=t.replace(/\\/g,"/").toLowerCase();return n==="react"&&!r.endsWith(".tsx")&&!r.endsWith(".jsx")?{slot:e,available:!1,framework:n,reason:"React behavior profiles are only available for .tsx and .jsx files"}:n==="vue"&&!r.endsWith(".vue")?{slot:e,available:!1,framework:n,reason:"Vue behavior facts are only available for .vue files"}:{slot:e,available:!0,framework:n}}function gR(e,t,n={}){let r=he(e,t);if(!r)return[];let i=[];if(n.includeCrossLanguageDispatchNames)for(let o of r.crossLanguageDispatchNames)i.push({name:o,kind:"cross-language-dispatch",occurrences:1});if(n.includeRustAttributeNames&&r.language==="rust")for(let o of r.rustAttrReferencedNames)i.push({name:o,kind:"rust-attribute",occurrences:1});return i}var yR=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function we(e){let t=[],n=0,r=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&n++,(o==="}"||o==="]"||o===")")&&n--,o===","&&n===0&&(t.push(e.slice(r,i)),r=i+1)}return t.push(e.slice(r)),t}function _e(e,t){for(let n of e.namedChildren)if(n.type===t)return n;return null}function J(e,t){let n=new Set,r=(i,o)=>{let s=o||t.has(i.type);!s&&yR.has(i.type)&&n.add(i.text);for(let a of i.children)r(a,s)};return r(e.rootNode,!1),n}function Ye(e,t,n,r,i,o,s){return{importedName:i,localName:o,sourcePath:s??K(e,r,$a(t)),kind:"named",used:Pe(n,o),usedMembers:[]}}function q(e,t,n,r,i="named",o={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function wt(e,t,n,r,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:n,kind:i,used:r,usedMembers:o,isTypeOnly:s.isTypeOnly}}function wn(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function Cn(e,t,n={}){return{importedName:e,localName:n.localName??null,sourcePath:t,kind:"namespace",used:n.used??!0,usedMembers:n.usedMembers??[],isTypeOnly:n.isTypeOnly}}function He(e,t,n){let r=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=zt(e,i.index,i.index+o.length);for(let a of n(i,s))r.push(a)}return r}function We(e,t,n,r,i){let o=Wr(e,t,i)?.tree??null;if(o){let s=n(o);if(s)return s}return r()}function Mo(e,t,n,r,i){let o=Wr(e,t,i)?.tree??null,s=oe(t),a=s?n[s]:void 0;return o&&a?a(o):r()}function mf(e,t,n){return We(e,t,r=>SR(e,t,r),()=>hR(e,t,n),n)}function hR(e,t,n){return He(n,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(r,i)=>{let o=r[1]?.trim();if(!o)return[];let s=ff(o).replace(/\.[^.]+$/,"");return[wt(o,s,Ro(e,t,o),Pe(i,s))]})}function SR(e,t,n){let r=J(n,new Set(["preproc_include"])),i=[];for(let o of n.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(u=>u.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=ff(s).replace(/\.[^.]+$/,"");i.push(q(s,a,Ro(e,t,s),r))}return i}var bR=new Set([":require",":require-macros",":use"]),gc=String.raw`A-Za-z0-9_$*+!?.<>=-`;function yf(e,t,n){let r=NR(n);if(!r)return[];let i=TR(n,r.start,r.end),o=[];for(let s of r.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=qe(s.children[0]);if(a){if(bR.has(a)){for(let c of IR(s.children.slice(1)))o.push(...vR(e,c,i));continue}if(a===":import")for(let c of RR(s.children.slice(1)))o.push(c)}}return o}function xR(e){return e.type==="list"&&qe(e.children[0])==="ns"}function vR(e,t,n){let r=Ga(e,t.namespace),i=t.alias??t.namespace,o=wR(n,i),s=[{importedName:t.namespace,localName:i,sourcePath:r,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||CR(n,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:r,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:r,kind:"named",used:FR(n,a),usedMembers:[]});return s}function IR(e){return e.flatMap(t=>jo(t,null))}function jo(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:mc(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&qe(e.children[0])===null?e.children.flatMap(n=>jo(n,t)):ER(e,t);if(e.type==="list"&&e.children.length>0){let n=qe(e.children[0]);return n?!n||n.startsWith(":")?[]:e.children.slice(1).flatMap(r=>jo(r,mc(t,n))):e.children.flatMap(r=>jo(r,t))}return[]}function ER(e,t){let n=qe(e.children[0]);if(!n||n.startsWith(":"))return[];let r={namespace:mc(t,n),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=qe(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){r.alias=qe(s),i+=1;continue}o===":refer"&&s&&(qe(s)===":all"?r.referAll=!0:(s.type==="vector"||s.type==="list")&&r.refers.push(...s.children.map(qe).filter(PR)),i+=1)}return[r]}function RR(e){let t=[];for(let n of e){if(n.type==="atom"){let i=n.text.split(".").pop()??n.text;t.push(wt(i,i,null,!0));continue}if(n.type!=="vector")continue;let r=qe(n.children[0]);if(r)for(let i of n.children.slice(1)){let o=qe(i);o&&t.push(wt(`${r}.${o}`,o,null,!0))}}return t}function mc(e,t){return e?`${e}.${t}`:t}function qe(e){return e?.type==="atom"?e.text:null}function PR(e){return!!(e&&!e.startsWith(":"))}function wR(e,t){let n=new Set,r=new RegExp(`${yc()}${le(t)}\\s*/\\s*([${gc}]+)`,"g");for(let i of e.matchAll(r)){let o=i[1];o&&n.add(o)}return[...n]}function CR(e,t){return new RegExp(`${yc()}${le(t)}\\s*/`,"m").test(e)}function FR(e,t){return new RegExp(`${yc()}${le(t)}(?![${gc}])`,"m").test(e)}function yc(){return`(?<![${gc}])`}function TR(e,t,n){let r="",i=0;for(;i<e.length;){if(i>=t&&i<n){r+=e[i]===`
|
|
115
|
+
`?`
|
|
116
|
+
`:" ",i+=1;continue}let o=e[i];if(o===";"){let s=No(e,i);r+=gf(e.slice(i,s)),i=s;continue}if(o==='"'){let s=zr(e,i,0).index;r+=gf(e.slice(i,s)),i=s;continue}r+=o,i+=1}return r}function NR(e){let t=0;for(;t<e.length&&(t=hc(e,t),!(t>=e.length));){let n=Bo(e,t);if(!n){t+=1;continue}if(xR(n.form))return n.form;t=n.index}return null}function Bo(e,t){let n=hc(e,t);if(e.startsWith("#?@",n)||e.startsWith("#?",n))return _R(e,n);if(e.startsWith("#_",n)){let i=Bo(e,n+2);return i?{form:{type:"atom",text:"",start:n,end:i.index},index:i.index}:null}for(;rc(e[n]);)n+=1;let r=e[n];return r?r==="("?fc(e,n,"list",")"):r==="["?fc(e,n,"vector","]"):r==="{"?fc(e,n,"map","}"):r==='"'?{form:{type:"atom",text:"",start:n,end:zr(e,n,0).index},index:zr(e,n,0).index}:LR(e,n):null}function _R(e,t){let n=e.startsWith("#?@",t)?3:2,r=Bo(e,t+n);return r?{form:{type:"list",children:r.form.type==="list"||r.form.type==="vector"||r.form.type==="map"?kR(r.form.children):[],start:t,end:r.index},index:r.index}:null}function kR(e){let t=[];for(let n=0;n<e.length;n+=2){let r=qe(e[n]),i=e[n+1];r?.startsWith(":")&&i&&t.push(i)}return t}function fc(e,t,n,r){let i=[],o=t+1;for(;o<e.length;){if(o=hc(e,o),e[o]===r)return{form:{type:n,children:i,start:t,end:o+1},index:o+1};let s=Bo(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:n,children:i,start:t,end:e.length},index:e.length}}function LR(e,t){let n=t;for(;n<e.length&&!ic(e[n]);)n+=1;return{form:{type:"atom",text:e.slice(t,n),start:t,end:n},index:n}}function hc(e,t){let n=t;for(;n<e.length;){let r=e[n];if(/\s|,/.test(r)){n+=1;continue}if(r===";"){n=No(e,n);continue}break}return n}function gf(e){return e.replace(/[^\r\n]/g," ")}function hf(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=zt(n,i.index,i.index+a.length);r.push({importedName:o,localName:s,sourcePath:Po(e,t,o),kind:s?"namespace":"side-effect",used:s?Pe(c,s):!0,usedMembers:s?Zn(c,s):[]})}return r}function Sf(e,t,n){let r=[];for(let i of n.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&r.push({specifier:o,sourcePath:Po(e,t,o)})}return r}function bf(e,t,n){return Mo(e,t,{csharp:r=>AR(e,t,r),vb:r=>DR(e,t,r)},()=>{let r=gp(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return He(n,r,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,u=(l?c:a)?.trim()??s,d=u.split(".").pop()??u,p=l?a?.trim()??d:d;return[Ye(e,t,o,u,d,p,K(e,u,Wt))]})},n)}function DR(e,t,n){let r=J(n,new Set(["imports_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(p=>p.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,u=l.split(".").pop()??l,d=c?.text??u;i.push(q(u,d,K(e,l,Wt),r,c?"namespace":"named"))}return i}function AR(e,t,n){let r=J(n,new Set(["using_directive"])),i=[];for(let o of n.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,u=l.split(".").pop()??l,d=a?.text??u;i.push(q(u,d,K(e,l,Wt),r,a?"namespace":"named"))}return i}var OR=C("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function xf(e,t){return OR.get(e,t,()=>{let n=new Set,r=F(e,t);if(!r)return n;let o=r.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))n.add(s[0]);return n})}function Sc(e,t,n){return We(e,t,r=>jR(e,t,r),()=>MR(e,t,n),n)}function MR(e,t,n){return JR(n).flatMap(r=>XR(e,t,r.clause,r.specifier,r.start,r.end,n))}function jR(e,t,n){let r=BR(e,t,n),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))i.push(...$R(e,t,n,o,r));return i}function BR(e,t,n){let r=J(n,new Set(["import_statement"]));if(Xe(t))for(let i of xf(e,t))r.add(i);return r}function $R(e,t,n,r,i){let o=qR(r);if(!o)return[];let s=at(e,t,o),a=_e(r,"import_clause");return a?GR(n,a,s,i,UR(r.text)):[wn("*",s)]}function GR(e,t,n,r,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(VR(s.text,n,r,i));else if(s.type==="namespace_import"){let a=HR(e,s,n,r,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...WR(s,n,r,i));return o}function VR(e,t,n,r){return q("default",e,t,n,"default",{isTypeOnly:r})}function HR(e,t,n,r,i){let s=_e(t,"identifier")?.text??"";if(!s)return null;let a=KR(e,s);return Cn("*",n,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||r.has(s)})}function WR(e,t,n,r){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(q(c,l,t,n,"named",{isTypeOnly:r||zR(o.text)}))}return i}function qR(e){let t=_e(e,"string");if(!t)return null;let n=_e(t,"string_fragment");return n?n.text:null}function UR(e){return/^\s*import\s+type\b/.test(e)}function zR(e){return/^\s*type\b/.test(e.trim())}function KR(e,t){let n=new Set;for(let r of e.rootNode.descendantsOfType("member_expression")){let i=r.namedChild(0),o=r.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&n.add(o.text)}return[...n]}function JR(e){let t=[],n=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let r=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function XR(e,t,n,r,i,o,s){let a=at(e,t,r),c=zt(s,i,o);return n?YR(n).map(u=>({...u,sourcePath:a})).map(u=>{if(u.kind==="namespace"){let d=Zn(c,u.localName);return Cn(u.importedName,u.sourcePath,{localName:u.localName,usedMembers:d,used:d.length>0||Pe(c,u.localName),isTypeOnly:u.isTypeOnly})}return u.kind==="side-effect"?wn(u.importedName,u.sourcePath):wt(u.importedName,u.localName??"",u.sourcePath,u.localName?Pe(c,u.localName):!1,u.kind,[],{isTypeOnly:u.isTypeOnly})}):[wn("*",a)]}function YR(e){let t=e.trim(),n=/^type\b/.test(t),r=t.replace(/^type\s+/,""),[i,o]=QR(r),s=[];return i&&s.push(...vf(i,n)),o&&s.push(...vf(o,n)),s}function vf(e,t){let n=e.trim();if(!n)return[];if(n.startsWith("{")){let r=n.slice(1,-1).trim();return r?we(r).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return n.startsWith("* as ")?[{importedName:"*",localName:n.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:n,kind:"default",isTypeOnly:t}]}function QR(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r==="{"&&t++,r==="}"&&t--,r===","&&t===0)return[e.slice(0,n).trim(),e.slice(n+1).trim()]}return[e.trim(),null]}function bc(e,t,n){let r=M(e,t);return r?iP(e,t,r):ZR(e,t,n)}function ZR(e,t,n){return[...eP(e,t,n),...tP(e,t,n),...nP(e,t,n)]}function eP(e,t,n){let r=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=we(s).map(d=>rP(d.trim())).filter(d=>!!d),l=ar(n,o.index),u=ar(n,o.index+o[0].length-1);r.push({kind:"named",sourcePath:at(e,t,a),names:c,startLine:l,endLine:u})}return r}function tP(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=ar(n,o.index),c=ar(n,o.index+o[0].length-1);r.push({kind:"star-as",sourcePath:at(e,t,s),names:o[1]?[o[1]]:[],startLine:a,endLine:c})}return r}function nP(e,t,n){let r=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of n.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=ar(n,o.index),c=ar(n,o.index+o[0].length-1);r.push({kind:"star",sourcePath:at(e,t,s),names:[],startLine:a,endLine:c})}return r}function rP(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let n=t.match(/^(\w+)\s+as\s+(\w+)$/);if(n)return n[2]??null;let r=t.match(/^(\w+)$/);return r?r[1]??null:null}function ar(e,t){let n=0;for(let r=0;r<t&&r<e.length;r++)e.charCodeAt(r)===10&&n++;return n}function iP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("export_statement")){let o=oP(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=sP(i,o,s,a);r.push(c)}return r}function oP(e,t,n){let r=_e(n,"string");if(!r)return;let i=_e(r,"string_fragment");if(i)return at(e,t,i.text)}function sP(e,t,n,r){let i=_e(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:n,endLine:r}}let o=_e(e,"namespace_export");if(o){let s=o.namedChildren.find(a=>a.type==="identifier"||a.type==="type_identifier")?.text;return{kind:"star-as",sourcePath:t,names:s?[s]:[],startLine:n,endLine:r}}return{kind:"star",sourcePath:t,names:[],startLine:n,endLine:r}}function If(e,t,n){return Mo(e,t,{java:r=>aP(e,t,r),kotlin:r=>cP(e,t,r),scala:r=>lP(e,t,r)},()=>He(n,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(r,i)=>{let o=r[1]?.trim();return o?uP(e,t,o,i):[]}),n)}function aP(e,t,n){let r=J(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(d=>d.type==="asterisk"),c=o.namedChildren.find(d=>d.type==="scoped_identifier")??o.namedChildren.find(d=>d.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(Cn("*",K(e,l,Ne)));continue}let u=l.split(".").pop()??l;i.push(q(u,u,K(e,l,Ne),r))}return i}function cP(e,t,n){let r=J(n,new Set(["import_header","import_list"])),i=[];for(let o of n.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(f=>f.type==="identifier");if(!s)continue;let a=o.namedChildren.some(f=>f.type==="wildcard_import"),c=o.namedChildren.find(f=>f.type==="import_alias");if(a){i.push(Cn("*",K(e,s.text,Ne)));continue}let l=s.text,u=l.split(".").pop()??l,p=c?.namedChild(0)?.text??u;i.push(q(u,p,K(e,l,Ne),r))}return i}function lP(e,t,n){let r=J(n,new Set(["import_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(d=>d.type==="namespace_selectors"||d.type==="namespace_wildcard"),a=o.namedChildren.filter(d=>d!==s&&(d.type==="identifier"||d.type==="stable_identifier")),c=a.map(d=>d.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(Cn("*",K(e,c,Ne)));continue}if(s?.type==="namespace_selectors"){for(let d of s.namedChildren)if(d.type==="arrow_renamed_identifier"){let[p,f]=d.namedChildren;if(!p)continue;let g=p.text,y=f?.text??g;if(g==="_")continue;i.push(q(g,y,K(e,`${c}.${g}`,Ne),r))}else if(d.type==="identifier"){let p=d.text;i.push(q(p,p,K(e,`${c}.${p}`,Ne),r))}continue}let l=a[a.length-1]?.text??c,u=a.slice(0,-1).map(d=>d.text).join(".")||c;i.push(q(l,l,K(e,u&&a.length>1?`${u}.${l}`:c,Ne),r))}return i}function uP(e,t,n,r){if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/\.$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return we(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),u=c?.trim();if(!u||u==="_")return[];let d=(l??u.split(".").pop()??u).trim(),p=u==="_"?i:`${i}.${u}`.replace(/\.\./g,".");return[Ye(e,t,r,p,u,d)]})}return[Ye(e,t,r,n,n.split(".").pop()??n,n.split(".").pop()??n)]}function Rf(e,t,n){return We(e,t,r=>dP(e,t,r),()=>He(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?we(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),u=c?.trim()??a,d=u.split("\\").pop()??u,p=(l??d).trim();return[Ye(e,t,i,u,d,p,K(e,u.replace(/\\/g,"."),En))]}):[]}),n)}function dP(e,t,n){let r=J(n,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(q(a,c,K(e,s.replace(/\\/g,"."),En),r))};for(let s of n.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:u,localName:d,qualified:p}=Ef(l,c);u&&o(p,u,d)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:u,qualified:d}=Ef(c,"");l&&o(d,l,u)}}return i}function Ef(e,t){let n=e.namedChildren.find(l=>l.type==="qualified_name"),r=e.namedChildren.filter(l=>l.type==="name"),i="";n?i=n.text:r.length>=1&&(i=r[0].text);let o=n&&r.length>0?r[r.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function wf(e,t,n){return We(e,t,r=>pP(e,t,r),()=>mP(n).flatMap(r=>yP(e,t,r,n)),n)}function pP(e,t,n){let r=J(n,new Set(["import_statement","import_from_statement"])),i=[];for(let o of n.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=Pf(s);if(!a)continue;let c=Qn(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:r.has(a.localName),usedMembers:[]})}for(let o of n.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=fP(s);if(a===null)continue;let c=Qn(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let u=o.namedChild(l);if(u.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let d=Pf(u);d&&i.push({importedName:d.qualifiedName,localName:d.localName,sourcePath:c,kind:"named",used:r.has(d.localName),usedMembers:[]})}}return i}function Pf(e){if(e.type==="aliased_import"){let t=e.namedChild(0),n=e.namedChild(1);return!t||!n?null:{qualifiedName:t.text,localName:n.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function fP(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=_e(e,"import_prefix")?.text??"",n=_e(e,"dotted_name")?.text??"";return`${t}${n}`}return null}function mP(e){let t=e.split(`
|
|
117
|
+
`),n=[],r=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=r;if(r+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,u=za(o);for(;i+1<t.length&&(u>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
|
|
118
|
+
${p}`,l+=1+p.length,u+=za(p),r+=p.length+1}let d=gP(c);d&&n.push({...d,start:a,end:l})}return n}function gP(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let n=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!n)return null;let r=n[2].trim();return r.startsWith("(")&&r.endsWith(")")&&(r=r.slice(1,-1).trim()),{kind:"from",module:n[1],clause:r}}function yP(e,t,n,r){let i=zt(r,n.start,n.end),o=n.clause.replace(/\n/g," ").trim();if(n.kind==="import")return we(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[u,d]=l.split(/\s+as\s+/),p=u.trim(),f=(d??p.split(".")[0]??p).trim(),g=Qn(e,t,p),y=Zn(i,f);return[{importedName:p,localName:f,sourcePath:g,kind:"namespace",used:Pe(i,f)||y.length>0,usedMembers:y}]});let s=n.module?Qn(e,t,n.module):null,a=[];for(let c of we(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[u,d]=l.split(/\s+as\s+/),p=(d??u).trim();a.push({importedName:u.trim(),localName:p,sourcePath:s,kind:"named",used:Pe(i,p),usedMembers:[]})}return a}import{basename as hP}from"path";function Cf(e,t,n){return We(e,t,r=>bP(e,t,r),()=>SP(e,t,n),n)}function SP(e,t,n){return He(n,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(r,i)=>{let o=r[1],s=r[2];if(!o||!s)return[];let a=o==="require_relative"?Eo(e,t,s):null;if(a){let c=Ff(s);return[wt(c,c,a,Pe(i,c))]}return[wn(s,a)]})}function bP(e,t,n){let r=J(n,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of n.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(f=>f.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let d=l.namedChildren.find(f=>f.type==="string_content")?.text;if(!d)continue;let p=a.text==="require_relative"?Eo(e,t,d):null;if(p){let f=Ff(d);i.push(q(f,f,p,r))}else i.push(wn(d,p))}return i}function Ff(e){return ko(hP(e).replace(/\.[^.]+$/,""),/_/)}function Tf(e,t,n){return We(e,t,r=>xP(e,t,r),()=>He(n,/^[ \t]*use\s+(.+?)\s*;$/gm,(r,i)=>{let o=r[1]?.trim();return o?vP(e,t,o,i):[]}),n)}function xP(e,t,n){let r=J(n,new Set(["use_declaration"])),i=[];for(let o of n.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of Yr(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=vt(e,t,a.qualifiedName)??vt(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(q(a.importedName,a.localName,c,r))}}return i}function Yr(e,t){switch(e.type){case"identifier":case"super":case"crate":{let n=e.text;return[{qualifiedName:$o(t,n),importedName:n,localName:n}]}case"self":{let n=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:n,localName:n}]}case"scoped_identifier":{let n=e.text,r=n.split("::").pop()??n;return[{qualifiedName:$o(t,n),importedName:r,localName:r}]}case"scoped_use_list":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=$o(t,n.text),o=[];for(let s of r.namedChildren)o.push(...Yr(s,i));return o}case"use_list":{let n=[];for(let r of e.namedChildren)n.push(...Yr(r,t));return n}case"use_as_clause":{let n=e.namedChild(0),r=e.namedChild(1);if(!n||!r)return[];let i=Yr(n,t),o=r.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let n=e.namedChild(0),r=n?n.text:"";return[{qualifiedName:$o(t,`${r}::*`),importedName:"*",localName:"*"}]}default:return[]}}function $o(e,t){return e?t?`${e}::${t}`:e:t}function vP(e,t,n,r){let i=n.trim();if(i.includes("{")&&i.includes("}")){let u=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),d=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return we(d).flatMap(p=>{let f=p.trim();if(!f)return[];if(f==="self"){let v=u.split("::").filter(Boolean).pop();return v?[Ye(e,t,r,u,v,v)]:[]}let[g,y]=f.split(/\s+as\s+/),m=g?.trim();if(!m)return[];let S=(y??m.split("::").pop()??m).trim(),h=`${u}::${m}`.replace(/::::/g,"::");return[Ye(e,t,r,h,m.split("::").pop()??m,S,vt(e,t,u))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=vt(e,t,a)??vt(e,t,a.split("::").slice(0,-1).join("::"));return[Ye(e,t,r,a,a.split("::").pop()??a,c,l)]}function Nf(e,t,n){let r=M(e,t);if(r)return IP(e,t,r);let i=[];for(let o of n.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...RP(e,t,s))}return i}function IP(e,t,n){let r=[];for(let i of n.rootNode.descendantsOfType("use_declaration")){if(!EP(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of Yr(o,""))s.importedName&&r.push(xc(e,t,s.qualifiedName))}return r}function EP(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function RP(e,t,n){let r=n.trim();if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/::$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return we(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[xc(e,t,l)]})}return[xc(e,t,r)]}function xc(e,t,n){return{specifier:n,sourcePath:vt(e,t,n)??vt(e,t,n.split("::").slice(0,-1).join("::"))}}function Jt({language:e,extensions:t,imports:n,parseImports:r}){return{language:e,extensions:t,capabilities:{imports:n},parseImports:r}}function _f(e,t){let n=t.toLowerCase();for(let r of e)for(let i of r.extensions)if(n.endsWith(i))return r;return null}var PP={language:"javascript",extensions:vn,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:Sc,parseReExports:bc},wP=Jt({language:"python",extensions:So,imports:"ast-with-regex-fallback",parseImports:wf}),CP=Jt({language:"jvm",extensions:Ne,imports:"ast-dispatch-with-regex-fallback",parseImports:If}),FP={language:"rust",extensions:bo,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:Tf,parseExports:Nf},TP=Jt({language:"ruby",extensions:xo,imports:"ast-with-regex-fallback",parseImports:Cf}),NP=Jt({language:"c/cpp",extensions:vo,imports:"ast-with-regex-fallback",parseImports:mf}),_P=Jt({language:"dotnet",extensions:Wt,imports:"ast-dispatch-with-regex-fallback",parseImports:bf}),kP={language:"dart",extensions:Io,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:hf,parseExports:Sf},LP=Jt({language:"php",extensions:En,imports:"ast-with-regex-fallback",parseImports:Rf}),DP=Jt({language:"clojure",extensions:Yn,imports:"regex-only",parseImports:yf}),kf=[PP,wP,CP,FP,TP,NP,_P,kP,LP,DP];function Qr(e){return _f(kf,e)}function WB(e){return kf.find(n=>n.language===e)?.capabilities??null}var vc={clearGroups:["whole-project","source-file"]},AP=C("source-imports",vc),OP=C("source-exports",vc),MP=C("source-reexports",vc),Lf=ce({kind:"source-imports",invalidation:te("source-imports"),serialize:jP,deserialize:BP}),Df=ce({kind:"source-reexports",invalidation:te("source-reexports"),serialize:$P,deserialize:GP});function Ct(e,t){let n=Z(t);return MP.get(e,n,()=>{let r=Qr(n);if(!r?.parseReExports)return[];let i=F(e,n);if(!i)return[];let o=fe(e,n,i),s=Wa(e),a=Df.read(e,n,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=r.parseReExports(e,n,i);return Df.write(e,n,o,{resolutionFingerprint:s,reExports:c}),c})}function ue(e,t){let n=Z(t);return AP.get(e,n,()=>{let r=Qr(n);if(!r)return[];let i=F(e,n);return i?Af(e,n,i,r):[]})}function Ic(e,t){let n=Z(t),r=Qr(n);if(!r)return[];let i;try{i=Or(e.config.projectRoot,n,{inputKind:"indexed source file"})}catch(o){if(Ht(o))return[];throw o}return Af(e,n,i,r)}function Af(e,t,n,r){let i=fe(e,t,n),o=Wa(e),s=Lf.read(e,t,i);if(s?.resolutionFingerprint===o)return s.imports;let a=r.parseImports(e,t,n);return Lf.write(e,t,i,{parserVersion:2,resolutionFingerprint:o,imports:a}),a}function e$(e,t,n){let r=ue(e,t).filter(i=>i.kind==="named"&&i.isTypeOnly!==!0&&i.localName===n&&i.sourcePath!==null);return r.length===1?r[0]:null}function t$(e,t){let n=Z(t);return OP.get(e,n,()=>{let r=Qr(n);if(!r?.parseExports)return[];let i=F(e,n);return i?r.parseExports(e,n,i):[]})}function jP(e){return JSON.stringify(e)}function BP(e){try{let t=JSON.parse(e);return!qt(t)||t.parserVersion!==2||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{parserVersion:2,resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function $P(e){return JSON.stringify(e)}function GP(e){try{let t=JSON.parse(e);return!qt(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}var Go=tp({kind:"file-dependency-graph",invalidation:te("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:zP}),VP=C("file-dep-graph",{clearGroups:["whole-project"]});function l$(e,t,n){if(n.length===0)return[];let r=new Set(n),i=cr(e),o=new Set;if(t==="forward")for(let s of r)for(let a of i.get(s)??[])r.has(a)||o.add(a);else for(let[s,a]of i)if(!r.has(s))for(let c of r)a.has(c)&&o.add(s);return[...o].sort()}function cr(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",o=ei(t,r,i);return VP.get(e,o,()=>{let s=new Set(Re(e,{includeIgnored:!1})),a=ht(e),c=0,l=0,u=null,d=!1,p=0,f=0,g=null;return z("file-dep-graph.product",()=>{if(a){let h=Go.read(e,o,a);if(h){d=!0,g=h.construction;let v=Mf(h);return c=h.sourceFileCount,l=h.sourceEdgeCount,p=h.scipEdgeCount,f=v.size,u=h.sourceDependencyFingerprint,v}}let y=i==="none"?{files:[],edges:[],fingerprint:U("no-source-dependency-fallback")}:z("file-dep-graph.source-imports",()=>{let h=qP(e,s,t,i);return c=h.files.length,l=h.edges.length,u=h.fingerprint,h},()=>({scope:t??null,sourceEdges:i,files:c,edges:l})),m=new Map,S=(h,v)=>Zr(e,m,s,h,v);z("file-dep-graph.scip-edges",()=>{for(let h of XP(e,t,r))p=(p??0)+1,S(h.from_file,h.to_file)},()=>({scope:t??null,edges:p}));for(let h of y.edges)S(h.fromFile,h.toFile);return f=m.size,a&&(g="full",Go.write(e,o,a,{version:2,construction:"full",sourceDependencyFingerprint:y.fingerprint,sourceFileCount:y.files.length,sourceEdgeCount:y.edges.length,scipEdgeCount:p,edgeCount:jf(m),graph:Of(m)})),m},()=>({scope:t??null,available:a!==null,hit:d,construction:g,files:c,sourceEdges:l,sourceEdgeMode:i,scipEdges:p,graphFiles:f,sourceDependencyFingerprint:u}))})}function u$(e){return HP(e,"none")}function d$(e,t="imports-only"){let n=ei(void 0,"all-references",t),r=ht(e);if(!r)return null;let i=Go.read(e,n,r);return i?{cacheKey:n,sourceEdges:t,graph:Mf(i)}:null}function HP(e,t){let n=ei(void 0,"all-references",t),r=cr(e,void 0,{sourceEdges:t});return{cacheKey:n,sourceEdges:t,graph:r}}function p$(e,t,n,r){let i=t.sourceEdges??"imports-only",o=ht(e);if(!o)return!1;let s=r??WP(e,t,n);if(!s)return!1;let a=new Set(Re(e,{includeIgnored:!1})),c=ei(void 0,"all-references",i);return Go.write(e,c,o,{version:2,construction:"carried",sourceDependencyFingerprint:null,sourceFileCount:a.size,sourceEdgeCount:null,scipEdgeCount:null,edgeCount:jf(s),graph:Of(s)}),!0}function WP(e,t,n,r=[]){let i=t.sourceEdges??"imports-only",o=ei(void 0,"all-references",i);if(t.cacheKey!==o)return null;let s=z("file-dep-graph.carry.indexed-files",()=>new Set(Re(e,{includeIgnored:!1}))),a=new Set(n),c=new Map;z("file-dep-graph.carry.reuse",()=>{if(r.length===0)for(let[u,d]of t.graph)a.has(u)||c.set(u,d);else for(let[u,d]of t.graph)if(!(a.has(u)||!s.has(u)))for(let p of d)Zr(e,c,s,u,p)});let l=z("file-dep-graph.carry.scip-edges",()=>YP(e,a,"all-references"));for(let u of l)Zr(e,c,s,u.from_file,u.to_file);return z("file-dep-graph.carry.source-edges",()=>{for(let u of a)if(s.has(u)){if(i!=="none")for(let d of Ic(e,u))d.sourcePath&&Zr(e,c,s,u,d.sourcePath);if(i==="imports-and-reexports")for(let d of Ct(e,u))d.sourcePath&&Zr(e,c,s,u,d.sourcePath)}}),c}function qP(e,t,n,r){let i=[],o=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let a of Ic(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath});if(r==="imports-and-reexports")for(let a of Ct(e,s))a.sourcePath&&o.push({fromFile:s,toFile:a.sourcePath})}return{files:i,edges:o,fingerprint:UP(i,o)}}function UP(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return U(JSON.stringify({files:e,edges:n}))}function ei(e,t,n){return`edge-mode-v4:${t}:${n}:${e??"<all>"}`}function Of(e){return[...e].map(([t,n])=>[t,[...n].sort()]).sort(([t],[n])=>t.localeCompare(n))}function Mf(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function zP(e){let t=JSON.parse(e);return KP(t)?t:null}function KP(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===2&&(t.construction==="full"||t.construction==="carried")&&(t.sourceDependencyFingerprint===null||typeof t.sourceDependencyFingerprint=="string")&&typeof t.sourceFileCount=="number"&&(t.sourceEdgeCount===null||typeof t.sourceEdgeCount=="number")&&(t.scipEdgeCount===null||typeof t.scipEdgeCount=="number")&&typeof t.edgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(JP)}function jf(e){let t=0;for(let n of e.values())t+=n.size;return t}function JP(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function XP(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],o=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
|
|
119
|
+
d1.relative_path AS from_file,
|
|
120
|
+
d2.relative_path AS to_file
|
|
121
|
+
FROM mentions m
|
|
122
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
123
|
+
JOIN documents d1 ON c.document_id = d1.id
|
|
124
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
125
|
+
JOIN (
|
|
126
|
+
SELECT m2.symbol_id, c2.document_id
|
|
127
|
+
FROM mentions m2
|
|
128
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
129
|
+
WHERE m2.role = 1
|
|
130
|
+
GROUP BY m2.symbol_id
|
|
131
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
132
|
+
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
133
|
+
WHERE d1.id != d2.id
|
|
134
|
+
${o}
|
|
135
|
+
${e.pathExclusionsFor("d1","d2")}
|
|
136
|
+
${r}`,...i)}function YP(e,t,n){let r=[...t].sort();if(r.length===0)return[];let i=n==="imports-only"?"AND m.role = 2":"AND m.role != 1",o=[];for(let s=0;s<r.length;s+=500){let a=r.slice(s,s+500),c=a.map(()=>"?").join(", ");o.push(...e.all(`SELECT DISTINCT
|
|
137
|
+
d1.relative_path AS from_file,
|
|
138
|
+
d2.relative_path AS to_file
|
|
139
|
+
FROM documents d1
|
|
140
|
+
CROSS JOIN chunks c
|
|
141
|
+
CROSS JOIN mentions m
|
|
142
|
+
CROSS JOIN global_symbols gs
|
|
143
|
+
CROSS JOIN chunks c2
|
|
144
|
+
CROSS JOIN documents d2
|
|
145
|
+
WHERE d1.relative_path IN (${c})
|
|
146
|
+
AND c.document_id = d1.id
|
|
147
|
+
AND m.chunk_id = c.id
|
|
148
|
+
AND gs.id = m.symbol_id
|
|
149
|
+
AND c2.id = (
|
|
150
|
+
SELECT m2.chunk_id
|
|
151
|
+
FROM mentions m2
|
|
152
|
+
WHERE m2.symbol_id = gs.id AND m2.role = 1
|
|
153
|
+
ORDER BY m2.chunk_id
|
|
154
|
+
LIMIT 1
|
|
155
|
+
)
|
|
156
|
+
AND d2.id = c2.document_id
|
|
157
|
+
AND d1.id != d2.id
|
|
158
|
+
${i}
|
|
159
|
+
${e.pathExclusionsFor("d1","d2")}`,...a))}return o}function Zr(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let o=t.get(r);o||(o=new Set,t.set(r,o)),o.add(i)}var QP={"/":"namespace","#":"type",".":"term","[":"type-param",":":"meta","!":"macro"};function Qe(e){if(e.startsWith("local "))return{kind:"local",id:e.slice(6),raw:e};let t=e.split(" ");if(t.length<4)return{scheme:t[0]??"",manager:t[1]??"",packageName:t[2]??"",version:"",descriptors:[],raw:e};let n=t[0],r=t[1],i=e.slice(n.length+1+r.length+1),o;if(i.startsWith("`")){let l=i.indexOf("`",1);l===-1?(o=i.slice(1),i=""):(o=i.slice(1,l),i=i.slice(l+2))}else{let l=i.indexOf(" ");l===-1?(o=i,i=""):(o=i.slice(0,l),i=i.slice(l+1))}let s,a=i.indexOf(" ");a===-1?(s=i,i=""):(s=i.slice(0,a),i=i.slice(a+1));let c=ZP(i);return{scheme:n,manager:r,packageName:o,version:s,descriptors:c,raw:e}}function Se(e){let t=Qe(e);if("kind"in t)return null;for(let n=t.descriptors.length-2;n>=0;n--){let r=t.descriptors[n];if(r?.suffix==="type")return r.name}return null}function ZP(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="["){let o=e.indexOf("]",n+1);if(o===-1){t.push({name:e.slice(n+1),suffix:"type-param"});break}t.push({name:e.slice(n+1,o),suffix:"type-param"}),n=o+1;continue}if(e[n]==="("&&(t.length===0||n===0||Bf(e[n-1]))){let o=e.indexOf(")",n+1);if(o!==-1&&e[o+1]!=="."){t.push({name:e.slice(n+1,o),suffix:"parameter"}),n=o+1;continue}}let r;if(e[n]==="`"){let o=e.indexOf("`",n+1);if(o===-1){r=e.slice(n+1),t.push({name:r,suffix:"term"});break}r=e.slice(n+1,o),n=o+1}else{let o=n;for(;n<e.length&&!Bf(e[n]);)n++;r=e.slice(o,n)}if(n>=e.length){r&&t.push({name:r,suffix:"term"});break}let i=e[n];if(i==="("){let o=e.indexOf(")",n+1);o!==-1&&e[o+1]==="."?(t.push({name:r,suffix:"method"}),n=o+2):o!==-1?(t.push({name:r,suffix:"method"}),n=o+1):(t.push({name:r,suffix:"term"}),n++)}else{let o=QP[i];o&&t.push({name:r,suffix:o}),n+=1}}return t}function Bf(e){return e==="/"||e==="#"||e==="."||e==="("||e==="["||e===":"||e==="!"}function Xt(e){let t=Qe(e);if("kind"in t&&t.kind==="local")return`local:${t.id}`;let n=t;if(n.descriptors.length===0)return n.raw;let r=[];for(let i of n.descriptors){let o=ew(i);o&&r.push(o)}return r.join(":")}function ew(e){let t=e.suffix==="namespace"?tw(e.name):e.name;return t?e.suffix==="method"?`${t}()`:t:""}function tw(e){return e.replace(/\.(ts|tsx|js|jsx|mjs|cjs)$/,"").replace(/\.(py|pyi)$/,"").replace(/\.(rs)$/,"").replace(/\.(java|scala|kt|kts)$/,"").replace(/\.(rb)$/,"").replace(/\.(go)$/,"").replace(/\.(cs|vb)$/,"").replace(/\.(dart)$/,"").replace(/\.(php)$/,"").replace(/\.(c|cc|cpp|cxx|h|hpp)$/,"")}function be(e){let t=Qe(e);if("kind"in t&&t.kind==="local")return t.id;let n=t;return n.descriptors.length===0?"":n.descriptors[n.descriptors.length-1].name}function Fn(e){let t=Qe(e);if("kind"in t&&t.kind==="local")return null;let n=t;return n.descriptors[n.descriptors.length-1]?.suffix??null}function Ec(e){return e.endsWith("().")||Fn(e)==="method"}function lr(e){let t=Fn(e);return t==="method"?!0:t!=="term"?!1:e.endsWith("().")?!0:e.startsWith("rust-analyzer ")&&e.includes("#")?!1:e.startsWith("scip-typescript ")?!/#[A-Za-z0-9_$]+\.$/.test(e):!0}function $f(e){return Fn(e)==="namespace"}var nw=/^rust-analyzer\b.*[\s/]impl#\[[^\]]+\]\[[^\]]+\]/;function m$(e){return nw.test(e)}var rw=new Set(["test","tests","_tests"]);function g$(e){let t=Qe(e);if("kind"in t)return!1;for(let n=0;n<t.descriptors.length-1;n+=1){let r=t.descriptors[n];if(r?.suffix==="namespace"&&r.name&&rw.has(r.name))return!0}return!1}function y$(e,t){let n=Qe(e),r=Qe(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length!==i.length+1)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function h$(e,t){let n=Qe(e),r=Qe(t);if("kind"in n||"kind"in r)return!1;let i=n.descriptors,o=r.descriptors;if(o.length<=i.length)return!1;for(let s=0;s<i.length;s++){let a=i[s],c=o[s];if(a.name!==c.name||a.suffix!==c.suffix)return!1}return!0}function Vo(e){return{forFile(t,n){return Gf(e,t,n)},forFiles(t,n){let r=new Map;for(let i of t)r.set(i,Gf(e,i,n));return r}}}function Gf(e,t,n){let r={file:t},i=n.facts||n.identifiers;if(n.text&&(r.text=F(e,t)),n.lines&&(r.lines=jr(e,t)),n.ast&&(r.ast=M(e,t)),n.imports&&(r.imports=ue(e,t)),n.reexports&&(r.reexports=Ct(e,t)),i){let o=sc(e,t),s=o.facts;n.facts&&(r.facts=s),o.unavailable&&(r.sourceFactsUnavailable=o.unavailable),n.identifiers&&s&&(r.identifiers=s.fileIdentifiers,r.identifierLineMap=s.identifierLineMap)}return r}function Yt(e,t){return e.all(`SELECT gs.id, gs.symbol, der.document_id, der.start_line, der.start_char, der.end_line, der.end_char, d.relative_path, gs.display_name, gs.documentation
|
|
160
|
+
FROM global_symbols gs
|
|
161
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
162
|
+
JOIN documents d ON der.document_id = d.id
|
|
163
|
+
WHERE ${t.where}
|
|
164
|
+
${e.pathExclusionsFor("d")}
|
|
165
|
+
${Hf(t.orderBy)}
|
|
166
|
+
${Wf(t.limit)}`,...t.params??[])}function Tn(e,t){return e.all(`SELECT
|
|
167
|
+
gs.id,
|
|
168
|
+
gs.symbol,
|
|
169
|
+
c.document_id,
|
|
170
|
+
MIN(c.start_line) AS start_line,
|
|
171
|
+
0 AS start_char,
|
|
172
|
+
MAX(c.end_line) AS end_line,
|
|
173
|
+
0 AS end_char,
|
|
174
|
+
d.relative_path,
|
|
175
|
+
gs.display_name,
|
|
176
|
+
gs.documentation
|
|
177
|
+
FROM global_symbols gs
|
|
178
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
179
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
180
|
+
JOIN documents d ON c.document_id = d.id
|
|
181
|
+
WHERE m.role = 1
|
|
182
|
+
AND ${t.where}
|
|
183
|
+
${e.pathExclusionsFor("d")}
|
|
184
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path, gs.display_name, gs.documentation
|
|
185
|
+
${Hf(t.orderBy)}
|
|
186
|
+
${Wf(t.limit)}`,...t.params??[])}function Hf(e){return e?`ORDER BY ${e}`:""}function Wf(e){return typeof e=="number"?`LIMIT ${e}`:""}function Rc(e){return!e||!e.trim()?null:e.replace(/^```\w*\s*/,"").replace(/\s*```$/,"").replace(/^\(method\)\s*/,"").replace(/^\(property\)\s*/,"").replace(/^\(function\)\s*/,"").replace(/^\(class\)\s*/,"").replace(/^\(interface\)\s*/,"").replace(/^\(enum\)\s*/,"").replace(/^\(type alias\)\s*/,"").replace(/^\(const\)\s*/,"").replace(/^\(var\)\s*/,"").trim()||null}function Pc(e){if(!e)return null;let t=Vf(e);if(t)return t.replace(/\n/g," ");let n=e.indexOf("|");if(n===-1)return e.replace(/\n/g," ");let r=e.slice(n+1);return(Vf(r)??r).replace(/\n/g," ")}function Vf(e){return/^```(?:\w+)?\s*\n?([\s\S]*?)\n?```/.exec(e.trimStart())?.[1]?.trim()||null}function iw(e,t={}){if(Se(e.symbol)!==null)return t.includeClassMemberFallbacks===!0;let i=(e.documentation??"").replace(/^```\w*\s*/,"").replace(/\s*```$/,"").trim();return/^(?:var|let|const|function|class|interface|type|enum)\b/.test(i)}function Ft(e,t,n={}){let r=new Map;for(let o of t)e.length>0&&!iw(o,{includeClassMemberFallbacks:n.includeClassMemberFallbacks})||r.set(o.id,o);for(let o of e)r.set(o.id,o);let i=[...r.values()];return n.sort?i.sort((o,s)=>o.start_line-s.start_line||o.end_line-s.end_line||o.symbol.localeCompare(s.symbol)):i}function V$(e){let t=new Map;for(let n of e){if(!n.leaf)continue;let r=t.get(n.leaf)??[];r.push(n),t.set(n.leaf,r)}return t}var ow=C("file-definitions",{clearGroups:["definition-catalog"]}),sw=rt("scoped-matched-definitions",{clearGroups:["definition-catalog"]}),aw=C("file-function-like-definitions",{clearGroups:["definition-catalog"]}),qf=new WeakMap;function B(e,t,n={},r){return Mr(t),n.includeClassMemberFallbacks?wc(e,t,void 0,{includeClassMemberFallbacks:!0},r):ow.get(e,t,()=>{let i=ct(r,"evidence-read",()=>Jf(e,t));if(i)return i;let o=wc(e,t,void 0,n,r);return ct(r,"evidence-write",()=>{let s=ht(e),a=Vo(e).forFile(t,{text:!0}).text;s&&a&&Kf.write(e,t,fe(e,t,a),{projectFingerprint:s,definitions:o.map(c=>({...c}))})}),o})}function cw(e,t){return aw.get(e,t,()=>{let n=Jf(e,t);return n?n.filter(r=>r.isFunctionLike):wc(e,t,r=>r.isFunctionLike)})}var Kf=ce({kind:"file-definitions",invalidation:te("file-definitions"),serialize:lw,deserialize:uw});function Jf(e,t){let n=ht(e);if(!n)return null;let r=Vo(e).forFile(t,{text:!0}).text;if(!r)return null;let i=Kf.read(e,t,fe(e,t,r));return i?dw(i,n,t):null}function lw(e){return JSON.stringify(e)}function uw(e){try{let t=JSON.parse(e);return!qt(t)||typeof t.projectFingerprint!="string"||!Array.isArray(t.definitions)?null:{projectFingerprint:t.projectFingerprint,definitions:t.definitions}}catch{return null}}function dw(e,t,n){if(e.projectFingerprint!==t)return null;let r=[];for(let i of e.definitions){let o=pw(i,n);if(!o)return null;r.push(o)}return r}function pw(e,t){return!qt(e)||typeof e.symbolId!="number"||typeof e.symbol!="string"||typeof e.documentId!="number"||typeof e.startLine!="number"||typeof e.startChar!="number"&&e.startChar!==void 0||typeof e.endLine!="number"||typeof e.endChar!="number"&&e.endChar!==void 0||e.relativePath!==t||typeof e.leaf!="string"||typeof e.parentTypeName!="string"&&e.parentTypeName!==null||typeof e.isFunctionLike!="boolean"||typeof e.isTypeLike!="boolean"||typeof e.kind!="number"&&e.kind!==null||typeof e.documentation!="string"&&e.documentation!==null||typeof e.enclosingSymbol!="string"&&e.enclosingSymbol!==null?null:{symbolId:e.symbolId,symbol:e.symbol,documentId:e.documentId,startLine:e.startLine,startChar:e.startChar,endLine:e.endLine,endChar:e.endChar,relativePath:e.relativePath,leaf:e.leaf,parentTypeName:e.parentTypeName,isFunctionLike:e.isFunctionLike,isTypeLike:e.isTypeLike,kind:e.kind,documentation:e.documentation,enclosingSymbol:e.enclosingSymbol}}function wc(e,t,n,r={},i){let o=ct(i,"primary-rows",()=>fw(e,t)),s=ct(i,"fallback-rows",()=>mw(e,t)),a=ct(i,"merge-rows",()=>Ft(o,s,{sort:!0,includeClassMemberFallbacks:r.includeClassMemberFallbacks}).map(Cc));return n&&(a=a.filter(n)),ct(i,"range-correction",()=>Fc(e,t,a,i,r.rangeCorrectionEvidence))}function ct(e,t,n){return e?e(t,n):n()}function fw(e,t){return e.all(`SELECT
|
|
187
|
+
gs.id,
|
|
188
|
+
gs.symbol,
|
|
189
|
+
der.document_id,
|
|
190
|
+
der.start_line,
|
|
191
|
+
der.start_char,
|
|
192
|
+
der.end_line,
|
|
193
|
+
der.end_char,
|
|
194
|
+
d.relative_path,
|
|
195
|
+
gs.display_name,
|
|
196
|
+
gs.kind,
|
|
197
|
+
gs.documentation,
|
|
198
|
+
gs.enclosing_symbol
|
|
199
|
+
FROM global_symbols gs
|
|
200
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
201
|
+
JOIN documents d ON der.document_id = d.id
|
|
202
|
+
WHERE d.relative_path = ?
|
|
203
|
+
${e.symbolNoiseFor("gs")}
|
|
204
|
+
ORDER BY der.start_line, der.end_line`,t)}function mw(e,t){return e.all(`SELECT
|
|
205
|
+
gs.id,
|
|
206
|
+
gs.symbol,
|
|
207
|
+
c.document_id,
|
|
208
|
+
MIN(c.start_line) AS start_line,
|
|
209
|
+
0 AS start_char,
|
|
210
|
+
MAX(c.end_line) AS end_line,
|
|
211
|
+
0 AS end_char,
|
|
212
|
+
d.relative_path,
|
|
213
|
+
gs.display_name,
|
|
214
|
+
gs.kind,
|
|
215
|
+
gs.documentation,
|
|
216
|
+
gs.enclosing_symbol
|
|
217
|
+
FROM global_symbols gs
|
|
218
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
219
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
220
|
+
JOIN documents d ON c.document_id = d.id
|
|
221
|
+
WHERE d.relative_path = ?
|
|
222
|
+
AND m.role = 1
|
|
223
|
+
${e.symbolNoiseFor("gs")}
|
|
224
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
225
|
+
ORDER BY start_line, end_line`,t)}function Cc(e){return{symbolId:e.id,symbol:e.symbol,documentId:e.document_id,startLine:e.start_line,startChar:e.start_char??0,endLine:e.end_line,endChar:e.end_char??0,relativePath:e.relative_path,leaf:be(e.symbol),parentTypeName:Se(e.symbol),isFunctionLike:lr(e.symbol),isTypeLike:Fn(e.symbol)==="type",kind:e.kind??null,documentation:e.documentation??null,enclosingSymbol:e.enclosing_symbol??null}}function H$(e,t={}){return gw(e,t.scope)}function gw(e,t){return Re(e,{scope:t,includeIgnored:!1}).flatMap(n=>B(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function W$(e,t){return Re(e,{scope:t,includeIgnored:!1}).flatMap(n=>cw(e,n)).filter(n=>!e.isIgnored(n.relativePath))}function q$(e,t){let n=sw.get(e,()=>new WeakMap),r=n.get(t.symbolMatches);r||(r=new Map,n.set(t.symbolMatches,r));let i=JSON.stringify({scope:t.scope??null,sqlPrefilter:t.sqlPrefilter??null}),o=r.get(i);if(o)return[...o];let s=Uf(yw(e,t.scope,t.sqlPrefilter)),a=Uf(hw(e,t.scope,t.sqlPrefilter)),c=new Set([...s.keys(),...a.keys()]),l=[];for(let u of[...c].sort()){if(e.isIgnored(u))continue;let d=Ft(s.get(u)??[],a.get(u)??[],{sort:!0}).filter(p=>t.symbolMatches(p.symbol));d.length!==0&&l.push(...Fc(e,u,d.map(Cc)))}return r.set(i,l),[...l]}function yw(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Xf("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
|
|
226
|
+
gs.id,
|
|
227
|
+
gs.symbol,
|
|
228
|
+
der.document_id,
|
|
229
|
+
der.start_line,
|
|
230
|
+
der.start_char,
|
|
231
|
+
der.end_line,
|
|
232
|
+
der.end_char,
|
|
233
|
+
d.relative_path,
|
|
234
|
+
gs.display_name,
|
|
235
|
+
gs.kind,
|
|
236
|
+
gs.documentation,
|
|
237
|
+
gs.enclosing_symbol
|
|
238
|
+
FROM global_symbols gs
|
|
239
|
+
JOIN defn_enclosing_ranges der ON gs.id = der.symbol_id
|
|
240
|
+
JOIN documents d ON der.document_id = d.id
|
|
241
|
+
WHERE 1 = 1
|
|
242
|
+
${e.pathExclusionsFor("d")}
|
|
243
|
+
${r}
|
|
244
|
+
${i}
|
|
245
|
+
${e.symbolNoiseFor("gs")}
|
|
246
|
+
ORDER BY d.relative_path, der.start_line, der.end_line`,...o)}function hw(e,t,n){let r=t?"AND d.relative_path LIKE ?":"",i=n?`AND ${Xf("gs",n)}`:"",o=t?[`%${t}%`]:[];return e.all(`SELECT
|
|
247
|
+
gs.id,
|
|
248
|
+
gs.symbol,
|
|
249
|
+
c.document_id,
|
|
250
|
+
MIN(c.start_line) AS start_line,
|
|
251
|
+
0 AS start_char,
|
|
252
|
+
MAX(c.end_line) AS end_line,
|
|
253
|
+
0 AS end_char,
|
|
254
|
+
d.relative_path,
|
|
255
|
+
gs.display_name,
|
|
256
|
+
gs.kind,
|
|
257
|
+
gs.documentation,
|
|
258
|
+
gs.enclosing_symbol
|
|
259
|
+
FROM global_symbols gs
|
|
260
|
+
JOIN mentions m ON m.symbol_id = gs.id
|
|
261
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
262
|
+
JOIN documents d ON c.document_id = d.id
|
|
263
|
+
WHERE m.role = 1
|
|
264
|
+
AND NOT EXISTS (
|
|
265
|
+
SELECT 1
|
|
266
|
+
FROM defn_enclosing_ranges existing_der
|
|
267
|
+
WHERE existing_der.symbol_id = gs.id
|
|
268
|
+
)
|
|
269
|
+
${e.pathExclusionsFor("d")}
|
|
270
|
+
${r}
|
|
271
|
+
${i}
|
|
272
|
+
${e.symbolNoiseFor("gs")}
|
|
273
|
+
GROUP BY gs.id, gs.symbol, c.document_id, d.relative_path
|
|
274
|
+
ORDER BY d.relative_path, start_line, end_line`,...o)}function Sw(e){return`(${e}.symbol LIKE '%().' OR ${e}.symbol LIKE '%()')`}function Xf(e,t){return t==="callable"?Sw(e):bw(e)}function bw(e){return`(${e}.symbol LIKE '%.' OR ${e}.symbol LIKE '%()')`}function Uf(e){let t=new Map;for(let n of e){let r=t.get(n.relative_path);r?r.push(n):t.set(n.relative_path,[n])}return t}function U$(e,t,n={}){if(t.length===0)return[];let r=t.flatMap(i=>B(e,i)).filter(i=>!e.isIgnored(i.relativePath));return n.onlyDocumented&&(r=r.filter(i=>i.documentation!==null&&i.documentation!=="")),n.sort&&(r=r.sort((i,o)=>i.relativePath.localeCompare(o.relativePath)||i.startLine-o.startLine||i.endLine-o.endLine)),r.map(i=>({startLine:i.startLine,endLine:i.endLine,symbol:i.symbol,shortName:Xt(i.symbol),signature:Rc(Pc(i.documentation)),relativePath:i.relativePath,enclosingSymbol:i.enclosingSymbol}))}function xw(e){let t=new Map,n=e.map((r,i)=>({definition:r,index:i,span:r.endLine-r.startLine})).sort((r,i)=>r.span-i.span||r.index-i.index);for(let{definition:r}of n)for(let i=r.startLine;i<=r.endLine;i+=1)t.has(i)||t.set(i,r);return t}function ur(e,t){let n=qf.get(e);return n||(n=xw(e),qf.set(e,n)),n.get(t)??null}function Ho(e,t){let n=B(e,t.relative_path).find(r=>r.symbolId===t.id)??(Se(t.symbol)===null||!lr(t.symbol)?void 0:Fc(e,t.relative_path,[Cc(t)])[0]);return n?{symbolId:n.symbolId,symbol:n.symbol,documentId:n.documentId,startLine:n.startLine,startChar:n.startChar,endLine:n.endLine,endChar:n.endChar,relativePath:n.relativePath}:{symbolId:t.id,symbol:t.symbol,documentId:t.document_id,startLine:t.start_line,startChar:t.start_char??0,endLine:t.end_line,endChar:t.end_char??0,relativePath:t.relative_path}}function Fc(e,t,n,r,i){let o=ct(r,"range-correction.source-text",()=>i?i.source:Vo(e).forFile(t,{text:!0}).text),s=ct(r,"range-correction.callable-sites",()=>i?i.callables:Kr(e,t));return s?ct(r,"range-correction.ast-correction",()=>ww(n,s,o)):o?ct(r,"range-correction.regex-fallback",()=>vw(n,o)):n}function vw(e,t){let n=t.split(/\r?\n/),r=Iw(e,n),i=Ew(e,r),o=Rw(i,n);return Pw(e,o)}function Iw(e,t){let n=e.some(i=>Wo(i.symbol))?Lw(t):null,r=new Map;for(let i of e)r.set(i.symbolId,kw(t,n,i));return r}function Ew(e,t){return e.filter(n=>Wo(n.symbol)).map(n=>({definition:n,startLine:t.get(n.symbolId)??n.startLine})).sort((n,r)=>n.startLine-r.startLine||n.definition.startLine-r.definition.startLine||n.definition.symbol.localeCompare(r.definition.symbol))}function Rw(e,t){let n=new Map;for(let r=0;r<e.length;r+=1){let i=e[r],o=e[r+1],s=o?Math.max(i.startLine,o.startLine-1):t.length-1;n.set(i.definition.symbolId,{startLine:i.startLine,endLine:Dw(t,i.definition,i.startLine,s)})}return n}function Pw(e,t){return e.map(n=>{let r=t.get(n.symbolId);return r?{...n,startLine:r.startLine,endLine:r.endLine}:n})}function ww(e,t,n=null){let r=new Map;for(let i of t){let o=r.get(i.name);o?o.push(i):r.set(i.name,[i])}return e.map(i=>{if(!_w(i)||!i.leaf)return zf(i,n);let o=r.get(i.leaf);if(!o||o.length===0)return zf(i,n);let s=n?Cw(i,o,n):null;if(s)return{...i,startLine:s.startLine,endLine:s.endLine};let a=o[0],c=Math.abs(a.startLine-i.startLine);for(let l=1;l<o.length;l+=1){let u=o[l],d=Math.abs(u.startLine-i.startLine);d<c&&(a=u,c=d)}return{...i,startLine:a.startLine,endLine:a.endLine}})}function Cw(e,t,n){let r=Fw(e.symbol);if(!r)return null;let i=n.split(/\r?\n/),o=new RegExp(`\\b${le(r)}\\b`);for(let s of t){let a=Tw(i,s.startLine);if(a&&o.test(a))return s}return null}function Fw(e){return e.match(/\/impl#\[([^\]]+)\]/)?.[1]??null}function Tw(e,t){for(let n=t;n>=0;n-=1){let r=e[n]?.trim()??"";if(r){if(/^impl\b/.test(r))return Nw(e,n,t);if(/^(?:struct|enum|trait|mod)\b/.test(r))return null}}return null}function Nw(e,t,n){let r=[];for(let i=t;i<=n;i+=1){let o=e[i]??"";if(r.push(o),o.includes("{"))break}return r.join(" ")}function _w(e){return Wo(e.symbol)?!0:Fn(e.symbol)==="term"&&Se(e.symbol)===null}function zf(e,t){if(!t||!e.leaf||Fn(e.symbol)!=="term"||Se(e.symbol)!==null)return e;let n=le(e.leaf),r=new RegExp(`\\b(?:export\\s+)?(?:const|let|var)\\s+${n}\\b`),o=t.split(/\r?\n/).findIndex(s=>r.test(s));return o>=0?{...e,startLine:o,endLine:o}:e}function kw(e,t,n){if(!Wo(n.symbol))return n.startLine;let r=Math.max(0,Math.min(n.startLine,e.length-1));if(!t)return r;let i=t.get(n.leaf);if(!i||i.length===0)return r;let o=null;for(let s of i){let a=Math.abs(s-n.startLine);(!o||a<o.distance)&&(o={line:s,distance:a})}return o?.line??r}function Lw(e){let t=/\b(?:function|def|fn)\s+([A-Za-z_$][\w$]*)/g,n=/\b([A-Za-z_$][\w$]*)\s*[:=]\s*(?:async\s*)?(?:function\b|\()/g,r=/^\s*(?:(?:export|public|private|protected|static|readonly|async|abstract|get|set)\s+)*([A-Za-z_$][\w$]*)\s*(?:<[^(]*>)?\s*\(/,i=/\b([A-Za-z_$][\w$]*)\s*\(/g,o=new Map,s=(a,c)=>{let l=o.get(a);if(!l){o.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)};for(let a=0;a<e.length;a+=1){let c=e[a]??"";for(let u of c.matchAll(t))u[1]&&s(u[1],a);for(let u of c.matchAll(n))u[1]&&s(u[1],a);let l=c.match(r);l?.[1]&&s(l[1],a);for(let u of c.matchAll(i))u[1]&&s(u[1],a)}return o}function Dw(e,t,n,r){let i=Math.max(n,Math.min(e.length-1,r)),o=Math.max(n,Math.min(i,t.endLine)),s=0,a=0,c=!1;for(let l=n;l<=i;l+=1){let u=Aw(e[l]??"");for(let d of u)d==="{"?(s+=1,c=!0):d==="}"?s=Math.max(0,s-1):d==="("?a+=1:d===")"&&(a=Math.max(0,a-1));if(c&&s===0||!c&&a===0&&l>=o)return l}return o}function Aw(e){let t="",n=null,r=!1;for(let i=0;i<e.length;i+=1){let o=e[i],s=e[i+1];if(!n&&o==="/"&&s==="/"){t+=" ".repeat(e.length-i);break}if(n){if(r){r=!1,t+=" ";continue}if(o==="\\"){r=!0,t+=" ";continue}o===n&&(n=null),t+=" ";continue}if(o==='"'||o==="'"||o==="`"){n=o,t+=" ";continue}t+=o}return t}function Wo(e){return e.includes("().")}function z$(e){let t=Qe(e);if("kind"in t)return[];let n=[];for(let r=t.descriptors.length-2;r>=0;r-=1){let i=t.descriptors[r];i?.suffix==="type"&&i.name&&n.push(i.name)}return n}var Ow=C("symbol-resolution",{clearGroups:[]});function nG(e,t){return Mw(e,t).match}function Mw(e,t){return Ow.get(e,t,()=>{let n=Zf(e,t.trim()).filter(s=>!e.isIgnored(s.relative_path));if(n.length>0)return dr(e,n);let r=qw(e,t);if(r&&!e.isIgnored(r.relative_path))return dr(e,[r]);let i=jw(e,t);if(i.length>0)return dr(e,i);let o=Bw(e,t);return o.length>0?dr(e,o):Hw(e,t)})}function jw(e,t){let n=t.trim().replace(/\(\)$/u,""),r=n.lastIndexOf(":");if(r<=0||r===n.length-1||n.startsWith("local:"))return[];let i=n.slice(r+1);if(!/^[\p{L}_$][\p{L}\p{N}_$]*$/u.test(i))return[];let o=[`/${i}().`,`/${i}.`,`/${i}#`,`#${i}().`,`#${i}.`,`/${i}/`],s=`gs.display_name = ? OR ${o.map(()=>"instr(gs.symbol, ?) > 0").join(" OR ")}`,a=[i,...o],c=Yt(e,{where:s,params:a,orderBy:"d.relative_path, der.start_line",limit:200}),l=c.length>0?[]:Tn(e,{where:s,params:a,orderBy:"d.relative_path, start_line",limit:200}),u=Ft(c,l).filter(d=>!e.isIgnored(d.relative_path)).filter(d=>Xt(d.symbol).replace(/\(\)$/u,"")===n);return[...new Map(u.map(d=>[`${d.symbol}\0${d.relative_path}`,d])).values()]}function Bw(e,t){let n=qo(t),r=Tc(n);if(!r)return[];let i=`%${r.path}%`,o=r.leaf;return $w(e,i,o,n)}function $w(e,t,n,r){let i=Ft([],[...Gw(e,t,n),...Vw(e,t,n)]).filter(o=>!e.isIgnored(o.relative_path)).filter(o=>pr(o,r)>1);return i.sort((o,s)=>pr(s,r)-pr(o,r)||o.end_line-o.start_line-(s.end_line-s.start_line)||o.start_line-s.start_line||o.symbol.localeCompare(s.symbol)),i}function Gw(e,t,n){return Yt(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function Vw(e,t,n){return Tn(e,{where:"d.relative_path LIKE ? AND (gs.display_name = ? OR gs.symbol LIKE ?)",params:[t,n,`%/${n}.%`]})}function Hw(e,t){let n=qo(t),r=Yw(t),i=Jw(e,r),o=Qw(i,t,n).filter(a=>!e.isIgnored(a.relative_path));if(o.length>0)return dr(e,o);let s=[];for(let a of i){if(e.isIgnored(a.relative_path))continue;let c=Xw(a,t,n,r);c<=0||s.push({row:a,score:c})}return s.sort((a,c)=>c.score-a.score||a.row.end_line-a.row.start_line-(c.row.end_line-c.row.start_line)||a.row.relative_path.localeCompare(c.row.relative_path)||a.row.symbol.localeCompare(c.row.symbol)),dr(e,s.map(a=>a.row))}function dr(e,t){let n=t.map(i=>Ho(e,i)),r=n[0]??null;return{match:r,candidates:r?Ww(n,r):[],total:n.length}}function Ww(e,t){let n=new Set([`${t.symbolId}:${t.relativePath}:${t.startLine}`]),r=[];for(let i of e){let o=`${i.symbolId}:${i.relativePath}:${i.startLine}`;if(!n.has(o)&&(n.add(o),r.push({symbol:i.symbol,shortName:Xt(i.symbol),relativePath:i.relativePath,startLine:i.startLine}),r.length>=5))break}return r}function qw(e,t){let n=t.match(/^(.+):(\d+)(?:-(\d+))?$/);if(!n)return;let[,r,i,o]=n,s=Zd(e,r,{allowMultiple:!1,requirePathMatch:!0})[0]?.relativePath;if(!s)return;let a=Math.max(0,parseInt(i,10)-1),c=o?Math.max(a,parseInt(o,10)-1):a;return Uw(e,s,a,c)??zw(e,s,a,c)}function Uw(e,t,n,r){return Yt(e,{where:"d.relative_path = ? AND der.start_line <= ? AND der.end_line >= ?",params:[t,n,r],orderBy:"(der.end_line - der.start_line) ASC",limit:1})[0]}function zw(e,t,n,r){return Tn(e,{where:"d.relative_path = ? AND c.start_line <= ? AND c.end_line >= ?",params:[t,n,r],orderBy:"(MAX(c.end_line) - MIN(c.start_line)) ASC",limit:1})[0]}function rG(e,t){let n=Zf(e,t).find(r=>!e.isIgnored(r.relative_path));return n?Ho(e,n):null}function Zf(e,t){let n=Yt(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, der.start_line"}),r=n.length>0?[]:Tn(e,{where:"gs.symbol = ?",params:[t],orderBy:"d.relative_path, start_line"});return Ft(n,r)}function ti(e,t){if("symbol"in t&&"relativePath"in t)return t;let n=Kw(e,t.symbolId)[0];return n?Ho(e,n):null}function Kw(e,t){let n=Yt(e,{where:"gs.id = ?",params:[t],orderBy:"der.start_line, der.end_line"}),r=Tn(e,{where:"gs.id = ?",params:[t],orderBy:"start_line, end_line"});return Ft(n,r)}function Jw(e,t){let n=t.map(()=>"(gs.symbol LIKE ? OR d.relative_path LIKE ? OR COALESCE(gs.display_name, '') LIKE ?)"),r=t.flatMap(a=>{let c=`%${a}%`;return[c,c,c]}),i=n.join(`
|
|
275
|
+
AND `),o=Yt(e,{where:i,params:r,limit:200}),s=Tn(e,{where:i,params:r,limit:200});return Ft(o,s)}function Xw(e,t,n,r){let i=t.trim(),o=n,s=o.replace(/\(\)$/,""),a=t.toLowerCase(),c=n.toLowerCase(),l=c.replace(/\(\)$/,""),u=e.symbol,d=Xt(e.symbol),p=be(e.symbol),f=e.display_name??"",g=e.symbol.toLowerCase(),y=d.toLowerCase(),m=p.toLowerCase(),S=f.toLowerCase(),h=e.relative_path.toLowerCase(),v=/[/:.]/.test(n),E=Tc(n),x=E?.leaf.toLowerCase(),b=0;return(u===i||u===o)&&(b+=1150),(d===i||d===o)&&(b+=1100),f===s&&(b+=1180),p===s&&(b+=1160),(`${p}()`===i||`${p}()`===o)&&(b+=955),(g===a||g===c)&&(b+=1e3),(y===a||y===c)&&(b+=950),(h===a||h===c)&&(b+=925),(h.endsWith(`/${c}`)||h.endsWith(`/${a}`))&&(b+=875),S===l&&(b+=850),m===l&&(b+=825),(`${m}()`===a||`${m}()`===c)&&(b+=820),(y.endsWith(`:${c}`)||y.endsWith(`:${l}`)||y.endsWith(`:${l}()`))&&(b+=800),g.includes(c)&&(b+=120),y.includes(c)&&(b+=140),h.includes(c)&&(b+=140),S.includes(c)&&(b+=110),r.every(I=>{let P=I.toLowerCase();return g.includes(P)||y.includes(P)||h.includes(P)||S.includes(P)})&&(b+=100+r.length*15),E&&h.includes(E.path.toLowerCase())&&(b+=360,x&&(m===x||`${m}()`===x||`${m}()`==`${x}()`)&&(b+=700),Ec(e.symbol)&&(b+=180)),lr(e.symbol)&&m===l&&(b+=60),!v&&$f(e.symbol)&&(b-=160),b-=Math.min(50,Math.max(0,e.end_line-e.start_line)),b}function Tc(e){let t=e.trim().replace(/\\/g,"/"),n=t.lastIndexOf("/");if(n<=0||n===t.length-1)return null;let r=t.slice(n+1).replace(/\(\)$/,"");return!r||r.includes(".")?null:{path:t.slice(0,n),leaf:r}}function qo(e){return e.trim().replace(/\(\)$/,"").replace(/\(.*$/,"")}function Yw(e){let t=qo(e),n=t.split(/[^A-Za-z0-9_]+/).map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?[...new Set(n)]:[t]}function Qw(e,t,n){let r=t.trim(),i=e.filter(a=>{let c=Xt(a.symbol),l=be(a.symbol),u=(a.display_name??"").trim();return a.symbol===r||c===r||c===n||l===r||l===n||`${l}()`===r||u===r||u===n||`${u}()`===r||pr(a,n)>1||a.relative_path===r});if(i.length===0)return[];let o=n.replace(/\(\)$/u,""),s=i.filter(a=>be(a.symbol)===o);if(s.length>0){s.sort((c,l)=>Yf(c,l,n));let a=s.filter(c=>lr(c.symbol));return a.length>0?a:s}return i.sort((a,c)=>Yf(a,c,n)),i}function Yf(e,t,n){return pr(t,n)-pr(e,n)||e.end_line-e.start_line-(t.end_line-t.start_line)||e.relative_path.localeCompare(t.relative_path)||e.symbol.localeCompare(t.symbol)}function pr(e,t){let n=Tc(t);if(!n)return 0;let r=e.relative_path.toLowerCase(),i=be(e.symbol).toLowerCase(),o=n.path.toLowerCase(),s=n.leaf.toLowerCase();return r.includes(o)?i!==s?1:Ec(e.symbol)?Se(e.symbol)===null?5:4:Se(e.symbol)===null?3:2:0}function iG(e,t,n=5){let r=Qf(t);if(!r)return[];let i=Yt(e,{where:"1 = 1",orderBy:"d.relative_path, der.start_line",limit:5e3}),o=new Map;for(let s of i){if(e.isIgnored(s.relative_path))continue;let a=Xt(s.symbol),c=be(s.symbol),l=s.display_name??c,u=[a,c,l].filter(f=>f.trim().length>0),d=Math.min(...u.map(f=>Zw(Qf(f),r))),p=o.get(a);(!p||d<p.distance)&&o.set(a,{shortName:a,distance:d})}return[...o.values()].sort((s,a)=>s.distance-a.distance||s.shortName.localeCompare(a.shortName)).slice(0,n).map(s=>s.shortName)}function Qf(e){return qo(e).toLowerCase().replace(/[^a-z0-9_]+/g,"")}function Zw(e,t){if(e===t)return 0;if(e.length===0)return t.length;if(t.length===0)return e.length;let n=Array.from({length:t.length+1},(r,i)=>i);for(let r=0;r<e.length;r++){let i=[r+1];for(let o=0;o<t.length;o++){let s=e[r]===t[o]?0:1;i[o+1]=Math.min(i[o]+1,n[o+1]+1,n[o]+s)}n=i}return n[t.length]}function fG(e,t){let n=em(e);return n?t.filter(r=>em(r.file)===n):t}function mG(e,t,n,r,i){let o=ue(e,t);if(r){let u=i?.match(/^[A-Za-z_$][\w$]*/u)?.[0];if(!u)return null;let d=new Set(o.filter(y=>y.localName===u||y.importedName===u).map(y=>y.sourcePath).filter(y=>!!y));for(let y of n)for(let m of d)if(ln(m,y.file))return y;if(u==="this"||u==="self"||u==="cls"){let y=n.filter(m=>m.file===t&&Se(m.symbol)!==null);if(y.length===1)return y[0]}let p=eC(F(e,t)??"",u);if(p.size===0)return null;let f=new Set(o.filter(y=>p.has(y.localName??y.importedName)).map(y=>y.sourcePath).filter(y=>!!y)),g=n.filter(y=>p.has(Se(y.symbol)??"")&&(y.file===t||[...f].some(m=>ln(m,y.file))));return g.length===1?g[0]:null}let s=n.filter(u=>Se(u.symbol)===null),a=s.find(u=>u.file===t);if(a)return a;let c=be(n[0].symbol),l=o.filter(u=>u.kind!=="namespace"&&u.kind!=="side-effect"&&(u.localName===c||u.localName===null&&u.importedName===c));if(l.length>0){let u=s.filter(d=>l.some(p=>p.sourcePath!==null&&ln(p.sourcePath,d.file)));return u.length===1?u[0]:null}return s.length===1?s[0]:null}function eC(e,t){let n=t.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),r=new Set,i=[new RegExp(`\\b${n}\\s*:\\s*([A-Za-z_$][\\w$]*)`,"gu"),new RegExp(`\\b${n}\\s*=\\s*(?:new\\s+)?([A-Za-z_$][\\w$]*)\\s*\\(`,"gu")];for(let o of i)for(let s of e.matchAll(o))r.add(s[1]);return r.size===1?r:new Set}function em(e){let t=oe(e);return t?t==="typescript"||t==="tsx"||t==="javascript"?"javascript-family":t:null}var tC=rt("global-leaf-index",{clearGroups:["whole-project"]});function Nc(e){return tC.get(e,()=>{let t=e.all(`SELECT gs.id, gs.symbol,
|
|
276
|
+
COALESCE(der_doc.relative_path, mention_doc.relative_path) AS relative_path
|
|
277
|
+
FROM global_symbols gs
|
|
278
|
+
LEFT JOIN defn_enclosing_ranges der ON der.symbol_id = gs.id
|
|
279
|
+
LEFT JOIN documents der_doc ON der_doc.id = der.document_id
|
|
280
|
+
LEFT JOIN (
|
|
281
|
+
SELECT m.symbol_id, MIN(d.relative_path) AS relative_path
|
|
282
|
+
FROM mentions m
|
|
283
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
284
|
+
JOIN documents d ON c.document_id = d.id
|
|
285
|
+
WHERE m.role = 1
|
|
286
|
+
GROUP BY m.symbol_id
|
|
287
|
+
) mention_doc ON mention_doc.symbol_id = gs.id
|
|
288
|
+
WHERE 1 = 1
|
|
289
|
+
${e.symbolNoiseFor("gs")}`),n=new Map;for(let r of t){if(!r.relative_path||e.isIgnored(r.relative_path))continue;let i=be(r.symbol);if(!i)continue;let o=n.get(i);o||(o=[],n.set(i,o)),o.some(s=>s.symbolId===r.id)||o.push({symbol:r.symbol,symbolId:r.id,file:r.relative_path})}return n})}function Uo(e,t,n,r={}){if(!n)return[];let i=F(e,t);return i?i.indexOf(n)===-1?[]:(_c(e,t).get(n)??[]).filter(s=>!nC(s,r)):[]}function nC(e,t){return typeof t.excludeStartLine=="number"&&typeof t.excludeEndLine=="number"&&e>=t.excludeStartLine&&e<=t.excludeEndLine}var rC=C("file-identifiers",{clearGroups:["whole-project","source-file"]});function tm(e,t){let n=he(e,t);return n?n.fileIdentifiers:rC.get(e,t,()=>new Set(_c(e,t).keys()))}var iC=C("file-ident-lines",{clearGroups:["whole-project","source-file"]});function _c(e,t){let n=he(e,t);return n?n.identifierLineMap:iC.get(e,t,()=>sC(e,t))}var oC=C("file-idents-by-line",{clearGroups:["whole-project","source-file"]});function xG(e,t){let n=he(e,t);return n?n.identifiersByLine:oC.get(e,t,()=>{let r=_c(e,t),i=0;for(let s of r.values()){let a=s[s.length-1];a!==void 0&&a>i&&(i=a)}let o=new Array(i+1);for(let s=0;s<=i;s+=1)o[s]=new Set;for(let[s,a]of r)for(let c of a)o[c].add(s);return o})}function sC(e,t){let n=new Map,r=(a,c)=>{let l=n.get(a);if(!l){n.set(a,[c]);return}l[l.length-1]!==c&&l.push(c)},i=F(e,t);if(!i)return n;let o=Ua(i).split(/\r?\n/),s=/\b([A-Za-z_$][\w$]*)\b/g;for(let a=0;a<o.length;a+=1){let c=o[a]??"";for(let l of c.matchAll(s))l[1]&&r(l[1],a)}return n}var nm=/[A-Za-z_$][A-Za-z0-9_$]*/g,rm=/^[A-Za-z_$][A-Za-z0-9_$]*$/,aC=512;function kc(e){let t=[],n=!1;for(let r of e)r&&(n=!0,rm.test(r)||t.push(r));return{candidateNames:e,hasUsableCandidate:n,nonIdentifierNames:t}}function im(e,t){let n=cC(t)?t:kc(t);if(n.candidateNames.size===0||!n.hasUsableCandidate)return!0;if(n.candidateNames.size<=aC){for(let i of n.candidateNames)if(i){if(rm.test(i)){if(lC(i).test(e))return!0;continue}if(e.includes(i))return!0}return!1}nm.lastIndex=0;let r;for(;(r=nm.exec(e))!==null;)if(n.candidateNames.has(r[0]))return!0;for(let i of n.nonIdentifierNames)if(e.includes(i))return!0;return!1}function cC(e){return"candidateNames"in e}function lC(e){return new RegExp(`(?<![A-Za-z_$0-9])${le(e)}(?![A-Za-z_$0-9])`)}var uC=C("source-import-paths-by-local-name",{clearGroups:["whole-project","source-file"]});function sm(e,t){let n=Vt(t);return uC.get(e,n,()=>dC(e,n))}function dC(e,t){let n=new Map;for(let r of ue(e,t)){if(!r.sourcePath)continue;let i=r.localName??r.importedName;if(i&&om(n,i,r.sourcePath),r.kind==="namespace")for(let o of r.usedMembers)om(n,o,r.sourcePath)}return n}function om(e,t,n){let r=e.get(t);r||(r=new Set,e.set(t,r)),r.add(n)}function Lc(e,t,n){let r=Nc(e).get(n);if(!r||r.length===0)return[];if(r.length===1)return[ni(r[0])];let i=r.filter(c=>c.file===t);if(i.length>0)return i.map(ni);let o=sm(e,t),s=o.get(n);if(s)for(let c of s){let l=r.filter(u=>ln(c,u.file));if(l.length>0)return l.map(ni)}let a=new Set;for(let c of o.values())for(let l of c)a.add(l);for(let c of a){let l=r.filter(u=>ln(c,u.file));if(l.length>0&&l.length===r.length)return l.map(ni)}return[]}function jG(e,t,n){let r=Lc(e,t,n);if(r.length>0)return r;let i=Nc(e).get(n);return!i||i.length===0?[]:i.map(ni)}function am(e,t,n={}){let r=pC(e,t);if(!r)return[];let i=ti(e,t);if(n.semantic!==!1&&n.semanticEvidence){let s=n.semanticEvidence.references(e,{...i,leaf:r.identifier,parentTypeName:null,isFunctionLike:!1,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null});if(s.length>0){let a=new Map;for(let c of s){let l=a.get(c.file)??[];l.push(c.line),a.set(c.file,l)}return zo(e,a)}}let o=new Map;for(let s of Me(e)){let a=fC(e,r,s);a.length>0&&o.set(s,a)}return zo(e,o)}function pC(e,t){let n=ti(e,t);if(!n)return null;let r=be(n.symbol);return r?{symbolId:n.symbolId,relativePath:n.relativePath,startLine:n.startLine,endLine:n.endLine,identifier:r}:null}function fC(e,t,n){let r=F(e,n);return!r||r.indexOf(t.identifier)===-1?[]:n!==t.relativePath&&!Lc(e,n,t.identifier).some(o=>o.symbolId===t.symbolId)?[]:Uo(e,n,t.identifier,n===t.relativePath?{excludeStartLine:t.startLine,excludeEndLine:t.endLine}:{})}function BG(e,t,n={}){let r=new Map;for(let c of t){if(!c.leaf)continue;let l=r.get(c.leaf)??[];l.push(c),r.set(c.leaf,l)}if(r.size===0)return new Map;let i=new Set(t.map(c=>c.symbolId)),o=new Set(r.keys()),s=kc(o),a=new Map;for(let c of Me(e)){if(n.skipPath?.(c)||!im(F(e,c),s))continue;let l=tm(e,c);if(l.size!==0){for(let u of l)if(r.has(u))for(let d of Lc(e,c,u)){if(!i.has(d.symbolId)||c===d.relativePath)continue;let p=a.get(d.symbolId);p||(p=new Set,a.set(d.symbolId,p)),p.add(c)}}}return a}function ni(e){return{symbolId:e.symbolId,symbol:e.symbol,relativePath:e.file}}function zo(e,t){let n=[],r=new Set;for(let[i,o]of t){let s=B(e,i);for(let a of o){let c=ur(s,a),l=`${i}|${a}|${c?.symbol??""}`;r.has(l)||(r.add(l),n.push({file:i,line:a,enclosingSymbol:c?.symbol??null}))}}return n}function GG(e,t){return Jo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT
|
|
290
|
+
m.symbol_id,
|
|
291
|
+
d.relative_path,
|
|
292
|
+
COUNT(*) AS ref_count
|
|
293
|
+
FROM mentions m
|
|
294
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
295
|
+
JOIN documents d ON c.document_id = d.id
|
|
296
|
+
WHERE m.role != 1
|
|
297
|
+
${r}
|
|
298
|
+
${e.pathExclusionsFor("d")}
|
|
299
|
+
GROUP BY m.symbol_id, d.relative_path`,...n??[])})}function VG(e,t){return Jo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id, d.relative_path
|
|
300
|
+
FROM mentions m
|
|
301
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
302
|
+
JOIN documents d ON c.document_id = d.id
|
|
303
|
+
WHERE m.role != 1
|
|
304
|
+
${r}
|
|
305
|
+
${e.pathExclusionsFor("d")}`,...n??[])}).filter(n=>n.symbol_id!==null)}function HG(e,t){return Jo(e,t,n=>{let r=n?`AND m.symbol_id IN (${n.map(()=>"?").join(",")})`:"";return e.all(`SELECT DISTINCT m.symbol_id
|
|
306
|
+
FROM mentions m
|
|
307
|
+
WHERE m.role != 1
|
|
308
|
+
${r}`,...n??[])}).filter(n=>n.symbol_id!==null)}function Ko(e,t){let n=Jo(e,t,o=>{let s=o?`AND m.symbol_id IN (${o.map(()=>"?").join(",")})`:"";return e.all(`SELECT m.symbol_id, d.relative_path, c.document_id,
|
|
309
|
+
c.start_line AS chunk_start, c.end_line AS chunk_end
|
|
310
|
+
FROM mentions m
|
|
311
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
312
|
+
JOIN documents d ON c.document_id = d.id
|
|
313
|
+
WHERE m.role != 1
|
|
314
|
+
${s}
|
|
315
|
+
${e.pathExclusionsFor("d")}`,...o??[])}),r=new Map;for(let o of n){let s=`${o.symbol_id}\0${o.document_id}\0${o.chunk_start}\0${o.chunk_end}`;r.set(s,o)}let i=t?new Map(t.map((o,s)=>[o,s])):null;return[...r.values()].sort((o,s)=>(i?(i.get(o.symbol_id)??0)-(i.get(s.symbol_id)??0):0)||o.relative_path.localeCompare(s.relative_path)||o.chunk_start-s.chunk_start||o.chunk_end-s.chunk_end||o.symbol_id-s.symbol_id)}function Jo(e,t,n){if(!t)return n();if(t.length===0)return[];let r=[];for(let i=0;i<t.length;i+=750)r.push(...n(t.slice(i,i+750)));return r}function mC(e,t){return gC(e,[t]).get(t.symbolId)??[]}function gC(e,t){let n=t.map(o=>({symbolId:o.symbolId,prelude:xC(e,o)})).filter(o=>o.prelude!==null),r=hC(e,n.map(o=>o.symbolId)),i=new Map;for(let{symbolId:o,prelude:s}of n){let a=yC(e,r.get(o)??new Map,s.match,s.identifier);i.set(o,zo(e,a))}return i}function XG(e,t,n={}){return Dc(e,t,n).map(r=>({file:r.file,line:r.line,enclosingSymbol:r.enclosingSymbol}))}function Dc(e,t,n={}){let r=am(e,t,{semantic:n.semantic,semanticEvidence:n.semanticEvidence}),i=r.length>0?cm(r,"source-attribution"):cm(mC(e,t),"scip-reference-chunk");return n.includeIgnored===!0?i:i.filter(o=>!e.isIgnored(o.file))}function cm(e,t){return e.map(n=>({...n,provenance:t}))}function yC(e,t,n,r){let i=new Map;for(let[o,s]of t)i.set(o,SC(e,o,s,n,r));return i}function hC(e,t){let n=new Map;for(let r of Ko(e,t)){if(e.isIgnored(r.relative_path))continue;let i=n.get(r.symbol_id);i||(i=new Map,n.set(r.symbol_id,i));let o=i.get(r.relative_path);o||(o=[],i.set(r.relative_path,o)),o.push({start_line:r.chunk_start,end_line:r.chunk_end})}return n}function SC(e,t,n,r,i){let o=t===r.relativePath?{excludeStartLine:r.startLine,excludeEndLine:r.endLine}:{},s=i?Uo(e,t,i,o):[];return n.flatMap(a=>bC(s,a))}function bC(e,t){let n=e.filter(r=>r>=t.start_line&&r<=t.end_line);return n.length>0?n:[t.start_line]}function xC(e,t){let n=ti(e,t);return n?{match:n,identifier:be(n.symbol)||null}:null}import{execFileSync as lm,spawnSync as vC}from"child_process";import{platform as IC}from"os";import{resolve as EC}from"path";var um=IC()==="win32";function t1(e,t=vC){try{return t(e,["--version"],{stdio:"ignore",timeout:1e4}).status===0}catch{return!1}}function dm(e){let t=um?"where":"which";try{return lm(t,[e],{stdio:"pipe",timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var RC=/\.(?:c|m)?js$/i,PC=/\.(?:exe|com)$/i;function n1(e,t){return RC.test(e)?{binary:process.execPath,args:[e,...t]}:{binary:e,args:[...t]}}function wC(e,t){return lm(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL"})}function pm(e,t={}){let n=t.isWindows??um,r=t.lookup??wC,i;try{i=r(n?"where":"which",[e])}catch{return null}let o=i.split(/\r?\n/).map(s=>s.trim()).filter(Boolean);if(!n){let s=o[0];return s?EC(s):null}return o.find(s=>PC.test(s))??null}import{execFileSync as mm}from"child_process";import{createHash as CC}from"crypto";import{existsSync as Xo,statSync as FC}from"fs";import{createRequire as TC}from"module";import{platform as NC}from"os";import{dirname as fm,join as ri}from"path";var _C=TC(import.meta.url),f1={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Ac(e){return[e.indexerBinary,...e.binaryAliases??[]]}function kC(e){let t=Ac(e);return t.length===1?t[0]:t.join(" or ")}function Oc(e){for(let t of Ac(e)){let n=pm(t);if(n)return n}return DC(e)}function m1(e){return Oc(e)!==null||LC(e)}function LC(e){return gm(e)!==null}function DC(e){let t=gm(e);if(!t)return null;let r=JSON.parse(T(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return ri(fm(t),r);for(let i of Ac(e)){let o=r[i];if(o)return ri(fm(t),o)}return null}function gm(e){if(!e.bundledNpmPackage)return null;try{return _C.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function AC(e,t){for(let n of e.projectLocalBinaries??[]){let r=ri(t,n);if(Xo(r))return r}return null}function OC(e,t){for(let n of e.projectLocalBinaries??[]){let r=ri(t,n);if(Xo(r))return ym(t,n,r)}return null}function g1(e,t){let n=MC(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function MC(e,t){try{return ym(e,t.relativePath,t.configuredPath)}catch{return null}}function ym(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=zn(e,t,r),o=fo(e,t,r),s=FC(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:CC("sha256").update(o).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(s.mode&73)!==0}}function jC(e,t,n={}){return(n.trustProjectTools?OC(e,t)?.canonicalPath:null)??Oc(e)}function y1(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Mc(n,t))return t;let r=hm(n,t);return r?{...t,DOTNET_ROOT:r}:t}function h1(e,t,n={}){let r=kC(e),i=t?jC(e,t,n):Oc(e);if(!i)return{language:e.language,binaryLabel:r,installed:!1,runnable:!1,resolvedBinary:null,installUrl:e.installUrl,...t&&AC(e,t)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(e.indexerBinary!=="scip-dotnet")return{language:e.language,binaryLabel:r,installed:!0,runnable:!0,resolvedBinary:i};let o=BC(i);return{language:e.language,binaryLabel:r,installed:!0,runnable:o.runnable,resolvedBinary:i,installUrl:e.installUrl,note:o.note}}function BC(e){if(Mc(e,process.env))return{runnable:!0};let t=hm(e,process.env);if(t)return{runnable:!0,note:`using .NET 9 runtime from ${t}`};let n=Sm(process.env);return{runnable:!1,note:n.length>0?`.NET 9 runtime still unavailable after checking ${n.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function hm(e,t){for(let n of Sm(t))if(Mc(e,{...t,DOTNET_ROOT:n}))return n;return null}function Sm(e){let t=[],n=e.DOTNET_ROOT;if(n&&Xo(n)&&t.push(n),NC()==="darwin"&&dm("brew"))try{let r=mm("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=ri(r,"libexec");Xo(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Mc(e,t){try{return mm(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}function Nn(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}}var $C=new Set(["aix","android","darwin","freebsd","haiku","linux","openbsd","sunos","win32","cygwin","netbsd"]);function Tt(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;return t.version!==1||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.platform!="string"||!$C.has(t.platform)||typeof t.startToken!="string"||t.startToken.trim()===""?null:{version:1,pid:t.pid,platform:t.platform,startToken:t.startToken}}function ke(e,t){return e.version===t.version&&e.pid===t.pid&&e.platform===t.platform&&e.startToken===t.startToken}import{execFileSync as GC}from"child_process";import{platform as VC}from"os";var HC=1e3,bm=16*1024,jc;function Nt(e,t=vm){if(!Number.isSafeInteger(e)||e<=0)return null;let n=e===process.pid&&t===vm;if(n&&jc)return{...jc};try{let r=WC(e,t);if(!r)return null;let i={version:1,pid:e,platform:t.platform,startToken:r};return n&&(jc=i),{...i}}catch{return null}}function WC(e,t){if(t.platform==="linux"||t.platform==="android")return qC(t.readFile(`/proc/${e}/stat`));if(t.platform==="win32"){let n=`([DateTimeOffset](Get-Process -Id ${e} -ErrorAction Stop).StartTime).ToUnixTimeMilliseconds()`;return xm(t.run("powershell.exe",["-NoProfile","-NonInteractive","-Command",n]))}return t.platform==="darwin"||t.platform==="freebsd"||t.platform==="openbsd"||t.platform==="netbsd"?xm(t.run("ps",["-p",String(e),"-o","lstart="])):null}function qC(e){let t=e.lastIndexOf(")");if(t<0)return null;let r=e.slice(t+1).trim().split(/\s+/)[19];return r&&/^\d+$/.test(r)?r:null}function xm(e){let t=e.trim();return t===""?null:t}var vm={platform:VC(),readFile(e){return sa(e,{maxBytes:bm,inputKind:"process identity pseudo-file"})},run(e,t){return GC(e,[...t],{encoding:"utf8",timeout:HC,maxBuffer:bm,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}};function _t(){return performance.now()}function w1(e,t,n,r,i,o){if(e>0)return n;let s=Math.max(0,Math.min(o,t-1));return Math.min(i,r*2**s)}import{randomUUID as XC}from"crypto";import{closeSync as YC,existsSync as QC,fsyncSync as ZC,linkSync as eF,mkdirSync as tF,openSync as nF,renameSync as rF,unlinkSync as iF,writeSync as oF}from"fs";import{dirname as Em}from"path";import{chmodSync as UC,constants as zC,copyFileSync as KC}from"fs";import{dirname as JC}from"path";var Im=Object.freeze({...Sn,copyFile:(e,t)=>KC(e,t,zC.COPYFILE_FICLONE),chmodFile:(e,t)=>UC(e,t)});function ii(e,t,n={}){let r=n.runtime??Im,i=JC(t),o=me(i,r);r.copyFile(e,t),n.mode!==void 0&&r.chmodFile(t,n.mode);let s=r.openFile(t,"r");try{r.syncFile(s)}finally{r.closeFile(s)}return W(o,D(i,r))}var Rm=Object.freeze({platform:process.platform,randomToken:()=>XC(),pathExists:e=>QC(e),makeDirectory:e=>tF(e,{recursive:!0}),openFile:(e,t,n)=>nF(e,t,n),writeFile:(e,t,n,r)=>oF(e,t,n,r),syncFile:e=>ZC(e),closeFile:e=>YC(e),renameFile:(e,t)=>rF(e,t),linkFile:(e,t)=>eF(e,t),removeFile:e=>iF(e)});function Bc(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??Rm,o=Em(e),s=r==="durable"?me(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,St(l,c,i,"atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.renameFile(a,e),u=!1;let d=r==="durable"?W(s,D(o,i)):"not-requested";return Pm(r,d)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function Yo(e,t,n={}){let r=n.durability??"visibility",i=n.runtime??Rm;if(!i.linkFile)throw new Error("Exclusive atomic file publication requires hard-link support.");let o=Em(e),s=r==="durable"?me(o,i):(i.makeDirectory(o),"not-requested"),a=`${e}.tmp-${i.randomToken()}`,c=typeof t=="string"?Buffer.from(t):t,l,u=!1;try{l=i.openFile(a,"wx",n.mode??384),u=!0,St(l,c,i,"exclusive atomic file"),r==="durable"&&i.syncFile(l),i.closeFile(l),l=void 0,i.linkFile(a,e);let d=r==="durable"?D(o,i):"not-requested";i.removeFile(a),u=!1;let p=r==="durable"?W(s,d,D(o,i)):"not-requested";return Pm(r,p)}finally{if(l!==void 0)try{i.closeFile(l)}catch{}if(u)try{i.removeFile(a)}catch{}}}function Pm(e,t){return{requestedDurability:e,achievedDurability:e==="visibility"?"visibility":t==="synced"?"directory-durable":"file-flushed",directorySync:t}}function Qt(e,t,n={}){Bc(e,wm(t,n),{durability:"visibility",runtime:n.runtime})}function Le(e,t,n={}){return Bc(e,wm(t,n),{durability:"durable",runtime:n.runtime})}function wm(e,t){let n=JSON.stringify(e,null,t.spacing);return t.trailingNewline?`${n}
|
|
316
|
+
`:n}import{join as Qo}from"path";var z1=6,K1=1e4,sF="watch.lock",aF="watch-state.json",cF="watch-activity.json",lF="watch-refresh-requests";function J1(e){return{lockPath:Qo(e,sF),statePath:Qo(e,aF),activityPath:Qo(e,cF),refreshRequestsPath:Qo(e,lF)}}function X1(e){try{return uF(JSON.parse(T(e,"watch service state")))}catch{return null}}function uF(e){if(!e||typeof e!="object")return null;let t=e;if(t.version!==1||typeof t.protocolVersion!="number"||typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0||typeof t.projectRoot!="string"||t.worktreeId!==void 0&&(typeof t.worktreeId!="string"||t.worktreeId.length===0)||typeof t.cliVersion!="string"||!se(t.startedAt)||!se(t.heartbeatAt)||!se(t.lastActivityAt)||!dF(t.watcher)||t.idleDeadlineAt!==void 0&&!se(t.idleDeadlineAt))return null;if(t.processIdentity!==void 0){let n=Tt(t.processIdentity);if(!n||n.pid!==t.pid)return null;t.processIdentity=n}return t.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(t.indexGeneration)||t.lastError!==void 0&&!pF(t.lastError)||t.lastRefresh!==void 0&&!fF(t.lastRefresh)||t.reindexActivity!==void 0&&!mF(t.reindexActivity)||t.refreshRequests!==void 0&&!yF(t.refreshRequests)||t.typescriptSemantic!==void 0&&!hF(t.typescriptSemantic)||t.typescriptIndex!==void 0&&!SF(t.typescriptIndex)?null:t}function se(e){return Ki(e)}function dF(e){if(!e||typeof e!="object"||!("state"in e))return!1;let t=e;switch(t.state){case"idle":return!0;case"waiting":return de(t.changedFiles)&&de(t.reindexAt);case"indexing":return de(t.startedAt);case"cooldown":return de(t.until)&&typeof t.dirty=="boolean";case"budget-paused":return de(t.until)&&typeof t.dirty=="boolean"&&typeof t.reason=="string"&&w(t.rebuilt)&&w(t.estimatedWriteBytes);case"draining":return de(t.startedAt)&&typeof t.reason=="string";default:return!1}}function pF(e){if(!e||typeof e!="object")return!1;let t=e;return se(t.at)&&typeof t.message=="string"}function fF(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.trigger?.kind=="string"&&typeof t.result=="string"&&se(t.startedAt)&&se(t.completedAt)&&de(t.durationMs)}function mF(e){if(!e||typeof e!="object")return!1;let t=e;return t.confidence!==void 0&&t.confidence!=="complete"&&t.confidence!=="partial"&&t.confidence!=="unavailable"||t.recordsRead!==void 0&&!w(t.recordsRead)||t.invalidRecords!==void 0&&!w(t.invalidRecords)||t.skippedRecords!==void 0&&!w(t.skippedRecords)||t.readErrors!==void 0&&!w(t.readErrors)||t.ignoredPartialTailBytes!==void 0&&!w(t.ignoredPartialTailBytes)||!se(t.windowStartedAt)||!se(t.windowEndedAt)||!w(t.runs)||!w(t.rebuilt)||t.fullRebuilds!==void 0&&!w(t.fullRebuilds)||!w(t.reused)||!w(t.failed)||!w(t.suppressed)||!de(t.estimatedLogicalOutputBytes)||t.estimatedWriteBytes!==void 0&&!w(t.estimatedWriteBytes)||t.reflinkedBytes!==void 0&&!w(t.reflinkedBytes)||t.fallbackCopiedBytes!==void 0&&!w(t.fallbackCopiedBytes)||t.oldestRebuildAt!==void 0&&!se(t.oldestRebuildAt)||t.oldestWriteAt!==void 0&&!se(t.oldestWriteAt)||t.languageAttribution!==void 0&&t.languageAttribution!=="complete"&&t.languageAttribution!=="partial"&&t.languageAttribution!=="unavailable"||t.attributedRuns!==void 0&&!w(t.attributedRuns)||t.unattributedRuns!==void 0&&!w(t.unattributedRuns)||t.invalidLanguageDetails!==void 0&&!w(t.invalidLanguageDetails)||t.estimatedLogicalOutputBytes<0||!t.byTrigger||typeof t.byTrigger!="object"||Array.isArray(t.byTrigger)||t.byLanguage!==void 0&&!gF(t.byLanguage)?!1:Object.values(t.byTrigger).every(n=>n===void 0||w(n))}function gF(e){if(!e||typeof e!="object"||Array.isArray(e))return!1;for(let[t,n]of Object.entries(e)){if(!Ji.includes(t)||!n||typeof n!="object")return!1;let r=n;if(!w(r.runs)||!w(r.rebuilt)||!w(r.reused)||!w(r.producedOutputBytes)||!Nu(r.durationMs)||r.rebuilt+r.reused!==r.runs)return!1}return!0}function yF(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.pending)&&w(t.claimed)&&w(t.completed)&&w(t.expired)&&w(t.invalid)&&(t.oldestPendingAt===void 0||se(t.oldestPendingAt))}function hF(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&de(t.requests)&&de(t.sessionsCreated)&&de(t.sessionsReused)&&de(t.sessionsRefreshed)&&de(t.sessionsReplaced)&&de(t.projectsCreated)&&(t.lastRequestAt===void 0||se(t.lastRequestAt))&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||se(t.busyUntil))&&(t.mailbox===void 0||Cm(t.mailbox))}function SF(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.protocolVersion=="number"&&(t.state==="idle"||t.state==="ready"||t.state==="unavailable"||t.state==="error")&&w(t.requests)&&w(t.sessionsCreated)&&w(t.sessionsReplaced)&&(t.sessionsEvicted===void 0||w(t.sessionsEvicted))&&(t.activeSessions===void 0||w(t.activeSessions))&&(t.maxActiveSessions===void 0||w(t.maxActiveSessions))&&(t.heapUsedBytes===void 0||w(t.heapUsedBytes))&&(t.heapLimitBytes===void 0||w(t.heapLimitBytes))&&(t.softMemoryLimitBytes===void 0||w(t.softMemoryLimitBytes))&&(t.retireRequested===void 0||typeof t.retireRequested=="boolean")&&w(t.initializations)&&w(t.programUpdates)&&w(t.documentsEmitted)&&w(t.documentsRemoved)&&(t.lastRequestAt===void 0||se(t.lastRequestAt))&&(t.lastDurationMs===void 0||de(t.lastDurationMs)&&t.lastDurationMs>=0)&&(t.lastError===void 0||typeof t.lastError=="string")&&(t.busyUntil===void 0||se(t.busyUntil))&&(t.mailbox===void 0||Cm(t.mailbox))}function Cm(e){if(!e||typeof e!="object")return!1;let t=e;return w(t.pending)&&w(t.inflight)&&w(t.responses)&&w(t.deadLetters)&&w(t.invalid)&&w(t.totalItems)&&de(t.totalBytes)&&t.totalBytes>=0&&t.totalItems===t.pending+t.inflight+t.responses+t.deadLetters&&(t.oldestPendingAt===void 0||se(t.oldestPendingAt))}function de(e){return typeof e=="number"&&Number.isFinite(e)}var bF=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function Zo(e){let t=e.toLowerCase();return bF.some(n=>t.endsWith(n))}function ts(e){let t=es(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(p=>[p.path,p])),i=e.snapshot.files.filter(p=>{let f=jt(p.path,["typescript"]);return f==="config"||f==="ambient"}).map(p=>p.path),o=es([...t,...i]),s=o.find(p=>!r.has(p)),a=new Set(e.snapshot.files.map(p=>p.path)).size!==e.snapshot.files.length,c=!s&&o.some(p=>Fm(r.get(p))),l=U(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:es(e.snapshot.typescriptProjects),membership:t})),u,d;return{identityFor(p,f){if(!n.has(p))return fr("target-outside-project");if(a)return fr("duplicate-input-path");if(s)return fr("missing-input-fingerprint");if(c)return fr("unreadable-input");let g=[],y,m;if(e.graph===null)g.push("dependency-graph-unavailable"),m="whole-project",y=o;else{let v=p===u&&d?d:xF(p,e.graph);if(u=p,d=v,v.find(x=>!r.has(x)))return fr("missing-input-fingerprint");if(y=es([...v,...i]),y.some(x=>Fm(r.get(x))))return fr("unreadable-input");m="dependency-closure"}let S=y.map(v=>vF(r.get(v)));return{version:1,key:U(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:f,projectIdentity:l,inputs:S})),mode:m,inputFiles:y,reasons:g}}}}function xF(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let o=r[i];if(!(o===void 0||n.has(o))){n.add(o);for(let s of[...t.get(o)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function vF(e){return e.semanticHash===void 0?{path:e.path,size:e.size,hash:e.hash}:{path:e.path,semanticHash:e.semanticHash}}function Fm(e){return e.size<0||e.hash==="unreadable"}function fr(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function es(e){return[...new Set(e)].sort()}import{createRequire as IF}from"module";var Tm=IF(import.meta.url),oi,ns;function EF(){if(oi!==void 0)return oi;try{oi=Tm("ts-morph")}catch{oi=null}return oi}function rs(){if(ns)return ns;let e=EF();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=Tm("ts-morph/package.json").version??"unknown"}catch{}return ns=`ts-morph:${t}:typescript:${e.ts.version}`,ns}function rV(e,t){return t.map(n=>({tsconfigPath:n,project:new e.Project({tsConfigFilePath:n,skipFileDependencyResolution:!0})}))}function iV(e,t,n){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:n}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}var RF=rt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function $c(e,t,n){let r=RF.get(e,()=>PF(e));if(!r)return null;let i=`${n}\0${t}`,o=r.identities.get(i);if(o)return o;let s=r.builder.identityFor(t,n);return r.identities.set(i,s),s}function si(e){return Re(e,{includeIgnored:!1}).filter(Zo).sort()}function PF(e){try{if(!e.generation.metadataRaw)return null;let t=Bt(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let n=Rr(t.metadata.fingerprint);return n?{builder:ts({projectFiles:si(e),snapshot:n,graph:cr(e),engineIdentity:rs()}),identities:new Map}:null}catch{return null}}function km(e,t){let n=Gc(e);for(let r of t.values())n.add(r);return n.finish()}function Gc(e){let t=new Map(e.map(r=>[r.symbol,r])),n=new Map(e.map(r=>[r.symbolId,[]]));return{add(r){for(let i of r){let o=t.get(i.targetSymbol);o&&n.get(o.symbolId).push(i.location)}},finish(){for(let[r,i]of n)n.set(r,wF(i));return n}}}function Lm(e,t,n){let r=_m(e,t),i=_m(e,n),o=[...r].filter(d=>!i.has(d)).sort(),s=[...i].filter(d=>!r.has(d)).sort(),a=Nm(e,t),c=Nm(e,n),l=[...a].filter(d=>!c.has(d)).sort(),u=[...c].filter(d=>!a.has(d)).sort();return{passed:o.length===0&&s.length===0,expectedCount:r.size,actualCount:i.size,missing:o,extra:s,callerFiles:{passed:l.length===0&&u.length===0,expectedCount:a.size,actualCount:c.size,missing:l,extra:u}}}function Nm(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])i.file!==r.relativePath&&n.add(`${r.symbol}\0${i.file}`);return n}function gV(e,t,n){let r=new Set(n),i=new Map(n.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])r.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,CF(s));return i}function _m(e,t){let n=new Set;for(let r of e)for(let i of t.get(r.symbolId)??[])n.add(`${r.symbol}\0${i.file}\0${i.line}\0${i.column}`);return n}function wF(e){let t=new Map;for(let n of e)t.set(`${n.file}\0${n.line}\0${n.column}`,n);return[...t.values()].sort(Dm)}function CF(e){let t=new Map;for(let n of e){let{location:r}=n;t.set(`${n.targetSymbol}\0${r.file}\0${r.line}\0${r.column}`,n)}return[...t.values()].sort((n,r)=>n.targetSymbol.localeCompare(r.targetSymbol)||Dm(n.location,r.location))}function Dm(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}var Vc="typescript-reference-fragment-v2",Am=128,is=ce({kind:"typescript-reference-fragments",invalidation:te("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:TF});function PV(e,t,n,r=e,i,o=new Set(n.keys())){let s=si(e),a=ts({projectFiles:s,snapshot:t,graph:i??cr(e),engineIdentity:rs()}),c=[],l=0;for(let[d,p]of n){let f=a.identityFor(d,Vc).key;if(!f){l+=1;continue}c.push({relativePath:d,contentHash:f,value:[...p]})}let u=s.filter(d=>!o.has(d)&&!n.has(d)).length;return is.writeBatch(r,c),{affectedFiles:c.length,carriedFiles:u,skippedAffectedFiles:l}}function wV(e,t,n,r){let i=t.filter(s=>Zo(s.relativePath));if(i.length===0)return ai("no TypeScript definitions");let o=ai("shadow did not run");return z("typescript.reference-fragments.shadow",()=>{try{let s=r(i[0].relativePath);if(!s.availability().available||!s.referenceFragmentsForFiles)return o=ai("TypeScript reference fragment provider is unavailable"),o;let a=si(e),c=new Set(a),l=new Map;for(let f of Om(a)){let g=s.referenceFragmentsForFiles(f);if(f.some(y=>!g.has(y)))return o=ai("TypeScript reference fragment provider returned an incomplete batch"),o;for(let y of f)l.set(y,g.get(y)??[])}let u=km(i,l),d=Lm(i,FF(n,c),u);if(!d.passed)return o={state:"failing",files:a.length,keyedFiles:0,writtenFiles:0,...d},o;let p=[];for(let f of a){let g=$c(e,f,Vc);g?.key&&p.push({relativePath:f,contentHash:g.key,value:l.get(f)??[]})}return is.writeBatch(e,p),o={state:"passing",files:a.length,keyedFiles:p.length,writtenFiles:p.length,...d},o}catch(s){return o=ai(s instanceof Error?s.message:String(s)),o}},()=>({...o}))}function FF(e,t){return new Map([...e].map(([n,r])=>[n,r.filter(i=>t.has(i.file))]))}function CV(e,t,n){if(t.length===0)return{references:new Map,files:0,cacheHits:0,cacheMisses:0,computedFiles:0};let r="fallback",i=0,o=0,s=0,a=0;return z("typescript.reference-fragments.materialize",()=>{try{let c=si(e);i=c.length;let l=Gc(t),u=[];for(let p of c){let f=$c(e,p,Vc);if(!f?.key)return null;let g=is.read(e,p,f.key);g===null?(s+=1,u.push({file:p,contentHash:f.key})):(o+=1,l.add(g))}if(s===0)return r="hit",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a};let d=n(t[0].relativePath);if(!d.availability().available||!d.referenceFragmentsForFiles)return null;for(let p of Om(u)){let f=p.map(({file:y})=>y),g=d.referenceFragmentsForFiles(f);if(f.some(y=>!g.has(y)))return null;is.writeBatch(e,p.map(({file:y,contentHash:m})=>({relativePath:y,contentHash:m,value:g.get(y)??[]})));for(let y of f)l.add(g.get(y)??[]);a+=p.length}return r="computed",{references:l.finish(),files:i,cacheHits:o,cacheMisses:s,computedFiles:a}}catch{return null}},()=>({state:r,files:i,cacheHits:o,cacheMisses:s,computedFiles:a}))}function Om(e){let t=[];for(let n=0;n<e.length;n+=Am)t.push(e.slice(n,n+Am));return t}function ai(e){return{state:"unavailable",files:0,keyedFiles:0,writtenFiles:0,expectedCount:0,actualCount:0,missing:[],extra:[],reason:e}}function TF(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(NF)?null:t}catch{return null}}function NF(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}function os(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function Mm(e,t){if(e?.aborted)throw os(e,t)}import{randomUUID as _F}from"crypto";import{closeSync as kF,fsyncSync as LF,linkSync as DF,mkdirSync as AF,openSync as OF,statSync as MF,unlinkSync as jF,writeSync as BF}from"fs";import{dirname as zc}from"path";var Wc="scip-query-process-lock",qc=1,ss=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:Nn,readProcessIdentity:Nt,randomToken:()=>_F(),makeDirectory:e=>AF(e,{recursive:!0}),openFile:(e,t,n)=>OF(e,t,n),writeFile:(e,t,n,r)=>BF(e,t,n,r),syncFile:e=>LF(e),closeFile:e=>kF(e),linkFile:(e,t)=>DF(e,t),readFile:e=>T(e,"process lock record"),statFile:e=>{let t=MF(e);return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs}},removeFile:e=>jF(e)});function as(e,t){let n=t.runtime??ss;n.makeDirectory(zc(e));let r;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:jm(e,t,n),...r?{reclaimed:r}:{}}}catch(o){if(o.code!=="EEXIST")throw o;let s=mr(e,{parseLegacy:t.parseLegacy,runtime:n});if(i===0&&GF(e,s,{creationGraceMs:t.creationGraceMs,parseLegacy:t.parseLegacy,runtime:n})){r=s;continue}return{kind:"contended",observation:s}}return{kind:"contended",observation:mr(e,{parseLegacy:t.parseLegacy,runtime:n})}}function mr(e,t={}){let n=t.runtime??ss,r,i;try{r=n.statFile(e),i=n.readFile(e)}catch(c){return c.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let o;try{o=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:r}}let s=$F(o);if(s)return{state:"valid",raw:i,identity:r,record:s,owner:WF(s),parsed:o};let a=t.parseLegacy?.(o)??null;return a?{state:"legacy",raw:i,identity:r,owner:a,parsed:o}:{state:"malformed",raw:i,identity:r,parsed:o}}function $F(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e;if(t.protocol!==Wc||t.version!==qc||typeof t.kind!="string"||t.kind.trim()===""||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.token!="string"||t.token.trim()===""||typeof t.startedAt!="string"||!Number.isFinite(Date.parse(t.startedAt))||t.detail!==void 0&&(typeof t.detail!="object"||t.detail===null||Array.isArray(t.detail)))return null;let n=t.processIdentity===void 0?null:Tt(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{protocol:Wc,version:qc,kind:t.kind,pid:t.pid,token:t.token,...n?{processIdentity:n}:{},startedAt:t.startedAt,...t.detail?{detail:t.detail}:{}}}function GF(e,t,n={}){let r=n.runtime??ss;if(!Uc(t,r))return!1;let i=HF(`${e}.reclaim`,r);if(!i)return!1;try{let o=mr(e,{parseLegacy:n.parseLegacy,runtime:r});return!$m(t,o)||!Uc(o,r)?!1:Kc(e,r)}finally{i.release()}}function jm(e,t,n){let r=t.directoryDurability??"durable",i=t.pid??process.pid,o=n.randomToken(),s=t.processIdentity===void 0?n.readProcessIdentity(i):t.processIdentity,a={protocol:Wc,version:qc,kind:t.kind,pid:i,token:o,...s?{processIdentity:s}:{},startedAt:new Date(n.wallNow()).toISOString(),...t.detail?{detail:t.detail}:{}},c=`${e}.${o}.candidate`,l=n.openFile(c,"wx",384),u;try{St(l,Buffer.from(`${JSON.stringify(a)}
|
|
317
|
+
`),n,"process lock"),n.syncFile(l)}catch(p){u=p}try{n.closeFile(l)}catch(p){u??=p}if(u!==void 0)throw Hc(c,n),u;try{n.linkFile(c,e)}catch(p){throw Hc(c,n),p}if(Hc(c,n),r==="durable")try{Gm(zc(e),n)}catch(p){throw VF(e,a,n),p}let d=!1;return{path:e,record:a,release:()=>d?!1:(d=!0,Bm(e,a,n,r))}}function VF(e,t,n=ss){return Bm(e,t,n,"durable")}function Bm(e,t,n,r){let i=mr(e,{runtime:n});return i.state!=="valid"||!i.record||i.record.pid!==t.pid||i.record.token!==t.token||t.processIdentity&&(!i.record.processIdentity||!ke(t.processIdentity,i.record.processIdentity))?!1:Kc(e,n,r)}function HF(e,t){for(let n=0;n<2;n+=1)try{return jm(e,{kind:"reclaim-guard",runtime:t},t)}catch(r){if(r.code!=="EEXIST")return null;let i=mr(e,{runtime:t});if(n>0||!Uc(i,t))return null;let o=mr(e,{runtime:t});if(!$m(i,o)||!Kc(e,t))return null}return null}function Uc(e,t){if(e.state==="missing")return!1;if(e.owner){if(!t.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let n=t.readProcessIdentity(e.owner.pid);return n!==null&&!ke(e.owner.processIdentity,n)}return!1}function $m(e,t){return e.state===t.state&&e.raw===t.raw&&e.identity!==void 0&&t.identity!==void 0&&e.identity.dev===t.identity.dev&&e.identity.ino===t.identity.ino&&e.identity.size===t.identity.size&&e.identity.mtimeMs===t.identity.mtimeMs}function WF(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function Gm(e,t){let n;try{n=t.openFile(e,"r")}catch(r){if(Wn(r,process.platform))return;throw r}try{t.syncFile(n)}catch(r){if(!Wn(r,process.platform))throw r}finally{t.closeFile(n)}}function Kc(e,t,n="durable"){try{return t.removeFile(e),n==="durable"&&Gm(zc(e),t),!0}catch{return!1}}function Hc(e,t){try{t.removeFile(e)}catch{}}import{join as qF}from"path";var UF=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function Vm(e,t={}){return kt(qF(e,"gc.lock"),t)}function kt(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??_t,o=i()+n;do{let s=Hm(e,t.directoryDurability);if(s)return Wm(s);let a=o-i();if(a<=0)return null;zF(Math.min(r,a))}while(i()<=o);return null}async function VV(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??_t,o=i()+n;do{Mm(t.signal,"Lock acquisition was aborted.");let s=Hm(e,t.directoryDurability);if(s)return Wm(s);let a=o-i();if(a<=0)return null;await KF(Math.min(r,a),t.signal)}while(i()<=o);return null}function Hm(e,t){let n=as(e,{kind:"generic",parseLegacy:UF,...t?{directoryDurability:t}:{}});return n.kind==="acquired"?n.lock:null}function Wm(e){return{release:()=>{e.release()}}}function zF(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function KF(e,t){return t?.aborted?Promise.reject(os(t,"Lock acquisition was aborted.")):new Promise((n,r)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),n()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),r(t?os(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}import{createHash as JF,randomUUID as XF}from"crypto";import{existsSync as gr,mkdirSync as YF,readdirSync as QF,rmSync as Um,statSync as zm}from"fs";import{basename as ZF,dirname as cs,join as De}from"path";var _n=1,Qc=1,li=".scipquery-generations",ls="manifest.json",Km="readers",eT="gc.lock",tT=128,ci=new Map,Jm={pid:process.pid,now:()=>new Date,randomToken:()=>XF(),isProcessAlive:Nn,readProcessIdentity:Nt};function X(e){return De(cs(e),li)}function us(e){return De(X(e),eT)}function Xm(e,t=Jm){let n=kt(us(e.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!n)throw new Error("SQLite generation retention is busy; retry opening the index.");let r;try{let i=el(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let s=De(X(e.dbPath),Km);YF(s,{recursive:!0}),r=De(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);Qt(r,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...a?{processIdentity:a}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!r||(c=!0,Um(r,{force:!0}))}}}finally{n.release()}}function Zc(e,t,n=Jm,r={}){let i=De(X(e),Km);if(!gr(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let l of QF(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let u=De(i,l.name),d;try{d=nT(JSON.parse(T(u,"SQLite generation reader lease")))}catch{d=null}if(!d){c+=1;for(let p of t)o.add(p);continue}if(!rT(d,n)){r.removeStale!==!1&&(Um(u,{force:!0}),a+=1);continue}s+=1,o.add(d.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function nT(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:Tt(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...n?{processIdentity:n}:{},acquiredAt:t.acquiredAt}}function rT(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||ke(e.processIdentity,n)}function Zt(e){try{let t=JSON.parse(T(De(X(e),"state.json"),"SQLite generation state"));return aT(t)?t:null}catch{return null}}function ui(e,t){return di(X(e),t)}function di(e,t){try{let n=JSON.parse(T(De(e,t,ls),"SQLite generation manifest"));return sT(n,t)?n:null}catch{return null}}function el(e){let t=Zt(e.dbPath);if(t){let n=iT(e,t.currentGeneration);if(n)return n;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(gr(De(cs(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return oT(e,t?.currentGeneration)}function eH(e){let t=Zt(e);if(t)return t.currentGeneration;try{let n=De(cs(e),"meta.json"),r=gr(n)?T(n,"reindex metadata"):void 0;return Ym(e,r)}catch{return null}}function en(e){return _u(Bt(e))??e}function iT(e,t){try{let n=De(X(e.dbPath),t),r=ui(e.dbPath,t);if(!r)return null;let i=Jc(n,r.database),o=r.index?Jc(n,r.index):void 0,s=r.metadata?Jc(n,r.metadata):void 0;return!Xc(i,r.database)||r.index&&(!o||!Xc(o,r.index))||r.metadata&&(!s||!Xc(s,r.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:T(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function oT(e,t){let n=Lt(e.dbPath),r=De(cs(e.dbPath),"meta.json"),i=gr(r)?T(r,"reindex metadata"):void 0,o=gr(e.indexPath)?e.indexPath:void 0;return{identity:t??Ym(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function Ym(e,t){let n=JF("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(en(t)),n.update(`\0${Lt(e)}`),n.digest("hex")}function Lt(e){let t=zm(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Jc(e,t){if(ZF(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return De(e,t.file)}function Xc(e,t){if(!gr(e))return!1;let n=qm(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(ci.has(r))return!0;let i=dn(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=qm(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(ci.set(r,!0);ci.size>tT;){let s=ci.keys().next().value;if(s===void 0)break;ci.delete(s)}return!0}function qm(e){let t=zm(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function sT(e,t){return e.version===Qc&&e.identity===t&&Yc(e.database)&&(e.index===void 0||Yc(e.index))&&(e.metadata===void 0||Yc(e.metadata))}function Yc(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function aT(e){return e.version===_n&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&cT(e.stableMirrors)&&lT(e.previousGeneration)&&uT(e.publication)}function cT(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function lT(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function uT(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import dT from"better-sqlite3";var pT=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],tl=class{constructor(t,n){this.connection=t;this.releaseGenerationReader=n}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let n of pT)this.connection.pragma(n);t(this.connection)}catch(n){try{this.close()}catch(r){throw new AggregateError([n,r],"SQLite initialization and rollback both failed.",{cause:r})}throw n}}close(){if(!this.active)return;this.active=!1;let t,n;try{this.connection.close()}catch(r){t=r}try{this.releaseGenerationReader()}catch(r){n=r}if(t!==void 0&&n!==void 0)throw new AggregateError([t,n],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(n!==void 0)throw n}},fT=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".scipquery-cache","__pycache__",".venv","venv"],Qm=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;constructor(t,n){this.config=t,this.pathFilter=n??null;let r=hT(t),i=new tl(r.db,r.release);try{i.initialize(yT),this.generation=r.generation,this.connection=r.db,this.connectionOwnership=i,this.db=mT(r.db)}catch(o){try{i.close()}catch(s){throw new AggregateError([o,s],"SQLite construction and rollback both failed.",{cause:s})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
|
|
318
|
+
EXISTS (
|
|
319
|
+
SELECT 1
|
|
320
|
+
FROM defn_enclosing_ranges local_der
|
|
321
|
+
JOIN documents local_d ON local_der.document_id = local_d.id
|
|
322
|
+
WHERE local_der.symbol_id = gs.id
|
|
323
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
324
|
+
)
|
|
325
|
+
OR EXISTS (
|
|
326
|
+
SELECT 1
|
|
327
|
+
FROM mentions local_m
|
|
328
|
+
JOIN chunks local_c ON local_m.chunk_id = local_c.id
|
|
329
|
+
JOIN documents local_d ON local_c.document_id = local_d.id
|
|
330
|
+
WHERE local_m.symbol_id = gs.id
|
|
331
|
+
AND local_m.role = 1
|
|
332
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
333
|
+
)
|
|
334
|
+
)`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(n=>fT.flatMap(r=>[`AND ${n}.relative_path NOT LIKE '${r}/%'`,`AND ${n}.relative_path NOT LIKE '%/${r}/%'`])).join(`
|
|
335
|
+
`)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...n){return this.statement(t).all(...n)}get(t,...n){return this.statement(t).get(...n)}close(){this.statementCache.clear(),this.connectionOwnership.close()}statement(t){let n=this.statementCache.get(t);return n||(n=this.connection.prepare(t),this.statementCache.set(t,n)),n}};function mT(e){return Object.freeze({prepare(t){let n=e.prepare(t);if(!n.readonly||!n.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return gT(n)}})}function gT(e){let t={get:(...n)=>e.get(...n),all:(...n)=>e.all(...n),iterate:(...n)=>e.iterate(...n),pluck(n){return n===void 0?e.pluck():e.pluck(n),t},expand(n){return n===void 0?e.expand():e.expand(n),t},raw(n){return n===void 0?e.raw():e.raw(n),t},bind(...n){return e.bind(...n),t},columns:()=>e.columns(),safeIntegers(n){return n===void 0?e.safeIntegers():e.safeIntegers(n),t}};return Object.freeze(t)}function yT(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let n=e.prepare("SELECT relative_path FROM documents").iterate();for(let r of n)Ie(r.relative_path)}function hT(e){for(let t=0;t<4;t+=1){let n=Xm(e),r=n.generation,i;try{i=new dT(r.databasePath,{readonly:!0,fileMustExist:!0})}catch(o){throw n.release(),o}if(r.source==="immutable")return{db:i,generation:r,release:n.release};try{let o=el(e);if(r.databaseFileIdentity===Lt(r.databasePath)&&o.source==="legacy"&&o.identity===r.identity&&o.databaseFileIdentity===r.databaseFileIdentity&&o.metadataRaw===r.metadataRaw)return{db:i,generation:r,release:n.release}}catch(o){throw i.close(),n.release(),o}i.close(),n.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import ST from"ignore";import{existsSync as Zm,readdirSync as bT}from"fs";import{dirname as nl,isAbsolute as eg,join as ds,relative as xT,resolve as vT}from"path";function uH(e){let t=ST();return IT(e,t)||t.add(PT),{isIgnored:r=>rl(t,e,r),filter:r=>r.filter(i=>!rl(t,e,i))}}function IT(e,t){let n=new Set,r=(s,a)=>{if(!(n.has(s)||!Zm(s)))try{let c=j(s,{maxBytes:ne,inputKind:"gitignore file"});t.add(a?ET(c,a):c),n.add(s)}catch{}},i=nl(e),o=0;for(;i!==nl(i)&&o<5&&(r(ds(i,".gitignore"),""),!Zm(ds(i,".git")));)i=nl(i),o++;return tg(e,"",t,r),n.size>0}function tg(e,t,n,r){let i=t?ds(e,t):e;r(ds(i,".gitignore"),t);let o;try{o=bT(i,{withFileTypes:!0})}catch{return}for(let s of o){if(!s.isDirectory()||s.name===".git")continue;let a=t?`${t}/${s.name}`:s.name;rl(n,e,`${a}/`)||tg(e,a,n,r)}}function ET(e,t){let n=t.replaceAll("\\","/").replace(/\/+$/,"");return e.split(/\r?\n/).map(r=>RT(r,n)).join(`
|
|
336
|
+
`)}function RT(e,t){let n=e.trimStart();if(!n||n.startsWith("#"))return e;let r=e.slice(0,e.length-n.length),i=n.startsWith("!"),o=i?n.slice(1):n;if(!o||o.startsWith("#"))return e;let s=o.startsWith("/"),a=s?o.slice(1):o,u=(a.endsWith("/")?a.slice(0,-1):a).includes("/")||s?`${t}/${a}`:`${t}/**/${a}`;return`${r}${i?"!":""}${u}`}var PT=`
|
|
337
|
+
# Dependencies
|
|
338
|
+
node_modules/
|
|
339
|
+
vendor/
|
|
340
|
+
.bundle/
|
|
341
|
+
|
|
342
|
+
# Build output
|
|
343
|
+
dist/
|
|
344
|
+
build/
|
|
345
|
+
out/
|
|
346
|
+
target/
|
|
347
|
+
bin/
|
|
348
|
+
obj/
|
|
349
|
+
|
|
350
|
+
# Python
|
|
351
|
+
__pycache__/
|
|
352
|
+
*.pyc
|
|
353
|
+
*.pyo
|
|
354
|
+
.venv/
|
|
355
|
+
venv/
|
|
356
|
+
.env/
|
|
357
|
+
env/
|
|
358
|
+
*.egg-info/
|
|
359
|
+
|
|
360
|
+
# Rust
|
|
361
|
+
target/
|
|
362
|
+
|
|
363
|
+
# Java / Kotlin / Scala
|
|
364
|
+
*.class
|
|
365
|
+
.gradle/
|
|
366
|
+
.mvn/
|
|
367
|
+
|
|
368
|
+
# C# / .NET
|
|
369
|
+
bin/
|
|
370
|
+
obj/
|
|
371
|
+
packages/
|
|
372
|
+
|
|
373
|
+
# Go
|
|
374
|
+
vendor/
|
|
375
|
+
|
|
376
|
+
# Dart
|
|
377
|
+
.dart_tool/
|
|
378
|
+
build/
|
|
379
|
+
|
|
380
|
+
# PHP
|
|
381
|
+
vendor/
|
|
382
|
+
|
|
383
|
+
# IDE / OS
|
|
384
|
+
.idea/
|
|
385
|
+
.vscode/
|
|
386
|
+
*.swp
|
|
387
|
+
*.swo
|
|
388
|
+
.DS_Store
|
|
389
|
+
Thumbs.db
|
|
390
|
+
|
|
391
|
+
# Type definitions (often noise in queries)
|
|
392
|
+
*.d.ts
|
|
393
|
+
`;function rl(e,t,n){let r=wT(t,n);if(!r)return!1;try{return e.ignores(r)}catch{return!1}}function wT(e,t){if(!t||t===".")return null;if(!eg(t)&&!t.startsWith(".."))return t.replaceAll("\\","/");let n=eg(t)?t:vT(e,t),r=xT(e,n).replaceAll("\\","/");return!r||r==="."||r.startsWith("..")?null:r}import{execFileSync as CT}from"child_process";import{existsSync as FT,readdirSync as ng}from"fs";import{extname as rg,join as ig}from"path";var og=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),TT=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function ps(e){let t=[],n=NT(e),r=DT(e);for(let i of TT){if(_T(e,i.files)){t.push(i.language);continue}if(kT(n,i.globs)){t.push(i.language);continue}OT(r,i.extensions)&&t.push(i.language)}if(t.includes("typescript")&&il(t,"javascript"),t.includes("cpp")&&t.includes("c")){let i=r.has(".c"),o=[".cc",".cpp",".cxx"].some(s=>r.has(s));i&&!o?il(t,"cpp"):i||il(t,"c")}return t}function NT(e){try{return ng(e)}catch{return[]}}function _T(e,t){return t?.length?t.some(n=>FT(ig(e,n))):!1}function kT(e,t){return t?.length?e.some(n=>t.some(r=>LT(n,r))):!1}function LT(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function DT(e){let t=AT(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=ng(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=ig(i,s.name);if(s.isDirectory()){og.has(s.name)||r.push(a);continue}let c=rg(s.name).toLowerCase();c&&n.add(c)}}return n}function AT(e){try{let t=Hi(e,26214400,()=>CT("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),n=new Set;for(let r of Wi(t)){if(r.split("/").some(o=>og.has(o)))continue;let i=rg(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function OT(e,t){return t?.length?t.some(n=>e.has(n)):!1}function il(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import MT from"better-sqlite3";var jT=25,BT=new Set(["typescript","javascript"]);function xH(e,t,n){let r=null;try{r=new MT(e,{readonly:!0,fileMustExist:!0});let i=new Set(r.prepare("SELECT relative_path FROM documents").pluck().all().map(Vt)),o=$T(t,n),s=new Set([...o.values()].flatMap(u=>[...u])),a=[...s].filter(u=>!i.has(u)).sort();if(a.length===0)return{state:"complete",expectedDocumentCount:s.size,actualDocumentCount:i.size};let c=new Set(a),l=n.filter(u=>[...o.get(u)??[]].some(d=>c.has(d)));return{state:"incomplete",expectedDocumentCount:s.size,actualDocumentCount:i.size,missingDocumentCount:a.length,missingPaths:a.slice(0,jT),affectedLanguages:l}}catch(i){return{state:"unavailable",reason:i instanceof Error?i.message:String(i)}}finally{r?.close()}}function $T(e,t){let n=new Map,r=t.filter(i=>BT.has(i));for(let i of r)n.set(i,new Set);for(let i of e.files){let o=Vt(i.path);for(let s of r)jt(o,[s])==="source"&&n.get(s).add(o)}return n}import{existsSync as ag,readdirSync as cg,rmSync as lg}from"fs";import{join as yr}from"path";import{create as dg,fromBinary as pg,toBinary as NH}from"@bufbuild/protobuf";import{deserializeSCIP as ol,DocumentSchema as fg,IndexSchema as mg,serializeSCIP as gg}from"@c4312/scip";import{existsSync as GT,mkdirSync as VT,renameSync as HT,writeFileSync as WT}from"fs";import{join as qT}from"path";function sg(e){VT(e.blobDir,{recursive:!0});let t=qT(e.blobDir,`${e.blobHash}.scipdoc`);if(GT(t)){let r=ee(t,{maxBytes:un,inputKind:e.inputKind});if(r.byteLength!==e.bytes.byteLength||U(r)!==e.blobHash)throw new Error(`existing ${e.inputKind} is corrupt: ${e.relativePath}`);return}let n=`${t}.${process.pid}.${Date.now()}.tmp`;WT(n,e.bytes),HT(n,t)}var sl=1,pi="typescript-scip-fragments";function DH(e){let t=new Set,n=[];for(let o of e){let s=fs(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=pg(fg,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);n.push(a)}let r=gg(dg(mg,{documents:n,externalSymbols:[]})),i=ol(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function UT(e){let t=yr(e,pi);return{rootDir:t,blobDir:yr(t,"blobs"),generationDir:yr(t,"generations")}}function yg(e){let t=zT(e);return KT(t.baseIndex,t.completeDocuments,"assembled")}function zT(e){let t=ol(e.baseIndexBytes);QT(t.metadata,ZT(e)),YT(t.externalSymbols);let n=new Map;for(let a of e.fragments){let c=fs(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);n.set(c,a)}if(n.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let r=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=fs(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let l=n.get(c);if(!l){i.push(a);continue}if(n.delete(c),l.bytes===null){s.push(c);continue}let u=ug(c,l.bytes);i.push(u),o.push(u)}for(let a of[...n.keys()].sort()){let c=n.get(a);if(c.bytes===null)continue;if(r.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);r.add(a);let l=ug(a,c.bytes);i.push(l),o.push(l)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function ug(e,t){let n=pg(fg,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function KT(e,t,n){let r=gg(dg(mg,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=ol(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function AH(e,t){let n=UT(e);if(!ag(n.generationDir))return;let r=new Set(t.map(s=>XT(s))),i=cg(n.generationDir).filter(s=>s.endsWith(".json")),o=new Set;for(let s of i.filter(a=>r.has(a))){let a=JT(j(yr(n.generationDir,s),{maxBytes:ne,inputKind:"TypeScript fragment manifest"}));for(let c of a.documents)o.add(`${c.blobHash}.scipdoc`)}for(let s of i)r.has(s)||lg(yr(n.generationDir,s),{force:!0});if(ag(n.blobDir))for(let s of cg(n.blobDir))o.has(s)||lg(yr(n.blobDir,s),{force:!0})}function JT(e){let t=JSON.parse(e);if(t.version!==sl||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let n=new Set;for(let r of t.documents){if(!r||typeof r.relativePath!="string"||typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash)||typeof r.byteLength!="number"||!Number.isInteger(r.byteLength)||r.byteLength<0||typeof r.documentIdentity!="string"||!r.documentIdentity)throw new Error("invalid TypeScript fragment record");if(fs(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function XT(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${U(e)}.json`}function YT(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function QT(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function ZT(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function fs(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}import{existsSync as ms,readdirSync as al,rmSync as hg}from"fs";import{join as lt}from"path";var gs=1,fi="typescript-scip-overlays",Sg="typescript-project-v3:";function WH(e){let t=xg(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let n=e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(Sg)&&e.projectIdentity.startsWith(Sg);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!n)throw new Error("TypeScript overlay project identity changed");let r=new Map((t?.overlays??[]).map(s=>[s.relativePath,s])),i=new Set;for(let s of e.fragments){let a=ul(s.relativePath);if(i.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);i.add(a),r.set(a,eN(e.cacheDir,s))}if(i.size===0)throw new Error("TypeScript overlay generation requires affected documents");let o={version:gs,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((s,a)=>s.relativePath.localeCompare(a.relativePath))};return tN(e.cacheDir,o),o}function qH(e){let t=xg(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=ee(lt(mi(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`),{maxBytes:un,inputKind:"TypeScript overlay blob"});if(i.byteLength!==r.byteLength||U(i)!==r.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${r.relativePath}`);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return yg({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function UH(e,t){let n=mi(e),r=lt(n,"generations");if(!ms(r))return;let i=new Set(t.map(ll)),o=new Set;for(let a of al(r).filter(c=>i.has(c))){let c=cl(j(lt(r,a),{maxBytes:ne,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of al(r))i.has(a)||hg(lt(r,a),{force:!0});let s=lt(n,"blobs");if(ms(s))for(let a of al(s))o.has(a)||hg(lt(s,a),{force:!0})}function xg(e,t){let n=lt(mi(e),"generations",ll(t));if(!ms(n))return null;let r=cl(j(n,{maxBytes:ne,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function eN(e,t){let n=ul(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=U(r);return sg({blobDir:lt(mi(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function tN(e,t){let n=lt(mi(e),"generations",ll(t.generationIdentity));if(ms(n)){let r=cl(j(n,{maxBytes:ne,inputKind:"TypeScript overlay manifest"}));if(bg(r)!==bg(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}Qt(n,t,{spacing:2,trailingNewline:!0})}function cl(e){let t=JSON.parse(e);if(t.version!==gs||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let n=new Set;for(let r of t.overlays){if(!r||typeof r.relativePath!="string"||r.blobHash!==null&&(typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash))||!Number.isInteger(r.byteLength)||r.byteLength<0||r.blobHash===null&&r.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(ul(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function mi(e){return lt(e,fi)}function ll(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${U(e)}.json`}function bg(e){return U(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function ul(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{closeSync as Ig,openSync as aN,renameSync as cN,rmSync as lN,writeSync as uN}from"fs";import{create as Eg,fromBinary as dN,toBinary as pN}from"@bufbuild/protobuf";import{DocumentSchema as pl,IndexSchema as fN,SymbolRole as ml}from"@c4312/scip";var Ue=class extends Error{},nN=0,rN=1,vg=2,iN=5;function dl(e,t,n){let r=0,i=0;for(;t<n;){let o=e[t];if(t+=1,i<53)r+=(o&127)*2**i;else if((o&127)!==0)throw new Ue("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new Ue("varint is longer than 64 bits")}throw new Ue("varint runs past the end of the buffer")}function*Ze(e,t=0,n=e.length){let r=t;for(;r<n;){let i=r,o=dl(e,r,n);r=o.pos;let s=Math.floor(o.value/8),a=o.value%8;if(s===0)throw new Ue("field number 0 is invalid");let c=r,l=0;if(a===nN){let u=dl(e,r,n);l=u.value,r=u.pos}else if(a===vg){let u=dl(e,r,n);if(c=u.pos,r=u.pos+u.value,r>n)throw new Ue("length-delimited field runs past the end of the buffer")}else if(a===rN)r+=8;else if(a===iN)r+=4;else throw new Ue(`unsupported wire type ${a}`);if(r>n)throw new Ue("field value runs past the end of the buffer");yield{fieldNumber:s,wireType:a,fieldStart:i,valueStart:c,valueEnd:r,fieldEnd:r,varint:l}}}function gi(e){if(!Number.isSafeInteger(e)||e<0)throw new Ue(`cannot encode varint ${e}`);let t=[],n=e;do{let r=n%128;n=Math.floor(n/128),n>0&&(r|=128),t.push(r)}while(n>0);return Uint8Array.from(t)}function ys(e){return gi(e*8+vg)}var oN=1,sN=3;function yi(e){let t=new TextDecoder,n;for(let r of Ze(e))if(!(r.fieldNumber!==oN||r.wireType!==2))for(let i of Ze(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==sN||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}var fl=2,mN=3,gN=1,yN=2,hN=3,SN=1,bN=2,xN=3;function tW(e){let t;try{t=ee(e,{inputKind:"SCIP sanitization input",maxBytes:ae})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return vN(t,e)}catch(n){if(n instanceof Ue)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function vN(e,t){let n=new TextDecoder,r=new Set;for(let s of Ze(e))if(s.wireType===2)if(s.fieldNumber===fl)for(let a of Ze(e,s.valueStart,s.valueEnd))a.wireType===2&&(a.fieldNumber===gN?Ie(n.decode(e.subarray(a.valueStart,a.valueEnd))):a.fieldNumber===hN&&Rg(e,a,n,r));else s.fieldNumber===mN&&Rg(e,s,n,r);let i=0,o=[];for(let s of Ze(e)){if(s.wireType!==2||s.fieldNumber!==fl)continue;let a=IN(e,s,n,r);a>0&&(i+=a,o.push(s))}return i===0?{removedDefinitionOccurrences:0,touchedDocuments:0}:(EN(e,t,o,r),{removedDefinitionOccurrences:i,touchedDocuments:o.length})}function Rg(e,t,n,r){for(let i of Ze(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==SN)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function IN(e,t,n,r){let i=0;for(let o of Ze(e,t.valueStart,t.valueEnd)){if(o.wireType!==2||o.fieldNumber!==yN)continue;let s="",a=0;for(let c of Ze(e,o.valueStart,o.valueEnd))c.fieldNumber===bN&&c.wireType===2?s=n.decode(e.subarray(c.valueStart,c.valueEnd)):c.fieldNumber===xN&&c.wireType===0&&(a=c.varint);(a&ml.Definition)!==0&&!r.has(s)&&(i+=1)}return i}function EN(e,t,n,r){let i=`${t}.sanitize-tmp`,o=aN(i,"w",384);try{let s=0;for(let a of n){hi(o,e.subarray(s,a.fieldStart));let c=dN(pl,e.subarray(a.valueStart,a.valueEnd));c.occurrences=c.occurrences.filter(u=>(u.symbolRoles&ml.Definition)===0||r.has(u.symbol));let l=pN(pl,c);hi(o,ys(fl)),hi(o,gi(l.byteLength)),hi(o,l),s=a.fieldEnd}hi(o,e.subarray(s))}catch(s){throw Ig(o),lN(i,{force:!0}),s}Ig(o),cN(i,t)}function hi(e,t){let n=0;for(;n<t.byteLength;)n+=uN(e,t,n,t.byteLength-n)}function Pg(e){let t=new Set;for(let o of e.documents){Ie(o.relativePath);for(let s of o.symbols)s.symbol&&t.add(s.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&ml.Definition)===0||t.has(a.symbol)?!0:(n+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(Eg(pl,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:Eg(fN,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}import{closeSync as bi,openSync as gl,readSync as RN,renameSync as PN,rmSync as Fg,statSync as wN,writeFileSync as Tg,writeSync as Ng}from"fs";import{create as yl,fromBinary as CN,toBinary as FN}from"@bufbuild/protobuf";import{deserializeSCIP as _g,serializeSCIP as kg,DocumentSchema as TN,IndexSchema as NN,MetadataSchema as wg,SymbolInformationSchema as _N}from"@c4312/scip";function Lg(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=kN(e),n=LN(e.flatMap(i=>i.documents??[])),r=Ag(e.flatMap(i=>i.externalSymbols??[]));return yl(NN,{metadata:t,documents:n,externalSymbols:r})}function uW(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>_g(ee(i,{inputKind:"SCIP merge input",maxBytes:ae}))),r=Lg(n);return Tg(t,kg(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function dW(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=wN(o).size,n>ae)throw new Error(`Concatenated SCIP output exceeds the ${ae}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=gl(t,"w",384);try{for(let o of e){let s=gl(o,"r");try{let a=0;for(;(a=RN(s,r,0,r.byteLength,null))>0;){let c=0;for(;c<a;)c+=Ng(i,r,c,a-c)}}finally{bi(s)}}}catch(o){throw bi(i),Fg(t,{force:!0}),o}bi(i)}function pW(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=z("reindex.publish.scip-output.deserialize",()=>e.map(o=>_g(ee(o,{inputKind:"SCIP merge input",maxBytes:ae})))),r=z("reindex.publish.scip-output.merge",()=>Lg(n)),i=z("reindex.publish.scip-output.sanitize",()=>Pg(r));return z("reindex.publish.scip-output.serialize",()=>Tg(t,kg(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,touchedDocuments:i.touchedDocuments}}var Cg=1;function Dg(e,t,n){let r=ee(e,{inputKind:"SCIP normalization input",maxBytes:ae}),i=yi(r),o=[];for(let c of Ze(r))c.fieldNumber===Cg&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let s=`${e}.rebase-tmp`,a=gl(s,"w",384);try{let c=0;for(let l of o){Si(a,r.subarray(c,l.fieldStart));let u=CN(wg,r.subarray(l.valueStart,l.valueEnd));u.projectRoot=n;let d=FN(wg,u);Si(a,ys(Cg)),Si(a,gi(d.byteLength)),Si(a,d),c=l.fieldEnd}Si(a,r.subarray(c))}catch(c){throw bi(a),Fg(s,{force:!0}),c}bi(a),PN(s,e)}function Si(e,t){let n=0;for(;n<t.byteLength;)n+=Ng(e,t,n,t.byteLength-n)}function kN(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function LN(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,yl(TN,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:DN([...r.occurrences,...n.occurrences]),symbols:Ag([...r.symbols,...n.symbols]),text:ON(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function DN(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function Ag(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,yl(_N,{symbol:r.symbol,documentation:MN([...r.documentation,...n.documentation]),relationships:AN([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function AN(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function ON(e,t){return e?t?e.length>=t.length?e:t:e:t}function MN(e){return[...new Set(e)]}import{createHash as El}from"crypto";import{closeSync as jN,existsSync as O,mkdirSync as BN,openSync as $N,readSync as GN,readdirSync as Rl,renameSync as xl,rmSync as xi,statSync as kn}from"fs";import{basename as Pl,dirname as ut,join as _,relative as Og}from"path";var vl=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function jg(e){let t=X(e.outputDb),n=UN(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=zN(e,n),o=Cl({generationRoot:t,databasePath:e.tempOutputDb,indexPath:O(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:O(e.tempMetaPath)?e.tempMetaPath:void 0}),s=(e.now??(()=>new Date))().toISOString(),a={version:_n,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:s},c=Le(_(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||bl(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),bl(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),bl(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let l=o.identity,u={...a,stableMirrors:wl(e.outputDb,e.outputScip)};Le(_(t,"state.json"),u,{spacing:2,trailingNewline:!0});let d=Bg(e.outputDb,{now:e.now}),p=W(o.directorySync,c.directorySync);return{currentGeneration:l,...n?{previousGeneration:n}:{},retention:d,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function VN(e,t,n,r=()=>new Date){if(!O(e))return null;let i=Zt(e),o=_(X(e),"state.json");if(i?.artifactSet==="immutable-v1"&&ui(e,i.currentGeneration))return i;let s=X(e),a=!i&&O(o)?JN(n,e,t):void 0;if(a&&!di(s,a))return null;let c=Cl({generationRoot:s,databasePath:e,indexPath:O(t)?t:void 0,metadataPath:O(n)?n:void 0,forcedIdentity:i?.currentGeneration??a}),l={version:_n,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:wl(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??r().toISOString()};return Le(_(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function RW(e,t,n=()=>new Date){if(!O(e)||!O(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=Zt(e),i=X(e),o=Cl({generationRoot:i,databasePath:e,indexPath:O(_(ut(e),"index.scip"))?_(ut(e),"index.scip"):void 0,metadataPath:t}),s=r&&r.currentGeneration!==o.identity?Vg(e,r.currentGeneration):void 0,a={version:_n,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:wl(e,_(ut(e),"index.scip")),...s?{previousGeneration:s}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return Le(_(X(e),"state.json"),a,{spacing:2,trailingNewline:!0}),Bg(e,{now:n}),a}function Bg(e,t={}){let n=HN(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=kt(us(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:"another process owns local generation retention"};try{let s=Zt(e),a=$g(e),c=Zc(e,a.map(m=>m.identity),{isProcessAlive:t.isProcessAlive??Nn,readProcessIdentity:t.readProcessIdentity??Nt}),l=new Set(c.protectedGenerations);s?.currentGeneration&&l.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&l.add(s.previousGeneration.generationIdentity);let u=a.length,d=a.reduce((m,S)=>m+S.logicalBytes,0),p=0,f=0;for(let m of a){if(u<=n.maxGenerations&&d<=n.maxLogicalBytes)break;l.has(m.identity)||(t.onBeforeRemove?.(m.identity),xi(m.path,{recursive:!0,force:!0}),u-=1,d-=m.logicalBytes,p+=1,f+=m.logicalBytes)}let g=u>n.maxGenerations||d>n.maxLogicalBytes,y={state:g?"protected":p>0?"collected":"within-bounds",generationCount:u,logicalBytes:d,protectedGenerations:l.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:p,removedLogicalBytes:f,limits:n,at:i,...g?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Mg(e,y),y}catch(s){let a={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:s instanceof Error?s.message:String(s)};try{Mg(e,a)}catch{}return a}finally{o.release()}}function PW(e){let t=X(e);if(!O(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...vl},reason:"local immutable generation store does not exist"};let n=WN(e),r=n?.limits??{...vl},i=kt(us(e),{waitMs:0});if(!i)return{state:"deferred",generationCount:n?.generationCount??0,logicalBytes:n?.logicalBytes??0,protectedGenerations:n?.protectedGenerations??0,activeReaderLeases:n?.activeReaderLeases??0,malformedReaderLeases:n?.malformedReaderLeases??0,limits:r,...n?{lastCollection:n}:{},reason:"another process owns local generation retention"};try{let o=$g(e),s=Zt(e),a=Zc(e,o.map(l=>l.identity),{isProcessAlive:Nn,readProcessIdentity:Nt},{removeStale:!1}),c=new Set(a.protectedGenerations);return s?.currentGeneration&&c.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&c.add(s.previousGeneration.generationIdentity),{state:"managed",generationCount:o.length,logicalBytes:o.reduce((l,u)=>l+u.logicalBytes,0),...o[0]?{oldestGenerationAt:new Date(o[0].modifiedAtMs).toISOString()}:{},protectedGenerations:c.size,activeReaderLeases:a.activeLeases,malformedReaderLeases:a.malformedLeases,limits:r,...n?{lastCollection:n}:{},...a.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:r,...n?{lastCollection:n}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function HN(e={}){let t={...vl,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function $g(e){let t=X(e);return O(t)?Rl(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=_(t,n.name),i=di(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Gg(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:kn(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function Gg(e){let t=0;for(let n of Rl(e,{withFileTypes:!0})){let r=_(e,n.name);n.isDirectory()?t+=Gg(r):n.isFile()&&(t+=kn(r).size)}return t}function Mg(e,t){Qt(_(X(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function WN(e){try{let t=JSON.parse(T(_(X(e),"gc.json"),"local SQLite generation GC status"));return!t||t.state!=="within-bounds"&&t.state!=="collected"&&t.state!=="protected"&&t.state!=="deferred"&&t.state!=="error"||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function Ss(e,t=_(ut(e),"meta.json")){let n=_(X(e),"state.json");if(!O(n))return{state:"legacy",statePath:n};let r=Zt(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=ui(e,r.currentGeneration),o=i!==null,s=i?qN(e,t,i,r):!1,a=r.previousGeneration?O(_(ut(e),r.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:n,currentMatches:s,recoveryExists:a,generation:r,reason:o?s?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:n,currentMatches:s,recoveryExists:a,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function qN(e,t,n,r){if(r.stableMirrors&&(r.stableMirrors.databaseFileIdentity!==Lt(e)||r.stableMirrors.indexFileIdentity!==void 0&&r.stableMirrors.indexFileIdentity!==Lt(_(ut(e),"index.scip")))||!Il(e,n.database))return!1;let i=_(ut(e),"index.scip");if(n.index&&!Il(i,n.index))return!1;if(!n.metadata)return!O(t);if(!O(t))return!1;let o=_(X(e),n.identity,n.metadata.file);return O(o)&&en(T(t,"reindex metadata"))===en(T(o,"immutable reindex metadata"))}function Il(e,t){return O(e)&&kn(e).isFile()&&kn(e).size===t.size}function UN(e){let t=VN(e.outputDb,e.outputScip,e.metaPath);return t?Vg(e.outputDb,t.currentGeneration):void 0}function zN(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=Ss(e.outputDb,e.metaPath);if(n.state!=="current"||n.generation.currentGeneration!==t.generationIdentity){let i=n.state==="current"?"generation identity changed":"reason"in n?n.reason:`generation state is ${n.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let r=ui(e.outputDb,t.generationIdentity);if(!r?.index||!Il(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function wl(e,t){return{databaseFileIdentity:Lt(e),...O(t)?{indexFileIdentity:Lt(t)}:{}}}function Vg(e,t){let n=_(X(e),t),r=_(n,Pl(e)),i=_(n,"meta.json");return{generationIdentity:t,databasePath:Og(ut(e),r),...O(i)?{metadataPath:Og(ut(e),i)}:{}}}function KN(e){if(O(e))for(let t of Rl(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&xi(_(e,t.name),{recursive:!0,force:!0})}function JN(e,t,n=_(ut(t),"index.scip")){let r=El("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(hs(t)),O(n)&&r.update(`\0${hs(n)}`),O(e)&&r.update(`\0${en(T(e,"reindex metadata"))}`),r.digest("hex")}function Cl(e){let t=hl(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?YN(e.indexPath,e.verifiedIndexArtifact):hl(e.indexPath):void 0,r=e.metadataPath?hl(e.metadataPath):void 0,i=e.forcedIdentity??XN(t,n,e.metadataPath),o=_(e.generationRoot,i),s=_(o,ls);if(O(s)){let l=di(e.generationRoot,i);if(l&&Hg(o,l.database,t)&&ZN(o,l.index,n)&&e_(o,l.metadata,e.metadataPath))return{identity:i,directorySync:D(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let a=[me(e.generationRoot)];KN(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;xi(c,{recursive:!0,force:!0}),BN(c,{recursive:!0});try{a.push(Sl(e.databasePath,_(c,t.file))),n&&e.indexPath&&a.push(Sl(e.indexPath,_(c,n.file))),r&&e.metadataPath&&a.push(Sl(e.metadataPath,_(c,r.file)));let l=Le(_(c,ls),{version:Qc,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&a.push(l.directorySync),a.push(D(c)),xl(c,o),a.push(D(e.generationRoot))}finally{xi(c,{recursive:!0,force:!0})}return{identity:i,directorySync:W(...a)}}function XN(e,t,n){let r=El("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${en(T(n,"reindex metadata"))}`),r.digest("hex")}function hl(e){return{file:Pl(e),size:kn(e).size,sha256:hs(e)}}function YN(e,t){if(t.file!==Pl(e)||kn(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function hs(e){let t=El("sha256"),n=$N(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=QN(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{jN(n)}return t.digest("hex")}function QN(e,t){let n=0;for(;n<t.length;){let r=GN(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function Sl(e,t){return ii(e,t,{mode:292})}function Hg(e,t,n){let r=_(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&O(r)&&kn(r).size===t.size&&hs(r)===t.sha256}function ZN(e,t,n){return!t||!n?t===n:Hg(e,t,n)}function e_(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=_(e,t.file);return O(r)&&en(T(r,"stored reindex metadata"))===en(T(n,"candidate reindex metadata"))}function bl(e,t){xi(`${t}.tmp-replace`,{force:!0}),xl(e,`${t}.tmp-replace`),xl(`${t}.tmp-replace`,t)}import{createHash as ey,randomUUID as a_}from"crypto";import{existsSync as pt,lstatSync as Nl,mkdirSync as hr,mkdtempSync as ty,readdirSync as ny,realpathSync as ry,renameSync as Ln,rmSync as tn,statSync as Es}from"fs";import{dirname as _l,join as R,resolve as Dt}from"path";import{setTimeout as c_}from"timers/promises";import{pathToFileURL as zg}from"url";import l_ from"better-sqlite3";import{lstatSync as t_,readdirSync as n_}from"fs";import{join as r_,relative as i_,resolve as Fl,sep as o_}from"path";var vi=1,Tl="language-indexes",Wg=["index.db","index.scip","meta.json"],qg=[Tl,pi,fi];function bs(e){let t=[];for(let n of Wg)s_(e,n),t.push(n);for(let n of qg)Ug(e,n,t);return{version:vi,files:t.sort()}}function xs(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!Wg.includes(e)&&!qg.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function dt(e,t){let n=xs(t),r=Fl(e),i=Fl(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${o_}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Ug(e,t,n){let r=r_(e,t),i;try{i=n_(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?Ug(e,s,n):o.isFile()&&n.push(xs(s))}}function s_(e,t){let n=dt(e,t),r;try{r=t_(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(i_(Fl(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Ll=1,Kg="SCIP_QUERY_SHARED_CACHE",u_=2,vs=JSON.stringify({cliVersion:qi,artifactCatalogVersion:vi,postIndexAugmentationSchemaVersion:u_,sqliteGenerationStoreVersion:_n,typescriptFragmentStoreVersion:sl,typescriptOverlayStoreVersion:gs}),Dl="manifest.json",iy="shared-cache.json",d_=6e4,Al=[Tl,pi,fi];function Is(e,t){if(!e.clean||!e.treeOid)return;let n=uy(JSON.stringify({version:Ll,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:Ui(t),producerIdentity:vs}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:vs,generationId:n,repositoryCacheDir:lo(e.repositoryId)}}function rq(e,t,n){if(!E_(n))return!1;let r=Is(e,n);if(!r)return!1;try{let i=cy(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(j(R(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:ne}));return o.version!==1||o.repositoryId!==i.repositoryId||o.worktreeId!==i.worktreeId||Dt(o.projectRoot)!==Dt(e.projectRoot)||o.treeOid!==e.treeOid||Dt(o.localCacheDir)!==Dt(t)||o.ownershipChecksum!==Rs(o)||o.baseGenerationId!==r.generationId||o.activeGenerationId!==r.generationId?!1:At(r,!1)!==null}catch{return!1}}function oy(e,t,n){if(process.env[Kg]==="0")return`${Kg}=0`;if(!Ia(n))return"explicit cache or database override";if(Ra(_l(t))!==Ra(co(e))||t!==R(_l(t),"index.db"))return"index database is outside the managed worktree cache"}function iq(e,t,n){if(!Ia(t))return;let r=n??Fr(e);return r?R(lo(r.repositoryId),"evidence.db"):void 0}function At(e,t=!0){let n=Ol(e),r;try{r=ay(j(R(n,Dl),{inputKind:"shared-generation manifest",maxBytes:ne}))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||!Pr(r.fingerprint,e.fingerprint)||!h_(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=dt(n,i.path),s=Es(o);if(!s.isFile()||s.size!==i.size||dn(o,{inputKind:"shared-generation artifact",maxBytes:ae})!==i.sha256)return null}}catch{return null}return r}function Jg(e,t,n,r){if(!e.treeOid)return null;let i=Jn(t,n),o=R(ao(),"repositories",e.repositoryId),s;try{let l=Nl(o);if(!l.isDirectory()||l.isSymbolicLink())return null;s=ry(o)}catch{return null}let a=R(s,"generations"),c=[];try{for(let l of ny(a)){if(!/^[a-f0-9]{64}$/.test(l))continue;let u=R(a,l),d;try{d=Nl(u)}catch{continue}if(!(!d.isDirectory()||d.isSymbolicLink()))try{let p=ay(j(R(u,Dl),{inputKind:"shared-generation baseline manifest",maxBytes:ne}));p.generationId===l&&p.repositoryId===e.repositoryId&&p.producerIdentity===vs&&S_(p.fingerprint,i)&&c.push(p)}catch{continue}}}catch{return null}c.sort((l,u)=>{let d=l.treeOid===e.treeOid?0:1,p=u.treeOid===e.treeOid?0:1;if(d!==p)return d-p;if(r){let g=Zg(l.fingerprint,r)-Zg(u.fingerprint,r);if(g!==0)return g}return Date.parse(u.createdAt)-Date.parse(l.createdAt)||l.generationId.localeCompare(u.generationId)});for(let l of c){let u={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:l.treeOid,fingerprint:l.fingerprint,producerIdentity:l.producerIdentity,generationId:l.generationId,repositoryCacheDir:s},d=At(u);if(d)return{snapshot:u,manifest:d}}return null}function sy(e){let t=kt(R(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return p_(e)}finally{t.release()}}function p_(e){let t=At(e.snapshot);if(t)return Xg(e.snapshot,t);if(!wi(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=Qg(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=bs(e.sourceCacheDir),i=R(e.snapshot.repositoryCacheDir,"generations"),o=[me(i)],s=ty(R(i,`.tmp-${process.pid}-`));try{let a=[];for(let g of r.files){let y=dt(e.sourceCacheDir,g),m=dt(s,g);o.push(Ci(y,m,292)),e.onPublicationStage?.("after-artifact-flushed",g);let S=Es(m).size;a.push({path:g,size:S,sha256:dn(m,{inputKind:"staged shared-generation artifact",maxBytes:ae})})}let c=yi(ee(R(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:ae}));if(!c)throw new Error("shared SCIP generation has no project root metadata");let l=jl(e.sourceProjectRoot);if(c!==l)throw new Error("shared SCIP generation root does not match its source worktree");if(Qg(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:Ll,artifactCatalogVersion:vi,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((g,y)=>g.path.localeCompare(y.path))},d=Le(R(s,Dl),u,{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&o.push(d.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(D(s)),e.onPublicationStage?.("after-staging-directory-synced");let p=Ol(e.snapshot);try{if(pt(p)&&!At(e.snapshot)){let g=`${p}.corrupt-${process.pid}-${Date.now()}`;Ln(p,g),tn(g,{recursive:!0,force:!0})}Ln(s,p)}catch(g){let y=At(e.snapshot);if(y)return Xg(e.snapshot,y);throw g}e.onPublicationStage?.("after-generation-renamed"),o.push(D(i)),e.onPublicationStage?.("after-generations-directory-synced");let f=W(...o);return{kind:"published",manifest:u,achievedDurability:f==="synced"?"directory-durable":"file-flushed",directorySync:f}}finally{tn(s,{recursive:!0,force:!0})}}function Xg(e,t){let n=D(R(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Ei(e){let t=Ol(e.snapshot);hr(e.targetCacheDir,{recursive:!0});let n=kt(R(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{r=ty(R(e.targetCacheDir,".shared-hydrate-")),I_(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=dt(t,c.path),u=dt(r,c.path);if(Ci(l,u),Es(u).size!==c.size||dn(u,{inputKind:"hydrated shared-generation artifact",maxBytes:ae})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=jl(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Dg(dt(r,c.path),e.manifest.scipProjectRoot,s);if(!wi(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=b_(e.targetCacheDir,r),o=!0,x_(r,e.targetCacheDir,i),jg({tempOutputScip:R(r,"index.scip"),tempOutputDb:R(r,"index.db"),tempMetaPath:R(r,"meta.json"),outputScip:R(e.targetCacheDir,"index.scip"),outputDb:R(e.targetCacheDir,"index.db"),metaPath:R(e.targetCacheDir,"meta.json"),now:e.now});let a=Ss(R(e.targetCacheDir,"index.db"),R(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);e.persistLease!==!1&&kl(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&v_(e.targetCacheDir,i),s}finally{r&&tn(r,{recursive:!0,force:!0}),n.release()}}function oq(e,t,n,r){let i=oy(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??Fr(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean){if(pt(n.dbPath))return Pi(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let d=t.languages??ps(e),p=Kn(e,d,Ri(t)),f=Jg(o,d,Ri(t),p);return f?(Ei({snapshot:f.snapshot,manifest:f.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),Yg(f.snapshot,n.cacheDir),{kind:"overlay"}):(Pi(o,n.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"})}let s=t.languages??ps(e),a=Kn(e,s,Ri(t)),c=Is(o,a);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let l=At(c);if(l)return Ei({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let u=g_(c,e);if(!u){if(!pt(n.dbPath)){let d=Jg(o,s,Ri(t),a);if(d)return Ei({snapshot:d.snapshot,manifest:d.manifest,targetCacheDir:n.cacheDir,targetProjectRoot:e,persistLease:!1,lockWaitMs:0}),Yg(d.snapshot,n.cacheDir),{kind:"overlay"}}return Pi(o,n.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"}}return l=u.manifest,Ei({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:u.sourceProjectRoot}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function sq(e,t,n,r){let i=oy(e,n.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=r??Fr(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return Pi(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let s=t.languages??ps(e),a=Kn(e,s,Ri(t)),c=Is(o,a);if(!c)return Pi(o,n.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let l=At(c);if(l)return wi(n.cacheDir,e,a)?(kl(c,n.cacheDir,"local-fresh"),{kind:"local-fresh"}):(Ei({snapshot:c,manifest:l,targetCacheDir:n.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let u=Ps(n.cacheDir);return!u||!Pr(Rr(u.fingerprint),a)||JSON.stringify([...u.indexedLanguages??[]].sort())!==JSON.stringify([...s].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:wi(n.cacheDir,e,a)?(sy({snapshot:c,sourceCacheDir:n.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let d=Fr(e);return(d?Is(d,a):void 0)?.generationId===c.generationId}}),kl(c,n.cacheDir,"built"),{kind:"built",generationId:c.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}async function aq(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??_t,o=i()+n,s=R(e.repositoryCacheDir,"locks"),a=R(s,`${e.generationId}.lock`),c=l=>{if(!l||typeof l!="object"||Array.isArray(l))return null;let u=l.pid;return typeof u=="number"&&Number.isSafeInteger(u)&&u>0?{pid:u}:null};for(;i()<=o;){if(At(e))return{kind:"generation-ready"};let l=as(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(l.kind==="acquired")return{kind:"owner",release:()=>l.lock.release()};let u=o-i();if(u<=0)break;await c_(Math.min(r,u))}return At(e)?{kind:"generation-ready"}:{kind:"timeout"}}function kl(e,t,n,r=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:n,lastSeenAt:(r??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:Rs(i)};return Ml(e.repositoryCacheDir,o,!0),o}function Yg(e,t,n=void 0){let r={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(n??(()=>new Date))().toISOString()},i={...r,ownershipChecksum:Rs(r)};return Ml(e.repositoryCacheDir,i,!0),i}function Pi(e,t,n,r=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:n,...i?{lastReason:i}:{},lastSeenAt:(r??(()=>new Date))().toISOString()},s={...o,ownershipChecksum:Rs(o)},a=lo(e.repositoryId),c=f_(a,s);return c||(Ml(a,s,!1),s)}function f_(e,t){try{let n=cy(t.localCacheDir);if(!n||n.repositoryId!==t.repositoryId||n.worktreeId!==t.worktreeId)return null;let r=JSON.parse(j(R(e,"worktrees",`${t.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:ne})),i=Date.parse(t.lastSeenAt)-Date.parse(r.lastSeenAt);return m_(r,t)&&Number.isFinite(i)&&i<d_?r:null}catch{return null}}function m_(e,t){return e.version===t.version&&e.repositoryId===t.repositoryId&&e.worktreeId===t.worktreeId&&e.projectRoot===t.projectRoot&&e.treeOid===t.treeOid&&e.localCacheDir===t.localCacheDir&&e.baseGenerationId===t.baseGenerationId&&e.activeGenerationId===t.activeGenerationId&&e.ownershipChecksum===t.ownershipChecksum&&e.lastAction===t.lastAction&&e.lastReason===t.lastReason}function Rs(e){return uy(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Dt(e.projectRoot),localCacheDir:Dt(e.localCacheDir)}))}function ay(e){let t=JSON.parse(e);if(t.version!==Ll||t.artifactCatalogVersion!==vi||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==vs||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(!r||typeof r.path!="string"||typeof r.size!="number"||r.size<0||typeof r.sha256!="string"||!/^[a-f0-9]{64}$/.test(r.sha256))throw new Error("invalid shared generation artifact");if(xs(r.path),n.has(r.path))throw new Error(`duplicate shared generation artifact: ${r.path}`);n.add(r.path)}for(let r of["index.db","index.scip","meta.json"])if(!n.has(r))throw new Error(`shared generation is missing ${r}`);return t}function Ci(e,t,n=384){return ii(e,t,{mode:n})}function g_(e,t){for(let n of ud(t)){if(Dt(n.path)===Dt(t))continue;let r=co(n.path),i=Ps(r);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&wi(r,n.path,e.fingerprint))try{return{manifest:sy({snapshot:e,sourceCacheDir:r,sourceProjectRoot:n.path}).manifest,sourceProjectRoot:n.path}}catch{continue}}return null}function y_(e,t,n){hr(e,{recursive:!0}),Le(R(e,iy),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function Qg(e){try{let t=bs(e),n=ey("sha256");for(let r of t.files){let i=dt(e,r),o=Es(i).size;n.update(r).update("\0").update(String(o)).update("\0"),Vn(i,{inputKind:"source-generation artifact",maxBytes:ae},s=>n.update(s)),n.update("\0")}return n.digest("hex")}catch{return null}}function Ps(e){try{let t=Bt(j(R(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:ne}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function h_(e){return Ps(e)?.scipCompanion!=="deferred"}function Ri(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function S_(e,t){let n=Jn(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function Zg(e,t){let n=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),r=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,s]of n)r.get(o)!==s&&(i+=1);for(let o of r.keys())n.has(o)||(i+=1);return i}function Ol(e){return R(e.repositoryCacheDir,"generations",e.generationId)}function cy(e){let t=JSON.parse(j(R(e,iy),{inputKind:"worktree cache pointer",maxBytes:ne}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function Ml(e,t,n){let r=Vm(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!pt(R(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=R(e,"worktrees");hr(i,{recursive:!0}),Le(R(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),y_(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function b_(e,t){let n=R(t,".rollback"),r=new Map,i=new Map;hr(n,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=R(e,a),l=pt(c);r.set(a,l),l&&Ci(c,R(n,"stable",a))}for(let a of Al){let c=R(e,a),l=pt(c);if(l){let u=Nl(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=R(e,li),s=pt(o);return s&&ly(o,R(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:s}}function x_(e,t,n){for(let r of Al){let i=R(t,r);if(n.managedDirectories.get(r)){let s=R(n.root,"managed",r);hr(_l(s),{recursive:!0}),Ln(i,s)}let o=R(e,r);pt(o)&&Ln(o,i)}}function v_(e,t){for(let i of Al){let o=R(e,i),s=R(t.root,"managed",i);t.managedDirectories.get(i)?pt(s)&&(tn(o,{recursive:!0,force:!0}),Ln(s,o)):tn(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=R(e,i);if(!o){tn(s,{force:!0});continue}let a=`${s}.shared-restore-${a_()}`;Ci(R(t.root,"stable",i),a),tn(s,{force:!0}),Ln(a,s)}let n=R(e,li);tn(n,{recursive:!0,force:!0});let r=R(t.root,"sqlite-generations");t.generationStoreExisted&&pt(r)&&Ln(r,n)}function ly(e,t){hr(t,{recursive:!0});for(let n of ny(e,{withFileTypes:!0})){let r=R(e,n.name),i=R(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?ly(r,i):n.isFile()&&Ci(r,i)}}function I_(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!Pr(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function wi(e,t,n,r=!0,i=!0){try{let o=Ps(e);if(!o||o.scipCompanion==="deferred"||!Pr(Rr(o.fingerprint),n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return Ii("source validation rejected metadata"),!1;let s=bs(e),a=Ss(R(e,"index.db"),R(e,"meta.json"));if(r?a.state!=="current":a.state==="invalid"||a.state==="drifted")return Ii(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new l_(R(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=jl(t),d=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let f=yi(ee(dt(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:ae}));return f!==l&&Ii(`source validation rejected SCIP root for ${p}: ${String(f)}`),f===l});return d||Ii("source validation rejected SCIP project roots"),d}catch(o){return Ii(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Ii(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function jl(e){try{return zg(ry(e)).href}catch{return zg(Dt(e)).href}}function E_(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(n=>n!==null&&typeof n=="object"&&typeof n.path=="string"&&typeof n.size=="number"&&typeof n.hash=="string"&&(n.semanticHash===void 0||typeof n.semanticHash=="string"))}function uy(e){return ey("sha256").update(e).digest("hex")}import{spawn as F_}from"child_process";import{platform as vy}from"os";import{performance as Iy}from"perf_hooks";import{execFileSync as fy}from"child_process";import{platform as R_}from"os";var my=1e3,gy=2*1024*1024,P_=25;function yy(e,t,n=xy){let r=n.readIdentity(e),i=new Map;return r&&i.set(e,r),{rootPid:e,rootIdentity:r,ownsProcessGroup:t,knownMembers:i}}async function hy(e,t,n=xy){if(!e.rootIdentity){let c=await Fi(e,t.gracefulMs+t.forceMs,n);return{reaped:c,reason:c?"terminated":"identity-unavailable",detail:c?void 0:`Could not establish the birth identity of process ${e.rootPid}.`}}let r=Sy(e,n);if(r==="mismatch")return{reaped:!1,reason:"identity-mismatch",detail:`Process ${e.rootPid} no longer has the identity owned by this runner.`};if(r==="exited"&&!by(e,n))return{reaped:!0,reason:"terminated"};if(n.platform==="win32"){try{n.terminateWindowsTree(e.rootPid)}catch(l){let u=await Fi(e,t.forceMs,n);return{reaped:u,reason:u?"terminated":"signal-failed",detail:u?void 0:Bl(l)}}let c=await Fi(e,t.forceMs,n);return{reaped:c,reason:c?"terminated":"deadline"}}let i=dy(e,"SIGTERM",n);if(await Fi(e,t.gracefulMs,n))return{reaped:!0,reason:"terminated"};let s=dy(e,"SIGKILL",n);return await Fi(e,t.forceMs,n)?{reaped:!0,reason:"terminated"}:s?{reaped:!1,reason:s.reason,detail:s.detail}:i?{reaped:!1,reason:i.reason,detail:i.detail}:{reaped:!1,reason:"deadline",detail:`Process tree ${e.rootPid} did not exit before its termination deadline.`}}function Sy(e,t){let n=t.readIdentity(e.rootPid);if(!n)return"exited";if(!e.rootIdentity||!ke(e.rootIdentity,n))return"mismatch";e.knownMembers.set(e.rootPid,n);for(let r of t.listDescendantPids(e.rootPid)){let i=t.readIdentity(r);i&&e.knownMembers.set(r,i)}return"owned"}function dy(e,t,n){let r=Sy(e,n);if(r==="mismatch")return{reason:"identity-mismatch",detail:`Process ${e.rootPid} changed identity before ${t}.`};if(r==="owned"&&e.ownsProcessGroup)try{return n.signal(-e.rootPid,t),null}catch(o){if(!py(o))return{reason:"signal-failed",detail:Bl(o)}}let i=null;for(let o of e.knownMembers.values()){let s=n.readIdentity(o.pid);if(!(!s||!ke(o,s)))try{n.signal(o.pid,t)}catch(a){!py(a)&&i===null&&(i=Bl(a))}}return i===null?null:{reason:"signal-failed",detail:i}}async function Fi(e,t,n){let r=n.now()+t;for(;by(e,n);){if(n.now()>=r)return!1;await n.sleep(Math.min(P_,Math.max(1,r-n.now())))}return!0}function by(e,t){if(!e.rootIdentity&&t.isProcessAlive(e.rootPid))return!0;for(let n of e.knownMembers.values()){let r=t.readIdentity(n.pid);if(r&&ke(n,r))return!0}return!!(e.ownsProcessGroup&&t.isProcessGroupAlive(e.rootPid))}function w_(e){let t=C_(!1),n=new Map;for(let s of t.split(/\r?\n/)){let a=/^\s*(\d+)\s+(\d+)\s*$/.exec(s);if(!a)continue;let c=Number(a[1]),l=Number(a[2]),u=n.get(l)??[];u.push(c),n.set(l,u)}let r=[],i=[...n.get(e)??[]],o=new Set;for(;i.length>0;){let s=i.pop();o.has(s)||(o.add(s),r.push(s),i.push(...n.get(s)??[]))}return r}function C_(e){return fy("ps",["-axo",e?"pid=,ppid=,rss=":"pid=,ppid="],{encoding:"utf8",timeout:my,maxBuffer:gy,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]})}function py(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function Bl(e){return e instanceof Error?e.message:String(e)}var xy={platform:R_(),now:Date.now,readIdentity:Nt,isProcessAlive(e){try{return process.kill(e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},isProcessGroupAlive(e){if(this.platform==="win32")return!1;try{return process.kill(-e,0),!0}catch(t){return typeof t=="object"&&t!==null&&"code"in t&&t.code==="EPERM"}},listDescendantPids(e){if(this.platform==="win32")return[];try{return w_(e)}catch{return[]}},signal(e,t){process.kill(e,t)},terminateWindowsTree(e){fy("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:my,maxBuffer:gy,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(t=>setTimeout(t,e))}};var hq={probe:1e4,git:3e4,analysis:18e4,install:3e5,indexer:6e5},Ni=class extends Error{constructor(n,r,i,o={}){super(i,o.cause===void 0?void 0:{cause:o.cause});this.kind=n;this.label=r;this.name="BoundedProcessError",this.timedOut=o.timedOut??!1,this.reaped=o.reaped??!1,this.stdout=o.stdout??"",this.stderr=o.stderr??"",this.stdoutTruncated=o.stdoutTruncated??!1,this.stderrTruncated=o.stderrTruncated??!1}kind;label;timedOut;reaped;stdout;stderr;stdoutTruncated;stderrTruncated};function Ti(e,t){if(!Number.isFinite(e)||e<=0)throw new TypeError(`${t} must be a positive finite number.`)}function Ey(e,t,n,r){let i=Math.max(0,r-n);i>0&&e.push(t.subarray(0,i))}function Ry(e,t,n){let r=Buffer.concat([...e,t]);e.length=0,e.push(r.subarray(Math.max(0,r.length-n)))}function Sq(e){Ti(e.timeoutMs,"timeoutMs"),Ti(e.maxStdoutBytes,"maxStdoutBytes"),Ti(e.maxStderrBytes,"maxStderrBytes");let t=e.terminationGraceMs??1e3;Ti(t,"terminationGraceMs");let n=e.terminationForceMs??t;return Ti(n,"terminationForceMs"),new Promise((r,i)=>{let o=Iy.now(),s=vy()!=="win32"&&process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1",a=vy()!=="win32"&&!s,c;try{c=F_(e.command,[...e.args??[]],{cwd:e.cwd,env:e.env,detached:a?!0:e.detached,stdio:["pipe","pipe","pipe"]})}catch(I){let P=I instanceof Error?I.message:String(I);i(new Ni("spawn",e.label,`${e.label} could not start: ${P}`,{cause:I,reaped:!0}));return}let l=[],u=[],d=0,p=0,f=!1,g=!1,y=null,m=!1,S=c.pid===void 0?null:yy(c.pid,a),h=()=>{clearTimeout(x),e.signal?.removeEventListener("abort",b)},v=I=>{if(m||!y)return;m=!0,h();let P=Buffer.concat(l).toString("utf8"),k=Buffer.concat(u).toString("utf8"),V=I.reaped||!I.detail?"":` Process-tree cleanup failed: ${I.detail}`;i(new Ni(y.kind,e.label,`${y.message}${V}`,{timedOut:y.timedOut,reaped:I.reaped,stdout:P,stderr:k,stdoutTruncated:f,stderrTruncated:g}))},E=I=>{if(!(y||m)){if(y=I,!S){v({reaped:c.pid===void 0,reason:c.pid===void 0?"terminated":"identity-unavailable"});return}hy(S,{gracefulMs:t,forceMs:n}).then(v,P=>{v({reaped:!1,reason:"signal-failed",detail:P instanceof Error?P.message:String(P)})})}},x=setTimeout(()=>{E({kind:"timeout",timedOut:!0,message:`${e.label} timed out after ${e.timeoutMs}ms.`})},e.timeoutMs);x.unref();let b=()=>{E({kind:"aborted",timedOut:!1,message:`${e.label} was cancelled.`})};e.signal?.addEventListener("abort",b,{once:!0}),e.signal?.aborted&&b(),c.stdout.on("data",I=>{let P=Buffer.isBuffer(I)?I:Buffer.from(I);e.outputLimitBehavior==="truncate-tail"?Ry(l,P,e.maxStdoutBytes):Ey(l,P,d,e.maxStdoutBytes),d+=P.length,d>e.maxStdoutBytes&&(f=!0,e.outputLimitBehavior!=="truncate-tail"&&E({kind:"stdout-limit",timedOut:!1,message:`${e.label} exceeded stdout limit (${e.maxStdoutBytes} bytes).`}))}),c.stderr.on("data",I=>{let P=Buffer.isBuffer(I)?I:Buffer.from(I);e.outputLimitBehavior==="truncate-tail"?Ry(u,P,e.maxStderrBytes):Ey(u,P,p,e.maxStderrBytes),p+=P.length,p>e.maxStderrBytes&&(g=!0,e.outputLimitBehavior!=="truncate-tail"&&E({kind:"stderr-limit",timedOut:!1,message:`${e.label} exceeded stderr limit (${e.maxStderrBytes} bytes).`}))}),c.on("error",I=>{if(!m&&!y){if(c.pid===void 0){h(),m=!0,i(new Ni("spawn",e.label,`${e.label} could not start: ${I.message}`,{cause:I,reaped:!0}));return}E({kind:"spawn",timedOut:!1,message:`${e.label} failed after start: ${I.message}`})}}),c.on("close",(I,P)=>{if(m||y)return;m=!0,h();let k=Buffer.concat(l).toString("utf8"),V=Buffer.concat(u).toString("utf8");r({status:I,signal:P,stdout:k,stderr:V,timedOut:!1,durationMs:Iy.now()-o,stdoutTruncated:f,stderrTruncated:g})}),e.input===void 0?c.stdin.end():c.stdin.end(e.input)})}function vq(e){switch(e){case"entry":case"source":case"worker":return 0;case"barrel":return 1;case"test":return 2}}function Py(e){let t=Z(e);return T_(t)?"test":N_(t)?"worker":__(t)?"entry":k_(t)?"barrel":"source"}function T_(e){return!!(/\.(?:test|spec)\.[a-z0-9]+$/i.test(e)||/(?:^|\/)(?:_)?test_[^/]+$/i.test(e)||/(?:^|\/)spec_[^/]+$/i.test(e)||/(?:^|\/)[^/]+_test\.[a-z0-9]+$/i.test(e)||/(?:^|\/)[^/]+_tests\.rs$/i.test(e)||/(?:^|\/)tests\.rs$/i.test(e)||/(?:^|\/)[^/]+_spec\.[a-z0-9]+$/i.test(e)||/(?:^|\/)__tests__\//i.test(e)||/(?:^|\/)test\//i.test(e)||/(?:^|\/)tests\//i.test(e)||/(?:^|\/)__fixtures__\//i.test(e)||/(?:^|\/)__mocks__\//i.test(e)||/(?:^|\/)test-support\//i.test(e)||/(?:^|\/)test-utils\//i.test(e)||/(?:^|\/)testing\//i.test(e))}function N_(e){return/(?:^|\/)[^/]*worker\.(?:ts|tsx|js|mjs|cjs|rs|py|go)$/.test(e)}function __(e){let t=e.split("/"),n=t[t.length-1]??e;return n==="cli.ts"||n==="cli.js"||n==="postinstall.ts"||n==="postinstall.js"||n==="main.ts"||n==="main.js"||n==="main.rs"||n==="main.go"||n==="main.py"||n==="build.rs"||n==="lib.rs"||/\bsrc\/bin\/[^/]+\.rs$/.test(e)||/(?:^|\/)examples\/[^/]+\.rs$/.test(e)||/(?:^|\/)tests\/[^/]+\.rs$/.test(e)||/(?:^|\/)benches\/[^/]+\.rs$/.test(e)?!0:n==="index.ts"||n==="index.js"?/(?:^|\/)(?:apps|services)\/[^/]+\/src\/index\.(?:ts|js)$/.test(e)?!0:t.length<=2:!1}function k_(e){return e==="index.ts"||e==="index.js"||e.endsWith("/index.ts")||e.endsWith("/index.js")||e.endsWith("/mod.rs")||e.endsWith("/__init__.py")}import{createHash as $l,randomUUID as Dy}from"crypto";import{closeSync as A_,existsSync as Ot,fstatSync as O_,lstatSync as br,mkdirSync as M_,openSync as j_,readdirSync as nn,readSync as B_,renameSync as Gl,rmSync as et}from"fs";import{basename as Sr,dirname as Vl,join as A}from"path";function wy(e){return ws(e,L_)}function Eq(e){return ws(e,D_)}function ws(e,t){return Array.isArray(e)?`[${e.map(n=>ws(n,t)).join(",")}]`:e&&typeof e=="object"?`{${Object.entries(e).sort(([n],[r])=>t(n,r)).map(([n,r])=>`${JSON.stringify(n)}:${ws(r,t)}`).join(",")}}`:JSON.stringify(e)}function L_(e,t){return e.localeCompare(t)}function D_(e,t){return e<t?-1:e>t?1:0}var Hl=1,$_=Object.freeze({maxItems:1024,maxBytes:512*1024*1024,maxItemBytes:64*1024*1024,maxBatch:16,claimLeaseMs:5*6e4,responseRetentionMs:10*6e4,deadLetterRetentionMs:1440*6e4,temporaryRetentionMs:6e4,cleanupBatch:64}),ft=class extends Error{constructor(n,r,i,o){let s=n==="item-too-large"?`request is ${o} bytes; per-item limit is ${i.maxItemBytes}`:n==="item-capacity"?`mailbox has ${r.totalItems} retained items; limit is ${i.maxItems}`:n==="byte-capacity"?`mailbox retains ${r.totalBytes} bytes and the request adds ${o}; limit is ${i.maxBytes}`:"another writer held the admission coordinator through the bounded wait";super(`Mailbox backpressure: ${s}. Retry after the service drains or expires retained work.`);this.code=n;this.status=r;this.limits=i;this.attemptedBytes=o;this.name="MailboxBackpressureError"}code;status;limits;attemptedBytes},Ay=".owner.json",Wl={isProcessAlive:()=>!0,readProcessIdentity:()=>null};function Dq(e){return{rootDir:e,pendingDir:A(e,"pending"),inflightDir:A(e,"inflight"),responseDir:A(e,"responses"),deadLetterDir:A(e,"dead-letter"),legacyRequestDir:A(e,"requests")}}function xr(e={}){let t={...$_,...e};for(let[n,r]of Object.entries(t))if(!Number.isFinite(r)||r<=0||!Number.isInteger(r))throw new Error(`Mailbox limit ${n} must be a positive integer.`);return t}function Fs(e){let t=[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir].map(n=>me(n));return W(...t)}function Aq(e,t){return $l("sha256").update(wy({namespace:e,payload:t})).digest("hex")}function Oy(e){if(!/^[a-f0-9]{64}$/.test(e))throw new Error("Mailbox operation keys must be lowercase SHA-256 identities.");return`op-${e}`}function Oq(e,t,n={}){let r=xr(n.limits),i=n.nowMs??Date.now(),o=Fs(e);return Q_(t),Ul(e,r,n.admissionLockTimeoutMs??2e3,n.monotonicNow??_t,n.durability??"durable",()=>{ql(e,i,r);let s=A(e.pendingDir,`${t.id}.json`),a=A(e.responseDir,`${t.id}.json`),c=Fy(e,t.id);if(c){let p=Ty(c,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:p.deadlineAtMs??t.deadlineAtMs}}let l=`${JSON.stringify(t)}
|
|
394
|
+
`,u=Buffer.byteLength(l),d=_i(e);if(u>r.maxItemBytes)throw new ft("item-too-large",d,r,u);if(d.totalItems+1>r.maxItems)throw new ft("item-capacity",d,r,u);if(d.totalBytes+u>r.maxBytes)throw new ft("byte-capacity",d,r,u);n.onBeforePublish?.();try{let p=n.durability??"durable",f=Yo(s,l,{durability:p}),g=p==="durable"?W(o,f.directorySync):"not-requested";return{disposition:"accepted",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:t.deadlineAtMs,achievedDurability:f.achievedDurability,directorySync:g}}catch(p){if(p.code!=="EEXIST")throw p;let f=Fy(e,t.id);if(!f)throw p;let g=Ty(f,t.operationKey,t.id);return{disposition:"duplicate",requestId:t.id,responsePath:a,authoritativeDeadlineAtMs:g.deadlineAtMs??t.deadlineAtMs}}})}function G_(e,t){if(!t.ownerId.trim())throw new Error("Mailbox claim owner identity is required.");if(t.owner&&(!Number.isSafeInteger(t.owner.pid)||t.owner.pid<=0||t.owner.processIdentity!==void 0&&t.owner.processIdentity.pid!==t.owner.pid))throw new Error("Mailbox claim process identity is invalid.");let n=t.nowMs??Date.now(),r=xr(t.limits),i=Fs(e);try{return Ul(e,r,2e3,t.monotonicNow??_t,t.durability??"durable",()=>V_(e,t.ownerId,n,r,t.liveness??Wl,t.owner??{pid:process.pid},i,t.durability??"durable",t.onClaimStage))}catch(o){if(o instanceof ft&&o.code==="admission-busy")return[];throw o}}function Mq(e,t){return!ky(e.pendingDir)&&!ky(e.legacyRequestDir)?[]:G_(e,t)}function V_(e,t,n,r,i,o,s,a,c){ql(e,n,r,i);let l=A(e.inflightDir,Cs(t)),u=[...Ny(e.pendingDir,!1),...Ny(e.legacyRequestDir,!0)].sort((f,g)=>f.orderAtMs-g.orderAtMs||f.header.id.localeCompare(g.header.id)||f.path.localeCompare(g.path)),d=a==="durable"?s:"not-requested";u.length>0&&(a==="durable"?d=W(d,me(l)):M_(l,{recursive:!0}),c?.("after-owner-directory-durable"),X_(l,t,o,a),c?.("after-owner-record-published"));let p=[];for(let f of u){if(p.length>=r.maxBatch)break;let g=A(e.responseDir,`${f.header.id}.json`);if(Ot(g)){et(f.path,{force:!0});continue}let y=Math.max(n+r.claimLeaseMs,(f.header.deadlineAtMs??n)+5e3),m=`${Cs(f.originalFile)}.${y}.claim`,S=A(l,m);try{Gl(f.path,S)}catch(x){let b=x.code;if(b==="ENOENT"||b==="EEXIST")continue;throw x}c?.("after-claim-renamed");let h=a==="durable"?D(Vl(f.path)):"not-requested";c?.("after-source-directory-synced");let v=a==="durable"?D(l):"not-requested";c?.("after-destination-directory-synced");let E=W(d,h,v);p.push({requestId:f.header.id,ownerId:t,path:S,originalFile:f.originalFile,claimedAtMs:n,claimExpiresAtMs:y,byteLength:f.byteLength,...f.header.operationKey?{operationKey:f.header.operationKey}:{},...f.header.clientId?{clientId:f.header.clientId}:{},...f.header.enqueuedAtMs===void 0?{}:{enqueuedAtMs:f.header.enqueuedAtMs},...f.header.deadlineAtMs===void 0?{}:{deadlineAtMs:f.header.deadlineAtMs},legacy:f.legacy,directorySync:E})}return p}function jq(e,t={}){let n=xr(t);if(e.byteLength>n.maxItemBytes)throw new ft("item-too-large",{pending:0,inflight:1,responses:0,deadLetters:0,invalid:0,totalItems:1,totalBytes:e.byteLength},n,e.byteLength);return j(e.path,{maxBytes:n.maxItemBytes,inputKind:"bounded mailbox item"})}function H_(e,t,n,r={}){let i=r.nowMs??Date.now(),o=xr(r.limits),s=t.deadlineAtMs===void 0?i+o.responseRetentionMs:Math.min(i+o.responseRetentionMs,Math.max(t.deadlineAtMs,i)+My),a={mailboxVersion:Hl,operationKey:t.operationKey??`legacy-${t.requestId}`,clientId:t.clientId??"legacy",...t.deadlineAtMs===void 0?{}:{deadlineAtMs:t.deadlineAtMs},completedAtMs:i,expiresAtMs:s},c={...a,...n,...a},l=Buffer.byteLength(`${JSON.stringify(c)}
|
|
395
|
+
`),u=_i(e);if(l>o.maxItemBytes)throw new ft("item-too-large",u,o,l);let d=Math.max(0,u.totalBytes-t.byteLength)+l;if(d>o.maxBytes&&d>u.totalBytes&&(q_(e,i).removed>0&&(u=_i(e),d=Math.max(0,u.totalBytes-t.byteLength)+l),d>o.maxBytes&&d>u.totalBytes))throw new ft("byte-capacity",u,o,l);let p=r.durability??"durable";if(U_(e,t,c,p),r.onAfterResponsePublished?.(),et(t.path,{force:!0}),p==="durable"){let f=Vl(t.path);D(Ot(f)?f:e.inflightDir)}}var My=3e4,W_=4096;function q_(e,t){let n={removed:0,bytesFreed:0},r;try{r=nn(e.responseDir)}catch{return n}for(let i of r){if(!i.endsWith(".json"))continue;let o=A(e.responseDir,i),s,a;try{let d=j_(o,"r");try{a=O_(d).size;let p=Buffer.alloc(Math.min(W_,a));B_(d,p,0,p.length,0),s=p.toString("utf8")}finally{A_(d)}}catch{continue}let c=Cy(s,"expiresAtMs"),l=Cy(s,"deadlineAtMs");if(c!==null&&c<=t||l!==null&&l+My<=t)try{et(o,{force:!0}),n.removed+=1,n.bytesFreed+=a}catch{}}return n}function Cy(e,t){let n=new RegExp(`"${t}":(\\d+)`).exec(e);if(!n)return null;let r=Number(n[1]);return Number.isSafeInteger(r)?r:null}function Bq(e,t,n,r,i={}){let o=i.nowMs??Date.now(),s=xr(i.limits);if(H_(e,t,n,{...i,nowMs:o,limits:s}),!Ot(t.path)){let a=A(e.deadLetterDir,`${tk(t.requestId)}.${o}.${$l("sha256").update(r).digest("hex").slice(0,12)}.json`),c={mailboxVersion:Hl,requestId:t.requestId,ownerId:t.ownerId,rejectedAtMs:o,reason:r,originalFile:t.originalFile},l=Buffer.byteLength(`${JSON.stringify(c,null,2)}
|
|
396
|
+
`),u=_i(e);u.totalItems<s.maxItems&&u.totalBytes+l<=s.maxBytes&&Le(a,c,{spacing:2,trailingNewline:!0})}}function $q(e,t={}){let n=t.nowMs??Date.now(),r=xr(t.limits);return Fs(e),Ul(e,r,2e3,t.monotonicNow??_t,"durable",()=>ql(e,n,r,t.liveness??Wl))}function ql(e,t,n,r=Wl){let i={reclaimed:0,completedClaimsRemoved:0,responsesRemoved:0,deadLettersRemoved:0,temporaryFilesRemoved:0},o=n.cleanupBatch;for(let s of Kl(e.inflightDir)){if(o<=0)break;let a=A(e.responseDir,`${s.requestId}.json`);if(Ot(a)){et(s.path,{force:!0}),i.completedClaimsRemoved++,o--;continue}if(s.claimExpiresAtMs>t||Y_(e,s.ownerId,r)!=="dead")continue;let c=A(e.pendingDir,s.originalFile);try{Gl(s.path,c),i.reclaimed++}catch(l){if(l.code!=="EEXIST")throw l;et(s.path,{force:!0})}D(Vl(s.path)),D(e.pendingDir),o--}o=_y(e.responseDir,o,(s,a)=>a+n.responseRetentionMs,t,()=>{i.responsesRemoved++}),o=_y(e.deadLetterDir,o,(s,a)=>a+n.deadLetterRetentionMs,t,()=>{i.deadLettersRemoved++});for(let s of[e.pendingDir,e.inflightDir,e.responseDir,e.deadLetterDir,e.legacyRequestDir]){if(o<=0)break;for(let a of By(s)){if(o<=0)break;if(!Sr(a).includes(".tmp-"))continue;let c;try{c=br(a).mtimeMs}catch(l){if(l.code==="ENOENT")continue;throw l}c+n.temporaryRetentionMs>t||(et(a,{force:!0}),i.temporaryFilesRemoved++,o--)}}return Z_(e.inflightDir),i}function _i(e){Fs(e);let t=[...Dn(e.pendingDir).map(c=>({path:c,pending:!0})),...Dn(e.legacyRequestDir).map(c=>({path:c,pending:!0}))],n=Kl(e.inflightDir).map(c=>({path:c.path,pending:!1})),r=Dn(e.responseDir).map(c=>({path:c,pending:!1})),i=Dn(e.deadLetterDir).map(c=>({path:c,pending:!1})),o=[...t,...n,...r,...i],s=0,a;for(let c of t){let l=ki(c.path);if(!l){s++;continue}let u=l.enqueuedAtMs;if(u===void 0)try{u=br(c.path).mtimeMs}catch(d){if(d.code==="ENOENT")continue;throw d}a=a===void 0?u:Math.min(a,u)}return{pending:t.length,inflight:n.length,responses:r.length,deadLetters:i.length,invalid:s,totalItems:o.length,totalBytes:o.reduce((c,l)=>c+ek(l.path),0),...a===void 0?{}:{oldestPendingAt:new Date(a).toISOString()}}}function U_(e,t,n,r){let i=A(e.responseDir,`${t.requestId}.json`),o=`${JSON.stringify(n)}
|
|
397
|
+
`;try{Yo(i,o,{durability:r})}catch(s){if(s.code!=="EEXIST")throw s;let a=ki(i),c=t.operationKey??`legacy-${t.requestId}`;if(a?.operationKey!==c)throw new Error(`Mailbox completion ${t.requestId} conflicts with an existing operation.`,{cause:s})}}function Ul(e,t,n,r,i,o){let s=A(e.rootDir,".admission.lock"),a=`${process.pid}-${Dy()}`,c=r()+Math.max(0,n);for(;!z_(e.rootDir,s,a,i);){if(K_(s),r()>=c)throw new ft("admission-busy",_i(e),t,0);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,5)}try{return o()}finally{try{zl(s).ownerToken===a&&(et(s,{recursive:!0,force:!0}),i==="durable"&&D(e.rootDir))}catch{}}}function z_(e,t,n,r){let i=`${JSON.stringify({ownerToken:n,pid:process.pid,acquiredAtMs:Date.now()})}
|
|
398
|
+
`;try{return Yo(t,i,{durability:r}),!0}catch(o){if(o.code==="EEXIST")return!1;try{zl(t).ownerToken===n&&(et(t,{force:!0}),r==="durable"&&D(e))}catch{}throw o}}function K_(e){let t=null;try{let r=zl(e);typeof r.ownerToken=="string"&&Number.isSafeInteger(r.pid)&&Number(r.pid)>0&&(t=Number(r.pid))}catch{}if(t===null||J_(t))return;let n=`${e}.stale-${Dy()}`;try{Gl(e,n)}catch(r){let i=r.code;if(i==="ENOENT"||i==="EEXIST")return;throw r}et(n,{recursive:!0,force:!0})}function zl(e){try{return JSON.parse(T(e,"mailbox lock record"))}catch(t){if(t.code!=="EISDIR"&&!(t instanceof st&&t.reason==="not-regular"))throw t;return JSON.parse(T(A(e,"owner.json"),"mailbox lock owner record"))}}function J_(e){try{return process.kill(e,0),!0}catch(t){let n=t.code;return n==="EPERM"||n!=="ESRCH"}}function X_(e,t,n,r){let i=A(e,Ay),o=n.processIdentity,s=jy(i);if(s&&s.ownerId===t&&s.pid===n.pid&&(!s.processIdentity&&!o||s.processIdentity&&o&&ke(s.processIdentity,o)))return;if(Dn(e).some(c=>c.endsWith(".claim")))throw new Error(`Mailbox owner identity ${t} collides with retained work from another process instance.`);let a={version:1,ownerId:t,pid:n.pid,...o?{processIdentity:o}:{}};r==="durable"?Le(i,a):Qt(i,a)}function Y_(e,t,n){let r=jy(A(e.inflightDir,Cs(t),Ay));if(!r)return"unknown";if(!n.isProcessAlive(r.pid))return"dead";if(!r.processIdentity)return"live";let i=n.readProcessIdentity(r.pid);return i?ke(r.processIdentity,i)?"live":"dead":"unknown"}function jy(e){try{let t=JSON.parse(T(e,"mailbox owner record"));if(t.version!==1||typeof t.ownerId!="string"||!t.ownerId||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0)return null;let n=t.processIdentity===void 0?null:Tt(t.processIdentity);return t.processIdentity!==void 0&&(!n||n.pid!==t.pid)?null:{version:1,ownerId:t.ownerId,pid:t.pid,...n?{processIdentity:n}:{}}}catch{return null}}function Fy(e,t){for(let n of[A(e.pendingDir,`${t}.json`),A(e.legacyRequestDir,`${t}.json`),A(e.responseDir,`${t}.json`)])if(Ot(n))return n;for(let n of Kl(e.inflightDir))if(n.requestId===t)return n.path;return null}function Ty(e,t,n){let r=ki(e);if(r?.operationKey===t)return r;if(Sr(e)===`${Oy(t)}.json`)return{id:n,operationKey:t};throw new Error(`Mailbox operation ${n} conflicts with an existing retained record.`)}function Q_(e){if(e.mailboxVersion!==Hl||e.id!==Oy(e.operationKey)||!e.clientId.trim()||!Number.isFinite(e.enqueuedAtMs)||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs)throw new Error("Mailbox request has an invalid lifecycle identity.")}function Ny(e,t){return Dn(e).filter(n=>n.endsWith(".json")).map(n=>{let r=br(n),i=Sr(n,".json"),o=ki(n)??{id:i};return{path:n,originalFile:Sr(n),header:o,byteLength:r.size,orderAtMs:o.enqueuedAtMs??r.mtimeMs,legacy:t}})}function Kl(e){if(!Ot(e))return[];let t=[];for(let n of nn(e,{withFileTypes:!0})){if(!n.isDirectory())continue;let r=Ly(n.name);if(r===null)continue;let i=A(e,n.name);for(let o of nn(i,{withFileTypes:!0})){if(!o.isFile()||!o.name.endsWith(".claim"))continue;let s=/^(.*)\.(\d+)\.claim$/.exec(o.name);if(!s)continue;let a=Ly(s[1]),c=Number(s[2]);if(a===null||Sr(a)!==a||!a.endsWith(".json")||!Number.isSafeInteger(c))continue;let l=A(i,o.name),u=ki(l)??{id:Sr(a,".json")},d;try{d=br(l)}catch(p){if(p.code==="ENOENT")continue;throw p}t.push({requestId:u.id,ownerId:r,path:l,originalFile:a,claimedAtMs:d.mtimeMs,claimExpiresAtMs:c,byteLength:d.size,...u.operationKey?{operationKey:u.operationKey}:{},...u.clientId?{clientId:u.clientId}:{},...u.enqueuedAtMs===void 0?{}:{enqueuedAtMs:u.enqueuedAtMs},...u.deadlineAtMs===void 0?{}:{deadlineAtMs:u.deadlineAtMs},legacy:u.operationKey===void 0})}}return t.sort((n,r)=>n.claimedAtMs-r.claimedAtMs||n.path.localeCompare(r.path))}function ki(e){try{let t=JSON.parse(T(e,"mailbox record"));return typeof t.id!="string"||!t.id?null:{id:t.id,...typeof t.operationKey=="string"?{operationKey:t.operationKey}:{},...typeof t.clientId=="string"?{clientId:t.clientId}:{},...typeof t.enqueuedAtMs=="number"?{enqueuedAtMs:t.enqueuedAtMs}:{},...typeof t.deadlineAtMs=="number"?{deadlineAtMs:t.deadlineAtMs}:{}}}catch{return null}}function _y(e,t,n,r,i){for(let o of Dn(e)){if(t<=0)break;let s;try{s=br(o)}catch(a){if(a.code==="ENOENT")continue;throw a}n(o,s.mtimeMs)>r||(et(o,{force:!0}),i(),t--)}return t}function Dn(e){return Ot(e)?nn(e,{withFileTypes:!0}).filter(t=>t.isFile()).map(t=>A(e,t.name)).sort():[]}function ky(e){try{return nn(e).some(t=>t.endsWith(".json"))}catch{return!1}}function By(e){if(!Ot(e))return[];let t=[];for(let n of nn(e,{withFileTypes:!0})){let r=A(e,n.name);n.isFile()?t.push(r):n.isDirectory()&&t.push(...By(r))}return t.sort()}function Z_(e){if(Ot(e))for(let t of nn(e,{withFileTypes:!0})){if(!t.isDirectory())continue;let n=A(e,t.name);nn(n).some(r=>r.endsWith(".claim"))||et(n,{recursive:!0,force:!0})}}function ek(e){try{return br(e).size}catch{return 0}}function Cs(e){return Buffer.from(e,"utf8").toString("base64url")}function Ly(e){try{let t=Buffer.from(e,"base64url").toString("utf8");return Cs(t)===e?t:null}catch{return null}}function tk(e){return/^[a-z0-9][a-z0-9-]{0,127}$/i.test(e)?e:`invalid-${$l("sha256").update(e).digest("hex")}`}var nk=4;function An(e,t,n,r={}){return $y(e,t,n,r.maxReexportDepth??nk,0,new Set)}function $y(e,t,n,r,i,o){let s=`${t}\0${n}`;if(o.has(s)||i>r)return[];o.add(s);let a=B(e,t).filter(c=>c.leaf===n);return a.length>0?a:Ct(e,t).flatMap(c=>c.sourcePath?c.kind==="named"&&!c.names.includes(n)?[]:$y(e,c.sourcePath,n,r,i+1,new Set(o)):[])}import{createHash as Gi}from"crypto";import{setImmediate as LL}from"timers/promises";import{createRequire as DL}from"module";import{createHash as xk}from"crypto";var Ts=8;function vr(e,t,n){return Zl(Gy(e,t,Yl(n),0,new Set))}function Ql(e,t,n){return Jl(e,t,n,0,new Set)}function Gy(e,t,n,r,i){if(r>Ts)return[];let o=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(n);return o?Vy(e,t,o[1],o[2],r,i):/^[A-Za-z_$][\w$]*$/u.test(n)?Hy(e,t,n,r,i):[]}function Vy(e,t,n,r,i,o){let s=[];for(let a of Jl(e,t,n,i+1,new Set(o))){let c=Ge(a.initializer);for(let l of c.namedChildren){if(l.type==="pair"){let u=l.childForFieldName("key")??l.namedChild(0);if(ak(u)!==r)continue;let d=l.childForFieldName("value")??l.namedChild(1);d&&s.push(...Gy(e,a.definition.relativePath,Yl(d.text),i+1,new Set(o)));continue}if(/(?:method|function)/u.test(l.type)){if((l.childForFieldName("name")??l.namedChild(0))?.text!==r)continue;let d=ok(e,a.definition.relativePath,r,l);s.push(...d.length>0?d:[rk(a.definition,r,l)]);continue}if(l.type==="spread_element"){let u=l.namedChild(0);if(!u)continue;for(let d of Jl(e,a.definition.relativePath,Yl(u.text),i+1,new Set(o)))s.push(...Vy(e,d.definition.relativePath,d.definition.leaf,r,i+1,new Set(o)))}}}return Zl(s)}function rk(e,t,n){return{documentId:e.documentId,symbolId:-1,symbol:`source-callable:${e.relativePath}:${n.startPosition.row}:${t}`,relativePath:e.relativePath,startLine:n.startPosition.row,startChar:n.startPosition.column,endLine:n.endPosition.row,endChar:n.endPosition.column,leaf:t,parentTypeName:e.leaf,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:e.symbol}}function Jl(e,t,n,r,i){return r>Ts||!/^[A-Za-z_$][\w$]*$/u.test(n)?[]:Hy(e,t,n,r,i).flatMap(o=>{let s=M(e,o.relativePath)?.rootNode,a=s?sk(s,o.leaf):null;return a?[{definition:o,initializer:a}]:[]})}function Hy(e,t,n,r,i){if(r>Ts)return[];let o=`${t}\0${n}`;if(i.has(o))return[];i.add(o);let s=B(e,t).filter(l=>l.leaf===n);if(s.length>0)return s;let a=ik(e,t,n);if(a.length>0)return a;let c=ue(e,t).find(l=>l.localName===n&&l.sourcePath);if(c?.sourcePath){let l=c.kind==="namespace"||c.importedName==="default"?n:c.importedName;return Xl(e,c.sourcePath,l,r+1,new Set(i))}return Xl(e,t,n,r+1,new Set(i))}function ik(e,t,n){let r=e.get("SELECT id FROM documents WHERE relative_path = ?",t)?.id;return r===void 0?[]:(he(e,t)?.callables??[]).filter(i=>i.name===n).map(i=>({documentId:r,symbolId:-1,symbol:`source-callable:${t}:${i.startLine}:${n}`,relativePath:t,startLine:i.startLine,startChar:0,endLine:i.endLine,endChar:0,leaf:n,parentTypeName:null,isFunctionLike:!0,isTypeLike:!1,kind:null,documentation:null,enclosingSymbol:null}))}function Xl(e,t,n,r,i){if(r>Ts)return[];let o=B(e,t).filter(s=>s.leaf===n);return o.length>0?o:Zl(Ct(e,t).flatMap(s=>s.sourcePath?s.kind==="named"&&!s.names.includes(n)?[]:Xl(e,s.sourcePath,n,r+1,new Set(i)):[]))}function ok(e,t,n,r){return B(e,t).filter(i=>i.leaf===n&&i.startLine<=r.startPosition.row&&i.endLine>=r.endPosition.row)}function sk(e,t){let n=null;return ge(e,r=>{n||r.type!=="variable_declarator"||(r.childForFieldName("name")??r.namedChild(0))?.text.trim()!==t||(n=r.childForFieldName("value")??r.namedChild(1))}),n}function ak(e){return e?.text.replace(/^['"`]|['"`]$/gu,"")??null}function Yl(e){return e.replace(/\s+/gu,"").replace(/^\.\.\./u,"")}function Zl(e){return[...new Map(e.map(t=>[t.symbol,t])).values()]}function Ns(e){let t=e.replaceAll("\\","/");return Py(t)==="test"?/(?:^|\/)__fixtures__\//iu.test(t)?"fixture":"test":/(?:^|\/)(?:fixtures?|testdata)\//iu.test(t)?"fixture":/(?:^|\/)(?:examples?|demos?|previews?)\//iu.test(t)?"example":/(?:^|\/)(?:generated|dist|build|coverage)\//iu.test(t)||/\.generated\./iu.test(t)?"generated":/^(?:scripts?|tools?)\//iu.test(t)?"script":"production"}var ck=8;function nt(e,t){return t?Ir(e,t,0,new Set):null}function Ir(e,t,n,r){if(n>ck)return mt(t,"value-evaluation-depth");let i=Ge(t),o=mk(i);if(o)return gk(e.file,i,o.term,o.value,o.precision);if(i.type==="binary_expression"&&/\+/u.test(i.text)){let c=i.namedChildren.map(l=>Ir(e,l,n+1,new Set(r)));if(c.length>=2&&c.every(l=>l!==null)){let l={kind:"concat",parts:c.map(d=>d.term)},u=c.map(d=>d.value).join("");return yk(e.file,i,l,u,c.some(d=>d.precision!=="literal")?"constrained-pattern":"literal",c)}}let s=i.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(s))return pk(e,s,i,n,r);let a=hk(i);return a?fk(e,a.base,a.properties,i,n,r):i.type==="call_expression"||i.type==="call"?lk(e,i,n,r):mt(i,`unsupported-expression:${i.type}`)}function lk(e,t,n,r){let o=(t.childForFieldName("function")??t.namedChild(0))?.text.replace(/\s+/gu,"").replace(/<.*>$/u,"")??"",s=uk(e,o);if(s.length!==1)return mt(t,s.length===0?"call-target-unresolved":"call-target-ambiguous");let a=s[0],c=`${a.relativePath}\0${a.symbol}`;if(r.has(c))return mt(t,"call-return-cycle");let l=M(e.db,a.relativePath)?.rootNode;if(!l)return mt(t,"call-target-unparsed");let u=$e(l,a.startLine,a.endLine);if(!u)return mt(t,"call-target-syntax-unavailable");let d=dk(u);if(!d)return mt(t,"call-return-not-single-expression");let p=new Set(r);p.add(c);let f=Ir({db:e.db,file:a.relativePath,root:l},d,n+1,p);return f?_s(t,"bounded-call-return",f,a.symbol):mt(t,"call-return-unresolved")}function uk(e,t){if(/^[A-Za-z_$][\w$]*$/u.test(t)){let i=B(e.db,e.file).filter(s=>s.isFunctionLike&&s.leaf===t);if(i.length>0)return i;let o=ue(e.db,e.file).find(s=>s.localName===t&&s.sourcePath&&s.kind!=="namespace");return o?.sourcePath?An(e.db,o.sourcePath,o.importedName==="default"?t:o.importedName).filter(s=>s.isFunctionLike):[]}let n=/^([A-Za-z_$][\w$]*)\.([A-Za-z_$][\w$]*)$/u.exec(t);if(!n)return[];let r=ue(e.db,e.file).find(i=>i.kind==="namespace"&&i.localName===n[1]&&i.sourcePath);return r?.sourcePath?An(e.db,r.sourcePath,n[2]).filter(i=>i.isFunctionLike):[]}function dk(e){let t=e.childForFieldName("body");if(e.type==="arrow_function"&&t&&t.type!=="statement_block")return t;let n=[];return qy(t??e,t??e,n),n.length!==1?null:n[0].childForFieldName("argument")??n[0].namedChild(0)}function qy(e,t,n){if(!(t!==e&&(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function"))){if(t.type==="return_statement"){n.push(t);return}for(let r of t.namedChildren)qy(e,r,n)}}function pk(e,t,n,r,i){let o=`${e.file}\0${t}`;if(i.has(o))return mt(n,"value-cycle");i.add(o);let s=eu(e.root,t);if(s){let g=Ir(e,s,r+1,i);return g?_s(n,"local-constant",g):mt(n,"non-foldable-local")}let a=ue(e.db,e.file).find(g=>g.localName===t&&g.sourcePath);if(!a?.sourcePath)return tt(n,t,"unresolved-identifier");if(a.kind==="namespace")return tt(n,t,"namespace-import-requires-property");let c=a.importedName==="default"?t:a.importedName,l=An(e.db,a.sourcePath,c);if(l.length!==1)return tt(n,t,l.length===0?"import-definition-missing":"import-definition-ambiguous");let u=l[0],d=M(e.db,u.relativePath)?.rootNode;if(!d)return tt(n,u.symbol,"import-definition-unparsed");let p=eu(d,u.leaf);if(!p)return tt(n,u.symbol,"import-definition-non-value");let f=Ir({db:e.db,file:u.relativePath,root:d},p,r+1,i);return f?_s(n,"imported-constant",f,u.symbol):tt(n,u.symbol,"import-value-unresolved")}function fk(e,t,n,r,i,o){let s=ue(e.db,e.file).find(f=>f.localName===t&&f.sourcePath),a=e.file,c=t,l;if(s?.sourcePath){s.kind==="namespace"?(c=n[0]??"",n=n.slice(1)):c=s.importedName==="default"?t:s.importedName;let f=An(e.db,s.sourcePath,c);if(f.length!==1)return tt(r,`${t}.${n.join(".")}`,f.length===0?"member-definition-missing":"member-definition-ambiguous");a=f[0].relativePath,c=f[0].leaf,l=f[0].symbol}let u=a===e.file?e.root:M(e.db,a)?.rootNode;if(!u)return tt(r,l??t,"member-definition-unparsed");let d=eu(u,c);if(!d)return tt(r,l??t,"member-base-non-value");for(let f of n){let g=Ge(d);if(d=bk(g,f),!d)return tt(r,l??`${t}.${n.join(".")}`,`member-property-missing:${f}`)}let p=Ir({db:e.db,file:a,root:u},d,i+1,o);return p?_s(r,"member-constant",p,l):tt(r,l??t,"member-value-unresolved")}function mk(e){let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);if(n!=="`"||!r.includes("${"))return{term:{kind:"literal",value:r},value:r,precision:"literal"};let i=[],o=0,s=/\$\{([^}]*)\}/gu;for(let a of r.matchAll(s)){let c=a.index??0;c>o&&i.push({kind:"literal",value:r.slice(o,c)}),i.push({kind:"unknown",reason:`template-hole:${a[1]?.trim()||"expression"}`}),o=c+a[0].length}return o<r.length&&i.push({kind:"literal",value:r.slice(o)}),{term:{kind:"pattern",language:"template",value:r.replace(s,"{}")},value:r.replace(s,"{}"),precision:"constrained-pattern"}}function gk(e,t,n,r,i){return{value:r,evidence:"literal",term:n,precision:i,derivation:ks("direct-literal","direct",e,t)}}function yk(e,t,n,r,i,o){return{value:r,evidence:"constant",term:n,precision:i,derivation:{...ks("constant-concatenation","mechanically-derived",e,t),inputFactIds:o.flatMap(s=>s.derivation.inputFactIds),sourceSpans:o.flatMap(s=>s.derivation.sourceSpans)}}}function _s(e,t,n,r){return n.evidence==="expression"?{...n,derivation:{kind:"heuristic",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}:{...n,evidence:"constant",derivation:{kind:"mechanically-derived",rule:t,ruleVersion:"1",inputFactIds:[...n.derivation.inputFactIds,...r?[r]:[]],sourceSpans:n.derivation.sourceSpans}}}function tt(e,t,n){return{value:e.text.trim(),evidence:"expression",term:{kind:"symbol",symbol:t},precision:"symbolic",derivation:ks(n,"heuristic","",e)}}function mt(e,t){return{value:e.text.trim(),evidence:"expression",term:{kind:"unknown",reason:t},precision:"unknown",derivation:ks(t,"heuristic","",e)}}function ks(e,t,n,r){return{kind:t,rule:e,ruleVersion:"1",inputFactIds:[],sourceSpans:n?[{file:n,startLine:r.startPosition.row,endLine:r.endPosition.row}]:[]}}function hk(e){let t=e.text.replace(/\s+/gu,"");if(!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)+$/u.test(t))return null;let[n,...r]=t.split(".");return n?{base:n,properties:r}:null}var Wy=new WeakMap;function Sk(e){let t=Wy.get(e);if(t)return t;let n=new Map;return ge(e,r=>{if(r.type!=="variable_declarator")return;let o=(r.childForFieldName("name")??r.namedChild(0))?.text.trim();if(!o||n.has(o))return;let s=r.parent;if(!s||s.type!=="lexical_declaration"||!/^\s*(?:export\s+)?const\b/u.test(s.text))return;let a=r.childForFieldName("value")??r.namedChild(1);a&&n.set(o,a)}),Wy.set(e,n),n}function eu(e,t){return Sk(e).get(t)??null}function bk(e,t){for(let n of e.namedChildren)if(!(n.type!=="pair"||(n.childForFieldName("key")??n.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")!==t))return n.childForFieldName("value")??n.namedChild(1);return null}var vk=new WeakMap,Zy=new Set(["delete","get","head","options","patch","post","put"]),Ik=/(?:^|\.)(?:app|router|server)$/u,Ek=new Set(["findFirst","findMany","findUnique","from","get","select"]),Rk=new Set(["create","delete","insert","remove","update","upsert"]),Pk=new Set(["execute","query","raw"]),Uy=/(?:\b(?:name|id)|['"`](?:name|id)['"`])\s*:/u,zy=/(?:^\s*|[,{]\s*)(?:async\s+)?['"`]?(?:execute|handler|invoke|run)['"`]?\s*(?::|\([^)]*\)\s*\{)/mu,Ky=/\b[A-Za-z_$][\w$-]*[_-][\w$-]*\s*\(/u,Jy=/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s+[A-Za-z_$][\w$-]*\s*\(/iu,ru=[Tk(),Fk(),wk(),Nk(),kk(),Lk(),Ak()],nu=new Set(["exec","execFile","execFileSync","execSync","fork","spawn","spawnSync"]);function wk(){return{id:"builtin.node-child-process",supports:e=>/(?:from\s*|require\s*\(\s*)['"](?:node:)?child_process['"]/u.test(e)&&/\b(?:exec|execFile|execFileSync|execSync|fork|spawn|spawnSync)\s*\(/u.test(e),extract:e=>{let t=Ck(e.source),n=[];return rn(e.root,"call_expression",r=>{let i=Oi(r);if(!i)return;let o=t.direct.get(i),s=/^(.*?)\.([A-Za-z_$][\w$]*)$/u.exec(i),a=s&&t.namespaces.has(s[1])?s[2]:null,c=o??a;if(!c||!nu.has(c))return;let l=On(r),u=ze(l[0],e)??{value:l[0]?.text.trim()||"<missing>",evidence:"expression"},d=["exec","execFile","execFileSync","execSync"].includes(c)?"process.exec":"process.spawn";n.push(pe(e,r,"builtin.node-child-process",d,[{name:"operation",value:c,evidence:"literal"},{name:"executable",...u}],"exact","node-child-process-import"))}),n}}}function Ck(e){let t=new Map,n=new Set,r=String.raw`['"](?:node:)?child_process['"]`,i=new RegExp(String.raw`\bimport\s*\{([^}]*)\}\s*from\s*${r}`,"gu");for(let c of e.matchAll(i))for(let l of(c[1]??"").split(",")){let u=/^\s*([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?\s*$/u.exec(l);u&&nu.has(u[1])&&t.set(u[2]??u[1],u[1])}let o=new RegExp(String.raw`\b(?:const|let)\s*\{([^}]*)\}\s*=\s*require\s*\(\s*${r}\s*\)`,"gu");for(let c of e.matchAll(o))for(let l of(c[1]??"").split(",")){let u=/^\s*([A-Za-z_$][\w$]*)(?:\s*:\s*([A-Za-z_$][\w$]*))?\s*$/u.exec(l);u&&nu.has(u[1])&&t.set(u[2]??u[1],u[1])}let s=new RegExp(String.raw`\bimport\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*from\s*${r}`,"gu");for(let c of e.matchAll(s))n.add(c[1]);let a=new RegExp(String.raw`\b(?:const|let)\s+([A-Za-z_$][\w$]*)\s*=\s*require\s*\(\s*${r}\s*\)`,"gu");for(let c of e.matchAll(a))n.add(c[1]);return{direct:t,namespaces:n}}function Ce(e,t,n,r){let i=Li(r,"runtime-boundaries.context.ast",t,()=>n===void 0?M(e,t):_p(e,t,n));if(!i)return null;let o=i.rootNode;n!==void 0&&vk.set(o,i);let s=n??F(e,t),a,c,l,u=()=>(c!==void 0||(c=Li(r,"runtime-boundaries.context.callable-sites",t,()=>{let d=oe(t);return(d?ac(o,d):null)??Kr(e,t)})),c);return{db:e,file:t,source:s,root:o,get constants(){return l??=Li(r,"runtime-boundaries.context.constants",t,()=>Gk(o)),l},ownerAt:d=>{let f=(a??=Li(r,"runtime-boundaries.context.definitions",t,()=>B(e,t,{rangeCorrectionEvidence:{source:s,callables:u()}},(m,S)=>Li(r,`runtime-boundaries.context.definitions.${m}`,t,S)))).filter(m=>m.startLine<=d&&m.endLine>=d).sort((m,S)=>m.endLine-m.startLine-(S.endLine-S.startLine)||m.startLine-S.startLine)[0];if(f)return{file:t,symbol:f.symbol,name:f.leaf,startLine:f.startLine,endLine:f.endLine};let y=(u()??[]).filter(m=>m.startLine<=d&&m.endLine>=d).sort((m,S)=>m.endLine-m.startLine-(S.endLine-S.startLine)||m.startLine-S.startLine)[0];return{file:t,symbol:null,name:y?.name??null,startLine:y?.startLine??d,endLine:y?.endLine??d}}}}function Li(e,t,n,r){return e?e(t,r,{file:n}):r()}function Fk(){return{id:"builtin.effect-httpapi",supports:e=>Di(e,"HttpApiEndpoint").size>0||Di(e,"HttpApiBuilder").size>0,extract:e=>{let t=[],n=Di(e.source,"HttpApiEndpoint"),r=Di(e.source,"HttpApiGroup"),i=Di(e.source,"HttpApiBuilder");return rn(e.root,"call_expression",o=>{let s=eh(o);if(!s)return;let a=On(o);if(n.has(s.receiver)&&Zy.has(s.member)){let y=ze(a[0],e),m=ze(a[1],e),S=Yy(o,r,"make",0,e);if(!y||!m||!S)return;let h=s.member.toUpperCase();t.push(pe(e,o,"builtin.effect-httpapi","http.handle",[{name:"method",value:h,evidence:"literal"},{name:"path",...m}],gt([{name:"path",...m}]),"effect-httpapi-endpoint-declaration")),t.push(pe(e,o,"builtin.effect-httpapi","framework.declare",tu(S,y),gt(tu(S,y)),"effect-httpapi-operation-declaration"));return}if(!["handle","handleRaw"].includes(s.member))return;let c=Yy(o,i,"group",1,e),l=ze(a[0],e),u=a[1];if(!c||!l||!u)return;let d=tu(c,l),p=vr(e.db,e.file,u.text),f=pe(e,o,"builtin.effect-httpapi","framework.handle",d,p.length===1?gt(d):"candidate","effect-httpapi-handler-registration"),g=p[0];p.length===1&&g&&(f.owner={file:g.relativePath,symbol:g.symbol,name:g.leaf,startLine:g.startLine,endLine:g.endLine}),t.push(f)}),t}}}function tu(e,t){return[{name:"adapter",value:"effect-httpapi",evidence:"literal"},{name:"group",...e},{name:"operation",...t}]}function Di(e,t){let n=new Set,r=/\bimport\s*\{([\s\S]*?)\}\s*from\s*['"]([^'"]+)['"]/gu;for(let o of e.matchAll(r)){let s=o[2]??"";if(Xy(s))for(let a of(o[1]??"").split(",")){let c=a.trim().replace(/^type\s+/u,""),l=/^([A-Za-z_$][\w$]*)(?:\s+as\s+([A-Za-z_$][\w$]*))?$/u.exec(c);l?.[1]===t&&n.add(l[2]??l[1])}}let i=/\bimport\s*\*\s*as\s*([A-Za-z_$][\w$]*)\s*from\s*['"]([^'"]+)['"]/gu;for(let o of e.matchAll(i)){let s=o[2]??"";s.endsWith(`/${t}`)&&Xy(s)&&n.add(o[1])}return n}function Xy(e){return e==="effect/unstable/httpapi"||e==="@effect/platform"||e.startsWith("@effect/platform/HttpApi")}function Yy(e,t,n,r,i){let o=e.parent;for(;o;){if(o.type==="call_expression"){let s=Qy(o,t,n,r,i);if(s)return s;let a=o.childForFieldName("function")??o.namedChild(0),c=null;if(a&&ou(a,l=>{!c&&l.type==="call_expression"&&(c=Qy(l,t,n,r,i))}),c)return c}o=o.parent}return null}function Qy(e,t,n,r,i){let o=eh(e);return!o||o.member!==n||!t.has(o.receiver)?null:ze(On(e)[r],i)}function eh(e){let t=e.childForFieldName("function")??e.namedChild(0);if(!t||!["member_expression","subscript_expression"].includes(t.type))return null;let n=t.childForFieldName("object")??t.namedChild(0),r=t.childForFieldName("property")??t.childForFieldName("index")??t.namedChild(1);return!n||!r?null:{receiver:n.text.replace(/\s+/gu,""),member:r.text.replace(/^['"`]|['"`]$/gu,"")}}function Tk(){return{id:"builtin.http",supports:e=>/\bfetch\s*\(|\baxios\b|\b(?:app|router|server)\s*\.\s*(?:get|post|put|patch|delete|options|head)\s*\(/u.test(e)||Ai(e,["axios"])||/\b(?:FastAPI|Flask|APIRouter|axum|Router::new)\b/u.test(e),extract:e=>{let t=[];return rn(e.root,["decorator","call_expression"],n=>{if(n.type==="decorator"){let p=/^@[^\s(]+\.(get|post|put|patch|delete|options|head)\s*\(\s*(['"`])([^'"`]+)\2/iu.exec(n.text.trim());if(!p||!Ai(e.source,["fastapi","flask"]))return;t.push(pe(e,n,"builtin.http","http.handle",[{name:"method",value:p[1].toUpperCase(),evidence:"literal"},{name:"path",value:p[3],evidence:"literal"}],"exact","framework-decorator"));return}if(n.type!=="call_expression")return;let r=Oi(n);if(!r)return;let i=r.split(".").at(-1)?.toLowerCase()??"",o=r.includes(".")?r.slice(0,r.lastIndexOf(".")):"",s=On(n);if(i==="route"&&Ai(e.source,["axum"])){let p=ze(s[0],e),f=/^\s*(get|post|put|patch|delete|options|head)\s*\(/iu.exec(s[1]?.text??"")?.[1];if(!p||!f)return;t.push(pe(e,n,"builtin.http","http.handle",[{name:"method",value:f.toUpperCase(),evidence:"literal"},{name:"path",...p}],gt([{name:"path",...p}]),"framework-adapter"));return}if(r==="fetch"||r.endsWith(".fetch")){let p=ze(s[0],e);if(!p)return;let g=/\bmethod\s*:\s*['"`]([A-Za-z]+)['"`]/u.exec(s[1]?.text??"")?.[1]?.toUpperCase()??(s[1]?null:"GET"),y=[...g?[{name:"method",value:g,evidence:"literal"}]:[],{name:"path",...p}];t.push(pe(e,n,"builtin.http","http.request",y,g?gt(y):"candidate","call-expression"));return}if(!Zy.has(i))return;let a=ze(s[0],e);if(!a)return;let c=i.toUpperCase();if(Ik.test(o)&&Ai(e.source,["express","fastify","hono","koa-router","@koa/router"])){t.push(pe(e,n,"builtin.http","http.handle",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],gt([{name:"path",...a}]),"framework-adapter"));return}let u=jk(e.source,["axios"]),d=o.split(".")[0]??"";u.has(d)&&t.push(pe(e,n,"builtin.http","http.request",[{name:"method",value:c,evidence:"literal"},{name:"path",...a}],gt([{name:"path",...a}]),"client-adapter"))}),t}}}function Nk(){return{id:"builtin.capability-registry",supports:e=>Uy.test(e)&&zy.test(e)||Ky.test(e)||Jy.test(e),extract:e=>{let t=[],n=new Set,r=[];return Uy.test(e.source)&&zy.test(e.source)&&r.push("pair"),(Ky.test(e.source)||Jy.test(e.source))&&r.push("string","string_literal","template_string"),rn(e.root,r,i=>{if(i.type==="pair"){let s=i.childForFieldName("key")??i.namedChild(0),a=i.childForFieldName("value")??i.namedChild(1),c=s?.text.replace(/^['"`]|['"`]$/gu,"");if(c!=="name"&&c!=="id")return;let l=th(a,e),u=Hk(i);if(!l||l.evidence!=="literal"||!u)return;let d=`handle\0${l.value}\0${u.startPosition.row}`;if(n.has(d))return;n.add(d),t.push(pe(e,u,"builtin.capability-registry","registry.handle",[{name:"key",...l}],"exact","capability-descriptor"));return}if(!["string","string_literal","template_string"].includes(i.type))return;let o=i.text.replace(/^['"`]|['"`]$/gu,"");for(let s of o.matchAll(/\b([A-Za-z_$][\w$-]*)\s*\(/gu)){let a=s[1];if(!_k(o,a,s.index))continue;let c=`reference\0${a}\0${i.startPosition.row}`;n.has(c)||(n.add(c),t.push(pe(e,i,"builtin.capability-registry","registry.reference",[{name:"key",value:a,evidence:"literal"}],"exact","capability-instruction-reference")))}}),t}}}function _k(e,t,n){if(t.includes("_")||t.includes("-"))return!0;let r=e.slice(Math.max(0,n-64),n);return/\b(?:use|call|invoke|run|via|with|read|stop)(?:\s+the)?(?:\s+(?:tool|capability|command))?\s*$/iu.test(r)}function kk(){return{id:"builtin.registry",supports:e=>/(?:Handlers?|Registry|Routes?)\b/iu.test(e),extract:e=>{let t=[];return rn(e.root,["pair","call_expression"],n=>{if(n.type==="pair"){let o=Vk(n);if(!o)return;let s=n.childForFieldName("key")??n.namedChild(0),a=n.childForFieldName("value")??n.namedChild(1),c=th(s,e);if(!c||!a||!nh(a))return;let l=iu(a)?"exact":"candidate";t.push(pe(e,n,"builtin.registry","registry.handle",[{name:"registry",value:o,evidence:"identifier"},{name:"key",...c}],gt([{name:"key",...c}],l),"object-member"));return}if(n.type!=="call_expression")return;let r=n.childForFieldName("function")??n.namedChild(0);if(!r)return;let i=/^([A-Za-z_$][\w$]*)\s*\[\s*(['"`])([^'"`]+)\2\s*\]$/u.exec(r.text.trim());i&&t.push(pe(e,n,"builtin.registry","registry.dispatch",[{name:"registry",value:i[1],evidence:"identifier"},{name:"key",value:i[3],evidence:"literal"}],"exact","indexed-access-call"))}),t}}}function Lk(){return{id:"builtin.persistence",supports:e=>/\b(?:db|database|prisma|drizzle|[A-Za-z_$][\w$]*(?:Repository|Repo))\b[^;]{0,1024}?\.\s*(?:findFirst|findMany|findUnique|from|get|select|create|delete|insert|remove|update|upsert|execute|query|raw|transaction)(?:\s*<[^()]{1,512}>)?\s*\(/iu.test(e),extract:e=>{let t=[],n=qk(e.root);return rn(e.root,"call_expression",r=>{let i=Oi(r);if(!i)return;let o=i.split("."),s=o.at(-1)??"",a=On(r),c=a[0]?.text??"",l=Wk(s,c);if(!l)return;let u=rh(o,n);if(!u)return;let d=Dk(a[0],e)??Uk(c),p=zk(u,o,s,d);if(!p)return;let f=s==="insert"?"persistence-insert":l==="database.read"&&/\bFOR\s+UPDATE\s+SKIP\s+LOCKED\b/iu.test(c)?"persistence-skip-locked-claim":"persistence-adapter";t.push(pe(e,r,"builtin.persistence",l,[{name:"resource",...p}],gt([{name:"resource",...p}]),f))}),t}}}function Dk(e,t){if(!e)return null;let n=e.text.replace(/\s+/gu,"");return/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/u.test(n)?{value:n.split(".").at(-1),evidence:"identifier",term:{kind:"symbol",symbol:n}}:ze(e,t)}function Ak(){return{id:"builtin.queue",supports:e=>Ai(e,["amqplib","bullmq","kafkajs","@aws-sdk/client-sqs","rabbitmq"])&&/\.(?:sendToQueue|consume|send|subscribe)\s*\(/u.test(e),extract:e=>{let t=[];return rn(e.root,"call_expression",n=>{let r=Oi(n);if(!r)return;let i=r.split(".").at(-1)??"",o=On(n),s=i==="sendToQueue"||i==="send"?"queue.send":i==="consume"||i==="subscribe"?"queue.consume":null;if(!s)return;let a=i==="send"||i==="subscribe"?Bk(o[0],"topic",e):ze(o[0],e);a&&t.push(pe(e,n,"builtin.queue",s,[{name:"address",...a}],gt([{name:"address",...a}]),"framework-adapter"))}),t}}}function pe(e,t,n,r,i,o,s){let a=e.ownerAt(t.startPosition.row),c=JSON.stringify({extractor:n,action:r,file:e.file,line:t.startPosition.row,keyParts:i});return{id:`boundary:${xk("sha256").update(c).digest("hex").slice(0,16)}`,extractor:n,action:r,owner:a,source:{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},keyParts:i,evidence:s,strength:o,protocol:r.split(".")[0]??r,role:Ok(r),executionDomain:Mk(e.file),derivation:{kind:o==="candidate"?"heuristic":o==="derived"?"mechanically-derived":"direct",rule:s,ruleVersion:"1",inputFactIds:i.flatMap(l=>l.derivation?.inputFactIds??[]),sourceSpans:[{file:e.file,startLine:t.startPosition.row,endLine:t.endPosition.row},...i.flatMap(l=>l.derivation?.sourceSpans??[])]},valuePrecision:i.some(l=>l.evidence==="expression")?"unknown":i.some(l=>l.evidence==="identifier")?"symbolic":"literal",modality:"may",resolution:"unresolved",sourceScope:Ns(e.file)}}function Ok(e){let t=e.split(".").at(-1)??e;return["handle","subscribe","consume","read"].includes(t)?"consumer":["request","publish","send","write","dispatch","reference","invoke","spawn","exec"].includes(t)?"producer":"observe"}function Mk(e){let t=e.replaceAll("\\","/"),n=/^(apps|services|packages)\/([^/]+)/u.exec(t);return n?`${n[1]}/${n[2]}`:null}function Ai(e,t){return t.some(n=>{let r=n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&");return new RegExp(`(?:\\bfrom\\s+${r}\\b|\\buse\\s+${r}\\b|(?:\\bfrom\\s*|\\brequire\\s*\\(\\s*)['"]${r}(?:[/']|"))`,"u").test(e)})}function jk(e,t){let n=new Set;for(let r of t){let i=r.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&"),o=new RegExp(`(?:import\\s+([A-Za-z_$][\\w$]*)[^;]*?\\sfrom\\s*|(?:const|let)\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*require\\s*\\(\\s*)['"]${i}(?:[/']|")`,"gu");for(let s of e.matchAll(o)){let a=s[1]??s[2];a&&n.add(a)}}return n}function Ls(e,t,n,r,i,o,s){return pe(e,t,n,r,i,o,s)}function Oi(e){return(e.childForFieldName("function")??e.namedChild(0))?.text.replace(/\s+/gu,"")??null}function On(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function ze(e,t){let n=nt(t,e);return n?{value:n.value,evidence:n.evidence,term:n.term,derivation:n.derivation}:null}function Bk(e,t,n){if(!e)return null;let r=e.namedChildren.find(o=>o.type!=="pair"?!1:(o.childForFieldName("key")??o.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")===t),i=r?.childForFieldName("value")??r?.namedChild(1);return ze(i,n)}function th(e,t){if(!e)return null;let n=ze(e,t);if(n?.evidence==="literal"||n?.evidence==="constant")return n;let r=e.text.trim();return/^[A-Za-z_$][\w$]*$/u.test(r)?{value:r,evidence:"identifier",term:{kind:"symbol",symbol:r}}:n}function gt(e,t="exact"){return t==="candidate"||e.some(n=>n.evidence==="expression")?"candidate":t==="derived"||e.some(n=>n.evidence==="constant")?"derived":"exact"}function $k(e){let t=e.text.trim(),n=t[0];if(n!=="'"&&n!=='"'&&n!=="`"||t.at(-1)!==n)return null;let r=t.slice(1,-1);return n==="`"&&r.includes("${")?null:r}function Gk(e){let t=new Map;return ou(e,n=>{if(n.type!=="variable_declarator")return;let r=n.childForFieldName("name")??n.namedChild(0),i=n.childForFieldName("value")??n.namedChild(1);if(!r||!i||!/^[A-Za-z_$][\w$]*$/u.test(r.text))return;let o=$k(i);o!==null&&t.set(r.text,o)}),t}function Vk(e){let t=e.parent,n=t?.parent??null;for(;n&&["as_expression","satisfies_expression","type_assertion","parenthesized_expression"].includes(n.type);)n=n.parent;if(!t||!n||n.type!=="variable_declarator")return null;let i=(n.childForFieldName("name")??n.namedChild(0))?.text??"";return/(?:handlers?|registry|routes?)$/iu.test(i)?i:null}function iu(e){return/(?:function|lambda|method)/u.test(e.type)||e.type==="arrow_function"}function nh(e){return iu(e)||e.type==="member_expression"?!0:e.type==="identifier"&&/(?:command|controller|dispatch|handle|handler)/iu.test(e.text)}function Hk(e){let t=e.parent;for(;t&&t.type!=="variable_declarator";){if(["object","object_literal","dictionary"].includes(t.type))for(let n of t.namedChildren){if(n.type==="pair"){let i=n.childForFieldName("key")??n.namedChild(0),o=n.childForFieldName("value")??n.namedChild(1),s=i?.text.replace(/^['"`]|['"`]$/gu,"");if(s&&["execute","handler","invoke","run"].includes(s)&&o&&nh(o))return t}let r=n.childForFieldName("name")??n.namedChild(0);if(r&&["execute","handler","invoke","run"].includes(r.text.replace(/^['"`]|['"`]$/gu,""))&&/(?:function|method)/u.test(n.type))return t}t=t.parent}return null}function rh(e,t=new Set){let n=e.slice(0,-1).map(r=>r.replace(/\([^)]*\)/gu,""));return n.some(r=>/^(?:prisma|drizzle)$/iu.test(r))?"orm":n.some(r=>/(?:Repository|Repo)$/u.test(r))?"repository":n.some(r=>/^(?:db|database)$/iu.test(r)||t.has(r))?"database":null}function Wk(e,t){if(Ek.has(e))return"database.read";if(Rk.has(e))return"database.write";if(!Pk.has(e))return null;let n=/\b(SELECT|INSERT|UPDATE|DELETE)\b/iu.exec(t)?.[1]?.toUpperCase();return n==="SELECT"?"database.read":n?"database.write":null}function qk(e){let t=new Set;return rn(e,"call_expression",n=>{let r=Oi(n);if(!r)return;let i=r.split(".");if(!(i.at(-1)!=="transaction"||!rh(i)))for(let o of On(n)){if(!iu(o))continue;let a=(o.childForFieldName("parameters")??o.namedChildren.find(l=>/parameters/u.test(l.type)))?.namedChildren[0],c=a?Vr(a):null;c&&t.add(c)}}),t}function Uk(e){let t=ih(e);return t?{value:t,evidence:"identifier",term:{kind:"symbol",symbol:t}}:null}function zk(e,t,n,r){if(e==="orm"&&t.length>=3)return{value:t.at(-2).replace(/\([^)]*\)/gu,""),evidence:"identifier"};if(e==="repository"){let o=t.at(-2)?.replace(/(?:Repository|Repo)$/u,"");return o?{value:o,evidence:"identifier"}:null}if(!r)return null;if(n==="from"||n==="insert")return r;let i=ih(r.value);return i?{value:i,evidence:r.evidence}:null}function ih(e){return/\b(?:from|into|update|table)\s+(?:\$\{\s*)?['"`]?([A-Za-z_$][\w$.-]*)/iu.exec(e)?.[1]??null}function ou(e,t){t(e);for(let n of e.namedChildren)ou(n,t)}function rn(e,t,n){for(let r of Gr(e,t))n(r)}var Kk=C("resolved-call-syntax",{clearGroups:[]}),su=C("resolved-call-sites",{clearGroups:[]}),Jk=C("resolved-call-sites-reference-evidence",{clearGroups:[]});function au(e,t){return su.get(e,t.symbolId,()=>sh(e,t,Xk(e,t)))}function oh(e,t){let n=[...new Map(t.map(o=>[o.symbolId,o])).values()],r=n.filter(o=>!su.has(e,o.symbolId)),i=ah(e,r);return new Map(n.map(o=>[o.symbolId,su.get(e,o.symbolId,()=>sh(e,o,i.get(o.symbolId)??[]))]))}function sh(e,t,n){let r=[],i=[],o=new Set,s=new Set;for(let a of n){o.add(a.file);let c=Kk.get(e,a.file,()=>Qk(e,a.file));if(!c){i.push({callee:t,file:a.file,line:a.startLine,reason:"ast-unavailable",candidates:0,referenceProvenance:a.provenance});continue}let l=(c.byLeaf.get(t.leaf)??[]).filter(({callNode:p})=>p.startPosition.row<=a.endLine&&p.endPosition.row>=a.startLine);if(l.length!==1){i.push({callee:t,file:a.file,line:a.startLine,reason:l.length===0?"call-not-found":"ambiguous-call",candidates:l.length,referenceProvenance:a.provenance});continue}let u=l[0],d=`${a.file}\0${u.callNode.startIndex}\0${u.callNode.endIndex}`;s.has(d)||(s.add(d),r.push({callee:t,caller:ur(B(e,a.file),u.callNode.startPosition.row),file:a.file,line:u.callNode.startPosition.row,startLine:u.callNode.startPosition.row,endLine:u.callNode.endPosition.row,targetText:u.targetNode.text,callNode:u.callNode,targetNode:u.targetNode,arguments:u.arguments,referenceProvenance:a.provenance}))}return{sites:r,unresolved:i,filesVisited:o.size}}function Xk(e,t){return ah(e,[t]).get(t.symbolId)??[]}function ah(e,t){if(!Yk(e))return new Map(t.map(r=>[r.symbolId,Dc(e,r,{semantic:!1}).map(i=>({file:i.file,startLine:i.line,endLine:i.line,provenance:i.provenance}))]));let n=new Map;for(let r of Ko(e,t.map(i=>i.symbolId))){let i=n.get(r.symbol_id)??[];i.push({file:r.relative_path,startLine:r.chunk_start,endLine:r.chunk_end,provenance:"scip-reference-chunk"}),n.set(r.symbol_id,i)}return new Map(t.map(r=>[r.symbolId,n.get(r.symbolId)??[]]))}function Yk(e){return Jk.get(e,"project",()=>!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))}function Qk(e,t){let n=M(e,t)?.rootNode;if(!n)return null;let r=new Map;for(let i of Gr(n,["call_expression","call"])){let o=i.childForFieldName("function")??i.namedChild(0);if(!o)continue;let s=Rt(o);if(!s)continue;let a=i.childForFieldName("arguments")??i.namedChildren.find(u=>u.type==="arguments"),c={callNode:i,targetNode:o,arguments:a?.namedChildren??[]},l=r.get(s);l?l.push(c):r.set(s,[c])}return{byLeaf:r}}var Zk=C("call-parameter-value-flow",{clearGroups:[]});function Mi(e,t){let n=`${t.callee.symbolId}\0${t.file}\0${t.callNode.startIndex}\0${t.callNode.endIndex}`;return Zk.get(e,n,()=>eL(e,t))}function ji(e,t){let n=new Set(t);return[...new Set(e.transfers.flatMap(r=>n.has(r.calleePosition)?[r.callerPosition]:[]))].sort((r,i)=>r-i)}function eL(e,t){let n={file:t.file,startLine:t.startLine,endLine:t.endLine};if(!t.caller)return{callee:t.callee,caller:null,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-unavailable",proof:n}))};let r=M(e,t.caller.relativePath)?.rootNode,i=r?$e(r,t.caller.startLine,t.caller.endLine):null;if(!i)return{callee:t.callee,caller:t.caller,call:n,transfers:[],unknown:t.arguments.map((c,l)=>({calleePosition:l,argumentText:c.text.trim(),reason:"caller-syntax-unavailable",proof:n}))};let o=Kt(i),s=[],a=[];return t.arguments.forEach((c,l)=>{let u=c.text.trim(),d=o.indexOf(u);d>=0?s.push({calleePosition:l,callerPosition:d,argumentText:u,proof:n}):a.push({calleePosition:l,argumentText:u,reason:"argument-not-direct-parameter",proof:n})}),{callee:t.callee,caller:t.caller,call:n,transfers:s,unknown:a}}var tL=8,nL=8;function lh(e,t,n=[]){let r=[],i=rL(e,n,r),o=i.summaries,s=iL(e,t,o,r),a=oL(e,t,r);return{observations:gL([...s.observations,...a]),bodySummaries:o.size,discriminatorSummaries:s.summaries,filesInspected:i.filesInspected,errors:r}}function rL(e,t,n){let r=new Map,i=[],o=new Map,s=a=>{if(o.has(a))return o.get(a)??null;let c=Ce(e,a);return o.set(a,c),c};for(let a of t){let c={...a,depth:0,proofSpans:[{file:a.definition.relativePath,startLine:a.definition.startLine,endLine:a.definition.endLine}]};r.set(a.definition.symbol,c),i.push(c)}for(;i.length>0;){let a=i.shift();if(!(a.depth>=tL))try{for(let c of au(e,a.definition).sites){if(!s(c.file))continue;let u=c.caller;if(!u)continue;let d=ji(Mi(e,c),a.parameterIndexes);if(d.length===0)continue;let p={definition:u,parameterIndexes:gh(d),depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]};lL(r,p)&&i.push(r.get(u.symbol))}}catch(c){n.push(`builtin.carrier body summary failed for ${a.definition.relativePath}: ${uu(c)}`)}}return{summaries:r,filesInspected:new Set(t.map(a=>a.definition.relativePath)).size}}function iL(e,t,n,r){let i=new Map,o=[],s=[];for(let a of t){if(a.action!=="http.request"||a.strength==="candidate"||a.sourceScope!=="production")continue;let c=dh(a);if(!c)continue;let l=Ce(e,a.source.file);if(!l)continue;let u=ph(l.root,a.source.startLine),d=u.find(h=>h.startPosition.row===a.source.startLine)??u[0];if(!d)continue;let p=lu(d);if(!p)continue;let f=vr(e,a.source.file,p.text);if(f.length!==1)continue;let g=n.get(f[0].symbol);if(!g)continue;let y=a.owner.symbol?B(e,a.owner.file).find(h=>h.symbol===a.owner.symbol):null;if(!y)continue;let m=uL(l,y),S=Ds(d);for(let h of g.parameterIndexes){let v=pL(l,S[h]);if(v)for(let E of fL(v)){let x=fh(E),b=mh(E);if(!x||!b)continue;let I=m.indexOf(b.text.trim());if(I>=0){let k={definition:y,carrier:c,field:x,parameterIndex:I,depth:0,proofObservationIds:[a.id],proofSpans:[a.source,{file:a.source.file,startLine:E.startPosition.row,endLine:E.endPosition.row}]},V=ch(k);i.has(V)||(i.set(V,k),o.push(k));continue}let P=nt(l,b);!P||P.evidence==="expression"||s.push(cu(l,E,"carrier.publish",c,x,P.value,[a.id]))}}}for(;o.length>0;){let a=o.shift();if(!(a.depth>=nL))try{for(let c of au(e,a.definition).sites){let l=Ce(e,c.file);if(!l)continue;let u=c.callNode,d=Ds(u)[a.parameterIndex];if(!d)continue;let p=nt(l,d);p&&p.evidence!=="expression"&&s.push(cu(l,u,"carrier.publish",a.carrier,a.field,p.value,a.proofObservationIds));let f=c.caller;if(!f)continue;let g=Mi(e,c).transfers.find(S=>S.calleePosition===a.parameterIndex)?.callerPosition;if(g===void 0)continue;let y={...a,definition:f,parameterIndex:g,depth:a.depth+1,proofSpans:[...a.proofSpans,{file:c.file,startLine:c.startLine,endLine:c.endLine}]},m=ch(y);i.has(m)||(i.set(m,y),o.push(y))}}catch(c){r.push(`builtin.carrier discriminator summary failed for ${a.definition.relativePath}: ${uu(c)}`)}}return{observations:s,summaries:i.size}}function oL(e,t,n){let r=[],i=t.filter(o=>o.action==="registry.handle"&&o.strength!=="candidate"&&o.sourceScope==="production");for(let o of t){if(o.action!=="http.handle"||o.strength==="candidate"||o.sourceScope!=="production")continue;let s=dh(o);if(!s)continue;let a=Ce(e,o.source.file);if(!a)continue;let c=ph(a.root,o.source.startLine)[0];if(c)for(let l of Ds(c).slice(1)){let u=vr(e,o.source.file,l.text);for(let d of u)try{let p=Ce(e,d.relativePath);if(!p)continue;let f=$e(p.root,d.startLine,d.endLine);if(!f)continue;ge(f,g=>{if(g.type!=="call_expression")return;let y=lu(g);if(!y)return;let m=/^([A-Za-z_$][\w$]*)\s*\[\s*([A-Za-z_$][\w$]*)\s*\]$/u.exec(y.text.trim());if(!m)return;let S=m[1],h=m[2],v=aL(e,p,d,h);if(!v)return;let E=cL(e,d.relativePath,S);for(let x of i){let b=x.keyParts.find(V=>V.name==="registry")?.value,I=x.keyParts.find(V=>V.name==="key")?.value;if(!b||!I||!E.some(V=>V.file===x.source.file&&V.binding===b))continue;let P=Ce(e,x.source.file),k=P?dL(P.root,x.source.startLine):null;!P||!k||r.push(cu(P,k,"carrier.consume",s,v,I,[o.id,x.id]))}})}catch(p){n.push(`builtin.carrier consumer analysis failed for ${d.relativePath}: ${uu(p)}`)}}}return r}function uh(e){let t=B(e.db,e.file),n=new Map;return ge(e.root,r=>{if(r.type!=="pair"||fh(r)?.toLowerCase()!=="body")return;let i=mh(r);if(!i||!/\bJSON\.stringify\s*\(/u.test(i.text))return;let o=ur(t,r.startPosition.row),s=sL(r);if(!o||!s)return;let a=Kt(s),c=new Set;mL(i,a,c);let l=n.get(o.symbol)??new Set;a.forEach((u,d)=>{u&&c.has(u)&&l.add(d)}),l.size>0&&n.set(o.symbol,l)}),t.flatMap(r=>{let i=n.get(r.symbol);return i?[{definition:r,parameterIndexes:[...i].sort((o,s)=>o-s)}]:[]})}function sL(e){let t=e.parent;for(;t;){if(/(?:function|method|lambda)/u.test(t.type)||t.type==="arrow_function")return t;t=t.parent}return null}function aL(e,t,n,r){let i=$e(t.root,n.startLine,n.endLine);if(!i)return null;let o=new RegExp(`\\.body\\??\\.${le(r)}\\b`,"u");if(o.test(i.text))return r;let s=null;if(ge(i,u=>{if(s||u.type!=="variable_declarator")return;let d=u.childForFieldName("name")??u.namedChild(0),p=u.childForFieldName("value")??u.namedChild(1);!d||!p||!new RegExp(`(?:^|[,{}])\\s*${le(r)}\\s*(?:[,}]|$)`,"u").test(d.text)||p.type==="call_expression"&&(s=lu(p)?.text??null)}),!s)return null;let a=vr(e,n.relativePath,s);if(a.length!==1)return null;let c=Ce(e,a[0].relativePath),l=c?$e(c.root,a[0].startLine,a[0].endLine):null;return l&&o.test(l.text)&&new RegExp(`\\b${le(r)}\\s*[,}]`,"u").test(l.text)?r:null}function cL(e,t,n){let r=[];for(let i of Ql(e,t,n)){let o=Ge(i.initializer);if(o.type==="call_expression")for(let s of Ds(o)){let a=s.text.trim();if(/^[A-Za-z_$][\w$]*$/u.test(a))for(let c of Ql(e,i.definition.relativePath,a))r.push({file:c.definition.relativePath,binding:c.definition.leaf})}}return[...new Map(r.map(i=>[`${i.file}\0${i.binding}`,i])).values()]}function cu(e,t,n,r,i,o,s){let c=Ls(e,t,"builtin.carrier",n,[{name:"carrier",value:r,evidence:"constant",term:{kind:"literal",value:r}},{name:"field",value:i,evidence:"literal",term:{kind:"literal",value:i}},{name:"value",value:o,evidence:"constant",term:{kind:"literal",value:o}}],"derived","http-body-registry-discriminator");return c.derivation={kind:"mechanically-derived",rule:"http-body-registry-discriminator",ruleVersion:"1",inputFactIds:[...s],sourceSpans:[c.source]},c}function dh(e){let t=e.keyParts.find(r=>r.name==="method"&&r.evidence!=="expression")?.value,n=e.keyParts.find(r=>r.name==="path"&&r.evidence!=="expression")?.value;return t&&n?`${t.toUpperCase()} ${n}`:null}function lL(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=gh([...n.parameterIndexes,...t.parameterIndexes]);return r.length===n.parameterIndexes.length&&t.depth>=n.depth?!1:(e.set(t.definition.symbol,{...n,parameterIndexes:r,depth:Math.min(n.depth,t.depth),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0)}function ch(e){return`${e.definition.symbol}\0${e.carrier}\0${e.field}\0${e.parameterIndex}`}function uL(e,t){let n=$e(e.root,t.startLine,t.endLine);return n?Kt(n):[]}function dL(e,t){let n=null;return ge(e,r=>{r.startPosition.row>t||r.endPosition.row<t||(!n||r.endIndex-r.startIndex<n.endIndex-n.startIndex)&&(n=r)}),n}function ph(e,t){let n=[];return ge(e,r=>{r.type==="call_expression"&&r.startPosition.row<=t&&r.endPosition.row>=t&&n.push(r)}),n.sort((r,i)=>r.endIndex-r.startIndex-(i.endIndex-i.startIndex))}function lu(e){return e.childForFieldName("function")??e.namedChild(0)}function Ds(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function pL(e,t){if(!t)return null;let n=t.text.trim();if(!/^[A-Za-z_$][\w$]*$/u.test(n))return Ge(t);let r=null;return ge(e.root,i=>{r||i.type!=="variable_declarator"||(i.childForFieldName("name")??i.namedChild(0))?.text.trim()!==n||(r=i.childForFieldName("value")??i.namedChild(1))}),r?Ge(r):Ge(t)}function fL(e){let t=Ge(e);return t.type==="object"?t.namedChildren.filter(n=>n.type==="pair"||n.type==="shorthand_property_identifier"):[]}function fh(e){return e.type==="shorthand_property_identifier"?e.text:(e.childForFieldName("key")??e.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"")??null}function mh(e){return e.type==="shorthand_property_identifier"?e:e.childForFieldName("value")??e.namedChild(1)}function mL(e,t,n){let r=new Set(e.text.match(/[A-Za-z_$][\w$]*/gu)??[]);for(let i of t)i&&r.has(i)&&n.add(i)}function gh(e){return[...new Set(e)].sort((t,n)=>t-n)}function gL(e){return[...new Map(e.map(t=>[t.id,t])).values()]}function uu(e){return e instanceof Error?e.message:String(e)}import{createHash as yL}from"crypto";function yh(e,t){let n=new Map;for(let o of t){if(o.action!=="http.handle"||o.sourceScope!=="production")continue;let s=n.get(o.source.file)??[];s.push(o),n.set(o.source.file,s)}let r=[],i=hL(e);for(let o of i.mounts)for(let s of o.targetFiles)for(let a of n.get(s)??[]){let c=a.keyParts.find(p=>p.name==="path");if(!c||c.evidence==="expression")continue;let l=bL(o.prefix.value,c.value),u=a.keyParts.map(p=>p.name==="path"?{name:"path",value:l,evidence:"constant",term:{kind:"concat",parts:[o.prefix.term??{kind:"literal",value:o.prefix.value},c.term??{kind:"literal",value:c.value}]},derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[a.id],sourceSpans:[a.source,{file:o.file,startLine:o.line,endLine:o.line},...o.prefix.derivation?.sourceSpans??[],...c.derivation?.sourceSpans??[]]}}:p),d=`${a.id}\0${o.file}\0${o.line}\0${l}`;r.push({...a,id:`boundary:${yL("sha256").update(d).digest("hex").slice(0,16)}`,keyParts:u,strength:"derived",evidence:"framework-mount-composition",derivation:{kind:"mechanically-derived",rule:"http.mount-prefix",ruleVersion:"1",inputFactIds:[a.id],sourceSpans:[a.source,{file:o.file,startLine:o.line,endLine:o.line}]},resolution:"unresolved"}),a.strength="candidate",a.resolution="unresolved"}return{observations:r,filesInspected:i.filesInspected,mounts:i.mounts.length}}function hL(e){let t=[],n=Me(e);for(let r of n){let i=F(e,r);if(!xL(i))continue;let o=Ce(e,r);o&&hh(o.root,s=>{if(s.type!=="call_expression")return;let a=s.childForFieldName("function")??s.namedChild(0);if(!a||!a.text.replace(/\s+/gu,"").endsWith(".use"))return;let c=vL(s);if(c.length<2)return;let l=nt(o,c[0]);if(!l||l.evidence==="expression")return;let u=SL(e,r,c[1]);u.length!==0&&t.push({file:r,line:s.startPosition.row,prefix:{value:l.value,evidence:l.evidence,term:l.term,derivation:l.derivation},targetFiles:u})})}return{mounts:t,filesInspected:n.length}}function SL(e,t,n){let r=n.text.replace(/\s+/gu,""),i=/^([A-Za-z_$][\w$]*)/u.exec(r)?.[1];if(!i)return[];let o=ue(e,t).find(c=>c.localName===i&&c.sourcePath);if(!o?.sourcePath)return[t];if(o.kind==="namespace")return[o.sourcePath];let s=o.importedName==="default"?i:o.importedName,a=An(e,o.sourcePath,s);return[...new Set(a.map(c=>c.relativePath))]}function bL(e,t){let n=e==="/"?"":e.replace(/\/+$/u,""),r=t.startsWith("/")?t:`/${t}`;return`${n}${r}`||"/"}function xL(e){return/(?:\bfrom\s*|\brequire\s*\(\s*)['"](?:express|fastify|hono|koa-router|@koa\/router)(?:[/']|")/u.test(e)}function vL(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function hh(e,t){t(e);for(let n of e.namedChildren)hh(n,t)}import{createHash as IL}from"crypto";function As(e){return[...new Map(e.map(t=>[t.observationId,t])).values()].sort((t,n)=>t.observationId.localeCompare(n.observationId))}var Ms=new Set(["DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT"]),EL=8,Sh=ce({kind:"runtime-boundary-http-roles",invalidation:te("runtime-boundary-http-roles"),serialize:CL,deserialize:FL});function vh(e,t,n){let r=n??((m,S)=>S()),i=new Map,o=[],s=[],a=new Set,c=[],l=[],u=new Map,d=new Map,p=new Map,f=m=>{if(u.has(m))return u.get(m)??null;let S=Ce(e,m);return u.set(m,S),S},g=m=>{let S=d.get(m);if(S)return S;let h=B(e,m);return d.set(m,h),h},y=(m,S)=>{let h=p.get(m.file);if(!h){let x=fe(e,m.file,m.source),b=Sh.read(e,m.file,x)??[];h={contentHash:x,roles:new Map(b.map(I=>[I.symbol,I])),dirty:!1},p.set(m.file,h)}let v=h.roles.get(S.symbol);if(v)return v;let E=wL(m,S);return h.roles.set(S.symbol,{symbol:S.symbol,...E}),h.dirty=!0,E};for(r("runtime-boundaries.http-summary.seed",()=>{for(let m of t){if(m.action!=="http.request"||!m.owner.symbol||m.evidence!=="call-expression"&&m.evidence!=="client-adapter")continue;let S=g(m.owner.file).find(x=>x.symbol===m.owner.symbol);if(!S)continue;let h=f(S.relativePath);if(!h)continue;let v=y(h,S),E={definition:S,...v,constantMethods:m.keyParts.flatMap(x=>x.name==="method"&&x.evidence!=="expression"&&Ms.has(x.value.toUpperCase())?[x.value.toUpperCase()]:[]),depth:0,proofObservationIds:[m.id],proofSpans:[m.source]};xh(i,E)&&o.push(i.get(S.symbol))}});o.length>0;){let m=o.splice(0,o.length),S=r("runtime-boundaries.http-summary.resolve-call-sites",()=>oh(e,m.map(h=>h.definition)),{batchSize:m.length});r("runtime-boundaries.http-summary.process-call-sites",()=>{for(let h of m)if(!(h.depth>=EL))try{let v=S.get(h.definition.symbolId);if(!v)continue;l.push(...v.unresolved.map(E=>RL(h,E)));for(let E of v.sites){let x=f(E.file);if(!x)continue;a.add(E.file);let b=E.callNode,I=PL(h,b,x);I&&s.push(I);let P=E.caller;if(!P)continue;let k=y(x,P),V=TL(e,h,E),xe={definition:P,pathParameterIndexes:Os([...k.pathParameterIndexes,...V.pathParameterIndexes]),methodParameterIndexes:Os([...k.methodParameterIndexes,...V.methodParameterIndexes]),constantMethods:Er([...h.constantMethods,...k.constantMethods]),depth:h.depth+1,proofObservationIds:Er([...h.proofObservationIds,...I?[I.id]:[]]),proofSpans:[...h.proofSpans,{file:E.file,startLine:E.startLine,endLine:E.endLine}]};xh(i,xe)&&o.push(i.get(P.symbol))}}catch(v){c.push(`builtin.http-summary failed for ${h.definition.relativePath}:${h.definition.startLine+1}: ${v instanceof Error?v.message:String(v)}`)}},{batchSize:m.length})}return Sh.writeBatch(e,[...p.entries()].flatMap(([m,S])=>S.dirty?[{relativePath:m,contentHash:S.contentHash,value:[...S.roles.values()].sort((h,v)=>h.symbol.localeCompare(v.symbol))}]:[])),{observations:s,frontiers:As(l),summaries:i.size,filesInspected:a.size,errors:c}}function RL(e,t){let n=Er([...e.pathParameterIndexes.length>0?["path"]:[],...e.methodParameterIndexes.length>0&&e.constantMethods.length!==1?["method"]:[]]),r=e.constantMethods.length===1?e.constantMethods[0]:"?",i=`${e.definition.symbol}\0${t.file}\0${t.line}\0${t.reason}`;return{observationId:`frontier:${IL("sha256").update(i).digest("hex").slice(0,16)}`,kind:"call-resolution",action:"http.request",strength:"candidate",source:{file:t.file,startLine:t.line,endLine:t.line},ownerShortName:null,address:`method=${r??"?"} path=?`,reason:`Compiler identity found a reference to ${e.definition.leaf}, but exact call recovery stopped with ${t.reason} (${t.candidates} syntax candidate(s)); HTTP value propagation did not cross this site.`,missingKeyParts:n.length>0?n:["call"],sourceScope:Ns(t.file)}}function PL(e,t,n){let r=Ih(t),i=e.pathParameterIndexes.flatMap(d=>{let p=nt(n,r[d]);return p&&p.evidence!=="expression"&&_L(p.value)?[{index:d,value:p}]:[]}),o=e.methodParameterIndexes.flatMap(d=>{let p=nt(n,r[d]),f=p?.value.toUpperCase();return p&&f&&p.evidence!=="expression"&&Ms.has(f)?[{index:d,value:{...p,value:f}}]:[]}),s=Er([...e.constantMethods,...o.map(d=>d.value.value)]);if(i.length!==1||s.length!==1)return null;let a=i[0].value,c=o.find(d=>d.value.value===s[0])?.value,l=[{name:"method",value:s[0],evidence:c?"constant":"literal",term:c?.term??{kind:"literal",value:s[0]},derivation:c?.derivation},{name:"path",value:a.value,evidence:"constant",term:a.term,derivation:a.derivation}],u=Ls(n,t,"builtin.http-summary","http.request",l,"derived","compiler-resolved-http-summary");return u.derivation={kind:"mechanically-derived",rule:"compiler-resolved-http-summary",ruleVersion:"1",inputFactIds:e.proofObservationIds,sourceSpans:[...e.proofSpans,u.source]},u}function wL(e,t){let n=$e(e.root,t.startLine,t.endLine);if(!n)return{pathParameterIndexes:[],methodParameterIndexes:[],constantMethods:[]};let r=Kt(n),i=new Set,o=new Set,s=new Set;return ge(n,a=>{if(a.type==="call_expression"&&((a.childForFieldName("function")??a.namedChild(0))?.text.replace(/\s+/gu,"").split(".").at(-1)??"")==="fetch"){let f=Ih(a);Bi(f[0],r,i);let g=NL(f[1],"method");if(g){Bi(g,r,o);let y=nt(e,g),m=y?.value.toUpperCase();m&&y?.evidence!=="expression"&&Ms.has(m)&&s.add(m)}else Bi(f[1],r,o)}if(a.type!=="pair")return;let c=a.childForFieldName("key")??a.namedChild(0),l=a.childForFieldName("value")??a.namedChild(1),u=c?.text.replace(/^['"`]|['"`]$/gu,"").toLowerCase();(u==="url"||u==="path"||u==="endpoint")&&Bi(l,r,i),(u==="init"||u==="requestinit"||u==="options")&&Bi(l,r,o)}),{pathParameterIndexes:r.flatMap((a,c)=>a&&i.has(a)?[c]:[]),methodParameterIndexes:r.flatMap((a,c)=>a&&o.has(a)?[c]:[]),constantMethods:[...s].sort()}}function CL(e){return e.map(t=>[encodeURIComponent(t.symbol),t.pathParameterIndexes.join(","),t.methodParameterIndexes.join(","),t.constantMethods.join(",")].join(" ")).join(`
|
|
399
|
+
`)}function FL(e){if(!e)return[];let t=[];for(let n of e.split(`
|
|
400
|
+
`)){let r=n.split(" ");if(r.length!==4)return null;let i=bh(r[1]),o=bh(r[2]),s=r[3]?r[3].split(","):[];if(i===null||o===null||s.some(a=>!Ms.has(a)))return null;t.push({symbol:decodeURIComponent(r[0]),pathParameterIndexes:i,methodParameterIndexes:o,constantMethods:s})}return t}function bh(e){if(!e)return[];let t=e.split(",").map(Number);return t.every(n=>Number.isSafeInteger(n)&&n>=0)?t:null}function TL(e,t,n){let r=Mi(e,n);return{pathParameterIndexes:ji(r,t.pathParameterIndexes),methodParameterIndexes:ji(r,t.methodParameterIndexes)}}function xh(e,t){let n=e.get(t.definition.symbol);if(!n)return e.set(t.definition.symbol,t),!0;let r=Os([...n.pathParameterIndexes,...t.pathParameterIndexes]),i=Os([...n.methodParameterIndexes,...t.methodParameterIndexes]),o=Er([...n.constantMethods,...t.constantMethods]);return r.length!==n.pathParameterIndexes.length||i.length!==n.methodParameterIndexes.length||o.length!==n.constantMethods.length||t.depth<n.depth?(e.set(t.definition.symbol,{...n,pathParameterIndexes:r,methodParameterIndexes:i,constantMethods:o,depth:Math.min(n.depth,t.depth),proofObservationIds:Er([...n.proofObservationIds,...t.proofObservationIds]),proofSpans:[...n.proofSpans,...t.proofSpans]}),!0):!1}function NL(e,t){if(!e)return null;for(let n of e.namedChildren)if(!(n.type!=="pair"||(n.childForFieldName("key")??n.namedChild(0))?.text.replace(/^['"`]|['"`]$/gu,"").toLowerCase()!==t))return n.childForFieldName("value")??n.namedChild(1);return null}function Bi(e,t,n){if(!e)return;let r=new Set(e.text.match(/[A-Za-z_$][\w$]*/gu)??[]);for(let i of t)i&&r.has(i)&&n.add(i)}function Ih(e){return(e.childForFieldName("arguments")??e.namedChildren.find(n=>n.type==="arguments"))?.namedChildren??[]}function _L(e){return e.startsWith("/")||/^https?:\/\//iu.test(e)}function Os(e){return[...new Set(e)].sort((t,n)=>t-n)}function Er(e){return[...new Set(e)].sort()}import{createHash as kL}from"crypto";function Ph(e){let t=Eh(e.filter(r=>r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim")),n=Eh(e.filter(r=>r.action==="database.write"&&r.evidence==="persistence-insert"));return e.flatMap(r=>r.action==="database.write"&&r.evidence==="persistence-insert"?du(r).flatMap(i=>{let o=t.get(i)?.[0];return o?[Rh(r,o,i,"queue.send")]:[]}):r.action==="database.read"&&r.evidence==="persistence-skip-locked-claim"?du(r).flatMap(i=>{let o=n.get(i)?.[0];return o?[Rh(r,o,i,"queue.consume")]:[]}):[])}function Eh(e){let t=new Map;for(let n of e)for(let r of du(n)){let i=t.get(r);i?i.push(n):t.set(r,[n])}for(let n of t.values())n.sort((r,i)=>r.id.localeCompare(i.id));return t}function du(e){return e.keyParts.filter(t=>t.name==="resource").map(t=>t.value)}function Rh(e,t,n,r){let i=`database:${n}`,o=r==="queue.send"?"database-queue-insert":"database-queue-skip-locked-claim",s=[e.id,r,i,o].join("\0");return{...e,id:`boundary:${kL("sha256").update(s).digest("hex").slice(0,16)}`,extractor:"builtin.database-queue",action:r,keyParts:[{name:"address",value:i,evidence:"identifier",term:{kind:"symbol",symbol:n},derivation:{kind:"mechanically-derived",rule:"database-work-queue.resource",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]}}],evidence:o,strength:"derived",protocol:"queue",role:r==="queue.send"?"producer":"consumer",derivation:{kind:"mechanically-derived",rule:"database-work-queue.insert-skip-locked",ruleVersion:"1",inputFactIds:[e.id,t.id],sourceSpans:[e.source,t.source]},valuePrecision:"symbolic",resolution:"unresolved"}}var Vi="runtime-boundaries-v19",AL=DL(import.meta.url),Y=AL("typescript"),OL=new Set([Y.SyntaxKind.WhitespaceTrivia,Y.SyntaxKind.NewLineTrivia,Y.SyntaxKind.SingleLineCommentTrivia,Y.SyntaxKind.MultiLineCommentTrivia]),ML=new Set([Y.SyntaxKind.NoSubstitutionTemplateLiteral,Y.SyntaxKind.TemplateHead,Y.SyntaxKind.TemplateMiddle,Y.SyntaxKind.TemplateTail]),$s=[{id:"http.method-path",protocol:"http",producerActions:["http.request"],consumerActions:["http.handle"],keyNames:["method","path"],traversable:!0},{id:"registry.identity-key",protocol:"registry",producerActions:["registry.dispatch"],consumerActions:["registry.handle"],keyNames:["registry","key"],traversable:!0},{id:"registry.capability-key",protocol:"registry",producerActions:["registry.reference"],consumerActions:["registry.handle"],keyNames:["key"],traversable:!0,requireUniqueConsumer:!0},{id:"queue.address",protocol:"queue",producerActions:["queue.send"],consumerActions:["queue.consume"],keyNames:["address"],traversable:!0},{id:"carrier.discriminator",protocol:"carrier",producerActions:["carrier.publish"],consumerActions:["carrier.consume"],keyNames:["carrier","field","value"],traversable:!0},{id:"resource.identity",protocol:"database",producerActions:["database.write"],consumerActions:["database.read"],keyNames:["resource"],traversable:!1},{id:"framework.effect-httpapi-operation",protocol:"framework",producerActions:[],consumerActions:["framework.handle"],declarationActions:["framework.declare"],keyNames:["adapter","group","operation"],traversable:!0,linkFrom:"declaration",requireUniquePair:!0}],jL=64,_h="builtin.http-summary",Gs={HTTP_HANDLE:"http.handle",HTTP_REQUEST:"http.request",REGISTRY_HANDLE:"registry.handle"},pu=new Set(Object.values(Gs));async function BL(e,t={}){let n=Me(e),r=new Set(n),i=new Set((t.affectedFiles??[]).map(sD)),o=t.previousGraph?.fileCoverage,s=i.size>0&&t.previousGraph?.extractorVersion===Vi&&o!==void 0&&o.length===t.previousGraph.coverage.filesScanned,a=s?o.filter(L=>r.has(L.file)&&!i.has(L.file)):[],c=new Set(a.flatMap(L=>L.observationIds)),l=s?t.previousGraph.observations.filter(L=>c.has(L.id)&&r.has(L.source.file)):[],u=s?n.filter(L=>i.has(L)):n,d=[],p=o?.reduce((L,$)=>L+$.observationIds.length,0)??0,f=performance.now(),g=await eD(e,u,t.profileSpan);Mt(d,"direct-extraction",f,u.length,g.observations.length,{filesVisited:u.length,filesReused:a.length,factsReused:l.length,factsInvalidated:Math.max(0,p-l.length)});let y=[...a,...g.fileCoverage].sort((L,$)=>L.file.localeCompare($.file)),m=oD(y),S=y.flatMap(L=>L.extractionErrors),h=$i([...l,...g.observations]);if(s&&!t.forceDerivedRebuild&&t.previousGraph&&$L(o,g.fileCoverage,i)&&(!UL(e,t.previousGraph,i)||JL(o,g.fileCoverage,i)&&!XL(t.previousGraph,i))){for(let $ of t.previousGraph.coverage.extractors)m.has($.id)||m.set($.id,$);let L=QL(t.previousGraph.coverage.phases);return d.push(...L),{...t.previousGraph,observations:t.previousGraph.observations,relationGroups:t.previousGraph.relationGroups,links:t.previousGraph.links,frontiers:t.previousGraph.frontiers,coverage:{filesScanned:n.length,filesWithAst:y.filter($=>$.hasAst).length,filesWithoutAst:y.filter($=>!$.hasAst).length,filesReused:a.length,extractors:[...m.values()],extractionErrors:t.previousGraph.coverage.extractionErrors,phases:d},fileCoverage:y}}let v=$i([...h,...Ph(h)]),E=s&&t.previousGraph!==void 0?GL(t.previousGraph,o,g.fileCoverage,i,h):{reuse:!1,shapeUnchanged:!1,proofFilesUnchanged:!1,seedUnchanged:!1},x=E.reuse;t.profileSpan?.("runtime-boundaries.http-summary.reuse-decision",()=>{},E),f=performance.now();let b;if(x){let L=t.previousGraph.coverage.phases?.find(Q=>Q.id==="http-summary"),$=t.previousGraph.coverage.extractors.find(Q=>Q.id==="builtin.wrapper");b={observations:t.previousGraph.observations.filter(Q=>Q.extractor===_h),frontiers:t.previousGraph.frontiers.filter(Q=>Q.kind==="call-resolution"&&Q.action===Gs.HTTP_REQUEST),summaries:0,filesInspected:L?.filesVisited??$?.applicableFiles??0,errors:t.previousGraph.coverage.extractionErrors.filter(Q=>Q.startsWith("builtin.http-summary failed"))},Mt(d,"http-summary",f,v.length,b.observations.length,{filesVisited:0,filesReused:b.filesInspected,factsReused:b.observations.length+b.frontiers.length,factsInvalidated:0}),$&&m.set($.id,$)}else b=vh(e,v,t.profileSpan),Mt(d,"http-summary",f,v.length,b.observations.length,{filesVisited:b.filesInspected}),m.set("builtin.wrapper",{id:"builtin.wrapper",applicableFiles:b.filesInspected,observations:b.observations.length,errors:b.errors.length});S.push(...b.errors);let I=$i([...v,...b.observations]);f=performance.now();let P=yh(e,I);Mt(d,"http-mount",f,I.length,P.observations.length,{filesVisited:P.filesInspected});let k=$i([...I,...P.observations]);f=performance.now();let V=x&&t.previousGraph!==void 0&&VL(t.previousGraph,o,g.fileCoverage,i),xe;if(V){let L=t.previousGraph.coverage.phases?.find(Q=>Q.id==="carrier"),$=t.previousGraph.coverage.extractors.find(Q=>Q.id==="builtin.carrier");xe={observations:t.previousGraph.observations.filter(Q=>Q.extractor==="builtin.carrier"),bodySummaries:$?.applicableFiles??0,discriminatorSummaries:0,filesInspected:L?.filesVisited??0,errors:t.previousGraph.coverage.extractionErrors.filter(Q=>Q.startsWith("builtin.carrier"))},Mt(d,"carrier",f,k.length,xe.observations.length,{filesVisited:0,filesReused:xe.filesInspected,factsReused:xe.observations.length,factsInvalidated:0}),$&&m.set($.id,$)}else xe=lh(e,k,y.flatMap(L=>L.bodySummaries??[])),Mt(d,"carrier",f,k.length,xe.observations.length,{filesVisited:xe.filesInspected}),m.set("builtin.carrier",{id:"builtin.carrier",applicableFiles:xe.bodySummaries,observations:xe.observations.length,errors:xe.errors.length});S.push(...xe.errors);let on=$i([...k,...xe.observations]);f=performance.now();let jn=aD(on);Mt(d,"relations",f,on.length,jn.length),f=performance.now();let fu=lD(on,jn);Mt(d,"links",f,jn.length,fu.length),uD(on,jn),f=performance.now();let mu=As([...dD(on,jn),...b.frontiers]);return Mt(d,"frontiers",f,on.length,mu.length),{schemaVersion:2,extractorVersion:Vi,observations:on,relationGroups:jn,links:fu,frontiers:mu,coverage:{filesScanned:n.length,filesWithAst:y.filter(L=>L.hasAst).length,filesWithoutAst:y.filter(L=>!L.hasAst).length,...s?{filesReused:a.length}:{},extractors:[...m.values()],extractionErrors:S,phases:d},fileCoverage:y}}function $L(e,t,n){if(!e)return!1;let r=e.filter(o=>n.has(o.file)).filter(wh).map(Ch).sort((o,s)=>o.file.localeCompare(s.file)),i=t.filter(wh).map(Ch).sort((o,s)=>o.file.localeCompare(s.file));return JSON.stringify(r)===JSON.stringify(i)}function wh(e){return e.observationIds.length>0||e.extractionErrors.length>0}function Ch(e){let{syntaxHash:t,shapeHash:n,bodySummaries:r,...i}=e;return i}function GL(e,t,n,r,i){let o=WL(t,n,r),s=qL(e),c=![...kh(t,n)].some(p=>s.has(p)),l=new Set((t??[]).filter(p=>r.has(p.file)).flatMap(p=>p.observationIds)),u=new Set(n.flatMap(p=>p.observationIds)),d=Fh(e.observations,l)===Fh(i,u);return{reuse:o&&c&&d,shapeUnchanged:o,proofFilesUnchanged:c,seedUnchanged:d}}function kh(e,t){let n=new Map(e?.map(r=>[r.file,r.syntaxHash])??[]);return new Set(t.filter(r=>r.syntaxHash===void 0||n.get(r.file)!==r.syntaxHash).map(r=>r.file))}function VL(e,t,n,r){if(!t)return!1;let i=t.filter(c=>r.has(c.file)).map(({file:c,bodySummaries:l})=>({file:c,bodySummaries:l??[]})).sort((c,l)=>c.file.localeCompare(l.file)),o=n.map(({file:c,bodySummaries:l})=>({file:c,bodySummaries:l??[]})).sort((c,l)=>c.file.localeCompare(l.file));if(JSON.stringify(i)!==JSON.stringify(o))return!1;let s=kh(t,n),a=HL(e,"builtin.carrier");return![...s].some(c=>a.has(c))}function HL(e,t){let n=new Set;for(let r of e.observations)if(r.extractor===t){n.add(r.source.file);for(let i of r.derivation.sourceSpans)n.add(i.file)}return n}function WL(e,t,n){if(!e)return!1;let r=new Map(e.filter(i=>n.has(i.file)).map(i=>[i.file,i.shapeHash]));return t.length===n.size&&t.every(i=>i.shapeHash!==void 0&&r.get(i.file)===i.shapeHash)}function qL(e){let t=new Set;for(let n of e.observations)if(n.extractor===_h){t.add(n.source.file);for(let r of n.derivation.sourceSpans)t.add(r.file)}for(let n of e.frontiers)n.kind==="call-resolution"&&n.action===Gs.HTTP_REQUEST&&n.source&&t.add(n.source.file);return t}function Fh(e,t){return JSON.stringify(e.filter(n=>t.has(n.id)&&n.action===Gs.HTTP_REQUEST&&n.owner.symbol!==null&&(n.evidence==="call-expression"||n.evidence==="client-adapter")).map(n=>({ownerSymbol:n.owner.symbol,evidence:n.evidence,methods:n.keyParts.filter(r=>r.name==="method"&&r.evidence!=="expression").map(r=>r.value.toUpperCase()).sort()})).sort((n,r)=>`${n.ownerSymbol}\0${n.evidence}\0${n.methods.join(",")}`.localeCompare(`${r.ownerSymbol}\0${r.evidence}\0${r.methods.join(",")}`)))}function UL(e,t,n){let r=zL(t),i=KL(t);if([...n].some(a=>r.has(a)))return!0;if(i.size===0||n.size===0)return!1;if(!!!e.get("SELECT 1 AS present FROM mentions WHERE role != 1 LIMIT 1"))return!0;let s=[...n];for(let a=0;a<s.length;a+=750){let c=s.slice(a,a+750),l=c.map(()=>"?").join(",");if(e.all(`SELECT DISTINCT global_symbol.symbol
|
|
401
|
+
FROM mentions mention
|
|
402
|
+
JOIN chunks reference_chunk ON reference_chunk.id = mention.chunk_id
|
|
403
|
+
JOIN documents reference_document ON reference_document.id = reference_chunk.document_id
|
|
404
|
+
JOIN global_symbols global_symbol ON global_symbol.id = mention.symbol_id
|
|
405
|
+
WHERE mention.role != 1
|
|
406
|
+
AND reference_document.relative_path IN (${l})`,...c).some(d=>i.has(d.symbol)))return!0}return!1}function zL(e){let t=new Set;for(let n of e.observations)if(pu.has(n.action)){t.add(n.source.file);for(let r of n.derivation?.sourceSpans??[])t.add(r.file)}for(let n of e.frontiers)!n.action||!pu.has(n.action)||!n.source||t.add(n.source.file);return t}function KL(e){return new Set(e.observations.flatMap(t=>pu.has(t.action)&&t.owner.symbol?[t.owner.symbol]:[]))}function JL(e,t,n){if(!e)return!1;let r=new Map(e.filter(i=>n.has(i.file)).map(i=>[i.file,i.syntaxHash]));return t.length===n.size&&t.every(i=>i.syntaxHash!==void 0&&r.get(i.file)===i.syntaxHash)}function XL(e,t){let n=YL(e);return[...t].some(r=>n.has(r))}function YL(e){let t=new Set;for(let n of e.observations){t.add(n.source.file);for(let r of n.derivation?.sourceSpans??[])t.add(r.file)}for(let n of e.frontiers)n.source&&t.add(n.source.file);return t}function QL(e){return(e??[]).filter(t=>t.id!=="direct-extraction").map(t=>({...t,durationMs:0,filesVisited:0,filesReused:t.filesVisited??0,factsReused:t.outputFacts,factsInvalidated:0}))}function Mt(e,t,n,r,i,o={}){e.push({id:t,durationMs:Math.max(0,performance.now()-n),inputFacts:r,outputFacts:i,...o})}var ZL=256;async function eD(e,t,n){let r=[],i=[],o=n??((d,p)=>p()),s=[],a=[],c=new Map,l=d=>{let p=c.get(d);if(p!==void 0)return p;let f=fe(e,d,yo(e,d));return c.set(d,f),f},u=0;for(let d of t){u+=1,u>=ZL&&(u=0,await LL());let p=o("runtime-boundaries.file.read",()=>yo(e,d)),f=fe(e,d,p);c.set(d,f);let g=o("runtime-boundaries.file.direct-product",()=>{let x=Nh.read(e,d,f);if(!x||x.extractorVersion!==Vi)return null;for(let b of x.deps)if(l(b.path)!==b.contentHash)return null;return x});if(g){r.push(...g.observations),i.push(g.coverage);continue}let y=o("runtime-boundaries.file.supports",()=>ru.filter(x=>x.supports(p))),m=/\bJSON\.stringify\s*\(/u.test(p)&&/\bbody\s*:/u.test(p),S=o("runtime-boundaries.file.hashes",()=>{let x=Th.read(e,d,f);if(x)return x;let b=tD(d,p);return s.push({relativePath:d,contentHash:f,value:b}),b}),h=new Set,v=[],E=np(x=>h.add(x),()=>{let x=y.length>0||m?Ce(e,d,p,n):null,b={file:d,hasAst:x!==null||iD(d,p),syntaxHash:S.syntaxHash,shapeHash:S.shapeHash,bodySummaries:x&&m?uh(x):[],observationIds:[],extractors:[],extractionErrors:[]};if(x)for(let I of y){let P={id:I.id,applicableFiles:1,observations:0,errors:0};try{let k=rD(n,`runtime-boundaries.extractor.${I.id}`,d,()=>I.extract(x));P.observations=k.length,v.push(...k),b.observationIds.push(...k.map(V=>V.id))}catch(k){P.errors=1,b.extractionErrors.push(`${I.id} failed for ${d}: ${k instanceof Error?k.message:String(k)}`)}b.extractors.push(P)}return b});r.push(...v),i.push(E),E.extractionErrors.length===0&&(h.delete(d),a.push({relativePath:d,contentHash:f,value:{extractorVersion:Vi,deps:[...h].sort().map(x=>({path:x,contentHash:l(x)})),observations:v,coverage:E}}))}return s.length>0&&Th.writeBatch(e,s),a.length>0&&Nh.writeBatch(e,a),{observations:r,fileCoverage:i}}var Th=ce({kind:"runtime-boundary-source-hashes",invalidation:te("runtime-boundary-source-hashes"),serialize:e=>JSON.stringify(e),deserialize:e=>{try{let t=JSON.parse(e);return typeof t.syntaxHash=="string"&&typeof t.shapeHash=="string"?{syntaxHash:t.syntaxHash,shapeHash:t.shapeHash}:null}catch{return null}}}),Nh=ce({kind:"runtime-boundary-direct-extraction",invalidation:te("runtime-boundary-direct-extraction"),serialize:e=>JSON.stringify(e),deserialize:e=>{try{let t=JSON.parse(e);return typeof t.extractorVersion!="string"||!Array.isArray(t.deps)||!Array.isArray(t.observations)||typeof t.coverage!="object"||t.coverage===null||!t.deps.every(n=>typeof n=="object"&&n!==null&&typeof n.path=="string"&&typeof n.contentHash=="string")?null:t}catch{return null}}});function tD(e,t){if(!/\.(?:[cm]?[jt]sx?)$/iu.test(e)){let l=Gi("sha256").update(t).digest("hex");return{syntaxHash:l,shapeHash:l}}let n=/\.[jt]sx$/iu.test(e)?Y.LanguageVariant.JSX:Y.LanguageVariant.Standard,r=Y.createScanner(Y.ScriptTarget.Latest,!1,n,t),i=Gi("sha256"),o=Gi("sha256"),s=[],a=[0];for(let l=0;l<t.length;l+=1)t.charCodeAt(l)===10&&a.push(l+1);let c=0;for(let l=r.scan();l!==Y.SyntaxKind.EndOfFileToken;l=r.scan()){if(l===Y.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)===0&&(l=r.reScanTemplateToken(!1)),OL.has(l))continue;let u=r.getTokenText();for(;a[c+1]!==void 0&&a[c+1]<=r.getTokenPos();)c+=1;i.update(String(l)),i.update("\0"),i.update(u),i.update("\0"),i.update(String(c)),i.update("\0"),o.update(String(l)),o.update("\0"),!ML.has(l)&&!nD(l,u)&&o.update(u),o.update("\0"),o.update(String(c)),o.update("\0"),l===Y.SyntaxKind.TemplateHead?s.push(0):l===Y.SyntaxKind.TemplateTail?s.pop():l===Y.SyntaxKind.OpenBraceToken&&s.length>0?s[s.length-1]+=1:l===Y.SyntaxKind.CloseBraceToken&&s.length>0&&s.at(-1)>0&&(s[s.length-1]-=1)}return{syntaxHash:i.digest("hex"),shapeHash:o.digest("hex")}}function nD(e,t){if(e!==Y.SyntaxKind.StringLiteral||t.length<2)return!1;let n=t.slice(1,-1);return n.startsWith("/")||n.includes("://")}function rD(e,t,n,r){return e?e(t,r,{file:n}):r()}function iD(e,t){return t?Xe(e)?/<script\b/iu.test(t):oe(e)!==null:!1}function oD(e){let t=new Map(ru.map(n=>[n.id,{id:n.id,applicableFiles:0,observations:0,errors:0}]));for(let n of e)for(let r of n.extractors){let i=t.get(r.id);i&&(i.applicableFiles+=r.applicableFiles,i.observations+=r.observations,i.errors+=r.errors)}return t}function sD(e){return e.replaceAll("\\","/").replace(/^\.\//u,"")}function aD(e){let t=new Map;for(let n of $s){let r=new Set([...n.producerActions,...n.consumerActions,...n.declarationActions??[]]);for(let i of e){if(!r.has(i.action)||i.strength==="candidate")continue;let o=fD(i,n.keyNames);if(!o)continue;let s=o.map(d=>`${d.name}=${Dh(d.name,d.value)}`).join("\0"),a=i.sourceScope==="production"?"production":i.sourceScope,c=`${n.id}\0${a}\0${s}`,l=`boundary-group:${Gi("sha256").update(c).digest("hex").slice(0,16)}`,u=t.get(l)??{id:l,protocol:n.protocol,joinRule:n.id,normalizedKey:s,keyParts:o,producerIds:[],consumerIds:[],declarationIds:[],derivation:{kind:"mechanically-derived",rule:n.id,ruleVersion:"2",inputFactIds:[],sourceSpans:[]}};n.producerActions.includes(i.action)&&u.producerIds.push(i.id),n.consumerActions.includes(i.action)&&u.consumerIds.push(i.id),n.declarationActions?.includes(i.action)&&u.declarationIds.push(i.id),u.derivation.inputFactIds.push(i.id),u.derivation.sourceSpans.push(i.source),t.set(l,u)}}return[...t.values()].map(cD).sort(gD)}function cD(e){return{...e,producerIds:js(e.producerIds),consumerIds:js(e.consumerIds),declarationIds:js(e.declarationIds),derivation:{...e.derivation,inputFactIds:js(e.derivation.inputFactIds),sourceSpans:[...new Map(e.derivation.sourceSpans.map(t=>[`${t.file}:${t.startLine}:${t.endLine}`,t])).values()]}}}function lD(e,t){let n=new Map(e.map(i=>[i.id,i])),r=new Map;for(let i of t){let o=$s.find(a=>a.id===i.joinRule);if(!o?.traversable)continue;let s=o.linkFrom==="declaration"?i.declarationIds:i.producerIds;if(!(s.length===0||i.consumerIds.length===0)&&!(o.requireUniquePair&&(s.length!==1||i.consumerIds.length!==1))&&!(o.requireUniqueConsumer&&i.consumerIds.length!==1)&&!(s.length*i.consumerIds.length>jL))for(let a of s)for(let c of i.consumerIds){let l=n.get(a),u=n.get(c);if(!l||!u||mD(l,u))continue;let d=l.strength==="derived"||u.strength==="derived"?"derived":"exact",p=`${i.joinRule}\0${a}\0${c}`,f={id:`boundary-link:${Gi("sha256").update(p).digest("hex").slice(0,16)}`,from:a,to:c,joinRule:i.joinRule,matchedKeyParts:i.keyParts,strength:d,derivation:{kind:"mechanically-derived",rule:i.joinRule,ruleVersion:"2",inputFactIds:[a,c],sourceSpans:[l.source,u.source]}};r.set(f.id,f)}}return[...r.values()].sort(yD)}function uD(e,t){let n=new Set(t.filter(Lh).flatMap(Bs)),r=new Set(t.filter(pD).flatMap(Bs));for(let i of e)i.resolution=n.has(i.id)?"locally-linked":r.has(i.id)?"ambiguous":"unresolved"}function dD(e,t){let n=new Set(e.filter(o=>o.strength!=="candidate").map(o=>`${o.action}\0${o.source.file}\0${o.source.startLine}\0${o.source.endLine}`)),r=new Set(t.flatMap(Bs)),i=new Set(t.filter(Lh).flatMap(Bs));return e.filter(o=>o.sourceScope==="production").filter(o=>o.strength!=="candidate"||!n.has(`${o.action}\0${o.source.file}\0${o.source.startLine}\0${o.source.endLine}`)).filter(o=>!i.has(o.id)).map(o=>{let s=o.keyParts.filter(c=>c.evidence==="expression"||c.value.length===0).map(c=>c.name),a=s.length>0?`${o.extractor} observed ${o.action}, but ${s.join(", ")} remained symbolic or unknown.`:o.resolution==="ambiguous"?`${o.extractor} established the address for ${o.action}, but more than one indexed peer has the same runtime key.`:r.has(o.id)?`${o.extractor} established the address for ${o.action}, but the indexed production scope contains no counterpart role in that relation group.`:`${o.extractor} observed ${o.action}, but no supported factorization rule could establish its addressed relation.`;return{observationId:o.id,reason:a,missingKeyParts:s,sourceScope:o.sourceScope}}).sort((o,s)=>o.observationId.localeCompare(s.observationId))}function Bs(e){return[...e.producerIds,...e.consumerIds,...e.declarationIds]}function Lh(e){let t=$s.find(r=>r.id===e.joinRule);if(!t)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length===0||e.consumerIds.length===0?!1:!t.requireUniquePair||n.length===1&&e.consumerIds.length===1}function pD(e){let t=$s.find(r=>r.id===e.joinRule);if(!t?.requireUniquePair)return!1;let n=t.linkFrom==="declaration"?e.declarationIds:e.producerIds;return n.length>0&&e.consumerIds.length>0&&(n.length!==1||e.consumerIds.length!==1)}function fD(e,t){let n=[];for(let r of t){let i=e.keyParts.find(o=>o.name===r);if(!i||i.evidence==="expression"||i.value.length===0)return null;n.push({...i,value:Dh(r,i.value)})}return n}function Dh(e,t){if(e==="method")return t.toUpperCase();if(e!=="path")return t;let n=t.startsWith("/")?t:`/${t}`;return n.length>1?n.replace(/\/+$/u,""):n}function mD(e,t){return e.source.file===t.source.file&&e.source.startLine===t.source.startLine}function $i(e){return[...new Map(e.map(t=>[t.id,t])).values()].sort((t,n)=>t.source.file.localeCompare(n.source.file)||t.source.startLine-n.source.startLine||t.action.localeCompare(n.action))}function js(e){return[...new Set(e)].sort()}function gD(e,t){return e.joinRule.localeCompare(t.joinRule)||e.normalizedKey.localeCompare(t.normalizedKey)}function yD(e,t){return e.joinRule.localeCompare(t.joinRule)||e.from.localeCompare(t.from)||e.to.localeCompare(t.to)}import hD from"better-sqlite3";var Hs="scip_query_runtime_boundaries",Mn="scip_query_runtime_observations",Ws="scip_query_runtime_relation_groups",qs="scip_query_runtime_relation_participants";function SD(e,t){let n=new hD(e);try{n.exec(`
|
|
407
|
+
CREATE TABLE IF NOT EXISTS ${Hs} (
|
|
408
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
409
|
+
schema_version INTEGER NOT NULL,
|
|
410
|
+
extractor_version TEXT NOT NULL,
|
|
411
|
+
payload TEXT NOT NULL
|
|
412
|
+
)
|
|
413
|
+
`),xD(n),n.transaction(()=>{n.prepare(`INSERT OR REPLACE INTO ${Hs} (singleton, schema_version, extractor_version, payload) VALUES (1, ?, ?, ?)`).run(t.schemaVersion,t.extractorVersion,JSON.stringify(t)),n.prepare(`DELETE FROM ${Mn}`).run(),n.prepare(`DELETE FROM ${qs}`).run(),n.prepare(`DELETE FROM ${Ws}`).run();let r=n.prepare(`INSERT INTO ${Mn}
|
|
414
|
+
(id, protocol, action, role, strength, source_scope, resolution, file, start_line, end_line, owner_symbol, payload)
|
|
415
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);for(let s of t.observations)r.run(s.id,s.protocol,s.action,s.role,s.strength,s.sourceScope,s.resolution,s.source.file,s.source.startLine,s.source.endLine,s.owner.symbol,JSON.stringify(s));let i=n.prepare(`INSERT INTO ${Ws} (id, protocol, join_rule, normalized_key, payload) VALUES (?, ?, ?, ?, ?)`),o=n.prepare(`INSERT INTO ${qs} (group_id, observation_id, participant_role) VALUES (?, ?, ?)`);for(let s of t.relationGroups){i.run(s.id,s.protocol,s.joinRule,s.normalizedKey,JSON.stringify(s));for(let a of s.producerIds)o.run(s.id,a,"producer");for(let a of s.consumerIds)o.run(s.id,a,"consumer");for(let a of s.declarationIds)o.run(s.id,a,"declaration")}})()}finally{n.close()}}function bD(e,t={}){if(!vD(e,Mn))return Ah(e)?.observations??[];let n=[],r=[];return Vs(n,r,"protocol",t.protocols),Vs(n,r,"action",t.actions),Vs(n,r,"source_scope",t.sourceScopes),Vs(n,r,"file",t.files),e.all(`SELECT payload FROM ${Mn}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY file, start_line, id`,...r).flatMap(o=>ID(o.payload))}function xD(e){e.exec(`
|
|
416
|
+
CREATE TABLE IF NOT EXISTS ${Mn} (
|
|
417
|
+
id TEXT PRIMARY KEY,
|
|
418
|
+
protocol TEXT NOT NULL,
|
|
419
|
+
action TEXT NOT NULL,
|
|
420
|
+
role TEXT NOT NULL,
|
|
421
|
+
strength TEXT NOT NULL,
|
|
422
|
+
source_scope TEXT NOT NULL,
|
|
423
|
+
resolution TEXT NOT NULL,
|
|
424
|
+
file TEXT NOT NULL,
|
|
425
|
+
start_line INTEGER NOT NULL,
|
|
426
|
+
end_line INTEGER NOT NULL,
|
|
427
|
+
owner_symbol TEXT,
|
|
428
|
+
payload TEXT NOT NULL
|
|
429
|
+
);
|
|
430
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_observations_protocol_action_scope
|
|
431
|
+
ON ${Mn}(protocol, action, source_scope);
|
|
432
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_observations_file_line
|
|
433
|
+
ON ${Mn}(file, start_line);
|
|
434
|
+
|
|
435
|
+
CREATE TABLE IF NOT EXISTS ${Ws} (
|
|
436
|
+
id TEXT PRIMARY KEY,
|
|
437
|
+
protocol TEXT NOT NULL,
|
|
438
|
+
join_rule TEXT NOT NULL,
|
|
439
|
+
normalized_key TEXT NOT NULL,
|
|
440
|
+
payload TEXT NOT NULL
|
|
441
|
+
);
|
|
442
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_groups_protocol_key
|
|
443
|
+
ON ${Ws}(protocol, join_rule, normalized_key);
|
|
444
|
+
|
|
445
|
+
CREATE TABLE IF NOT EXISTS ${qs} (
|
|
446
|
+
group_id TEXT NOT NULL,
|
|
447
|
+
observation_id TEXT NOT NULL,
|
|
448
|
+
participant_role TEXT NOT NULL,
|
|
449
|
+
PRIMARY KEY (group_id, observation_id, participant_role)
|
|
450
|
+
);
|
|
451
|
+
CREATE INDEX IF NOT EXISTS idx_runtime_participants_observation
|
|
452
|
+
ON ${qs}(observation_id, participant_role);
|
|
453
|
+
`)}function vD(e,t){return!!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",t)}function Vs(e,t,n,r){!r||r.length===0||(e.push(`${n} IN (${r.map(()=>"?").join(", ")})`),t.push(...r))}function ID(e){try{return[JSON.parse(e)]}catch{return[]}}function Ah(e){if(!e.get("SELECT name FROM sqlite_master WHERE type = 'table' AND name = ?",Hs))return null;let n=e.get(`SELECT schema_version, payload FROM ${Hs} WHERE singleton = 1`);if(!n||n.schema_version!==2)return null;try{let r=JSON.parse(n.payload);return r.schemaVersion===2&&Array.isArray(r.observations)&&Array.isArray(r.relationGroups)&&Array.isArray(r.links)?r:null}catch{return null}}export{jt as a,Ru as b,Rr as c,Ui as d,Pr as e,FD as f,Vh as g,H as h,Vt as i,Z as j,ln as k,Ae as l,Ie as m,ne as n,un as o,ae as p,RS as q,st as r,ee as s,j as t,T as u,PS as v,wS as w,dn as x,ED as y,RD as z,Ke as A,wA as B,Fr as C,AS as D,OS as E,CA as F,FA as G,$S as H,qS as I,ud as J,TA as K,eo as L,Ee as M,ro as N,hd as O,Sd as P,HA as Q,bd as R,xd as S,WA as T,JA as U,St as V,Wn as W,me as X,D as Y,W as Z,qi as _,va as $,ao as aa,co as ba,Ia as ca,dO as da,ba as ea,pO as fa,fO as ga,Ra as ha,bn as ia,lx as ja,zn as ka,fo as la,ux as ma,Jd as na,Or as oa,Ht as pa,gx as qa,yx as ra,hx as sa,Kn as ta,DO as ua,AO as va,Jn as wa,yt as xa,Ki as ya,ND as za,w as Aa,_D as Ba,kD as Ca,LD as Da,Nu as Ea,Ji as Fa,AD as Ga,sn as Ha,Bt as Ia,GD as Ja,_u as Ka,qh as La,VD as Ma,Bn as Na,WD as Oa,C as Pa,rt as Qa,$t as Ra,rS as Sa,U as Ta,fe as Ua,ht as Va,eA as Wa,tA as Xa,nA as Ya,rA as Za,iA as _a,oA as $a,Re as ab,Zd as bb,cp as cb,Zx as db,Yn as eb,at as fb,qt as gb,Be as hb,Gt as ib,Zu as jb,ed as kb,td as lb,bS as mb,pA as nb,z as ob,fA as pb,Yi as qb,ce as rb,tp as sb,te as tb,F as ub,JO as vb,jr as wb,_x as xb,XO as yb,YO as zb,le as Ab,Ua as Bb,PM as Cb,wM as Db,za as Eb,oe as Fb,Xe as Gb,Gr as Hb,ge as Ib,$e as Jb,Ip as Kb,BM as Lb,$M as Mb,M as Nb,ij as Ob,he as Pb,VI as Qb,HI as Rb,Kr as Sb,zI as Tb,KI as Ub,iM as Vb,ap as Wb,Me as Xb,oM as Yb,f0 as Zb,gR as _b,$o as $b,WB as ac,Ct as bc,ue as cc,e$ as dc,t$ as ec,l$ as fc,cr as gc,u$ as hc,d$ as ic,p$ as jc,WP as kc,Vo as lc,Qe as mc,Se as nc,Xt as oc,be as pc,Fn as qc,Ec as rc,lr as sc,$f as tc,m$ as uc,g$ as vc,y$ as wc,h$ as xc,Rc as yc,Pc as zc,V$ as Ac,B as Bc,H$ as Cc,gw as Dc,W$ as Ec,q$ as Fc,U$ as Gc,xw as Hc,ur as Ic,z$ as Jc,vq as Kc,Py as Lc,Uo as Mc,_c as Nc,xG as Oc,nG as Pc,Mw as Qc,rG as Rc,iG as Sc,GG as Tc,VG as Uc,HG as Vc,Ko as Wc,fG as Xc,mG as Yc,Nc as Zc,kc as _c,im as $c,sm as ad,Lc as bd,jG as cd,pC as dd,fC as ed,BG as fd,mC as gd,gC as hd,XG as id,Dc as jd,t1 as kd,dm as ld,n1 as md,pm as nd,f1 as od,kC as pd,Oc as qd,m1 as rd,AC as sd,OC as td,g1 as ud,y1 as vd,h1 as wd,Nn as xd,Tt as yd,ke as zd,Nt as Ad,_t as Bd,w1 as Cd,wy as Dd,Eq as Ed,Bc as Fd,Yo as Gd,Qt as Hd,Le as Id,Hl as Jd,ft as Kd,Dq as Ld,Fs as Md,Aq as Nd,Oy as Od,Oq as Pd,Mq as Qd,jq as Rd,H_ as Sd,Bq as Td,$q as Ud,_i as Vd,hy as Wd,z1 as Xd,K1 as Yd,J1 as Zd,X1 as _d,se as $d,bF as ae,Zo as be,EF as ce,rV as de,iV as ee,gV as fe,$c as ge,PV as he,wV as ie,CV as je,Ns as ke,An as le,nt as me,au as ne,Mi as oe,Vi as pe,BL as qe,SD as re,bD as se,Ah as te,os as ue,Mm as ve,ss as we,as as xe,mr as ye,GF as ze,Vm as Ae,kt as Be,VV as Ce,eH as De,Qm as Ee,uH as Fe,ps as Ge,xH as He,DH as Ie,AH as Je,WH as Ke,qH as Le,UH as Me,Ze as Ne,gi as Oe,ys as Pe,tW as Qe,uW as Re,dW as Se,pW as Te,jg as Ue,VN as Ve,RW as We,PW as Xe,Ss as Ye,Is as Ze,rq as _e,oy as $e,iq as af,At as bf,Jg as cf,sy as df,Ei as ef,oq as ff,sq as gf,aq as hf,kl as if,Yg as jf,Rs as kf,hq as lf,Ni as mf,Sq as nf};
|
|
454
|
+
//# sourceMappingURL=chunk-2BTJALUS.js.map
|