codebaseiq 0.2.0 → 0.3.1
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 +59 -2
- package/README.md +1 -1
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-WH5SYOMD.js → chunk-2E6OUPCF.js} +2 -2
- package/dist/chunk-2I2UHZET.js +2 -0
- package/dist/{chunk-CSZOQ7YO.js → chunk-2OMXFE64.js} +2 -2
- package/dist/{chunk-57KFVPVZ.js → chunk-2XBJRZEM.js} +2 -2
- package/dist/{chunk-PFPHS4NO.js → chunk-2Z7K66D7.js} +2 -2
- package/dist/{chunk-5WXOEJ4G.js → chunk-356EZBIP.js} +2 -2
- package/dist/{chunk-DLC6JDN7.js → chunk-3H2H5ODK.js} +2 -2
- package/dist/{chunk-HBQGKMM3.js → chunk-3LQJRS4I.js} +2 -2
- package/dist/{chunk-H3CKAL6P.js → chunk-3ON3A2QV.js} +2 -2
- package/dist/{chunk-MTMF4N7F.js → chunk-3VJ3OCRE.js} +2 -2
- package/dist/{chunk-QMGWSEPL.js → chunk-4GWN76B2.js} +2 -2
- package/dist/{chunk-IBM3F2BJ.js → chunk-4LK5OIPW.js} +2 -2
- package/dist/{chunk-6SDEQTVY.js → chunk-53ELMZRF.js} +2 -2
- package/dist/{chunk-OJFLPVBP.js → chunk-57OPIQFM.js} +2 -2
- package/dist/{chunk-2E6BTWER.js → chunk-5CR4U5X2.js} +2 -2
- package/dist/{chunk-IYBIBMPF.js → chunk-5FWR5HLG.js} +2 -2
- package/dist/{chunk-HHBBGWES.js → chunk-5LL4KEHO.js} +2 -2
- package/dist/{chunk-NTRW52UR.js → chunk-5MPBSFZH.js} +2 -2
- package/dist/chunk-5T44HG5Y.js +88 -0
- package/dist/chunk-5TZNHP4T.js +8 -0
- package/dist/{chunk-L3YSDLNB.js → chunk-5YBDBY5L.js} +2 -2
- package/dist/{chunk-YFQPWKHR.js → chunk-5ZI2PPI7.js} +2 -2
- package/dist/{chunk-WO47BIPY.js → chunk-6EYESTJM.js} +2 -2
- package/dist/{chunk-PHPQ24UG.js → chunk-6FXXYYQM.js} +2 -2
- package/dist/chunk-6O3KXIDL.js +2 -0
- package/dist/{chunk-PLZXWZHY.js → chunk-7GAK2F3H.js} +2 -2
- package/dist/{chunk-W3FK73MD.js → chunk-7UCDGXRW.js} +2 -2
- package/dist/{chunk-U2XX3BT4.js → chunk-AGGR2BKS.js} +2 -2
- package/dist/{chunk-ZB3V5QM7.js → chunk-ALOEHWJS.js} +2 -2
- package/dist/{chunk-NDGTJHQN.js → chunk-AXQCHG77.js} +2 -2
- package/dist/{chunk-X5I2BQGX.js → chunk-BFANZRQ5.js} +2 -2
- package/dist/{chunk-VVCBMH5O.js → chunk-BGGB5N53.js} +2 -2
- package/dist/{chunk-PARCKE3Q.js → chunk-BGYRF5YX.js} +2 -2
- package/dist/{chunk-CIVYHK7U.js → chunk-BIADXGC3.js} +2 -2
- package/dist/{chunk-NK76RSB6.js → chunk-BPKNP3KZ.js} +2 -2
- package/dist/{chunk-ZOEDRCR4.js → chunk-BRQL7AFJ.js} +2 -2
- package/dist/{chunk-KDYQQJ6X.js → chunk-BWL3PMPT.js} +2 -2
- package/dist/{chunk-M7LAIM77.js → chunk-C6WKPKCF.js} +2 -2
- package/dist/{chunk-37TKC6MB.js → chunk-CB5AVJMM.js} +2 -2
- package/dist/{chunk-BX2U3QQV.js → chunk-CCIYWXX6.js} +2 -2
- package/dist/{chunk-3AC56WAR.js → chunk-CIYA2KZN.js} +2 -2
- package/dist/{chunk-6OVNYYY4.js → chunk-CJTKGAGH.js} +2 -2
- package/dist/{chunk-FIXYHQ3W.js → chunk-CLPCFGRT.js} +2 -2
- package/dist/{chunk-LY2NB5XR.js → chunk-CSPDQLLU.js} +2 -2
- package/dist/{chunk-CMXW7MFV.js → chunk-CYJS33YX.js} +2 -2
- package/dist/{chunk-ACZDU5GK.js → chunk-D7DOB27N.js} +7 -7
- package/dist/{chunk-XUJM6474.js → chunk-DDRA3QKN.js} +2 -2
- package/dist/{chunk-3NUZVLR7.js → chunk-DECN422G.js} +2 -2
- package/dist/{chunk-RRPK327J.js → chunk-DJKOXMNG.js} +2 -2
- package/dist/{chunk-SJZQ2PTZ.js → chunk-DWBAESVW.js} +2 -2
- package/dist/{chunk-S5SKXCND.js → chunk-EHPOTEQX.js} +2 -2
- package/dist/chunk-EIBGSU2R.js +2 -0
- package/dist/{chunk-DVYG3JTA.js → chunk-ELYMY5S2.js} +2 -2
- package/dist/chunk-EOKVZXNF.js +355 -0
- package/dist/chunk-EQNMD62X.js +51 -0
- package/dist/{chunk-YIOQJ45A.js → chunk-F3QSL4W2.js} +2 -2
- package/dist/{chunk-VG55NFXF.js → chunk-F5CJO5JN.js} +2 -2
- package/dist/{chunk-JOALNFY3.js → chunk-F74LZWCE.js} +2 -2
- package/dist/chunk-G7GVV2TV.js +27 -0
- package/dist/{chunk-U24M5RQM.js → chunk-GQLDYCWS.js} +2 -2
- package/dist/{chunk-B2E3HZ2A.js → chunk-GV2CEZCW.js} +2 -2
- package/dist/{chunk-AM5SUGHF.js → chunk-GVAF222T.js} +2 -2
- package/dist/{chunk-T3YFIJ5P.js → chunk-HJTM3C4Y.js} +2 -2
- package/dist/{chunk-FY5V4V4F.js → chunk-HNXRVGMY.js} +2 -2
- package/dist/{chunk-UWB5WMC2.js → chunk-I3OK27P7.js} +2 -2
- package/dist/{chunk-RVYLJDXC.js → chunk-ICUL7XRT.js} +2 -2
- package/dist/{chunk-QVHZB75Z.js → chunk-IHSLIIL3.js} +2 -2
- package/dist/chunk-ILGTMRMZ.js +2 -0
- package/dist/{chunk-XNUWRTYM.js → chunk-IZDPGOZR.js} +2 -2
- package/dist/{chunk-BH5CE4LN.js → chunk-J7AMBVWF.js} +2 -2
- package/dist/chunk-JAFDMV5I.js +2 -0
- package/dist/{chunk-YXJ4IAHH.js → chunk-JCMFBF4Z.js} +2 -2
- package/dist/{chunk-BLKYYQ7C.js → chunk-JNXI6NQ7.js} +95 -95
- package/dist/{chunk-DKJXK3HA.js → chunk-JSB43EX6.js} +2 -2
- package/dist/chunk-JYRJYXUV.js +2 -0
- package/dist/chunk-K4S2VH42.js +82 -0
- package/dist/{chunk-QLTFXVUI.js → chunk-K6FNTQQW.js} +2 -2
- package/dist/{chunk-JYX5UZSZ.js → chunk-KEJ2HLRW.js} +2 -2
- package/dist/{chunk-VCWAJPXQ.js → chunk-KFTHI2R6.js} +2 -2
- package/dist/chunk-KLX6NSWT.js +3 -0
- package/dist/{chunk-DFPAZXLU.js → chunk-KPZGTB2O.js} +2 -2
- package/dist/{chunk-T55YPJGB.js → chunk-KUKKLWJD.js} +2 -2
- package/dist/{chunk-RWKEXCHU.js → chunk-KUKWHP4R.js} +2 -2
- package/dist/{chunk-ZJZQ7Q2Q.js → chunk-KWRQVLPX.js} +2 -2
- package/dist/{chunk-FQA3KIFX.js → chunk-L37EQYAX.js} +2 -2
- package/dist/{chunk-PNVZIJ57.js → chunk-LCW3PSGL.js} +2 -2
- package/dist/{chunk-7Z7HCZ7J.js → chunk-LKUTSP4G.js} +2 -2
- package/dist/{chunk-HIEXRDJF.js → chunk-LMTSB3TB.js} +2 -2
- package/dist/{chunk-SF34QLK2.js → chunk-LQHYYIOB.js} +2 -2
- package/dist/{chunk-EXMVF3JR.js → chunk-LSZYMN2A.js} +3 -3
- package/dist/{chunk-RCPZOPV6.js → chunk-M2Y6PCFE.js} +2 -2
- package/dist/chunk-MC46AL7B.js +343 -0
- package/dist/{chunk-SRY26ITJ.js → chunk-MDFT325O.js} +2 -2
- package/dist/{chunk-WJOQC4P7.js → chunk-MEUHIDI3.js} +2 -2
- package/dist/{chunk-FLLXYUOL.js → chunk-MQW6SJ4P.js} +2 -2
- package/dist/{chunk-57KEZDPT.js → chunk-MSI3K7PJ.js} +2 -2
- package/dist/{chunk-27PHVDKL.js → chunk-MZNMASFM.js} +2 -2
- package/dist/{chunk-VYZQZ4ZN.js → chunk-N2XDMNVI.js} +2 -2
- package/dist/{chunk-JN5LIBT3.js → chunk-NDKOVQFG.js} +2 -2
- package/dist/{chunk-W6C6QTXJ.js → chunk-NEWHKGVD.js} +2 -2
- package/dist/chunk-NNG6M6XD.js +3 -0
- package/dist/chunk-O2KWU34K.js +278 -0
- package/dist/{chunk-HBXZAGY6.js → chunk-O2M3VNDY.js} +2 -2
- package/dist/{chunk-FPDL2TUB.js → chunk-OBC7HSSO.js} +2 -2
- package/dist/{chunk-J24VICI5.js → chunk-OKAF4OQS.js} +2 -2
- package/dist/{chunk-I5FCDTK2.js → chunk-OP6BUIV6.js} +2 -2
- package/dist/{chunk-2DMVFAY7.js → chunk-OQ3DK7FW.js} +2 -2
- package/dist/{chunk-FEBLLMTL.js → chunk-OQUCBKOI.js} +2 -2
- package/dist/chunk-OT5ISJSR.js +2 -0
- package/dist/{chunk-N3Q3AWGW.js → chunk-OWJWOEDU.js} +96 -96
- package/dist/{chunk-M4EVGA5S.js → chunk-PIFYOWS4.js} +3 -3
- package/dist/{chunk-35YYZD3D.js → chunk-PTR3EOXC.js} +2 -2
- package/dist/{chunk-5XEVXVTK.js → chunk-PUVNH4PO.js} +2 -2
- package/dist/{chunk-I645ZF75.js → chunk-QEOWONKY.js} +2 -2
- package/dist/{chunk-JXHLB7TP.js → chunk-QMOZZ2VX.js} +2 -2
- package/dist/{chunk-NIO346UL.js → chunk-QY7QB7I6.js} +2 -2
- package/dist/{chunk-YYFV32WR.js → chunk-R4OJGTMP.js} +2 -2
- package/dist/{chunk-2VKB5CMA.js → chunk-RCIGX23V.js} +2 -2
- package/dist/{chunk-TUTSO7UZ.js → chunk-RIO3JXHM.js} +2 -2
- package/dist/{chunk-4IFISPQW.js → chunk-SA7G6GJX.js} +2 -2
- package/dist/{chunk-OMBRP7BB.js → chunk-SB53KPWA.js} +2 -2
- package/dist/chunk-SB7NASHU.js +2 -0
- package/dist/{chunk-3XFJUWJE.js → chunk-SGMNWYTH.js} +2 -2
- package/dist/{chunk-A7XQT7MH.js → chunk-SUE7SHZL.js} +2 -2
- package/dist/{chunk-IOVPAZWP.js → chunk-SX72EVMY.js} +2 -2
- package/dist/{chunk-OVKZM2XI.js → chunk-SZ4P7MF7.js} +2 -2
- package/dist/{chunk-EM5UHLAM.js → chunk-T2M5HWBQ.js} +2 -2
- package/dist/{chunk-CZEIHYMP.js → chunk-T6MQNNAC.js} +2 -2
- package/dist/chunk-T75DS2E6.js +21 -0
- package/dist/{chunk-57GCCPLS.js → chunk-TEANKHUU.js} +2 -2
- package/dist/{chunk-MT5W4DUG.js → chunk-TEMM2FEL.js} +2 -2
- package/dist/{chunk-I2KP4AGR.js → chunk-TJWVT4DO.js} +2 -2
- package/dist/{chunk-77GHPR2R.js → chunk-TLTSESB4.js} +2 -2
- package/dist/{chunk-KM4QRWI5.js → chunk-TNJGTQWO.js} +2 -2
- package/dist/{chunk-EFFMFK7C.js → chunk-TOTWJZIX.js} +2 -2
- package/dist/{chunk-54K6556S.js → chunk-U33PMPNW.js} +2 -2
- package/dist/{chunk-GXVDTHFC.js → chunk-U7NUXDQO.js} +2 -2
- package/dist/chunk-UC2FD2PS.js +4 -0
- package/dist/{chunk-MRGTCMDK.js → chunk-UIAUPFBJ.js} +2 -2
- package/dist/{chunk-LAGDJXFY.js → chunk-UJIXCI3L.js} +2 -2
- package/dist/{chunk-IVJJNVSX.js → chunk-UMEPSVKT.js} +2 -2
- package/dist/{chunk-4O52YNKL.js → chunk-UQYQBLJX.js} +2 -2
- package/dist/{chunk-JUO3Z644.js → chunk-UW6KD57C.js} +2 -2
- package/dist/{chunk-TAJ6UGCO.js → chunk-V4NGDIEA.js} +3 -3
- package/dist/{chunk-VLTUX4IF.js → chunk-VGWZ4MOY.js} +2 -2
- package/dist/{chunk-KNV5VFDV.js → chunk-VSGOIZMQ.js} +2 -2
- package/dist/{chunk-K5G7SPAG.js → chunk-W7QDASTN.js} +4 -4
- package/dist/{chunk-IWAMYGPN.js → chunk-W7YLRXZE.js} +2 -2
- package/dist/{chunk-QKVTWODE.js → chunk-WK2IQJPK.js} +2 -2
- package/dist/{chunk-HYKSLTAR.js → chunk-WO6OFKUC.js} +2 -2
- package/dist/{chunk-S64NCE2Z.js → chunk-WWCV4E6J.js} +2 -2
- package/dist/{chunk-2F5ERMNI.js → chunk-XJBK3QDV.js} +2 -2
- package/dist/{chunk-IGYAZPRX.js → chunk-XN3EKMLI.js} +2 -2
- package/dist/{chunk-FWY2PRIF.js → chunk-XQAVQVIL.js} +2 -2
- package/dist/{chunk-NJA4MMBD.js → chunk-XUPFA6GH.js} +2 -2
- package/dist/{chunk-4AOOSCZ7.js → chunk-YHPG3S2U.js} +2 -2
- package/dist/{chunk-CDWSLAPN.js → chunk-YPBKBYPS.js} +2 -2
- package/dist/{chunk-5BDK6QC3.js → chunk-YRKP7PM7.js} +2 -2
- package/dist/{chunk-4NHWNAWQ.js → chunk-YT4DVWUV.js} +2 -2
- package/dist/{chunk-5NJPH3QZ.js → chunk-YTJHCGYB.js} +2 -2
- package/dist/{chunk-ZNQCR656.js → chunk-Z66XYVLZ.js} +2 -2
- package/dist/{chunk-A67HT5FR.js → chunk-ZB4C5TTR.js} +2 -2
- package/dist/chunk-ZMA5HWXY.js +3 -0
- package/dist/{chunk-CWMHWD56.js → chunk-ZNH33XIB.js} +2 -2
- package/dist/{cli-context-XEPPF4RX.js → cli-context-FJL2JHOE.js} +2 -2
- package/dist/{cli-context-TSADTXLB.js → cli-context-PQNWHMCQ.js} +2 -2
- package/dist/{cli-program-KJGQEM72.js → cli-program-SCHOHOQE.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{code-CDe-mIjx.d.ts → code-DfX3xeWy.d.ts} +1 -1
- package/dist/{code-viewer-ZCTHXQ5C.js → code-viewer-AMRXV444.js} +2 -2
- package/dist/{code-viewer-YGDON6SY.js → code-viewer-EXI5SFFR.js} +2 -2
- package/dist/{command-descriptors-5VAB2MZX.js → command-descriptors-H6A4UY72.js} +129 -129
- package/dist/{command-descriptors-EAHKIRAG.js → command-descriptors-ROIOTCCW.js} +130 -130
- package/dist/{db-DmRNdCtm.d.ts → db-BoG_PWYH.d.ts} +1 -1
- package/dist/direct-navigation-3JOYP2MO.js +3 -0
- package/dist/direct-navigation-SJMJLBY7.js +2 -0
- package/dist/{graph-evidence-Bs54NWws.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
- package/dist/{health-BnzbSLCE.d.ts → health-DkYBS5BI.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-GMZX3UAD.js +2 -0
- package/dist/invocation-command-descriptors-HNMKDEF6.js +3 -0
- package/dist/{scip-cli-BRFKkHQn.d.ts → maintenance-types-CdL5eQii.d.ts} +1 -20
- package/dist/output-continuation-command-5NWVDQT7.js +2 -0
- package/dist/output-continuation-command-RNEHNYPU.js +3 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-MIW5CYEG.js +3 -0
- package/dist/project-reindex-VQ23LWDA.js +2 -0
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.d.ts +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.d.ts +2 -2
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +1 -1
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +2 -2
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +2 -2
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +4 -4
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.d.ts +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.d.ts +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.d.ts +3 -3
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +1 -1
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.d.ts +2 -2
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +2 -2
- package/dist/reindex.d.ts +2 -4
- package/dist/reindex.js +71 -32
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.js +3 -3
- 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-H66AZ3VE.js +2 -0
- package/dist/sentinel-ensure-command-R4YAUCJB.js +3 -0
- package/dist/sentinel-worker.js +1 -1
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +2 -2
- package/docs/INDEX_GENERATIONS.md +2 -2
- package/docs/NPM_RELEASE.md +323 -0
- package/docs/schemas/npm-release-state.schema.json +4 -13
- package/package.json +3 -11
- package/dist/chunk-2Q2LW5JW.js +0 -14
- package/dist/chunk-327YK6TB.js +0 -4
- package/dist/chunk-347TXATM.js +0 -2
- package/dist/chunk-36WRYYTE.js +0 -3
- package/dist/chunk-5IO2APSS.js +0 -2
- package/dist/chunk-6OAHRI2D.js +0 -6
- package/dist/chunk-6URCE5QY.js +0 -2
- package/dist/chunk-6ZV5EDUT.js +0 -5
- package/dist/chunk-7R64XY4Y.js +0 -12
- package/dist/chunk-CANBLFVQ.js +0 -15
- package/dist/chunk-CCRZLRWJ.js +0 -2
- package/dist/chunk-G2XUZCF2.js +0 -88
- package/dist/chunk-H5QXP63L.js +0 -2
- package/dist/chunk-HCMQZPEO.js +0 -2
- package/dist/chunk-IEL6Q5W3.js +0 -308
- package/dist/chunk-IGQQUENU.js +0 -109
- package/dist/chunk-K2O7SBAU.js +0 -2
- package/dist/chunk-QVWDQTMG.js +0 -2
- package/dist/chunk-RJWAB4VR.js +0 -345
- package/dist/chunk-VCL7FK3E.js +0 -3
- package/dist/chunk-WOOTEWQT.js +0 -239
- package/dist/chunk-XYLV727H.js +0 -21
- package/dist/chunk-YMGZZEW4.js +0 -2
- package/dist/direct-navigation-B3SGOOBW.js +0 -2
- package/dist/direct-navigation-ZL362KXF.js +0 -3
- package/dist/invocation-command-descriptors-CSUGUHTT.js +0 -2
- package/dist/invocation-command-descriptors-PPVZOIE5.js +0 -3
- package/dist/output-continuation-command-FTVVBVSN.js +0 -2
- package/dist/output-continuation-command-ITPRC3YV.js +0 -3
- package/dist/project-reindex-7HZSLLLY.js +0 -3
- package/dist/project-reindex-NGM3DYBN.js +0 -2
- package/dist/sentinel-ensure-command-KYYULCFU.js +0 -2
- package/dist/sentinel-ensure-command-RIZA3RY7.js +0 -3
- package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
- package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
- package/scripts/build-codebaseiq-windows.mjs +0 -197
- package/scripts/codebaseiq-windows-provenance.mjs +0 -364
- package/scripts/verify-codebaseiq-windows.mjs +0 -29
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as ir}from"./chunk-EN4AHLL3.js";import{Bb as Yn,Jb as Kn,Kb as Qn,Lb as Zn,Nb as er,Ob as tr,Pb as nr,Qb as rr,T as Vn,U as $n,ca as ke,cb as Bn,db as Un,fb as re,gb as Te,hb as pe,ib as Wn,jb as Gn,k as Ee,kb as qn,lb as Jn,mb as Hn,ob as we,pb as zn,ub as ft,zb as Xn}from"./chunk-EOKVZXNF.js";import{d as nn,e as tt}from"./chunk-D62CTZX6.js";import{$ as gn,$a as Ie,A as an,Aa as U,B as Se,Ba as W,C as E,Ca as G,D as le,E as ee,Ea as lt,F as it,Fa as Sn,G as sn,Ga as dt,H as ot,Ha as pt,I as at,Ia as Rn,J as R,Ja as xn,Ka as Pn,L as cn,La as vn,M as A,Ma as In,Na as En,O as Re,Oa as kn,P as st,Pa as Tn,Q as un,Qa as wn,Ra as _n,S as ln,Sa as Fn,Ta as Ln,U as te,Ua as An,Va as ve,Wa as Dn,X as dn,Y as pn,Ya as gt,Za as On,_ as O,_a as Nn,cb as Cn,db as jn,eb as Mn,ha as xe,ia as de,j as nt,ka as ne,ma as fn,pa as mn,s as rt,ta as Pe,u as F,ua as hn,v as rn,va as ct,wa as yn,xa as bn,ya as ut,z as on}from"./chunk-5T44HG5Y.js";import{C as tn,D as et,F as B,d as ye,i as Qt,j as K,k as Q,l as Ke,m as ce,n as be,o as Qe,p as D,q as _,r as L,s as Zt,w as en,x as ue,y as Z,z as Ze}from"./chunk-DUKHVPU5.js";import{createHash as Gu}from"crypto";import{existsSync as T,mkdirSync as He,readdirSync as Zi,renameSync as eo,rmSync as ae,statSync as qu}from"fs";import{basename as Je,dirname as y,extname as Ju,join as k,resolve as qi}from"path";import{execFileSync as mo}from"child_process";import{constants as ho,copyFileSync as or,statSync as yo}from"fs";import{platform as bo}from"os";var So=Object.freeze({size:e=>yo(e).size,clone:xo,copy:(e,t)=>or(e,t)}),Ro=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function q(e,t,n=So){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!vo(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function xo(e,t){if(bo()!=="darwin"){or(e,t,ho.COPYFILE_FICLONE_FORCE);return}try{mo("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw Po(n)}}function Po(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 vo(e){let t=e?.code;return t!==void 0&&Ro.has(t)}function ar(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function J(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import Io from"better-sqlite3";import{execFileSync as Eo}from"child_process";import{existsSync as ko,readdirSync as To}from"fs";import{extname as _e,join as wo}from"path";function H(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>sr({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function sr(e){let t=new Set((e.extensions??Vn).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!ko(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=gn(e.projectRoot),r=_o(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new Io(F(e.dbPath));try{let o=Lo(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=mn(e.projectRoot,p,{inputKind:"auxiliary source file"}),f=a.run(Ao(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 _o(e,t){let n=Fo(e,t);if(n)return n;let r=[],i=o=>{let a=o?wo(e,o):e,s;try{s=To(a,{withFileTypes:!0})}catch{return}for(let c of s){if($n.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 Fo(e,t){try{return Eo("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 Lo(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 Ao(e){return _e(e).toLowerCase()===".vue"?"vue":_e(e).replace(/^\./,"").toLowerCase()||"source"}import{dirname as Do,join as Oo}from"path";function cr(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??Oo(Do(n),"index.scip")}),o,a=!1,s=!1;try{let u=e.reuseExisting||e.affectedFiles?er(i):null;e.reuseExisting&&u?.extractorVersion===Kn?(o=u,a=!0):(o=Qn(i,{...u?{previousGraph:u}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(o.coverage.filesReused??0)>0)}finally{i.close()}a||Zn(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 Yo}from"crypto";import{existsSync as Ko}from"fs";import{dirname as Qo,join as fr}from"path";function mt(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=mt(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"),ur(r,i,a)):a.size>0?ur(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:No(r,t,i),reasons:[]}}function ur(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function No(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 Co,existsSync as jo,mkdirSync as Mo,renameSync as Vo,rmSync as $o,statSync as Bo,truncateSync as Uo}from"fs";import{basename as Wo,dirname as Go}from"path";var ie=".previous",qo=".rotation.lock",Jo=2e3,ht=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"},yt=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"},lr=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:Wo(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){Mo(e,{recursive:!0})},exists:jo,readBytes(e){return D(e,{maxBytes:be,inputKind:"rotating JSONL segment"})},size(e){return Bo(e).size},truncate:Uo,remove(e){$o(e,{force:!0})},rename:Vo,append:Co});function Le(e,t,n){let r=n.runtime??lr,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 pr(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(Go(e));let s=Ho(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 dr(e,t={}){let n=t.runtime??lr,r=zo(t.maxSegmentBytes);return pr(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=Xo(gr(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function pr(e,t,n,r){let i=`${e}${qo}`,o=Math.max(0,t??Jo),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 ht(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 yt(i);return l}function Ho(e,t,n){if(!n.exists(e))return 0;let r=gr(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 zo(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 gr(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 Xo(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 Zo="<global-symbols>";function ea(e){let t=[];for(let n of e.all(`
|
|
7
|
+
SELECT relative_path, language, position_encoding, text
|
|
8
|
+
FROM documents
|
|
9
|
+
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
10
|
+
SELECT d.relative_path,
|
|
11
|
+
c.chunk_index,
|
|
12
|
+
c.start_line,
|
|
13
|
+
c.end_line,
|
|
14
|
+
hex(c.occurrences) AS occurrences_hex
|
|
15
|
+
FROM chunks c
|
|
16
|
+
JOIN documents d ON d.id = c.document_id
|
|
17
|
+
`))t.push({relativePath:n.relative_path,kind:"chunk",values:[n.chunk_index,n.start_line,n.end_line,n.occurrences_hex]});for(let n of e.all(`
|
|
18
|
+
SELECT d.relative_path,
|
|
19
|
+
r.start_line,
|
|
20
|
+
r.start_char,
|
|
21
|
+
r.end_line,
|
|
22
|
+
r.end_char,
|
|
23
|
+
g.symbol,
|
|
24
|
+
g.display_name,
|
|
25
|
+
g.kind,
|
|
26
|
+
g.documentation,
|
|
27
|
+
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
|
|
28
|
+
g.enclosing_symbol,
|
|
29
|
+
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
|
|
30
|
+
FROM defn_enclosing_ranges r
|
|
31
|
+
JOIN documents d ON d.id = r.document_id
|
|
32
|
+
JOIN global_symbols g ON g.id = r.symbol_id
|
|
33
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:bt(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
34
|
+
SELECT d.relative_path,
|
|
35
|
+
c.chunk_index,
|
|
36
|
+
m.role,
|
|
37
|
+
g.symbol,
|
|
38
|
+
g.display_name,
|
|
39
|
+
g.kind,
|
|
40
|
+
g.documentation,
|
|
41
|
+
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
|
|
42
|
+
g.enclosing_symbol,
|
|
43
|
+
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
|
|
44
|
+
FROM mentions m
|
|
45
|
+
JOIN chunks c ON c.id = m.chunk_id
|
|
46
|
+
JOIN documents d ON d.id = c.document_id
|
|
47
|
+
JOIN global_symbols g ON g.id = m.symbol_id
|
|
48
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:bt(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
49
|
+
SELECT g.symbol,
|
|
50
|
+
g.display_name,
|
|
51
|
+
g.kind,
|
|
52
|
+
g.documentation,
|
|
53
|
+
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature_hex,
|
|
54
|
+
g.enclosing_symbol,
|
|
55
|
+
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships_hex
|
|
56
|
+
FROM global_symbols g
|
|
57
|
+
WHERE NOT EXISTS (
|
|
58
|
+
SELECT 1 FROM defn_enclosing_ranges r WHERE r.symbol_id = g.id
|
|
59
|
+
) AND NOT EXISTS (
|
|
60
|
+
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
61
|
+
)
|
|
62
|
+
`))t.push({relativePath:Zo,kind:"global-symbol",values:bt(n)});return ta(t)}function ta(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=Yo("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 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
|
|
64
|
+
FROM main.documents d
|
|
65
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
66
|
+
FROM temp.incremental_affected_paths p
|
|
67
|
+
LEFT JOIN incremental.documents d ON d.relative_path = p.relative_path
|
|
68
|
+
WHERE d.id IS NULL
|
|
69
|
+
LIMIT 1`).pluck().get(),o=e.prepare(`SELECT d.relative_path
|
|
70
|
+
FROM incremental.documents d
|
|
71
|
+
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
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 wa(e){e.exec(`
|
|
74
|
+
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
75
|
+
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
76
|
+
SELECT g.symbol
|
|
77
|
+
FROM main.defn_enclosing_ranges r
|
|
78
|
+
JOIN main.documents d ON d.id = r.document_id
|
|
79
|
+
JOIN main.global_symbols g ON g.id = r.symbol_id
|
|
80
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path;
|
|
81
|
+
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
82
|
+
SELECT g.symbol
|
|
83
|
+
FROM main.mentions m
|
|
84
|
+
JOIN main.chunks c ON c.id = m.chunk_id
|
|
85
|
+
JOIN main.documents d ON d.id = c.document_id
|
|
86
|
+
JOIN main.global_symbols g ON g.id = m.symbol_id
|
|
87
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
88
|
+
WHERE m.role = 1;
|
|
89
|
+
|
|
90
|
+
CREATE TEMP TABLE incremental_new_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
91
|
+
INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
|
|
92
|
+
SELECT g.symbol
|
|
93
|
+
FROM incremental.defn_enclosing_ranges r
|
|
94
|
+
JOIN incremental.global_symbols g ON g.id = r.symbol_id;
|
|
95
|
+
INSERT OR IGNORE INTO temp.incremental_new_defined_symbols(symbol)
|
|
96
|
+
SELECT g.symbol
|
|
97
|
+
FROM incremental.mentions m
|
|
98
|
+
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
99
|
+
WHERE m.role = 1;
|
|
100
|
+
`)}function _a(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
101
|
+
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
102
|
+
UNION
|
|
103
|
+
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
104
|
+
), unaffected_definitions AS (
|
|
105
|
+
SELECT g.symbol
|
|
106
|
+
FROM main.defn_enclosing_ranges r
|
|
107
|
+
JOIN main.documents d ON d.id = r.document_id
|
|
108
|
+
JOIN main.global_symbols g ON g.id = r.symbol_id
|
|
109
|
+
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
110
|
+
WHERE p.relative_path IS NULL
|
|
111
|
+
UNION
|
|
112
|
+
SELECT g.symbol
|
|
113
|
+
FROM main.mentions m
|
|
114
|
+
JOIN main.chunks c ON c.id = m.chunk_id
|
|
115
|
+
JOIN main.documents d ON d.id = c.document_id
|
|
116
|
+
JOIN main.global_symbols g ON g.id = m.symbol_id
|
|
117
|
+
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
118
|
+
WHERE m.role = 1 AND p.relative_path IS NULL
|
|
119
|
+
)
|
|
120
|
+
SELECT u.symbol
|
|
121
|
+
FROM unaffected_definitions u
|
|
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 Fa(e){e.exec(`
|
|
124
|
+
DELETE FROM main.mentions
|
|
125
|
+
WHERE chunk_id IN (
|
|
126
|
+
SELECT c.id
|
|
127
|
+
FROM main.chunks c
|
|
128
|
+
JOIN main.documents d ON d.id = c.document_id
|
|
129
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
130
|
+
);
|
|
131
|
+
DELETE FROM main.chunks
|
|
132
|
+
WHERE document_id IN (
|
|
133
|
+
SELECT d.id
|
|
134
|
+
FROM main.documents d
|
|
135
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
136
|
+
);
|
|
137
|
+
DELETE FROM main.defn_enclosing_ranges
|
|
138
|
+
WHERE document_id IN (
|
|
139
|
+
SELECT d.id
|
|
140
|
+
FROM main.documents d
|
|
141
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
142
|
+
);
|
|
143
|
+
DELETE FROM main.documents
|
|
144
|
+
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
145
|
+
`)}function La(e){e.exec(`
|
|
146
|
+
UPDATE main.global_symbols
|
|
147
|
+
SET display_name = NULL,
|
|
148
|
+
kind = NULL,
|
|
149
|
+
documentation = NULL,
|
|
150
|
+
signature = NULL,
|
|
151
|
+
enclosing_symbol = NULL,
|
|
152
|
+
relationships = NULL
|
|
153
|
+
WHERE symbol IN (SELECT symbol FROM temp.incremental_old_defined_symbols);
|
|
154
|
+
|
|
155
|
+
INSERT OR IGNORE INTO main.global_symbols(
|
|
156
|
+
symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
|
|
157
|
+
)
|
|
158
|
+
SELECT symbol, display_name, kind, documentation, signature, enclosing_symbol, relationships
|
|
159
|
+
FROM incremental.global_symbols;
|
|
160
|
+
|
|
161
|
+
UPDATE main.global_symbols
|
|
162
|
+
SET display_name = (
|
|
163
|
+
SELECT source.display_name FROM incremental.global_symbols source
|
|
164
|
+
WHERE source.symbol = main.global_symbols.symbol
|
|
165
|
+
),
|
|
166
|
+
kind = (
|
|
167
|
+
SELECT source.kind FROM incremental.global_symbols source
|
|
168
|
+
WHERE source.symbol = main.global_symbols.symbol
|
|
169
|
+
),
|
|
170
|
+
documentation = (
|
|
171
|
+
SELECT source.documentation FROM incremental.global_symbols source
|
|
172
|
+
WHERE source.symbol = main.global_symbols.symbol
|
|
173
|
+
),
|
|
174
|
+
signature = (
|
|
175
|
+
SELECT source.signature FROM incremental.global_symbols source
|
|
176
|
+
WHERE source.symbol = main.global_symbols.symbol
|
|
177
|
+
),
|
|
178
|
+
enclosing_symbol = (
|
|
179
|
+
SELECT source.enclosing_symbol FROM incremental.global_symbols source
|
|
180
|
+
WHERE source.symbol = main.global_symbols.symbol
|
|
181
|
+
),
|
|
182
|
+
relationships = (
|
|
183
|
+
SELECT source.relationships FROM incremental.global_symbols source
|
|
184
|
+
WHERE source.symbol = main.global_symbols.symbol
|
|
185
|
+
)
|
|
186
|
+
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
187
|
+
`)}function Aa(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
|
+
SELECT id + ?, language, relative_path, position_encoding, text
|
|
189
|
+
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
190
|
+
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
191
|
+
FROM incremental.chunks`).run(n,t),e.prepare(`INSERT INTO main.mentions(chunk_id, symbol_id, role)
|
|
192
|
+
SELECT m.chunk_id + ?, target.id, m.role
|
|
193
|
+
FROM incremental.mentions m
|
|
194
|
+
JOIN incremental.global_symbols source ON source.id = m.symbol_id
|
|
195
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(n),e.prepare(`INSERT INTO main.defn_enclosing_ranges(
|
|
196
|
+
id, document_id, symbol_id, start_line, start_char, end_line, end_char
|
|
197
|
+
)
|
|
198
|
+
SELECT r.id + ?, r.document_id + ?, target.id,
|
|
199
|
+
r.start_line, r.start_char, r.end_line, r.end_char
|
|
200
|
+
FROM incremental.defn_enclosing_ranges r
|
|
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 Da(e){e.exec(`
|
|
203
|
+
DELETE FROM main.global_symbols
|
|
204
|
+
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
205
|
+
AND NOT EXISTS (
|
|
206
|
+
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
207
|
+
);
|
|
208
|
+
`)}function Oa(e,t,n){let r=V(e,"SELECT COUNT(*) AS value FROM main.documents"),i=V(e,`SELECT COUNT(*) AS value
|
|
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 Na(e){let t=vt(e,"main",!0),n=vt(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 vt(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
|
+
FROM ${t}.documents d
|
|
212
|
+
${r}
|
|
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
|
|
214
|
+
FROM ${t}.chunks c
|
|
215
|
+
JOIN ${t}.documents d ON d.id = c.document_id
|
|
216
|
+
${r}
|
|
217
|
+
ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),a=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
|
|
218
|
+
g.symbol, g.display_name, g.kind, g.documentation,
|
|
219
|
+
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
|
|
220
|
+
g.enclosing_symbol,
|
|
221
|
+
CASE WHEN g.relationships IS NULL THEN NULL ELSE hex(g.relationships) END AS relationships
|
|
222
|
+
FROM ${t}.defn_enclosing_ranges r
|
|
223
|
+
JOIN ${t}.documents d ON d.id = r.document_id
|
|
224
|
+
JOIN ${t}.global_symbols g ON g.id = r.symbol_id
|
|
225
|
+
${r}
|
|
226
|
+
ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
|
|
227
|
+
FROM ${t}.mentions m
|
|
228
|
+
JOIN ${t}.chunks c ON c.id = m.chunk_id
|
|
229
|
+
JOIN ${t}.documents d ON d.id = c.document_id
|
|
230
|
+
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
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=Ra("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 Ca from"better-sqlite3";var De="idx_mentions_definitions",ja=["symbol_id","chunk_id"];function It(e){let t=new Ca(F(e)),n=[],r=[],i=[];try{return t.transaction(()=>{Ma(t,n),Oe(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&Nr(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=Nr(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 Ma(e,t){let n=Cr(e,De);if(n){let r=n.columns.join("\0")===ja.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${De} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${De}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(De)}function Nr(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 Cr(e,t)?.columns??null}function Cr(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 Va}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 Mr(e){let t=e.readFingerprint(),n=$a(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return Ba(e.cachePath,e.readFingerprint(),r),r}function $a(e,t){try{let n=JSON.parse(_(e,{maxBytes:Q,inputKind:"post-index augmentation cache"}));return jr(n.fingerprint)===jr(t)?{result:n.result}:null}catch{return null}}function Ba(e,t,n){Va(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
|
|
234
|
+
`)}function jr(e){return JSON.stringify(e)}import{existsSync as Vr,statSync as Ua}from"fs";import{dirname as Ur,join as Wr}from"path";var Wa="reindex-activity.jsonl",Ne=ie,Ga=1024*1024,qa=1440*60*1e3,$r=e=>L(e,"reindex activity segment");function Ce(e){return Wr(Ur(e),Wa)}function Ja(e){if(e.reused)return 0;let t=Et(e.indexPath)+Et(e.dbPath);for(let n of e.shards??[])!n.reused&&n.outputBytes!==null&&(t+=n.outputBytes);return t}function kt(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=Ja(t);return Tt(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:Qa(t)})}function Gr(e,t){return Tt(Ce(e),{version:1,event:"run",recordedAt:t.completedAt,trigger:t.trigger,result:"failed",durationMs:t.durationMs,estimatedLogicalOutputBytes:0})}function $d(e,t,n=new Date){return Tt(Ce(e),{version:1,event:"suppressed",recordedAt:n.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function Ha(e,t,n=Ga,r){Le(e,t,{maxSegmentBytes:n,previousSuffix:Ne,...r?{runtime:r}:{}})}function za(e,t=new Date,n=qa,r=$r){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===$r){if(!Vr(s)&&!Vr(`${s}${Ne}`))return a;try{let u=dr(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(...os(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=Xa(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 ns(d.byLanguage)){let m=(a.byLanguage??={})[g]??=rs();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=is(a),a}function Tt(e,t){try{return Ha(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function Xa(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(n.version!==1||!tn(n.recordedAt)||!n.trigger||!Ka(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"||!B(n.durationMs)||!B(n.estimatedLogicalOutputBytes)||n.estimatedWriteBytes!==void 0&&!B(n.estimatedWriteBytes)||n.reflinkedBytes!==void 0&&!B(n.reflinkedBytes)||n.fallbackCopiedBytes!==void 0&&!B(n.fallbackCopiedBytes))return null;let r=n,{byLanguage:i,...o}=r,a=Za(i);return{record:{...o,...a.byLanguage?{byLanguage:a.byLanguage}:{}},hasLanguageDetails:a.hasLanguageDetails,invalidLanguageDetails:a.invalidLanguageDetails}}catch{return null}}function Bd(e,t,n=new Date){return t.enabled?Ya(za(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function Ya(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:Br(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:Br(e.oldestWriteAt,t.windowMs,n),...i,detail:`${r}/${t.maxEstimatedWriteBytes} estimated write bytes consumed`}:{state:"allowed",...i}:{state:"allowed",...i}}function Br(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function Ka(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 Et(e){try{return Ua(e).size}catch{return 0}}function Qa(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=Et(Wr(Ur(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 Za(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(!ts(i)||!es(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function es(e){if(!e||typeof e!="object")return!1;let t=e;return(t.result==="rebuilt"||t.result==="reused")&&et(t.outputBytes)&&et(t.producedOutputBytes)&&B(t.durationMs)&&(t.result!=="reused"||t.producedOutputBytes===0&&t.durationMs===0)&&t.producedOutputBytes<=t.outputBytes}function ts(e){return Ze.includes(e)}function ns(e){return e?Ze.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function rs(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function is(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function os(e){return e.endsWith(`
|
|
235
|
+
`)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
|
|
236
|
+
`)+1))),e.split(`
|
|
237
|
+
`).filter(t=>t.length>0)}import{createHash as as}from"crypto";import{existsSync as wt,readdirSync as ss}from"fs";import{dirname as _t,join as je,relative as cs,resolve as Ft,sep as qr}from"path";function Jr(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=Yr(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function Hr(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=Yr(s,e);c&&c!==i&&a.add(c)}}return us(e,r)}function zr(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 Lt(e){if(e===".")return"root";let t=as("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Xr(e,t){let n=Ft(e),r={};for(let i of t)r[i]=ls(n,i);return r}function Yr(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 us(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 ls(e,t){let n=t==="."?e:je(e,t),r=ds(n),i=ps(n),o=i?gs(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 ds(e){let t=je(e,"package.json");if(!wt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=At(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 ps(e){let t=je(e,"tsconfig.json");if(wt(t))return t;let n;try{n=ss(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 gs(e,t){let n=At(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=fs(n.value,e,t),i=Kr(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function fs(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=_t(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=Qr(s,i,n);c&&o.add(c)}return[...o]}function Kr(e,t,n,r){let i=ms(t);if(i)return{pathsTargets:hs(i,_t(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=ys(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=At(o);return a.ok?Kr(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function ms(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 hs(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=Qr(o,t,n);a&&r.add(a)}return[...r]}function ys(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=Ft(_t(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(qr).includes("node_modules")&&nt(n,i)&&wt(i))return i}function Qr(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Ft(t,r===""?".":r);if(!nt(n,i))return;let a=cs(n,i).split(qr).join("/");return a===""?".":a}function bs(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 At(e){try{let t=_(e,{maxBytes:Q,inputKind:"TypeScript project manifest"}),n=JSON.parse(bs(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{writeFileSync as Os}from"fs";import{deserializeSCIP as Ns,PositionEncoding as Me,serializeSCIP as Cs}from"@c4312/scip";import{rmSync as Rs}from"fs";import xs from"better-sqlite3";var Ps=200,vs=[`CREATE TABLE documents (
|
|
239
|
+
id INTEGER PRIMARY KEY,
|
|
240
|
+
language TEXT,
|
|
241
|
+
relative_path TEXT NOT NULL UNIQUE,
|
|
242
|
+
position_encoding TEXT,
|
|
243
|
+
text TEXT
|
|
244
|
+
)`,`CREATE TABLE chunks (
|
|
245
|
+
id INTEGER PRIMARY KEY,
|
|
246
|
+
document_id INTEGER NOT NULL,
|
|
247
|
+
chunk_index INTEGER NOT NULL,
|
|
248
|
+
start_line INTEGER NOT NULL,
|
|
249
|
+
end_line INTEGER NOT NULL,
|
|
250
|
+
occurrences BLOB NOT NULL,
|
|
251
|
+
FOREIGN KEY (document_id) REFERENCES documents(id)
|
|
252
|
+
)`,`CREATE TABLE global_symbols (
|
|
253
|
+
id INTEGER PRIMARY KEY,
|
|
254
|
+
symbol TEXT NOT NULL UNIQUE,
|
|
255
|
+
display_name TEXT,
|
|
256
|
+
kind INTEGER,
|
|
257
|
+
documentation TEXT,
|
|
258
|
+
signature BLOB,
|
|
259
|
+
enclosing_symbol TEXT,
|
|
260
|
+
relationships BLOB
|
|
261
|
+
)`,`CREATE TABLE mentions (
|
|
262
|
+
chunk_id INTEGER NOT NULL,
|
|
263
|
+
symbol_id INTEGER NOT NULL,
|
|
264
|
+
role INTEGER NOT NULL,
|
|
265
|
+
PRIMARY KEY (chunk_id, symbol_id, role),
|
|
266
|
+
FOREIGN KEY (chunk_id) REFERENCES chunks(id),
|
|
267
|
+
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
268
|
+
)`,`CREATE TABLE defn_enclosing_ranges (
|
|
269
|
+
id INTEGER PRIMARY KEY,
|
|
270
|
+
document_id INTEGER NOT NULL,
|
|
271
|
+
symbol_id INTEGER NOT NULL,
|
|
272
|
+
start_line INTEGER NOT NULL,
|
|
273
|
+
start_char INTEGER NOT NULL,
|
|
274
|
+
end_line INTEGER NOT NULL,
|
|
275
|
+
end_char INTEGER NOT NULL,
|
|
276
|
+
FOREIGN KEY (document_id) REFERENCES documents(id),
|
|
277
|
+
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
278
|
+
)`],Is=["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 ei(e,t){Rs(e,{force:!0});let n=new xs(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 vs)n.exec(r);n.transaction(()=>Es(n,t)).immediate(),n.transaction(()=>{for(let r of Is)n.exec(r)}).immediate()}finally{n.close()}}function Es(e,t){let n=ks(e);for(let r of Ts(e,n,t))ws(e,n,r),_s(e,n,r)}function ks(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 Ts(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 Fs(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:Ls(a.occurrences)})}return i}function ws(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]=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}`:""}`)}Sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw cn(r,"Reindex cancelled by its owner.");let l=u instanceof Error?u.message:String(u),d=`${e.resolvedBinary} indexer failed: ${l.split(`
|
|
282
|
+
`)[0]}`,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:Ic(u)}}finally{xc(i),bc(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=fc(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 vc(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):tr.indexer}function Ic(e){return e instanceof nr?e.kind==="spawn"&&mi(e.cause):mi(e)}function mi(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as bi}from"child_process";import{homedir as yi,platform as Ec}from"os";import{delimiter as kc,join as Ge}from"path";function Si(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(!Bn(i.prerequisite))continue;let o=Tc(i);t(`Installing immutable ${i.identity} via ${i.label} into ${o}; expected executable: ${r}.`);try{bi(i.binary,i.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:Ec()==="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 Tc(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(kc)[0],"bin")}return e.binary==="dotnet"?Ge(process.env.DOTNET_CLI_HOME??yi(),".dotnet","tools"):e.binary==="dart"?Ge(process.env.PUB_CACHE??Ge(yi(),".pub-cache"),"bin"):e.destination}function $t(e,t){try{return bi(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}import Ru from"better-sqlite3";import{existsSync as xu}from"fs";import{dirname as Pu,join as vu,resolve as Iu}from"path";import{randomUUID as _c}from"crypto";import{mkdtempSync as Fc,rmSync as Lc,statSync as xi}from"fs";import{tmpdir as Ac}from"os";import{join as Pi}from"path";import{Worker as Dc}from"worker_threads";function wc(){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:wc(),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 Oc=3e5,vi=64*1024*1024,Nc={createResultDirectory:()=>Fc(Pi(Ac(),"codebaseiq-vue-workers-")),spawn:(e,t)=>new Dc(e,{workerData:t}),resultSize:e=>xi(e).size,readResult:e=>_(e,{maxBytes:vi,inputKind:"Vue worker result"}),removeResultDirectory:e=>Lc(e,{recursive:!0,force:!0})};function Ii(e){return e.length>=8&&ki(e.length)>1}async function Ei(e,t=Nc){let n=ki(e.vueFiles.length),r=zc(e.vueFiles),i=Yc(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??Jc(),s=e.maxResultBytes??Hc();Ri("timeoutMs",a),Ri("maxResultBytes",s);let c=_c(),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=Pi(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:Cc(v,I)})}await jc(l,a);let f=l.sort((m,I)=>m.workerId-I.workerId).map(m=>Vc(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 Mc(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: ${qc(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 Cc(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 jc(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 Mc(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function Vc(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(!Gc(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||!$c(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function $c(e){if(!ge(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(Bc)||!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(Uc)}function Bc(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 Uc(e){return ge(e)&&typeof e.sourceFile=="string"&&N(e.sourceLine)&&N(e.sourceStartChar)&&N(e.sourceEndChar)&&typeof e.token=="string"&&Wc(e.reason)}function Wc(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 Gc(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function Ri(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function qc(e){return e instanceof Error?e.message:String(e)}function ki(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 Jc(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:Oc}function Hc(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:vi}function zc(e){let t=Xc(),n=[];for(let r of e){let i=Ti(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 Xc(){return Number.POSITIVE_INFINITY}function Yc(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Kc(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 Kc(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Ti(e.fileName)-e.startOffset)}function Ti(e){try{return xi(e).size}catch{return 1}}import{createRequire as Qc}from"module";import{existsSync as Zc}from"fs";import{dirname as wi,extname as eu,join as _i,relative as tu,resolve as nu}from"path";import{pathToFileURL as ru}from"url";function iu(e){e.transaction(()=>{e.prepare(`
|
|
283
|
+
DELETE FROM mentions
|
|
284
|
+
WHERE chunk_id IN (
|
|
285
|
+
SELECT c.id
|
|
286
|
+
FROM chunks c
|
|
287
|
+
JOIN documents d ON d.id = c.document_id
|
|
288
|
+
WHERE d.language = 'vue' OR d.relative_path LIKE '%.vue'
|
|
289
|
+
)
|
|
290
|
+
`).run(),e.prepare(`
|
|
291
|
+
DELETE FROM chunks
|
|
292
|
+
WHERE document_id IN (
|
|
293
|
+
SELECT id
|
|
294
|
+
FROM documents
|
|
295
|
+
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
296
|
+
)
|
|
297
|
+
`).run()})()}function Fi(e,t){return e.prepare(`
|
|
298
|
+
SELECT relative_path AS relativePath
|
|
299
|
+
FROM documents
|
|
300
|
+
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
301
|
+
ORDER BY relative_path
|
|
302
|
+
`).all().map(r=>nu(t,r.relativePath))}function Li(e,t){let{vueCore:n,ts:r,volarTs:i}=ou(e),{parsed:o,vueOptions:a}=au(n,r,t),s=wi(t),c=n.createVueLanguagePlugin(r,o.options,a,g=>g),u=su(n,r,c),l=cu(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 ou(e){let t=Qc(ru(_i(e,"package.json")).href);return{vueCore:Bt(t,"@vue/language-core",e),ts:Bt(t,"typescript",e),volarTs:Bt(t,"@volar/typescript",e)}}function au(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,wi(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function su(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Zc(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)??fu(o))});return r.current=i,i}function cu(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function Bt(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 Ai(e,t,n){let r=uu(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:lu(c.starts,s.line,2,i.name)}}function uu(e){let t=e.prepare(`
|
|
303
|
+
SELECT
|
|
304
|
+
d.relative_path AS relativePath,
|
|
305
|
+
der.start_line AS startLine,
|
|
306
|
+
der.end_line AS endLine,
|
|
307
|
+
der.symbol_id AS symbolId,
|
|
308
|
+
gs.display_name AS displayName
|
|
309
|
+
FROM defn_enclosing_ranges der
|
|
310
|
+
JOIN documents d ON d.id = der.document_id
|
|
311
|
+
JOIN global_symbols gs ON gs.id = der.symbol_id
|
|
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 lu(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 Di(e,t,n){let r=yu(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
|
|
314
|
+
INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
|
|
315
|
+
VALUES (?, ?, ?, ?)
|
|
316
|
+
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let l=C(t,u),d=Ui(r.name,r.version,l);o.run(d,"default",7,`Vue component|${l}`);let p=bu(i,r,t,u);p&&(a++,s.set(u,p))}})(),{get(u){return s.get(u)??null},syntheticSymbols:a}}function Oi(e,t,n,r,i){return e.transaction(()=>(iu(e),du(e,t,n,r),pu(e,i)))()}function du(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
|
|
317
|
+
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
318
|
+
VALUES (?, ?, ?, ?, X'00')
|
|
319
|
+
`),a=e.prepare(`
|
|
320
|
+
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
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 Ni(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(Ut(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function Ci(e){let t=new Set,n=[];for(let r of e){let i=ji(r);t.has(i)||(t.add(i),n.push(r))}return n}function ji(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function pu(e,t){let n=hu(e,[...new Set(t.map(c=>c.sourceFile))]),r=e.prepare(`
|
|
323
|
+
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
324
|
+
VALUES (?, ?, ?, ?, X'00')
|
|
325
|
+
`),i=e.prepare(`
|
|
326
|
+
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
327
|
+
VALUES (?, ?, 0)
|
|
328
|
+
`),o=new Set,a=0,s=0;for(let c of t){let u=ji(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*Mi(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 Vi(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Ut(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function gu(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 $i(e,t){return C(e,t).startsWith("node_modules/")}function C(e,t){return tu(e,t).replaceAll("\\","/")}function fu(e){switch(eu(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 Bi(){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:mu(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:gu}}function mu(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function hu(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 yu(e){try{let t=JSON.parse(_(_i(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 bu(e,t,n,r){let i=C(n,r),o=Ui(t.name,t.version,i);return e.get(o)?.id??null}function Ui(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function Eu(e){return z(H(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),ku(e)}async function ku(e){let t=Iu(e.projectRoot,e.tsconfig);if(!xu(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new Ru(F(e.dbPath));try{let r=Fi(n,e.projectRoot),i=vu(Pu(e.dbPath),"augment-vue-meta.json");return await Mr({cachePath:i,readFingerprint:()=>Fu(n,e.projectRoot,e.tsconfig),compute:()=>Tu({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 Tu(e){let t=Di(e.db,e.projectRoot,e.vueFiles),n=Ii(e.vueFiles)?await Ei({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):_u(e,t);return wu(e,t,n)}function wu(e,t,n){let r=Ci(n.occurrences),i=Oi(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:Vu(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:Mu(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function _u(e,t){let n=Lu({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return Au({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function Fu(e,t,n){let r=e.prepare(`
|
|
329
|
+
SELECT
|
|
330
|
+
(SELECT COUNT(*) FROM documents) AS documents,
|
|
331
|
+
(SELECT COUNT(*) FROM global_symbols) AS symbols,
|
|
332
|
+
(SELECT COUNT(*) FROM chunks) AS chunks,
|
|
333
|
+
(SELECT COUNT(*) FROM mentions) AS mentions,
|
|
334
|
+
(SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
|
|
335
|
+
(SELECT MAX(id) FROM chunks) AS maxChunkId,
|
|
336
|
+
(SELECT MAX(id) FROM global_symbols) AS maxSymbolId
|
|
337
|
+
`).get();return{version:3,tsconfig:n,files:Pe(t),db:r}}function Lu(e){let t=Bi();return{projectRoot:e.projectRoot,context:Li(e.projectRoot,e.configPath),symbolLookup:Ai(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function Au(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=Du(e,i);t.push(...o.occurrences),qe(n,o)}return{occurrences:t,...n}}function Du(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return Wi(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 Wi(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=C(e.projectRoot,t.fileName),s=[...Mi(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:Bu(s),processedStarts:new Set};return Ou({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function Ou(e){let t=[],n=oe();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||Nu(e.sourceInfo.text,r.start))continue;let i=Vi(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(l=>!$i(e.projectRoot,l.fileName));if(!a){Wt(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=C(e.projectRoot,a.fileName),c=Cu(e.sourceFile,r.text,s);if(c){Wt(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,c);continue}let u=Ni(a,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(u===null){Wt(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}Gi(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,u),e.tokenContext.processedStarts.add(r.start),$u(t,e,r,i,s,u)}return{occurrences:t,...n}}function Nu(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 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(`
|
|
339
|
+
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
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
|
+
`+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
342
|
+
`))}function zi(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=An(e.map(o=>o.scipPath),t);return ao(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&eo(e[0].scipPath,t);return!1}async function bl(e){let t;if(Sl(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();Xi(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=Dr({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 Xi(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 Sl(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 Rl(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:St(e.plan,o,e.projectFileCount)}}function Xi(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{ao(ri(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 ao(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=Ju(e)||".scip",i=Je(e,r);return k(y(e),`${i}.${n+1}.${t}${r}`)}async function xl(e,t){for(let n=0;n<2;n++){let r=Pl(e,t);if(r)return r;let i=vl(e);if(i&&uo(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await El(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: ${$(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(!un(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 Pl(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=so(r.reclaimed,e);i&&uo(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 vl(e){return so(st(e,{parseLegacy:ze}),e)}var ze=e=>{let t=co(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function so(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 co(e.parsed,t)}function co(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=en(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 uo(e,t){return e?.kind==="manual-cli"&&Il(t?.trigger)}function Il(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function El(e){return!K(e.pid)||(Jt(e),Yi(e,"SIGTERM"),await Ki(e,2e3))?!0:(Jt(e),Yi(e,"SIGKILL"),Ki(e,1e3))}function Yi(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!K(e.pid))return;Jt(e)}try{process.kill(e.pid,t)}catch{}}async function Ki(e,t){let n=R()+t;for(;R()<n;){if(Qi(e))return!0;await kl(50)}return Qi(e)}function Jt(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 Qi(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 kl(e){return new Promise(t=>setTimeout(t,e))}function lo(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?fn(n.typescriptProjects):[],o=r==="clojure"?Tl(n.clojureConfigPath):void 0,a=[...xt(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"&&wl(n),...s,clojureConfigPath:o,files:Pe(e,{language:r,markerFiles:a})}]}))}function Tl(e){return e?.trim()||void 0}function wl(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Xt(e,t){return k(y(e),"language-indexes",`${t}.scip`)}function po(e){return k(y(e),"language-indexes","typescript-projects")}function Xe(e,t){return k(po(e),`${Lt(t)}.scip`)}function se(e){try{return it(ee(L(e,"reindex metadata")))}catch{return null}}function go(e,t){try{let n=ee(L(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 Yt(e,t){pn(e,t,{spacing:2,trailingNewline:!0})}function fo(e,t){try{let n=it(ee(L(e,"reindex metadata")));if(!n)return;Yt(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 Uf(e,t,n,r){return to({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}:{}})}export{sr as a,pd as b,gd as c,xt as d,Wa as e,$d as f,Bd as g,Si as h,Eu as i,to as j,Uf as k};
|
|
343
|
+
//# sourceMappingURL=chunk-MC46AL7B.js.map
|