codebaseiq 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-DQMDCD24.js → chunk-27PHVDKL.js} +2 -2
- package/dist/{chunk-ZMI2JSX2.js → chunk-2DMVFAY7.js} +2 -2
- package/dist/{chunk-5PUWMSDU.js → chunk-2E6BTWER.js} +2 -2
- package/dist/{chunk-YESXMKX3.js → chunk-2F5ERMNI.js} +2 -2
- package/dist/chunk-2VKB5CMA.js +60 -0
- package/dist/{chunk-NNJ2KZZG.js → chunk-327YK6TB.js} +4 -4
- package/dist/chunk-347TXATM.js +2 -0
- package/dist/{chunk-VEXUL62T.js → chunk-35YYZD3D.js} +2 -2
- package/dist/chunk-36WRYYTE.js +3 -0
- package/dist/chunk-37TKC6MB.js +2 -0
- package/dist/{chunk-FAJQ7LWY.js → chunk-3AC56WAR.js} +2 -2
- package/dist/{chunk-JE3WZ6II.js → chunk-3NUZVLR7.js} +2 -2
- package/dist/{chunk-UZGZB3VB.js → chunk-3XFJUWJE.js} +2 -2
- package/dist/{chunk-OVTS4DKB.js → chunk-4AOOSCZ7.js} +2 -2
- package/dist/{chunk-LU3BMVH2.js → chunk-4IFISPQW.js} +2 -2
- package/dist/chunk-4NHWNAWQ.js +11 -0
- package/dist/chunk-4O52YNKL.js +5 -0
- package/dist/{chunk-HPJRBHVT.js → chunk-54K6556S.js} +2 -2
- package/dist/{chunk-HRWGYWRJ.js → chunk-57GCCPLS.js} +2 -2
- package/dist/{chunk-J77SU6VA.js → chunk-57KEZDPT.js} +2 -2
- package/dist/{chunk-OFBE4NGP.js → chunk-57KFVPVZ.js} +2 -2
- package/dist/{chunk-WOQBZPIF.js → chunk-5BDK6QC3.js} +2 -2
- package/dist/{chunk-7MGU3HPH.js → chunk-5IO2APSS.js} +2 -2
- package/dist/chunk-5NJPH3QZ.js +61 -0
- package/dist/{chunk-GW6Z3WGY.js → chunk-5WXOEJ4G.js} +2 -2
- package/dist/chunk-5XEVXVTK.js +3 -0
- package/dist/{chunk-RR7SX44N.js → chunk-6OVNYYY4.js} +2 -2
- package/dist/{chunk-ZV3JV5G5.js → chunk-6SDEQTVY.js} +2 -2
- package/dist/{chunk-EF2R3WNQ.js → chunk-6URCE5QY.js} +2 -2
- package/dist/{chunk-UCD3H3UZ.js → chunk-6ZV5EDUT.js} +2 -2
- package/dist/{chunk-C6SBF2WH.js → chunk-77GHPR2R.js} +2 -2
- package/dist/{chunk-YVCIMIOC.js → chunk-7R64XY4Y.js} +2 -2
- package/dist/{chunk-VXYS3FZD.js → chunk-7Z7HCZ7J.js} +2 -2
- package/dist/{chunk-CO5R3UNA.js → chunk-A67HT5FR.js} +2 -2
- package/dist/{chunk-UDS562V4.js → chunk-A7XQT7MH.js} +2 -2
- package/dist/{chunk-RDBI2RXU.js → chunk-ACZDU5GK.js} +2 -2
- package/dist/{chunk-FETNQCFO.js → chunk-AM5SUGHF.js} +2 -2
- package/dist/{chunk-NNOKTMZT.js → chunk-B2E3HZ2A.js} +2 -2
- package/dist/{chunk-CVYSU6BX.js → chunk-BH5CE4LN.js} +2 -2
- package/dist/chunk-BLKYYQ7C.js +543 -0
- package/dist/{chunk-4WKDMDEW.js → chunk-BX2U3QQV.js} +2 -2
- package/dist/{chunk-ZKX2FRS6.js → chunk-CANBLFVQ.js} +2 -2
- package/dist/{chunk-SMRBZ6EC.js → chunk-CCRZLRWJ.js} +2 -2
- package/dist/chunk-CDWSLAPN.js +21 -0
- package/dist/chunk-CIVYHK7U.js +22 -0
- package/dist/{chunk-L57ZKWVG.js → chunk-CMXW7MFV.js} +2 -2
- package/dist/{chunk-T3DGWPXM.js → chunk-CSZOQ7YO.js} +2 -2
- package/dist/{chunk-ZZXSWSN6.js → chunk-CWMHWD56.js} +2 -2
- package/dist/{chunk-6NW7MU72.js → chunk-CZEIHYMP.js} +2 -2
- package/dist/{chunk-DO6WQD2T.js → chunk-D62CTZX6.js} +2 -2
- package/dist/{chunk-XWUOUWYI.js → chunk-DFPAZXLU.js} +2 -2
- package/dist/{chunk-MOVBWNIP.js → chunk-DKJXK3HA.js} +2 -2
- package/dist/{chunk-XMQ23E27.js → chunk-DLC6JDN7.js} +2 -2
- package/dist/chunk-DUKHVPU5.js +4 -0
- package/dist/{chunk-ID63777H.js → chunk-DVYG3JTA.js} +2 -2
- package/dist/{chunk-NE6IU5ZD.js → chunk-EFFMFK7C.js} +2 -2
- package/dist/{chunk-I2T2LLK2.js → chunk-EM5UHLAM.js} +2 -2
- package/dist/chunk-EN4AHLL3.js +3 -0
- package/dist/chunk-EXMVF3JR.js +3 -0
- package/dist/{chunk-SWHMHUKF.js → chunk-FEBLLMTL.js} +2 -2
- package/dist/chunk-FIXYHQ3W.js +3 -0
- package/dist/{chunk-RKEJ6VTF.js → chunk-FLLXYUOL.js} +2 -2
- package/dist/{chunk-KWVHSKHK.js → chunk-FPDL2TUB.js} +2 -2
- package/dist/chunk-FQA3KIFX.js +17 -0
- package/dist/chunk-FWY2PRIF.js +3 -0
- package/dist/chunk-FY5V4V4F.js +2 -0
- package/dist/chunk-G2XUZCF2.js +88 -0
- package/dist/{chunk-QHRNXP3C.js → chunk-GXVDTHFC.js} +2 -2
- package/dist/{chunk-6MUIJMVL.js → chunk-H3CKAL6P.js} +2 -2
- package/dist/chunk-H5QXP63L.js +2 -0
- package/dist/{chunk-VUIYB2V3.js → chunk-HBQGKMM3.js} +2 -2
- package/dist/{chunk-PYAB5SM6.js → chunk-HBXZAGY6.js} +2 -2
- package/dist/{chunk-NNO6A2PO.js → chunk-HCMQZPEO.js} +2 -2
- package/dist/{chunk-Q65CQ4XL.js → chunk-HHBBGWES.js} +2 -2
- package/dist/{chunk-GTXSJDCO.js → chunk-HIEXRDJF.js} +2 -2
- package/dist/{chunk-4FC325IF.js → chunk-HYKSLTAR.js} +2 -2
- package/dist/{chunk-XLQ3GLWZ.js → chunk-I2KP4AGR.js} +2 -2
- package/dist/chunk-I5FCDTK2.js +2 -0
- package/dist/{chunk-QKPLA6IC.js → chunk-I645ZF75.js} +2 -2
- package/dist/{chunk-FDGD5AB5.js → chunk-IBM3F2BJ.js} +2 -2
- package/dist/{chunk-Q72QSKXC.js → chunk-IEL6Q5W3.js} +38 -38
- package/dist/{chunk-NCZUNH3E.js → chunk-IGQQUENU.js} +12 -12
- package/dist/chunk-IGYAZPRX.js +4 -0
- package/dist/chunk-IOVPAZWP.js +3 -0
- package/dist/{chunk-OL6KJP3N.js → chunk-IVJJNVSX.js} +2 -2
- package/dist/{chunk-AKB7V7TV.js → chunk-IWAMYGPN.js} +2 -2
- package/dist/chunk-IYBIBMPF.js +90 -0
- package/dist/{chunk-IOP6FWIM.js → chunk-J24VICI5.js} +2 -2
- package/dist/{chunk-C7QOQX32.js → chunk-JN5LIBT3.js} +2 -2
- package/dist/{chunk-O6QTXQPJ.js → chunk-JOALNFY3.js} +2 -2
- package/dist/{chunk-GCHRX4YW.js → chunk-JUO3Z644.js} +2 -2
- package/dist/{chunk-BJ6SQAEN.js → chunk-JXHLB7TP.js} +2 -2
- package/dist/{chunk-IJ4HMYBE.js → chunk-JYX5UZSZ.js} +2 -2
- package/dist/chunk-K2O7SBAU.js +2 -0
- package/dist/{chunk-OLF4MA5W.js → chunk-K5G7SPAG.js} +2 -2
- package/dist/{chunk-YSNONTJ2.js → chunk-KDYQQJ6X.js} +2 -2
- package/dist/{chunk-7NVGT435.js → chunk-KM4QRWI5.js} +2 -2
- package/dist/{chunk-HKQUXIFO.js → chunk-KNV5VFDV.js} +2 -2
- package/dist/chunk-L3YSDLNB.js +2 -0
- package/dist/{chunk-EZNMUY67.js → chunk-LAGDJXFY.js} +2 -2
- package/dist/{chunk-ENCCHKM6.js → chunk-LY2NB5XR.js} +4 -4
- package/dist/chunk-M4EVGA5S.js +14 -0
- package/dist/chunk-M7LAIM77.js +127 -0
- package/dist/{chunk-BVAJLC5A.js → chunk-MRGTCMDK.js} +2 -2
- package/dist/{chunk-OZYRSMSH.js → chunk-MT5W4DUG.js} +2 -2
- package/dist/{chunk-VE5AVNMP.js → chunk-MTMF4N7F.js} +2 -2
- package/dist/chunk-N3Q3AWGW.js +545 -0
- package/dist/{chunk-TXXOEMZJ.js → chunk-NDGTJHQN.js} +2 -2
- package/dist/chunk-NIO346UL.js +2 -0
- package/dist/chunk-NJA4MMBD.js +2 -0
- package/dist/{chunk-7FND7D7N.js → chunk-NK76RSB6.js} +2 -2
- package/dist/{chunk-H3LGFZVK.js → chunk-NTRW52UR.js} +2 -2
- package/dist/{chunk-JOIRNPPY.js → chunk-OJFLPVBP.js} +2 -2
- package/dist/{chunk-KMITESMT.js → chunk-OMBRP7BB.js} +2 -2
- package/dist/{chunk-UP3BUZR5.js → chunk-OVKZM2XI.js} +2 -2
- package/dist/{chunk-MVB3DAEY.js → chunk-PARCKE3Q.js} +2 -2
- package/dist/{chunk-CAUCPUOF.js → chunk-PFPHS4NO.js} +2 -2
- package/dist/chunk-PHPQ24UG.js +22 -0
- package/dist/chunk-PLZXWZHY.js +77 -0
- package/dist/{chunk-34WBMAYK.js → chunk-PNVZIJ57.js} +2 -2
- package/dist/{chunk-SYDJMPES.js → chunk-QKVTWODE.js} +2 -2
- package/dist/{chunk-FW53T7EB.js → chunk-QLTFXVUI.js} +2 -2
- package/dist/{chunk-PBI2LFKH.js → chunk-QMGWSEPL.js} +2 -2
- package/dist/{chunk-CQP3THUZ.js → chunk-QVHZB75Z.js} +2 -2
- package/dist/{chunk-6BQ3DSPK.js → chunk-QVWDQTMG.js} +2 -2
- package/dist/{chunk-ST7V3SKN.js → chunk-RCPZOPV6.js} +2 -2
- package/dist/chunk-RJWAB4VR.js +345 -0
- package/dist/chunk-RRPK327J.js +20 -0
- package/dist/chunk-RVYLJDXC.js +21 -0
- package/dist/chunk-RWKEXCHU.js +3 -0
- package/dist/{chunk-L4NRUAGJ.js → chunk-S5SKXCND.js} +2 -2
- package/dist/{chunk-RBAS5ZHI.js → chunk-S64NCE2Z.js} +2 -2
- package/dist/{chunk-WMPRTGH2.js → chunk-SF34QLK2.js} +2 -2
- package/dist/{chunk-ANFVSJWQ.js → chunk-SJZQ2PTZ.js} +2 -2
- package/dist/{chunk-4XTAUQFD.js → chunk-SRY26ITJ.js} +2 -2
- package/dist/chunk-SV2LEFVM.js +2 -0
- package/dist/{chunk-7XAN6GKB.js → chunk-T3YFIJ5P.js} +2 -2
- package/dist/chunk-T55YPJGB.js +3 -0
- package/dist/chunk-TAJ6UGCO.js +21 -0
- package/dist/{chunk-PIOMTC27.js → chunk-TUTSO7UZ.js} +2 -2
- package/dist/{chunk-FQKZWM4L.js → chunk-U24M5RQM.js} +5 -5
- package/dist/{chunk-XME3HPXZ.js → chunk-U2XX3BT4.js} +2 -2
- package/dist/{chunk-SZD2KF7Q.js → chunk-UWB5WMC2.js} +2 -2
- package/dist/{chunk-6CS3UQTN.js → chunk-VCL7FK3E.js} +2 -2
- package/dist/{chunk-N3IQCBCF.js → chunk-VCWAJPXQ.js} +2 -2
- package/dist/{chunk-LZYFLFEH.js → chunk-VG55NFXF.js} +2 -2
- package/dist/{chunk-PTAWHLVJ.js → chunk-VLTUX4IF.js} +2 -2
- package/dist/{chunk-JEJLSICM.js → chunk-VVCBMH5O.js} +2 -2
- package/dist/{chunk-JSOYNVWH.js → chunk-VYZQZ4ZN.js} +2 -2
- package/dist/chunk-W3FK73MD.js +8 -0
- package/dist/{chunk-UNBY47BC.js → chunk-W6C6QTXJ.js} +2 -2
- package/dist/chunk-WH5SYOMD.js +2 -0
- package/dist/chunk-WJOQC4P7.js +7 -0
- package/dist/chunk-WO47BIPY.js +3 -0
- package/dist/chunk-WOOTEWQT.js +239 -0
- package/dist/{chunk-UBGWN7I4.js → chunk-X5I2BQGX.js} +2 -2
- package/dist/{chunk-PX4RYAAK.js → chunk-XNUWRTYM.js} +2 -2
- package/dist/{chunk-ICFDQHAM.js → chunk-XUJM6474.js} +2 -2
- package/dist/chunk-XYLV727H.js +21 -0
- package/dist/{chunk-TRRC4ZJ7.js → chunk-YFQPWKHR.js} +2 -2
- package/dist/{chunk-NEDP5RFQ.js → chunk-YIOQJ45A.js} +2 -2
- package/dist/{chunk-Y6KHROC3.js → chunk-YXJ4IAHH.js} +2 -2
- package/dist/chunk-YYFV32WR.js +3 -0
- package/dist/{chunk-BH5F2Q4O.js → chunk-ZB3V5QM7.js} +2 -2
- package/dist/chunk-ZJZQ7Q2Q.js +3 -0
- package/dist/{chunk-EMNIHCRB.js → chunk-ZNQCR656.js} +2 -2
- package/dist/{chunk-TIIC3ZE7.js → chunk-ZOEDRCR4.js} +2 -2
- package/dist/cli-context-TSADTXLB.js +2 -0
- package/dist/cli-context-XEPPF4RX.js +3 -0
- package/dist/cli-program-KJGQEM72.js +7 -0
- package/dist/cli.js +1 -1
- package/dist/{code-DlqpBDd0.d.ts → code-CDe-mIjx.d.ts} +1 -1
- package/dist/code-viewer-YGDON6SY.js +12 -0
- package/dist/code-viewer-ZCTHXQ5C.js +11 -0
- package/dist/command-descriptors-5VAB2MZX.js +335 -0
- package/dist/command-descriptors-EAHKIRAG.js +337 -0
- package/dist/{config-types-BNoC96J3.d.ts → config-types-D6X5S68_.d.ts} +50 -0
- package/dist/{db-D7sauVFH.d.ts → db-DmRNdCtm.d.ts} +1 -1
- package/dist/direct-navigation-B3SGOOBW.js +2 -0
- package/dist/direct-navigation-ZL362KXF.js +3 -0
- package/dist/{graph-evidence-BIFqyisO.d.ts → graph-evidence-Bs54NWws.d.ts} +1 -1
- package/dist/{health-DJaZXg8I.d.ts → health-BnzbSLCE.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-CSUGUHTT.js +2 -0
- package/dist/invocation-command-descriptors-PPVZOIE5.js +3 -0
- package/dist/output-continuation-command-FTVVBVSN.js +2 -0
- package/dist/output-continuation-command-ITPRC3YV.js +3 -0
- package/dist/project-reindex-7HZSLLLY.js +3 -0
- package/dist/project-reindex-NGM3DYBN.js +2 -0
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +2 -2
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.d.ts +2 -2
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +3 -3
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +2 -2
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.d.ts +3 -3
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +2 -2
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +2 -2
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +3 -3
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +5 -5
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.d.ts +2 -2
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.d.ts +2 -2
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.d.ts +4 -4
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +2 -2
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +2 -2
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.d.ts +3 -3
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.d.ts +3 -3
- package/dist/reindex.js +31 -31
- package/dist/runtime.d.ts +24 -4
- 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/{scip-cli-B7N3haxa.d.ts → scip-cli-BRFKkHQn.d.ts} +1 -1
- package/dist/sentinel-ensure-command-KYYULCFU.js +2 -0
- package/dist/sentinel-ensure-command-RIZA3RY7.js +3 -0
- package/dist/sentinel-hook.js +39 -0
- package/dist/sentinel-worker.js +16 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +6 -6
- package/docs/COMMAND_REFERENCE.md +5 -3
- package/docs/schemas/project-config.schema.json +159 -0
- package/package.json +9 -5
- package/skills/codebaseiq/SKILL.md +1 -1
- package/skills/concrete-plan/SKILL.md +1 -1
- package/ui/view/api.js +450 -0
- package/ui/view/app.js +394 -0
- package/ui/view/builder.js +323 -0
- package/ui/view/file-panel.js +170 -0
- package/ui/view/focus.js +379 -0
- package/ui/view/index.html +54 -0
- package/ui/view/map.js +424 -0
- package/ui/view/styles.css +1125 -0
- package/dist/chunk-2X7V4HS4.js +0 -88
- package/dist/chunk-3IER7Q6H.js +0 -12
- package/dist/chunk-3JSXXYTZ.js +0 -345
- package/dist/chunk-476NR5B7.js +0 -2
- package/dist/chunk-5VKBFZZU.js +0 -3
- package/dist/chunk-ADTBPVUZ.js +0 -21
- package/dist/chunk-BFFZDZQV.js +0 -2
- package/dist/chunk-BMYOV5GP.js +0 -77
- package/dist/chunk-C74PPYLA.js +0 -3
- package/dist/chunk-CWONGW6P.js +0 -3
- package/dist/chunk-DDZ7VHWV.js +0 -20
- package/dist/chunk-DR2LURYU.js +0 -3
- package/dist/chunk-ECQBG7PW.js +0 -564
- package/dist/chunk-FM5BPL4V.js +0 -60
- package/dist/chunk-G6XFR4ZL.js +0 -4
- package/dist/chunk-GTIYTDRE.js +0 -562
- package/dist/chunk-HOA5YGOH.js +0 -3
- package/dist/chunk-KUW32IRO.js +0 -2
- package/dist/chunk-LTA3BRZX.js +0 -2
- package/dist/chunk-NAUD7LCA.js +0 -2
- package/dist/chunk-OGTFJ3XD.js +0 -2
- package/dist/chunk-Q5ELPRKQ.js +0 -2
- package/dist/chunk-QCN62RTF.js +0 -3
- package/dist/chunk-QW7EP6WI.js +0 -21
- package/dist/chunk-RU65DDUP.js +0 -215
- package/dist/chunk-SELM5MER.js +0 -2
- package/dist/chunk-SNNWPCN7.js +0 -4
- package/dist/chunk-TFZB6XTM.js +0 -239
- package/dist/chunk-UXM43C7T.js +0 -3
- package/dist/chunk-VFY6Y2H6.js +0 -61
- package/dist/chunk-WE5RZHZ7.js +0 -5
- package/dist/chunk-Z54RD7VL.js +0 -3
- package/dist/cli-context-3SNLDYBM.js +0 -3
- package/dist/cli-context-T3B7W6GG.js +0 -2
- package/dist/cli-program-YNOXO72B.js +0 -7
- package/dist/command-descriptors-6AOUKWW7.js +0 -346
- package/dist/command-descriptors-ZFKJSRUP.js +0 -344
- package/dist/direct-navigation-DP4LVMRX.js +0 -3
- package/dist/direct-navigation-FLUS3BT6.js +0 -2
- package/dist/invocation-command-descriptors-QT2JMY5J.js +0 -3
- package/dist/invocation-command-descriptors-YN4QJEAX.js +0 -2
- package/dist/output-continuation-command-2V2SL4TD.js +0 -2
- package/dist/output-continuation-command-65J5IP3O.js +0 -3
- package/dist/project-reindex-5JOKXAXT.js +0 -2
- package/dist/project-reindex-UQBIKO4M.js +0 -3
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
3
|
-
`),console.log("Or download that exact release manually:");else if(
|
|
2
|
+
import{a as sr}from"./chunk-EN4AHLL3.js";import{Fb as tr,Gb as nr,Hb as rr,Jb as ir,Kb as or,Lb as ar,Mb as _e,T as Gn,U as qn,ca as Fe,cb as ie,db as Jn,eb as Hn,fb as oe,gb as Ae,hb as ge,ib as zn,jb as Xn,k as Te,kb as Kn,lb as Yn,mb as Qn,qb as yt,vb as Zn,xb as er}from"./chunk-RJWAB4VR.js";import{d as sn,e as ot}from"./chunk-D62CTZX6.js";import{$ as Sn,$a as Ee,A as ln,Aa as U,B as ve,Ba as W,C as k,Ca as G,D as pe,E as ee,Ea as gt,F as ct,Fa as In,G as dn,Ga as ft,H as ut,Ha as mt,I as pn,Ia as kn,J as R,Ja as wn,Ka as En,L as gn,La as Tn,M as A,Ma as Fn,Na as An,O as Pe,Oa as _n,P as lt,Pa as Dn,Q as fn,Qa as Ln,Ra as On,S as mn,Sa as jn,Ta as Cn,U as te,Ua as Mn,Va as we,Wa as Nn,X as hn,Y as yn,Ya as ht,Za as $n,_ as L,_a as Bn,cb as Vn,db as Un,eb as Wn,ha as Ie,ia as ne,j as at,ka as re,ma as bn,pa as Rn,s as st,ta as ke,u as D,ua as xn,v as cn,va as dt,wa as vn,xa as Pn,ya as pt,z as un}from"./chunk-G2XUZCF2.js";import{C as an,D as it,F as V,d as Re,i as nn,j as Y,k as Q,l as et,m as tt,n as xe,o as nt,p as B,q as F,r as _,s as rn,w as on,x as de,y as Z,z as rt}from"./chunk-DUKHVPU5.js";import{createHash as Lu}from"crypto";import{existsSync as E,mkdirSync as Ke,readdirSync as no,renameSync as ro,rmSync as ue,statSync as Ou}from"fs";import{basename as Xe,dirname as y,extname as ju,join as w,resolve as zi}from"path";import{platform as Cu}from"os";import{execFileSync as cr}from"child_process";import{createRequire as bo}from"module";import{existsSync as Ro}from"fs";import{platform as fe,arch as ur}from"os";var me="v0.8.1",St="https://github.com/sourcegraph/scip",De=`github.com/sourcegraph/scip/cmd/scip@${me}`,lr=bo(import.meta.url),dr="CODEBASEIQ_SCIP_BIN";function xo(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let t=e.env[dr];if(t&&e.fileExists(t))return{source:"env",path:t};if(e.platform==="win32"){let n=e.resolveSidecar(e.arch);if(n&&e.fileExists(n))return{source:"sidecar",path:n}}return null}function vo(e){for(let t of e==="arm64"?["arm64","x64"]:[e])try{return lr.resolve(`codebaseiq-windows/scip-win32-${t}.exe`)}catch{}return null}function ae(e=process.env){let t=xo({platform:fe(),arch:ur(),env:e,isOnPath:ie,fileExists:Ro,resolveSidecar:vo});return t?.source==="path"?Hn("scip")??t.path:t?.path??null}function kl(){return ae()!==null}function Po(){let e=ae();if(!e)return null;try{return cr(e,["--version"],{stdio:"pipe",windowsHide:!0,timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function Io(){let e=fe(),t=ur(),n,r,i;switch(e){case"darwin":n="darwin",i="tar.gz";break;case"linux":n="linux",i="tar.gz";break;default:return null}switch(t){case"arm64":r="arm64";break;case"x64":r="amd64";break;default:return null}let o=`scip-${n}-${r}.${i}`;return{url:`${St}/releases/download/${me}/${o}`,filename:o}}function wl(){let e=Io();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),fe()==="darwin"||fe()==="linux")console.log("Install the reviewed version with Go:"),console.log(` go install ${De}
|
|
3
|
+
`),console.log("Or download that exact release manually:");else if(fe()==="win32"){let t=ko();console.log("On Windows the scip binary ships via the npm sidecar package codebaseiq-windows,"),console.log("installed automatically with codebaseiq. If it is missing:"),console.log(` npm install -g ${t}`),console.log(`Or set ${dr} to a local scip.exe path.
|
|
4
4
|
`),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
|
|
5
|
-
`:` ${
|
|
6
|
-
`),console.log("After installing, ensure `scip` is on your PATH and run `codebaseiq reindex`.")}function
|
|
7
|
-
VALUES (?, ?, NULL, ?)`),c=i.transaction(l=>{let d=0;for(let p of l){if(o.has(p))continue;let g=
|
|
8
|
-
`).filter(r=>r&&t.has(Le(r).toLowerCase())).sort()}catch{return null}}function
|
|
9
|
-
`),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return
|
|
10
|
-
`).filter(i=>i.length>0),partialTailBytes:e.length-n}}var
|
|
5
|
+
`:` ${St}/releases/tag/${me}
|
|
6
|
+
`),console.log("After installing, ensure `scip` is on your PATH and run `codebaseiq reindex`.")}function ko(){let t=lr("../../package.json").optionalDependencies?.["codebaseiq-windows"];if(!t||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(t))throw new Error("codebaseiq package metadata does not declare an exact Windows sidecar version.");return`codebaseiq-windows@${t}`}function pr(e){if(ie("go")){e(`Installing immutable ${De} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(cr("go",["install",De],{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env}),ie("scip")){let t=ae(),n=Po();if(t&&n&&n.includes(me))return e(`Successfully installed ${De}; resolved executable: ${t}; reported version: ${n}.`),!0;e(`go install completed, but the resolved scip executable did not report ${me} (executable: ${t??"unresolved"}; version: ${n??"unavailable"}).`)}}catch(t){let n=t instanceof Error?t.message:String(t);e(`go install failed: ${n}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${St}/releases`),!1}import{execFileSync as wo}from"child_process";import{constants as Eo,copyFileSync as gr,statSync as To}from"fs";import{platform as Fo}from"os";var Ao=Object.freeze({size:e=>To(e).size,clone:Do,copy:(e,t)=>gr(e,t)}),_o=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function q(e,t,n=Ao){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(i){if(!Oo(i))throw i}return n.copy(e,t),{method:"copy",bytes:r}}function Do(e,t){if(Fo()!=="darwin"){gr(e,t,Eo.COPYFILE_FICLONE_FORCE);return}try{wo("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"],windowsHide:!0})}catch(n){throw Lo(n)}}function Lo(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 Oo(e){let t=e?.code;return t!==void 0&&_o.has(t)}function fr(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function J(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import jo from"better-sqlite3";import{execFileSync as Co}from"child_process";import{existsSync as Mo,readdirSync as No}from"fs";import{extname as Le,join as $o}from"path";function H(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>mr({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function mr(e){let t=new Set((e.extensions??Gn).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!Mo(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=Sn(e.projectRoot),r=Bo(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new jo(D(e.dbPath));try{let o=Uo(i,r),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
|
|
7
|
+
VALUES (?, ?, NULL, ?)`),c=i.transaction(l=>{let d=0;for(let p of l){if(o.has(p))continue;let g=Rn(e.projectRoot,p,{inputKind:"auxiliary source file"}),f=a.run(Wo(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 Bo(e,t){let n=Vo(e,t);if(n)return n;let r=[],i=o=>{let a=o?$o(e,o):e,s;try{s=No(a,{withFileTypes:!0})}catch{return}for(let c of s){if(qn.has(c.name))continue;let u=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(u);continue}t.has(Le(c.name).toLowerCase())&&r.push(u)}};return i(""),r.sort()}function Vo(e,t){try{return Co("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}).split(`
|
|
8
|
+
`).filter(r=>r&&t.has(Le(r).toLowerCase())).sort()}catch{return null}}function Uo(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 Wo(e){return Le(e).toLowerCase()===".vue"?"vue":Le(e).replace(/^\./,"").toLowerCase()||"source"}import{dirname as Go,join as qo}from"path";function hr(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let i=new L({projectRoot:t,dbPath:n,indexPath:e.indexPath??qo(Go(n),"index.scip")}),o,a=!1,s=!1;try{let u=e.reuseExisting||e.affectedFiles?ir(i):null;e.reuseExisting&&u?.extractorVersion===tr?(o=u,a=!0):(o=nr(i,{...u?{previousGraph:u}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{}}),s=(o.coverage.filesReused??0)>0)}finally{i.close()}a||rr(n,o);let c={reused:a,incrementallyUpdated:s,observations:o.observations.length,links:o.links.length,frontiers:o.frontiers.length,filesScanned:o.coverage.filesScanned,errors:o.coverage.extractionErrors.length,phases:o.coverage.phases};return r?.(c.reused?`Reused ${c.observations} cached runtime-boundary observation(s) and ${c.links} link(s).`:c.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${c.filesScanned-(o.coverage.filesReused??0)} file(s) extracted, ${o.coverage.filesReused??0} reused) and rebuilt ${c.links} link(s).`:`Extracted ${c.observations} runtime-boundary observation(s), ${c.links} link(s), and ${c.frontiers} unresolved frontier(s).`),!a&&o.coverage.phases&&r?.(`Runtime-boundary phases: ${o.coverage.phases.map(u=>`${u.id} ${u.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as sa}from"crypto";import{existsSync as ca}from"fs";import{dirname as ua,join as vr}from"path";function bt(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 Oe(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=bt(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"),yr(r,i,a)):a.size>0?yr(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:Jo(r,t,i),reasons:[]}}function yr(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Jo(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 Ho,existsSync as zo,mkdirSync as Xo,renameSync as Ko,rmSync as Yo,statSync as Qo,truncateSync as Zo}from"fs";import{basename as ea,dirname as ta}from"path";var se=".previous",na=".rotation.lock",ra=2e3,Rt=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"},xt=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"},Sr=Object.freeze({monotonicNow:R,wait(e){Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)},tryAcquireLock(e,t){let n=Pe(e,{kind:"rotating-jsonl",detail:{target:ea(t)}});return n.kind==="acquired"?{kind:"acquired",lock:n.lock}:{kind:"contended"}},makeDirectory(e){Xo(e,{recursive:!0})},exists:zo,readBytes(e){return B(e,{maxBytes:xe,inputKind:"rotating JSONL segment"})},size(e){return Qo(e).size},truncate:Zo,remove(e){Yo(e,{force:!0})},rename:Ko,append:Ho});function je(e,t,n){let r=n.runtime??Sr,i=JSON.stringify(t);if(i===void 0)throw new TypeError("Rotating JSONL records must be JSON-serializable values.");let o=Buffer.from(`${i}
|
|
9
|
+
`),a=Math.max(1,Math.floor(n.maxSegmentBytes),o.length);return Rr(e,n.lockTimeoutMs,r,()=>{r.makeDirectory(ta(e));let s=ia(e,xe,r);n.onPhase?.("tail-repaired");let c=`${e}${n.previousSuffix??se}`,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 br(e,t={}){let n=t.runtime??Sr,r=oa(t.maxSegmentBytes);return Rr(e,t.lockTimeoutMs,n,()=>{let i=[],o=0,a=`${e}${t.previousSuffix??se}`;for(let s of[a,e]){if(!n.exists(s))continue;let c=aa(xr(s,r,n));i.push(...c.lines),o+=c.partialTailBytes}return{lines:i,ignoredPartialTailBytes:o}})}function Rr(e,t,n,r){let i=`${e}${na}`,o=Math.max(0,t??ra),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 Rt(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 xt(i);return l}function ia(e,t,n){if(!n.exists(e))return 0;let r=xr(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 oa(e){let t=e??xe;if(!Number.isSafeInteger(t)||t<=0)throw new RangeError(`maxSegmentBytes must be a positive safe integer; received ${t}`);return t}function xr(e,t,n){let r=n.size(e);if(r>t)throw new nt("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 nt("rotating JSONL segment",e,"changed-during-read",o,t);return i}function aa(e){let t=e.lastIndexOf(10),n=t<0?0:t+1;return{lines:e.subarray(0,n).toString("utf8").split(`
|
|
10
|
+
`).filter(i=>i.length>0),partialTailBytes:e.length-n}}var la="<global-symbols>";function da(e){let t=[];for(let n of e.all(`
|
|
11
11
|
SELECT relative_path, language, position_encoding, text
|
|
12
12
|
FROM documents
|
|
13
13
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -34,7 +34,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
34
34
|
FROM defn_enclosing_ranges r
|
|
35
35
|
JOIN documents d ON d.id = r.document_id
|
|
36
36
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
37
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
37
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:vt(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
38
38
|
SELECT d.relative_path,
|
|
39
39
|
c.chunk_index,
|
|
40
40
|
m.role,
|
|
@@ -49,7 +49,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
49
49
|
JOIN chunks c ON c.id = m.chunk_id
|
|
50
50
|
JOIN documents d ON d.id = c.document_id
|
|
51
51
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
52
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
52
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:vt(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
53
53
|
SELECT g.symbol,
|
|
54
54
|
g.display_name,
|
|
55
55
|
g.kind,
|
|
@@ -63,8 +63,8 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
63
63
|
) AND NOT EXISTS (
|
|
64
64
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
65
65
|
)
|
|
66
|
-
`))t.push({relativePath:
|
|
67
|
-
`);n.set(r,o.digest("hex"))}return n}function pa(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 vt(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 Pt(e,t=ya){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(u,l)=>{let d=r();return Er(e.refreshResult,u,n?d:i(),Math.max(0,d-o),l)};if(!t.databaseExists(e.previousDbPath))return a("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return a("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let u=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=xe(e.previousSnapshot,e.currentSnapshot),d=new Set(u),p=l.changes.length>0&&!St(l).fullProject&&l.changes.every(I=>d.has(I.path)),g=De(l,p?t.dependencyGraph(s):new Map,u),f=pa(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:vt(g,f,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{xr(s),xr(c)}}function Ir(e,t,n,r=Date.now()){return Er(e,t,r,0,n)}function kr(e){let t=ca(e);return{latestPath:Rr(t,"affected-shadow-latest.json"),historyPath:Rr(t,"affected-shadow.jsonl")}}function ld(e,t=n=>rn(n,"affected-shadow source file")){let n=kr(e),r;try{r=JSON.parse(t(n.latestPath))}catch(h){let S=va(h),b=S?"telemetry-missing":xa(h);return C(n,b,S?void 0:h instanceof Error?h.message:String(h))}if(U(r)&&typeof r.version=="number"&&r.version!==1)return C(n,"unsupported-record-version",`Unsupported version ${r.version}.`);if(!ba(r))return C(n,"telemetry-malformed");if(r.status==="unavailable")return Ra(r.reason)?{state:"unavailable",...n,reason:r.reason,recordedAt:r.recordedAt,refreshResult:r.refreshResult,durationMs:r.durationMs,...typeof r.error=="string"?{error:r.error}:{}}:C(n,"telemetry-malformed");if(r.status!=="evaluated")return C(n,"telemetry-malformed");let i=r.plan,o=r.comparison,a=r.evaluation;if(!U(r.manifest)||!U(i)||!U(o)||!U(a))return C(n,"telemetry-malformed");let s=i.mode,c=W(i.affectedFiles),u=W(i.reasons),l=W(o.changedFiles),d=W(a.predictedFiles),p=W(a.actualFiles),g=W(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"||!vr(f)||!vr(m))return C(n,"telemetry-malformed");let I=p.length===0?1:(p.length-g.length)/p.length;return!Pr(c,d)||!Pr(l,p)||a.passed!==(g.length===0)||Math.abs(f-I)>Number.EPSILON||g.some(h=>!p.includes(h)||d.includes(h))?C(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 dd(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 wr(e,t,n=Sa){let r=kr(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var ga=8*1024*1024,fa=ae;function ma(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 ha(e,t,n=ga){Oe(e,ma(t),{maxSegmentBytes:n,previousSuffix:fa})}function xt(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var ya={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:R,databaseExists:e=>sa(e),openDatabase:(e,t,n)=>new L({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Ee(e),dependencyGraph:e=>Te(e),factDigests:e=>la(e)},Sa={appendHistory:ha,writeLatest:(e,t)=>mn(e,t,{spacing:2,trailingNewline:!0})};function Er(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function xr(e){try{e?.close()}catch{}}function ba(e){return U(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 Ra(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function vr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function Pr(e,t){return e.length===t.length&&e.every((n,r)=>n===t[r])}function C(e,t,n){return{state:"unavailable",...e,reason:t,...n?{error:n}:{}}}function xa(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function va(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Pa}from"fs";import{isAbsolute as Tr,join as Ia,resolve as ka}from"path";var je="@sourcegraph/scip-typescript@0.4.0",Fr="scip-python-plus@0.7.5",Ar="github.com/sourcegraph/scip-go@v0.2.7",_r="scip-dotnet@0.2.14",wa="scip_dart@1.6.2",Ea={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:[...k.typescript],installMethods:[{label:"npm",identity:je,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",je]}],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:[...k.javascript],installMethods:[{label:"npm",identity:je,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",je]}],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:[...k.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:[...k.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:[...k.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:ie.language,indexerBinary:ie.indexerBinary,checkCommand:`${ie.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:ie.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...k.rust],installMethods:[],installUrl:ie.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:[...k.python],installMethods:[{label:"npm",identity:Fr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Fr]}],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",Tr(r)?r:ka(e,r)),{binary:n,args:i}},markerFiles:[...k.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:[...k.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:[...k.go],installMethods:[{label:"go install",identity:Ar,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Ar]}],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:[...k.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:[...k.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Lr(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...k.csharp],installMethods:[{label:"dotnet",identity:_r,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Lr(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...k.vb],installMethods:[{label:"dotnet",identity:_r,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...k.dart],installMethods:[{label:"dart pub",identity:wa,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})=>Tr(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...k.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Dr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function It(e){return Ea[e]}function Lr(e,t){let n;try{n=Pa(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Ia(e,i);return null}import{createHash as Ta}from"crypto";import{existsSync as Or,rmSync as jr}from"fs";import{resolve as Fa}from"path";import Nr from"better-sqlite3";var Aa={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}]},_a={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 $r(e){let t=R(),n=La(e.affectedFiles);if(Da(e.previousDbPath,e.miniDbPath,e.candidateDbPath),jr(e.candidateDbPath,{force:!0}),!Or(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Or(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Cr(e.previousDbPath,"previous SQLite generation",!1),Cr(e.miniDbPath,"incremental SQLite mini database");let r=G(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&q(e.writeTelemetry,r);let i=null;try{i=new Nr(e.candidateDbPath,{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),kt(i,"main","candidate SQLite generation"),kt(i,"incremental","incremental SQLite mini database"),Oa(i,n),ja(i,n.length);let o=wt(i,"main",!0),a=M(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{Ca(i),Ma(i),Na(i),e.onStage?.("after-delete"),$a(i),e.onStage?.("after-symbol-reconciliation"),Ba(i),e.onStage?.("after-insert"),Va(i),Ua(i,n.length,a),e.onStage?.("before-commit")}).immediate(),Br(i,"main","candidate SQLite generation");let u=[...Wa(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{jr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function La(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 Da(e,t,n){let r=[e,t,n].map(i=>Fa(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Cr(e,t,n=!0){let r=new Nr(e,{readonly:!0,fileMustExist:!0});try{kt(r,"main",t),n&&Br(r,"main",t)}finally{r.close()}}function kt(e,t,n){for(let[r,i]of Object.entries(Aa)){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(_a)){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}`)}Mr(e,t,"documents",["relative_path"],n),Mr(e,t,"global_symbols",["symbol"],n)}function Mr(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 Br(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 Oa(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 ja(e,t){let n=M(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=M(e,`SELECT COUNT(*) AS value
|
|
66
|
+
`))t.push({relativePath:la,kind:"global-symbol",values:vt(n)});return pa(t)}function pa(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=sa("sha256");for(let a of i.sort())o.update(String(Buffer.byteLength(a))),o.update(":"),o.update(a),o.update(`
|
|
67
|
+
`);n.set(r,o.digest("hex"))}return n}function ga(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 Pt(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 It(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 Fr(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=ve(e.previousSnapshot,e.currentSnapshot),d=new Set(u),p=l.changes.length>0&&!bt(l).fullProject&&l.changes.every(I=>d.has(I.path)),g=Oe(l,p?t.dependencyGraph(s):new Map,u),f=ga(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:Pt(g,f,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{Pr(s),Pr(c)}}function wr(e,t,n,r=Date.now()){return Fr(e,t,r,0,n)}function Er(e){let t=ua(e);return{latestPath:vr(t,"affected-shadow-latest.json"),historyPath:vr(t,"affected-shadow.jsonl")}}function dd(e,t=n=>rn(n,"affected-shadow source file")){let n=Er(e),r;try{r=JSON.parse(t(n.latestPath))}catch(h){let S=Pa(h),b=S?"telemetry-missing":va(h);return M(n,b,S?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(!Ra(r))return M(n,"telemetry-malformed");if(r.status==="unavailable")return xa(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"||!Ir(f)||!Ir(m))return M(n,"telemetry-malformed");let I=p.length===0?1:(p.length-g.length)/p.length;return!kr(c,d)||!kr(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 pd(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 Tr(e,t,n=ba){let r=Er(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var fa=8*1024*1024,ma=se;function ha(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 ya(e,t,n=fa){je(e,ha(t),{maxSegmentBytes:n,previousSuffix:ma})}function vt(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=>ca(e),openDatabase:(e,t,n)=>new L({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Te(e),dependencyGraph:e=>Fe(e),factDigests:e=>da(e)},ba={appendHistory:ya,writeLatest:(e,t)=>hn(e,t,{spacing:2,trailingNewline:!0})};function Fr(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 Pr(e){try{e?.close()}catch{}}function Ra(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 xa(e){return e==="prior-index-unavailable"||e==="candidate-index-unavailable"||e==="oracle-error"}function Ir(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0&&e<=1}function kr(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 va(e){return e instanceof SyntaxError?"telemetry-malformed":"telemetry-unreadable"}function Pa(e){return e instanceof Error&&e.code==="ENOENT"}import{readdirSync as Ia}from"fs";import{isAbsolute as Ar,join as ka,resolve as wa}from"path";var Ce="@sourcegraph/scip-typescript@0.4.0",_r="scip-python-plus@0.7.5",Dr="github.com/sourcegraph/scip-go@v0.2.7",Lr="scip-dotnet@0.2.14",Ea="scip_dart@1.6.2",Ta={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:[...k.typescript],installMethods:[{label:"npm",identity:Ce,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ce]}],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:[...k.javascript],installMethods:[{label:"npm",identity:Ce,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Ce]}],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:[...k.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:[...k.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:[...k.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:oe.language,indexerBinary:oe.indexerBinary,checkCommand:`${oe.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:oe.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...k.rust],installMethods:[],installUrl:oe.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:[...k.python],installMethods:[{label:"npm",identity:_r,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",_r]}],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",Ar(r)?r:wa(e,r)),{binary:n,args:i}},markerFiles:[...k.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:[...k.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:[...k.go],installMethods:[{label:"go install",identity:Dr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Dr]}],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:[...k.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:[...k.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",Or(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...k.csharp],installMethods:[{label:"dotnet",identity:Lr,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",Or(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...k.vb],installMethods:[{label:"dotnet",identity:Lr,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:[...k.dart],installMethods:[{label:"dart pub",identity:Ea,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})=>Ar(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...k.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function jr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function kt(e){return Ta[e]}function Or(e,t){let n;try{n=Ia(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return ka(e,i);return null}import{createHash as Fa}from"crypto";import{existsSync as Cr,rmSync as Mr}from"fs";import{resolve as Aa}from"path";import Br from"better-sqlite3";var _a={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},Da={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 Vr(e){let t=R(),n=La(e.affectedFiles);if(Oa(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Mr(e.candidateDbPath,{force:!0}),!Cr(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Cr(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Nr(e.previousDbPath,"previous SQLite generation",!1),Nr(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 Br(D(e.candidateDbPath),{fileMustExist:!0}),i.pragma("busy_timeout = 5000"),i.pragma("foreign_keys = ON"),i.prepare("ATTACH DATABASE ? AS incremental").run(D(e.miniDbPath)),wt(i,"main","candidate SQLite generation"),wt(i,"incremental","incremental SQLite mini database"),ja(i,n),Ca(i,n.length);let o=Et(i,"main",!0),a=N(i,"SELECT COUNT(*) AS value FROM main.documents");i.transaction(()=>{Ma(i),Na(i),$a(i),e.onStage?.("after-delete"),Ba(i),e.onStage?.("after-symbol-reconciliation"),Va(i),e.onStage?.("after-insert"),Ua(i),Wa(i,n.length,a),e.onStage?.("before-commit")}).immediate(),Ur(i,"main","candidate SQLite generation");let u=[...Ga(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{Mr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${o instanceof Error?o.message:String(o)}`,{cause:o})}}function La(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 Oa(e,t,n){let r=[e,t,n].map(i=>Aa(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Nr(e,t,n=!0){let r=new Br(D(e),{readonly:!0,fileMustExist:!0});try{wt(r,"main",t),n&&Ur(r,"main",t)}finally{r.close()}}function wt(e,t,n){for(let[r,i]of Object.entries(_a)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:l})=>({name:s,type:c.toUpperCase(),notnull:u,pk:l}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Da)){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}`)}$r(e,t,"documents",["relative_path"],n),$r(e,t,"global_symbols",["symbol"],n)}function $r(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 Ur(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 ja(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 Ca(e,t){let n=N(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=N(e,`SELECT COUNT(*) AS value
|
|
68
68
|
FROM main.documents d
|
|
69
69
|
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
70
70
|
FROM temp.incremental_affected_paths p
|
|
@@ -74,7 +74,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
74
74
|
FROM incremental.documents d
|
|
75
75
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
76
76
|
WHERE p.relative_path IS NULL
|
|
77
|
-
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
|
|
77
|
+
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 Ma(e){e.exec(`
|
|
78
78
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
79
79
|
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
80
80
|
SELECT g.symbol
|
|
@@ -101,7 +101,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
101
101
|
FROM incremental.mentions m
|
|
102
102
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
103
103
|
WHERE m.role = 1;
|
|
104
|
-
`)}function
|
|
104
|
+
`)}function Na(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
105
105
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
106
106
|
UNION
|
|
107
107
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
@@ -124,7 +124,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
124
124
|
SELECT u.symbol
|
|
125
125
|
FROM unaffected_definitions u
|
|
126
126
|
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
127
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function
|
|
127
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function $a(e){e.exec(`
|
|
128
128
|
DELETE FROM main.mentions
|
|
129
129
|
WHERE chunk_id IN (
|
|
130
130
|
SELECT c.id
|
|
@@ -146,7 +146,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
146
146
|
);
|
|
147
147
|
DELETE FROM main.documents
|
|
148
148
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
149
|
-
`)}function
|
|
149
|
+
`)}function Ba(e){e.exec(`
|
|
150
150
|
UPDATE main.global_symbols
|
|
151
151
|
SET display_name = NULL,
|
|
152
152
|
kind = NULL,
|
|
@@ -188,7 +188,7 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
188
188
|
WHERE source.symbol = main.global_symbols.symbol
|
|
189
189
|
)
|
|
190
190
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
191
|
-
`)}function
|
|
191
|
+
`)}function Va(e){let t=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=N(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)
|
|
192
192
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
193
193
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
194
194
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
@@ -203,15 +203,15 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
203
203
|
r.start_line, r.start_char, r.end_line, r.end_char
|
|
204
204
|
FROM incremental.defn_enclosing_ranges r
|
|
205
205
|
JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
206
|
-
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function
|
|
206
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function Ua(e){e.exec(`
|
|
207
207
|
DELETE FROM main.global_symbols
|
|
208
208
|
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
209
209
|
AND NOT EXISTS (
|
|
210
210
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
211
211
|
);
|
|
212
|
-
`)}function
|
|
212
|
+
`)}function Wa(e,t,n){let r=N(e,"SELECT COUNT(*) AS value FROM main.documents"),i=N(e,`SELECT COUNT(*) AS value
|
|
213
213
|
FROM main.documents d
|
|
214
|
-
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
|
|
214
|
+
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 Ga(e){let t=Et(e,"main",!0),n=Et(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 Et(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
|
|
215
215
|
FROM ${t}.documents d
|
|
216
216
|
${r}
|
|
217
217
|
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
|
|
@@ -233,15 +233,15 @@ import{$a as Jn,Ab as er,Bb as tr,Cb as nr,Eb as rr,Fb as ir,Gb as or,Hb as Ae,O
|
|
|
233
233
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
234
234
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
235
235
|
${r}
|
|
236
|
-
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=
|
|
237
|
-
`);u.set(l,p.digest("hex"))}return u}function
|
|
238
|
-
`)}function
|
|
236
|
+
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=Fa("sha256");for(let g of d.sort())p.update(g).update(`
|
|
237
|
+
`);u.set(l,p.digest("hex"))}return u}function N(e,t){return e.prepare(t).get().value}import qa from"better-sqlite3";var Me="idx_mentions_definitions",Ja=["symbol_id","chunk_id"];function Tt(e){let t=new qa(D(e)),n=[],r=[],i=[];try{return t.transaction(()=>{Ha(t,n),Ne(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&Wr(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")):Ne(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let o=Ne(t,"idx_chunks_doc_id"),a=Wr(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 Ha(e,t){let n=Gr(e,Me);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(`${Me} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Me}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Me)}function Wr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Ne(e,n.name)??[]}))}function Ne(e,t){return Gr(e,t)?.columns??null}function Gr(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 za}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 Jr(e){let t=e.readFingerprint(),n=Xa(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return Ka(e.cachePath,e.readFingerprint(),r),r}function Xa(e,t){try{let n=JSON.parse(F(e,{maxBytes:Q,inputKind:"post-index augmentation cache"}));return qr(n.fingerprint)===qr(t)?{result:n.result}:null}catch{return null}}function Ka(e,t,n){za(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
|
|
238
|
+
`)}function qr(e){return JSON.stringify(e)}import{existsSync as Hr,statSync as Ya}from"fs";import{dirname as Kr,join as Yr}from"path";var Qa="reindex-activity.jsonl",$e=se,Za=1024*1024,es=1440*60*1e3,zr=e=>_(e,"reindex activity segment");function Be(e){return Yr(Kr(e),Qa)}function ts(e){if(e.reused)return 0;let t=Ft(e.indexPath)+Ft(e.dbPath);for(let n of e.shards??[])!n.reused&&n.outputBytes!==null&&(t+=n.outputBytes);return t}function At(e,t){let n=t.lastRefresh;if(!n)return{state:"failed",reason:"reindex result has no refresh metadata"};let r=ts(t);return _t(Be(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:ss(t)})}function Qr(e,t){return _t(Be(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 _t(Be(e),{version:1,event:"suppressed",recordedAt:n.toISOString(),trigger:t,reason:"completed-index-is-fresh"})}function ns(e,t,n=Za,r){je(e,t,{maxSegmentBytes:n,previousSuffix:$e,...r?{runtime:r}:{}})}function rs(e,t=new Date,n=es,r=zr){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=Be(e),c=[];if(r===zr){if(!Hr(s)&&!Hr(`${s}${$e}`))return a;try{let u=br(s,{previousSuffix:$e});c=u.lines,a.ignoredPartialTailBytes=u.ignoredPartialTailBytes}catch{a.readErrors+=1,a.confidence="unavailable"}}else{let u=0;for(let l of[`${s}${$e}`,s])try{c.push(...fs(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=is(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 ds(d.byLanguage)){let m=(a.byLanguage??={})[g]??=ps();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=gs(a),a}function _t(e,t){try{return ns(e,t),{state:"recorded"}}catch(n){return{state:"failed",reason:n instanceof Error?n.message:String(n)}}}function is(e){try{let t=JSON.parse(e);if(!t||typeof t!="object")return null;let n=t;if(n.version!==1||!an(n.recordedAt)||!n.trigger||!as(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"||!V(n.durationMs)||!V(n.estimatedLogicalOutputBytes)||n.estimatedWriteBytes!==void 0&&!V(n.estimatedWriteBytes)||n.reflinkedBytes!==void 0&&!V(n.reflinkedBytes)||n.fallbackCopiedBytes!==void 0&&!V(n.fallbackCopiedBytes))return null;let r=n,{byLanguage:i,...o}=r,a=cs(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?os(rs(e,n,t.windowMs),t,n.getTime()):{state:"allowed",rebuilt:0,estimatedWriteBytes:0}}function os(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:Xr(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:Xr(e.oldestWriteAt,t.windowMs,n),...i,detail:`${r}/${t.maxEstimatedWriteBytes} estimated write bytes consumed`}:{state:"allowed",...i}:{state:"allowed",...i}}function Xr(e,t,n){let r=e?Date.parse(e):Number.NaN;return Number.isFinite(r)&&r+t>n?r+t:n+t}function as(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 Ft(e){try{return Ya(e).size}catch{return 0}}function ss(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=Ft(Yr(Kr(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 cs(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(!ls(i)||!us(o)){n+=1;continue}t[i]=o}let r=Object.keys(t).length>0;return{...r?{byLanguage:t}:{},hasLanguageDetails:r,invalidLanguageDetails:n}}function us(e){if(!e||typeof e!="object")return!1;let t=e;return(t.result==="rebuilt"||t.result==="reused")&&it(t.outputBytes)&&it(t.producedOutputBytes)&&V(t.durationMs)&&(t.result!=="reused"||t.producedOutputBytes===0&&t.durationMs===0)&&t.producedOutputBytes<=t.outputBytes}function ls(e){return rt.includes(e)}function ds(e){return e?rt.flatMap(t=>{let n=e[t];return n?[[t,n]]:[]}):[]}function ps(){return{runs:0,rebuilt:0,reused:0,producedOutputBytes:0,durationMs:0}}function gs(e){let t=e.invalidLanguageDetails??0,n=e.attributedRuns??0;return(e.unattributedRuns??0)===0&&t===0?"complete":n===0?"unavailable":"partial"}function fs(e){return e.endsWith(`
|
|
239
239
|
`)||(e=e.slice(0,Math.max(0,e.lastIndexOf(`
|
|
240
240
|
`)+1))),e.split(`
|
|
241
|
-
`).filter(t=>t.length>0)}import{createHash as
|
|
242
|
-
`;)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 jt(e){try{let t=F(e,{maxBytes:Y,inputKind:"TypeScript project manifest"}),n=JSON.parse(ws(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as qs}from"crypto";import{existsSync as Mt,statSync as Js,writeFileSync as Nt}from"fs";import{join as Hs}from"path";import{createRequire as Es}from"module";import{dirname as Ts,isAbsolute as Xd,relative as Kd,resolve as Yd,sep as Qd}from"path";var oi=Es(import.meta.url),Fs=1,ai="0.4.0";function Ct(){let e=As();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function As(){try{let e=oi.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(_(e,"scip-typescript package manifest"));if(t.version!==ai)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${ai}`};let n=Ts(e),r=oi.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(_(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:_s(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function _s(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${Fs}`}import{createHash as Ls}from"crypto";import{dirname as Ds,join as si}from"path";var Ve=4;var Os="typescript-index";function ci(e){let t=si(e,Os),n=Pn(t);return{...n,requestDir:n.legacyRequestDir}}function ui(e){try{let t=ln(Z(_(si(Ds(e),"meta.json"),"reindex metadata")));return t?Ls("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as js}from"crypto";import{existsSync as Cs}from"fs";var Ms=12e4,Ns=5,Ue=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=nn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ws(),this.runtime=n.runtime??Gs,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=sn(this.cacheDir),r=ci(this.cacheDir),i=it(n.statePath);if(!li(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=gt("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),u=ft(c),l=In(r,{mailboxVersion:pt,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(Cs(l.responsePath))return $s(F(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let d=it(n.statePath);if(!li(d,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Ns)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function li(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&&le(e.processIdentity,r))}function $s(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=Bs(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 Bs(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(Vs)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:Us(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 Vs(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 Us(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ws(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Ms}var Gs={now:Date.now,monotonicNow:R,randomId:js,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:K,readProcessIdentity:Q};function zs(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=xe(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"||!ht(l.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=De(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=Xs(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=di(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=di(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=gi(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=gi(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:pi(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:pi(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...u?{tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument}:{}}}function Xs(e,t,n){let r=new Map;for(let o of e.affectedFiles){let a=Ks(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=>Ys(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 Ks(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)=>We(a)-We(o)||o.localeCompare(a)),i=r[0];return r[1]&&We(r[1])===We(i)?null:i}function We(e){return e==="."?0:e.split("/").filter(Boolean).length}function Ys(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 fi(e){let t=R();try{if(!Mt(e.previousDbPath)||!Mt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Ct();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new L({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=Ee(o,{includeIgnored:!1}).filter(ht).sort(),s=Te(o)}finally{o.close()}let c=performance.now()-n,u=zs({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:Mt(Hs(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let l=ui(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let d=new Ue({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=Js(e.previousShardPath).size>=An;n=performance.now();let I=m?null:$(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:et}),h=m?{completeIndexBytes:null,affectedIndexBytes:kn(g)}:Tn({packageVersion:r.packageVersion,baseIndexBytes:I,fragments:g}),S=performance.now()-n;n=performance.now(),m?_n({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(wn({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:I,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),En({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:g,documentIdentities:u.nextDocumentIdentities}));let b=performance.now()-n;n=performance.now(),h.completeIndexBytes&&Nt(e.candidateShardPath,h.completeIndexBytes),Nt(e.candidateAffectedScipPath,h.affectedIndexBytes);let P=performance.now()-n,v={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,z)=>x+z.durationMs,0),assemblyMs:S,fragmentStoreMs:b,writeMs:P}};return e.onStatus(`Incremental TypeScript index emitted ${v.affectedFiles.length} affected document(s) across ${u.projects.length} project(s) in ${(v.durationMs/1e3).toFixed(3)}s (${v.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 ${S.toFixed(0)}ms, fragments ${b.toFixed(0)}ms, write ${P.toFixed(0)}ms).`),v}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 mi(e){let t=Ct();if(!t.available)throw new Error(t.reason);let n=Ln({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:$(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:et}),packageVersion:t.packageVersion});Nt(e.candidateShardPath,n)}function di(e,t,n){let r=e.files.filter(i=>cn(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 $t(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function pi(e,t){return $t(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function gi(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=Qn({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,$t(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function $t(e){return qs("sha256").update(e).digest("hex")}import{closeSync as Qs,existsSync as Ge,fstatSync as Zs,lstatSync as ec,openSync as tc,renameSync as Ut,rmSync as qe,statSync as nc,writeSync as rc}from"fs";import{cpus as ic}from"os";import{join as Wt}from"path";var Bt=Symbol("no-error");async function hi(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=Number.isFinite(t)?Math.max(1,Math.floor(t)):1,o=Math.min(e.length,i),a=0,s=Bt,c=!0,u=Array.from({length:o},async()=>{for(;c&&a<e.length;){let l=a++;try{r[l]=await n(e[l])}catch(d){s===Bt&&(s=d),c=!1}}});if(await Promise.all(u),s!==Bt)throw s;return r}function oc(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=Wt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=tc(n,"wx",384)}catch(o){if(o.code==="EEXIST")return null;throw o}try{rc(i,r);let o=Zs(i);return{path:n,content:r,device:o.dev,inode:o.ino}}finally{Qs(i)}}function ac(e){if(e)try{let t=ec(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=$(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;qe(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function sc(e,t,n){if(!e.defaultOutputPath)return;let r=Wt(t,e.defaultOutputPath);n!==r&&Ge(r)&&Ut(r,n)}function cc(e,t,n){if(!e.defaultOutputPath)return null;let r=Wt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return qe(i,{force:!0}),Ge(r)?(Ut(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function uc(e){e&&(qe(e.defaultOutputPath,{force:!0}),e.backupPath&&Ge(e.backupPath)&&Ut(e.backupPath,e.defaultOutputPath))}function lc(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,ic().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Si(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=lc(a.length,r),u=await hi(a,c,l=>Vt(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 Vt(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 Vt(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 Vt(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),qe(e.scipPath,{force:!0});let i=cc(e.config,t,e.scipPath),o=oc(e,t),a=[e.binary,...e.args].join(" "),s=R();try{e.trustedProjectTool&&Kn(t,e.trustedProjectTool);let u=qn(e.binary,e.args),l=await Ae({command:u.binary,args:u.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:dc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let d=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${d?`:
|
|
243
|
-
${d}`:""}`)}
|
|
244
|
-
`)[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:
|
|
241
|
+
`).filter(t=>t.length>0)}import{createHash as ms}from"crypto";import{existsSync as Dt,readdirSync as hs}from"fs";import{dirname as Lt,join as Ve,relative as ys,resolve as Ot,sep as Zr}from"path";function ei(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=ii(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function ti(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=ii(s,e);c&&c!==i&&a.add(c)}}return Ss(e,r)}function ni(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 jt(e){if(e===".")return"root";let t=ms("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function ri(e,t){let n=Ot(e),r={};for(let i of t)r[i]=bs(n,i);return r}function ii(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 Ss(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 bs(e,t){let n=t==="."?e:Ve(e,t),r=Rs(n),i=xs(n),o=i?vs(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 Rs(e){let t=Ve(e,"package.json");if(!Dt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Ct(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 xs(e){let t=Ve(e,"tsconfig.json");if(Dt(t))return t;let n;try{n=hs(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?Ve(e,n[0]):void 0}function vs(e,t){let n=Ct(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Ps(n.value,e,t),i=oi(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Ps(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Lt(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=ai(s,i,n);c&&o.add(c)}return[...o]}function oi(e,t,n,r){let i=Is(t);if(i)return{pathsTargets:ks(i,Lt(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=ws(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=Ct(o);return a.ok?oi(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function Is(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 ks(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=ai(o,t,n);a&&r.add(a)}return[...r]}function ws(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=Ot(Lt(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Zr).includes("node_modules")&&at(n,i)&&Dt(i))return i}function ai(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Ot(t,r===""?".":r);if(!at(n,i))return;let a=ys(n,i).split(Zr).join("/");return a===""?".":a}function Es(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let o=e[n];if(r){if(t+=o,o==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}o==='"'&&(r=!1),n+=1;continue}if(o==='"'){r=!0,t+=o,n+=1;continue}if(o==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
242
|
+
`;)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 Ct(e){try{let t=F(e,{maxBytes:Q,inputKind:"TypeScript project manifest"}),n=JSON.parse(Es(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as Js}from"crypto";import{existsSync as Nt,statSync as Hs,writeFileSync as $t}from"fs";import{join as zs}from"path";import{createRequire as Ts}from"module";import{dirname as Fs,isAbsolute as Qd,relative as Zd,resolve as ep,sep as tp}from"path";var si=Ts(import.meta.url),As=1,ci="0.4.0";function Mt(){let e=_s();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function _s(){try{let e=si.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(_(e,"scip-typescript package manifest"));if(t.version!==ci)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${ci}`};let n=Fs(e),r=si.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(_(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:Ds(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Ds(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${As}`}import{createHash as Ls}from"crypto";import{dirname as Os,join as ui}from"path";var Ue=4;var js="typescript-index";function li(e){let t=ui(e,js),n=In(t);return{...n,requestDir:n.legacyRequestDir}}function di(e){try{let t=dn(ee(_(ui(Os(e),"meta.json"),"reindex metadata")));return t?Ls("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as Cs}from"crypto";import{existsSync as Ms}from"fs";var Ns=12e4,$s=5,We=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=nn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Gs(),this.runtime=n.runtime??qs,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=sn(this.cacheDir),r=li(this.cacheDir),i=ot(n.statePath);if(!pi(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=ft("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),u=mt(c),l=kn(r,{mailboxVersion:gt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:Ue,id:u,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??R)()<=s;){if(Ms(l.responsePath))return Bs(F(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let d=ot(n.statePath);if(!pi(d,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep($s)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function pi(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Ue&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&de(e.processIdentity,r))}function Bs(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==Ue||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=Vs(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 Vs(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(Us)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:Ws(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 Us(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 Ws(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Gs(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Ns}var qs={now:Date.now,monotonicNow:R,randomId:Cs,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:Y,readProcessIdentity:Z};function Xs(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=ve(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"||!yt(l.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Oe(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=Ks(r,t,e.graph);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=gi(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=gi(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=mi(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=mi(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:fi(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:fi(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,projects:i,...u?{tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument}:{}}}function Ks(e,t,n){let r=new Map;for(let o of e.affectedFiles){let a=Ys(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=>Qs(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 Ys(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)=>Ge(a)-Ge(o)||o.localeCompare(a)),i=r[0];return r[1]&&Ge(r[1])===Ge(i)?null:i}function Ge(e){return e==="."?0:e.split("/").filter(Boolean).length}function Qs(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 hi(e){let t=R();try{if(!Nt(e.previousDbPath)||!Nt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Mt();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new L({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=Te(o,{includeIgnored:!1}).filter(yt).sort(),s=Fe(o)}finally{o.close()}let c=performance.now()-n,u=Xs({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?re(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:Nt(zs(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let l=di(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let d=new We({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=Hs(e.previousShardPath).size>=_n;n=performance.now();let I=m?null:B(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:tt}),h=m?{completeIndexBytes:null,affectedIndexBytes:wn(g)}:Fn({packageVersion:r.packageVersion,baseIndexBytes:I,fragments:g}),S=performance.now()-n;n=performance.now(),m?Dn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g}):(En({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:I,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),Tn({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:g,documentIdentities:u.nextDocumentIdentities}));let b=performance.now()-n;n=performance.now(),h.completeIndexBytes&&$t(e.candidateShardPath,h.completeIndexBytes),$t(e.candidateAffectedScipPath,h.affectedIndexBytes);let P=performance.now()-n,v={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:S,fragmentStoreMs:b,writeMs:P}};return e.onStatus(`Incremental TypeScript index emitted ${v.affectedFiles.length} affected document(s) across ${u.projects.length} project(s) in ${(v.durationMs/1e3).toFixed(3)}s (${v.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 ${S.toFixed(0)}ms, fragments ${b.toFixed(0)}ms, write ${P.toFixed(0)}ms).`),v}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 yi(e){let t=Mt();if(!t.available)throw new Error(t.reason);let n=Ln({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:B(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:tt}),packageVersion:t.packageVersion});$t(e.candidateShardPath,n)}function gi(e,t,n){let r=e.files.filter(i=>un(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return Bt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function fi(e,t){return Bt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function mi(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=Zn({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let u=a.identityFor(c,"typescript-scip-document-v1");if(u.key){s.set(c,u.key);continue}if(o.has(c))return null;s.set(c,Bt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function Bt(e){return Js("sha256").update(e).digest("hex")}import{closeSync as Zs,existsSync as qe,fstatSync as ec,lstatSync as tc,openSync as nc,renameSync as Ut,rmSync as Je,statSync as rc,writeSync as ic}from"fs";import{cpus as oc}from"os";import{join as Wt}from"path";function ac(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=Wt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),i;try{i=nc(n,"wx",384)}catch(o){if(o.code==="EEXIST")return null;throw o}try{ic(i,r);let o=ec(i);return{path:n,content:r,device:o.dev,inode:o.ino}}finally{Zs(i)}}function sc(e){if(e)try{let t=tc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=B(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;Je(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function cc(e,t,n){if(!e.defaultOutputPath)return;let r=Wt(t,e.defaultOutputPath);n!==r&&qe(r)&&Ut(r,n)}function uc(e,t,n){if(!e.defaultOutputPath)return null;let r=Wt(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Je(i,{force:!0}),qe(r)?(Ut(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function lc(e){e&&(Je(e.defaultOutputPath,{force:!0}),e.backupPath&&qe(e.backupPath)&&Ut(e.backupPath,e.defaultOutputPath))}function dc(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,oc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function bi(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=dc(a.length,r),u=await sr(a,c,l=>Vt(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 Vt(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 Vt(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 Vt(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Je(e.scipPath,{force:!0});let i=uc(e.config,t,e.scipPath),o=ac(e,t),a=[e.binary,...e.args].join(" "),s=R();try{e.trustedProjectTool&&Yn(t,e.trustedProjectTool);let u=Jn(e.binary,e.args),l=await _e({command:u.binary,args:u.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:pc(),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?`:
|
|
243
|
+
${d}`:""}`)}cc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw gn(r,"Reindex cancelled by its owner.");let l=u instanceof Error?u.message:String(u),d=`${e.resolvedBinary} indexer failed: ${l.split(`
|
|
244
|
+
`)[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:gc(u)}}finally{lc(i),sc(o)}if(!qe(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=rc(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 pc(){let e=Number(process.env.CODEBASEIQ_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):or.indexer}function gc(e){return e instanceof ar?e.kind==="spawn"&&Si(e.cause):Si(e)}function Si(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as xi}from"child_process";import{homedir as Ri,platform as fc}from"os";import{delimiter as mc,join as He}from"path";function vi(e,t){let n=e.installMethods,r=Ae(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(!ie(i.prerequisite))continue;let o=hc(i);t(`Installing immutable ${i.identity} via ${i.label} into ${o}; expected executable: ${r}.`);try{xi(i.binary,i.args,{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env,shell:fc()==="win32"});let a=ge(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 hc(e){if(e.binary==="npm")return Gt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=Gt("go",["env","GOBIN"]);if(t)return t;let n=Gt("go",["env","GOPATH"]);if(n)return He(n.split(mc)[0],"bin")}return e.binary==="dotnet"?He(process.env.DOTNET_CLI_HOME??Ri(),".dotnet","tools"):e.binary==="dart"?He(process.env.PUB_CACHE??He(Ri(),".pub-cache"),"bin"):e.destination}function Gt(e,t){try{return xi(e,t,{stdio:["ignore","pipe","ignore"],windowsHide:!0,encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}import uu from"better-sqlite3";import{existsSync as lu}from"fs";import{dirname as du,join as pu,resolve as gu}from"path";import{randomUUID as Sc}from"crypto";import{mkdtempSync as bc,rmSync as Rc,statSync as Ii}from"fs";import{tmpdir as xc}from"os";import{join as ki}from"path";import{Worker as vc}from"worker_threads";function yc(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function ce(){return{skippedReferences:0,skippedReferenceReasons:yc(),skippedReferenceSamples:[]}}function ze(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 Pc=3e5,wi=64*1024*1024,Ic={createResultDirectory:()=>bc(ki(xc(),"codebaseiq-vue-workers-")),spawn:(e,t)=>new vc(e,{workerData:t}),resultSize:e=>Ii(e).size,readResult:e=>F(e,{maxBytes:wi,inputKind:"Vue worker result"}),removeResultDirectory:e=>Rc(e,{recursive:!0,force:!0})};function Ei(e){return e.length>=8&&Fi(e.length)>1}async function Ti(e,t=Ic){let n=Fi(e.vueFiles.length),r=Mc(e.vueFiles),i=$c(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??jc(),s=e.maxResultBytes??Cc();Pi("timeoutMs",a),Pi("maxResultBytes",s);let c=Sc(),u=t.createResultDirectory(),l=[],d,p,g;try{for(let m=0;m<i.length;m++){let I=m,h=i[m]??[],S=h.map(v=>v.taskId),b=ki(u,`${I}.json`),P=t.spawn(o,{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:h,resultPath:b,runId:c,workerId:I,taskIds:S});l.push({workerId:I,taskIds:S,resultPath:b,handle:P,completion:kc(P,I)})}await wc(l,a);let f=l.sort((m,I)=>m.workerId-I.workerId).map(m=>Tc(m,c,s,t));g={occurrences:f.flatMap(m=>m.occurrences),...ce()};for(let m of f)ze(g,m)}catch(f){d=f}finally{let f=await Ec(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: ${Oc(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 kc(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 wc(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 Ec(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function Tc(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(!he(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(!Lc(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||!Fc(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function Fc(e){if(!he(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(Ac)||!O(e.skippedReferences)||!he(e.skippedReferenceReasons))return!1;for(let t of["missing-source-file","missing-service-script","no-definition","same-file-definition","unindexed-definition"])if(!O(e.skippedReferenceReasons[t]))return!1;return Array.isArray(e.skippedReferenceSamples)&&e.skippedReferenceSamples.every(_c)}function Ac(e){return he(e)&&typeof e.sourceFile=="string"&&O(e.sourceLine)&&O(e.sourceStartChar)&&O(e.sourceEndChar)&&typeof e.sourceToken=="string"&&typeof e.definitionFile=="string"&&O(e.symbolId)}function _c(e){return he(e)&&typeof e.sourceFile=="string"&&O(e.sourceLine)&&O(e.sourceStartChar)&&O(e.sourceEndChar)&&typeof e.token=="string"&&Dc(e.reason)}function Dc(e){return e==="missing-source-file"||e==="missing-service-script"||e==="no-definition"||e==="same-file-definition"||e==="unindexed-definition"}function O(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function he(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Lc(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function Pi(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function Oc(e){return e instanceof Error?e.message:String(e)}function Fi(e){let t=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function jc(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:Pc}function Cc(){let e=Number(process.env.CODEBASEIQ_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:wi}function Mc(e){let t=Nc(),n=[];for(let r of e){let i=Ai(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 Nc(){return Number.POSITIVE_INFINITY}function $c(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Bc(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 Bc(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,Ai(e.fileName)-e.startOffset)}function Ai(e){try{return Ii(e).size}catch{return 1}}import{createRequire as Vc}from"module";import{existsSync as Uc}from"fs";import{dirname as _i,extname as Wc,join as Di,relative as Gc,resolve as qc}from"path";import{pathToFileURL as Jc}from"url";function Hc(e){e.transaction(()=>{e.prepare(`
|
|
245
245
|
DELETE FROM mentions
|
|
246
246
|
WHERE chunk_id IN (
|
|
247
247
|
SELECT c.id
|
|
@@ -261,7 +261,7 @@ ${d}`:""}`)}sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw pn(r,"Reindex
|
|
|
261
261
|
FROM documents
|
|
262
262
|
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
263
263
|
ORDER BY relative_path
|
|
264
|
-
`).all().map(r=>
|
|
264
|
+
`).all().map(r=>qc(t,r.relativePath))}function Oi(e,t){let{vueCore:n,ts:r,volarTs:i}=zc(e),{parsed:o,vueOptions:a}=Xc(n,r,t),s=_i(t),c=n.createVueLanguagePlugin(r,o.options,a,g=>g),u=Kc(n,r,c),l=Yc(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 zc(e){let t=Vc(Jc(Di(e,"package.json")).href);return{vueCore:qt(t,"@vue/language-core",e),ts:qt(t,"typescript",e),volarTs:qt(t,"@volar/typescript",e)}}function Xc(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,_i(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function Kc(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Uc(o))return;let a=F(o,{maxBytes:et,inputKind:"Vue language-service source file"});r.current?.scripts.set(o,t.ScriptSnapshot.fromString(a),n.getLanguageId(o)??ru(o))});return r.current=i,i}function Yc(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function qt(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 ji(e,t,n){let r=Qc(e);return i=>{if(!i.name)return null;let o=j(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:Zc(c.starts,s.line,2,i.name)}}function Qc(e){let t=e.prepare(`
|
|
265
265
|
SELECT
|
|
266
266
|
d.relative_path AS relativePath,
|
|
267
267
|
der.start_line AS startLine,
|
|
@@ -272,22 +272,22 @@ ${d}`:""}`)}sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw pn(r,"Reindex
|
|
|
272
272
|
JOIN documents d ON d.id = der.document_id
|
|
273
273
|
JOIN global_symbols gs ON gs.id = der.symbol_id
|
|
274
274
|
ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
|
|
275
|
-
`).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
|
|
275
|
+
`).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 Zc(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 Ci(e,t,n){let r=au(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
|
|
276
276
|
INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
|
|
277
277
|
VALUES (?, ?, ?, ?)
|
|
278
|
-
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let l=
|
|
278
|
+
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let l=j(t,u),d=qi(r.name,r.version,l);o.run(d,"default",7,`Vue component|${l}`);let p=su(i,r,t,u);p&&(a++,s.set(u,p))}})(),{get(u){return s.get(u)??null},syntheticSymbols:a}}function Mi(e,t,n,r,i){return e.transaction(()=>(Hc(e),eu(e,t,n,r),tu(e,i)))()}function eu(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
|
|
279
279
|
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
280
280
|
VALUES (?, ?, ?, ?, X'00')
|
|
281
281
|
`),a=e.prepare(`
|
|
282
282
|
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
283
283
|
VALUES (?, ?, 1)
|
|
284
|
-
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=
|
|
284
|
+
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=j(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(Jt(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function $i(e){let t=new Set,n=[];for(let r of e){let i=Bi(r);t.has(i)||(t.add(i),n.push(r))}return n}function Bi(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function tu(e,t){let n=ou(e,[...new Set(t.map(c=>c.sourceFile))]),r=e.prepare(`
|
|
285
285
|
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
286
286
|
VALUES (?, ?, ?, ?, X'00')
|
|
287
287
|
`),i=e.prepare(`
|
|
288
288
|
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
289
289
|
VALUES (?, ?, 0)
|
|
290
|
-
`),o=new Set,a=0,s=0;for(let c of t){let u
|
|
290
|
+
`),o=new Set,a=0,s=0;for(let c of t){let u=Bi(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*Vi(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 Ui(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function Jt(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function nu(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 Wi(e,t){return j(e,t).startsWith("node_modules/")}function j(e,t){return Gc(e,t).replaceAll("\\","/")}function ru(e){switch(Wc(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 Gi(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=F(t,{maxBytes:et,inputKind:"Vue source file"}),r={text:n,lineStarts:iu(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:nu}}function iu(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function ou(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 au(e){try{let t=JSON.parse(F(Di(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 su(e,t,n,r){let i=j(n,r),o=qi(t.name,t.version,i);return e.get(o)?.id??null}function qi(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}async function fu(e){return z(H(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),mu(e)}async function mu(e){let t=gu(e.projectRoot,e.tsconfig);if(!lu(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new uu(D(e.dbPath));try{let r=Li(n,e.projectRoot),i=pu(du(e.dbPath),"augment-vue-meta.json");return await Jr({cachePath:i,readFingerprint:()=>bu(n,e.projectRoot,e.tsconfig),compute:()=>hu({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 hu(e){let t=Ci(e.db,e.projectRoot,e.vueFiles),n=Ei(e.vueFiles)?await Ti({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):Su(e,t);return yu(e,t,n)}function yu(e,t,n){let r=$i(n.occurrences),i=Mi(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:Tu(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:Eu(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function Su(e,t){let n=Ru({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return xu({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function bu(e,t,n){let r=e.prepare(`
|
|
291
291
|
SELECT
|
|
292
292
|
(SELECT COUNT(*) FROM documents) AS documents,
|
|
293
293
|
(SELECT COUNT(*) FROM global_symbols) AS symbols,
|
|
@@ -296,13 +296,13 @@ ${d}`:""}`)}sc(e.config,t,e.scipPath)}catch(u){if(r?.aborted)throw pn(r,"Reindex
|
|
|
296
296
|
(SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
|
|
297
297
|
(SELECT MAX(id) FROM chunks) AS maxChunkId,
|
|
298
298
|
(SELECT MAX(id) FROM global_symbols) AS maxSymbolId
|
|
299
|
-
`).get();return{version:3,tsconfig:n,files:
|
|
300
|
-
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function Iu(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function qi(e,t,n){let r=se();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:O(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function Ht(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 zt(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 ku(e,t){let n=zt(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=zt(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function wu(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(...zt(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Eu(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return ku(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function Tu(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of Au(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&&(Ji(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function Ji(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 Fu(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function Au(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=_u(r,u.textSpan.start,o,i.text);l!==null&&s.push(l)}return s}function _u(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Jt(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function ro(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=$u(e),a=Date.now(),s=R();Xe(y(o.outputScip),{recursive:!0}),Xe(y(o.outputDb),{recursive:!0});let c=e.languages??lt(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=Pe("reindex.fingerprint",()=>Rn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,d;if(e.skipIfUnchanged!==!1&&!Mn(t,o.outputDb)&&Hi(o.outputScip)===Hi(w(y(o.outputDb),"index.scip"))){let h=be(t);if(l=h?.clean?ke(h,u):void 0,h&&!h.clean&&!Nu(o)){let S=Nn(h,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(S)try{we({snapshot:S.snapshot,manifest:S.manifest,targetCacheDir:y(o.outputDb),targetProjectRoot:t,persistLease:!1}),Un(S.snapshot,y(o.outputDb)),r(`Forked shared baseline ${S.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(b){r(`Shared baseline fork failed; continuing locally: ${N(b)}`)}}else if(l){let S=mt(l);if(S){if(!Mu(o,u))try{we({snapshot:l,manifest:S,targetCacheDir:y(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(b){r(`Shared generation attach failed; continuing locally: ${N(b)}`)}}else{let b=await Bn(l);if(b.kind==="owner")d=b.release;else if(b.kind==="generation-ready"){let P=mt(l);if(P)try{we({snapshot:l,manifest:P,targetCacheDir:y(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(v){r(`Shared generation attach failed after waiting; continuing locally: ${N(v)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=fn(w(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 te("reindex.lock",()=>pl(w(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=pr();try{vn(o.outputDb,o.outputScip,o.metaPath);let h=Wu(y(o.outputDb));h.removed>0&&r(`Removed ${h.removed} abandoned reindex workspace(s)`);for(let X of h.errors)r(`Could not remove abandoned reindex workspace: ${X}`);let S=null,b=Pe("reindex.reuse-check",()=>(S=Bu({opts:e,paths:o,languages:c,fingerprint:u,start:a,monotonicStart:s,onStatus:r}),S),()=>({languages:c.length,reused:S!==null}));if(b){zi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let X=Ft(o.outputDb,b);return X.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${X.reason}`),at(t,y(o.outputDb)),b}await te("reindex.scip-cli-ready",()=>il(i,r));let P=Uu(o);m=P.runDir;let v,x=await te("reindex.fresh",async()=>(v=await Gu({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:P,fingerprint:u,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:I}),v),()=>({languages:c.length,reused:v?.reused,skipped:v?.skipped.length}));zi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let z=Ft(o.outputDb,x);return z.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${z.reason}`),at(t,y(o.outputDb)),x}catch(h){let S=Qe({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:h instanceof Error?h.message:String(h)});yo(o.metaPath,S);let b=Kr(o.outputDb,S);throw b.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${b.reason}`),h}finally{if(m){let h=m;try{ee(()=>ce(h,{recursive:!0,force:!0}))}catch(S){r(`Warning: temporary reindex workspace was left behind: ${N(S)}`)}}f(),g.release(),d?.()}}function zi(e){if(e.snapshot)try{let t=be(e.projectRoot),n=t?ke(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=$n({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=be(e.projectRoot);return(i?ke(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Vn(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: ${N(t)}`)}}function Mu(e,t){if(!E(e.outputScip)||!E(e.outputDb)||!ho(e.metaPath,t))return!1;let n=V(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function Nu(e){if(!E(e.outputScip)||!E(e.outputDb)||!ue(e.metaPath))return!1;let t=V(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function N(e){return e instanceof Error?e.message:String(e)}function Yt(e,t,n,r,i,o){try{H(fr({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 $u(e){let t=e.outputScip??w(e.projectRoot,"index.scip"),n=e.outputDb??w(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:w(y(n),"meta.json")}}function Bu(e){let t=V(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!E(e.paths.outputScip)||!E(e.paths.outputDb)||!ho(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;H(J(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Yt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),V(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(dt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=R()-e.monotonicStart,r=Qe({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return yo(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:Vu(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Vu(e,t,n,r){let i=fo(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:he(i[o]),outputBytes:ye(Zt(e.outputDb,o)),durationMs:0}))}function Uu(e){let t=Du(w(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:w(t,ze(e.outputScip)),tempOutputDb:w(t,ze(e.outputDb)),tempMetaPath:w(t,ze(e.metaPath))}}function Wu(e){let t=[],n;try{n=to(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[N(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{ce(w(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${N(o)}`)}return{removed:r,errors:t}}async function Gu(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await te("reindex.language-indexers",async()=>(n=await Ju(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(", ")}`),qu({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let g=Pe("reindex.publish",()=>tl(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 te("reindex.publish",()=>el(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 qu(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!E(e.run.paths.outputScip)||!E(e.run.paths.outputDb))return!1;let t=V(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 Ju(e,t){let n=Yu({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[T,tn]of n)tn.reused&&(r.push({language:T,scipPath:tn.scipPath}),i.add(T));for(let T of i)e.onStatus(`Reusing cached ${T} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=V(e.paths.outputDb,e.paths.metaPath),s=ue(e.paths.metaPath),c=a.state==="legacy"||a.state==="current",u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),l=o&&!o.reused&&c?fi({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:Se(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Se(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:Qt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,d=new Set(l?["typescript"]:[]),p=l?void 0:Hu(e,n),{preparedRuns:g,skippedLanguages:f,languageOutputScipPaths:m}=ol({languages:e.languages.filter(T=>!i.has(T)&&!d.has(T)),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(T=>T.language!=="typescript"||p.missedProjectIds.has(T.id)):g,h=await Si(I,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),S=[];if(p){Xu(e.paths.outputDb,h,e.writeTelemetry);let T=m.typescript??e.tempPaths.tempOutputScip;S=Ku({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:T,reusedProjects:p.reusedProjects,writeTelemetry:e.writeTelemetry})}let b=[...h,...S],{indexedOutputs:P}=sl(b,f),v=l?[{language:"typescript",scipPath:l.scipPath}]:[],x=[...r,...v,...P];cl(x,f,e.languages,e.opts.allowPartial,e.onStatus);let z=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:ye(l.scipPath)??void 0}]:[],X=Qu(n,[...h,...z],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:x,skippedLanguages:f,reusedLanguages:[...i],languageFingerprints:Zu(n,e.languages),shards:X,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Hu(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=ti(e.projectRoot,r),o=Qr(n.fingerprint.files,r),a=Zr(r,i),s=ei(r,o,a),c=ue(e.paths.metaPath),l=zu(c,s,f=>E(Ye(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 zu(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===de&&ct(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 Xu(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=Ye(e,i);Xe(y(o),{recursive:!0}),q(n,G(r.scipPath,o))}}function Ku(e){return e.reusedProjects.map((t,n)=>{let r=Ye(e.outputDb,t),i=Se(e.tempOutputScip,"typescript-project-cached",n);return q(e.writeTelemetry,G(r,i)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:ye(i)??void 0}})}function Yu(e){let t=ue(e.paths.metaPath),n=fo(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Zt(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!==de){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(!ct(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(!E(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 Qu(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:he(o.fingerprint),outputBytes:ye(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?he(s.fingerprint):o?he(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:he(o.fingerprint),outputBytes:ye(Ye(n.outputDb,i)),durationMs:0});return r}function he(e){return Lu("sha256").update(j(e)).digest("hex").slice(0,16)}function ye(e){try{return Ou(e).size}catch{return null}}function Zu(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function el(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&&(Xi(e.paths.outputDb,n,e.writeTelemetry),u=Ki(n,e.tempPaths.tempOutputScip,e.onStatus));let l=await ul({run:e,env:t,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..."),mi({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let P=n.map(v=>v.language==="typescript"?{language:v.language,scipPath:s.candidateScipPath}:v);return Xi(e.paths.outputDb,P,e.writeTelemetry),u=Ki(P,e.tempPaths.tempOutputScip,e.onStatus),u}});A(e.opts.signal,"Reindex cancelled by its owner."),H(J(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),Yt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles);let d=Et(e.tempPaths.tempOutputDb);if(d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),l.mode==="incremental"&&s){let P=null,v=null;try{P=new L({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),v=new L({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=Zn(P,e.fingerprint,s.referenceFragmentsByFile,v);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{P?.close(),v?.close()}}let p=Qt(e.paths.metaPath),g=l.mode==="incremental"&&s?dl(s,l.changedDocumentPaths):Pt({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=Qe({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(P=>P.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",I={...o};m&&delete I.typescript;let{metadata:h,pruneProjects:S}=oo({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:I,typescriptProjectShardContext:a,lastRefresh:f});h.scipCompanion=m?"deferred":"current",ao(e.paths.outputDb,S),en(e.tempPaths.tempMetaPath,h);let b=xn({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}});return b.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${b.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),Dn(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),Fn(y(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),io(e.paths.outputDb,g,e.onStatus),f}function tl(e,t,n,r,i,o){let a=Qt(e.paths.metaPath),s=null;try{q(e.writeTelemetry,G(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=Ir("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}H(J(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Yt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Et(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),s??=Pt({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=Qe({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:d}=oo({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:u});return ao(e.paths.outputDb,d),en(e.paths.metaPath,l),dt(e.paths.outputDb,e.paths.metaPath),io(e.paths.outputDb,s,e.onStatus),u}function Qt(e){return un(ue(e)?.fingerprint)}function io(e,t,n){try{wr(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 oo(e){let t=nl({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:de,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function nl(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=ue(e.metaPath),n=t?.version===de?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 ao(e,t){let n=mo(e);if(t===null){ee(()=>ce(n,{recursive:!0,force:!0}));return}let r;try{r=to(n)}catch{return}for(let i of rl(r,t))ee(()=>ce(w(n,i),{force:!0}))}function rl(e,t){let n=new Set(t.map(r=>`${Ot(r)}.scip`));return e.filter(r=>!n.has(r))}function Xi(e,t,n){for(let r of t){let i=Zt(e,r.language);Xe(y(i),{recursive:!0}),r.scipPath!==i&&q(n,G(r.scipPath,i))}}async function il(e,t){if(!oe()){if(Cu()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package codebaseiq-windows (installed automatically with codebaseiq). Reinstall codebaseiq with optional dependencies enabled, or follow 'codebaseiq setup' guidance for the exact sidecar package version, or set CODEBASEIQ_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
299
|
+
`).get();return{version:3,tsconfig:n,files:ke(t),db:r}}function Ru(e){let t=Gi();return{projectRoot:e.projectRoot,context:Oi(e.projectRoot,e.configPath),symbolLookup:ji(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function xu(e){let t=[],n=ce(),r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=vu(e,i);t.push(...o.occurrences),ze(n,o)}return{occurrences:t,...n}}function vu(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return Ji(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 Ji(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=j(e.projectRoot,t.fileName),s=[...Vi(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:Au(s),processedStarts:new Set};return Pu({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function Pu(e){let t=[],n=ce();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||Iu(e.sourceInfo.text,r.start))continue;let i=Ui(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(l=>!Wi(e.projectRoot,l.fileName));if(!a){Ht(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=j(e.projectRoot,a.fileName),c=ku(e.sourceFile,r.text,s);if(c){Ht(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){Ht(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}Hi(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,u),e.tokenContext.processedStarts.add(r.start),Fu(t,e,r,i,s,u)}return{occurrences:t,...n}}function Iu(e,t){let n=e.lastIndexOf(`
|
|
300
|
+
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function ku(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function Ji(e,t,n){let r=ce();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:j(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function Ht(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 zt(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 wu(e,t){let n=zt(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=zt(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function Eu(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(...zt(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Tu(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return wu(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function Fu(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of _u(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&&(Hi(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function Hi(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 Au(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function _u(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=Du(r,u.textSpan.start,o,i.text);l!==null&&s.push(l)}return s}function Du(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=Jt(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function io(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,o=$u(e),a=Date.now(),s=R();Ke(y(o.outputScip),{recursive:!0}),Ke(y(o.outputDb),{recursive:!0});let c=e.languages??dt(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=Ie("reindex.fingerprint",()=>xn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,d;if(e.skipIfUnchanged!==!1&&!Nn(t,o.outputDb)&&zi(o.outputScip)===zi(w(y(o.outputDb),"index.scip"))){let h=Re(t);if(l=h?.clean?we(h,u):void 0,h&&!h.clean&&!Nu(o)){let S=$n(h,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(S)try{Ee({snapshot:S.snapshot,manifest:S.manifest,targetCacheDir:y(o.outputDb),targetProjectRoot:t,persistLease:!1}),Wn(S.snapshot,y(o.outputDb)),r(`Forked shared baseline ${S.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(b){r(`Shared baseline fork failed; continuing locally: ${$(b)}`)}}else if(l){let S=ht(l);if(S){if(!Mu(o,u))try{Ee({snapshot:l,manifest:S,targetCacheDir:y(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(b){r(`Shared generation attach failed; continuing locally: ${$(b)}`)}}else{let b=await Vn(l);if(b.kind==="owner")d=b.release;else if(b.kind==="generation-ready"){let P=ht(l);if(P)try{Ee({snapshot:l,manifest:P,targetCacheDir:y(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(v){r(`Shared generation attach failed after waiting; continuing locally: ${$(v)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let g=mn(w(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 ne("reindex.lock",()=>pl(w(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=fr();try{Pn(o.outputDb,o.outputScip,o.metaPath);let h=Wu(y(o.outputDb));h.removed>0&&r(`Removed ${h.removed} abandoned reindex workspace(s)`);for(let K of h.errors)r(`Could not remove abandoned reindex workspace: ${K}`);let S=null,b=Ie("reindex.reuse-check",()=>(S=Bu({opts:e,paths:o,languages:c,fingerprint:u,start:a,monotonicStart:s,onStatus:r}),S),()=>({languages:c.length,reused:S!==null}));if(b){Xi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let K=At(o.outputDb,b);return K.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${K.reason}`),st(t,y(o.outputDb)),b}await ne("reindex.scip-cli-ready",()=>il(i,r));let P=Uu(o);m=P.runDir;let v,x=await ne("reindex.fresh",async()=>(v=await Gu({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:P,fingerprint:u,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r,writeTelemetry:I}),v),()=>({languages:c.length,reused:v?.reused,skipped:v?.skipped.length}));Xi({snapshot:l,paths:o,projectRoot:t,fingerprint:u,onStatus:r});let X=At(o.outputDb,x);return X.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${X.reason}`),st(t,y(o.outputDb)),x}catch(h){let S=Ze({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:h instanceof Error?h.message:String(h)});So(o.metaPath,S);let b=Qr(o.outputDb,S);throw b.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${b.reason}`),h}finally{if(m){let h=m;try{te(()=>ue(h,{recursive:!0,force:!0}))}catch(S){r(`Warning: temporary reindex workspace was left behind: ${$(S)}`)}}f(),g.release(),d?.()}}function Xi(e){if(e.snapshot)try{let t=Re(e.projectRoot),n=t?we(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=Bn({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=Re(e.projectRoot);return(i?we(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});Un(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 Mu(e,t){if(!E(e.outputScip)||!E(e.outputDb)||!yo(e.metaPath,t))return!1;let n=U(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function Nu(e){if(!E(e.outputScip)||!E(e.outputDb)||!le(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 Yt(e,t,n,r,i,o){try{z(hr({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 $u(e){let t=e.outputScip??w(e.projectRoot,"index.scip"),n=e.outputDb??w(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:w(y(n),"meta.json")}}function Bu(e){let t=U(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!E(e.paths.outputScip)||!E(e.paths.outputDb)||!yo(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;z(H(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),Yt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),U(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(pt(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let n=R()-e.monotonicStart,r=Ze({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return So(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:Vu(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Vu(e,t,n,r){let i=mo(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:ye(i[o]),outputBytes:Se(Zt(e.outputDb,o)),durationMs:0}))}function Uu(e){let t=cn(w(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:w(t,Xe(e.outputScip)),tempOutputDb:w(t,Xe(e.outputDb)),tempMetaPath:w(t,Xe(e.metaPath))}}function Wu(e){let t=[],n;try{n=no(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{ue(w(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${$(o)}`)}return{removed:r,errors:t}}async function Gu(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await ne("reindex.language-indexers",async()=>(n=await Ju(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(", ")}`),qu({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let g=Ie("reindex.publish",()=>tl(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 ne("reindex.publish",()=>el(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 qu(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!E(e.run.paths.outputScip)||!E(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 Ju(e,t){let n=Yu({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[T,tn]of n)tn.reused&&(r.push({language:T,scipPath:tn.scipPath}),i.add(T));for(let T of i)e.onStatus(`Reusing cached ${T} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=U(e.paths.outputDb,e.paths.metaPath),s=le(e.paths.metaPath),c=a.state==="legacy"||a.state==="current",u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),l=o&&!o.reused&&c?hi({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:be(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:be(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:Qt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,d=new Set(l?["typescript"]:[]),p=l?void 0:Hu(e,n),{preparedRuns:g,skippedLanguages:f,languageOutputScipPaths:m}=ol({languages:e.languages.filter(T=>!i.has(T)&&!d.has(T)),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(T=>T.language!=="typescript"||p.missedProjectIds.has(T.id)):g,h=await bi(I,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal),S=[];if(p){Xu(e.paths.outputDb,h,e.writeTelemetry);let T=m.typescript??e.tempPaths.tempOutputScip;S=Ku({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:T,reusedProjects:p.reusedProjects,writeTelemetry:e.writeTelemetry})}let b=[...h,...S],{indexedOutputs:P}=sl(b,f),v=l?[{language:"typescript",scipPath:l.scipPath}]:[],x=[...r,...v,...P];cl(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:Se(l.scipPath)??void 0}]:[],K=Qu(n,[...h,...X],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:x,skippedLanguages:f,reusedLanguages:[...i],languageFingerprints:Zu(n,e.languages),shards:K,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Hu(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=re(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=ri(e.projectRoot,r),o=ei(n.fingerprint.files,r),a=ti(r,i),s=ni(r,o,a),c=le(e.paths.metaPath),l=zu(c,s,f=>E(Qe(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 zu(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===pe&&ut(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(C(a)!==C(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 Xu(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let i=r.id.slice(11),o=Qe(e,i);Ke(y(o),{recursive:!0}),J(n,q(r.scipPath,o))}}function Ku(e){return e.reusedProjects.map((t,n)=>{let r=Qe(e.outputDb,t),i=be(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:Se(i)??void 0}})}function Yu(e){let t=le(e.paths.metaPath),n=mo(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Zt(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!==pe){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(!ut(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(!E(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:o});continue}if(C(s)!==C(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 Qu(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:ye(o.fingerprint),outputBytes:Se(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?ye(s.fingerprint):o?ye(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:ye(o.fingerprint),outputBytes:Se(Qe(n.outputDb,i)),durationMs:0});return r}function ye(e){return Lu("sha256").update(C(e)).digest("hex").slice(0,16)}function Se(e){try{return Ou(e).size}catch{return null}}function Zu(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}async function el(e,t,n,r,i,o,a,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,u=!1;c&&(Ki(e.paths.outputDb,n,e.writeTelemetry),u=Yi(n,e.tempPaths.tempOutputScip,e.onStatus));let l=await ul({run:e,env:t,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..."),yi({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let P=n.map(v=>v.language==="typescript"?{language:v.language,scipPath:s.candidateScipPath}:v);return Ki(e.paths.outputDb,P,e.writeTelemetry),u=Yi(P,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}),Yt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles);let d=Tt(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 P=null,v=null;try{P=new L({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),v=new L({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=er(P,e.fingerprint,s.referenceFragmentsByFile,v);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{P?.close(),v?.close()}}let p=Qt(e.paths.metaPath),g=l.mode==="incremental"&&s?dl(s,l.changedDocumentPaths):It({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=Ze({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(P=>P.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",I={...o};m&&delete I.typescript;let{metadata:h,pruneProjects:S}=ao({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:I,typescriptProjectShardContext:a,lastRefresh:f});h.scipCompanion=m?"deferred":"current",so(e.paths.outputDb,S),en(e.tempPaths.tempMetaPath,h);let b=vn({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 b.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${b.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),On(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),An(y(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),oo(e.paths.outputDb,g,e.onStatus),f}function tl(e,t,n,r,i,o){let a=Qt(e.paths.metaPath),s=null;try{J(e.writeTelemetry,q(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=wr("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}),Yt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Tt(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??=It({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=Ze({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:d}=ao({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:u});return so(e.paths.outputDb,d),en(e.paths.metaPath,l),pt(e.paths.outputDb,e.paths.metaPath),oo(e.paths.outputDb,s,e.onStatus),u}function Qt(e){return ln(le(e)?.fingerprint)}function oo(e,t,n){try{Tr(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 ao(e){let t=nl({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:pe,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function nl(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=le(e.metaPath),n=t?.version===pe?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 so(e,t){let n=ho(e);if(t===null){te(()=>ue(n,{recursive:!0,force:!0}));return}let r;try{r=no(n)}catch{return}for(let i of rl(r,t))te(()=>ue(w(n,i),{force:!0}))}function rl(e,t){let n=new Set(t.map(r=>`${jt(r)}.scip`));return e.filter(r=>!n.has(r))}function Ki(e,t,n){for(let r of t){let i=Zt(e,r.language);Ke(y(i),{recursive:!0}),r.scipPath!==i&&J(n,q(r.scipPath,i))}}async function il(e,t){if(!ae()){if(Cu()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package codebaseiq-windows (installed automatically with codebaseiq). Reinstall codebaseiq with optional dependencies enabled, or follow 'codebaseiq setup' guidance for the exact sidecar package version, or set CODEBASEIQ_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
301
301
|
To install the reviewed version, run: codebaseiq reindex --install-missing
|
|
302
|
-
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!
|
|
303
|
-
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function ol(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?
|
|
302
|
+
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!pr(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
303
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function ol(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?be(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=al({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?co(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function al(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[Xt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??re(e.projectRoot,e.typescriptProjects);return t.length===0?[Xt({...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)=>Xt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:be(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function Xt(e){let t=kt(e.language),n=Ae(t),r=Xn(t,e.projectRoot),i=e.trustProjectTools&&r?Kn(t,e.projectRoot):null,o=ge(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&&!zn(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: codebaseiq reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!vi(t,e.onStatus)){let l=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}}let a=i?.canonicalPath??ge(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=jr({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:Qn(t,e.env,a),...u===void 0?{}:{temporaryRootConfigContent:u},...i?{trustedProjectTool:i}:{}}}}function sl(e,t){let n=new Map;for(let i of e)if(i.skipped)co(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)Cn(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&ro(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function co(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 cl(e,t,n,r,i){if(e.length===0){let o=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
304
304
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
305
305
|
`+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.
|
|
306
306
|
`+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
307
|
-
`))}function
|
|
308
|
-
//# sourceMappingURL=chunk-
|
|
307
|
+
`))}function Yi(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Mn(e.map(o=>o.scipPath),t);return lo(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&ro(e[0].scipPath,t);return!1}async function ul(e){let t;if(ll(e)){let i=w(e.run.tempPaths.runDir,"typescript-affected.db");try{uo(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let o=performance.now();await Qi(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus,!1,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-o).toFixed(0)}ms.`);let a=Vr({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(()=>ue(i,{force:!0})),te(()=>ue(e.run.tempPaths.tempOutputDb,{force:!0})),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await Qi(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n,e.run.opts.signal),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function ll(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!E(e.run.paths.outputDb)||!E(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 dl(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:Pt(e.plan,o,e.projectFileCount)}}async function Qi(e,t,n,r,i=!1,o){if(A(o,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!E(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||uo(e,r);let a=ae();if(!a)throw new Error("scip CLI is not available");let s=await _e({command:a,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:o});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}catch(a){A(o,"Reindex cancelled by its owner.");let s=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:a})}}function uo(e,t){let n=jn(e);lo(n,t)}function lo(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function be(e,t,n){let r=ju(e)||".scip",i=Xe(e,r);return w(y(e),`${i}.${n+1}.${t}${r}`)}async function pl(e,t){for(let n=0;n<2;n++){let r=gl(e,t);if(r)return r;let i=fl(e);if(i&&fo(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await hl(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=lt(e,{parseLegacy:Ye});if(!fn(e,a,{parseLegacy:Ye}))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 gl(e,t){let n=Z(process.pid),r=Pe(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:Ye});if(r.kind==="acquired"&&r.reclaimed){let i=po(r.reclaimed,e);i&&fo(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function fl(e){return po(lt(e,{parseLegacy:Ye}),e)}var Ye=e=>{let t=go(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function po(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return go(e.parsed,t)}function go(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=on(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function fo(e,t){return e?.kind==="manual-cli"&&ml(t?.trigger)}function ml(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function hl(e){return!Y(e.pid)||(Kt(e),Zi(e,"SIGTERM"),await eo(e,2e3))?!0:(Kt(e),Zi(e,"SIGKILL"),eo(e,1e3))}function Zi(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!Y(e.pid))return;Kt(e)}try{process.kill(e.pid,t)}catch{}}async function eo(e,t){let n=R()+t;for(;R()<n;){if(to(e))return!0;await yl(50)}return to(e)}function Kt(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(!de(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function to(e){if(!Y(e.pid))return!0;if(!e.processIdentity)return!1;let t=Z(e.pid);return t!==null&&!de(e.processIdentity,t)}function yl(e){return new Promise(t=>setTimeout(t,e))}function mo(e,t,n){return Object.fromEntries(t.map(r=>{let i=r==="typescript"?bn(n.typescriptProjects):[],o=r==="clojure"?Sl(n.clojureConfigPath):void 0,a=[...kt(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"&&bl(n),...s,clojureConfigPath:o,files:ke(e,{language:r,markerFiles:a})}]}))}function Sl(e){return e?.trim()||void 0}function bl(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Zt(e,t){return w(y(e),"language-indexes",`${t}.scip`)}function ho(e){return w(y(e),"language-indexes","typescript-projects")}function Qe(e,t){return w(ho(e),`${jt(t)}.scip`)}function le(e){try{return ct(ee(_(e,"reindex metadata")))}catch{return null}}function yo(e,t){try{let n=ee(_(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&pn(r)&&C(r.fingerprint)===C(t)&&C([...r.indexedLanguages??[]].sort())===C(t.languages)}catch{return!1}}function en(e,t){yn(e,t,{spacing:2,trailingNewline:!0})}function So(e,t){try{let n=ct(ee(_(e,"reindex metadata")));if(!n)return;en(e,{...n,lastRefresh:t})}catch{}}function Ze(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 C(e){return JSON.stringify(e)}function Df(e,t,n,r){return io({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{kl as a,wl as b,mr as c,dd as d,pd as e,kt as f,Qa as g,$d as h,Bd as i,vi as j,fu as k,io as l,Df as m};
|
|
308
|
+
//# sourceMappingURL=chunk-IEL6Q5W3.js.map
|