codebaseiq 0.3.0 → 0.4.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 +80 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-7GAK2F3H.js → chunk-23AD24QZ.js} +12 -12
- package/dist/chunk-24TEZJST.js +2 -0
- package/dist/{chunk-356EZBIP.js → chunk-26EDDGAX.js} +2 -2
- package/dist/{chunk-O2M3VNDY.js → chunk-26EZWQ24.js} +2 -2
- package/dist/{chunk-U33PMPNW.js → chunk-2L3NCI52.js} +2 -2
- package/dist/{chunk-MSI3K7PJ.js → chunk-2QJAVISG.js} +2 -2
- package/dist/{chunk-4LK5OIPW.js → chunk-2ZBZRYX4.js} +2 -2
- package/dist/chunk-33AXWMO2.js +2 -0
- package/dist/{chunk-EQNMD62X.js → chunk-37K55EG3.js} +2 -2
- package/dist/{chunk-ITSJMNUD.js → chunk-3EFZ5KQ4.js} +2 -2
- package/dist/{chunk-D7DOB27N.js → chunk-3F23W57G.js} +2 -2
- package/dist/{chunk-BGGB5N53.js → chunk-3GKKCVKK.js} +2 -2
- package/dist/{chunk-MQW6SJ4P.js → chunk-3SYRGMCL.js} +2 -2
- package/dist/{chunk-PFC44E6D.js → chunk-3VDL7GTY.js} +2 -2
- package/dist/{chunk-7JELP5YE.js → chunk-3XBZ5PKL.js} +2 -2
- package/dist/{chunk-75KJGYX7.js → chunk-42PXSE74.js} +2 -2
- package/dist/{chunk-FEIZXBLH.js → chunk-4GIERC2P.js} +2 -2
- package/dist/{chunk-W7YLRXZE.js → chunk-4UXDBRIF.js} +2 -2
- package/dist/chunk-4XMZYLW5.js +2 -0
- package/dist/{chunk-6BF3VYEF.js → chunk-55NUXP2V.js} +2 -2
- package/dist/chunk-5AJQCOZZ.js +21 -0
- package/dist/{chunk-5DSL3NT2.js → chunk-5NUPFZFA.js} +2 -2
- package/dist/{chunk-RJVAPMHF.js → chunk-65QIFIF6.js} +2 -2
- package/dist/{chunk-36JC5BG2.js → chunk-66Q5VLH6.js} +2 -2
- package/dist/{chunk-D7AZAOZX.js → chunk-6CQPIIS7.js} +2 -2
- package/dist/{chunk-GV2CEZCW.js → chunk-6CTSFS7R.js} +2 -2
- package/dist/{chunk-Q4XEU3UH.js → chunk-6EBUAKJT.js} +2 -2
- package/dist/chunk-6I55VYFG.js +4 -0
- package/dist/chunk-6NUURWPF.js +3 -0
- package/dist/{chunk-MHWMEZDA.js → chunk-6P5QMOM7.js} +2 -2
- package/dist/{chunk-LZSQ6X7E.js → chunk-6S5FE4ZF.js} +2 -2
- package/dist/chunk-74LRKLNC.js +22 -0
- package/dist/chunk-75A23IID.js +3 -0
- package/dist/chunk-75VNTSO6.js +7 -0
- package/dist/chunk-7HBBVZJ6.js +3 -0
- package/dist/{chunk-VWYGCMV5.js → chunk-7PPBMBH6.js} +2 -2
- package/dist/{chunk-3RSBGWGL.js → chunk-7WG57A5X.js} +2 -2
- package/dist/{chunk-FWQGH2N2.js → chunk-7XHZX6FX.js} +2 -2
- package/dist/{chunk-RIYJ4L33.js → chunk-A5HJ3CJW.js} +2 -2
- package/dist/{chunk-LONKINMJ.js → chunk-AJ5HVC5Z.js} +2 -2
- package/dist/{chunk-ZAFGY22Q.js → chunk-AYRHOFLV.js} +2 -2
- package/dist/chunk-AZDY3EKD.js +93 -0
- package/dist/{chunk-CW6AXOLR.js → chunk-AZZNG5Z2.js} +2 -2
- package/dist/chunk-BEKCTUPY.js +3 -0
- package/dist/{chunk-CR3OG6SQ.js → chunk-BKKX2OU5.js} +2 -2
- package/dist/{chunk-5LL4KEHO.js → chunk-BQKRYKDD.js} +2 -2
- package/dist/{chunk-FOZ74V56.js → chunk-BVDQU2XJ.js} +2 -2
- package/dist/chunk-C3PPB2T5.js +5 -0
- package/dist/chunk-CABIZQXQ.js +21 -0
- package/dist/{chunk-M2Y6PCFE.js → chunk-CAH322MC.js} +2 -2
- package/dist/{chunk-EIBGSU2R.js → chunk-CBOOHUK4.js} +2 -2
- package/dist/chunk-CFIICAOM.js +2 -0
- package/dist/{chunk-XMJ53WG4.js → chunk-CPWYEPWQ.js} +2 -2
- package/dist/{chunk-LQHYYIOB.js → chunk-CRT7I7RJ.js} +2 -2
- package/dist/{chunk-IZDPGOZR.js → chunk-CZVSQQDU.js} +2 -2
- package/dist/{chunk-TNJGTQWO.js → chunk-D3KE26FS.js} +2 -2
- package/dist/{chunk-GP7C5VAE.js → chunk-DNRHRVKS.js} +2 -2
- package/dist/{chunk-SGMNWYTH.js → chunk-DOQLO74K.js} +2 -2
- package/dist/{chunk-AURCQHSG.js → chunk-DP3EJ6XL.js} +2 -2
- package/dist/{chunk-C7QWUBR2.js → chunk-DQZF7MP6.js} +2 -2
- package/dist/{chunk-E52K4L2W.js → chunk-DTM4EHD2.js} +2 -2
- package/dist/{chunk-YRKP7PM7.js → chunk-DUM7GR6B.js} +2 -2
- package/dist/{chunk-I22IZYDI.js → chunk-DZ4QOIRY.js} +2 -2
- package/dist/{chunk-EXZ7VLRY.js → chunk-E3R6TJ5T.js} +2 -2
- package/dist/chunk-E4DP45YU.js +3 -0
- package/dist/{chunk-PUVNH4PO.js → chunk-E5U6N5WI.js} +2 -2
- package/dist/chunk-E7T22WET.js +21 -0
- package/dist/{chunk-QEOWONKY.js → chunk-ED7ZAZ5V.js} +2 -2
- package/dist/{chunk-RCIGX23V.js → chunk-EDMG5CSO.js} +2 -2
- package/dist/{chunk-IHSLIIL3.js → chunk-EOSUV7H5.js} +2 -2
- package/dist/{chunk-FQTIFWLR.js → chunk-ESWVTSHU.js} +2 -2
- package/dist/{chunk-6VREELBC.js → chunk-ETZBIG6K.js} +2 -2
- package/dist/chunk-EYSJHKX6.js +3 -0
- package/dist/{chunk-Q23IMHXS.js → chunk-F4AGM7ZE.js} +37 -37
- package/dist/{chunk-FTTV7IRX.js → chunk-FPUJRBHL.js} +50 -50
- package/dist/{chunk-CCIYWXX6.js → chunk-G2UU6PQP.js} +2 -2
- package/dist/{chunk-C6WKPKCF.js → chunk-G3KRXNNT.js} +2 -2
- package/dist/{chunk-TEANKHUU.js → chunk-G3ZBP72R.js} +2 -2
- package/dist/{chunk-NBCQZSGR.js → chunk-GC4I33OD.js} +2 -2
- package/dist/{chunk-NDKOVQFG.js → chunk-GLXEWYQY.js} +2 -2
- package/dist/{chunk-AEXQYQD7.js → chunk-GRHNPFHT.js} +2 -2
- package/dist/{chunk-NBZKSTXP.js → chunk-GWESWURK.js} +2 -2
- package/dist/{chunk-Q3ZCQY2Y.js → chunk-GXOFPAIR.js} +2 -2
- package/dist/{chunk-USOAJHY7.js → chunk-H4FGIFEU.js} +2 -2
- package/dist/{chunk-LKUTSP4G.js → chunk-HOGS6JFP.js} +2 -2
- package/dist/{chunk-UQE4XFSA.js → chunk-HSJLK5MC.js} +2 -2
- package/dist/{chunk-BWL3PMPT.js → chunk-HTPEUJ42.js} +2 -2
- package/dist/{chunk-3RR2K7EZ.js → chunk-IBPXUGJV.js} +2 -2
- package/dist/{chunk-BFBIMTCJ.js → chunk-ITA3N7G6.js} +2 -2
- package/dist/chunk-JG5OWAEB.js +22 -0
- package/dist/{chunk-2PRONPAS.js → chunk-JGJKRTTB.js} +2 -2
- package/dist/{chunk-TJWVT4DO.js → chunk-JGXLB7PR.js} +2 -2
- package/dist/{chunk-K7JLSGCJ.js → chunk-JKUF2UG6.js} +3 -3
- package/dist/{chunk-CIYA2KZN.js → chunk-JOYASZRF.js} +2 -2
- package/dist/{chunk-U7NUXDQO.js → chunk-K3PFL5QQ.js} +2 -2
- package/dist/{chunk-WK2IQJPK.js → chunk-KAXBWTSX.js} +2 -2
- package/dist/{chunk-5ZI2PPI7.js → chunk-KHHAGHAW.js} +2 -2
- package/dist/{chunk-UW6KD57C.js → chunk-KJLUQVBG.js} +2 -2
- package/dist/{chunk-WWCV4E6J.js → chunk-KOVUXHIZ.js} +2 -2
- package/dist/chunk-KPMMOAV5.js +4 -0
- package/dist/{chunk-GDHWOA57.js → chunk-LKJZNGMA.js} +2 -2
- package/dist/{chunk-3VJ3OCRE.js → chunk-LMPOC372.js} +2 -2
- package/dist/{chunk-F3QSL4W2.js → chunk-LTPNP6D5.js} +2 -2
- package/dist/{chunk-MVRGB4KJ.js → chunk-M3IBH6C3.js} +9 -9
- package/dist/{chunk-PHNCEUXX.js → chunk-MAGBSB6E.js} +2 -2
- package/dist/{chunk-QMOZZ2VX.js → chunk-MFMHD36E.js} +2 -2
- package/dist/{chunk-LMTSB3TB.js → chunk-MJX2J5QE.js} +2 -2
- package/dist/{chunk-PTQPPPG2.js → chunk-N26LGGSF.js} +2 -2
- package/dist/{chunk-J7AMBVWF.js → chunk-NB2DAVPP.js} +2 -2
- package/dist/{chunk-JYI7CV25.js → chunk-NJDXNYLG.js} +2 -2
- package/dist/{chunk-BRQL7AFJ.js → chunk-NMKQOIYZ.js} +2 -2
- package/dist/{chunk-ICUL7XRT.js → chunk-NRNVMB2R.js} +2 -2
- package/dist/{chunk-DDN2F6GB.js → chunk-O5BWFNIH.js} +2 -2
- package/dist/{chunk-HVFB3PME.js → chunk-O7PCDZ5B.js} +2 -2
- package/dist/{chunk-KPZGTB2O.js → chunk-OAJYNPRU.js} +2 -2
- package/dist/{chunk-2EDX3JT5.js → chunk-OFUC6R46.js} +2 -2
- package/dist/chunk-OSZ7PW5K.js +5 -0
- package/dist/{chunk-B3UYV66Z.js → chunk-OZ2M2X7A.js} +2 -2
- package/dist/{chunk-6O3KXIDL.js → chunk-OZI44VCR.js} +2 -2
- package/dist/{chunk-XN3EKMLI.js → chunk-PCKIKOUA.js} +2 -2
- package/dist/{chunk-NCJILOAK.js → chunk-PFMQRHC6.js} +2 -2
- package/dist/chunk-PVKSZBX5.js +82 -0
- package/dist/{chunk-NEWHKGVD.js → chunk-QANCT4MO.js} +2 -2
- package/dist/{chunk-ZNH33XIB.js → chunk-QEWN7BLP.js} +2 -2
- package/dist/{chunk-OQUCBKOI.js → chunk-QFJ46F6F.js} +2 -2
- package/dist/{chunk-2E6OUPCF.js → chunk-QPQWR6CW.js} +2 -2
- package/dist/{chunk-YTJHCGYB.js → chunk-QX4HDF2I.js} +2 -2
- package/dist/{chunk-J3GLP7Q5.js → chunk-R2F2CTBA.js} +2 -2
- package/dist/{chunk-2OMXFE64.js → chunk-R7PXHYMY.js} +2 -2
- package/dist/{chunk-F74LZWCE.js → chunk-RGBZDOUO.js} +2 -2
- package/dist/{chunk-362QOSFD.js → chunk-RNPG5P4P.js} +2 -2
- package/dist/{chunk-D62CTZX6.js → chunk-RS6UYNEP.js} +2 -2
- package/dist/{chunk-VGWZ4MOY.js → chunk-RVBRPBLQ.js} +2 -2
- package/dist/{chunk-5IZRKWTZ.js → chunk-RWAZCEJD.js} +2 -2
- package/dist/{chunk-ZQ62NNKN.js → chunk-RWDIONS7.js} +2 -2
- package/dist/{chunk-HQA7EBSK.js → chunk-S3CJYDXP.js} +2 -2
- package/dist/{chunk-GL6UTNUB.js → chunk-S6UTKCBT.js} +2 -2
- package/dist/chunk-SLLFJXTW.js +27 -0
- package/dist/{chunk-TOTWJZIX.js → chunk-T3KTMLQT.js} +2 -2
- package/dist/{chunk-67VJAYVR.js → chunk-TB575ZGO.js} +2 -2
- package/dist/{chunk-YHPG3S2U.js → chunk-TG4GMU73.js} +2 -2
- package/dist/{chunk-CVHOQONG.js → chunk-THKM7OXM.js} +2 -2
- package/dist/{chunk-GVAF222T.js → chunk-TNLOX4TN.js} +2 -2
- package/dist/{chunk-HENP2O4A.js → chunk-UHFZDQZJ.js} +2 -2
- package/dist/{chunk-YT4DVWUV.js → chunk-UUMAM5LM.js} +2 -2
- package/dist/{chunk-JX6ZWDOS.js → chunk-UUT5P3V7.js} +2 -2
- package/dist/{chunk-Z6RL7XOE.js → chunk-VEPK6M5C.js} +2 -2
- package/dist/{chunk-C7OUW52M.js → chunk-VPCHKZ3I.js} +2 -2
- package/dist/{chunk-GIDCP7KV.js → chunk-VZY3XOBU.js} +2 -2
- package/dist/{chunk-XQAVQVIL.js → chunk-W6E6ME7G.js} +2 -2
- package/dist/{chunk-XQPPURLQ.js → chunk-WGYZBS5S.js} +2 -2
- package/dist/{chunk-GUFPEFBG.js → chunk-WUP24Q4U.js} +2 -2
- package/dist/chunk-WXUHXSLN.js +2 -0
- package/dist/{chunk-HINZQKSY.js → chunk-X4YZD2MP.js} +2 -2
- package/dist/chunk-XARPGCTL.js +2 -0
- package/dist/{chunk-5FWR5HLG.js → chunk-XDQ6QJF5.js} +20 -20
- package/dist/{chunk-JCMFBF4Z.js → chunk-XRH7R5SX.js} +2 -2
- package/dist/{chunk-BBP7HVBJ.js → chunk-XVJ2E7W7.js} +2 -2
- package/dist/{chunk-D53LWANR.js → chunk-Y7GFAU5N.js} +2 -2
- package/dist/{chunk-T6MQNNAC.js → chunk-YBDLHFZZ.js} +2 -2
- package/dist/{chunk-ZB4C5TTR.js → chunk-YI3CJPOY.js} +2 -2
- package/dist/chunk-YMAGXBLT.js +3 -0
- package/dist/{chunk-MZNMASFM.js → chunk-YRAGNEBZ.js} +2 -2
- package/dist/chunk-YXZAAQHZ.js +3 -0
- package/dist/chunk-Z2L5H2HF.js +3 -0
- package/dist/{chunk-JSNTHRLQ.js → chunk-ZHK7TVAJ.js} +2 -2
- package/dist/chunk-ZJNV27DZ.js +4 -0
- package/dist/{chunk-GQLDYCWS.js → chunk-ZQ6GAIUV.js} +2 -2
- package/dist/{chunk-TPO7XC5Z.js → chunk-ZQE2QYAC.js} +2 -2
- package/dist/chunk-ZUQ2MDFT.js +2 -0
- package/dist/cli-context-4R2LREXQ.js +3 -0
- package/dist/cli-context-6X7JYARX.js +2 -0
- package/dist/cli-failure-RECEHOM2.js +3 -0
- package/dist/cli-program-MXA3WTAO.js +7 -0
- package/dist/cli.js +1 -1
- package/dist/{code-viewer-VHLBLIUM.js → code-viewer-C6HE4DFC.js} +2 -2
- package/dist/{code-viewer-KIXEYQNJ.js → code-viewer-XHSSAMBX.js} +2 -2
- package/dist/{command-descriptors-YCLATF5I.js → command-descriptors-NWW34Z54.js} +171 -171
- package/dist/{command-descriptors-F5P2V3NW.js → command-descriptors-XHK3PK2I.js} +116 -116
- package/dist/{command-panels-SZONPMLJ.js → command-panels-OXMCJ2QZ.js} +2 -2
- package/dist/direct-navigation-236VXYBZ.js +3 -0
- package/dist/direct-navigation-36YSILY6.js +2 -0
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-35JULLNR.js +3 -0
- package/dist/invocation-command-descriptors-FEWSFUO2.js +2 -0
- package/dist/output-continuation-command-MJBVH3A5.js +2 -0
- package/dist/output-continuation-command-TBXIOPHQ.js +3 -0
- package/dist/project-reindex-5TCGOVSK.js +2 -0
- package/dist/project-reindex-BUNTSYKM.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.js +30 -30
- package/dist/runtime.js +1 -1
- 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/sentinel-ensure-command-3MZCLPQY.js +2 -0
- package/dist/sentinel-ensure-command-LEWHIRLL.js +3 -0
- package/dist/sentinel-worker.js +1 -1
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +6 -6
- package/docs/COMMAND_REFERENCE.md +2 -2
- package/docs/SECURITY_MODEL.md +3 -0
- package/package.json +1 -1
- package/skills/codebaseiq/SKILL.md +15 -3
- package/dist/chunk-23C5AD3B.js +0 -2
- package/dist/chunk-2I2UHZET.js +0 -2
- package/dist/chunk-5IC2WZAL.js +0 -22
- package/dist/chunk-5T44HG5Y.js +0 -88
- package/dist/chunk-6JMAVFL4.js +0 -3
- package/dist/chunk-6WAPPQ5F.js +0 -82
- package/dist/chunk-7UCDGXRW.js +0 -8
- package/dist/chunk-AQI4N64O.js +0 -22
- package/dist/chunk-DAKIGMIK.js +0 -21
- package/dist/chunk-DUKHVPU5.js +0 -4
- package/dist/chunk-DVWO7RBC.js +0 -2
- package/dist/chunk-FH5WG4LE.js +0 -2
- package/dist/chunk-GQXXOS55.js +0 -2
- package/dist/chunk-GWYZVVKY.js +0 -21
- package/dist/chunk-JFIA2JI3.js +0 -3
- package/dist/chunk-JLZLLLW5.js +0 -3
- package/dist/chunk-MEUHIDI3.js +0 -7
- package/dist/chunk-OFGOOL6U.js +0 -3
- package/dist/chunk-P4NVCOM7.js +0 -2
- package/dist/chunk-SMDIEDM4.js +0 -27
- package/dist/chunk-SX72EVMY.js +0 -3
- package/dist/chunk-T5X7DK6C.js +0 -3
- package/dist/chunk-T75DS2E6.js +0 -21
- package/dist/chunk-TJBOJUVN.js +0 -3
- package/dist/chunk-UC2FD2PS.js +0 -4
- package/dist/chunk-UQYQBLJX.js +0 -5
- package/dist/chunk-Z35GOVEH.js +0 -2
- package/dist/cli-context-FJL2JHOE.js +0 -3
- package/dist/cli-context-PQNWHMCQ.js +0 -2
- package/dist/cli-program-UO7PZD6V.js +0 -7
- package/dist/direct-navigation-4XJTXIDT.js +0 -2
- package/dist/direct-navigation-J5MVYYAD.js +0 -3
- package/dist/invocation-command-descriptors-RWV4VAI4.js +0 -2
- package/dist/invocation-command-descriptors-U76PN7IY.js +0 -3
- package/dist/output-continuation-command-BL25S26S.js +0 -3
- package/dist/output-continuation-command-BTETTXEC.js +0 -2
- package/dist/project-reindex-CRJU3IFG.js +0 -2
- package/dist/project-reindex-TQFCOA2O.js +0 -3
- package/dist/sentinel-ensure-command-OSWGCFFL.js +0 -3
- package/dist/sentinel-ensure-command-SPW7XQLB.js +0 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
3
|
-
VALUES (?, ?, NULL, ?)`),c=i.transaction(l=>{let d=0;for(let p of l){if(o.has(p))continue;let g=
|
|
4
|
-
`).filter(r=>r&&t.has(_e(r).toLowerCase())).sort()}catch{return null}}function
|
|
5
|
-
`),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return
|
|
6
|
-
`).filter(i=>i.length>0),partialTailBytes:e.length-n}}var
|
|
2
|
+
import{a as cr}from"./chunk-EN4AHLL3.js";import{Bb as er,Jb as tr,Kb as nr,Lb as rr,Nb as ir,Ob as or,Pb as ar,Qb as sr,T as Wn,U as Gn,ca as ke,cb as qn,db as Jn,fb as re,gb as Te,hb as pe,ib as Hn,jb as zn,k as Ee,kb as Xn,lb as Yn,mb as Kn,ob as we,pb as Qn,ub as mt,zb as Zn}from"./chunk-FPUJRBHL.js";import{d as on,e as tt}from"./chunk-RS6UYNEP.js";import{A as ln,Ab as Ln,B as Se,Bb as On,C as E,Cb as Nn,D as le,Db as Cn,E as ee,Eb as ve,F as it,Fb as jn,G as dn,H as ot,Hb as ft,I as at,Ib as Mn,J as R,Jb as Vn,Kb as Ie,L as pn,M as A,Nb as Bn,O as Re,Ob as $n,P as st,Pb as Un,Q as gn,S as fn,Sa as xe,Ta as de,U as te,Va as ne,W as mn,X as hn,Xa as bn,Z as O,_ as yn,_a as Sn,cb as Pe,db as Rn,eb as ut,fb as xn,gb as Pn,hb as lt,j as nt,jb as U,kb as W,lb as G,nb as dt,ob as vn,pb as pt,q as an,qb as gt,r as sn,rb as In,s as rt,sb as En,tb as kn,u as F,ub as Tn,v as cn,vb as wn,wb as _n,xa as ct,xb as Fn,yb as Dn,z as un,zb as An}from"./chunk-AZDY3EKD.js";import{A as Ze,D as rn,E as et,G as $,d as Zt,e as ye,j as en,k as K,l as Q,m as Ke,n as ce,o as be,p as Qe,q as L,r as _,s as D,t as tn,x as nn,y as ue,z as Z}from"./chunk-KPMMOAV5.js";import{spawnSync as Ro}from"child_process";import{mkdtempSync as jl,rmSync as So}from"fs";import{tmpdir as Ml}from"os";import{join as Vl}from"path";import{createHash as Qu}from"crypto";import{existsSync as T,mkdirSync as He,readdirSync as ro,renameSync as io,rmSync as ae,statSync as Zu}from"fs";import{basename as Je,dirname as y,extname as el,join as k,resolve as Xi}from"path";import{execFileSync as Po}from"child_process";import{constants as vo,copyFileSync as ur,statSync as Io}from"fs";import{platform as Eo}from"os";var ko=Object.freeze({size:e=>Io(e).size,clone:wo,copy:(e,t)=>ur(e,t)}),To=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function q(e,t,n=ko){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!Fo(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function wo(e,t){if(Eo()!=="darwin"){ur(e,t,vo.COPYFILE_FICLONE_FORCE);return}try{Po("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw _o(n)}}function _o(e){let t=e?.stderr,n=Buffer.isBuffer(t)?t.toString("utf8"):t??"";return/operation not supported|not supported/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"ENOTSUP"}):/cross-device link/i.test(n)?Object.assign(e instanceof Error?e:new Error(String(e)),{code:"EXDEV"}):e}function Fo(e){let t=e?.code;return t!==void 0&&To.has(t)}function lr(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function J(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import Do from"better-sqlite3";import{execFileSync as Ao}from"child_process";import{existsSync as Lo,readdirSync as Oo}from"fs";import{extname as _e,join as No}from"path";function H(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>dr({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function dr(e){let t=new Set((e.extensions??Wn).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!Lo(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=yn(e.projectRoot),r=Co(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new Do(F(e.dbPath));try{let o=Mo(i,r),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
|
|
3
|
+
VALUES (?, ?, NULL, ?)`),c=i.transaction(l=>{let d=0;for(let p of l){if(o.has(p))continue;let g=Sn(e.projectRoot,p,{inputKind:"auxiliary source file"}),f=a.run(Vo(p),p,g);d+=Number(f.changes)}return d})(r),u={scanned:r.length,inserted:c,existing:r.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${u.existing} already present).`),u}finally{i.close()}}function Co(e,t){let n=jo(e,t);if(n)return n;let r=[],i=o=>{let a=o?No(e,o):e,s;try{s=Oo(a,{withFileTypes:!0})}catch{return}for(let c of s){if(Gn.has(c.name))continue;let u=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(u);continue}t.has(_e(c.name).toLowerCase())&&r.push(u)}};return i(""),r.sort()}function jo(e,t){try{return Ao("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}).split(`
|
|
4
|
+
`).filter(r=>r&&t.has(_e(r).toLowerCase())).sort()}catch{return null}}function Mo(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.add(s.relative_path)}return n}function Vo(e){return _e(e).toLowerCase()===".vue"?"vue":_e(e).replace(/^\./,"").toLowerCase()||"source"}import{dirname as Bo,join as $o}from"path";function pr(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new O({projectRoot:t,dbPath:n,indexPath:e.indexPath??$o(Bo(n),"index.scip")}),o,a=!1,s=!1;try{let u=e.reuseExisting||e.affectedFiles?ir(i):null;e.reuseExisting&&u?.extractorVersion===tr?(o=u,a=!0):(o=nr(i,{...u?{previousGraph:u}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(o.coverage.filesReused??0)>0)}finally{i.close()}a||rr(n,o);let c={reused:a,incrementallyUpdated:s,observations:o.observations.length,links:o.links.length,frontiers:o.frontiers.length,filesScanned:o.coverage.filesScanned,errors:o.coverage.extractionErrors.length,phases:o.coverage.phases};return r?.(c.reused?`Reused ${c.observations} cached runtime-boundary observation(s) and ${c.links} link(s).`:c.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${c.filesScanned-(o.coverage.filesReused??0)} file(s) extracted, ${o.coverage.filesReused??0} reused) and rebuilt ${c.links} link(s).`:`Extracted ${c.observations} runtime-boundary observation(s), ${c.links} link(s), and ${c.frontiers} unresolved frontier(s).`),!a&&o.coverage.phases&&r?.(`Runtime-boundary phases: ${o.coverage.phases.map(u=>`${u.id} ${u.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as ra}from"crypto";import{existsSync as ia}from"fs";import{dirname as oa,join as br}from"path";function ht(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function Fe(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),o=ht(e),a=new Set(o.reasons);return r.some(s=>!i.has(s))&&a.add("changed-file-outside-project"),t===null?(a.add("dependency-graph-unavailable"),gr(r,i,a)):a.size>0?gr(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:Uo(r,t,i),reasons:[]}}function gr(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Uo(e,t,n){let r=new Map;for(let[a,s]of t)if(n.has(a))for(let c of s){if(!n.has(c))continue;let u=r.get(c)??new Set;u.add(a),r.set(c,u)}let i=new Set(e),o=[...e];for(let a=0;a<o.length;a+=1){let s=o[a];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}import{appendFileSync as Wo,existsSync as Go,mkdirSync as qo,renameSync as Jo,rmSync as Ho,statSync as zo,truncateSync as Xo}from"fs";import{basename as Yo,dirname as Ko}from"path";var ie=".previous",Qo=".rotation.lock",Zo=2e3,yt=class extends Error{constructor(n,r){super(`Timed out after ${r}ms waiting for rotating JSONL lock: ${n}`);this.lockPath=n;this.timeoutMs=r;this.name="RotatingJsonlLockTimeoutError"}lockPath;timeoutMs;code="ROTATING_JSONL_LOCK_TIMEOUT"},bt=class extends Error{constructor(n){super(`Rotating JSONL lock ownership changed before release: ${n}`);this.lockPath=n;this.name="RotatingJsonlLockReleaseError"}lockPath;code="ROTATING_JSONL_LOCK_RELEASE_FAILED"},fr=Object.freeze({monotonicNow:R,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let n=Re(e,{kind:"rotating-jsonl",detail:{target:Yo(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){qo(e,{recursive:!0})},exists:Go,readBytes(e){return L(e,{maxBytes:be,inputKind:"rotating JSONL segment"})},size(e){return zo(e).size},truncate:Xo,remove(e){Ho(e,{force:!0})},rename:Jo,append:Wo});function De(e,t,n){let r=n.runtime??fr,i=JSON.stringify(t);if(i===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let o=Buffer.from(`${i}
|
|
5
|
+
`),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return hr(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(Ko(e));let s=ea(e,be,r);n.onPhase?.("tail-repaired");let c=`${e}${n.previousSuffix??ie}`,u=!1,l=!1;return r.exists(e)&&r.size(e)+o.length>a&&(r.exists(c)&&(r.remove(c),l=!0),n.onPhase?.("previous-pruned"),r.rename(e,c),u=!0,n.onPhase?.("current-rotated")),r.append(e,o),n.onPhase?.("record-appended"),{lineBytes:o.length,segmentLimitBytes:a,repairedTailBytes:s,rotated:u,prunedPrevious:l}})}function mr(e,t={}){let n=t.runtime??fr,r=ta(t.maxSegmentBytes);return hr(e,t.lockTimeoutMs,n,()=>{let i=[],o=0,a=`${e}${t.previousSuffix??ie}`;for(let s of[a,e]){if(!n.exists(s))continue;let c=na(yr(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function hr(e,t,n,r){let i=`${e}${Qo}`,o=Math.max(0,t??Zo),a=n.monotonicNow()+o,s;for(;;){let p=n.tryAcquireLock(i,e);if(p.kind==="acquired"){s=p.lock;break}let g=a-n.monotonicNow();if(g<=0)throw new yt(i,o);n.wait(Math.min(5,g))}let c=!1,u,l;try{l=r()}catch(p){c=!0,u=p}let d=!1;try{d=s.release()}catch(p){if(!c)throw p}if(c)throw u;if(!d)throw new bt(i);return l}function ea(e,t,n){if(!n.exists(e))return 0;let r=yr(e,t,n);if(r.length===0||r[r.length-1]===10)return 0;let i=r.lastIndexOf(10),o=i<0?0:i+1;return n.truncate(e,o),r.length-o}function ta(e){let t=e??be;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function yr(e,t,n){let r=n.size(e);if(r>t)throw new Qe("rotating JSONL segment",e,"too-large",r,t);let i=n.readBytes(e),o=n.size(e);if(o!==r||i.byteLength!==r)throw new Qe("rotating JSONL segment",e,"changed-during-read",o,t);return i}function na(e){let t=e.lastIndexOf(10),n=t<0?0:t+1;return{lines:e.subarray(0,n).toString("utf8").split(`
|
|
6
|
+
`).filter(i=>i.length>0),partialTailBytes:e.length-n}}var aa="<global-symbols>";function sa(e){let t=[];for(let n of e.all(`
|
|
7
7
|
SELECT relative_path, language, position_encoding, text
|
|
8
8
|
FROM documents
|
|
9
9
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -30,7 +30,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
30
30
|
FROM defn_enclosing_ranges r
|
|
31
31
|
JOIN documents d ON d.id = r.document_id
|
|
32
32
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
33
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
33
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:St(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
34
34
|
SELECT d.relative_path,
|
|
35
35
|
c.chunk_index,
|
|
36
36
|
m.role,
|
|
@@ -45,7 +45,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
45
45
|
JOIN chunks c ON c.id = m.chunk_id
|
|
46
46
|
JOIN documents d ON d.id = c.document_id
|
|
47
47
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
48
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
48
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:St(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
49
49
|
SELECT g.symbol,
|
|
50
50
|
g.display_name,
|
|
51
51
|
g.kind,
|
|
@@ -59,8 +59,8 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
59
59
|
) AND NOT EXISTS (
|
|
60
60
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
61
61
|
)
|
|
62
|
-
`))t.push({relativePath:
|
|
63
|
-
`);n.set(r,o.digest("hex"))}return n}function na(e,t){let n=[],r=[],i=[],o=[],a=new Set([...e.keys(),...t.keys()]);for(let s of[...a].sort()){let c=e.get(s),u=t.get(s);c===void 0?n.push(s):u===void 0?i.push(s):c!==u?r.push(s):o.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:o}}function St(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),o=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),a=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-o.length;return{passed:o.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:o,extraFiles:a}}function Rt(e,t=sa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(u,l)=>{let d=r();return xr(e.refreshResult,u,n?d:i(),Math.max(0,d-o),l)};if(!t.databaseExists(e.previousDbPath))return a("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return a("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let u=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=Se(e.previousSnapshot,e.currentSnapshot),d=new Set(u),p=l.changes.length>0&&!mt(l).fullProject&&l.changes.every(I=>d.has(I.path)),g=Fe(l,p?t.dependencyGraph(s):new Map,u),f=na(t.factDigests(s),t.factDigests(c)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-o),manifest:l,plan:g,comparison:f,evaluation:St(g,f,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{mr(s),mr(c)}}function br(e,t,n,r=Date.now()){return xr(e,t,r,0,n)}function Sr(e){let t=Qo(e);return{latestPath:fr(t,"affected-shadow-latest.json"),historyPath:fr(t,"affected-shadow.jsonl")}}function pd(e,t=n=>Zt(n,"affected-shadow source file")){let n=Sr(e),r;try{r=JSON.parse(t(n.latestPath))}catch(h){let b=pa(h),S=b?"telemetry-missing":da(h);return M(n,S,b?void 0:h instanceof Error?h.message:String(h))}if(W(r)&&typeof r.version=="number"&&r.version!==1)return M(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!ua(r))return M(n,"telemetry-malformed");if(r.status==="unavailable")return la(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:M(n,"telemetry-malformed");if(r.status!=="evaluated")return M(n,"telemetry-malformed");let i=r.plan,o=r.comparison,a=r.evaluation;if(!W(r.manifest)||!W(i)||!W(o)||!W(a))return M(n,"telemetry-malformed");let s=i.mode,c=G(i.affectedFiles),u=G(i.reasons),l=G(o.changedFiles),d=G(a.predictedFiles),p=G(a.actualFiles),g=G(a.missingFiles),f=a.recall,m=a.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||u===null||l===null||d===null||p===null||g===null||typeof a.passed!="boolean"||!hr(f)||!hr(m))return M(n,"telemetry-malformed");let I=p.length===0?1:(p.length-g.length)/p.length;return!yr(c,d)||!yr(l,p)||a.passed!==(g.length===0)||Math.abs(f-I)>Number.EPSILON||g.some(h=>!p.includes(h)||d.includes(h))?M(n,"telemetry-malformed"):{state:a.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:f,affectedRatio:m,predictedFiles:d,actualFiles:p,missingFiles:g,fallbackReasons:u}}function gd(e){if(e.state==="unavailable")return`unavailable (${e.reason})`;let t=e.missingFiles.length>0?`, ${e.missingFiles.length} missed`:"",n=e.fallbackReasons.length>0?`; fallback: ${e.fallbackReasons.join(", ")}`:"";return`${e.state}, ${(e.recall*100).toFixed(1)}% recall, ${e.predictedFiles.length} predicted / ${e.actualFiles.length} changed, ${(e.affectedRatio*100).toFixed(1)}% of project${t}${n}`}function Rr(e,t,n=ca){let r=Sr(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var ra=8*1024*1024,ia=ie;function oa(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function aa(e,t,n=ra){Le(e,oa(t),{maxSegmentBytes:n,previousSuffix:ia})}function bt(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var sa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:R,databaseExists:e=>Ko(e),openDatabase:(e,t,n)=>new O({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Ee(e),dependencyGraph:e=>ke(e),factDigests:e=>ea(e)},ca={appendHistory:aa,writeLatest:(e,t)=>dn(e,t,{spacing:2,trailingNewline:!0})};function xr(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function mr(e){try{e?.close()}catch{}}function ua(e){return W(e)&&e.version===1&&typeof e.recordedAt=="string"&&(e.refreshResult==="rebuilt"||e.refreshResult==="reused")&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0}function la(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function hr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function yr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function M(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function da(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function pa(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as ga}from"fs";import{isAbsolute as Pr,join as fa,resolve as ma}from"path";var Ae="@sourcegraph/scip-typescript@0.4.0",vr="scip-python-plus@0.7.5",Ir="github.com/sourcegraph/scip-go@v0.2.7",Er="scip-dotnet@0.2.14",ha="scip_dart@1.6.2",ya=3,ba=new Set(["bin","obj","node_modules"]),Sa={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar"]}:{binary:n,args:["index","--output",e,"--no-progress-bar"]},markerFiles:[...E.typescript],installMethods:[{label:"npm",identity:Ae,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ae]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar"]}),markerFiles:[...E.javascript],installMethods:[{label:"npm",identity:Ae,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ae]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:re.language,indexerBinary:re.indexerBinary,checkCommand:`${re.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:re.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...E.rust],installMethods:[],installUrl:re.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...E.python],installMethods:[{label:"npm",identity:vr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",vr]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",Pr(r)?r:ma(e,r)),{binary:n,args:i}},markerFiles:[...E.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...E.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...E.go],installMethods:[{label:"go install",identity:Ir,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Ir]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...E.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...E.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",kr(e,[".sln",".slnx",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...E.csharp],installMethods:[{label:"dotnet",identity:Er,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",kr(e,[".sln",".slnx",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...E.vb],installMethods:[{label:"dotnet",identity:Er,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...E.dart],installMethods:[{label:"dart pub",identity:ha,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>Pr(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...E.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Tr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function xt(e){return Sa[e]}function kr(e,t){let n=[e];for(let r=0;r<=ya&&n.length>0;r++){let i=[],o=[];for(let a of n){let s;try{s=ga(a,{withFileTypes:!0})}catch{continue}for(let c of s){let u=fa(a,c.name);c.isDirectory()?!c.name.startsWith(".")&&!ba.has(c.name)&&o.push(u):i.push(u)}}for(let a of t){let s=i.filter(c=>c.endsWith(a)).sort()[0];if(s)return s}n=o.sort()}return null}import{createHash as Ra}from"crypto";import{existsSync as wr,rmSync as _r}from"fs";import{resolve as xa}from"path";import Ar from"better-sqlite3";var Pa={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},va={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function Dr(e){let t=R(),n=Ia(e.affectedFiles);if(Ea(e.previousDbPath,e.miniDbPath,e.candidateDbPath),_r(e.candidateDbPath,{force:!0}),!wr(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!wr(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Fr(e.previousDbPath,"previous SQLite generation",!1),Fr(e.miniDbPath,"incremental SQLite mini database");let r=q(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&J(e.writeTelemetry,r);let i=null;try{i=new Ar(F(e.candidateDbPath),{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(F(e.miniDbPath)),Pt(i,"main","candidate SQLite generation"),Pt(i,"incremental","incremental SQLite mini database"),ka(i,n),Ta(i,n.length);let o=vt(i,"main",!0),a=V(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{wa(i),_a(i),Fa(i),e.onStage?.("after-delete"),La(i),e.onStage?.("after-symbol-reconciliation"),Aa(i),e.onStage?.("after-insert"),Da(i),Oa(i,n.length,a),e.onStage?.("before-commit")}).immediate(),Or(i,"main","candidate SQLite generation");let u=[...Na(i)].filter(([l,d])=>o.get(l)!==d).map(([l])=>l).sort();return i.exec("DETACH DATABASE incremental"),i.close(),i=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:u,durationMs:R()-t}}catch(o){try{i?.close()}finally{_r(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function Ia(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Ea(e,t,n){let r=[e,t,n].map(i=>xa(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Fr(e,t,n=!0){let r=new Ar(F(e),{readonly:!0,fileMustExist:!0});try{Pt(r,"main",t),n&&Or(r,"main",t)}finally{r.close()}}function Pt(e,t,n){for(let[r,i]of Object.entries(Pa)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:l})=>({name:s,type:c.toUpperCase(),notnull:u,pk:l}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(va)){let o=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),a=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(o?.tbl_name!==i.table||JSON.stringify(a)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Lr(e,t,"documents",["relative_path"],n),Lr(e,t,"global_symbols",["symbol"],n)}function Lr(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(u=>u.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Or(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function ka(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let o of i)n.run(o)})(t)}function Ta(e,t){let n=V(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=V(e,`SELECT COUNT(*) AS value
|
|
62
|
+
`))t.push({relativePath:aa,kind:"global-symbol",values:St(n)});return ca(t)}function ca(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),o=t.get(r.relativePath)??[];o.push(i),t.set(r.relativePath,o)}let n=new Map;for(let[r,i]of[...t].sort(([o],[a])=>o.localeCompare(a))){let o=ra("sha256");for(let a of i.sort())o.update(String(Buffer.byteLength(a))),o.update(":"),o.update(a),o.update(`
|
|
63
|
+
`);n.set(r,o.digest("hex"))}return n}function ua(e,t){let n=[],r=[],i=[],o=[],a=new Set([...e.keys(),...t.keys()]);for(let s of[...a].sort()){let c=e.get(s),u=t.get(s);c===void 0?n.push(s):u===void 0?i.push(s):c!==u?r.push(s):o.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:o}}function Rt(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),o=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),a=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-o.length;return{passed:o.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:o,extraFiles:a}}function xt(e,t=fa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(u,l)=>{let d=r();return Er(e.refreshResult,u,n?d:i(),Math.max(0,d-o),l)};if(!t.databaseExists(e.previousDbPath))return a("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return a("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let u=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=Se(e.previousSnapshot,e.currentSnapshot),d=new Set(u),p=l.changes.length>0&&!ht(l).fullProject&&l.changes.every(I=>d.has(I.path)),g=Fe(l,p?t.dependencyGraph(s):new Map,u),f=ua(t.factDigests(s),t.factDigests(c)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-o),manifest:l,plan:g,comparison:f,evaluation:Rt(g,f,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{Sr(s),Sr(c)}}function Pr(e,t,n,r=Date.now()){return Er(e,t,r,0,n)}function vr(e){let t=oa(e);return{latestPath:br(t,"affected-shadow-latest.json"),historyPath:br(t,"affected-shadow.jsonl")}}function Ed(e,t=n=>tn(n,"affected-shadow source file")){let n=vr(e),r;try{r=JSON.parse(t(n.latestPath))}catch(h){let b=Sa(h),S=b?"telemetry-missing":ba(h);return M(n,S,b?void 0:h instanceof Error?h.message:String(h))}if(W(r)&&typeof r.version=="number"&&r.version!==1)return M(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!ha(r))return M(n,"telemetry-malformed");if(r.status==="unavailable")return ya(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:M(n,"telemetry-malformed");if(r.status!=="evaluated")return M(n,"telemetry-malformed");let i=r.plan,o=r.comparison,a=r.evaluation;if(!W(r.manifest)||!W(i)||!W(o)||!W(a))return M(n,"telemetry-malformed");let s=i.mode,c=G(i.affectedFiles),u=G(i.reasons),l=G(o.changedFiles),d=G(a.predictedFiles),p=G(a.actualFiles),g=G(a.missingFiles),f=a.recall,m=a.affectedRatio;if(s!=="none"&&s!=="closure"&&s!=="full-project"||c===null||u===null||l===null||d===null||p===null||g===null||typeof a.passed!="boolean"||!Rr(f)||!Rr(m))return M(n,"telemetry-malformed");let I=p.length===0?1:(p.length-g.length)/p.length;return!xr(c,d)||!xr(l,p)||a.passed!==(g.length===0)||Math.abs(f-I)>Number.EPSILON||g.some(h=>!p.includes(h)||d.includes(h))?M(n,"telemetry-malformed"):{state:a.passed?"passing":"failing",...n,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,mode:s,recall:f,affectedRatio:m,predictedFiles:d,actualFiles:p,missingFiles:g,fallbackReasons:u}}function kd(e){if(e.state==="unavailable")return`unavailable (${e.reason})`;let t=e.missingFiles.length>0?`, ${e.missingFiles.length} missed`:"",n=e.fallbackReasons.length>0?`; fallback: ${e.fallbackReasons.join(", ")}`:"";return`${e.state}, ${(e.recall*100).toFixed(1)}% recall, ${e.predictedFiles.length} predicted / ${e.actualFiles.length} changed, ${(e.affectedRatio*100).toFixed(1)}% of project${t}${n}`}function Ir(e,t,n=ma){let r=vr(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var la=8*1024*1024,da=ie;function pa(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function ga(e,t,n=la){De(e,pa(t),{maxSegmentBytes:n,previousSuffix:da})}function St(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var fa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:R,databaseExists:e=>ia(e),openDatabase:(e,t,n)=>new O({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Ee(e),dependencyGraph:e=>ke(e),factDigests:e=>sa(e)},ma={appendHistory:ga,writeLatest:(e,t)=>mn(e,t,{spacing:2,trailingNewline:!0})};function Er(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function Sr(e){try{e?.close()}catch{}}function ha(e){return W(e)&&e.version===1&&typeof e.recordedAt=="string"&&(e.refreshResult==="rebuilt"||e.refreshResult==="reused")&&typeof e.durationMs=="number"&&Number.isFinite(e.durationMs)&&e.durationMs>=0}function ya(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function Rr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function xr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function M(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function ba(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function Sa(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Ra}from"fs";import{isAbsolute as kr,join as xa,resolve as Pa}from"path";var Ae="@sourcegraph/scip-typescript@0.4.0",Tr="scip-python-plus@0.7.5",wr="github.com/sourcegraph/scip-go@v0.2.7",_r="scip-dotnet@0.2.14",va="scip_dart@1.6.2",Ia=3,Ea=new Set(["bin","obj","node_modules"]),ka={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar"]}:{binary:n,args:["index","--output",e,"--no-progress-bar"]},markerFiles:[...E.typescript],installMethods:[{label:"npm",identity:Ae,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ae]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar"]}),markerFiles:[...E.javascript],installMethods:[{label:"npm",identity:Ae,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ae]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...E.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:re.language,indexerBinary:re.indexerBinary,checkCommand:`${re.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:re.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...E.rust],installMethods:[],installUrl:re.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project","--project-version","0"]}),markerFiles:[...E.python],installMethods:[{label:"npm",identity:Tr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Tr]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",kr(r)?r:Pa(e,r)),{binary:n,args:i}},markerFiles:[...E.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...E.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...E.go],installMethods:[{label:"go install",identity:wr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",wr]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...E.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...E.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Fr(e,[".sln",".slnx",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...E.csharp],installMethods:[{label:"dotnet",identity:_r,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Fr(e,[".sln",".slnx",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...E.vb],installMethods:[{label:"dotnet",identity:_r,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...E.dart],installMethods:[{label:"dart pub",identity:va,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>kr(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...E.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Dr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function Pt(e){return ka[e]}function Fr(e,t){let n=[e];for(let r=0;r<=Ia&&n.length>0;r++){let i=[],o=[];for(let a of n){let s;try{s=Ra(a,{withFileTypes:!0})}catch{continue}for(let c of s){let u=xa(a,c.name);c.isDirectory()?!c.name.startsWith(".")&&!Ea.has(c.name)&&o.push(u):i.push(u)}}for(let a of t){let s=i.filter(c=>c.endsWith(a)).sort()[0];if(s)return s}n=o.sort()}return null}import{createHash as Ta}from"crypto";import{existsSync as Ar,rmSync as Lr}from"fs";import{resolve as wa}from"path";import Cr from"better-sqlite3";var _a={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},Fa={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function jr(e){let t=R(),n=Da(e.affectedFiles);if(Aa(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Lr(e.candidateDbPath,{force:!0}),!Ar(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Ar(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Or(e.previousDbPath,"previous SQLite generation",!1),Or(e.miniDbPath,"incremental SQLite mini database");let r=q(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&J(e.writeTelemetry,r);let i=null;try{i=new Cr(F(e.candidateDbPath),{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(F(e.miniDbPath)),vt(i,"main","candidate SQLite generation"),vt(i,"incremental","incremental SQLite mini database"),La(i,n),Oa(i,n.length);let o=It(i,"main",!0),a=V(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{Na(i),Ca(i),ja(i),e.onStage?.("after-delete"),Ma(i),e.onStage?.("after-symbol-reconciliation"),Va(i),e.onStage?.("after-insert"),Ba(i),$a(i,n.length,a),e.onStage?.("before-commit")}).immediate(),Mr(i,"main","candidate SQLite generation");let u=[...Ua(i)].filter(([l,d])=>o.get(l)!==d).map(([l])=>l).sort();return i.exec("DETACH DATABASE incremental"),i.close(),i=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:u,durationMs:R()-t}}catch(o){try{i?.close()}finally{Lr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function Da(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Aa(e,t,n){let r=[e,t,n].map(i=>wa(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Or(e,t,n=!0){let r=new Cr(F(e),{readonly:!0,fileMustExist:!0});try{vt(r,"main",t),n&&Mr(r,"main",t)}finally{r.close()}}function vt(e,t,n){for(let[r,i]of Object.entries(_a)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:l})=>({name:s,type:c.toUpperCase(),notnull:u,pk:l}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Fa)){let o=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),a=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(o?.tbl_name!==i.table||JSON.stringify(a)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Nr(e,t,"documents",["relative_path"],n),Nr(e,t,"global_symbols",["symbol"],n)}function Nr(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(u=>u.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Mr(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function La(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let o of i)n.run(o)})(t)}function Oa(e,t){let n=V(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=V(e,`SELECT COUNT(*) AS value
|
|
64
64
|
FROM main.documents d
|
|
65
65
|
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
66
66
|
FROM temp.incremental_affected_paths p
|
|
@@ -70,7 +70,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
70
70
|
FROM incremental.documents d
|
|
71
71
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
72
72
|
WHERE p.relative_path IS NULL
|
|
73
|
-
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||o!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function
|
|
73
|
+
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||o!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function Na(e){e.exec(`
|
|
74
74
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
75
75
|
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
76
76
|
SELECT g.symbol
|
|
@@ -97,7 +97,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
97
97
|
FROM incremental.mentions m
|
|
98
98
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
99
99
|
WHERE m.role = 1;
|
|
100
|
-
`)}function
|
|
100
|
+
`)}function Ca(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
101
101
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
102
102
|
UNION
|
|
103
103
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
@@ -120,7 +120,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
120
120
|
SELECT u.symbol
|
|
121
121
|
FROM unaffected_definitions u
|
|
122
122
|
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
123
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function
|
|
123
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function ja(e){e.exec(`
|
|
124
124
|
DELETE FROM main.mentions
|
|
125
125
|
WHERE chunk_id IN (
|
|
126
126
|
SELECT c.id
|
|
@@ -142,7 +142,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
142
142
|
);
|
|
143
143
|
DELETE FROM main.documents
|
|
144
144
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
145
|
-
`)}function
|
|
145
|
+
`)}function Ma(e){e.exec(`
|
|
146
146
|
UPDATE main.global_symbols
|
|
147
147
|
SET display_name = NULL,
|
|
148
148
|
kind = NULL,
|
|
@@ -184,7 +184,7 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
184
184
|
WHERE source.symbol = main.global_symbols.symbol
|
|
185
185
|
)
|
|
186
186
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
187
|
-
`)}function
|
|
187
|
+
`)}function Va(e){let t=V(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=V(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=V(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
|
|
188
188
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
189
189
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
190
190
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
@@ -199,15 +199,15 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
199
199
|
r.start_line, r.start_char, r.end_line, r.end_char
|
|
200
200
|
FROM incremental.defn_enclosing_ranges r
|
|
201
201
|
JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
202
|
-
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function
|
|
202
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function Ba(e){e.exec(`
|
|
203
203
|
DELETE FROM main.global_symbols
|
|
204
204
|
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
205
205
|
AND NOT EXISTS (
|
|
206
206
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
207
207
|
);
|
|
208
|
-
`)}function
|
|
208
|
+
`)}function $a(e,t,n){let r=V(e,"SELECT COUNT(*) AS value FROM main.documents"),i=V(e,`SELECT COUNT(*) AS value
|
|
209
209
|
FROM main.documents d
|
|
210
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let o=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),a=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(o!==void 0||a!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function
|
|
210
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let o=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),a=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(o!==void 0||a!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function Ua(e){let t=It(e,"main",!0),n=It(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function It(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
|
|
211
211
|
FROM ${t}.documents d
|
|
212
212
|
${r}
|
|
213
213
|
ORDER BY d.relative_path`).all(),o=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
@@ -229,13 +229,13 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
229
229
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
230
230
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
231
231
|
${r}
|
|
232
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,d]of Object.entries({documents:i,chunks:o,definitions:a,mentions:s}))for(let p of d){let g=JSON.stringify([l,p]),f=c.get(p.relative_path)??[];f.push(g),c.set(p.relative_path,f)}let u=new Map;for(let[l,d]of[...c].sort(([p],[g])=>p.localeCompare(g))){let p=
|
|
233
|
-
`);u.set(l,p.digest("hex"))}return u}function V(e,t){return e.prepare(t).get().value}import
|
|
234
|
-
`)}function
|
|
232
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,d]of Object.entries({documents:i,chunks:o,definitions:a,mentions:s}))for(let p of d){let g=JSON.stringify([l,p]),f=c.get(p.relative_path)??[];f.push(g),c.set(p.relative_path,f)}let u=new Map;for(let[l,d]of[...c].sort(([p],[g])=>p.localeCompare(g))){let p=Ta("sha256");for(let g of d.sort())p.update(g).update(`
|
|
233
|
+
`);u.set(l,p.digest("hex"))}return u}function V(e,t){return e.prepare(t).get().value}import Wa from"better-sqlite3";var Le="idx_mentions_definitions",Ga=["symbol_id","chunk_id"];function Et(e){let t=new Wa(F(e)),n=[],r=[],i=[];try{return t.transaction(()=>{qa(t,n),Oe(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&Vr(t,"global_symbols").some(s=>s.name!=="idx_global_symbols_symbol"&&s.unique&&s.columns.join("\0")==="symbol")?(t.exec('DROP INDEX "idx_global_symbols_symbol"'),r.push("idx_global_symbols_symbol")):Oe(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let o=Oe(t,"idx_chunks_doc_id"),a=Vr(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");o?.join("\0")==="document_id"&&a?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):o&&i.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:i,analyzed:!0}}catch(o){if(o.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw o}finally{t.close()}}function qa(e,t){let n=Br(e,Le);if(n){let r=n.columns.join("\0")===Ga.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${Le} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Le}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Le)}function Vr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Oe(e,n.name)??[]}))}function Oe(e,t){return Br(e,t)?.columns??null}function Br(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(i=>i.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{writeFileSync as Ja}from"fs";function z(e,t){let n=performance.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:performance.now()-n,result:r}}async function Ur(e){let t=e.readFingerprint(),n=Ha(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return za(e.cachePath,e.readFingerprint(),r),r}function Ha(e,t){try{let n=JSON.parse(_(e,{maxBytes:Q,inputKind:"post-index augmentation cache"}));return $r(n.fingerprint)===$r(t)?{result:n.result}:null}catch{return null}}function za(e,t,n){Ja(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
|
|
234
|
+
`)}function $r(e){return JSON.stringify(e)}import{existsSync as Wr,statSync as Xa}from"fs";import{dirname as Jr,join as Hr}from"path";var Ya="reindex-activity.jsonl",Ne=ie,Ka=1024*1024,Qa=1440*60*1e3,Gr=e=>D(e,"reindex activity segment");function Ce(e){return Hr(Jr(e),Ya)}function Za(e){if(e.reused)return 0;let t=kt(e.indexPath)+kt(e.dbPath);for(let n of e.shards??[])!n.reused&&n.outputBytes!==null&&(t+=n.outputBytes);return t}function Tt(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=Za(t);return wt(Ce(e),{version:1,event:"run",recordedAt:n.completedAt,trigger:n.trigger,result:n.result,durationMs:n.durationMs,estimatedLogicalOutputBytes:r,estimatedWriteBytes:r+(t.writeTelemetry?.fallbackCopiedBytes??0),reflinkedBytes:t.writeTelemetry?.reflinkedBytes??0,fallbackCopiedBytes:t.writeTelemetry?.fallbackCopiedBytes??0,byLanguage:os(t)})}function zr(e,t){return wt(Ce(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function Zd(e,t,n=new Date){return wt(Ce(e),{version:1,event:"suppressed",recordedAt:n.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function es(e,t,n=Ka,r){De(e,t,{maxSegmentBytes:n,previousSuffix:Ne,...r?{runtime:r}:{}})}function ts(e,t=new Date,n=Qa,r=Gr){let i=t.getTime(),o=i-n,a={confidence:"complete",recordsRead:0,invalidRecords:0,skippedRecords:0,readErrors:0,ignoredPartialTailBytes:0,windowStartedAt:new Date(o).toISOString(),windowEndedAt:t.toISOString(),runs:0,rebuilt:0,reused:0,failed:0,suppressed:0,estimatedLogicalOutputBytes:0,estimatedWriteBytes:0,reflinkedBytes:0,fallbackCopiedBytes:0,languageAttribution:"complete",attributedRuns:0,unattributedRuns:0,invalidLanguageDetails:0,byLanguage:{},byTrigger:{}},s=Ce(e),c=[];if(r===Gr){if(!Wr(s)&&!Wr(`${s}${Ne}`))return a;try{let u=mr(s,{previousSuffix:Ne});c=u.lines,a.ignoredPartialTailBytes=u.ignoredPartialTailBytes}catch{a.readErrors+=1,a.confidence="unavailable"}}else{let u=0;for(let l of[`${s}${Ne}`,s])try{c.push(...ps(r(l))),u+=1}catch{a.readErrors+=1}u===0?a.confidence="unavailable":a.readErrors>0&&(a.confidence="partial")}for(let u of c){a.recordsRead+=1;let l=ns(u);if(!l){a.invalidRecords+=1,a.confidence!=="unavailable"&&(a.confidence="partial");continue}let{record:d}=l,p=Date.parse(d.recordedAt);if(p<o||p>i){a.skippedRecords+=1;continue}if(a.invalidLanguageDetails=(a.invalidLanguageDetails??0)+l.invalidLanguageDetails,a.byTrigger[d.trigger.kind]=(a.byTrigger[d.trigger.kind]??0)+1,d.event==="suppressed"){a.suppressed+=1;continue}a.runs+=1,a[d.result]+=1,a.estimatedLogicalOutputBytes+=d.estimatedLogicalOutputBytes,a.estimatedWriteBytes=(a.estimatedWriteBytes??0)+(d.estimatedWriteBytes??d.estimatedLogicalOutputBytes),a.reflinkedBytes=(a.reflinkedBytes??0)+(d.reflinkedBytes??0),a.fallbackCopiedBytes=(a.fallbackCopiedBytes??0)+(d.fallbackCopiedBytes??0),d.result!=="failed"&&(l.hasLanguageDetails?a.attributedRuns=(a.attributedRuns??0)+1:a.unattributedRuns=(a.unattributedRuns??0)+1);for(let[g,f]of us(d.byLanguage)){let m=(a.byLanguage??={})[g]??=ls();m.runs+=1,m[f.result]+=1,m.producedOutputBytes+=f.producedOutputBytes,m.durationMs+=f.durationMs}d.result==="rebuilt"&&a.oldestRebuildAt===void 0&&(a.oldestRebuildAt=d.recordedAt),(d.estimatedWriteBytes??d.estimatedLogicalOutputBytes)>0&&a.oldestWriteAt===void 0&&(a.oldestWriteAt=d.recordedAt)}return a.ignoredPartialTailBytes>0&&a.confidence!=="unavailable"&&(a.confidence="partial"),a.languageAttribution=ds(a),a}function wt(e,t){try{return es(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function ns(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(n.version!==1||!rn(n.recordedAt)||!n.trigger||!is(n.trigger.kind))return null;if(n.event==="suppressed")return n.reason==="completed-index-is-fresh"?{record:n,hasLanguageDetails:!1,invalidLanguageDetails:0}:null;if(n.event!=="run"||n.result!=="rebuilt"&&n.result!=="reused"&&n.result!=="failed"||!$(n.durationMs)||!$(n.estimatedLogicalOutputBytes)||n.estimatedWriteBytes!==void 0&&!$(n.estimatedWriteBytes)||n.reflinkedBytes!==void 0&&!$(n.reflinkedBytes)||n.fallbackCopiedBytes!==void 0&&!$(n.fallbackCopiedBytes))return null;let r=n,{byLanguage:i,...o}=r,a=as(i);return{record:{...o,...a.byLanguage?{byLanguage:a.byLanguage}:{}},hasLanguageDetails:a.hasLanguageDetails,invalidLanguageDetails:a.invalidLanguageDetails}}catch{return null}}function ep(e,t,n=new Date){return t.enabled?rs(ts(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function rs(e,t,n){let r=e.estimatedWriteBytes??e.estimatedLogicalOutputBytes,i={rebuilt:e.rebuilt,estimatedWriteBytes:r};return t.enabled?e.confidence!==void 0&&e.confidence!=="complete"?{state:"paused",reason:"activity-evidence",until:n+t.windowMs,...i,detail:`reindex activity evidence is ${e.confidence}`}:e.rebuilt>=t.maxRebuilds?{state:"paused",reason:"rebuild-count",until:qr(e.oldestRebuildAt,t.windowMs,n),...i,detail:`${e.rebuilt}/${t.maxRebuilds} automatic rebuild slots consumed`}:r>=t.maxEstimatedWriteBytes?{state:"paused",reason:"estimated-write-bytes",until:qr(e.oldestWriteAt,t.windowMs,n),...i,detail:`${r}/${t.maxEstimatedWriteBytes} estimated write bytes consumed`}:{state:"allowed",...i}:{state:"allowed",...i}}function qr(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function is(e){return e==="manual-cli"||e==="setup"||e==="watch-source"||e==="watch-startup"||e==="watch-demand"||e==="watch-git-head"||e==="watch-git-index"||e==="watch-git-state"||e==="unknown"}function kt(e){try{return Xa(e).size}catch{return 0}}function os(e){let t={};for(let n of e.languages){let r=(e.shards??[]).filter(u=>u.language===n),i=r.find(u=>u.id===n),o=e.reused||(i?i.reused:r.length>0&&r.every(u=>u.reused)),a=kt(Hr(Jr(e.dbPath),"language-indexes",`${n}.scip`)),s=a>0?a:i?.outputBytes??a,c=o?0:i?.durationMs??r.filter(u=>!u.reused).reduce((u,l)=>u+l.durationMs,0);t[n]={result:o?"reused":"rebuilt",outputBytes:s,producedOutputBytes:o?0:s,durationMs:c}}return t}function as(e){if(e===void 0)return{hasLanguageDetails:!1,invalidLanguageDetails:0};if(!e||typeof e!="object"||Array.isArray(e))return{hasLanguageDetails:!1,invalidLanguageDetails:1};let t={},n=0;for(let[i,o]of Object.entries(e)){if(!cs(i)||!ss(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function ss(e){if(!e||typeof e!="object")return!1;let t=e;return(t.result==="rebuilt"||t.result==="reused")&&et(t.outputBytes)&&et(t.producedOutputBytes)&&$(t.durationMs)&&(t.result!=="reused"||t.producedOutputBytes===0&&t.durationMs===0)&&t.producedOutputBytes<=t.outputBytes}function cs(e){return Ze.includes(e)}function us(e){return e?Ze.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function ls(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function ds(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function ps(e){return e.endsWith(`
|
|
235
235
|
`)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
|
|
236
236
|
`)+1))),e.split(`
|
|
237
|
-
`).filter(t=>t.length>0)}import{createHash as
|
|
238
|
-
`;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function
|
|
237
|
+
`).filter(t=>t.length>0)}import{createHash as gs}from"crypto";import{existsSync as _t,readdirSync as fs}from"fs";import{dirname as Ft,join as je,relative as ms,resolve as Dt,sep as Xr}from"path";function Yr(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=ei(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function Kr(e,t){let n=new Map;for(let i of e){let o=t[i]?.packageName;o&&n.set(o,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let o=t[i],a=r.get(i);if(!o||o.parseFailed){for(let s of e)s!==i&&a.add(s);continue}for(let s of o.dependencyNames){let c=n.get(s);c&&c!==i&&a.add(c)}for(let s of[...o.pathsTargets,...o.referencesPaths]){let c=ei(s,e);c&&c!==i&&a.add(c)}}return hs(e,r)}function Qr(e,t,n){let r={};for(let i of e){let o=new Map;for(let a of t.files[i]??[])o.set(a.path,a);for(let a of n[i]??[])for(let s of t.files[a]??[])o.set(s.path,s);for(let a of t.shared)o.set(a.path,a);r[i]={files:[...o.values()].sort((a,s)=>a.path.localeCompare(s.path))}}return r}function At(e){if(e===".")return"root";let t=gs("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Zr(e,t){let n=Dt(e),r={};for(let i of t)r[i]=ys(n,i);return r}function ei(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function hs(e,t){let n={};for(let r of e){let i=new Set,o=[...t.get(r)??[]];for(;o.length>0;){let a=o.pop();if(!(a===r||i.has(a))){i.add(a);for(let s of t.get(a)??[])s!==r&&!i.has(s)&&o.push(s)}}n[r]=[...i].sort((a,s)=>a.localeCompare(s))}return n}function ys(e,t){let n=t==="."?e:je(e,t),r=bs(n),i=Ss(n),o=i?Rs(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:o.pathsTargets,referencesPaths:o.referencesPaths,parseFailed:r.failed||o.failed}}function bs(e){let t=je(e,"package.json");if(!_t(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Lt(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let o of["dependencies","devDependencies","peerDependencies"]){let a=n.value[o];if(a&&typeof a=="object"&&!Array.isArray(a))for(let s of Object.keys(a))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function Ss(e){let t=je(e,"tsconfig.json");if(_t(t))return t;let n;try{n=fs(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?je(e,n[0]):void 0}function Rs(e,t){let n=Lt(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=xs(n.value,e,t),i=ti(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function xs(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Ft(t),o=new Set;for(let a of r){if(!a||typeof a!="object")continue;let s=a.path;if(typeof s!="string"||s.trim()==="")continue;let c=ni(s,i,n);c&&o.add(c)}return[...o]}function ti(e,t,n,r){let i=Ps(t);if(i)return{pathsTargets:vs(i,Ft(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=Is(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=Lt(o);return a.ok?ti(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function Ps(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function vs(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let o of i){if(typeof o!="string")continue;let a=ni(o,t,n);a&&r.add(a)}return[...r]}function Is(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=Dt(Ft(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Xr).includes("node_modules")&&nt(n,i)&&_t(i))return i}function ni(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Dt(t,r===""?".":r);if(!nt(n,i))return;let a=ms(n,i).split(Xr).join("/");return a===""?".":a}function Es(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let o=e[n];if(r){if(t+=o,o==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}o==='"'&&(r=!1),n+=1;continue}if(o==='"'){r=!0,t+=o,n+=1;continue}if(o==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
238
|
+
`;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function Lt(e){try{let t=_(e,{maxBytes:Q,inputKind:"TypeScript project manifest"}),n=JSON.parse(Es(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{writeFileSync as $s}from"fs";import{deserializeSCIP as Us,PositionEncoding as Me,serializeSCIP as Ws}from"@c4312/scip";import{rmSync as Ts}from"fs";import ws from"better-sqlite3";var _s=200,Fs=[`CREATE TABLE documents (
|
|
239
239
|
id INTEGER PRIMARY KEY,
|
|
240
240
|
language TEXT,
|
|
241
241
|
relative_path TEXT NOT NULL UNIQUE,
|
|
@@ -275,11 +275,11 @@ import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as
|
|
|
275
275
|
end_char INTEGER NOT NULL,
|
|
276
276
|
FOREIGN KEY (document_id) REFERENCES documents(id),
|
|
277
277
|
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
278
|
-
)`],
|
|
279
|
-
`)||null,i.enclosingSymbol||null).lastInsertRowid);return n.set(i.symbol,a),a};return{declared:r,referenced:i=>r({symbol:i,displayName:null,kind:null,documentation:[],enclosingSymbol:null})}}function
|
|
280
|
-
VALUES (?, ?, ?, ?, ?, ?)`);for(let i of n.occurrences){if((i.roles&1)===0||we(i.symbol)||!i.enclosingRange)continue;let[o,a,s,c]=Ds(i,n.relativePath);r.run(n.id,t.referenced(i.symbol),o,a,s,c)}}function _s(e,t,n){let r=e.prepare("INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?)"),i=e.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)");As(n.occurrences).forEach((o,a)=>{let s=Number(r.run(n.id,a,o.startLine,o.endLine,zn(o.occurrences)).lastInsertRowid),c=new Map;for(let u of o.occurrences){if(we(u.symbol))continue;let l=c.get(u.symbol)??new Set;l.add(u.roles),c.set(u.symbol,l)}for(let[u,l]of c){let d=t.referenced(u);for(let p of l)i.run(s,d,p)}})}function Fs(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,{...r,documentation:[...r.documentation,...n.documentation.filter(i=>!r.documentation.includes(i))]})}return[...t.values()].sort((n,r)=>ti(n.symbol,r.symbol))}function Ls(e){let t=[...e].sort((r,i)=>Zr(r.range,i.range)||ti(r.symbol,i.symbol)),n=[];for(let r of t){let i=n.at(-1);i&&i.symbol===r.symbol&&Zr(i.range,r.range)===0?n[n.length-1]={...i,roles:i.roles|r.roles}:n.push(r)}return n}function As(e){let t=[],n=0;for(;n<e.length;){let r=Math.min(e.length,n+Ps);for(;r<e.length&&e[r-1].range[0]===e[r].range[0];)r+=1;t.push({startLine:e[n].range[0],endLine:e[r-1].range[0],occurrences:e.slice(n,r)}),n=r}return t}function Ds(e,t){let n=e.enclosingRange,[r,i,o,a]=n;if(!(r>=0&&i>=0&&(o>r&&a>=0||o===r&&a>=i)))throw new Error(`bad enclosing range ${JSON.stringify(n)} for symbol ${e.symbol} in document ${t}`);return n}function Zr(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]||e[3]-t[3]}function ti(e,t){return e<t?-1:e>t?1:0}var js={[Me.UnspecifiedPositionEncoding]:null,[Me.UTF8CodeUnitOffsetFromLineStart]:"UTF-8",[Me.UTF16CodeUnitOffsetFromLineStart]:"UTF-16",[Me.UTF32CodeUnitOffsetFromLineStart]:"UTF-32"};function ri(e,t,n){let r=Ns(D(e,{inputKind:"SCIP index store input",maxBytes:ce})),i={removedDefinitionOccurrences:0,touchedDocuments:0};if(n.sanitize){let o=Fn(r);o.touchedDocuments>0&&(Os(e,Buffer.from(Cs(o.index))),r=o.index),i={removedDefinitionOccurrences:o.removedDefinitionOccurrences,touchedDocuments:o.touchedDocuments}}return ei(t,r.documents.map(Ms)),i}function Ms(e){let t=js[e.positionEncoding];if(t===void 0)throw new Error(`unknown position encoding ${e.positionEncoding} in ${e.relativePath}`);return{relativePath:e.relativePath,language:e.language||null,positionEncoding:t,text:e.text||null,symbols:e.symbols.map(n=>({symbol:n.symbol,displayName:n.displayName||null,kind:n.kind||null,documentation:n.documentation,enclosingSymbol:n.enclosingSymbol||null})),occurrences:e.occurrences.flatMap(n=>{let r=ni(n.range);return r?[{symbol:n.symbol,roles:n.symbolRoles,range:r,enclosingRange:ni(n.enclosingRange)}]:[]})}}function ni(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}import{createHash as rc}from"crypto";import{existsSync as Ot,statSync as ic,writeFileSync as Nt}from"fs";import{join as oc}from"path";import{createRequire as Vs}from"module";import{dirname as $s,isAbsolute as dp,relative as pp,resolve as gp,sep as fp}from"path";var ii=Vs(import.meta.url),Bs=1,oi="0.4.0";function Dt(){let e=Us();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function Us(){try{let e=ii.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(L(e,"scip-typescript package manifest"));if(t.version!==oi)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${oi}`};let n=$s(e),r=ii.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(L(r,"TypeScript package manifest"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:n,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:Ws(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Ws(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${Bs}`}import{createHash as Gs}from"crypto";import{dirname as qs,join as ai}from"path";var Ve=4;var Js="typescript-index";function si(e){let t=ai(e,Js),n=Sn(t);return{...n,requestDir:n.legacyRequestDir}}function ci(e){try{let t=sn(ee(L(ai(qs(e),"meta.json"),"reindex metadata")));return t?Gs("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as Hs}from"crypto";import{existsSync as zs}from"fs";var Xs=12e4,Ys=5,$e=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=Qt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??tc(),this.runtime=n.runtime??nc,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=nn(this.cacheDir),r=si(this.cacheDir),i=tt(n.statePath);if(!ui(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let o=this.runtime.now(),a=o+this.timeoutMs,s=(this.runtime.monotonicNow??R)()+this.timeoutMs,c=dt("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),u=pt(c),l=Rn(r,{mailboxVersion:lt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:Ve,id:u,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??R)()<=s;){if(zs(l.responsePath))return Ks(_(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let d=tt(n.statePath);if(!ui(d,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Ys)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function ui(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Ve&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&ue(e.processIdentity,r))}function Ks(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==Ve||a.id!==t||a.operationKey!==n||a.ok===!0&&a.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(a.ok!==!0)throw new Error(typeof a.error=="string"?a.error:"TypeScript index service request failed.");let s=Qs(a.response,i),c=[...new Set(o)].sort(),u=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(u)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return s}function Qs(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(o=>{if(!o||typeof o.relativePath!="string"||o.bytesBase64!==null&&typeof o.bytesBase64!="string"||typeof o.occurrences!="number"||!Number.isInteger(o.occurrences)||o.occurrences<0||typeof o.symbols!="number"||!Number.isInteger(o.symbols)||o.symbols<0||!Array.isArray(o.referenceFragments)||!o.referenceFragments.every(Zs)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:ec(o.bytesBase64);return{relativePath:o.relativePath,bytes:a,occurrences:o.occurrences,symbols:o.symbols,referenceFragments:o.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Zs(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function ec(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function tc(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Xs}var nc={now:Date.now,monotonicNow:R,randomId:Hs,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:K,readProcessIdentity:Z};function ac(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=Se(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(l=>l.kind!=="modified"||l.inputKind!=="source"||!ft(l.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Fe(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=sc(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=li(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=li(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=pi(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=pi(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);if(!c)return{eligible:!1,reason:"next document identity unavailable"};let u=i.length===1?i[0]:void 0;return{eligible:!0,manifest:n,plan:r,projectIdentity:o,previousFragmentGeneration:di(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:di(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...u?{tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument}:{}}}function sc(e,t,n){let r=new Map;for(let o of e.affectedFiles){let a=cc(o,t);if(!a)return null;let s=r.get(a)??[];s.push(o),r.set(a,s)}let i=[];for(let[o,a]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(a),c=e.changedFiles.filter(u=>s.has(u)||a.some(l=>uc(l,u,n)));if(c.length===0)return null;i.push({projectArgument:o,tsconfigPath:o==="."?"tsconfig.json":`${o}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...a].sort()})}return i}function cc(e,t){let n=t.filter(o=>o==="."||e===o||e.startsWith(`${o}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((o,a)=>Be(a)-Be(o)||o.localeCompare(a)),i=r[0];return r[1]&&Be(r[1])===Be(i)?null:i}function Be(e){return e==="."?0:e.split("/").filter(Boolean).length}function uc(e,t,n){let r=new Set,i=[e];for(let o=0;o<i.length;o+=1){let a=i[o];if(!(!a||r.has(a))){r.add(a);for(let s of n.get(a)??[]){if(s===t)return!0;r.has(s)||i.push(s)}}}return!1}function gi(e){let t=R();try{if(!Ot(e.previousDbPath)||!Ot(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Dt();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new O({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=Ee(o,{includeIgnored:!1}).filter(ft).sort(),s=ke(o)}finally{o.close()}let c=performance.now()-n,u=ac({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?ne(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:Ot(oc(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let l=ci(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let d=new $e({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}),p=u.projects.map(x=>d.request({kind:"emit-documents",tsconfigPath:x.tsconfigPath,projectArgument:x.projectArgument,projectIdentity:u.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:x.modifiedFiles,affectedFiles:x.affectedFiles})),g=p.flatMap(x=>x.fragments),f=performance.now()-n,m=ic(e.previousShardPath).size>=kn;n=performance.now();let I=m?null:D(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:ce}),h=m?{completeIndexBytes:null,affectedIndexBytes:xn(g)}:In({packageVersion:r.packageVersion,baseIndexBytes:I,fragments:g}),b=performance.now()-n;n=performance.now(),m?Tn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(Pn({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:I,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),vn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:g,documentIdentities:u.nextDocumentIdentities}));let S=performance.now()-n;n=performance.now(),h.completeIndexBytes&&Nt(e.candidateShardPath,h.completeIndexBytes),Nt(e.candidateAffectedScipPath,h.affectedIndexBytes);let v=performance.now()-n,P={scipPath:m?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!m,durationMs:R()-t,cold:p.some(x=>x.cold),changedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:u.previousFragmentGeneration,nextFragmentGeneration:u.nextFragmentGeneration,manifest:u.manifest,plan:u.plan,projectFileCount:a.length,referenceFragmentsByFile:new Map(g.map(x=>[x.relativePath,x.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:f,serviceMs:p.reduce((x,X)=>x+X.durationMs,0),assemblyMs:b,fragmentStoreMs:S,writeMs:v}};return e.onStatus(`Incremental TypeScript index emitted ${P.affectedFiles.length} affected document(s) across ${u.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; ${m?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${f.toFixed(0)}ms, assembly ${b.toFixed(0)}ms, fragments ${S.toFixed(0)}ms, write ${v.toFixed(0)}ms).`),P}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function fi(e){let t=Dt();if(!t.available)throw new Error(t.reason);let n=wn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:D(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:ce}),packageVersion:t.packageVersion});Nt(e.candidateShardPath,n)}function li(e,t,n){let r=e.files.filter(i=>on(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return Ct(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function di(e,t){return Ct(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function pi(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=Xn({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let u=a.identityFor(c,"typescript-scip-document-v1");if(u.key){s.set(c,u.key);continue}if(o.has(c))return null;s.set(c,Ct(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function Ct(e){return rc("sha256").update(e).digest("hex")}import{closeSync as lc,existsSync as Ue,fstatSync as dc,lstatSync as pc,openSync as gc,renameSync as Mt,rmSync as We,statSync as fc,writeSync as mc}from"fs";import{cpus as hc}from"os";import{join as Vt}from"path";function yc(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=Vt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=gc(n,"wx",384)}catch(o){if(o.code==="EEXIST")return null;throw o}try{mc(i,r);let o=dc(i);return{path:n,content:r,device:o.dev,inode:o.ino}}finally{lc(i)}}function bc(e){if(e)try{let t=pc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=D(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;We(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function Sc(e,t,n){if(!e.defaultOutputPath)return;let r=Vt(t,e.defaultOutputPath);n!==r&&Ue(r)&&Mt(r,n)}function Rc(e,t,n){if(!e.defaultOutputPath)return null;let r=Vt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return We(i,{force:!0}),Ue(r)?(Mt(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function xc(e){e&&(We(e.defaultOutputPath,{force:!0}),e.backupPath&&Ue(e.backupPath)&&Mt(e.backupPath,e.defaultOutputPath))}function Pc(e,t){if(e<=1)return 1;let n=Number(process.env.CODEBASEIQ_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,hc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function hi(e,t,n,r,i){A(i,"Reindex cancelled by its owner.");let o=e.filter(l=>l.config.defaultOutputPath),a=e.filter(l=>!l.config.defaultOutputPath),s=[],c=Pc(a.length,r),u=await ir(a,c,l=>jt(l,t,n,i));if(c>1){let l=new Map;for(let d of u.filter(p=>p.result.skipped&&p.retryable)){let p=a.find(g=>g.id===d.result.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),A(i,"Reindex cancelled by its owner."),l.set(p.id,(await jt(p,t,n,i)).result))}s.push(...u.map(({result:d})=>l.get(d.id)??d))}else s.push(...u.map(({result:l})=>l));for(let l of o)A(i,"Reindex cancelled by its owner."),s.push((await jt(l,t,n,i)).result);return s.sort((l,d)=>e.findIndex(p=>p.id===l.id)-e.findIndex(p=>p.id===d.id))}async function jt(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),We(e.scipPath,{force:!0});let i=Rc(e.config,t,e.scipPath),o=yc(e,t),a=[e.binary,...e.args].join(" "),s=R();try{e.trustedProjectTool&&Jn(t,e.trustedProjectTool);let u=Un(e.binary,e.args),l=await rr({command:u.binary,args:u.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:vc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let d=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${d?`:
|
|
281
|
-
${d}`:""}`)}
|
|
282
|
-
`)
|
|
278
|
+
)`],Ds=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function ii(e,t){Ts(e,{force:!0});let n=new ws(F(e));try{n.pragma("journal_mode = WAL"),n.pragma("synchronous = NORMAL"),n.pragma("temp_store = MEMORY"),n.pragma("foreign_keys = ON");for(let r of Fs)n.exec(r);n.transaction(()=>As(n,t)).immediate(),n.transaction(()=>{for(let r of Ds)n.exec(r)}).immediate()}finally{n.close()}}function As(e,t){let n=Ls(e);for(let r of Os(e,n,t))Ns(e,n,r),Cs(e,n,r)}function Ls(e){let t=e.prepare("INSERT INTO global_symbols (symbol, display_name, kind, documentation, enclosing_symbol) VALUES (?, ?, ?, ?, ?)"),n=new Map,r=i=>{let o=n.get(i.symbol);if(o!==void 0)return o;let a=Number(t.run(i.symbol,i.displayName||null,i.kind||null,i.documentation.join(`
|
|
279
|
+
`)||null,i.enclosingSymbol||null).lastInsertRowid);return n.set(i.symbol,a),a};return{declared:r,referenced:i=>r({symbol:i,displayName:null,kind:null,documentation:[],enclosingSymbol:null})}}function Os(e,t,n){let r=e.prepare("INSERT INTO documents (language, relative_path, position_encoding, text) VALUES (?, ?, ?, ?)"),i=[],o=new Set;for(let a of n){if(!a.relativePath)throw new Error("document relative path must not be empty");if(o.has(a.relativePath))continue;o.add(a.relativePath);let s=Number(r.run(a.language||null,a.relativePath,a.positionEncoding,a.text||null).lastInsertRowid);for(let c of js(a.symbols)){if(!c.symbol)throw new Error(`empty symbol in symbol information for document ${a.relativePath}`);we(c.symbol)||t.declared(c)}i.push({id:s,relativePath:a.relativePath,occurrences:Ms(a.occurrences)})}return i}function Ns(e,t,n){let r=e.prepare(`INSERT INTO defn_enclosing_ranges (document_id, symbol_id, start_line, start_char, end_line, end_char)
|
|
280
|
+
VALUES (?, ?, ?, ?, ?, ?)`);for(let i of n.occurrences){if((i.roles&1)===0||we(i.symbol)||!i.enclosingRange)continue;let[o,a,s,c]=Bs(i,n.relativePath);r.run(n.id,t.referenced(i.symbol),o,a,s,c)}}function Cs(e,t,n){let r=e.prepare("INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?)"),i=e.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)");Vs(n.occurrences).forEach((o,a)=>{let s=Number(r.run(n.id,a,o.startLine,o.endLine,Qn(o.occurrences)).lastInsertRowid),c=new Map;for(let u of o.occurrences){if(we(u.symbol))continue;let l=c.get(u.symbol)??new Set;l.add(u.roles),c.set(u.symbol,l)}for(let[u,l]of c){let d=t.referenced(u);for(let p of l)i.run(s,d,p)}})}function js(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,{...r,documentation:[...r.documentation,...n.documentation.filter(i=>!r.documentation.includes(i))]})}return[...t.values()].sort((n,r)=>oi(n.symbol,r.symbol))}function Ms(e){let t=[...e].sort((r,i)=>ri(r.range,i.range)||oi(r.symbol,i.symbol)),n=[];for(let r of t){let i=n.at(-1);i&&i.symbol===r.symbol&&ri(i.range,r.range)===0?n[n.length-1]={...i,roles:i.roles|r.roles}:n.push(r)}return n}function Vs(e){let t=[],n=0;for(;n<e.length;){let r=Math.min(e.length,n+_s);for(;r<e.length&&e[r-1].range[0]===e[r].range[0];)r+=1;t.push({startLine:e[n].range[0],endLine:e[r-1].range[0],occurrences:e.slice(n,r)}),n=r}return t}function Bs(e,t){let n=e.enclosingRange,[r,i,o,a]=n;if(!(r>=0&&i>=0&&(o>r&&a>=0||o===r&&a>=i)))throw new Error(`bad enclosing range ${JSON.stringify(n)} for symbol ${e.symbol} in document ${t}`);return n}function ri(e,t){return e[0]-t[0]||e[1]-t[1]||e[2]-t[2]||e[3]-t[3]}function oi(e,t){return e<t?-1:e>t?1:0}var Gs={[Me.UnspecifiedPositionEncoding]:null,[Me.UTF8CodeUnitOffsetFromLineStart]:"UTF-8",[Me.UTF16CodeUnitOffsetFromLineStart]:"UTF-16",[Me.UTF32CodeUnitOffsetFromLineStart]:"UTF-32"};function si(e,t,n){let r=Us(L(e,{inputKind:"SCIP index store input",maxBytes:ce})),i={removedDefinitionOccurrences:0,touchedDocuments:0};if(n.sanitize){let o=On(r);o.touchedDocuments>0&&($s(e,Buffer.from(Ws(o.index))),r=o.index),i={removedDefinitionOccurrences:o.removedDefinitionOccurrences,touchedDocuments:o.touchedDocuments}}return ii(t,r.documents.map(qs)),i}function qs(e){let t=Gs[e.positionEncoding];if(t===void 0)throw new Error(`unknown position encoding ${e.positionEncoding} in ${e.relativePath}`);return{relativePath:e.relativePath,language:e.language||null,positionEncoding:t,text:e.text||null,symbols:e.symbols.map(n=>({symbol:n.symbol,displayName:n.displayName||null,kind:n.kind||null,documentation:n.documentation,enclosingSymbol:n.enclosingSymbol||null})),occurrences:e.occurrences.flatMap(n=>{let r=ai(n.range);return r?[{symbol:n.symbol,roles:n.symbolRoles,range:r,enclosingRange:ai(n.enclosingRange)}]:[]})}}function ai(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}import{createHash as lc}from"crypto";import{existsSync as Nt,statSync as dc,writeFileSync as Ct}from"fs";import{join as pc}from"path";import{createRequire as Js}from"module";import{dirname as Hs,isAbsolute as Ip,relative as Ep,resolve as kp,sep as Tp}from"path";var ci=Js(import.meta.url),zs=1,ui="0.4.0";function Ot(){let e=Xs();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function Xs(){try{let e=ci.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(D(e,"scip-typescript package manifest"));if(t.version!==ui)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${ui}`};let n=Hs(e),r=ci.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(D(r,"TypeScript package manifest"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:n,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:Ys(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Ys(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${zs}`}import{createHash as Ks}from"crypto";import{dirname as Qs,join as li}from"path";var Ve=4;var Zs="typescript-index";function di(e){let t=li(e,Zs),n=vn(t);return{...n,requestDir:n.legacyRequestDir}}function pi(e){try{let t=dn(ee(D(li(Qs(e),"meta.json"),"reindex metadata")));return t?Ks("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as ec}from"crypto";import{existsSync as tc}from"fs";var nc=12e4,rc=5,Be=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=en(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??cc(),this.runtime=n.runtime??uc,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=on(this.cacheDir),r=di(this.cacheDir),i=tt(n.statePath);if(!gi(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let o=this.runtime.now(),a=o+this.timeoutMs,s=(this.runtime.monotonicNow??R)()+this.timeoutMs,c=pt("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),u=gt(c),l=In(r,{mailboxVersion:dt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:Ve,id:u,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??R)()<=s;){if(tc(l.responsePath))return ic(_(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let d=tt(n.statePath);if(!gi(d,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(rc)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function gi(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Ve&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&ue(e.processIdentity,r))}function ic(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==Ve||a.id!==t||a.operationKey!==n||a.ok===!0&&a.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(a.ok!==!0)throw new Error(typeof a.error=="string"?a.error:"TypeScript index service request failed.");let s=oc(a.response,i),c=[...new Set(o)].sort(),u=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(u)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return s}function oc(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(o=>{if(!o||typeof o.relativePath!="string"||o.bytesBase64!==null&&typeof o.bytesBase64!="string"||typeof o.occurrences!="number"||!Number.isInteger(o.occurrences)||o.occurrences<0||typeof o.symbols!="number"||!Number.isInteger(o.symbols)||o.symbols<0||!Array.isArray(o.referenceFragments)||!o.referenceFragments.every(ac)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:sc(o.bytesBase64);return{relativePath:o.relativePath,bytes:a,occurrences:o.occurrences,symbols:o.symbols,referenceFragments:o.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function ac(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function sc(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function cc(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:nc}var uc={now:Date.now,monotonicNow:R,randomId:ec,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:K,readProcessIdentity:Z};function gc(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=Se(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(l=>l.kind!=="modified"||l.inputKind!=="source"||!mt(l.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Fe(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=fc(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=fi(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=fi(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=hi(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=hi(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);if(!c)return{eligible:!1,reason:"next document identity unavailable"};let u=i.length===1?i[0]:void 0;return{eligible:!0,manifest:n,plan:r,projectIdentity:o,previousFragmentGeneration:mi(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:mi(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...u?{tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument}:{}}}function fc(e,t,n){let r=new Map;for(let o of e.affectedFiles){let a=mc(o,t);if(!a)return null;let s=r.get(a)??[];s.push(o),r.set(a,s)}let i=[];for(let[o,a]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(a),c=e.changedFiles.filter(u=>s.has(u)||a.some(l=>hc(l,u,n)));if(c.length===0)return null;i.push({projectArgument:o,tsconfigPath:o==="."?"tsconfig.json":`${o}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...a].sort()})}return i}function mc(e,t){let n=t.filter(o=>o==="."||e===o||e.startsWith(`${o}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((o,a)=>$e(a)-$e(o)||o.localeCompare(a)),i=r[0];return r[1]&&$e(r[1])===$e(i)?null:i}function $e(e){return e==="."?0:e.split("/").filter(Boolean).length}function hc(e,t,n){let r=new Set,i=[e];for(let o=0;o<i.length;o+=1){let a=i[o];if(!(!a||r.has(a))){r.add(a);for(let s of n.get(a)??[]){if(s===t)return!0;r.has(s)||i.push(s)}}}return!1}function yi(e){let t=R();try{if(!Nt(e.previousDbPath)||!Nt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Ot();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new O({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=Ee(o,{includeIgnored:!1}).filter(mt).sort(),s=ke(o)}finally{o.close()}let c=performance.now()-n,u=gc({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?ne(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:Nt(pc(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let l=pi(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let d=new Be({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}),p=u.projects.map(x=>d.request({kind:"emit-documents",tsconfigPath:x.tsconfigPath,projectArgument:x.projectArgument,projectIdentity:u.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:x.modifiedFiles,affectedFiles:x.affectedFiles})),g=p.flatMap(x=>x.fragments),f=performance.now()-n,m=dc(e.previousShardPath).size>=Fn;n=performance.now();let I=m?null:L(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:ce}),h=m?{completeIndexBytes:null,affectedIndexBytes:En(g)}:wn({packageVersion:r.packageVersion,baseIndexBytes:I,fragments:g}),b=performance.now()-n;n=performance.now(),m?Dn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(kn({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:I,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),Tn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:g,documentIdentities:u.nextDocumentIdentities}));let S=performance.now()-n;n=performance.now(),h.completeIndexBytes&&Ct(e.candidateShardPath,h.completeIndexBytes),Ct(e.candidateAffectedScipPath,h.affectedIndexBytes);let v=performance.now()-n,P={scipPath:m?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!m,durationMs:R()-t,cold:p.some(x=>x.cold),changedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:u.previousFragmentGeneration,nextFragmentGeneration:u.nextFragmentGeneration,manifest:u.manifest,plan:u.plan,projectFileCount:a.length,referenceFragmentsByFile:new Map(g.map(x=>[x.relativePath,x.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:f,serviceMs:p.reduce((x,X)=>x+X.durationMs,0),assemblyMs:b,fragmentStoreMs:S,writeMs:v}};return e.onStatus(`Incremental TypeScript index emitted ${P.affectedFiles.length} affected document(s) across ${u.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; ${m?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${f.toFixed(0)}ms, assembly ${b.toFixed(0)}ms, fragments ${S.toFixed(0)}ms, write ${v.toFixed(0)}ms).`),P}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function bi(e){let t=Ot();if(!t.available)throw new Error(t.reason);let n=An({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:L(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:ce}),packageVersion:t.packageVersion});Ct(e.candidateShardPath,n)}function fi(e,t,n){let r=e.files.filter(i=>un(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return jt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function mi(e,t){return jt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function hi(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=Zn({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let u=a.identityFor(c,"typescript-scip-document-v1");if(u.key){s.set(c,u.key);continue}if(o.has(c))return null;s.set(c,jt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function jt(e){return lc("sha256").update(e).digest("hex")}import{closeSync as yc,existsSync as Ue,fstatSync as bc,lstatSync as Sc,openSync as Rc,renameSync as Vt,rmSync as We,statSync as xc,writeSync as Pc}from"fs";import{cpus as vc}from"os";import{join as Bt}from"path";function Ic(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=Bt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=Rc(n,"wx",384)}catch(o){if(o.code==="EEXIST")return null;throw o}try{Pc(i,r);let o=bc(i);return{path:n,content:r,device:o.dev,inode:o.ino}}finally{yc(i)}}function Ec(e){if(e)try{let t=Sc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=L(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;We(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function kc(e,t,n){if(!e.defaultOutputPath)return;let r=Bt(t,e.defaultOutputPath);n!==r&&Ue(r)&&Vt(r,n)}function Tc(e,t,n){if(!e.defaultOutputPath)return null;let r=Bt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return We(i,{force:!0}),Ue(r)?(Vt(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function wc(e){e&&(We(e.defaultOutputPath,{force:!0}),e.backupPath&&Ue(e.backupPath)&&Vt(e.backupPath,e.defaultOutputPath))}function _c(e,t){if(e<=1)return 1;let n=Number(process.env.CODEBASEIQ_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,vc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Ri(e,t,n,r,i){A(i,"Reindex cancelled by its owner.");let o=e.filter(l=>l.config.defaultOutputPath),a=e.filter(l=>!l.config.defaultOutputPath),s=[],c=_c(a.length,r),u=await cr(a,c,l=>Mt(l,t,n,i));if(c>1){let l=new Map;for(let d of u.filter(p=>p.result.skipped&&p.retryable)){let p=a.find(g=>g.id===d.result.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),A(i,"Reindex cancelled by its owner."),l.set(p.id,(await Mt(p,t,n,i)).result))}s.push(...u.map(({result:d})=>l.get(d.id)??d))}else s.push(...u.map(({result:l})=>l));for(let l of o)A(i,"Reindex cancelled by its owner."),s.push((await Mt(l,t,n,i)).result);return s.sort((l,d)=>e.findIndex(p=>p.id===l.id)-e.findIndex(p=>p.id===d.id))}async function Mt(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),We(e.scipPath,{force:!0});let i=Tc(e.config,t,e.scipPath),o=Ic(e,t),a=[e.binary,...e.args].join(" "),s=R();try{e.trustedProjectTool&&Yn(t,e.trustedProjectTool);let u=Jn(e.binary,e.args),l=await sr({command:u.binary,args:u.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Dc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let d=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${d?`:
|
|
281
|
+
${d}`:""}`)}kc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw pn(r,"Reindex cancelled by its owner.");let l=u instanceof Error?u.message:String(u),d=`${e.resolvedBinary} indexer failed: ${Fc(l)}`,p=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:R()-s,command:a,skipped:{language:e.language,reason:p}},retryable:Ac(u)}}finally{wc(i),Ec(o)}if(!Ue(e.scipPath)){let u=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,l=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:R()-s,command:a,skipped:{language:e.language,reason:l}},retryable:!1}}let c;try{c=xc(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:R()-s,command:a,outputBytes:c},retryable:!1}}function Fc(e){let[t="",...n]=e.split(`
|
|
282
|
+
`),r=n.map(o=>o.trim()).filter(Boolean);if(r.length===0)return t;let i=r.find(o=>/^(?:error:\s*)?[A-Z]\w*Error\b/.test(o))??r[r.length-1];return`${t} ${i}`}function Dc(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):or.indexer}function Ac(e){return e instanceof ar?e.kind==="spawn"&&Si(e.cause):Si(e)}function Si(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Pi}from"child_process";import{homedir as xi,platform as Lc}from"os";import{delimiter as Oc,join as Ge}from"path";function vi(e,t){let n=e.installMethods,r=Te(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!qn(i.prerequisite))continue;let o=Nc(i);t(`Installing immutable ${i.identity} via ${i.label} into ${o}; expected executable: ${r}.`);try{Pi(i.binary,i.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:Lc()==="win32"});let a=pe(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${a}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Nc(e){if(e.binary==="npm")return $t("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=$t("go",["env","GOBIN"]);if(t)return t;let n=$t("go",["env","GOPATH"]);if(n)return Ge(n.split(Oc)[0],"bin")}return e.binary==="dotnet"?Ge(process.env.DOTNET_CLI_HOME??xi(),".dotnet","tools"):e.binary==="dart"?Ge(process.env.PUB_CACHE??Ge(xi(),".pub-cache"),"bin"):e.destination}function $t(e,t){try{return Pi(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}import wu from"better-sqlite3";import{existsSync as _u}from"fs";import{dirname as Fu,join as Du,resolve as Au}from"path";import{randomUUID as jc}from"crypto";import{mkdtempSync as Mc,rmSync as Vc,statSync as Ei}from"fs";import{tmpdir as Bc}from"os";import{join as ki}from"path";import{Worker as $c}from"worker_threads";function Cc(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function oe(){return{skippedReferences:0,skippedReferenceReasons:Cc(),skippedReferenceSamples:[]}}function qe(e,t){e.skippedReferences+=t.skippedReferences;for(let n of Object.keys(e.skippedReferenceReasons)){e.skippedReferenceReasons[n]+=t.skippedReferenceReasons[n];for(let r of t.skippedReferenceSamples.filter(i=>i.reason===n))e.skippedReferenceSamples.filter(o=>o.reason===n&&o.sourceFile===r.sourceFile).length<2&&e.skippedReferenceSamples.push(r)}}var Uc=3e5,Ti=64*1024*1024,Wc={createResultDirectory:()=>Mc(ki(Bc(),"codebaseiq-vue-workers-")),spawn:(e,t)=>new $c(e,{workerData:t}),resultSize:e=>Ei(e).size,readResult:e=>_(e,{maxBytes:Ti,inputKind:"Vue worker result"}),removeResultDirectory:e=>Vc(e,{recursive:!0,force:!0})};function wi(e){return e.length>=8&&Fi(e.length)>1}async function _i(e,t=Wc){let n=Fi(e.vueFiles.length),r=nu(e.vueFiles),i=iu(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??eu(),s=e.maxResultBytes??tu();Ii("timeoutMs",a),Ii("maxResultBytes",s);let c=jc(),u=t.createResultDirectory(),l=[],d,p,g;try{for(let m=0;m<i.length;m++){let I=m,h=i[m]??[],b=h.map(P=>P.taskId),S=ki(u,`${I}.json`),v=t.spawn(o,{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:h,resultPath:S,runId:c,workerId:I,taskIds:b});l.push({workerId:I,taskIds:b,resultPath:S,handle:v,completion:Gc(v,I)})}await qc(l,a);let f=l.sort((m,I)=>m.workerId-I.workerId).map(m=>Hc(m,c,s,t));g={occurrences:f.flatMap(m=>m.occurrences),...oe()};for(let m of f)qe(g,m)}catch(f){d=f}finally{let f=await Jc(l);if(f.length===0)try{t.removeResultDirectory(u)}catch(m){f.push(m)}if(f.length>0){let m=d===void 0?f:[d,...f];p=new AggregateError(m,`Vue worker cleanup failed: ${Zc(m[0])}`)}}if(p)throw p;if(d!==void 0)throw d;if(!g)throw new Error("Vue workers completed without producing a merged result.");return g}function Gc(e,t){return new Promise((n,r)=>{let i=!1,o=c=>{i||(i=!0,e.off("error",a),e.off("exit",s),c?r(c):n())},a=c=>{o(new Error(`Vue reference worker ${t} failed: ${c.message}`,{cause:c}))},s=c=>{o(c===0?void 0:new Error(`Vue reference worker ${t} exited with code ${c}`))};e.once("error",a),e.once("exit",s)})}async function qc(e,t){let n;try{await Promise.race([Promise.all(e.map(r=>r.completion)),new Promise((r,i)=>{n=setTimeout(()=>i(new Error(`Vue reference workers timed out after ${(t/1e3).toFixed(3)}s`)),t),n.unref()})])}finally{n&&clearTimeout(n)}}async function Jc(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function Hc(e,t,n,r){let i=r.resultSize(e.resultPath);if(!Number.isSafeInteger(i)||i<0||i>n)throw new Error(`Vue reference worker ${e.workerId} result is ${i} bytes; limit is ${n} bytes`);let o;try{o=JSON.parse(r.readResult(e.resultPath))}catch(a){throw new Error(`Vue reference worker ${e.workerId} produced invalid JSON`,{cause:a})}if(!ge(o)||o.version!==1||o.runId!==t||o.workerId!==e.workerId)throw new Error(`Vue reference worker ${e.workerId} result identity does not match its assignment`);if(!Qc(o.taskIds,e.taskIds))throw new Error(`Vue reference worker ${e.workerId} result task identities do not match its assignment`);if(o.ok===!1)throw typeof o.error!="string"?new Error(`Vue reference worker ${e.workerId} failure payload is malformed`):new Error(`Vue reference worker ${e.workerId} failed: ${o.error}`);if(o.ok!==!0||!zc(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function zc(e){if(!ge(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(Xc)||!N(e.skippedReferences)||!ge(e.skippedReferenceReasons))return!1;for(let t of["missing-source-file","missing-service-script","no-definition","same-file-definition","unindexed-definition"])if(!N(e.skippedReferenceReasons[t]))return!1;return Array.isArray(e.skippedReferenceSamples)&&e.skippedReferenceSamples.every(Yc)}function Xc(e){return ge(e)&&typeof e.sourceFile=="string"&&N(e.sourceLine)&&N(e.sourceStartChar)&&N(e.sourceEndChar)&&typeof e.sourceToken=="string"&&typeof e.definitionFile=="string"&&N(e.symbolId)}function Yc(e){return ge(e)&&typeof e.sourceFile=="string"&&N(e.sourceLine)&&N(e.sourceStartChar)&&N(e.sourceEndChar)&&typeof e.token=="string"&&Kc(e.reason)}function Kc(e){return e==="missing-source-file"||e==="missing-service-script"||e==="no-definition"||e==="same-file-definition"||e==="unindexed-definition"}function N(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function ge(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qc(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function Ii(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function Zc(e){return e instanceof Error?e.message:String(e)}function Fi(e){let t=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function eu(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:Uc}function tu(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:Ti}function nu(e){let t=ru(),n=[];for(let r of e){let i=Di(r),o=Math.max(1,Math.ceil(i/t));for(let a=0;a<o;a++)n.push({taskId:`${n.length}:${r}:${a}`,fileName:r,startOffset:Math.floor(i*a/o),endOffset:a===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(a+1)/o),countFileSkip:a===0})}return n}function ru(){return Number.POSITIVE_INFINITY}function iu(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:ou(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((a,s)=>s.weight<a.weight?s:a);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function ou(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Di(e.fileName)-e.startOffset)}function Di(e){try{return Ei(e).size}catch{return 1}}import{createRequire as au}from"module";import{existsSync as su}from"fs";import{dirname as Ai,extname as cu,join as Li,relative as uu,resolve as lu}from"path";import{pathToFileURL as du}from"url";function pu(e){e.transaction(()=>{e.prepare(`
|
|
283
283
|
DELETE FROM mentions
|
|
284
284
|
WHERE chunk_id IN (
|
|
285
285
|
SELECT c.id
|
|
@@ -294,12 +294,12 @@ ${d}`:""}`)}Sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw cn(r,"Reindex
|
|
|
294
294
|
FROM documents
|
|
295
295
|
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
296
296
|
)
|
|
297
|
-
`).run()})()}function
|
|
297
|
+
`).run()})()}function Oi(e,t){return e.prepare(`
|
|
298
298
|
SELECT relative_path AS relativePath
|
|
299
299
|
FROM documents
|
|
300
300
|
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
301
301
|
ORDER BY relative_path
|
|
302
|
-
`).all().map(r=>
|
|
302
|
+
`).all().map(r=>lu(t,r.relativePath))}function Ni(e,t){let{vueCore:n,ts:r,volarTs:i}=gu(e),{parsed:o,vueOptions:a}=fu(n,r,t),s=Ai(t),c=n.createVueLanguagePlugin(r,o.options,a,g=>g),u=mu(n,r,c),l=hu(s,o),{languageServiceHost:d}=i.createLanguageServiceHost(r,r.sys,u,g=>g,l),p=r.createLanguageService(d);return{ts:r,language:u,languageService:p,fileNames:o.fileNames,configDir:s}}function gu(e){let t=au(du(Li(e,"package.json")).href);return{vueCore:Ut(t,"@vue/language-core",e),ts:Ut(t,"typescript",e),volarTs:Ut(t,"@volar/typescript",e)}}function fu(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,Ai(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function mu(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!su(o))return;let a=_(o,{maxBytes:Ke,inputKind:"Vue language-service source file"});r.current?.scripts.set(o,t.ScriptSnapshot.fromString(a),n.getLanguageId(o)??Pu(o))});return r.current=i,i}function hu(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function Ut(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function Ci(e,t,n){let r=yu(e);return i=>{if(!i.name)return null;let o=C(t,i.fileName),a=n.get(i.fileName);if(!a)return null;let s=n.positionAt(a,i.textSpan.start),c=r.get(o);if(!c)return null;let u=c.starts.find(d=>d.line===s.line&&d.displayName===i.name);if(u)return u.symbolId;let l=c.containingByLine.get(s.line);return l&&l.displayName===i.name?l.symbolId:bu(c.starts,s.line,2,i.name)}}function yu(e){let t=e.prepare(`
|
|
303
303
|
SELECT
|
|
304
304
|
d.relative_path AS relativePath,
|
|
305
305
|
der.start_line AS startLine,
|
|
@@ -310,22 +310,22 @@ ${d}`:""}`)}Sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw cn(r,"Reindex
|
|
|
310
310
|
JOIN documents d ON d.id = der.document_id
|
|
311
311
|
JOIN global_symbols gs ON gs.id = der.symbol_id
|
|
312
312
|
ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
|
|
313
|
-
`).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId,displayName:r.displayName});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,{symbolId:r.symbolId,displayName:r.displayName})}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function
|
|
313
|
+
`).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId,displayName:r.displayName});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,{symbolId:r.symbolId,displayName:r.displayName})}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function bu(e,t,n,r){let i=0,o=e.length-1;for(;i<=o;){let s=Math.floor((i+o)/2);e[s].line<t?i=s+1:o=s-1}let a=null;for(let s of[o,i]){let c=e[s];if(!c||c.displayName!==r)continue;let u=Math.abs(c.line-t);u>n||(!a||u<a.distance)&&(a={distance:u,symbolId:c.symbolId})}return a?.symbolId??null}function ji(e,t,n){let r=Eu(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
|
|
314
314
|
INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
|
|
315
315
|
VALUES (?, ?, ?, ?)
|
|
316
|
-
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let l=C(t,u),d=
|
|
316
|
+
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let l=C(t,u),d=Ji(r.name,r.version,l);o.run(d,"default",7,`Vue component|${l}`);let p=ku(i,r,t,u);p&&(a++,s.set(u,p))}})(),{get(u){return s.get(u)??null},syntheticSymbols:a}}function Mi(e,t,n,r,i){return e.transaction(()=>(pu(e),Su(e,t,n,r),Ru(e,i)))()}function Su(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
|
|
317
317
|
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
318
318
|
VALUES (?, ?, ?, ?, X'00')
|
|
319
319
|
`),a=e.prepare(`
|
|
320
320
|
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
321
321
|
VALUES (?, ?, 1)
|
|
322
|
-
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=C(t,s),l=i.get(u);if(!l)continue;let d=o.run(l.id,-1,0,0);a.run(Number(d.lastInsertRowid),c)}}function
|
|
322
|
+
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=C(t,s),l=i.get(u);if(!l)continue;let d=o.run(l.id,-1,0,0);a.run(Number(d.lastInsertRowid),c)}}function Vi(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),a=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&a){let s=r.language.maps.get(a,o);if(Wt(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function Bi(e){let t=new Set,n=[];for(let r of e){let i=$i(r);t.has(i)||(t.add(i),n.push(r))}return n}function $i(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function Ru(e,t){let n=Iu(e,[...new Set(t.map(c=>c.sourceFile))]),r=e.prepare(`
|
|
323
323
|
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
324
324
|
VALUES (?, ?, ?, ?, X'00')
|
|
325
325
|
`),i=e.prepare(`
|
|
326
326
|
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
327
327
|
VALUES (?, ?, 0)
|
|
328
|
-
`),o=new Set,a=0,s=0;for(let c of t){let u
|
|
328
|
+
`),o=new Set,a=0,s=0;for(let c of t){let u=$i(c);if(o.has(u))continue;o.add(u);let l=n.get(c.sourceFile);if(!l)continue;let d=r.run(l,s++,c.sourceLine,c.sourceLine),p=i.run(Number(d.lastInsertRowid),c.symbolId);a+=Number(p.changes)}return a}function*Ui(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Wi(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Wt(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function xu(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function Gi(e,t){return C(e,t).startsWith("node_modules/")}function C(e,t){return uu(e,t).replaceAll("\\","/")}function Pu(e){switch(cu(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function qi(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=_(t,{maxBytes:Ke,inputKind:"Vue source file"}),r={text:n,lineStarts:vu(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:xu}}function vu(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function Iu(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.set(s.relativePath,s.id)}return n}function Eu(e){try{let t=JSON.parse(_(Li(e,"package.json"),{maxBytes:Q,inputKind:"project package manifest"}));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function ku(e,t,n,r){let i=C(n,r),o=Ji(t.name,t.version,i);return e.get(o)?.id??null}function Ji(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function Lu(e){return z(H(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),Ou(e)}async function Ou(e){let t=Au(e.projectRoot,e.tsconfig);if(!_u(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new wu(F(e.dbPath));try{let r=Oi(n,e.projectRoot),i=Du(Fu(e.dbPath),"augment-vue-meta.json");return await Ur({cachePath:i,readFingerprint:()=>Mu(n,e.projectRoot,e.tsconfig),compute:()=>Nu({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}async function Nu(e){let t=ji(e.db,e.projectRoot,e.vueFiles),n=wi(e.vueFiles)?await _i({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):ju(e,t);return Cu(e,t,n)}function Cu(e,t,n){let r=Bi(n.occurrences),i=Mi(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:Hu(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:Ju(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function ju(e,t){let n=Vu({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return Bu({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function Mu(e,t,n){let r=e.prepare(`
|
|
329
329
|
SELECT
|
|
330
330
|
(SELECT COUNT(*) FROM documents) AS documents,
|
|
331
331
|
(SELECT COUNT(*) FROM global_symbols) AS symbols,
|
|
@@ -334,10 +334,10 @@ ${d}`:""}`)}Sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw cn(r,"Reindex
|
|
|
334
334
|
(SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
|
|
335
335
|
(SELECT MAX(id) FROM chunks) AS maxChunkId,
|
|
336
336
|
(SELECT MAX(id) FROM global_symbols) AS maxSymbolId
|
|
337
|
-
`).get();return{version:3,tsconfig:n,files:Pe(t),db:r}}function
|
|
338
|
-
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function Cu(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function Wi(e,t,n){let r=oe();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:C(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function Wt(e,t,n,r,i,o){if(e.skippedReferences++,e.skippedReferenceReasons[o]++,e.skippedReferenceSamples.filter(s=>s.reason===o&&s.sourceFile===r).length>=2)return;let a=t.positionAt(n,i.start);e.skippedReferenceSamples.push({sourceFile:r,sourceLine:a.line,sourceStartChar:a.character,sourceEndChar:a.character+i.text.length,token:i.text,reason:o})}function Gt(e,t){let n=new Map;for(let o of e){let a=n.get(o.sourceFile)??[];a.push(o),n.set(o.sourceFile,a)}let r=[...n.keys()].sort(),i=[];for(let o=0;i.length<t;o++){let a=!1;for(let s of r){let c=n.get(s)?.[o];if(c&&(i.push(c),a=!0,i.length===t))break}if(!a)break}return i}function ju(e,t){let n=Gt(e.filter(o=>o.sourceFile!==o.definitionFile),Math.ceil(t/2)),r=new Set(n.map(o=>`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),i=Gt(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function Mu(e,t){let n=[...new Set(e.map(i=>i.reason))].sort(),r=[];for(let[i,o]of n.entries()){let a=n.length-i,s=Math.ceil((t-r.length)/a);r.push(...Gt(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Vu(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return ju(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function $u(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of Uu(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(a))continue;let s=t.tokenContext.tokenByStart.get(a);s&&(Gi(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function Gi(e,t,n,r,i,o,a){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,sourceToken:i.text,definitionFile:o,symbolId:a})}function Bu(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Uu(e,t,n,r,i,o){let a=e.getDocumentHighlights?.(t,n,[t])??[],s=[];for(let c of a)if(c.fileName===t)for(let u of c.highlightSpans){let l=Wu(r,u.textSpan.start,o,i.text);l!==null&&s.push(l)}return s}function Wu(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Ut(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function to(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=Xu(e),a=Date.now(),s=R();He(y(o.outputScip),{recursive:!0}),He(y(o.outputDb),{recursive:!0});let c=e.languages??ct(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let u=xe("reindex.fingerprint",()=>hn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,d;if(e.skipIfUnchanged!==!1&&!Dn(t,o.outputDb)&&qi(o.outputScip)===qi(k(y(o.outputDb),"index.scip"))){let h=ye(t);if(l=h?.clean?ve(h,u):void 0,h&&!h.clean&&!zu(o)){let b=On(h,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(b)try{Ie({snapshot:b.snapshot,manifest:b.manifest,targetCacheDir:y(o.outputDb),targetProjectRoot:t,persistLease:!1}),Mn(b.snapshot,y(o.outputDb)),r(`Forked shared baseline ${b.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(S){r(`Shared baseline fork failed; continuing locally: ${$(S)}`)}}else if(l){let b=gt(l);if(b){if(!Hu(o,u))try{Ie({snapshot:l,manifest:b,targetCacheDir:y(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(S){r(`Shared generation attach failed; continuing locally: ${$(S)}`)}}else{let S=await Cn(l);if(S.kind==="owner")d=S.release;else if(S.kind==="generation-ready"){let v=gt(l);if(v)try{Ie({snapshot:l,manifest:v,targetCacheDir:y(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(P){r(`Shared generation attach failed after waiting; continuing locally: ${$(P)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=ln(k(y(o.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!g)throw d?.(),new Error(`Could not acquire codebaseiq cache lifecycle lock for ${y(o.outputDb)}.`);let f;try{f=await de("reindex.lock",()=>xl(k(y(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(h){throw g.release(),d?.(),h}let m=null,I=ar();try{bn(o.outputDb,o.outputScip,o.metaPath);let h=Zu(y(o.outputDb));h.removed>0&&r(`Removed ${h.removed} abandoned reindex workspace(s)`);for(let Y of h.errors)r(`Could not remove abandoned reindex workspace: ${Y}`);let b=null,S=xe("reindex.reuse-check",()=>(b=Yu({opts:e,paths:o,languages:c,fingerprint:u,start:a,monotonicStart:s,onStatus:r}),b),()=>({languages:c.length,reused:b!==null}));if(S){Ji({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let Y=kt(o.outputDb,S);return Y.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${Y.reason}`),rt(t,y(o.outputDb)),S}let v=Qu(o);m=v.runDir;let P,x=await de("reindex.fresh",async()=>(P=await el({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:v,fingerprint:u,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:I}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));Ji({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let X=kt(o.outputDb,x);return X.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${X.reason}`),rt(t,y(o.outputDb)),x}catch(h){let b=Ye({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:h instanceof Error?h.message:String(h)});fo(o.metaPath,b);let S=Gr(o.outputDb,b);throw S.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${S.reason}`),h}finally{if(m){let h=m;try{te(()=>ae(h,{recursive:!0,force:!0}))}catch(b){r(`Warning: temporary reindex workspace was left behind: ${$(b)}`)}}f(),g.release(),d?.()}}function Ji(e){if(e.snapshot)try{let t=ye(e.projectRoot),n=t?ve(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=Nn({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=ye(e.projectRoot);return(i?ve(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});jn(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${$(t)}`)}}function Hu(e,t){if(!T(e.outputScip)||!T(e.outputDb)||!go(e.metaPath,t))return!1;let n=U(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function zu(e){if(!T(e.outputScip)||!T(e.outputDb)||!se(e.metaPath))return!1;let t=U(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function $(e){return e instanceof Error?e.message:String(e)}function Ht(e,t,n,r,i,o){try{z(cr({indexPath:n,reuseExisting:i,affectedFiles:o}),{projectRoot:e,dbPath:t,onStatus:r})}catch(a){r(`Runtime-boundary extraction unavailable: ${a instanceof Error?a.message:String(a)}.`)}}function Xu(e){let t=e.outputScip??k(e.projectRoot,"index.scip"),n=e.outputDb??k(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:k(y(n),"meta.json")}}function Yu(e){let t=U(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!T(e.paths.outputScip)||!T(e.paths.outputDb)||!go(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;z(H(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Ht(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),U(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(ut(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=R()-e.monotonicStart,r=Ye({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return fo(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:Ku(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Ku(e,t,n,r){let i=lo(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:fe(i[o]),outputBytes:me(Xt(e.outputDb,o)),durationMs:0}))}function Qu(e){let t=rn(k(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:k(t,Je(e.outputScip)),tempOutputDb:k(t,Je(e.outputDb)),tempMetaPath:k(t,Je(e.metaPath))}}function Zu(e){let t=[],n;try{n=Zi(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[$(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{ae(k(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${$(o)}`)}return{removed:r,errors:t}}async function el(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await de("reindex.language-indexers",async()=>(n=await nl(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:o,reusedLanguages:a,languageFingerprints:s,shards:c,typescriptProjectShardContext:u,incrementalTypeScript:l}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),tl({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let g=xe("reindex.publish",()=>dl(e,i,o,a,s,u),{mode:"metadata-only",languages:i.length,reused:a.length}),f=g.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(f/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:f,reused:!0,skipped:o,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}let d=await de("reindex.publish",()=>ll(e,t,i,o,a,s,u,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:a.length,skipped:o.length}),p=d.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(g=>g.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:o,lastRefresh:d,shards:c,writeTelemetry:e.writeTelemetry}}function tl(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!T(e.run.paths.outputScip)||!T(e.run.paths.outputDb))return!1;let t=U(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function nl(e,t){let n=sl({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[w,Kt]of n)Kt.reused&&(r.push({language:w,scipPath:Kt.scipPath}),i.add(w));for(let w of i)e.onStatus(`Reusing cached ${w} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=U(e.paths.outputDb,e.paths.metaPath),s=se(e.paths.metaPath),c=(a.state==="legacy"||a.state==="current")&&s!==null&&at(s),u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),l=o&&!o.reused&&c?gi({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:he(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:he(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:zt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,d=new Set(l?["typescript"]:[]),p=l?void 0:rl(e,n),{preparedRuns:g,skippedLanguages:f,languageOutputScipPaths:m}=fl({languages:e.languages.filter(w=>!i.has(w)&&!d.has(w)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),I=p?g.filter(w=>w.language!=="typescript"||p.missedProjectIds.has(w.id)):g,h=await hi(I,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),b=[];if(p){ol(e.paths.outputDb,h,e.writeTelemetry);let w=m.typescript??e.tempPaths.tempOutputScip;b=al({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:w,reusedProjects:p.reusedProjects,writeTelemetry:e.writeTelemetry})}let S=[...h,...b],{indexedOutputs:v}=hl(S,f),P=l?[{language:"typescript",scipPath:l.scipPath}]:[],x=[...r,...P,...v];yl(x,f,e.languages,e.opts.allowPartial,e.onStatus);let X=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:me(l.scipPath)??void 0}]:[],Y=cl(n,[...h,...X],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:x,skippedLanguages:f,reusedLanguages:[...i],languageFingerprints:ul(n,e.languages),shards:Y,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function rl(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=ne(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Xr(e.projectRoot,r),o=Jr(n.fingerprint.files,r),a=Hr(r,i),s=zr(r,o,a),c=se(e.paths.metaPath),l=il(c,s,f=>T(Xe(e.paths.outputDb,f))),d=[...l.entries()].filter(([,f])=>f.reused).map(([f])=>f),p=new Set(d),g=new Set(r.filter(f=>!p.has(f)).map(f=>`typescript:${f}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:d,missedProjectIds:g}}function il(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let a=e.version===le&&ot(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if(j(a)!==j(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function ol(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=Xe(e,i);He(y(o),{recursive:!0}),J(n,q(r.scipPath,o))}}function al(e){return e.reusedProjects.map((t,n)=>{let r=Xe(e.outputDb,t),i=he(e.tempOutputScip,"typescript-project-cached",n);return J(e.writeTelemetry,q(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:me(i)??void 0}})}function sl(e){let t=se(e.paths.metaPath),n=lo(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Xt(e.paths.outputDb,i),a=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a,scipPath:o});continue}if(t.version!==le){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:a,scipPath:o});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:a,scipPath:o});continue}if(!ot(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:a,scipPath:o});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:a,scipPath:o});continue}if(!T(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:o});continue}if(j(s)!==j(a)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:a,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:a,scipPath:o})}return r}function cl(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:fe(o.fingerprint),outputBytes:me(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),a=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=a?n.classification.get(a):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??o?.reason??i.skipped?.reason,fingerprint:s?fe(s.fingerprint):o?fe(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:fe(o.fingerprint),outputBytes:me(Xe(n.outputDb,i)),durationMs:0});return r}function fe(e){return Gu("sha256").update(j(e)).digest("hex").slice(0,16)}function me(e){try{return qu(e).size}catch{return null}}function ul(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function ll(e,t,n,r,i,o,a,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,u=!1;c&&(Hi(e.paths.outputDb,n,e.writeTelemetry),u=zi(n,e.tempPaths.tempOutputScip,e.onStatus));let l=await bl({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:u,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return u;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),fi({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let v=n.map(P=>P.language==="typescript"?{language:P.language,scipPath:s.candidateScipPath}:P);return Hi(e.paths.outputDb,v,e.writeTelemetry),u=zi(v,e.tempPaths.tempOutputScip,e.onStatus),u}});A(e.opts.signal,"Reindex cancelled by its owner."),z(H(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Ht(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles);let d=It(e.tempPaths.tempOutputDb);if(d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),l.mode==="incremental"&&s){let v=null,P=null;try{v=new O({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),P=new O({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=Yn(v,e.fingerprint,s.referenceFragmentsByFile,P);e.onStatus(`Cached exact TypeScript reference fragments for ${x} affected document(s).`)}catch(x){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${x instanceof Error?x.message:String(x)}.`)}finally{v?.close(),P?.close()}}let p=zt(e.paths.metaPath),g=l.mode==="incremental"&&s?Rl(s,l.changedDocumentPaths):Rt({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),f=Ye({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(v=>v.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",I={...o};m&&delete I.typescript;let{metadata:h,pruneProjects:b}=ro({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:I,typescriptProjectShardContext:a,lastRefresh:f});h.scipCompanion=m?"deferred":"current",io(e.paths.outputDb,b),Yt(e.tempPaths.tempMetaPath,h);let S=yn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}});return S.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${S.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),_n(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),En(y(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),no(e.paths.outputDb,g,e.onStatus),f}function dl(e,t,n,r,i,o){let a=zt(e.paths.metaPath),s=null;try{J(e.writeTelemetry,q(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=br("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}z(H(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Ht(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=It(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),s??=Rt({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,refreshResult:"reused"});let u=Ye({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:d}=ro({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:u});return io(e.paths.outputDb,d),Yt(e.paths.metaPath,l),ut(e.paths.outputDb,e.paths.metaPath),no(e.paths.outputDb,s,e.onStatus),u}function zt(e){return an(se(e)?.fingerprint)}function no(e,t,n){try{Rr(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function ro(e){let t=pl({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:le,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:2,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function pl(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=se(e.metaPath),n=t?.version===le?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function io(e,t){let n=po(e);if(t===null){te(()=>ae(n,{recursive:!0,force:!0}));return}let r;try{r=Zi(n)}catch{return}for(let i of gl(r,t))te(()=>ae(k(n,i),{force:!0}))}function gl(e,t){let n=new Set(t.map(r=>`${Lt(r)}.scip`));return e.filter(r=>!n.has(r))}function Hi(e,t,n){for(let r of t){let i=Xt(e,r.language);He(y(i),{recursive:!0}),r.scipPath!==i&&J(n,q(r.scipPath,i))}}function fl(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?he(e.tempOutputScip,o,a):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:o,scipPath:a})=>[o,a]));for(let{language:o,scipPath:a}of r){let s=ml({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?oo(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function ml(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[qt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??ne(e.projectRoot,e.typescriptProjects);return t.length===0?[qt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>qt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:he(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function qt(e){let t=xt(e.language),n=Te(t),r=Gn(t,e.projectRoot),i=e.trustProjectTools&&r?qn(t,e.projectRoot):null,o=pe(t);if(!i&&!o&&r){let l=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(!i&&!o&&!Wn(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: codebaseiq reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Si(t,e.onStatus)){let l=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}}let a=i?.canonicalPath??pe(t);if(!a){let l=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:a,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),u=Tr({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let l=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:a,binary:s,args:c,env:Hn(t,e.env,a),...u===void 0?{}:{temporaryRootConfigContent:u},...i?{trustedProjectTool:i}:{}}}}function hl(e,t){let n=new Map;for(let i of e)if(i.skipped)oo(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,a=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};a.scipPaths.push(i.scipPath),n.set(o,a)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Ln(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&eo(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function oo(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function yl(e,t,n,r,i){if(e.length===0){let o=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
337
|
+
`).get();return{version:3,tsconfig:n,files:Pe(t),db:r}}function Vu(e){let t=qi();return{projectRoot:e.projectRoot,context:Ni(e.projectRoot,e.configPath),symbolLookup:Ci(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function Bu(e){let t=[],n=oe(),r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=$u(e,i);t.push(...o.occurrences),qe(n,o)}return{occurrences:t,...n}}function $u(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return Hi(e.projectRoot,t,"missing-source-file");let r=e.context.language.scripts.get(t.fileName),i=r?.generated?.languagePlugin.typescript?.getServiceScript(r.generated.root)?.code;if(!r||!i)return Hi(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=C(e.projectRoot,t.fileName),s=[...Ui(n.text)],c={tokens:s.filter(u=>u.start>=t.startOffset&&u.start<t.endOffset),tokenByStart:new Map(s.map(u=>[u.start,u])),tokenTextCounts:Xu(s),processedStarts:new Set};return Uu({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function Uu(e){let t=[],n=oe();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||Wu(e.sourceInfo.text,r.start))continue;let i=Wi(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(l=>!Gi(e.projectRoot,l.fileName));if(!a){Gt(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=C(e.projectRoot,a.fileName),c=Gu(e.sourceFile,r.text,s);if(c){Gt(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,c);continue}let u=Vi(a,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(u===null){Gt(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}zi(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,u),e.tokenContext.processedStarts.add(r.start),zu(t,e,r,i,s,u)}return{occurrences:t,...n}}function Wu(e,t){let n=e.lastIndexOf(`
|
|
338
|
+
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function Gu(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function Hi(e,t,n){let r=oe();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:C(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function Gt(e,t,n,r,i,o){if(e.skippedReferences++,e.skippedReferenceReasons[o]++,e.skippedReferenceSamples.filter(s=>s.reason===o&&s.sourceFile===r).length>=2)return;let a=t.positionAt(n,i.start);e.skippedReferenceSamples.push({sourceFile:r,sourceLine:a.line,sourceStartChar:a.character,sourceEndChar:a.character+i.text.length,token:i.text,reason:o})}function qt(e,t){let n=new Map;for(let o of e){let a=n.get(o.sourceFile)??[];a.push(o),n.set(o.sourceFile,a)}let r=[...n.keys()].sort(),i=[];for(let o=0;i.length<t;o++){let a=!1;for(let s of r){let c=n.get(s)?.[o];if(c&&(i.push(c),a=!0,i.length===t))break}if(!a)break}return i}function qu(e,t){let n=qt(e.filter(o=>o.sourceFile!==o.definitionFile),Math.ceil(t/2)),r=new Set(n.map(o=>`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),i=qt(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function Ju(e,t){let n=[...new Set(e.map(i=>i.reason))].sort(),r=[];for(let[i,o]of n.entries()){let a=n.length-i,s=Math.ceil((t-r.length)/a);r.push(...qt(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Hu(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return qu(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function zu(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of Yu(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(a))continue;let s=t.tokenContext.tokenByStart.get(a);s&&(zi(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function zi(e,t,n,r,i,o,a){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,sourceToken:i.text,definitionFile:o,symbolId:a})}function Xu(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Yu(e,t,n,r,i,o){let a=e.getDocumentHighlights?.(t,n,[t])??[],s=[];for(let c of a)if(c.fileName===t)for(let u of c.highlightSpans){let l=Ku(r,u.textSpan.start,o,i.text);l!==null&&s.push(l)}return s}function Ku(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Wt(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function oo(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=rl(e),a=Date.now(),s=R();He(y(o.outputScip),{recursive:!0}),He(y(o.outputDb),{recursive:!0});let c=e.languages??ut(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let u=xe("reindex.fingerprint",()=>Rn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,d;if(e.skipIfUnchanged!==!1&&!jn(t,o.outputDb)&&Xi(o.outputScip)===Xi(k(y(o.outputDb),"index.scip"))){let h=ye(t);if(l=h?.clean?ve(h,u):void 0,h&&!h.clean&&!nl(o)){let b=Mn(h,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(b)try{Ie({snapshot:b.snapshot,manifest:b.manifest,targetCacheDir:y(o.outputDb),targetProjectRoot:t,persistLease:!1}),Un(b.snapshot,y(o.outputDb)),r(`Forked shared baseline ${b.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(S){r(`Shared baseline fork failed; continuing locally: ${B(S)}`)}}else if(l){let b=ft(l);if(b){if(!tl(o,u))try{Ie({snapshot:l,manifest:b,targetCacheDir:y(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(S){r(`Shared generation attach failed; continuing locally: ${B(S)}`)}}else{let S=await Bn(l);if(S.kind==="owner")d=S.release;else if(S.kind==="generation-ready"){let v=ft(l);if(v)try{Ie({snapshot:l,manifest:v,targetCacheDir:y(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(P){r(`Shared generation attach failed after waiting; continuing locally: ${B(P)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=fn(k(y(o.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!g)throw d?.(),new Error(`Could not acquire codebaseiq cache lifecycle lock for ${y(o.outputDb)}.`);let f;try{f=await de("reindex.lock",()=>_l(k(y(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(h){throw g.release(),d?.(),h}let m=null,I=lr();try{Pn(o.outputDb,o.outputScip,o.metaPath);let h=sl(y(o.outputDb));h.removed>0&&r(`Removed ${h.removed} abandoned reindex workspace(s)`);for(let Y of h.errors)r(`Could not remove abandoned reindex workspace: ${Y}`);let b=null,S=xe("reindex.reuse-check",()=>(b=il({opts:e,paths:o,languages:c,fingerprint:u,start:a,monotonicStart:s,onStatus:r}),b),()=>({languages:c.length,reused:b!==null}));if(S){Yi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let Y=Tt(o.outputDb,S);return Y.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${Y.reason}`),rt(t,y(o.outputDb)),S}let v=al(o);m=v.runDir;let P,x=await de("reindex.fresh",async()=>(P=await cl({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:v,fingerprint:u,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:I}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));Yi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let X=Tt(o.outputDb,x);return X.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${X.reason}`),rt(t,y(o.outputDb)),x}catch(h){let b=Ye({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:h instanceof Error?h.message:String(h)});bo(o.metaPath,b);let S=zr(o.outputDb,b);throw S.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${S.reason}`),h}finally{if(m){let h=m;try{te(()=>ae(h,{recursive:!0,force:!0}))}catch(b){r(`Warning: temporary reindex workspace was left behind: ${B(b)}`)}}f(),g.release(),d?.()}}function Yi(e){if(e.snapshot)try{let t=ye(e.projectRoot),n=t?ve(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=Vn({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=ye(e.projectRoot);return(i?ve(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});$n(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${B(t)}`)}}function tl(e,t){if(!T(e.outputScip)||!T(e.outputDb)||!yo(e.metaPath,t))return!1;let n=U(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function nl(e){if(!T(e.outputScip)||!T(e.outputDb)||!se(e.metaPath))return!1;let t=U(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function B(e){return e instanceof Error?e.message:String(e)}function zt(e,t,n,r,i,o){try{z(pr({indexPath:n,reuseExisting:i,affectedFiles:o}),{projectRoot:e,dbPath:t,onStatus:r})}catch(a){r(`Runtime-boundary extraction unavailable: ${a instanceof Error?a.message:String(a)}.`)}}function rl(e){let t=e.outputScip??k(e.projectRoot,"index.scip"),n=e.outputDb??k(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:k(y(n),"meta.json")}}function il(e){let t=U(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!T(e.paths.outputScip)||!T(e.paths.outputDb)||!yo(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;z(H(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),zt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),U(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(lt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=R()-e.monotonicStart,r=Ye({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return bo(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:ol(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function ol(e,t,n,r){let i=mo(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:fe(i[o]),outputBytes:me(Yt(e.outputDb,o)),durationMs:0}))}function al(e){let t=cn(k(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:k(t,Je(e.outputScip)),tempOutputDb:k(t,Je(e.outputDb)),tempMetaPath:k(t,Je(e.metaPath))}}function sl(e){let t=[],n;try{n=ro(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[B(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{ae(k(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${B(o)}`)}return{removed:r,errors:t}}async function cl(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await de("reindex.language-indexers",async()=>(n=await ll(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:o,reusedLanguages:a,languageFingerprints:s,shards:c,typescriptProjectShardContext:u,incrementalTypeScript:l}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),ul({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let g=xe("reindex.publish",()=>Sl(e,i,o,a,s,u),{mode:"metadata-only",languages:i.length,reused:a.length}),f=g.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(f/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:f,reused:!0,skipped:o,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}let d=await de("reindex.publish",()=>bl(e,t,i,o,a,s,u,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:a.length,skipped:o.length}),p=d.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(g=>g.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:o,lastRefresh:d,shards:c,writeTelemetry:e.writeTelemetry}}function ul(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!T(e.run.paths.outputScip)||!T(e.run.paths.outputDb))return!1;let t=U(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function ll(e,t){let n=ml({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[w,Qt]of n)Qt.reused&&(r.push({language:w,scipPath:Qt.scipPath}),i.add(w));for(let w of i)e.onStatus(`Reusing cached ${w} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=U(e.paths.outputDb,e.paths.metaPath),s=se(e.paths.metaPath),c=(a.state==="legacy"||a.state==="current")&&s!==null&&at(s),u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),l=o&&!o.reused&&c?yi({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:he(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:he(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:Xt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,d=new Set(l?["typescript"]:[]),p=l?void 0:dl(e,n),{preparedRuns:g,skippedLanguages:f,languageOutputScipPaths:m}=Pl({languages:e.languages.filter(w=>!i.has(w)&&!d.has(w)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),I=p?g.filter(w=>w.language!=="typescript"||p.missedProjectIds.has(w.id)):g,h=await Ri(I,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),b=[];if(p){gl(e.paths.outputDb,h,e.writeTelemetry);let w=m.typescript??e.tempPaths.tempOutputScip;b=fl({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:w,reusedProjects:p.reusedProjects,writeTelemetry:e.writeTelemetry})}let S=[...h,...b],{indexedOutputs:v}=Il(S,f),P=l?[{language:"typescript",scipPath:l.scipPath}]:[],x=[...r,...P,...v];El(x,f,e.languages,e.opts.allowPartial,e.onStatus);let X=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:me(l.scipPath)??void 0}]:[],Y=hl(n,[...h,...X],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:x,skippedLanguages:f,reusedLanguages:[...i],languageFingerprints:yl(n,e.languages),shards:Y,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function dl(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=ne(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Zr(e.projectRoot,r),o=Yr(n.fingerprint.files,r),a=Kr(r,i),s=Qr(r,o,a),c=se(e.paths.metaPath),l=pl(c,s,f=>T(Xe(e.paths.outputDb,f))),d=[...l.entries()].filter(([,f])=>f.reused).map(([f])=>f),p=new Set(d),g=new Set(r.filter(f=>!p.has(f)).map(f=>`typescript:${f}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:d,missedProjectIds:g}}function pl(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let a=e.version===le&&ot(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if(j(a)!==j(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function gl(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=Xe(e,i);He(y(o),{recursive:!0}),J(n,q(r.scipPath,o))}}function fl(e){return e.reusedProjects.map((t,n)=>{let r=Xe(e.outputDb,t),i=he(e.tempOutputScip,"typescript-project-cached",n);return J(e.writeTelemetry,q(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:me(i)??void 0}})}function ml(e){let t=se(e.paths.metaPath),n=mo(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Yt(e.paths.outputDb,i),a=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a,scipPath:o});continue}if(t.version!==le){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:a,scipPath:o});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:a,scipPath:o});continue}if(!ot(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:a,scipPath:o});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:a,scipPath:o});continue}if(!T(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:o});continue}if(j(s)!==j(a)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:a,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:a,scipPath:o})}return r}function hl(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:fe(o.fingerprint),outputBytes:me(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),a=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=a?n.classification.get(a):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??o?.reason??i.skipped?.reason,fingerprint:s?fe(s.fingerprint):o?fe(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:fe(o.fingerprint),outputBytes:me(Xe(n.outputDb,i)),durationMs:0});return r}function fe(e){return Qu("sha256").update(j(e)).digest("hex").slice(0,16)}function me(e){try{return Zu(e).size}catch{return null}}function yl(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function bl(e,t,n,r,i,o,a,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,u=!1;c&&(Ki(e.paths.outputDb,n,e.writeTelemetry),u=Qi(n,e.tempPaths.tempOutputScip,e.onStatus));let l=await kl({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:u,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return u;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),bi({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let v=n.map(P=>P.language==="typescript"?{language:P.language,scipPath:s.candidateScipPath}:P);return Ki(e.paths.outputDb,v,e.writeTelemetry),u=Qi(v,e.tempPaths.tempOutputScip,e.onStatus),u}});A(e.opts.signal,"Reindex cancelled by its owner."),z(H(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),zt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles);let d=Et(e.tempPaths.tempOutputDb);if(d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),l.mode==="incremental"&&s){let v=null,P=null;try{v=new O({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),P=new O({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=er(v,e.fingerprint,s.referenceFragmentsByFile,P);e.onStatus(`Cached exact TypeScript reference fragments for ${x} affected document(s).`)}catch(x){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${x instanceof Error?x.message:String(x)}.`)}finally{v?.close(),P?.close()}}let p=Xt(e.paths.metaPath),g=l.mode==="incremental"&&s?wl(s,l.changedDocumentPaths):xt({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),f=Ye({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(v=>v.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",I={...o};m&&delete I.typescript;let{metadata:h,pruneProjects:b}=so({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:I,typescriptProjectShardContext:a,lastRefresh:f});h.scipCompanion=m?"deferred":"current",co(e.paths.outputDb,b),Kt(e.tempPaths.tempMetaPath,h);let S=xn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}});return S.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${S.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),Ln(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),_n(y(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),ao(e.paths.outputDb,g,e.onStatus),f}function Sl(e,t,n,r,i,o){let a=Xt(e.paths.metaPath),s=null;try{J(e.writeTelemetry,q(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=Pr("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}z(H(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),zt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Et(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),s??=xt({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,refreshResult:"reused"});let u=Ye({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:d}=so({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:u});return co(e.paths.outputDb,d),Kt(e.paths.metaPath,l),lt(e.paths.outputDb,e.paths.metaPath),ao(e.paths.outputDb,s,e.onStatus),u}function Xt(e){return ln(se(e)?.fingerprint)}function ao(e,t,n){try{Ir(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function so(e){let t=Rl({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:le,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:2,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function Rl(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=se(e.metaPath),n=t?.version===le?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function co(e,t){let n=ho(e);if(t===null){te(()=>ae(n,{recursive:!0,force:!0}));return}let r;try{r=ro(n)}catch{return}for(let i of xl(r,t))te(()=>ae(k(n,i),{force:!0}))}function xl(e,t){let n=new Set(t.map(r=>`${At(r)}.scip`));return e.filter(r=>!n.has(r))}function Ki(e,t,n){for(let r of t){let i=Yt(e,r.language);He(y(i),{recursive:!0}),r.scipPath!==i&&J(n,q(r.scipPath,i))}}function Pl(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?he(e.tempOutputScip,o,a):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:o,scipPath:a})=>[o,a]));for(let{language:o,scipPath:a}of r){let s=vl({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?uo(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function vl(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[Jt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??ne(e.projectRoot,e.typescriptProjects);return t.length===0?[Jt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>Jt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:he(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function Jt(e){let t=Pt(e.language),n=Te(t),r=zn(t,e.projectRoot),i=e.trustProjectTools&&r?Xn(t,e.projectRoot):null,o=pe(t);if(!i&&!o&&r){let l=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(!i&&!o&&!Hn(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: codebaseiq reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!vi(t,e.onStatus)){let l=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}}let a=i?.canonicalPath??pe(t);if(!a){let l=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:a,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),u=Dr({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(i&&!i.executable){let l=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:a,binary:s,args:c,env:Kn(t,e.env,a),...u===void 0?{}:{temporaryRootConfigContent:u},...i?{trustedProjectTool:i}:{}}}}function Il(e,t){let n=new Map;for(let i of e)if(i.skipped)uo(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,a=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};a.scipPaths.push(i.scipPath),n.set(o,a)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Nn(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&io(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function uo(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function El(e,t,n,r,i){if(e.length===0){let o=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
339
339
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
340
340
|
`+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
341
341
|
`+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
342
|
-
`))}function
|
|
343
|
-
//# sourceMappingURL=chunk-
|
|
342
|
+
`))}function Qi(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Cn(e.map(o=>o.scipPath),t);return lo(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&io(e[0].scipPath,t);return!1}async function kl(e){let t;if(Tl(e)){let i=k(e.run.tempPaths.runDir,"typescript-affected.db");try{e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let o=performance.now();Zi(e.incrementalTypeScript.affectedScipPath,i,e.run.onStatus,!1,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-o).toFixed(0)}ms.`);let a=jr({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles,writeTelemetry:e.run.writeTelemetry});return e.run.onStatus(`Patched ${a.affectedDocumentCount} SQLite document(s) in ${(a.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:a.changedDocumentPaths,patchDurationMs:a.durationMs,converterDurationMs:performance.now()-o,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(o){A(e.run.opts.signal,"Reindex cancelled by its owner."),t=o instanceof Error?o.message:String(o),te(()=>ae(i,{force:!0})),te(()=>ae(e.run.tempPaths.tempOutputDb,{force:!0})),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return Zi(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Tl(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!T(e.run.paths.outputDb)||!T(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function wl(e,t){let n=R(),r=[...t].sort(),i=new Set(r),o={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(a=>!i.has(a)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:R()-n,manifest:e.manifest,plan:e.plan,comparison:o,evaluation:Rt(e.plan,o,e.projectFileCount)}}function Zi(e,t,n,r,i){if(A(i,"Reindex cancelled by its owner."),n("Writing the SQLite index..."),!T(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{lo(si(e,t,{sanitize:!r}),n)}catch(o){let a=o instanceof Error?o.message:String(o);throw new Error(`Failed to write the SQLite index: ${a}`,{cause:o})}}function lo(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function he(e,t,n){let r=el(e)||".scip",i=Je(e,r);return k(y(e),`${i}.${n+1}.${t}${r}`)}async function _l(e,t){for(let n=0;n<2;n++){let r=Fl(e,t);if(r)return r;let i=Dl(e);if(i&&fo(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await Ll(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${B(s)}`,{cause:s})}if(!o)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${y(e)}; refusing to steal an active lock.`);let a=st(e,{parseLegacy:ze});if(!gn(e,a,{parseLegacy:ze}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another codebaseiq reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire codebaseiq reindex lock for ${y(e)}.`)}function Fl(e,t){let n=Z(process.pid),r=Re(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:ze});if(r.kind==="acquired"&&r.reclaimed){let i=po(r.reclaimed,e);i&&fo(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Dl(e){return po(st(e,{parseLegacy:ze}),e)}var ze=e=>{let t=go(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function po(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return go(e.parsed,t)}function go(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=nn(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function fo(e,t){return e?.kind==="manual-cli"&&Al(t?.trigger)}function Al(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function Ll(e){return!K(e.pid)||(Ht(e),eo(e,"SIGTERM"),await to(e,2e3))?!0:(Ht(e),eo(e,"SIGKILL"),to(e,1e3))}function eo(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!K(e.pid))return;Ht(e)}try{process.kill(e.pid,t)}catch{}}async function to(e,t){let n=R()+t;for(;R()<n;){if(no(e))return!0;await Ol(50)}return no(e)}function Ht(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=Z(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!ue(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function no(e){if(!K(e.pid))return!0;if(!e.processIdentity)return!1;let t=Z(e.pid);return t!==null&&!ue(e.processIdentity,t)}function Ol(e){return new Promise(t=>setTimeout(t,e))}function mo(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?bn(n.typescriptProjects):[],o=r==="clojure"?Nl(n.clojureConfigPath):void 0,a=[...Pt(r).markerFiles,...i,...o?[o]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:i}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Cl(n),...s,clojureConfigPath:o,files:Pe(e,{language:r,markerFiles:a})}]}))}function Nl(e){return e?.trim()||void 0}function Cl(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Yt(e,t){return k(y(e),"language-indexes",`${t}.scip`)}function ho(e){return k(y(e),"language-indexes","typescript-projects")}function Xe(e,t){return k(ho(e),`${At(t)}.scip`)}function se(e){try{return it(ee(D(e,"reindex metadata")))}catch{return null}}function yo(e,t){try{let n=ee(D(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&at(r)&&j(r.fingerprint)===j(t)&&j([...r.indexedLanguages??[]].sort())===j(t.languages)}catch{return!1}}function Kt(e,t){hn(e,t,{spacing:2,trailingNewline:!0})}function bo(e,t){try{let n=it(ee(D(e,"reindex metadata")));if(!n)return;Kt(e,{...n,lastRefresh:t})}catch{}}function Ye(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:R()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function j(e){return JSON.stringify(e)}function Bl(e,t,n,r){return oo({projectRoot:e,languages:r.languages?.length?r.languages:t.languages,outputScip:n.indexPath,outputDb:n.dbPath,pnpmWorkspaces:t.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:t.indexer?.typescript?.projectMode,typescriptProjects:t.indexer?.typescript?.projects,clojureConfigPath:t.indexer?.clojure?.configPath,skipIfUnchanged:r.force!==!0,allowPartial:r.allowPartial===!0,skipAutoInstall:r.skipAutoInstall===!0,installMissing:r.installMissing===!0,trustProjectTools:r.trustProjectTools===!0,indexerConcurrency:r.indexerConcurrency??t.indexerConcurrency,trigger:r.trigger,...r.onStatus?{onStatus:r.onStatus}:{}})}async function cm(e,t,n){if(!an(ct(e)))throw new Error("reindex --base publishes a shared generation, which CODEBASEIQ_CACHE_DIR, CODEBASEIQ_INDEX_DB, CODEBASEIQ_READ_ONLY, CODEBASEIQ_SHARED_CACHE=0 and a configured dbPath disable");let r=Zt(e,t),i=jl(Vl(Ml(),"codebaseiq-base-"));$l(e,["-c","core.longpaths=true","worktree","add","--detach",i,r]);let o;try{let a=ct(i),s=sn(i,a);return o=s.cacheDir,{commit:r,result:await Bl(i,a,s,n)}}finally{Ro("git",["worktree","remove","--force",i],{cwd:e,timeout:xo,windowsHide:!0}),So(i,{recursive:!0,force:!0}),o&&So(o,{recursive:!0,force:!0})}}var xo=6e5;function $l(e,t){let n=Ro("git",t,{cwd:e,encoding:"utf8",timeout:xo,windowsHide:!0});if(n.status!==0)throw new Error(`git ${t.join(" ")} failed: ${(n.stderr||n.stdout).trim()}`)}export{dr as a,Ed as b,kd as c,Pt as d,Ya as e,Zd as f,ep as g,vi as h,Lu as i,oo as j,Bl as k,cm as l};
|
|
343
|
+
//# sourceMappingURL=chunk-F4AGM7ZE.js.map
|