scip-query 0.23.0 → 0.24.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 +244 -1
- package/README.md +2 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-H3P6BR5G.js +2 -0
- package/dist/call-graph-VTG2CUOQ.js +2 -0
- package/dist/call-graph-evidence-BociKRpF.d.ts +19 -0
- package/dist/chunk-2BMSSRBH.js +2 -0
- package/dist/{chunk-WIWY3CRX.js → chunk-2GJSD5GY.js} +2 -2
- package/dist/{chunk-W5OXRYGE.js → chunk-2M2LSIMY.js} +3 -3
- package/dist/{chunk-2LDBDR6J.js → chunk-2N6WBNDC.js} +2 -2
- package/dist/{chunk-HOENASQM.js → chunk-2USA3S3P.js} +2 -2
- package/dist/chunk-2VAHDDLM.js +133 -0
- package/dist/chunk-2XWIUW5Z.js +455 -0
- package/dist/chunk-3D4BOXW6.js +20 -0
- package/dist/{chunk-BBCIS4DX.js → chunk-3LO4FST5.js} +2 -2
- package/dist/chunk-3WTY4LP2.js +3 -0
- package/dist/{chunk-UXW33INU.js → chunk-3Z5AMSK6.js} +2 -2
- package/dist/{chunk-4ILJCCXV.js → chunk-44IETFOU.js} +2 -2
- package/dist/chunk-4FR6GQIT.js +2 -0
- package/dist/chunk-4KBTHJLP.js +2 -0
- package/dist/{chunk-SSK6LDPC.js → chunk-5BIKR67W.js} +2 -2
- package/dist/{chunk-IHGQTTVW.js → chunk-5PROPLHI.js} +2 -2
- package/dist/{chunk-TA3QKLLU.js → chunk-5V7EPTII.js} +2 -2
- package/dist/{chunk-JS4PGXMV.js → chunk-62LPZCBQ.js} +2 -2
- package/dist/{chunk-DBRSYFXR.js → chunk-64O2JHQA.js} +2 -2
- package/dist/chunk-6D4F5VWG.js +10 -0
- package/dist/{chunk-BHVUJOCQ.js → chunk-6ERFBC3X.js} +2 -2
- package/dist/{chunk-ILTDAWEF.js → chunk-6ILKOOGH.js} +2 -2
- package/dist/chunk-6MFXCMZC.js +2 -0
- package/dist/chunk-6O7FACKB.js +2 -0
- package/dist/{chunk-XDQMU3BT.js → chunk-6TS3KOXR.js} +2 -2
- package/dist/{chunk-YI2AWIHC.js → chunk-76QOU4PK.js} +2 -2
- package/dist/{chunk-7CYG22FH.js → chunk-7DUI77BN.js} +2 -2
- package/dist/{chunk-IDFEUFKS.js → chunk-7F7T6DCR.js} +2 -2
- package/dist/chunk-7H6VHWWJ.js +2 -0
- package/dist/chunk-7HXT6YLU.js +5 -0
- package/dist/{chunk-DIRJWYBM.js → chunk-7R4V5ES6.js} +4 -4
- package/dist/{chunk-SZHGTCPP.js → chunk-7RIRIADH.js} +2 -2
- package/dist/chunk-7ZLWLOGT.js +2 -0
- package/dist/{chunk-M2O5NY6W.js → chunk-A4WEAK35.js} +2 -2
- package/dist/chunk-AADQLOQ4.js +38 -0
- package/dist/{chunk-OLNV6I6U.js → chunk-AN76MGUE.js} +2 -2
- package/dist/chunk-ANLNLY66.js +2 -0
- package/dist/chunk-ATXPTSEI.js +81 -0
- package/dist/{chunk-YPWBKGFU.js → chunk-AX7IDVFT.js} +2 -2
- package/dist/chunk-B7MPDEAK.js +3 -0
- package/dist/chunk-BBB5FBX4.js +2 -0
- package/dist/{chunk-6I6L7Z62.js → chunk-BHKK5RJY.js} +2 -2
- package/dist/chunk-BJWFVAA5.js +2 -0
- package/dist/{chunk-UHFYCMZO.js → chunk-BKZYTLGE.js} +2 -2
- package/dist/chunk-BL6DCHQP.js +2 -0
- package/dist/{chunk-TEBQMNVI.js → chunk-BOW7SSQH.js} +2 -2
- package/dist/{chunk-OWOOWNJ5.js → chunk-C4RHHCKL.js} +2 -2
- package/dist/{chunk-N2ZSIIGR.js → chunk-C7C6AKAT.js} +6 -6
- package/dist/chunk-CD6M6LS2.js +16 -0
- package/dist/chunk-CFE6PSG6.js +2 -0
- package/dist/{chunk-6V5CNXL6.js → chunk-CFNIGQMT.js} +2 -2
- package/dist/{chunk-GUFSG5TX.js → chunk-CKBUBRYD.js} +2 -2
- package/dist/{chunk-4WNW27SX.js → chunk-CZW5MZ5B.js} +2 -2
- package/dist/chunk-DBBZ63ZX.js +2 -0
- package/dist/{chunk-HCXEQRFF.js → chunk-DBN7DMJB.js} +2 -2
- package/dist/{chunk-6PQNKL3G.js → chunk-DUULLZHZ.js} +2 -2
- package/dist/{chunk-Z4CDXYNQ.js → chunk-DV5Y5NOS.js} +2 -2
- package/dist/chunk-DZOIKCTM.js +3 -0
- package/dist/chunk-E4PKTOL3.js +2 -0
- package/dist/{chunk-EG2CPZMJ.js → chunk-E65ELFKU.js} +2 -2
- package/dist/{chunk-CNO7TOKL.js → chunk-E7QR35ST.js} +2 -2
- package/dist/{chunk-3D3QG236.js → chunk-EFSXAINW.js} +2 -2
- package/dist/{chunk-IL676XCC.js → chunk-EHVEIEQN.js} +2 -2
- package/dist/{chunk-BE7ZZTMC.js → chunk-EHYDXE3Z.js} +2 -2
- package/dist/{chunk-LXABEJX3.js → chunk-EP63Y6LD.js} +2 -2
- package/dist/{chunk-QU5XRYB5.js → chunk-EPX6NQN6.js} +2 -2
- package/dist/{chunk-FESCRNVV.js → chunk-ETC674NS.js} +2 -2
- package/dist/{chunk-OSSESPDX.js → chunk-F5GSBHC6.js} +2 -2
- package/dist/chunk-FH3DGXC6.js +2 -0
- package/dist/{chunk-YEN6CYC7.js → chunk-FI7VGOR4.js} +2 -2
- package/dist/chunk-FJF6VO2P.js +2 -0
- package/dist/{chunk-FRUSVINH.js → chunk-FLMTCX5R.js} +2 -2
- package/dist/chunk-FVFDOIM3.js +2 -0
- package/dist/{chunk-PJFGPYTU.js → chunk-G2HU5WRN.js} +2 -2
- package/dist/{chunk-FIQRSHVM.js → chunk-G4ALYS4J.js} +2 -2
- package/dist/{chunk-UVGEWT4Y.js → chunk-G56I7K4W.js} +2 -2
- package/dist/{chunk-WOIKCX6A.js → chunk-GC4DG2V5.js} +2 -2
- package/dist/chunk-GG45PK4S.js +4 -0
- package/dist/{chunk-XBGWL66K.js → chunk-GHNPACNP.js} +2 -2
- package/dist/{chunk-IICPE7B2.js → chunk-GINH3YQU.js} +2 -2
- package/dist/{chunk-HLZTEXRA.js → chunk-GTZZVLKJ.js} +2 -2
- package/dist/chunk-GXXW5ZHH.js +2 -0
- package/dist/{chunk-B5D7QPBE.js → chunk-HAXXKRTD.js} +2 -2
- package/dist/chunk-HEZWBAZY.js +2 -0
- package/dist/chunk-HMEWLMML.js +2 -0
- package/dist/{chunk-QUU5OBVK.js → chunk-HOBOVYPO.js} +2 -2
- package/dist/{chunk-XGZEP6GR.js → chunk-HRFQ6GW5.js} +2 -2
- package/dist/{chunk-MPQ4OTBM.js → chunk-HX4X7KG3.js} +2 -2
- package/dist/{chunk-FDLOBR6P.js → chunk-HYT2R7LX.js} +2 -2
- package/dist/chunk-IKQVBVQL.js +40 -0
- package/dist/chunk-J6GLBBRK.js +4 -0
- package/dist/{chunk-ZTI4SBFV.js → chunk-J7A4PWFX.js} +2 -2
- package/dist/{chunk-OSR2GEHQ.js → chunk-JCSAZ35V.js} +2 -2
- package/dist/{chunk-ESIQ66Z7.js → chunk-JDU2IV3A.js} +2 -2
- package/dist/chunk-JFMI5SGB.js +4 -0
- package/dist/{chunk-W6STWDQI.js → chunk-JJP37RGX.js} +2 -2
- package/dist/chunk-JZ2A7LDM.js +5 -0
- package/dist/chunk-KNLQGXVH.js +80 -0
- package/dist/chunk-KVQCECPR.js +2 -0
- package/dist/{chunk-SQXRS7BG.js → chunk-KXXORBZ2.js} +2 -2
- package/dist/{chunk-DIUFNHRJ.js → chunk-L5KYH6U3.js} +2 -2
- package/dist/chunk-L6XHYJPZ.js +21 -0
- package/dist/{chunk-2GRUZAQF.js → chunk-L7KTFEAV.js} +2 -2
- package/dist/{chunk-QBE3YX64.js → chunk-LDXHR5EL.js} +2 -2
- package/dist/{chunk-HEHOQQKH.js → chunk-MHGDSBFX.js} +2 -2
- package/dist/{chunk-PWWAJSKV.js → chunk-MLQVVDG3.js} +2 -2
- package/dist/chunk-MOKUWRHO.js +3 -0
- package/dist/{chunk-VQILFTEH.js → chunk-MPYAPMNE.js} +2 -2
- package/dist/{chunk-UICY4GTQ.js → chunk-MV6SPXCR.js} +2 -2
- package/dist/{chunk-HYO3NP5Q.js → chunk-MZPXPSUJ.js} +2 -2
- package/dist/{chunk-VZRNID6A.js → chunk-N55KIE46.js} +2 -2
- package/dist/{chunk-YF5IB2LF.js → chunk-NB4D3BNM.js} +2 -2
- package/dist/{chunk-VVZSBTSU.js → chunk-NGKBOT6G.js} +2 -2
- package/dist/{chunk-NJITK2GP.js → chunk-NJGKXKQF.js} +2 -2
- package/dist/chunk-NJQISBL4.js +8 -0
- package/dist/{chunk-T4N4P2K5.js → chunk-NJT3ZEKY.js} +2 -2
- package/dist/{chunk-FPYLNQPT.js → chunk-NKMKZP6A.js} +2 -2
- package/dist/chunk-NODFZ6ED.js +2 -0
- package/dist/{chunk-BRV7PIFF.js → chunk-NSM5IEVW.js} +2 -2
- package/dist/{chunk-3WR4E3A3.js → chunk-NTGUVNR2.js} +2 -2
- package/dist/{chunk-VUPHCS7Y.js → chunk-NU3KFF2O.js} +2 -2
- package/dist/chunk-NWLVNU66.js +557 -0
- package/dist/{chunk-D4N5SQ2M.js → chunk-NYKZMCRC.js} +2 -2
- package/dist/{chunk-VNLGKHS6.js → chunk-O6BUXZEH.js} +2 -2
- package/dist/chunk-ODPDP7A4.js +3 -0
- package/dist/{chunk-JTQVMR42.js → chunk-OHIV323X.js} +2 -2
- package/dist/chunk-OIAPEKMT.js +3 -0
- package/dist/chunk-OIOC5EHF.js +3 -0
- package/dist/{chunk-YBGKCQIS.js → chunk-ONPPQM4G.js} +2 -2
- package/dist/{chunk-64BFSI5I.js → chunk-OUHEZBYI.js} +2 -2
- package/dist/{chunk-L6PJPETJ.js → chunk-OVGYW7UD.js} +2 -2
- package/dist/{chunk-I55I7XXP.js → chunk-OYKU4B3Y.js} +2 -2
- package/dist/{chunk-J66VOFW6.js → chunk-POBJ6FR2.js} +2 -2
- package/dist/{chunk-CWFP7GM5.js → chunk-PSZPMMWN.js} +2 -2
- package/dist/chunk-PXTRBKRK.js +3 -0
- package/dist/{chunk-HKGFPJ4T.js → chunk-Q5JRIHT3.js} +2 -2
- package/dist/{chunk-P42EIXTA.js → chunk-Q7ATHARX.js} +2 -2
- package/dist/{chunk-JYR66JN5.js → chunk-Q7CSKIDM.js} +2 -2
- package/dist/{chunk-TRNAEQ6P.js → chunk-QBQE7ZJ5.js} +2 -2
- package/dist/{chunk-DULC3QFP.js → chunk-QH22UIXP.js} +2 -2
- package/dist/chunk-QXCKQTKR.js +60 -0
- package/dist/{chunk-ODDUPDP7.js → chunk-RBAD4GJ2.js} +5 -5
- package/dist/{chunk-IZDPJ2QI.js → chunk-RMDPFPNW.js} +2 -2
- package/dist/chunk-ROPJDEJZ.js +4 -0
- package/dist/{chunk-EKV5HX33.js → chunk-RVZC6TJE.js} +2 -2
- package/dist/{chunk-XFA4SSO3.js → chunk-S4QZBKSR.js} +2 -2
- package/dist/{chunk-D2DHWI3D.js → chunk-SCPMZ73U.js} +2 -2
- package/dist/{chunk-PZL5T7SU.js → chunk-SIAP5RGI.js} +2 -2
- package/dist/{chunk-7IWV2EG3.js → chunk-SIX4RFR3.js} +2 -2
- package/dist/{chunk-DYGHBZ2N.js → chunk-SKKXTABJ.js} +2 -2
- package/dist/{chunk-F7DY272B.js → chunk-SSRFUQBD.js} +2 -2
- package/dist/chunk-SYVJEEUJ.js +3 -0
- package/dist/{chunk-FGA2U4OR.js → chunk-T3CZAZSI.js} +2 -2
- package/dist/chunk-T3I6NHBH.js +2 -0
- package/dist/{chunk-EQHFIL6T.js → chunk-T6DWDI5E.js} +2 -2
- package/dist/chunk-T6HRIROJ.js +7 -0
- package/dist/{chunk-GSP44ENC.js → chunk-TAA7HXHE.js} +2 -2
- package/dist/{chunk-BQGB4HBD.js → chunk-TJ2JQYT3.js} +2 -2
- package/dist/{chunk-XPDPNWTQ.js → chunk-TULNMD5T.js} +19 -19
- package/dist/chunk-U2FPY5XA.js +3 -0
- package/dist/chunk-U3SXIMII.js +38 -0
- package/dist/{chunk-NOGJXYFO.js → chunk-U6KCHXJ4.js} +2 -2
- package/dist/chunk-UH3XSKS5.js +9 -0
- package/dist/{chunk-AFHTBORT.js → chunk-UIFUZVCC.js} +2 -2
- package/dist/{chunk-7BWFZPPZ.js → chunk-UXKURIVI.js} +2 -2
- package/dist/{chunk-2E7CX53V.js → chunk-V2RBODHL.js} +2 -2
- package/dist/{chunk-KLFEXGQA.js → chunk-VBKUWB6N.js} +2 -2
- package/dist/{chunk-WUN6KBHV.js → chunk-VBV6ALJE.js} +2 -2
- package/dist/{chunk-GZIUDL6G.js → chunk-VDGFWCQV.js} +2 -2
- package/dist/chunk-VDSDOEWF.js +2 -0
- package/dist/{chunk-WDNVY4E7.js → chunk-VZPWVCLN.js} +2 -2
- package/dist/chunk-WDSFQDPN.js +2 -0
- package/dist/{chunk-CIYLO6SI.js → chunk-WFA35BGR.js} +2 -2
- package/dist/{chunk-LMZ5PRUV.js → chunk-WLMP3OCW.js} +2 -2
- package/dist/{chunk-3SVF22I5.js → chunk-WSA52GOR.js} +2 -2
- package/dist/{chunk-VMPRET3I.js → chunk-X3YVZAKZ.js} +2 -2
- package/dist/{chunk-GYIZ4NXB.js → chunk-X6OGVFIT.js} +2 -2
- package/dist/{chunk-6HFCYNYE.js → chunk-XKXTR6ZI.js} +2 -2
- package/dist/{chunk-6VVV4WRR.js → chunk-Y5DFAW5W.js} +2 -2
- package/dist/chunk-YSYPDRD5.js +3 -0
- package/dist/{chunk-TQPCBMWT.js → chunk-ZFVPWH62.js} +2 -2
- package/dist/chunk-ZGIHTH27.js +2 -0
- package/dist/{chunk-OR2E3AGZ.js → chunk-ZGIQN2SX.js} +2 -2
- package/dist/{chunk-WNTFFKAX.js → chunk-ZHG4WAHR.js} +2 -2
- package/dist/{chunk-DTZCKZEU.js → chunk-ZKB2XUEN.js} +2 -2
- package/dist/chunk-ZLMXIQLC.js +21 -0
- package/dist/chunk-ZMCQIHI4.js +2 -0
- package/dist/cli-main.js +2 -2
- package/dist/code-TAVIKWJI.js +2 -0
- package/dist/code-result-json-5FEFQCAQ.js +2 -0
- package/dist/{command-descriptors-P34VABY5.js → command-descriptors-7BKH53Y3.js} +124 -124
- package/dist/dataflow-GFBTVDH3.js +2 -0
- package/dist/dependence-slice-GWGQCODG.js +2 -0
- package/dist/deps-4QHVDPYA.js +2 -0
- package/dist/direct-navigation-4UBC6HNW.js +3 -0
- package/dist/entry-map-QCTF4RVY.js +2 -0
- package/dist/files-M2UBF5HJ.js +2 -0
- package/dist/frontend-profile-roles-D7eCum8P.d.ts +10 -0
- package/dist/{health-CPp2Jf1Z.d.ts → health-BI2a9WPy.d.ts} +60 -2
- package/dist/hierarchy-2UIHRLW4.js +2 -0
- package/dist/imports-WIE3YZOB.js +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/members-YKD636DA.js +2 -0
- package/dist/methods-VDF4IMYG.js +2 -0
- package/dist/output-continuation-command-4UMDOOLO.js +3 -0
- package/dist/output-pagination-2GME6OPY.js +19 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-XEQTRCV5.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -0
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +20 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -0
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +28 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.d.ts +50 -23
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +4 -3
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +9 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +19 -3
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +22 -3
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +17 -3
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +7 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +22 -6
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +16 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/query-service-fastpath.js +5 -5
- package/dist/query-service-server.js +2 -2
- package/dist/refs-JNK5CLM7.js +2 -0
- package/dist/refs-pagination-6BLRYGMV.js +2 -0
- package/dist/reindex-worker.js +10 -10
- package/dist/reindex.js +18 -18
- package/dist/runtime.js +4 -4
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/slice-PHPVNCWX.js +2 -0
- package/dist/surface-MQX5MPIV.js +2 -0
- package/dist/{symbol-resolution-WD5EU5JE.js → symbol-resolution-DBLVXLBC.js} +2 -2
- package/dist/system-JOPKV4OG.js +2 -0
- package/dist/trace-I2P2YFH4.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/value-flow-JJVMF7NP.js +2 -0
- package/dist/watch-server.js +3 -3
- package/docs/COMMAND_REFERENCE.md +2 -2
- package/docs/DETECTOR_GUIDE.md +51 -12
- package/docs/accuracy-audit-checklist.md +36 -13
- package/docs/locality-analyzer-design.md +9 -9
- package/package.json +2 -2
- package/skills/conductor/SKILL.md +110 -0
- package/skills/conductor/agents/openai.yaml +4 -0
- package/skills/principal-maintainability-review/SKILL.md +273 -0
- package/skills/principal-maintainability-review/agents/openai.yaml +4 -0
- package/skills/scip-calibrate/SKILL.md +102 -0
- package/skills/scip-calibrate/agents/openai.yaml +4 -0
- package/skills/scip-claim-audit/SKILL.md +113 -0
- package/skills/scip-claim-audit/agents/openai.yaml +4 -0
- package/skills/scip-probe-reachability/SKILL.md +93 -0
- package/skills/scip-probe-reachability/agents/openai.yaml +4 -0
- package/skills/scip-root-cause/SKILL.md +160 -0
- package/skills/scip-root-cause/agents/openai.yaml +4 -0
- package/skills/scip-system-compression/SKILL.md +252 -0
- package/skills/scip-system-compression/agents/openai.yaml +4 -0
- package/skills/scip-system-compression/references/compression-atlas.md +116 -0
- package/skills/scip-system-compression/references/compression-patterns.md +87 -0
- package/skills/scip-twin-drift/SKILL.md +109 -0
- package/skills/scip-twin-drift/agents/openai.yaml +4 -0
- package/dist/by-kind-XI2CSWEY.js +0 -2
- package/dist/call-graph-UONR6JR5.js +0 -2
- package/dist/call-graph-evidence-lZa2dwQA.d.ts +0 -11
- package/dist/chunk-2R3V3PSD.js +0 -4
- package/dist/chunk-2WC2OEDO.js +0 -4
- package/dist/chunk-3FHOF22C.js +0 -21
- package/dist/chunk-3JKSW6LJ.js +0 -2
- package/dist/chunk-3L2ZBPEX.js +0 -133
- package/dist/chunk-3PJABJSU.js +0 -2
- package/dist/chunk-4FTZ4P5G.js +0 -2
- package/dist/chunk-4UX2F3JX.js +0 -2
- package/dist/chunk-5ENOG4VP.js +0 -61
- package/dist/chunk-66DVSJQG.js +0 -455
- package/dist/chunk-AVRYW5OZ.js +0 -2
- package/dist/chunk-BDUVI7TO.js +0 -3
- package/dist/chunk-CEEZJXEF.js +0 -2
- package/dist/chunk-CJZXN4NU.js +0 -2
- package/dist/chunk-COF23M5F.js +0 -2
- package/dist/chunk-DHUIOLDT.js +0 -2
- package/dist/chunk-DRENNWRG.js +0 -2
- package/dist/chunk-E5R6AQ73.js +0 -40
- package/dist/chunk-E73UNJTF.js +0 -38
- package/dist/chunk-EVFUMY4R.js +0 -3
- package/dist/chunk-FBN2FGXG.js +0 -2
- package/dist/chunk-FFRKR4EQ.js +0 -2
- package/dist/chunk-GAS2LJMP.js +0 -3
- package/dist/chunk-HVF5VBG6.js +0 -2
- package/dist/chunk-JGKUET5J.js +0 -3
- package/dist/chunk-JWTGMPIT.js +0 -80
- package/dist/chunk-KFOYCQAJ.js +0 -9
- package/dist/chunk-KYSDI3GE.js +0 -5
- package/dist/chunk-LDVT66YM.js +0 -2
- package/dist/chunk-LQRQN2XA.js +0 -2
- package/dist/chunk-MNV5FSBW.js +0 -3
- package/dist/chunk-MV3CDXPI.js +0 -38
- package/dist/chunk-N5B2NILC.js +0 -5
- package/dist/chunk-NOYBFVJA.js +0 -554
- package/dist/chunk-NWQXSFFU.js +0 -3
- package/dist/chunk-OLIWTZI3.js +0 -3
- package/dist/chunk-PP7KNN7L.js +0 -2
- package/dist/chunk-PU7T5QYQ.js +0 -2
- package/dist/chunk-QGVTFRY2.js +0 -7
- package/dist/chunk-QOJONDS7.js +0 -2
- package/dist/chunk-RBLQNW26.js +0 -20
- package/dist/chunk-RTQ7NEKG.js +0 -81
- package/dist/chunk-TPFHAQ2G.js +0 -2
- package/dist/chunk-TQZV7KV4.js +0 -2
- package/dist/chunk-TY7CRN3Z.js +0 -2
- package/dist/chunk-W7CXK74K.js +0 -2
- package/dist/chunk-WB3WYIRE.js +0 -4
- package/dist/chunk-WK46TNUM.js +0 -3
- package/dist/chunk-WYCTJDVR.js +0 -2
- package/dist/chunk-XRYABF57.js +0 -8
- package/dist/chunk-YPWHBBIS.js +0 -2
- package/dist/chunk-YSH6U3L4.js +0 -3
- package/dist/chunk-YU5DZUZI.js +0 -10
- package/dist/chunk-YWO5DDRC.js +0 -16
- package/dist/chunk-ZF5KHH7C.js +0 -2
- package/dist/chunk-ZOHS7AQV.js +0 -21
- package/dist/code-MI6F2TTU.js +0 -2
- package/dist/code-result-json-FXALY4HE.js +0 -2
- package/dist/dataflow-4KEMJPC6.js +0 -2
- package/dist/dependence-slice-R7FPWD5M.js +0 -2
- package/dist/deps-7EMQUYUT.js +0 -2
- package/dist/direct-navigation-6YO234F2.js +0 -3
- package/dist/entry-map-KOOLR26E.js +0 -2
- package/dist/files-OPIPJIGZ.js +0 -2
- package/dist/hierarchy-QPD2CAER.js +0 -2
- package/dist/imports-M6HUXRXC.js +0 -2
- package/dist/members-I5MEFOCT.js +0 -2
- package/dist/methods-5JYGGHXA.js +0 -2
- package/dist/output-continuation-command-UPQAAKBP.js +0 -3
- package/dist/output-pagination-3OFL2MJV.js +0 -19
- package/dist/project-reindex-UKKQ5PLS.js +0 -3
- package/dist/refs-PSU4JZZW.js +0 -2
- package/dist/refs-pagination-JG6CJMRC.js +0 -2
- package/dist/slice-HYRATV64.js +0 -2
- package/dist/surface-VTGDYWF5.js +0 -2
- package/dist/system-LRQNFOR2.js +0 -2
- package/dist/trace-F4B6OLL4.js +0 -2
- package/dist/value-flow-VRPZY72V.js +0 -2
package/dist/reindex-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Ce,b as xn,c as En,d as
|
|
1
|
+
import{a as Ce,b as xn,c as En,d as vn,e as In,f as _n,g as Tn,h as wn}from"./chunk-LEECKFCJ.js";import{a as Ne,b as Ae,c as or}from"./chunk-3LO4FST5.js";import{a as jr}from"./chunk-ILMHV3KM.js";import{a as Pt,b as Cr}from"./chunk-Q7ATHARX.js";import{a as dn,b as ln}from"./chunk-BKVWUP7Y.js";import{e as Yn,f as Qn,g as Kn,i as Vn}from"./chunk-JJP37RGX.js";import"./chunk-HX4X7KG3.js";import{b as Xn}from"./chunk-JCSAZ35V.js";import"./chunk-NJGKXKQF.js";import"./chunk-FI7VGOR4.js";import"./chunk-WRQXLNYE.js";import{b as Wn,c as De,d as Me,e as Hn,f as Jn,g as zn}from"./chunk-L7KTFEAV.js";import"./chunk-2USA3S3P.js";import"./chunk-YUKYB54I.js";import"./chunk-BJT7LSPK.js";import{a as de,b as Oe,c as he,d as Nn,e as Ln,f as An,g as $n,h as Gn,j as Or}from"./chunk-CZW5MZ5B.js";import{a as hn,b as yn}from"./chunk-F4FNK44D.js";import{a as $}from"./chunk-VZPWVCLN.js";import{b as ue}from"./chunk-FVFDOIM3.js";import"./chunk-2VAHDDLM.js";import{a as ke}from"./chunk-YXPUP5G2.js";import"./chunk-BL6DCHQP.js";import{a as sn,b as cn,c as Ie,d as le,e as Zn,f as er,h as St,i as sr,n as Fr}from"./chunk-7RIRIADH.js";import{a as qe,b as Ir,d as _r}from"./chunk-G4ALYS4J.js";import{a as xt}from"./chunk-MXNGIEPU.js";import{b as Tr,c as wr,d as Rt}from"./chunk-EHYDXE3Z.js";import"./chunk-2OOY75BW.js";import{A as bt,B as hr,C as yr,D as Ue,E as Sr,F as br,G as Pr,c as ht,e as tr,f as Q,g as K,h as Le,i as nr,j as rr,k as ir,l as ar,m as $e,n as cr,o as dr,p as lr,q as ur,r as pr,s as gr,t as fr,u as Ge,v as B,w as Be,y as mr}from"./chunk-RMDPFPNW.js";import{a as Sn,b as A,d as Rn}from"./chunk-WYPL7GF7.js";import"./chunk-T3I6NHBH.js";import{a as Un,d as yt,l as qn}from"./chunk-ATXPTSEI.js";import{c as ae,d as me,e as Te,g as ut,h as gn}from"./chunk-CKBUBRYD.js";import"./chunk-MWN53KRN.js";import"./chunk-IW5XQG5G.js";import{b as bn,c as ft,d as Pn}from"./chunk-3AF4TUFK.js";import{b as Fe,c as Bn,f as Rr,j as xr,k as Er,l as vr}from"./chunk-T3CZAZSI.js";import{a as oe}from"./chunk-B3PYOSCX.js";import"./chunk-H5EXS3HM.js";import{a as fn,e as E,f as G,g as mn}from"./chunk-HGFDYOVB.js";import{a as ve,b as X,c as q,d as C}from"./chunk-JFMEXGFE.js";import{A as gt,C as we,G as je,N as Cn,O as Y,P as se,Q as ce,R as jn,S as On,T as mt,W as Fn,a as _e,b as un,c as lt,d as pn,ea as kn,f as W,fa as Dn,ga as Mn,h as M,q as pt}from"./chunk-7HXT6YLU.js";import{a as an,c as Ee,f as ie,g as ge,h as fe,i as on}from"./chunk-7F45LJKI.js";import{createHash as Rc}from"crypto";import{existsSync as L,mkdirSync as rt,mkdtempSync as xc,readdirSync as ua,renameSync as pa,rmSync as ee,statSync as Qt}from"fs";import{basename as tt,dirname as x,extname as Ec,join as O,resolve as Zi}from"path";import{platform as ea}from"os";import{execFileSync as Ua}from"child_process";import{constants as qa,copyFileSync as kr,linkSync as Wa,rmSync as Ha,statSync as Ja}from"fs";import{platform as za}from"os";var Xa=Object.freeze({size:e=>Ja(e).size,clone:Va,copy:(e,t)=>kr(e,t),link:(e,t)=>Wa(e,t),remove:e=>Ha(e,{force:!0})}),Ya=new Set(["EXDEV","EPERM","EMLINK","ENOTSUP","EOPNOTSUPP","ENOSYS","EINVAL"]),Qa=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function V(e,t,n=Xa,r={}){let a=n.size(e);n.remove?.(t);try{return n.clone(e,t),{method:"reflink",bytes:a}}catch(i){if(!eo(i))throw i}if(r.shareImmutable&&n.link)try{return n.link(e,t),{method:"link",bytes:a}}catch(i){if(!Ka(i))throw i}return n.copy(e,t),{method:"copy",bytes:a}}function Ka(e){let t=e?.code;return typeof t=="string"&&Ya.has(t)}function Va(e,t){if(za()!=="darwin"){kr(e,t,qa.COPYFILE_FICLONE_FORCE);return}try{Ua("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"]})}catch(n){throw Za(n)}}function Za(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 eo(e){let t=e?.code;return t!==void 0&&Qa.has(t)}function Dr(){return{reflinkedBytes:0,fallbackCopiedBytes:0,incrementalWrittenBytes:0}}function Z(e,t){t.method==="reflink"||t.method==="link"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}function We(e,t){if(!Number.isSafeInteger(t)||t<0)throw new Error("incremental write bytes must be a non-negative integer");e.incrementalWrittenBytes=(e.incrementalWrittenBytes??0)+t}import{dirname as to,join as no}from"path";function Mr(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:async({projectRoot:t,dbPath:n,onStatus:r})=>{let a=new $({projectRoot:t,dbPath:n,indexPath:e.indexPath??no(to(n),"index.scip"),...e.evidenceDbPath?{evidenceDbPath:e.evidenceDbPath}:{}}),i,o=!1,s=!1;try{let d=e.reuseExisting||e.affectedFiles?Vn(a):null;e.reuseExisting&&d?.extractorVersion===Yn?(i=d,o=!0):(i=await Qn(a,{...d?{previousGraph:d}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{},...e.forceDerivedRebuild?{forceDerivedRebuild:!0}:{},profileSpan:E}),s=(i.coverage.filesReused??0)>0)}finally{a.close()}o||Kn(n,i);let c={reused:o,incrementallyUpdated:s,observations:i.observations.length,links:i.links.length,frontiers:i.frontiers.length,filesScanned:i.coverage.filesScanned,errors:i.coverage.extractionErrors.length,phases:i.coverage.phases};return r?.(c.reused?`Reused ${c.observations} cached runtime-boundary observation(s) and ${c.links} link(s).`:c.incrementallyUpdated?`Incrementally refreshed runtime-boundary observations (${c.filesScanned-(i.coverage.filesReused??0)} file(s) extracted, ${i.coverage.filesReused??0} reused) and rebuilt ${c.links} link(s).`:`Extracted ${c.observations} runtime-boundary observation(s), ${c.links} link(s), and ${c.frontiers} unresolved frontier(s).`),!o&&i.coverage.phases&&r?.(`Runtime-boundary phases: ${i.coverage.phases.map(d=>`${d.id} ${d.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}function ye(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 Se(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let a=new Set(n),i=ye(e),o=new Set(i.reasons);return r.some(s=>!a.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),Nr(r,a,o)):o.size>0?Nr(r,a,o):{mode:"closure",changedFiles:r,affectedFiles:ro(r,t,a),reasons:[]}}function Nr(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function ro(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let c of s){if(!n.has(c))continue;let d=r.get(c)??new Set;d.add(o),r.set(c,d)}let a=new Set(e),i=[...e];for(let o=0;o<i.length;o+=1){let s=i[o];if(s!==void 0)for(let c of r.get(s)??[])a.has(c)||(a.add(c),i.push(c))}return[...a].sort()}import{createHash as io}from"crypto";import{existsSync as ao}from"fs";import{dirname as oo,join as Lr}from"path";var so="<global-symbols>";function co(e){let t=[];for(let n of e.all(`
|
|
2
2
|
SELECT relative_path, language, position_encoding, text
|
|
3
3
|
FROM documents
|
|
4
4
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -55,7 +55,7 @@ import{a as Ce,b as xn,c as En,d as In,e as vn,f as _n,g as Tn,h as wn}from"./ch
|
|
|
55
55
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
56
56
|
)
|
|
57
57
|
`))t.push({relativePath:so,kind:"global-symbol",values:Et(n)});return lo(t)}function lo(e){let t=new Map;for(let r of e){let a=JSON.stringify([r.kind,r.values]),i=t.get(r.relativePath)??[];i.push(a),t.set(r.relativePath,i)}let n=new Map;for(let[r,a]of[...t].sort(([i],[o])=>i.localeCompare(o))){let i=io("sha256");for(let o of a.sort())i.update(String(Buffer.byteLength(o))),i.update(":"),i.update(o),i.update(`
|
|
58
|
-
`);n.set(r,i.digest("hex"))}return n}function uo(e,t){let n=[],r=[],a=[],i=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let c=e.get(s),d=t.get(s);c===void 0?n.push(s):d===void 0?a.push(s):c!==d?r.push(s):i.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:a,changedFiles:[...n,...r,...a].sort(),unchangedFiles:i}}function It(e,t,n){let r=new Set(e.affectedFiles),a=new Set(t.changedFiles),i=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),o=e.affectedFiles.filter(c=>!a.has(c)).sort(),s=t.changedFiles.length-i.length;return{passed:i.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:i,extraFiles:o}}function vt(e,t=yo){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,a=t.wallNow??t.now,i=r(),o=(d,l)=>{let g=r();return Br(e.refreshResult,d,n?g:a(),Math.max(0,g-i),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");if(e.refreshResult==="rebuilt"&&q(e.previousSnapshot,e.currentSnapshot).changes.length===0)return o("no-input-changes");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let d=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=q(e.previousSnapshot,e.currentSnapshot),g=new Set(d),p=l.changes.length>0&&!ye(l).fullProject&&l.changes.every(j=>g.has(j.path)),f=Se(l,p?t.dependencyGraph(s):new Map,d),R=uo(t.factDigests(s),t.factDigests(c)),T=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?T:a()).toISOString(),durationMs:Math.max(0,T-i),manifest:l,plan:f,comparison:R,evaluation:It(f,R,d.length)}}catch(d){return o("oracle-error",d instanceof Error?d.message:String(d))}finally{Ar(s),Ar(c)}}function $r(e,t,n,r=Date.now()){return Br(e,t,r,0,n)}function po(e){let t=oo(e);return{latestPath:Lr(t,"affected-shadow-latest.json"),historyPath:Lr(t,"affected-shadow.jsonl")}}function Gr(e,t,n=So){let r=po(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var go=8*1024*1024,fo=Zn;function mo(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 ho(e,t,n=go){er(e,mo(t),{maxSegmentBytes:n,previousSuffix:fo})}function Et(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 yo={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:C,databaseExists:e=>ao(e),openDatabase:(e,t,n)=>new $({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>ke(e),dependencyGraph:e=>Wn(e),factDigests:e=>co(e)},So={appendHistory:ho,writeLatest:(e,t)=>Fe(e,t,{spacing:2,trailingNewline:!0})};function Br(e,t,n,r,a){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...a?{error:a}:{}}}function Ar(e){try{e?.close()}catch{}}import{readdirSync as bo}from"fs";import{isAbsolute as Ur,join as Po,resolve as Ro}from"path";var He="@sourcegraph/scip-typescript@0.4.0",qr="scip-python-plus@0.7.5",Wr="github.com/sourcegraph/scip-go@v0.2.7",Hr="scip-dotnet@0.2.14",xo="scip_dart@1.6.2",Eo={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar","--no-global-caches"]}:{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]},markerFiles:[...M.typescript],installMethods:[{label:"npm",identity:He,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",He]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]}),markerFiles:[...M.javascript],installMethods:[{label:"npm",identity:He,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",He]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:de.language,indexerBinary:de.indexerBinary,checkCommand:`${de.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:de.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...M.rust],installMethods:[],installUrl:de.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...M.python],installMethods:[{label:"npm",identity:qr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",qr]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let a=["-root",e,"-output",t];return r&&a.push("-config",Ur(r)?r:Ro(e,r)),{binary:n,args:a}},markerFiles:[...M.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...M.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...M.go],installMethods:[{label:"go install",identity:Wr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Wr]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...M.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...M.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Jr(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...M.csharp],installMethods:[{label:"dotnet",identity:Hr,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",Jr(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...M.vb],installMethods:[{label:"dotnet",identity:Hr,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...M.dart],installMethods:[{label:"dart pub",identity:xo,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})=>Ur(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...M.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function zr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function _t(e){return Eo[e]}function Jr(e,t){let n;try{n=bo(e)}catch{return null}for(let r of t)for(let a of n)if(a.endsWith(r))return Po(e,a);return null}import{createHash as Io}from"crypto";import{existsSync as wt,rmSync as Xr,statSync as vo}from"fs";import{resolve as _o}from"path";import Kr from"better-sqlite3";var To={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}]},wo={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=C(),n=Yr(e.affectedFiles),r=Yr(e.deletedFiles??[],!0),a=new Set(n);if(r.some(s=>!a.has(s)))throw new Error("deleted incremental documents must be included in the affected document set");let i=n.length-r.length;if(jo(e.previousDbPath,e.miniDbPath,e.candidateDbPath),!wt(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!wt(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");E("reindex.publish.sqlite-patch.validate-inputs",()=>{Tt(e.previousDbPath,"previous SQLite generation",!1),Tt(e.miniDbPath,"incremental SQLite mini database")}),e.reuseCandidate?E("reindex.publish.sqlite-patch.reuse-candidate",()=>Tt(e.candidateDbPath,"incremental SQLite candidate",!1)):E("reindex.publish.sqlite-patch.clone",()=>{Xr(e.candidateDbPath,{force:!0});let s=K(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&V(e.writeTelemetry,s)});let o=null;try{o=E("reindex.publish.sqlite-patch.open",()=>{let f=new Kr(e.candidateDbPath,{fileMustExist:!0});return f.pragma("busy_timeout = 5000"),f.pragma("foreign_keys = ON"),f.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ct(f,"main","candidate SQLite generation"),Ct(f,"incremental","incremental SQLite mini database"),f});let{priorAffectedCount:s,previousFactDigests:c}=E("reindex.publish.sqlite-patch.prepare",()=>(ko(o,n,r),{...Do(o,n.length,r.length),previousFactDigests:jt(o,"main",!0)})),d=H(o,"SELECT COUNT(*) AS value FROM main.documents"),l=o.transaction(()=>{E("reindex.publish.sqlite-patch.transaction.symbol-ownership",()=>Mo(o)),E("reindex.publish.sqlite-patch.transaction.shared-definitions",()=>No(o)),E("reindex.publish.sqlite-patch.transaction.delete",()=>Lo(o)),e.onStage?.("after-delete"),E("reindex.publish.sqlite-patch.transaction.reconcile-symbols",()=>Ao(o)),e.onStage?.("after-symbol-reconciliation"),E("reindex.publish.sqlite-patch.transaction.insert",()=>$o(o)),e.onStage?.("after-insert"),E("reindex.publish.sqlite-patch.transaction.prune-symbols",()=>Go(o,e.trustedPriorGeneration===!0)),E("reindex.publish.sqlite-patch.transaction.validate",()=>Bo(o,i,d,s)),e.onStage?.("before-commit")});E("reindex.publish.sqlite-patch.transaction",()=>l.immediate()),e.writeTelemetry&&We(e.writeTelemetry,2*Co(e.candidateDbPath)),E("reindex.publish.sqlite-patch.integrity",()=>Fo(o,"candidate SQLite generation",!e.deferIntegrity&&e.trustedPriorGeneration!==!0));let g=E("reindex.publish.sqlite-patch.validate-facts",()=>Uo(o)),p=[...new Set([...c.keys(),...g.keys()])].filter(f=>c.get(f)!==g.get(f)).sort();return o.exec("DETACH DATABASE incremental"),o.close(),o=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:p,durationMs:C()-t}}catch(s){try{o?.close()}finally{Xr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}function Co(e){let t=0;for(let n of["-wal","-journal"]){let r=`${e}${n}`;wt(r)&&(t+=vo(r).size)}return t}function Yr(e,t=!1){if(!t&&e.length===0)throw new Error("incremental SQLite publication requires affected documents");let n=[...e].sort();for(let r of n)if(!r||r.startsWith("/")||r.includes("\\")||r.split("/").includes(".."))throw new Error(`invalid affected document path: ${r}`);if(new Set(n).size!==n.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return n}function jo(e,t,n){let r=[e,t,n].map(a=>_o(a));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Tt(e,t,n=!0){let r=new Kr(e,{readonly:!0,fileMustExist:!0});try{Ct(r,"main",t),n&&Oo(r,"main",t)}finally{r.close()}}function Ct(e,t,n){for(let[r,a]of Object.entries(To)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:d,pk:l})=>({name:s,type:c.toUpperCase(),notnull:d,pk:l}));if(JSON.stringify(o)!==JSON.stringify(a))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,a]of Object.entries(wo)){let i=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(i?.tbl_name!==a.table||JSON.stringify(o)!==JSON.stringify(a.columns))throw new Error(`${n} schema changed for index ${r}`)}Qr(e,t,"documents",["relative_path"],n),Qr(e,t,"global_symbols",["symbol"],n)}function Qr(e,t,n,r,a){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(d=>d.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${a} lost the unique ${n}(${r.join(", ")}) constraint`)}function Oo(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 Fo(e,t,n){if(e.pragma("foreign_keys",{simple:!0})!==1)throw new Error(`${t} lost foreign-key enforcement`);if(!n)return;let r=e.prepare("PRAGMA main.quick_check").pluck().get();if(r!=="ok")throw new Error(`${t} failed quick_check: ${String(r)}`)}function ko(e,t,n){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID"),e.exec("CREATE TEMP TABLE incremental_deleted_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let r=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)"),a=e.prepare("INSERT INTO temp.incremental_deleted_paths(relative_path) VALUES (?)");e.transaction(o=>{for(let s of o)r.run(s);for(let s of n)a.run(s)})(t)}function Do(e,t,n){let r=H(e,"SELECT COUNT(*) AS value FROM incremental.documents"),a=H(e,`SELECT COUNT(*) AS value
|
|
58
|
+
`);n.set(r,i.digest("hex"))}return n}function uo(e,t){let n=[],r=[],a=[],i=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let c=e.get(s),d=t.get(s);c===void 0?n.push(s):d===void 0?a.push(s):c!==d?r.push(s):i.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:a,changedFiles:[...n,...r,...a].sort(),unchangedFiles:i}}function vt(e,t,n){let r=new Set(e.affectedFiles),a=new Set(t.changedFiles),i=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),o=e.affectedFiles.filter(c=>!a.has(c)).sort(),s=t.changedFiles.length-i.length;return{passed:i.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:i,extraFiles:o}}function It(e,t=yo){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,a=t.wallNow??t.now,i=r(),o=(d,l)=>{let g=r();return Br(e.refreshResult,d,n?g:a(),Math.max(0,g-i),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");if(e.refreshResult==="rebuilt"&&W(e.previousSnapshot,e.currentSnapshot).changes.length===0)return o("no-input-changes");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let d=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),l=W(e.previousSnapshot,e.currentSnapshot),g=new Set(d),p=l.changes.length>0&&!ye(l).fullProject&&l.changes.every(j=>g.has(j.path)),f=Se(l,p?t.dependencyGraph(s):new Map,d),R=uo(t.factDigests(s),t.factDigests(c)),T=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?T:a()).toISOString(),durationMs:Math.max(0,T-i),manifest:l,plan:f,comparison:R,evaluation:vt(f,R,d.length)}}catch(d){return o("oracle-error",d instanceof Error?d.message:String(d))}finally{Ar(s),Ar(c)}}function $r(e,t,n,r=Date.now()){return Br(e,t,r,0,n)}function po(e){let t=oo(e);return{latestPath:Lr(t,"affected-shadow-latest.json"),historyPath:Lr(t,"affected-shadow.jsonl")}}function Gr(e,t,n=So){let r=po(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var go=8*1024*1024,fo=Zn;function mo(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 ho(e,t,n=go){er(e,mo(t),{maxSegmentBytes:n,previousSuffix:fo})}function Et(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 yo={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:C,databaseExists:e=>ao(e),openDatabase:(e,t,n)=>new $({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>ke(e),dependencyGraph:e=>Wn(e),factDigests:e=>co(e)},So={appendHistory:ho,writeLatest:(e,t)=>Fe(e,t,{spacing:2,trailingNewline:!0})};function Br(e,t,n,r,a){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...a?{error:a}:{}}}function Ar(e){try{e?.close()}catch{}}import{readdirSync as bo}from"fs";import{isAbsolute as Ur,join as Po,resolve as Ro}from"path";var He="@sourcegraph/scip-typescript@0.4.0",qr="scip-python-plus@0.7.5",Wr="github.com/sourcegraph/scip-go@v0.2.7",Hr="scip-dotnet@0.2.14",xo="scip_dart@1.6.2",Eo={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar","--no-global-caches"]}:{binary:n,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]},markerFiles:[...M.typescript],installMethods:[{label:"npm",identity:He,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",He]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar","--no-global-caches"]}),markerFiles:[...M.javascript],installMethods:[{label:"npm",identity:He,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",He]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.java],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.scala],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:[...M.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:de.language,indexerBinary:de.indexerBinary,checkCommand:`${de.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:de.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...M.rust],installMethods:[],installUrl:de.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:[...M.python],installMethods:[{label:"npm",identity:qr,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",qr]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let a=["-root",e,"-output",t];return r&&a.push("-config",Ur(r)?r:Ro(e,r)),{binary:n,args:a}},markerFiles:[...M.clojure],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:[...M.ruby],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:[...M.go],installMethods:[{label:"go install",identity:Wr,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Wr]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...M.cpp],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:[...M.c],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Jr(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...M.csharp],installMethods:[{label:"dotnet",identity:Hr,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",Jr(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...M.vb],installMethods:[{label:"dotnet",identity:Hr,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:[...M.dart],installMethods:[{label:"dart pub",identity:xo,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})=>Ur(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...M.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function zr(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function _t(e){return Eo[e]}function Jr(e,t){let n;try{n=bo(e)}catch{return null}for(let r of t)for(let a of n)if(a.endsWith(r))return Po(e,a);return null}import{createHash as vo}from"crypto";import{existsSync as wt,rmSync as Xr,statSync as Io}from"fs";import{resolve as _o}from"path";import Kr from"better-sqlite3";var To={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}]},wo={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=C(),n=Yr(e.affectedFiles),r=Yr(e.deletedFiles??[],!0),a=new Set(n);if(r.some(s=>!a.has(s)))throw new Error("deleted incremental documents must be included in the affected document set");let i=n.length-r.length;if(jo(e.previousDbPath,e.miniDbPath,e.candidateDbPath),!wt(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!wt(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");E("reindex.publish.sqlite-patch.validate-inputs",()=>{Tt(e.previousDbPath,"previous SQLite generation",!1),Tt(e.miniDbPath,"incremental SQLite mini database")}),e.reuseCandidate?E("reindex.publish.sqlite-patch.reuse-candidate",()=>Tt(e.candidateDbPath,"incremental SQLite candidate",!1)):E("reindex.publish.sqlite-patch.clone",()=>{Xr(e.candidateDbPath,{force:!0});let s=V(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&Z(e.writeTelemetry,s)});let o=null;try{o=E("reindex.publish.sqlite-patch.open",()=>{let f=new Kr(e.candidateDbPath,{fileMustExist:!0});return f.pragma("busy_timeout = 5000"),f.pragma("foreign_keys = ON"),f.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ct(f,"main","candidate SQLite generation"),Ct(f,"incremental","incremental SQLite mini database"),f});let{priorAffectedCount:s,previousFactDigests:c}=E("reindex.publish.sqlite-patch.prepare",()=>(ko(o,n,r),{...Do(o,n.length,r.length),previousFactDigests:jt(o,"main",!0)})),d=H(o,"SELECT COUNT(*) AS value FROM main.documents"),l=o.transaction(()=>{E("reindex.publish.sqlite-patch.transaction.symbol-ownership",()=>Mo(o)),E("reindex.publish.sqlite-patch.transaction.shared-definitions",()=>No(o)),E("reindex.publish.sqlite-patch.transaction.delete",()=>Lo(o)),e.onStage?.("after-delete"),E("reindex.publish.sqlite-patch.transaction.reconcile-symbols",()=>Ao(o)),e.onStage?.("after-symbol-reconciliation"),E("reindex.publish.sqlite-patch.transaction.insert",()=>$o(o)),e.onStage?.("after-insert"),E("reindex.publish.sqlite-patch.transaction.prune-symbols",()=>Go(o,e.trustedPriorGeneration===!0)),E("reindex.publish.sqlite-patch.transaction.validate",()=>Bo(o,i,d,s)),e.onStage?.("before-commit")});E("reindex.publish.sqlite-patch.transaction",()=>l.immediate()),e.writeTelemetry&&We(e.writeTelemetry,2*Co(e.candidateDbPath)),E("reindex.publish.sqlite-patch.integrity",()=>Fo(o,"candidate SQLite generation",!e.deferIntegrity&&e.trustedPriorGeneration!==!0));let g=E("reindex.publish.sqlite-patch.validate-facts",()=>Uo(o)),p=[...new Set([...c.keys(),...g.keys()])].filter(f=>c.get(f)!==g.get(f)).sort();return o.exec("DETACH DATABASE incremental"),o.close(),o=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:p,durationMs:C()-t}}catch(s){try{o?.close()}finally{Xr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${s instanceof Error?s.message:String(s)}`,{cause:s})}}function Co(e){let t=0;for(let n of["-wal","-journal"]){let r=`${e}${n}`;wt(r)&&(t+=Io(r).size)}return t}function Yr(e,t=!1){if(!t&&e.length===0)throw new Error("incremental SQLite publication requires affected documents");let n=[...e].sort();for(let r of n)if(!r||r.startsWith("/")||r.includes("\\")||r.split("/").includes(".."))throw new Error(`invalid affected document path: ${r}`);if(new Set(n).size!==n.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return n}function jo(e,t,n){let r=[e,t,n].map(a=>_o(a));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Tt(e,t,n=!0){let r=new Kr(e,{readonly:!0,fileMustExist:!0});try{Ct(r,"main",t),n&&Oo(r,"main",t)}finally{r.close()}}function Ct(e,t,n){for(let[r,a]of Object.entries(To)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:d,pk:l})=>({name:s,type:c.toUpperCase(),notnull:d,pk:l}));if(JSON.stringify(o)!==JSON.stringify(a))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,a]of Object.entries(wo)){let i=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(i?.tbl_name!==a.table||JSON.stringify(o)!==JSON.stringify(a.columns))throw new Error(`${n} schema changed for index ${r}`)}Qr(e,t,"documents",["relative_path"],n),Qr(e,t,"global_symbols",["symbol"],n)}function Qr(e,t,n,r,a){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(d=>d.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${a} lost the unique ${n}(${r.join(", ")}) constraint`)}function Oo(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 Fo(e,t,n){if(e.pragma("foreign_keys",{simple:!0})!==1)throw new Error(`${t} lost foreign-key enforcement`);if(!n)return;let r=e.prepare("PRAGMA main.quick_check").pluck().get();if(r!=="ok")throw new Error(`${t} failed quick_check: ${String(r)}`)}function ko(e,t,n){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID"),e.exec("CREATE TEMP TABLE incremental_deleted_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let r=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)"),a=e.prepare("INSERT INTO temp.incremental_deleted_paths(relative_path) VALUES (?)");e.transaction(o=>{for(let s of o)r.run(s);for(let s of n)a.run(s)})(t)}function Do(e,t,n){let r=H(e,"SELECT COUNT(*) AS value FROM incremental.documents"),a=H(e,`SELECT COUNT(*) AS value
|
|
59
59
|
FROM main.documents d
|
|
60
60
|
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
61
61
|
FROM temp.incremental_affected_paths p
|
|
@@ -241,7 +241,7 @@ import{a as Ce,b as xn,c as En,d as In,e as vn,f as _n,g as Tn,h as wn}from"./ch
|
|
|
241
241
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
242
242
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
243
243
|
${r}
|
|
244
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,g]of Object.entries({documents:a,chunks:i,definitions:o,mentions:s}))for(let p of g){let f=JSON.stringify([l,p]),R=c.get(p.relative_path)??[];R.push(f),c.set(p.relative_path,R)}let d=new Map;for(let[l,g]of[...c].sort(([p],[f])=>p.localeCompare(f))){let p=
|
|
244
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,g]of Object.entries({documents:a,chunks:i,definitions:o,mentions:s}))for(let p of g){let f=JSON.stringify([l,p]),R=c.get(p.relative_path)??[];R.push(f),c.set(p.relative_path,R)}let d=new Map;for(let[l,g]of[...c].sort(([p],[f])=>p.localeCompare(f))){let p=vo("sha256");for(let f of g.sort())p.update(f).update(`
|
|
245
245
|
`);d.set(l,p.digest("hex"))}return d}function H(e,t){return e.prepare(t).get().value}import qo from"better-sqlite3";var Je="idx_mentions_definitions",Wo=["symbol_id","chunk_id"];function Ot(e,t={}){let n=new qo(e),r=[],a=[],i=[];try{return n.transaction(()=>{Ho(n,r),ze(n,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&Zr(n,"global_symbols").some(c=>c.name!=="idx_global_symbols_symbol"&&c.unique&&c.columns.join("\0")==="symbol")?(n.exec('DROP INDEX "idx_global_symbols_symbol"'),a.push("idx_global_symbols_symbol")):ze(n,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let o=ze(n,"idx_chunks_doc_id"),s=Zr(n,"chunks").some(c=>c.name!=="idx_chunks_doc_id"&&c.columns.length>1&&c.columns[0]==="document_id");o?.join("\0")==="document_id"&&s?(n.exec('DROP INDEX "idx_chunks_doc_id"'),a.push("idx_chunks_doc_id")):o&&i.push("idx_chunks_doc_id"),t.analyze!==!1&&n.exec("ANALYZE")})(),{added:r,removed:a,retained:i,analyzed:t.analyze!==!1}}catch(o){if(o.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw o}finally{n.close()}}function Ho(e,t){let n=ei(e,Je);if(n){let r=n.columns.join("\0")===Wo.join("\0"),a=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!a||n.table!=="mentions")throw new Error(`${Je} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${Je}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(Je)}function Zr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:ze(e,n.name)??[]}))}function ze(e,t){return ei(e,t)?.columns??null}function ei(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(a=>a.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{createHash as Jo}from"crypto";import{existsSync as Ft,readdirSync as zo}from"fs";import{dirname as kt,join as Xe,relative as Xo,resolve as Dt,sep as ti}from"path";function ni(e,t){let n=t.includes("."),r={};for(let i of t)r[i]=[];let a=[];for(let i of e){let o=oi(i.path,t);o?r[o].push(i):n?r["."].push(i):a.push(i)}return{files:r,shared:a}}function ri(e,t){let n=new Map;for(let a of e){let i=t[a]?.packageName;i&&n.set(i,a)}let r=new Map;for(let a of e)r.set(a,new Set);for(let a of e){let i=t[a],o=r.get(a);if(!i||i.parseFailed){for(let s of e)s!==a&&o.add(s);continue}for(let s of i.dependencyNames){let c=n.get(s);c&&c!==a&&o.add(c)}for(let s of[...i.pathsTargets,...i.referencesPaths]){let c=oi(s,e);c&&c!==a&&o.add(c)}}return Yo(e,r)}function ii(e,t,n){let r={};for(let a of e){let i=new Map;for(let o of t.files[a]??[])i.set(o.path,o);for(let o of n[a]??[])for(let s of t.files[o]??[])i.set(s.path,s);for(let o of t.shared)i.set(o.path,o);r[a]={files:[...i.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function Mt(e){if(e===".")return"root";let t=Jo("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function ai(e,t){let n=Dt(e),r={};for(let a of t)r[a]=Qo(n,a);return r}function oi(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 Yo(e,t){let n={};for(let r of e){let a=new Set,i=[...t.get(r)??[]];for(;i.length>0;){let o=i.pop();if(!(o===r||a.has(o))){a.add(o);for(let s of t.get(o)??[])s!==r&&!a.has(s)&&i.push(s)}}n[r]=[...a].sort((o,s)=>o.localeCompare(s))}return n}function Qo(e,t){let n=t==="."?e:Xe(e,t),r=Ko(n),a=Vo(n),i=a?Zo(a,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:i.pathsTargets,referencesPaths:i.referencesPaths,parseFailed:r.failed||i.failed}}function Ko(e){let t=Xe(e,"package.json");if(!Ft(t))return{name:void 0,dependencyNames:[],failed:!1};let n=Nt(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,a=new Set;for(let i of["dependencies","devDependencies","peerDependencies"]){let o=n.value[i];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))a.add(s)}return{name:r,dependencyNames:[...a],failed:!1}}function Vo(e){let t=Xe(e,"tsconfig.json");if(Ft(t))return t;let n;try{n=zo(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,a)=>r.localeCompare(a)),n.length>0?Xe(e,n[0]):void 0}function Zo(e,t){let n=Nt(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=es(n.value,e,t),a=si(e,n.value,t,0);return{pathsTargets:a.pathsTargets,referencesPaths:r,failed:a.failed}}function es(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let a=kt(t),i=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let c=ci(s,a,n);c&&i.add(c)}return[...i]}function si(e,t,n,r){let a=ts(t);if(a)return{pathsTargets:ns(a,kt(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let i=rs(t.extends,e,n);if(!i)return{pathsTargets:[],failed:!1};let o=Nt(i);return o.ok?si(i,o.value,n,r+1):{pathsTargets:[],failed:!0}}function ts(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 ns(e,t,n){let r=new Set;for(let a of Object.values(e))if(Array.isArray(a))for(let i of a){if(typeof i!="string")continue;let o=ci(i,t,n);o&&r.add(o)}return[...r]}function rs(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let a=Dt(kt(t),r);if(a.endsWith(".json")||(a=`${a}.json`),!a.split(ti).includes("node_modules")&&pt(n,a)&&Ft(a))return a}function ci(e,t,n){let r=e.replace(/\/?\*+$/,""),a=Dt(t,r===""?".":r);if(!pt(n,a))return;let o=Xo(n,a).split(ti).join("/");return o===""?".":o}function is(e){let t="",n=0,r=!1,a=e.length;for(;n<a;){let i=e[n];if(r){if(t+=i,i==="\\"&&n+1<a){t+=e[n+1],n+=2;continue}i==='"'&&(r=!1),n+=1;continue}if(i==='"'){r=!0,t+=i,n+=1;continue}if(i==="/"&&e[n+1]==="/"){for(n+=2;n<a&&e[n]!==`
|
|
246
246
|
`;)n+=1;continue}if(i==="/"&&e[n+1]==="*"){for(n+=2;n<a&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=i,n+=1}return t}function Nt(e){try{let t=ge(e,{maxBytes:an,inputKind:"TypeScript project manifest"}),n=JSON.parse(is(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import as from"better-sqlite3";import{zstdCompressSync as os}from"zlib";import{setImmediate as di}from"timers/promises";var J=class extends Error{},ss=200,At=2,li=1,cs=2,ds=3,ls=4,us=5,ps=6,mi=1,hi=2,yi=3,gs=7,fs=1,ms=3,hs=5,ys=6,Ss=8,bs=1,ui=64,Ps=[`CREATE TABLE documents (
|
|
247
247
|
id INTEGER PRIMARY KEY,
|
|
@@ -283,17 +283,17 @@ import{a as Ce,b as xn,c as En,d as In,e as vn,f as _n,g as Tn,h as wn}from"./ch
|
|
|
283
283
|
end_char INTEGER NOT NULL,
|
|
284
284
|
FOREIGN KEY (document_id) REFERENCES documents(id),
|
|
285
285
|
FOREIGN KEY (symbol_id) REFERENCES global_symbols(id)
|
|
286
|
-
)`],Rs=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function Lt(e){return e.startsWith("local ")}function pi(e,t,n,r){let a=t,i=0,o=0;for(;a<n;){let s=e[a];a+=1,o<53&&(i+=(s&127)*2**o),(s&128)===0?(r.push(i),i=0,o=0):o+=7}}function gi(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}function xs(e,t){return e.startLine!==t.startLine?e.startLine-t.startLine:e.startChar!==t.startChar?e.startChar-t.startChar:e.endLine!==t.endLine?e.endLine-t.endLine:e.endChar!==t.endChar?e.endChar-t.endChar:e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0}function Es(e,t,n,r){let a=[],i=[],o="",s=0;for(let d of
|
|
287
|
-
`),u.enclosingSymbol===""?null:u.enclosingSymbol)}let F=new Set;
|
|
288
|
-
`;return{configPath:i,content:o,inputPaths:r}})}var Ei="typescript-shard-costs.json",bi=4;function Ii(e){let t;try{t=JSON.parse(on(Ye(e,Ei),"shard cost model"))}catch{return null}if(typeof t!="object"||t===null||t.version!==1)return null;let n=t.samples;return Array.isArray(n)&&n.every(a=>typeof a=="object"&&a!==null&&typeof a.firstPath=="string"&&typeof a.lastPath=="string"&&Number.isFinite(a.totalBytes)&&a.totalBytes>0&&Number.isFinite(a.durationMs)&&a.durationMs>0)?{version:1,samples:n}:null}function vi(e,t){Fe(Ye(e,Ei),t)}function _i(e){let t=(e?.samples??[]).filter(i=>i.totalBytes>0&&i.durationMs>0);if(t.length<2)return(i,o)=>o;let n=t.map(i=>i.durationMs/i.totalBytes).sort((i,o)=>i-o),r=n[Math.floor(n.length/2)];if(!(r>0))return(i,o)=>o;let a=[...t].sort((i,o)=>i.firstPath.localeCompare(o.firstPath));return(i,o)=>{for(let s of a){if(i.localeCompare(s.firstPath)<0)break;if(i.localeCompare(s.lastPath)>0)continue;let c=s.durationMs/s.totalBytes/r;return o*Math.min(bi,Math.max(1/bi,c))}return o}}function Ti(e,t){let n=[];for(let r of e){let a=r.inputPaths[0],i=r.inputPaths[r.inputPaths.length-1];if(a===void 0||i===void 0||!(r.durationMs>0))return null;let o=r.inputPaths.reduce((s,c)=>s+Math.max(1,t(c)),0);n.push({firstPath:a,lastPath:i,totalBytes:o,durationMs:r.durationMs})}return n.length>0?{version:1,samples:n}:null}function wi(e=process.env,t={totalmemBytes:Fs(),cpuCount:Os().length}){let n=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_CONCURRENCY??"",10);if(Number.isSafeInteger(n)&&n>0)return n;let r=Math.floor(t.totalmemBytes/2/Ds),a=Math.floor(t.cpuCount/2);return Math.max(1,Math.min(Ms,r,a))}function Ci(e){let t;try{t=Cs(e)}catch{return}for(let n of t)if(On(n))try{js(Ye(e,n))}catch{}}import{createHash as qt}from"crypto";import{existsSync as Ut,writeFileSync as Li}from"fs";import{join as zs}from"path";import{randomUUID as As}from"crypto";import{existsSync as ji,rmSync as Gt}from"fs";import{join as $s}from"path";var Gs=12e4,Bs=5,be=class extends Error{name="TypeScriptIndexMemoryPressureError"},Qe=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;requireService;localHost=null;constructor(t,n={}){this.projectRoot=Cn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Hs(),this.runtime=n.runtime??Js,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally,this.requireService=n.requireService===!0}request(t){let n=wr(this.cacheDir),r=vr(this.cacheDir),a=Rt(n.statePath);if(!Oi(a,this.projectRoot,this.runtime))return this.requestLocally(t);let i=this.runtime.now(),o=i+this.timeoutMs,s=(this.runtime.monotonicNow??C)()+this.timeoutMs,c=xr("typescript-index-v5",{baseGeneration:this.baseGeneration,request:t}),d=Er(c),l=Ir(r,{mailboxVersion:Rr,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:i,deadlineAtMs:o,protocolVersion:qe,id:d,baseGeneration:this.baseGeneration,request:t},{nowMs:i,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??C)()<=s;){if(ji(l.responsePath))try{return Fi(ge(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{Gt(l.responsePath,{force:!0})}let g=Rt(n.statePath);if(!Oi(g,this.projectRoot,this.runtime))return this.abandonPendingRequest(r,d),this.requestLocally(t);this.runtime.sleep(Bs)}if(ji(l.responsePath))try{return Fi(ge(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{Gt(l.responsePath,{force:!0})}return this.abandonPendingRequest(r,d),this.requestLocally(t)}abandonPendingRequest(t,n){try{Gt($s(t.pendingDir,`${n}.json`),{force:!0})}catch{}}requestLocally(t){if(this.requireService)throw new Error("TypeScript incremental index service unavailable; refusing to load the whole compiler graph inside the reindex process");return this.emitLocally?Bt(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new Cr({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),Bt(ki(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function Oi(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null,a=e?Date.parse(e.heartbeatAt):Number.NaN;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===qe&&n.isProcessAlive(e.pid)&&Number.isFinite(a)&&n.now()-a<=Tr&&(!e.processIdentity||r!=null&&z(e.processIdentity,r))}function Fi(e,t,n,r,a,i){let o=JSON.parse(e);if(o.protocolVersion!==qe||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0){let s=typeof o.error=="string"?o.error:"TypeScript index service request failed.";throw Us(s)?new be(s):new Error(s)}return Bt(ki(o.response,a),a,i)}function Us(e){let t=e.toLowerCase();return t.includes("out of memory")||t.includes("memory limit")||t.includes("allocation failed")||t.includes("err_worker_out_of_memory")}function Bt(e,t,n){if(e.producerIdentity!==t)throw new Error("TypeScript index service wrote an invalid response.");let r=[...new Set(n)].sort(),a=e.fragments.map(i=>i.relativePath).sort();if(JSON.stringify(a)!==JSON.stringify(r))throw new Error("TypeScript index service omitted or added an affected document.");return e}function ki(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,a=n.fragments.map(i=>{if(!i||typeof i.relativePath!="string"||i.bytesBase64!==null&&typeof i.bytesBase64!="string"||typeof i.occurrences!="number"||!Number.isInteger(i.occurrences)||i.occurrences<0||typeof i.symbols!="number"||!Number.isInteger(i.symbols)||i.symbols<0||!Array.isArray(i.referenceFragments)||!i.referenceFragments.every(qs)||r.has(i.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(i.relativePath);let o=i.bytesBase64===null?null:Ws(i.bytesBase64);return{relativePath:i.relativePath,bytes:o,occurrences:i.occurrences,symbols:i.symbols,referenceFragments:i.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:a}}function qs(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 Hs(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Gs}var Js={now:Date.now,monotonicNow:C,randomId:As,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:oe,readProcessIdentity:U};var Xs=128,Ys=256;function Qs(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."],n=se(t);if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let r=q(e.previousSnapshot,e.currentSnapshot);if(r.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let a=r.changes.filter(m=>m.inputKind==="source"&&ue(m.path)),i=Ai(r,n),o={...r,changes:i},s=a.filter(m=>m.kind==="added").map(m=>m.path),c=a.filter(m=>m.kind==="deleted").map(m=>m.path),d=a.filter(m=>m.kind==="modified"),l=Ve(e.currentSnapshot,e.producerIdentity,n),g=Ve(e.previousSnapshot,e.producerIdentity,n),p=$i(r,i,l,g),f=!p&&Bi(r);if(a.length===0&&!p)return{eligible:!1,reason:"change does not affect the configured TypeScript project"};let R=e.currentSnapshot.files.filter(m=>_e(m.path,e.currentSnapshot.languages)==="source"&&ue(m.path)).map(m=>m.path).sort(),T=new Set(R),j=p?e.projectFiles.filter(m=>!T.has(m)).sort():[...c].sort(),D=p?o:{...r,changes:a},v=p?{eligible:!0,plan:{...Se(o,e.graph,[...new Set([...R,...j])]),mode:"full-project"}}:Vs(d,s,j,e.graph,e.projectFiles);if(!v.eligible)return v;let F=v.plan,_=new Set(j),h=Zs(F,t,e.graph,_);if(!h)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let y=h.length===1?h[0]:void 0;return{eligible:!0,manifest:D,plan:F,projectIdentity:l,previousFragmentGeneration:Ni(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Ni(e.currentSnapshot,e.producerIdentity),projects:h,deletedFiles:j,replaceProject:p,dependencyGraphUnchanged:f,...y?{tsconfigPath:y.tsconfigPath,projectArgument:y.projectArgument}:{}}}function Ai(e,t){return e.changes.filter(n=>n.inputKind==="source"&&ue(n.path)||n.inputKind==="config"&&(!ce(n.path)||t.has(n.path))&&Ks(n)||n.inputKind==="ambient")}function Ks(e){return e.kind!=="modified"||e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function $i(e,t,n,r){return n!==r||e.projectIdentityChanged||e.uncertainty.length>0||t.length>Ys||t.some(a=>a.inputKind==="config"||a.inputKind==="ambient")}function Vs(e,t,n,r,a){if(e.length===0)return t.length===0&&n.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...t,...n])].sort(),affectedFiles:[...new Set([...t,...Di(n,r,a)])].sort(),reasons:[]}};let i=Se({version:1,changes:e.filter(Gi),projectIdentityChanged:!1,uncertainty:[]},r,a);return i.mode==="full-project"?{eligible:!1,reason:i.reasons.length>0?`affected set widened: ${i.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...e.map(o=>o.path),...t,...n])].sort(),affectedFiles:[...new Set([...i.affectedFiles,...e.map(o=>o.path),...t,...Di(n,r,a)])].sort(),reasons:[]}}}function Gi(e){return e.kind!=="modified"?!0:e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function Bi(e){let t=e.changes.filter(n=>n.inputKind==="source"&&ue(n.path));return t.length>0&&t.every(n=>n.kind==="modified"&&!Gi(n))}function Zs(e,t,n,r){let a=new Map;for(let o of e.affectedFiles){let s=ec(o,t);if(!s)return null;let c=a.get(s)??[];c.push(o),a.set(s,c)}let i=[];for(let[o,s]of[...a].sort(([c],[d])=>c.localeCompare(d))){let c=new Set(s),d=e.changedFiles.filter(p=>!r.has(p)&&(c.has(p)||s.some(f=>Mi(f,p,n)))),l=e.changedFiles.filter(p=>r.has(p)&&(c.has(p)||s.some(f=>Mi(f,p,n)))),g=s.filter(p=>!r.has(p));if(d.length===0&&l.length===0&&g.length===0)return null;i.push({projectArgument:o,tsconfigPath:o==="."?"tsconfig.json":`${o}/tsconfig.json`,modifiedFiles:d,removedFiles:l,affectedFiles:[...g].sort()})}return i}function Di(e,t,n){let r=new Set(n),a=new Map;for(let[s,c]of t)if(r.has(s))for(let d of c){let l=a.get(d)??new Set;l.add(s),a.set(d,l)}let i=new Set(e),o=[...e];for(let s=0;s<o.length;s+=1){let c=o[s];if(c)for(let d of a.get(c)??[])i.has(d)||(i.add(d),o.push(d))}return[...i].sort()}function ec(e,t){let n=t.filter(i=>i==="."||e===i||e.startsWith(`${i}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((i,o)=>Ke(o)-Ke(i)||i.localeCompare(o)),a=r[0];return r[1]&&Ke(r[1])===Ke(a)?null:a}function Ke(e){return e==="."?0:e.split("/").filter(Boolean).length}function Mi(e,t,n){let r=new Set,a=[e];for(let i=0;i<a.length;i+=1){let o=a[i];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||a.push(s)}}}return!1}function Ui(e){let t=C();try{if(!Ut(e.previousDbPath)||!Ut(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Pt();if(!r.available)throw new Error(r.reason);let a=performance.now()-n;n=performance.now();let i=new $({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o=nc(e.projectRoot,e.previousSnapshot,e.currentSnapshot),s=e.projectMode==="workspace"?X(e.projectRoot,e.currentSnapshot.typescriptProjects):["."],c=se(s),d,l,g;try{d=ke(i,{includeIgnored:!1}).filter(ue).sort();let I=o?q(o,e.currentSnapshot):null,u=I&&o&&$i(I,Ai(I,c),Ve(e.currentSnapshot,r.producerIdentity,c),Ve(o,r.producerIdentity,c)),b=I!==null&&!u&&Bi(I);u?(g=Me(i,"none")??void 0,l=new Map):b?l=new Map:(g=De(i),l=g.graph)}finally{i.close()}let p=performance.now()-n,f=Qs({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?s:void 0,previousSnapshot:o,currentSnapshot:e.currentSnapshot,projectFiles:d,graph:l,producerIdentity:r.producerIdentity,rootTsconfigExists:Ut(zs(e.projectRoot,"tsconfig.json"))});if(!f.eligible)throw new Error(f.reason);let R=_r(e.previousDbPath);if(!R)throw new Error("published TypeScript base generation unavailable");n=performance.now();let T=new Qe({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:R},{requireService:!0}),j=f.projects.flatMap(I=>{let u=tc(I.affectedFiles,Xs);return(u.length>0?u:[[]]).map((k,B)=>({project:I,affectedFiles:k,removedFiles:B===0?I.removedFiles:[],firstForProject:B===0}))}),D=[],v=new Map,F=[],_=!1,h=0,y=0,m=0,w=f.previousFragmentGeneration;for(let[I,u]of j.entries()){let b=T.request({kind:"emit-documents",tsconfigPath:u.project.tsconfigPath,projectArgument:u.project.projectArgument,projectIdentity:f.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:u.firstForProject?u.project.modifiedFiles:[],removedFiles:u.firstForProject?u.project.removedFiles:[],affectedFiles:u.affectedFiles});_||=b.cold,F.push(b.durationMs);let k=u.removedFiles.map(xe=>({relativePath:xe,bytes:null,occurrences:0,symbols:0,referenceFragments:[]})),B=[...b.fragments,...k];if(!f.replaceProject)for(let xe of B)v.set(xe.relativePath,xe.referenceFragments);let dt=performance.now(),$a=cr(b.fragments);h+=performance.now()-dt;let nn=I===0?e.candidateAffectedScipPath:`${e.candidateAffectedScipPath}.batch-${I}.scip`,Ga=performance.now();Li(nn,$a),m+=performance.now()-Ga;let Ba=performance.now(),rn=I===j.length-1?f.nextFragmentGeneration:rc({previousGenerationIdentity:w,targetGenerationIdentity:f.nextFragmentGeneration,fragments:B});lr({cacheDir:e.cacheDir,previousGenerationIdentity:w,nextGenerationIdentity:rn,producerIdentity:r.producerIdentity,projectIdentity:f.projectIdentity,baseShardCurrent:I===0?e.baseShardCurrent:!1,fragments:B,allowProjectIdentityChange:f.replaceProject&&I===0,allowLegacyProjectIdentityMigration:!0}),y+=performance.now()-Ba,w=rn,D.push({scipPath:nn,affectedFiles:[...u.affectedFiles,...u.removedFiles].sort(),deletedFiles:[...u.removedFiles].sort()})}let S=performance.now()-n,P={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,affectedBatches:D,completeScipUpdated:!1,durationMs:C()-t,cold:_,changedFiles:f.plan.changedFiles,affectedFiles:f.plan.affectedFiles,deletedFiles:f.deletedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:f.previousFragmentGeneration,nextFragmentGeneration:f.nextFragmentGeneration,manifest:f.manifest,plan:f.plan,projectFileCount:d.length,dependencyGraphSnapshot:g,dependencyGraphUnchanged:f.dependencyGraphUnchanged,referenceFragmentsByFile:v,timings:{runtimeMs:a,graphMs:p,requestMs:S,serviceMs:F.reduce((I,u)=>I+u,0),assemblyMs:h,fragmentStoreMs:y,writeMs:m}};return e.onStatus(`${f.replaceProject?"Bounded TypeScript project refresh":"Incremental TypeScript index"} emitted ${P.affectedFiles.length-P.deletedFiles.length} document(s), removed ${P.deletedFiles.length}, and produced ${D.length} bounded batch(es) across ${f.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${a.toFixed(0)}ms, graph ${p.toFixed(0)}ms, request ${S.toFixed(0)}ms, assembly ${h.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${m.toFixed(0)}ms).`),P}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof be)throw e.onStatus(`Incremental TypeScript index stopped after memory pressure survived one cold Worker retry: ${r}. Preserving the accepted index instead of starting a memory-heavier whole-project rebuild.`),n;return e.onStatus(`Incremental TypeScript index unavailable: ${r}.`),null}}function tc(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function nc(e,t,n){if(!t)return null;let r=new Map(n.files.map(o=>[o.path,o])),a=!1,i=t.files.map(o=>{let s=r.get(o.path);if(o.semanticHash!==void 0||s?.semanticHash===void 0)return o;let c=we(e,o.path,o.hash);return c===void 0?o:(a=!0,{...o,semanticHash:c})});return a?{...t,files:i}:t}function rc(e){let t=qt("sha256");t.update("typescript-overlay-batch-v1\0"),t.update(e.previousGenerationIdentity),t.update("\0"),t.update(e.targetGenerationIdentity);for(let n of[...e.fragments].sort((r,a)=>r.relativePath.localeCompare(a.relativePath)))t.update("\0path\0"),t.update(n.relativePath),n.bytes===null?t.update("\0deleted"):(t.update("\0bytes\0"),t.update(qt("sha256").update(n.bytes).digest()));return t.digest("hex")}function Wt(e){let t=Pt();if(!t.available)throw new Error(t.reason);let n=ur({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:ie(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Ee}),packageVersion:t.packageVersion});Li(e.candidateShardPath,n)}function Ve(e,t,n){let r=e.files.filter(a=>{let i=_e(a.path,e.languages);return i==="ambient"||i==="config"&&(!ce(a.path)||n.has(a.path))}).map(a=>{let o=_e(a.path,e.languages)==="config"?a.semanticHash:void 0;return{path:a.path,size:o===void 0?a.size:0,hash:o??a.hash}}).sort((a,i)=>a.path.localeCompare(i.path));return`typescript-project-v3:${qi(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function Ni(e,t){return qi(JSON.stringify({version:1,producerIdentity:t,snapshot:pn(e)}))}function qi(e){return qt("sha256").update(e).digest("hex")}import{closeSync as ic,existsSync as Ze,fstatSync as ac,lstatSync as oc,openSync as sc,renameSync as Jt,rmSync as Pe,statSync as cc,writeSync as dc}from"fs";import{cpus as lc}from"os";import{join as zt}from"path";var Wi=8*1024;function Hi(e,t,n){let r=Buffer.from(t,"utf8"),a=()=>sc(e,"wx",384),i;try{i=a()}catch(o){if(o.code!=="EEXIST")throw o;if(n==="skip")return null;Pe(e,{force:!0}),i=a()}try{dc(i,r);let o=ac(i);return{path:e,content:r,device:o.dev,inode:o.ino}}finally{ic(i)}}function uc(e,t){let n=[];try{if(e.temporaryRootConfigContent!==void 0){let r=Hi(zt(t,"tsconfig.json"),e.temporaryRootConfigContent,"skip");r&&n.push(r)}for(let r of e.temporaryProjectConfigs??[]){let a=Hi(r.path,r.content,"replace");a&&n.push(a)}return n}catch(r){for(let a of n.reverse())Xi(a);throw r}}function Xi(e){if(e)try{let t=oc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=ie(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;Pe(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function pc(e,t,n){if(!e.defaultOutputPath)return;let r=zt(t,e.defaultOutputPath);n!==r&&Ze(r)&&Jt(r,n)}function gc(e,t,n){if(!e.defaultOutputPath)return null;let r=zt(t,e.defaultOutputPath);if(r===n)return null;let a=`${n}.default-output-backup`;return Pe(a,{force:!0}),Ze(r)?(Jt(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function fc(e){e&&(Pe(e.defaultOutputPath,{force:!0}),e.backupPath&&Ze(e.backupPath)&&Jt(e.backupPath,e.defaultOutputPath))}function mc(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,lc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Yi(e,t,n,r,a){A(a,"Reindex cancelled by its owner.");let i=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath&&d.boundedConcurrency!==void 0),s=e.filter(d=>!d.config.defaultOutputPath&&d.boundedConcurrency===void 0),c=[];if(c.push(...await Ji(s,mc(s.length,r),t,n,a)),o.length>0){let d=Math.max(1,Math.min(...o.map(l=>l.boundedConcurrency)));c.push(...await Ji(o,d,t,n,a))}for(let d of i)A(a,"Reindex cancelled by its owner."),c.push((await Ht(d,t,n,a)).result);return c.sort((d,l)=>e.findIndex(g=>g.id===d.id)-e.findIndex(g=>g.id===l.id))}async function Ji(e,t,n,r,a){let i=await jr(e,Math.max(1,t),s=>Ht(s,n,r,a));if(t<=1)return i.map(({result:s})=>s);let o=new Map;for(let s of i.filter(c=>c.result.skipped&&c.retryable)){let c=e.find(d=>d.id===s.result.id);c&&(r(`Retrying ${c.label} indexer serially after parallel failure...`),A(a,"Reindex cancelled by its owner."),o.set(c.id,(await Ht(c,n,r,a)).result))}return i.map(({result:s})=>o.get(s.id)??s)}async function Ht(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Pe(e.scipPath,{force:!0});let a=gc(e.config,t,e.scipPath),i=[],o=[e.binary,...e.args].join(" "),s=C();try{i=uc(e,t),e.trustedProjectTool&&$n(t,e.trustedProjectTool);let d=yn(e.binary,e.args),l=await ve({command:d.binary,args:d.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:hc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let g=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${g?`:
|
|
286
|
+
)`],Rs=["CREATE INDEX idx_chunks_line_range ON chunks(document_id, start_line, end_line)","CREATE INDEX idx_mentions_symbol_id_role ON mentions(symbol_id, role)","CREATE INDEX idx_defn_enclosing_ranges_symbol_id ON defn_enclosing_ranges(symbol_id)","CREATE INDEX idx_defn_enclosing_ranges_document ON defn_enclosing_ranges(document_id, start_line, end_line)","CREATE INDEX idx_chunks_doc_id ON chunks(document_id)","CREATE INDEX idx_global_symbols_symbol ON global_symbols(symbol)"];function Lt(e){return e.startsWith("local ")}function pi(e,t,n,r){let a=t,i=0,o=0;for(;a<n;){let s=e[a];a+=1,o<53&&(i+=(s&127)*2**o),(s&128)===0?(r.push(i),i=0,o=0):o+=7}}function gi(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e.length===4?[e[0],e[1],e[2],e[3]]:null}function xs(e,t){return e.startLine!==t.startLine?e.startLine-t.startLine:e.startChar!==t.startChar?e.startChar-t.startChar:e.endLine!==t.endLine?e.endLine-t.endLine:e.endChar!==t.endChar?e.endChar-t.endChar:e.symbol<t.symbol?-1:e.symbol>t.symbol?1:0}function Es(e,t,n,r){let a=[],i=[],o="",s=0;for(let d of Q(e,n,r))d.fieldNumber===mi?d.wireType===2?pi(e,d.valueStart,d.valueEnd,a):d.wireType===0&&a.push(d.varint):d.fieldNumber===hi&&d.wireType===2?o=pe.decode(e.subarray(d.valueStart,d.valueEnd)):d.fieldNumber===yi&&d.wireType===0?s=d.varint:d.fieldNumber===gs&&(d.wireType===2?pi(e,d.valueStart,d.valueEnd,i):d.wireType===0&&i.push(d.varint));let c=gi(a);return c?{startLine:c[0],startChar:c[1],endLine:c[2],endChar:c[3],symbol:o,roles:s,frameStart:t,frameEnd:r,merged:!1,enclosing:gi(i)}:null}function vs(e,t,n){let r={symbol:"",displayName:null,kind:null,documentation:[],enclosingSymbol:null};for(let a of Q(e,t,n))if(a.wireType===2){let i=()=>pe.decode(e.subarray(a.valueStart,a.valueEnd));a.fieldNumber===fs?r.symbol=i():a.fieldNumber===ms?r.documentation.push(i()):a.fieldNumber===ys?r.displayName=i():a.fieldNumber===Ss&&(r.enclosingSymbol=i())}else a.fieldNumber===hs&&a.wireType===0&&(r.kind=a.varint);return r}var pe=new TextDecoder;function Is(e,t){if(e.length===0)return[];let n=[],r=Math.min(e.length,t);for(let a=0;a<r&&r<=e.length;){for(;r<=e.length-1&&e[r-1].startLine===e[r].startLine;)r+=1;n.push(e.slice(a,r)),a=r,r=Math.min(e.length,r+t)}return n}function _s(e){let t=e.startLine===e.endLine?[e.startLine,e.startChar,e.endChar]:[e.startLine,e.startChar,e.endLine,e.endChar],n=[],r=Buffer.concat(t.map(o=>K(o)));n.push(Le(mi),K(r.length),r);let a=Buffer.from(e.symbol,"utf8");n.push(Le(hi),K(a.length),a),e.roles!==0&&n.push(K(yi*8),K(e.roles));let i=Buffer.concat(n);return Buffer.concat([Le(At),K(i.length),i])}function Ts(e,t){let n=[];for(let r of t)r.merged?n.push(_s(r)):n.push(e.subarray(r.frameStart,r.frameEnd));return os(Buffer.concat(n))}async function Si(e,t,n={}){let r=n.chunkSize??ss,a={documents:0,duplicateDocumentsSkipped:0,occurrences:0,illegalOccurrencesDropped:0,mergedOccurrences:0,chunks:0,mentions:0,globalSymbols:0,enclosingRanges:0},i=new as(t);try{i.pragma("synchronous = normal"),i.pragma("temp_store = memory"),i.pragma("foreign_keys = ON"),i.pragma("journal_mode = WAL");for(let I of Ps)i.exec(I);let o=i.prepare("INSERT INTO documents (id, language, relative_path, position_encoding, text) VALUES (?, ?, ?, ?, ?)"),s=i.prepare("INSERT INTO chunks (id, document_id, chunk_index, start_line, end_line, occurrences) VALUES (?, ?, ?, ?, ?, ?)"),c=i.prepare("INSERT INTO defn_enclosing_ranges (document_id, symbol_id, start_line, start_char, end_line, end_char) VALUES (?, ?, ?, ?, ?, ?)"),d=i.prepare("INSERT INTO global_symbols (id, symbol, display_name, kind, documentation, enclosing_symbol) VALUES (?, ?, ?, ?, ?, ?)"),l=i.prepare("INSERT INTO mentions (chunk_id, symbol_id, role) VALUES (?, ?, ?)"),g=new Map,p=new Map,f=1,R=1,T=1,j=(I,F,_,h,y)=>{let m=T;return T+=1,p.set(I,m),d.run(m,I,F,_,h,y),a.globalSymbols+=1,m};i.exec("BEGIN IMMEDIATE");let D=!1;try{let I=0;for(let _ of Q(e)){if(_.fieldNumber!==At||_.wireType!==2)continue;fi(n.signal),I+=1,I>=ui&&(I=0,await di());let h="",y=null,m=null,w=null,S=[];for(let u of Q(e,_.valueStart,_.valueEnd))u.wireType===2?u.fieldNumber===li?h=pe.decode(e.subarray(u.valueStart,u.valueEnd)):u.fieldNumber===ds?S.push(vs(e,u.valueStart,u.valueEnd)):u.fieldNumber===ls?y=pe.decode(e.subarray(u.valueStart,u.valueEnd)):u.fieldNumber===us&&(m=pe.decode(e.subarray(u.valueStart,u.valueEnd))):u.fieldNumber===ps&&u.wireType===0&&(w=ws(u.varint));if(h==="")throw new J("relative path must not be empty");if(g.has(h)){a.duplicateDocumentsSkipped+=1;continue}let P=f;f+=1,o.run(P,y===""?null:y,h,w,m===""?null:m),g.set(h,P),a.documents+=1;let v=new Map;for(let u of S){if(u.symbol==="")throw new J(`empty symbol in SymbolInformation for document ${h}`);let b=v.get(u.symbol);if(!b){v.set(u.symbol,u);continue}for(let k of u.documentation)b.documentation.includes(k)||b.documentation.push(k)}for(let u of[...v.values()].sort((b,k)=>b.symbol<k.symbol?-1:b.symbol>k.symbol?1:0))Lt(u.symbol)||p.has(u.symbol)||j(u.symbol,u.displayName===""?null:u.displayName,u.kind===0?null:u.kind,u.documentation.length===0?null:u.documentation.join(`
|
|
287
|
+
`),u.enclosingSymbol===""?null:u.enclosingSymbol)}let F=new Set;I=0;for(let _ of Q(e)){if(_.fieldNumber!==At||_.wireType!==2)continue;fi(n.signal),I+=1,I>=ui&&(I=0,await di());let h="",y=[];for(let S of Q(e,_.valueStart,_.valueEnd))if(S.wireType===2){if(S.fieldNumber===li)h=pe.decode(e.subarray(S.valueStart,S.valueEnd));else if(S.fieldNumber===cs){let P=Es(e,S.fieldStart,S.valueStart,S.valueEnd);P?y.push(P):a.illegalOccurrencesDropped+=1}}if(F.has(h))continue;F.add(h);let m=g.get(h);if(m===void 0)continue;y.sort(xs);let w=[];for(let S of y){let P=w[w.length-1];if(P&&P.startLine===S.startLine&&P.startChar===S.startChar&&P.endLine===S.endLine&&P.endChar===S.endChar&&P.symbol===S.symbol){P.roles|=S.roles,P.merged=!0,a.mergedOccurrences+=1;continue}w.push(S)}a.occurrences+=w.length;for(let S of w){if((S.roles&bs)===0||Lt(S.symbol)||!S.enclosing)continue;let[P,v,u,b]=S.enclosing;if(P<0||v<0||u<P||u===P&&b<v)throw new J(`bad enclosing range for symbol ${S.symbol} in ${h}`);let k=p.get(S.symbol);if(k===void 0)throw new J(`symbol ${S.symbol} has definition occurrence, but no SymbolInformation`);c.run(m,k,P,v,u,b),a.enclosingRanges+=1}for(let[S,P]of Is(w,r).entries()){let v=R;R+=1,s.run(v,m,S,P[0].startLine,P[P.length-1].startLine,Ts(e,P)),a.chunks+=1;let u=new Map;for(let b of P){if(Lt(b.symbol))continue;let k=u.get(b.symbol);k||u.set(b.symbol,k=new Set),k.add(b.roles),p.has(b.symbol)||j(b.symbol,null,null,null,null)}for(let[b,k]of u){let U=p.get(b);for(let dt of k)l.run(v,U,dt),a.mentions+=1}}}i.exec("COMMIT"),D=!0}finally{if(!D)try{i.exec("ROLLBACK")}catch{}}i.exec("BEGIN IMMEDIATE");for(let I of Rs)i.exec(I);i.exec("COMMIT"),i.pragma("wal_checkpoint(TRUNCATE)")}finally{i.close()}return a}function ws(e){if(e===0)return null;if(e===1)return"UTF-8";if(e===2)return"UTF-16";if(e===3)return"UTF-32";throw new J(`unknown position encoding ${e}`)}function fi(e){if(e?.aborted)throw new J("SCIP SQLite conversion aborted")}import{readdirSync as Cs,rmSync as js}from"fs";import{cpus as Os,totalmem as Fs}from"os";import{join as Ye}from"path";var ks=2048,Ds=6*1024**3,Ms=4;function $t(e=process.env){let t=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_FILES??"",10);return Number.isSafeInteger(t)&&t>0?t:ks}function Pi(e,t){return e>Math.floor(t*1.5)}var Ns=1.25;function Ri(e,t,n){if(!Number.isSafeInteger(t)||t<1)throw new Error(`TypeScript compiler shard targetFiles must be a positive safe integer; received ${t}.`);let r=Math.max(1,Math.ceil(e/t));if(r<=1||n<=1)return r;let a=Math.floor(t*Ns),i=new Set([r,n*Math.floor(r/n),n*Math.ceil(r/n)]),o=c=>Math.ceil(c/n)*Math.ceil(e/c),s=r;for(let c of i)c<1||Math.ceil(e/c)>a||(o(c)<o(s)||o(c)===o(s)&&c<s)&&(s=c);return s}function Ls(e,t,n=()=>1){if(!Number.isSafeInteger(t)||t<1)throw new Error(`TypeScript compiler shard count must be a positive safe integer; received ${t}.`);let r=[...new Set(e)].sort((d,l)=>d.localeCompare(l));if(t===1||r.length<=t)return r.length<=t&&t>1?r.map(d=>[d]):r.length>0?[r]:[];let a=r.map(d=>Math.max(1,n(d))),i=a.reduce((d,l)=>d+l,0),o=[],s=[],c=0;for(let d=0;d<r.length;d+=1){s.push(r[d]),c+=a[d];let l=t-o.length-1,g=r.length-d-1;l>0&&g>=l&&(c>=i*(o.length+1)/t||g===l)&&(o.push(s),s=[])}return s.length>0&&o.push(s),o}function xi(e){let t=e.targetFiles??$t(),n=e.shardCount??Math.max(1,Math.ceil(new Set(e.inputPaths).size/Math.max(1,t)));return Ls(e.inputPaths,n,e.weightOf).map((r,a)=>{let i=Ye(e.projectRoot,jn(a)),o=`${JSON.stringify({extends:`./${e.rootConfigPath}`,compilerOptions:{incremental:!1},files:r.map(s=>`./${s}`),include:[],exclude:[]},null,2)}
|
|
288
|
+
`;return{configPath:i,content:o,inputPaths:r}})}var Ei="typescript-shard-costs.json",bi=4;function vi(e){let t;try{t=JSON.parse(on(Ye(e,Ei),"shard cost model"))}catch{return null}if(typeof t!="object"||t===null||t.version!==1)return null;let n=t.samples;return Array.isArray(n)&&n.every(a=>typeof a=="object"&&a!==null&&typeof a.firstPath=="string"&&typeof a.lastPath=="string"&&Number.isFinite(a.totalBytes)&&a.totalBytes>0&&Number.isFinite(a.durationMs)&&a.durationMs>0)?{version:1,samples:n}:null}function Ii(e,t){Fe(Ye(e,Ei),t)}function _i(e){let t=(e?.samples??[]).filter(i=>i.totalBytes>0&&i.durationMs>0);if(t.length<2)return(i,o)=>o;let n=t.map(i=>i.durationMs/i.totalBytes).sort((i,o)=>i-o),r=n[Math.floor(n.length/2)];if(!(r>0))return(i,o)=>o;let a=[...t].sort((i,o)=>i.firstPath.localeCompare(o.firstPath));return(i,o)=>{for(let s of a){if(i.localeCompare(s.firstPath)<0)break;if(i.localeCompare(s.lastPath)>0)continue;let c=s.durationMs/s.totalBytes/r;return o*Math.min(bi,Math.max(1/bi,c))}return o}}function Ti(e,t){let n=[];for(let r of e){let a=r.inputPaths[0],i=r.inputPaths[r.inputPaths.length-1];if(a===void 0||i===void 0||!(r.durationMs>0))return null;let o=r.inputPaths.reduce((s,c)=>s+Math.max(1,t(c)),0);n.push({firstPath:a,lastPath:i,totalBytes:o,durationMs:r.durationMs})}return n.length>0?{version:1,samples:n}:null}function wi(e=process.env,t={totalmemBytes:Fs(),cpuCount:Os().length}){let n=Number.parseInt(e.SCIP_QUERY_TS_COMPILER_SHARD_CONCURRENCY??"",10);if(Number.isSafeInteger(n)&&n>0)return n;let r=Math.floor(t.totalmemBytes/2/Ds),a=Math.floor(t.cpuCount/2);return Math.max(1,Math.min(Ms,r,a))}function Ci(e){let t;try{t=Cs(e)}catch{return}for(let n of t)if(On(n))try{js(Ye(e,n))}catch{}}import{createHash as qt}from"crypto";import{existsSync as Ut,writeFileSync as Li}from"fs";import{join as zs}from"path";import{randomUUID as As}from"crypto";import{existsSync as ji,rmSync as Gt}from"fs";import{join as $s}from"path";var Gs=12e4,Bs=5,be=class extends Error{name="TypeScriptIndexMemoryPressureError"},Qe=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;requireService;localHost=null;constructor(t,n={}){this.projectRoot=Cn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Hs(),this.runtime=n.runtime??Js,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally,this.requireService=n.requireService===!0}request(t){let n=wr(this.cacheDir),r=Ir(this.cacheDir),a=Rt(n.statePath);if(!Oi(a,this.projectRoot,this.runtime))return this.requestLocally(t);let i=this.runtime.now(),o=i+this.timeoutMs,s=(this.runtime.monotonicNow??C)()+this.timeoutMs,c=xr("typescript-index-v5",{baseGeneration:this.baseGeneration,request:t}),d=Er(c),l=vr(r,{mailboxVersion:Rr,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:i,deadlineAtMs:o,protocolVersion:qe,id:d,baseGeneration:this.baseGeneration,request:t},{nowMs:i,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??C)()<=s;){if(ji(l.responsePath))try{return Fi(ge(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{Gt(l.responsePath,{force:!0})}let g=Rt(n.statePath);if(!Oi(g,this.projectRoot,this.runtime))return this.abandonPendingRequest(r,d),this.requestLocally(t);this.runtime.sleep(Bs)}if(ji(l.responsePath))try{return Fi(ge(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles)}finally{Gt(l.responsePath,{force:!0})}return this.abandonPendingRequest(r,d),this.requestLocally(t)}abandonPendingRequest(t,n){try{Gt($s(t.pendingDir,`${n}.json`),{force:!0})}catch{}}requestLocally(t){if(this.requireService)throw new Error("TypeScript incremental index service unavailable; refusing to load the whole compiler graph inside the reindex process");return this.emitLocally?Bt(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new Cr({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),Bt(ki(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function Oi(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null,a=e?Date.parse(e.heartbeatAt):Number.NaN;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===qe&&n.isProcessAlive(e.pid)&&Number.isFinite(a)&&n.now()-a<=Tr&&(!e.processIdentity||r!=null&&X(e.processIdentity,r))}function Fi(e,t,n,r,a,i){let o=JSON.parse(e);if(o.protocolVersion!==qe||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0){let s=typeof o.error=="string"?o.error:"TypeScript index service request failed.";throw Us(s)?new be(s):new Error(s)}return Bt(ki(o.response,a),a,i)}function Us(e){let t=e.toLowerCase();return t.includes("out of memory")||t.includes("memory limit")||t.includes("allocation failed")||t.includes("err_worker_out_of_memory")}function Bt(e,t,n){if(e.producerIdentity!==t)throw new Error("TypeScript index service wrote an invalid response.");let r=[...new Set(n)].sort(),a=e.fragments.map(i=>i.relativePath).sort();if(JSON.stringify(a)!==JSON.stringify(r))throw new Error("TypeScript index service omitted or added an affected document.");return e}function ki(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,a=n.fragments.map(i=>{if(!i||typeof i.relativePath!="string"||i.bytesBase64!==null&&typeof i.bytesBase64!="string"||typeof i.occurrences!="number"||!Number.isInteger(i.occurrences)||i.occurrences<0||typeof i.symbols!="number"||!Number.isInteger(i.symbols)||i.symbols<0||!Array.isArray(i.referenceFragments)||!i.referenceFragments.every(qs)||r.has(i.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(i.relativePath);let o=i.bytesBase64===null?null:Ws(i.bytesBase64);return{relativePath:i.relativePath,bytes:o,occurrences:i.occurrences,symbols:i.symbols,referenceFragments:i.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:a}}function qs(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 Hs(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Gs}var Js={now:Date.now,monotonicNow:C,randomId:As,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:oe,readProcessIdentity:q};var Xs=128,Ys=256;function Qs(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."],n=se(t);if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let r=W(e.previousSnapshot,e.currentSnapshot);if(r.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let a=r.changes.filter(m=>m.inputKind==="source"&&ue(m.path)),i=Ai(r,n),o={...r,changes:i},s=a.filter(m=>m.kind==="added").map(m=>m.path),c=a.filter(m=>m.kind==="deleted").map(m=>m.path),d=a.filter(m=>m.kind==="modified"),l=Ve(e.currentSnapshot,e.producerIdentity,n),g=Ve(e.previousSnapshot,e.producerIdentity,n),p=$i(r,i,l,g),f=!p&&Bi(r);if(a.length===0&&!p)return{eligible:!1,reason:"change does not affect the configured TypeScript project"};let R=e.currentSnapshot.files.filter(m=>_e(m.path,e.currentSnapshot.languages)==="source"&&ue(m.path)).map(m=>m.path).sort(),T=new Set(R),j=p?e.projectFiles.filter(m=>!T.has(m)).sort():[...c].sort(),D=p?o:{...r,changes:a},I=p?{eligible:!0,plan:{...Se(o,e.graph,[...new Set([...R,...j])]),mode:"full-project"}}:Vs(d,s,j,e.graph,e.projectFiles);if(!I.eligible)return I;let F=I.plan,_=new Set(j),h=Zs(F,t,e.graph,_);if(!h)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let y=h.length===1?h[0]:void 0;return{eligible:!0,manifest:D,plan:F,projectIdentity:l,previousFragmentGeneration:e.previousOverlayGeneration??Ni(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Ni(e.currentSnapshot,e.producerIdentity),projects:h,deletedFiles:j,replaceProject:p,dependencyGraphUnchanged:f,...y?{tsconfigPath:y.tsconfigPath,projectArgument:y.projectArgument}:{}}}function Ai(e,t){return e.changes.filter(n=>n.inputKind==="source"&&ue(n.path)||n.inputKind==="config"&&(!ce(n.path)||t.has(n.path))&&Ks(n)||n.inputKind==="ambient")}function Ks(e){return e.kind!=="modified"||e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function $i(e,t,n,r){return n!==r||e.projectIdentityChanged||e.uncertainty.length>0||t.length>Ys||t.some(a=>a.inputKind==="config"||a.inputKind==="ambient")}function Vs(e,t,n,r,a){if(e.length===0)return t.length===0&&n.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...t,...n])].sort(),affectedFiles:[...new Set([...t,...Di(n,r,a)])].sort(),reasons:[]}};let i=Se({version:1,changes:e.filter(Gi),projectIdentityChanged:!1,uncertainty:[]},r,a);return i.mode==="full-project"?{eligible:!1,reason:i.reasons.length>0?`affected set widened: ${i.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...e.map(o=>o.path),...t,...n])].sort(),affectedFiles:[...new Set([...i.affectedFiles,...e.map(o=>o.path),...t,...Di(n,r,a)])].sort(),reasons:[]}}}function Gi(e){return e.kind!=="modified"?!0:e.before.semanticHash===void 0||e.after.semanticHash===void 0||e.before.semanticHash!==e.after.semanticHash}function Bi(e){let t=e.changes.filter(n=>n.inputKind==="source"&&ue(n.path));return t.length>0&&t.every(n=>n.kind==="modified"&&!Gi(n))}function Zs(e,t,n,r){let a=new Map;for(let o of e.affectedFiles){let s=ec(o,t);if(!s)return null;let c=a.get(s)??[];c.push(o),a.set(s,c)}let i=[];for(let[o,s]of[...a].sort(([c],[d])=>c.localeCompare(d))){let c=new Set(s),d=e.changedFiles.filter(p=>!r.has(p)&&(c.has(p)||s.some(f=>Mi(f,p,n)))),l=e.changedFiles.filter(p=>r.has(p)&&(c.has(p)||s.some(f=>Mi(f,p,n)))),g=s.filter(p=>!r.has(p));if(d.length===0&&l.length===0&&g.length===0)return null;i.push({projectArgument:o,tsconfigPath:o==="."?"tsconfig.json":`${o}/tsconfig.json`,modifiedFiles:d,removedFiles:l,affectedFiles:[...g].sort()})}return i}function Di(e,t,n){let r=new Set(n),a=new Map;for(let[s,c]of t)if(r.has(s))for(let d of c){let l=a.get(d)??new Set;l.add(s),a.set(d,l)}let i=new Set(e),o=[...e];for(let s=0;s<o.length;s+=1){let c=o[s];if(c)for(let d of a.get(c)??[])i.has(d)||(i.add(d),o.push(d))}return[...i].sort()}function ec(e,t){let n=t.filter(i=>i==="."||e===i||e.startsWith(`${i}/`));if(n.length===0)return null;let r=[...new Set(n)].sort((i,o)=>Ke(o)-Ke(i)||i.localeCompare(o)),a=r[0];return r[1]&&Ke(r[1])===Ke(a)?null:a}function Ke(e){return e==="."?0:e.split("/").filter(Boolean).length}function Mi(e,t,n){let r=new Set,a=[e];for(let i=0;i<a.length;i+=1){let o=a[i];if(!(!o||r.has(o))){r.add(o);for(let s of n.get(o)??[]){if(s===t)return!0;r.has(s)||a.push(s)}}}return!1}function Ui(e){let t=C();try{if(!Ut(e.previousDbPath)||!Ut(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Pt();if(!r.available)throw new Error(r.reason);let a=performance.now()-n;n=performance.now();let i=new $({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o=nc(e.projectRoot,e.previousSnapshot,e.currentSnapshot),s=e.projectMode==="workspace"?Y(e.projectRoot,e.currentSnapshot.typescriptProjects):["."],c=se(s),d,l,g;try{d=ke(i,{includeIgnored:!1}).filter(ue).sort();let v=o?W(o,e.currentSnapshot):null,u=v&&o&&$i(v,Ai(v,c),Ve(e.currentSnapshot,r.producerIdentity,c),Ve(o,r.producerIdentity,c)),b=v!==null&&!u&&Bi(v);u?(g=Me(i,"none")??void 0,l=new Map):b?l=new Map:(g=De(i),l=g.graph)}finally{i.close()}let p=performance.now()-n,f=Qs({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?s:void 0,previousSnapshot:o,currentSnapshot:e.currentSnapshot,projectFiles:d,graph:l,producerIdentity:r.producerIdentity,rootTsconfigExists:Ut(zs(e.projectRoot,"tsconfig.json")),...e.previousOverlayGeneration===void 0?{}:{previousOverlayGeneration:e.previousOverlayGeneration}});if(!f.eligible)throw new Error(f.reason);let R=_r(e.previousDbPath);if(!R)throw new Error("published TypeScript base generation unavailable");n=performance.now();let T=new Qe({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:R},{requireService:!0}),j=f.projects.flatMap(v=>{let u=tc(v.affectedFiles,Xs);return(u.length>0?u:[[]]).map((k,U)=>({project:v,affectedFiles:k,removedFiles:U===0?v.removedFiles:[],firstForProject:U===0}))}),D=[],I=new Map,F=[],_=!1,h=0,y=0,m=0,w=f.previousFragmentGeneration;for(let[v,u]of j.entries()){let b=T.request({kind:"emit-documents",tsconfigPath:u.project.tsconfigPath,projectArgument:u.project.projectArgument,projectIdentity:f.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:u.firstForProject?u.project.modifiedFiles:[],removedFiles:u.firstForProject?u.project.removedFiles:[],affectedFiles:u.affectedFiles});_||=b.cold,F.push(b.durationMs);let k=u.removedFiles.map(xe=>({relativePath:xe,bytes:null,occurrences:0,symbols:0,referenceFragments:[]})),U=[...b.fragments,...k];if(!f.replaceProject)for(let xe of U)I.set(xe.relativePath,xe.referenceFragments);let dt=performance.now(),$a=cr(b.fragments);h+=performance.now()-dt;let nn=v===0?e.candidateAffectedScipPath:`${e.candidateAffectedScipPath}.batch-${v}.scip`,Ga=performance.now();Li(nn,$a),m+=performance.now()-Ga;let Ba=performance.now(),rn=v===j.length-1?f.nextFragmentGeneration:rc({previousGenerationIdentity:w,targetGenerationIdentity:f.nextFragmentGeneration,fragments:U});lr({cacheDir:e.cacheDir,previousGenerationIdentity:w,nextGenerationIdentity:rn,producerIdentity:r.producerIdentity,projectIdentity:f.projectIdentity,baseShardCurrent:v===0?e.baseShardCurrent:!1,fragments:U,allowProjectIdentityChange:f.replaceProject&&v===0,allowLegacyProjectIdentityMigration:!0}),y+=performance.now()-Ba,w=rn,D.push({scipPath:nn,affectedFiles:[...u.affectedFiles,...u.removedFiles].sort(),deletedFiles:[...u.removedFiles].sort()})}let S=performance.now()-n,P={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,affectedBatches:D,completeScipUpdated:!1,durationMs:C()-t,cold:_,changedFiles:f.plan.changedFiles,affectedFiles:f.plan.affectedFiles,deletedFiles:f.deletedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:f.previousFragmentGeneration,nextFragmentGeneration:f.nextFragmentGeneration,manifest:f.manifest,plan:f.plan,projectFileCount:d.length,dependencyGraphSnapshot:g,dependencyGraphUnchanged:f.dependencyGraphUnchanged,referenceFragmentsByFile:I,timings:{runtimeMs:a,graphMs:p,requestMs:S,serviceMs:F.reduce((v,u)=>v+u,0),assemblyMs:h,fragmentStoreMs:y,writeMs:m}};return e.onStatus(`${f.replaceProject?"Bounded TypeScript project refresh":"Incremental TypeScript index"} emitted ${P.affectedFiles.length-P.deletedFiles.length} document(s), removed ${P.deletedFiles.length}, and produced ${D.length} bounded batch(es) across ${f.projects.length} project(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${a.toFixed(0)}ms, graph ${p.toFixed(0)}ms, request ${S.toFixed(0)}ms, assembly ${h.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${m.toFixed(0)}ms).`),P}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof be)throw e.onStatus(`Incremental TypeScript index stopped after memory pressure survived one cold Worker retry: ${r}. Preserving the accepted index instead of starting a memory-heavier whole-project rebuild.`),n;return e.onStatus(`Incremental TypeScript index unavailable: ${r}.`),null}}function tc(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function nc(e,t,n){if(!t)return null;let r=new Map(n.files.map(o=>[o.path,o])),a=!1,i=t.files.map(o=>{let s=r.get(o.path);if(o.semanticHash!==void 0||s?.semanticHash===void 0)return o;let c=we(e,o.path,o.hash);return c===void 0?o:(a=!0,{...o,semanticHash:c})});return a?{...t,files:i}:t}function rc(e){let t=qt("sha256");t.update("typescript-overlay-batch-v1\0"),t.update(e.previousGenerationIdentity),t.update("\0"),t.update(e.targetGenerationIdentity);for(let n of[...e.fragments].sort((r,a)=>r.relativePath.localeCompare(a.relativePath)))t.update("\0path\0"),t.update(n.relativePath),n.bytes===null?t.update("\0deleted"):(t.update("\0bytes\0"),t.update(qt("sha256").update(n.bytes).digest()));return t.digest("hex")}function Wt(e){let t=Pt();if(!t.available)throw new Error(t.reason);let n=ur({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:ie(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:Ee}),packageVersion:t.packageVersion});Li(e.candidateShardPath,n)}function Ve(e,t,n){let r=e.files.filter(a=>{let i=_e(a.path,e.languages);return i==="ambient"||i==="config"&&(!ce(a.path)||n.has(a.path))}).map(a=>{let o=_e(a.path,e.languages)==="config"?a.semanticHash:void 0;return{path:a.path,size:o===void 0?a.size:0,hash:o??a.hash}}).sort((a,i)=>a.path.localeCompare(i.path));return`typescript-project-v3:${qi(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function Ni(e,t){return qi(JSON.stringify({version:1,producerIdentity:t,snapshot:pn(e)}))}function qi(e){return qt("sha256").update(e).digest("hex")}import{closeSync as ic,existsSync as Ze,fstatSync as ac,lstatSync as oc,openSync as sc,renameSync as Jt,rmSync as Pe,statSync as cc,writeSync as dc}from"fs";import{cpus as lc}from"os";import{join as zt}from"path";var Wi=8*1024;function Hi(e,t,n){let r=Buffer.from(t,"utf8"),a=()=>sc(e,"wx",384),i;try{i=a()}catch(o){if(o.code!=="EEXIST")throw o;if(n==="skip")return null;Pe(e,{force:!0}),i=a()}try{dc(i,r);let o=ac(i);return{path:e,content:r,device:o.dev,inode:o.ino}}finally{ic(i)}}function uc(e,t){let n=[];try{if(e.temporaryRootConfigContent!==void 0){let r=Hi(zt(t,"tsconfig.json"),e.temporaryRootConfigContent,"skip");r&&n.push(r)}for(let r of e.temporaryProjectConfigs??[]){let a=Hi(r.path,r.content,"replace");a&&n.push(a)}return n}catch(r){for(let a of n.reverse())Xi(a);throw r}}function Xi(e){if(e)try{let t=oc(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=ie(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;Pe(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function pc(e,t,n){if(!e.defaultOutputPath)return;let r=zt(t,e.defaultOutputPath);n!==r&&Ze(r)&&Jt(r,n)}function gc(e,t,n){if(!e.defaultOutputPath)return null;let r=zt(t,e.defaultOutputPath);if(r===n)return null;let a=`${n}.default-output-backup`;return Pe(a,{force:!0}),Ze(r)?(Jt(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function fc(e){e&&(Pe(e.defaultOutputPath,{force:!0}),e.backupPath&&Ze(e.backupPath)&&Jt(e.backupPath,e.defaultOutputPath))}function mc(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,lc().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Yi(e,t,n,r,a){A(a,"Reindex cancelled by its owner.");let i=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath&&d.boundedConcurrency!==void 0),s=e.filter(d=>!d.config.defaultOutputPath&&d.boundedConcurrency===void 0),c=[];if(c.push(...await Ji(s,mc(s.length,r),t,n,a)),o.length>0){let d=Math.max(1,Math.min(...o.map(l=>l.boundedConcurrency)));c.push(...await Ji(o,d,t,n,a))}for(let d of i)A(a,"Reindex cancelled by its owner."),c.push((await Ht(d,t,n,a)).result);return c.sort((d,l)=>e.findIndex(g=>g.id===d.id)-e.findIndex(g=>g.id===l.id))}async function Ji(e,t,n,r,a){let i=await jr(e,Math.max(1,t),s=>Ht(s,n,r,a));if(t<=1)return i.map(({result:s})=>s);let o=new Map;for(let s of i.filter(c=>c.result.skipped&&c.retryable)){let c=e.find(d=>d.id===s.result.id);c&&(r(`Retrying ${c.label} indexer serially after parallel failure...`),A(a,"Reindex cancelled by its owner."),o.set(c.id,(await Ht(c,n,r,a)).result))}return i.map(({result:s})=>o.get(s.id)??s)}async function Ht(e,t,n,r){A(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Pe(e.scipPath,{force:!0});let a=gc(e.config,t,e.scipPath),i=[],o=[e.binary,...e.args].join(" "),s=C();try{i=uc(e,t),e.trustedProjectTool&&$n(t,e.trustedProjectTool);let d=yn(e.binary,e.args),l=await Ie({command:d.binary,args:d.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:hc(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(l.status!==0){let g=l.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${l.status}${g?`:
|
|
289
289
|
${g}`:""}`)}pc(e.config,t,e.scipPath)}catch(d){if(r?.aborted)throw Sn(r,"Reindex cancelled by its owner.");let l=d instanceof Error?d.message:String(d),g=l.length<=Wi?l:`${l.slice(0,Wi)}
|
|
290
|
-
[indexer failure detail truncated]`,p=`${e.resolvedBinary} indexer failed: ${g}`,f=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:f}},retryable:yc(d)}}finally{fc(a);for(let d of i.reverse())Xi(d)}if(!Ze(e.scipPath)){let d=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,l=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:l}},retryable:!1}}let c;try{c=cc(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},outputBytes:c},retryable:!1}}function hc(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):sn.indexer}function yc(e){return e instanceof cn?e.kind==="spawn"&&zi(e.cause):zi(e)}function zi(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Ki}from"child_process";import{homedir as Qi,platform as Sc}from"os";import{delimiter as bc,join as et}from"path";function Vi(e,t){let n=e.installMethods,r=Oe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let a of n){if(!a.identity||!a.destination){t(`Refusing ${a.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!hn(a.prerequisite))continue;let i=Pc(a);t(`Installing immutable ${a.identity} via ${a.label} into ${i}; expected executable: ${r}.`);try{Ki(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Sc()==="win32"});let o=he(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${a.identity} via ${a.label}${s}; resolved executable: ${o}.`),!0}t(`${a.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${a.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Pc(e){if(e.binary==="npm")return Xt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=Xt("go",["env","GOBIN"]);if(t)return t;let n=Xt("go",["env","GOPATH"]);if(n)return et(n.split(bc)[0],"bin")}return e.binary==="dotnet"?et(process.env.DOTNET_CLI_HOME??Qi(),".dotnet","tools"):e.binary==="dart"?et(process.env.PUB_CACHE??et(Qi(),".pub-cache"),"bin"):e.destination}function Xt(e,t){try{return Ki(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function ga(e){let{projectRoot:t,onStatus:n=console.log}=e,r=e.maxHeapMb??dn(process.env.NODE_OPTIONS)??8192,a=e.skipAutoInstall===!0||e.installMissing!==!0,i=_c(e),o=Date.now(),s=C();rt(x(i.outputScip),{recursive:!0}),rt(x(i.outputDb),{recursive:!0});let c=e.languages??tr(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");n(`Detected languages: ${c.join(", ")}`);let d=at(i.metaPath),l=E("reindex.fingerprint",()=>Mn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},d,e.changeJournal,ht(i.outputDb)),{languages:c.length}),g=l.fingerprint,p=l.mode==="delta"?e.changeJournal?.entries.filter(y=>y.kind!=="add").length??0:0,f=Math.max(0,(d?.files.length??0)-p);n(l.mode==="delta"?`Project fingerprint revalidated ${l.changedPaths.length} changed path(s), reused ${f} accepted file fingerprint(s), and accepted ${g.files.length} input(s)`:`Project fingerprint used full scan: ${l.reason}`);let R=await Ic({opts:e,paths:i,languages:c,fingerprint:g,onStatus:n}),T=R.snapshot,j=R.releaseBuildLock,D=_a(e.trigger),v=Rn(O(x(i.outputDb),"cache-lifecycle.lock"),{waitMs:D?1e3:3e4});if(!v)throw j?.(),new le(D?`Could not acquire scip-query cache lifecycle lock for ${x(i.outputDb)}; another refresh is publishing, so the watcher will retry.`:`Could not acquire scip-query cache lifecycle lock for ${x(i.outputDb)}. A watch daemon or another reindex may hold it. Run "scip-query watch --stop", retry the reindex, then restart with "scip-query watch --daemon".`);let F;try{F=await G("reindex.lock",()=>rd(O(x(i.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:n}),{languages:c.length})}catch(y){throw v.release(),j?.(),y}let _=null,h=Dr();try{l.mode==="delta"&&ht(i.outputDb)!==e.changeJournal?.baseGeneration&&(g=kn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),l={mode:"full",fingerprint:g,reason:"accepted-generation-changed-before-lock"},T=void 0,j?.(),j=void 0,n("Project fingerprint used full scan: accepted-generation-changed-before-lock")),fr(i.outputDb,i.outputScip,i.metaPath);let y=jc(x(i.outputDb));y.removed>0&&n(`Removed ${y.removed} abandoned reindex workspace(s)`);for(let b of y.errors)n(`Could not remove abandoned reindex workspace: ${b}`);let m=null,w=await G("reindex.reuse-check",async()=>(m=await Tc({opts:e,paths:i,languages:c,fingerprint:g,start:o,monotonicStart:s,onStatus:n}),m),()=>({languages:c.length,reused:m!==null}));if(w){na({snapshot:T,paths:i,projectRoot:t,fingerprint:g,onStatus:n});let b=St(i.outputDb,w);return b.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${b.reason}`),gt(t,x(i.outputDb)),w}xn()&&await G("reindex.scip-cli-ready",()=>zc(a,n));let S=Cc(i);_=S.runDir;let P,I=await G("reindex.fresh",async()=>(P=await Oc({opts:e,languages:c,projectRoot:t,paths:i,tempPaths:S,fingerprint:g,start:o,monotonicStart:s,maxHeapMb:r,skipAutoInstall:a,onStatus:n,writeTelemetry:h}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));na({snapshot:T,paths:i,projectRoot:t,fingerprint:g,onStatus:n});let u=St(i.outputDb,I);return u.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${u.reason}`),gt(t,x(i.outputDb)),I}catch(y){let m=ct({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:y instanceof Error?y.message:String(y)});ja(i.metaPath,m);let w=sr(i.outputDb,m);throw w.state==="failed"&&n(`Warning: failed reindex activity telemetry was not recorded: ${w.reason}`),y}finally{_&&Z(_,{recursive:!0,force:!0}),F(),v.release(),j?.()}}async function Ic(e){let{opts:t,paths:n,languages:r,fingerprint:a,onStatus:i}=e,o=t.projectRoot;if(!(t.skipIfUnchanged!==!1&&!mr(o,n.outputDb)&&Zi(n.outputScip)===Zi(O(x(n.outputDb),"index.scip"))))return{snapshot:void 0,releaseBuildLock:void 0};let c=je(o),d=c?.clean?Be(c,a):void 0;if(c&&!c.clean&&!ra(n))return ta({context:c,languages:r,opts:t,paths:n,fingerprint:a,projectRoot:o,onStatus:i,successMessage:"dirty worktree reindex",failurePrefix:"Shared baseline fork failed"}),{snapshot:d,releaseBuildLock:void 0};if(!d)return{snapshot:void 0,releaseBuildLock:void 0};let l=bt(d);if(l){if(!vc(n,a))try{Ue({snapshot:d,manifest:l,targetCacheDir:x(n.outputDb),targetProjectRoot:o}),i(`Attached shared generation ${d.generationId.slice(0,12)}`)}catch(p){i(`Shared generation attach failed; continuing locally: ${ee(p)}`)}return{snapshot:d,releaseBuildLock:void 0}}c&&!ra(n)&&ta({context:c,languages:r,opts:t,paths:n,fingerprint:a,projectRoot:o,onStatus:i,successMessage:"cold worktree reindex",failurePrefix:"Compatible shared baseline fork failed",compatible:!0});let g=await Sr(d);if(g.kind==="owner")return{snapshot:d,releaseBuildLock:g.release};if(g.kind==="generation-ready"){let p=bt(d);if(p)try{Ue({snapshot:d,manifest:p,targetCacheDir:x(n.outputDb),targetProjectRoot:o,action:"waited"}),i(`Attached shared generation ${d.generationId.slice(0,12)} after waiting`)}catch(f){i(`Shared generation attach failed after waiting; continuing locally: ${ee(f)}`)}}else i("Shared generation build lock timed out; continuing with an isolated local reindex");return{snapshot:d,releaseBuildLock:void 0}}function ta(e){let t=hr(e.context,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath},e.fingerprint);if(t)try{Ue({snapshot:t.snapshot,manifest:t.manifest,targetCacheDir:x(e.paths.outputDb),targetProjectRoot:e.projectRoot,persistLease:!1}),Pr(t.snapshot,x(e.paths.outputDb)),e.onStatus(`Forked ${e.compatible?"compatible ":""}shared baseline ${t.snapshot.generationId.slice(0,12)} for ${e.successMessage}`)}catch(n){e.onStatus(`${e.failurePrefix}; continuing locally: ${ee(n)}`)}}function na(e){if(e.snapshot)try{let t=je(e.projectRoot),n=t?Be(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=yr({snapshot:e.snapshot,sourceCacheDir:x(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let a=je(e.projectRoot);return(a?Be(a,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});br(e.snapshot,x(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${ee(t)}`)}}function vc(e,t){if(!L(e.outputScip)||!L(e.outputDb)||Ca(e.metaPath,t)===null)return!1;let n=W(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function ra(e){if(!L(e.outputScip)||!L(e.outputDb)||!re(e.metaPath))return!1;let t=W(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function ee(e){return e instanceof Error?e.message:String(e)}async function Kt(e,t,n,r,a,i,o,s=!1){try{await or(Mr({indexPath:n,evidenceDbPath:o,reuseExisting:a,affectedFiles:i,forceDerivedRebuild:s}),{projectRoot:e,dbPath:t,onStatus:r})}catch(c){r(`Runtime-boundary extraction unavailable: ${c instanceof Error?c.message:String(c)}.`)}}function _c(e){let t=e.outputScip??O(e.projectRoot,"index.scip"),n=e.outputDb??O(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:O(x(n),"meta.json")}}async function Tc(e){let t=W(e.paths.outputDb,e.paths.metaPath),n=Ca(e.paths.metaPath,e.fingerprint);if(e.opts.skipIfUnchanged===!1||!L(e.paths.outputScip)||!L(e.paths.outputDb)||n===null||t.state==="invalid"||t.state==="drifted")return null;let r=$e(e.paths.outputDb,e.fingerprint,e.languages);if(r.state!=="complete")return e.onStatus(Vt("Accepted SQLite index",r)),null;Ae(Ne(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await Kt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),W(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(Ge(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation")),n==="operational-config-compatible"&&(ud(e.paths.metaPath,e.fingerprint,e.languages,e.opts),Ge(e.paths.outputDb,e.paths.metaPath),e.onStatus("Migrated operational .scipquery.json metadata without rerunning language indexers."));let a=C()-e.monotonicStart,i=ct({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return ja(e.paths.metaPath,i),e.onStatus(`Index unchanged; reused existing SQLite index in ${(a/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:a,reused:!0,skipped:[],lastRefresh:i,shards:wc(e.paths,e.languages,e.opts,e.fingerprint)}}function wc(e,t,n,r){let a=Zt(r,t,n);return t.map(i=>({id:i,language:i,reused:!0,strategy:"reused",fingerprint:Re(a[i]),outputBytes:te(en(e.outputDb,i)),durationMs:0}))}function Cc(e){let t=xc(O(x(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:O(t,tt(e.outputScip)),tempOutputDb:O(t,tt(e.outputDb)),tempMetaPath:O(t,tt(e.metaPath))}}function jc(e){let t=[],n;try{n=ua(e,{withFileTypes:!0})}catch(a){return{removed:0,errors:[ee(a)]}}let r=0;for(let a of n)if(!(!a.name.startsWith("reindex-")||!a.isDirectory()))try{Z(O(e,a.name),{recursive:!0,force:!0}),r+=1}catch(i){t.push(`${a.name}: ${ee(i)}`)}return{removed:r,errors:t}}async function Oc(e){let t={...process.env,NODE_OPTIONS:ln(process.env.NODE_OPTIONS,e.maxHeapMb)},n,r=await G("reindex.language-indexers",async()=>(n=await kc(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:a,skippedLanguages:i,reusedLanguages:o,languageFingerprints:s,shards:c,typescriptProjectShardContext:d,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),Fc({run:e,indexedOutputs:a,skippedLanguages:i,reusedLanguages:o})){let f=await G("reindex.publish",()=>qc(e,a,i,o,s,d),{mode:"metadata-only",languages:a.length,reused:o.length}),R=f.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(R/1e3).toFixed(1)}s`),{languages:a.map(T=>T.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:R,reused:!0,skipped:i,lastRefresh:f,shards:c,writeTelemetry:e.writeTelemetry}}let g=await G("reindex.publish",()=>Bc(e,t,a,i,o,s,d,l),{mode:l?"incremental-or-fallback":"full",languages:a.length,reused:o.length,skipped:i.length}),p=g.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:a.map(f=>f.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:i,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}function Fc(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!L(e.run.paths.outputScip)||!L(e.run.paths.outputDb))return!1;let t=W(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(a=>a.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(a=>n.has(a)&&r.has(a))}async function kc(e,t){let n=e.opts.skipIfUnchanged===!1,r=Ac({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,projectFingerprint:e.fingerprint});if(n)for(let[u,b]of r)b.reused&&r.set(u,{...b,reused:!1,reason:"forced reindex requested"});let a=[],i=new Set;for(let[u,b]of r)b.reused&&(a.push({language:u,scipPath:b.scipPath}),i.add(u));for(let u of i)e.onStatus(`Reusing cached ${u} SCIP shard (language inputs unchanged).`);let o=r.get("typescript"),s=W(e.paths.outputDb,e.paths.metaPath),c=re(e.paths.metaPath),d=s.state==="legacy"||s.state==="current",l=c?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),g;n&&o&&!o.reused&&(g="forced reindex rebuilds from the compilers");let p=!n&&o&&!o.reused&&d?Ui({projectRoot:e.projectRoot,cacheDir:x(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:ne(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:ne(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:at(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus,onUnavailable:u=>{g=u}}):null,f=new Set(p?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1){let u=e.languages.filter(b=>!i.has(b)&&!f.has(b));if(u.length>0){let b=u.length===1&&u[0]==="typescript"&&g?`: ${g}`:"";throw new Error(`Incremental indexing is unavailable for ${u.join(", ")}${b}. The accepted index was preserved because whole-project rebuilds are disabled; run scip-query reindex --allow-expensive-rebuild only when you explicitly want that fallback.`)}}let R=p||i.has("typescript")?void 0:Dc(e,r),T=R&&n?{...R,classification:new Map([...R.classification].map(([u,b])=>[u,b.reused?{...b,reused:!1,reason:"forced reindex requested"}:b])),reusedProjects:[],missedProjectIds:new Set(R.allProjects.map(u=>`typescript:${u}`))}:R,{preparedRuns:j,skippedLanguages:D,languageOutputScipPaths:v}=Xc({languages:e.languages.filter(u=>!i.has(u)&&!f.has(u)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:T?.allProjects,typescriptShardCostDir:x(e.paths.outputDb),clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),F=T?j.filter(u=>u.language!=="typescript"||T.missedProjectIds.has(u.id)):j,_=await Yi(F,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(fn())for(let u of _)mn({type:"span",name:`reindex.language-indexer.${u.id}`,durationMs:Math.round(u.durationMs),ok:!u.skipped,language:u.language,indexerCommand:u.command,outputBytes:u.outputBytes,measurement:"indexer-run-result"});Qc(x(e.paths.outputDb),e.projectRoot,F,_);let h=[];if(T){Nc(e.paths.outputDb,_,e.writeTelemetry);let u=v.typescript??e.tempPaths.tempOutputScip;h=Lc({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:u,reusedProjects:T.reusedProjects,writeTelemetry:e.writeTelemetry})}let y=[..._,...h],{indexedOutputs:m}=Vc(y,D),w=p?[{language:"typescript",scipPath:p.scipPath}]:[],S=[...a,...w,...m];Zc(S,D,e.languages,e.opts.allowPartial,e.onStatus);let P=p?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:p.scipPath,outputScipPath:p.scipPath,durationMs:p.durationMs,command:"watch-service:typescript-index",outputBytes:te(p.scipPath)??void 0,producedOutputBytes:te(p.affectedScipPath)??void 0}]:[],I=$c(r,[..._,...P],T?{outputDb:e.paths.outputDb,classification:T.classification}:void 0,g);return{indexedOutputs:S,skippedLanguages:D,reusedLanguages:[...i],languageFingerprints:Gc(r,e.languages),shards:I,typescriptProjectShardContext:T?{projects:T.allProjects,fingerprints:T.fingerprints}:void 0,incrementalTypeScript:p??void 0}}function Dc(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=X(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let a=ai(e.projectRoot,r),i=ni(n.fingerprint.files,r),o=ri(r,a),s=ii(r,i,o),c=re(e.paths.metaPath),l=Mc(c,s,R=>L(ot(e.paths.outputDb,R))),g=[...l.entries()].filter(([,R])=>R.reused).map(([R])=>R),p=new Set(g),f=new Set(r.filter(R=>!p.has(R)).map(R=>`typescript:${R}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:g,missedProjectIds:f}}function Mc(e,t,n){let r=new Map;for(let a of Object.keys(t)){let i=t[a];if(!e){r.set(a,{reused:!1,reason:"no reindex metadata found",fingerprint:i});continue}let o=e.version===ae&&ut(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[a]:void 0;if(!o){r.set(a,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:i});continue}if(!n(a)){r.set(a,{reused:!1,reason:"cached shard file missing on disk",fingerprint:i});continue}if(N(o)!==N(i)){r.set(a,{reused:!1,reason:"project inputs changed since last index",fingerprint:i});continue}r.set(a,{reused:!0,fingerprint:i})}return r}function Nc(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let a=r.id.slice(11),i=ot(e,a);rt(x(i),{recursive:!0}),V(n,K(r.scipPath,i,void 0,{shareImmutable:!0}))}}function Lc(e){return e.reusedProjects.map((t,n)=>{let r=ot(e.outputDb,t),a=ne(e.tempOutputScip,"typescript-project-cached",n);return V(e.writeTelemetry,K(r,a,void 0,{shareImmutable:!0})),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:a,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:te(a)??void 0}})}function Ac(e){let t=re(e.paths.metaPath),n=Zt(e.projectFingerprint,e.languages,e),r=t&&L(e.paths.outputDb)?$e(e.paths.outputDb,e.projectFingerprint,e.languages):null,a=new Map;for(let i of e.languages){let o=en(e.paths.outputDb,i),s=n[i];if(!t){a.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:o});continue}if(t.version!==ae){a.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!ut(t).languageShardReuse||!t.languageFingerprints){a.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:o});continue}let c=t.languageFingerprints[i];if(!c){a.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:o});continue}if(!L(o)){a.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}let d=i==="typescript"?cd(e.projectRoot,c):c;if(N(d)!==N(s)){a.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:o});continue}if(r?.state==="unavailable"||r?.state==="incomplete"&&r.affectedLanguages.includes(i)){a.set(i,{reused:!1,reason:Vt("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:o});continue}a.set(i,{reused:!0,fingerprint:s,scipPath:o})}return a}function $c(e,t,n,r){let a=[];for(let[i,o]of e)o.reused&&a.push({id:i,language:i,reused:!0,strategy:"reused",fingerprint:Re(o.fingerprint),outputBytes:te(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,c=s?n.classification.get(s):void 0;a.push({id:i.id,language:i.language,reused:!1,strategy:i.command==="watch-service:typescript-index"?"incremental":"full",missReason:c?.reason??o?.reason??i.skipped?.reason,fallbackReason:i.language==="typescript"?r:void 0,fingerprint:c?Re(c.fingerprint):o?Re(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,producedOutputBytes:i.producedOutputBytes,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&a.push({id:`typescript:${i}`,language:"typescript",reused:!0,strategy:"reused",fingerprint:Re(o.fingerprint),outputBytes:te(ot(n.outputDb,i)),durationMs:0});return a}function Re(e){return Rc("sha256").update(N(e)).digest("hex").slice(0,16)}function te(e){try{return Qt(e).size}catch{return null}}function Gc(e,t){let n={};for(let r of t){let a=e.get(r);a&&(n[r]=a.fingerprint)}return n}async function Bc(e,t,n,r,a,i,o,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,d=!1;c&&(d=E("reindex.publish.scip-output",()=>{let h=Jc({run:e,indexedOutputs:n,incrementalTypeScript:s,typescriptReused:a.includes("typescript")});return ia(e.paths.outputDb,h,e.writeTelemetry),aa(h,e.tempPaths.tempOutputScip,e.onStatus)}));let l=await G("reindex.publish.sqlite-output",()=>ed({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:d,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return d;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Wt({cacheDir:x(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let h=n.map(y=>y.language==="typescript"?{language:y.language,scipPath:s.candidateScipPath}:y);return ia(e.paths.outputDb,h,e.writeTelemetry),d=aa(h,e.tempPaths.tempOutputScip,e.onStatus),d}}));A(e.opts.signal,"Reindex cancelled by its owner."),E("reindex.publish.auxiliary-documents",()=>{Ae(Ne(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),await G("reindex.publish.runtime-boundaries",async()=>{let h=s?.plan.mode==="full-project",y=s?.dependencyGraphUnchanged===!0;h?e.onStatus("Rebuilding compiler-derived runtime-boundary relationships while retaining unchanged per-file extraction facts."):y&&e.onStatus("Reusing runtime-boundary relationships because TypeScript semantics are unchanged."),await Kt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,y,y?void 0:h?s?.changedFiles:s?.affectedFiles,O(x(e.paths.outputDb),Un),h)});let g=E("reindex.publish.sqlite-layout",()=>Ot(e.tempPaths.tempOutputDb,{analyze:Uc(s,l.mode)}));g.added.length>0&&e.onStatus(`Added SQLite query indexes: ${g.added.join(", ")}`),g.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${g.removed.join(", ")}`),E("reindex.publish.coverage",()=>Sa(e,e.tempPaths.tempOutputDb,n.map(h=>h.language)));let p,f=null;l.mode==="incremental"&&s&&E("reindex.publish.reference-fragments",()=>{if(s.dependencyGraphUnchanged){let m=new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});try{f=yt(m),e.onStatus("Preserved exact TypeScript reference fragments and dependency relationships because only trivia changed.")}finally{m.close()}return}let h=null,y=null;try{h=E("reindex.publish.reference-fragments.open-candidate",()=>new $({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip})),y=E("reindex.publish.reference-fragments.open-evidence",()=>new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip})),p=s.dependencyGraphSnapshot?E("reindex.publish.reference-fragments.dependency-graph",()=>Jn(h,s.dependencyGraphSnapshot,s.affectedFiles,s.deletedFiles))??void 0:void 0;let m=new Set(s.deletedFiles),w=m.size===0?s.referenceFragmentsByFile:new Map([...s.referenceFragmentsByFile].filter(([P])=>!m.has(P))),S=E("reindex.publish.reference-fragments.seed",()=>Xn(h,e.fingerprint,w,y,p,new Set(s.affectedFiles)));e.onStatus(`Cached exact TypeScript reference fragments for ${S.affectedFiles} affected document(s) and carried ${S.carriedFiles} unaffected document(s) forward.`),S.skippedAffectedFiles>0&&e.onStatus(`Skipped exact TypeScript reference fragment prefill for ${S.skippedAffectedFiles} affected document(s) whose semantic identity was unavailable.`)}catch(m){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${m instanceof Error?m.message:String(m)}.`)}finally{h?.close(),y?.close()}});let R=at(e.paths.metaPath);l.mode==="incremental"&&s||await fa({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousSnapshot:R,currentSnapshot:e.fingerprint,onStatus:e.onStatus});let T=E("reindex.publish.affected-shadow",()=>l.mode==="incremental"&&s?nd(s,l.changedDocumentPaths):vt({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:R,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"})),j=ct({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(h=>h.language),skipped:[...r]}),D=l.mode==="incremental"&&l.scipCompanion==="deferred",{metadata:v,pruneProjects:F}=ha({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:j});v.scipCompanion=D?"deferred":"current",E("reindex.publish.metadata",()=>{ya(e),ba(e.paths.outputDb,F),st(e.tempPaths.tempMetaPath,v)});let _=E("reindex.publish.generation-handoff",()=>gr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}));return _.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${_.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),l.mode==="incremental"&&s&&E("reindex.publish.dependency-graph",()=>{let h=null;try{h=new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let y=s.plan.mode==="full-project"&&s.plan.reasons.length===0?s.changedFiles:s.affectedFiles,m=!1;if(s.dependencyGraphUnchanged){let w=yt(h),S=f&&w?qn(h,"file-dependency-graph",f,w):0;m=S>0,e.onStatus(m?`Carried ${S} unchanged dependency graph product(s) forward without rebuilding them.`:"No persisted dependency graph product required rekeying; the next graph consumer can materialize it.")}else s.dependencyGraphSnapshot?m=Hn(h,s.dependencyGraphSnapshot,y,p):De(h);s.dependencyGraphUnchanged||e.onStatus(m?`Carried the dependency graph forward by replacing ${y.length} changed dependency owner(s).`:"Materialized a fresh dependency graph for the accepted generation because no compatible prior graph was available.")}catch(y){e.onStatus(`Dependency graph carry-forward unavailable: ${y instanceof Error?y.message:String(y)}. The next graph consumer will rebuild it.`)}finally{h?.close()}}),E("reindex.publish.cleanup",()=>{pr(x(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),dr(x(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[])}),E("reindex.publish.shadow-telemetry",()=>ma(e.paths.outputDb,T,e.onStatus)),j}function Uc(e,t){return t!=="incremental"||!e||e.plan.mode==="full-project"?!0:e.affectedFiles.length*20>=e.projectFileCount}async function qc(e,t,n,r,a,i){let o=at(e.paths.metaPath),s=null;try{V(e.writeTelemetry,K(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=$r("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}Ae(Ne(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await Kt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Ot(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),Sa(e,e.paths.outputDb,t.map(p=>p.language)),s==null&&await fa({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,onStatus:e.onStatus}),s??=vt({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=ct({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:g}=ha({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:a,typescriptProjectShardContext:i,lastRefresh:d});return ya(e),ba(e.paths.outputDb,g),st(e.paths.metaPath,l),Ge(e.paths.outputDb,e.paths.metaPath),ma(e.paths.outputDb,s,e.onStatus),d}async function fa(e){if(!L(e.previousDbPath))return;let t=q(e.previousSnapshot,e.currentSnapshot);if(t.changes.length===0||ye(t).fullProject)return;let n=null;try{if(n=new $({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),Me(n))return;let r=await G("reindex.publish.affected-shadow.warm-sources",()=>zn(n,{yieldToEventLoop:()=>new Promise(a=>setImmediate(a))}));e.onStatus(`Persisted import products for ${r.files} document(s) before the affected-set shadow.`)}catch(r){e.onStatus(`Affected-set shadow import warm-up unavailable: ${r instanceof Error?r.message:String(r)}.`)}finally{n?.close()}}function at(e){return lt(re(e)?.fingerprint)}function ma(e,t,n){try{Gr(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 ha(e){let t=Wc({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:ae,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function ya(e){A(e.opts.signal,"Reindex cancelled by its owner.");let t=Dn(e.projectRoot,e.fingerprint);if(N(t)===N(e.fingerprint))return;let n=new Map(e.fingerprint.files.map(i=>[i.path,i])),r=new Map(t.files.map(i=>[i.path,i])),a=[...new Set([...n.keys(),...r.keys()])].filter(i=>N(n.get(i))!==N(r.get(i))).slice(0,5);throw new Error(`Project inputs changed during reindex (${a.join(", ")||"unknown path"}); refusing to publish artifacts built from a different filesystem snapshot.`)}function Sa(e,t,n){let r=$e(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${Vt("Candidate SQLite index",r)} Refusing to publish it.`)}function Vt(e,t){if(t.state==="unavailable")return`${e} document coverage could not be verified (${t.reason}); rebuilding cached language shards.`;let n=t.missingPaths.length>0?` First missing path: ${t.missingPaths[0]}.`:"";return`${e} is missing ${t.missingDocumentCount} fingerprinted source document${t.missingDocumentCount===1?"":"s"}; rebuilding affected language shards.${n}`}function Wc(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=re(e.metaPath),n=t?.version===ae?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function ba(e,t){let n=wa(e);if(t===null){Z(n,{recursive:!0,force:!0});return}let r;try{r=ua(n)}catch{return}for(let a of Hc(r,t))Z(O(n,a),{force:!0})}function Hc(e,t){let n=new Set(t.map(r=>`${Mt(r)}.scip`));return e.filter(r=>!n.has(r))}function Jc(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(o=>o.language==="typescript");if(!t)return[...e.indexedOutputs];if(!e.typescriptReused)return[...e.indexedOutputs];let n=W(e.run.paths.outputDb,e.run.paths.metaPath),r=n.state==="current"?n.generation.publication?.typescriptOverlayGeneration:void 0;if(!(n.state==="current"?n.generation.publication?.scipCompanion==="deferred":re(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let i=ne(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),Wt({cacheDir:x(e.run.paths.outputDb),generationIdentity:r,baseShardPath:t.scipPath,candidateShardPath:i}),e.indexedOutputs.map(o=>o.language==="typescript"?{language:o.language,scipPath:i}:o)}function ia(e,t,n){for(let r of t){let a=en(e,r.language);rt(x(a),{recursive:!0}),r.scipPath!==a&&V(n,K(r.scipPath,a,void 0,{shareImmutable:!0}))}}async function zc(e,t){let n=In();if(n){if(n.source==="path"&&ea()!=="win32"){let r=_n();vn(r)||(e?t(`scip on PATH reports ${r??"an unknown version"}; the reviewed version is ${Ce} and compatibility is unverified. Run scip-query setup --install-missing to install the reviewed release.`):(t(`scip on PATH reports ${r??"an unknown version"}; installing the reviewed ${Ce}.`),await Tn(t)))}return}if(ea()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
290
|
+
[indexer failure detail truncated]`,p=`${e.resolvedBinary} indexer failed: ${g}`,f=e.label===e.language?p:`${e.label}: ${p}`;return n(`Skipping ${e.label}: ${p}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:f}},retryable:yc(d)}}finally{fc(a);for(let d of i.reverse())Xi(d)}if(!Ze(e.scipPath)){let d=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,l=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},skipped:{language:e.language,reason:l}},retryable:!1}}let c;try{c=cc(e.scipPath).size}catch{c=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:C()-s,command:o,...e.outputComposition?{outputComposition:e.outputComposition}:{},outputBytes:c},retryable:!1}}function hc(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):sn.indexer}function yc(e){return e instanceof cn?e.kind==="spawn"&&zi(e.cause):zi(e)}function zi(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as Ki}from"child_process";import{homedir as Qi,platform as Sc}from"os";import{delimiter as bc,join as et}from"path";function Vi(e,t){let n=e.installMethods,r=Oe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let a of n){if(!a.identity||!a.destination){t(`Refusing ${a.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!hn(a.prerequisite))continue;let i=Pc(a);t(`Installing immutable ${a.identity} via ${a.label} into ${i}; expected executable: ${r}.`);try{Ki(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Sc()==="win32"});let o=he(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${a.identity} via ${a.label}${s}; resolved executable: ${o}.`),!0}t(`${a.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${a.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function Pc(e){if(e.binary==="npm")return Xt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=Xt("go",["env","GOBIN"]);if(t)return t;let n=Xt("go",["env","GOPATH"]);if(n)return et(n.split(bc)[0],"bin")}return e.binary==="dotnet"?et(process.env.DOTNET_CLI_HOME??Qi(),".dotnet","tools"):e.binary==="dart"?et(process.env.PUB_CACHE??et(Qi(),".pub-cache"),"bin"):e.destination}function Xt(e,t){try{return Ki(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function ga(e){let{projectRoot:t,onStatus:n=console.log}=e,r=e.maxHeapMb??dn(process.env.NODE_OPTIONS)??8192,a=e.skipAutoInstall===!0||e.installMissing!==!0,i=_c(e),o=Date.now(),s=C();rt(x(i.outputScip),{recursive:!0}),rt(x(i.outputDb),{recursive:!0});let c=e.languages??tr(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");n(`Detected languages: ${c.join(", ")}`);let d=at(i.metaPath),l=E("reindex.fingerprint",()=>Mn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},d,e.changeJournal,ht(i.outputDb)),{languages:c.length}),g=l.fingerprint,p=l.mode==="delta"?e.changeJournal?.entries.filter(y=>y.kind!=="add").length??0:0,f=Math.max(0,(d?.files.length??0)-p);n(l.mode==="delta"?`Project fingerprint revalidated ${l.changedPaths.length} changed path(s), reused ${f} accepted file fingerprint(s), and accepted ${g.files.length} input(s)`:`Project fingerprint used full scan: ${l.reason}`);let R=await vc({opts:e,paths:i,languages:c,fingerprint:g,onStatus:n}),T=R.snapshot,j=R.releaseBuildLock,D=_a(e.trigger),I=Rn(O(x(i.outputDb),"cache-lifecycle.lock"),{waitMs:D?1e3:3e4});if(!I)throw j?.(),new le(D?`Could not acquire scip-query cache lifecycle lock for ${x(i.outputDb)}; another refresh is publishing, so the watcher will retry.`:`Could not acquire scip-query cache lifecycle lock for ${x(i.outputDb)}. A watch daemon or another reindex may hold it. Run "scip-query watch --stop", retry the reindex, then restart with "scip-query watch --daemon".`);let F;try{F=await G("reindex.lock",()=>id(O(x(i.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:n}),{languages:c.length})}catch(y){throw I.release(),j?.(),y}let _=null,h=Dr();try{l.mode==="delta"&&ht(i.outputDb)!==e.changeJournal?.baseGeneration&&(g=kn(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),l={mode:"full",fingerprint:g,reason:"accepted-generation-changed-before-lock"},T=void 0,j?.(),j=void 0,n("Project fingerprint used full scan: accepted-generation-changed-before-lock")),fr(i.outputDb,i.outputScip,i.metaPath);let y=jc(x(i.outputDb));y.removed>0&&n(`Removed ${y.removed} abandoned reindex workspace(s)`);for(let b of y.errors)n(`Could not remove abandoned reindex workspace: ${b}`);let m=null,w=await G("reindex.reuse-check",async()=>(m=await Tc({opts:e,paths:i,languages:c,fingerprint:g,start:o,monotonicStart:s,onStatus:n}),m),()=>({languages:c.length,reused:m!==null}));if(w){na({snapshot:T,paths:i,projectRoot:t,fingerprint:g,onStatus:n});let b=St(i.outputDb,w);return b.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${b.reason}`),gt(t,x(i.outputDb)),w}xn()&&await G("reindex.scip-cli-ready",()=>Xc(a,n));let S=Cc(i);_=S.runDir;let P,v=await G("reindex.fresh",async()=>(P=await Oc({opts:e,languages:c,projectRoot:t,paths:i,tempPaths:S,fingerprint:g,start:o,monotonicStart:s,maxHeapMb:r,skipAutoInstall:a,onStatus:n,writeTelemetry:h}),P),()=>({languages:c.length,reused:P?.reused,skipped:P?.skipped.length}));na({snapshot:T,paths:i,projectRoot:t,fingerprint:g,onStatus:n});let u=St(i.outputDb,v);return u.state==="failed"&&n(`Warning: reindex succeeded, but activity telemetry was not recorded: ${u.reason}`),gt(t,x(i.outputDb)),v}catch(y){let m=ct({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:y instanceof Error?y.message:String(y)});ja(i.metaPath,m);let w=sr(i.outputDb,m);throw w.state==="failed"&&n(`Warning: failed reindex activity telemetry was not recorded: ${w.reason}`),y}finally{_&&ee(_,{recursive:!0,force:!0}),F(),I.release(),j?.()}}async function vc(e){let{opts:t,paths:n,languages:r,fingerprint:a,onStatus:i}=e,o=t.projectRoot;if(!(t.skipIfUnchanged!==!1&&!mr(o,n.outputDb)&&Zi(n.outputScip)===Zi(O(x(n.outputDb),"index.scip"))))return{snapshot:void 0,releaseBuildLock:void 0};let c=je(o),d=c?.clean?Be(c,a):void 0;if(c&&!c.clean&&!ra(n))return ta({context:c,languages:r,opts:t,paths:n,fingerprint:a,projectRoot:o,onStatus:i,successMessage:"dirty worktree reindex",failurePrefix:"Shared baseline fork failed"}),{snapshot:d,releaseBuildLock:void 0};if(!d)return{snapshot:void 0,releaseBuildLock:void 0};let l=bt(d);if(l){if(!Ic(n,a))try{Ue({snapshot:d,manifest:l,targetCacheDir:x(n.outputDb),targetProjectRoot:o}),i(`Attached shared generation ${d.generationId.slice(0,12)}`)}catch(p){i(`Shared generation attach failed; continuing locally: ${te(p)}`)}return{snapshot:d,releaseBuildLock:void 0}}c&&!ra(n)&&ta({context:c,languages:r,opts:t,paths:n,fingerprint:a,projectRoot:o,onStatus:i,successMessage:"cold worktree reindex",failurePrefix:"Compatible shared baseline fork failed",compatible:!0});let g=await Sr(d);if(g.kind==="owner")return{snapshot:d,releaseBuildLock:g.release};if(g.kind==="generation-ready"){let p=bt(d);if(p)try{Ue({snapshot:d,manifest:p,targetCacheDir:x(n.outputDb),targetProjectRoot:o,action:"waited"}),i(`Attached shared generation ${d.generationId.slice(0,12)} after waiting`)}catch(f){i(`Shared generation attach failed after waiting; continuing locally: ${te(f)}`)}}else i("Shared generation build lock timed out; continuing with an isolated local reindex");return{snapshot:d,releaseBuildLock:void 0}}function ta(e){let t=hr(e.context,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath},e.fingerprint);if(t)try{Ue({snapshot:t.snapshot,manifest:t.manifest,targetCacheDir:x(e.paths.outputDb),targetProjectRoot:e.projectRoot,persistLease:!1}),Pr(t.snapshot,x(e.paths.outputDb)),e.onStatus(`Forked ${e.compatible?"compatible ":""}shared baseline ${t.snapshot.generationId.slice(0,12)} for ${e.successMessage}`)}catch(n){e.onStatus(`${e.failurePrefix}; continuing locally: ${te(n)}`)}}function na(e){if(e.snapshot)try{let t=je(e.projectRoot),n=t?Be(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=yr({snapshot:e.snapshot,sourceCacheDir:x(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let a=je(e.projectRoot);return(a?Be(a,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});br(e.snapshot,x(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${te(t)}`)}}function Ic(e,t){if(!L(e.outputScip)||!L(e.outputDb)||Ca(e.metaPath,t)===null)return!1;let n=B(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function ra(e){if(!L(e.outputScip)||!L(e.outputDb)||!z(e.metaPath))return!1;let t=B(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function te(e){return e instanceof Error?e.message:String(e)}async function Kt(e,t,n,r,a,i,o,s=!1){try{await or(Mr({indexPath:n,evidenceDbPath:o,reuseExisting:a,affectedFiles:i,forceDerivedRebuild:s}),{projectRoot:e,dbPath:t,onStatus:r})}catch(c){r(`Runtime-boundary extraction unavailable: ${c instanceof Error?c.message:String(c)}.`)}}function _c(e){let t=e.outputScip??O(e.projectRoot,"index.scip"),n=e.outputDb??O(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:O(x(n),"meta.json")}}async function Tc(e){let t=B(e.paths.outputDb,e.paths.metaPath),n=Ca(e.paths.metaPath,e.fingerprint);if(e.opts.skipIfUnchanged===!1||!L(e.paths.outputScip)||!L(e.paths.outputDb)||n===null||t.state==="invalid"||t.state==="drifted")return null;let r=$e(e.paths.outputDb,e.fingerprint,e.languages);if(r.state!=="complete")return e.onStatus(Vt("Accepted SQLite index",r)),null;Ae(Ne(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await Kt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),B(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(Ge(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation")),n==="operational-config-compatible"&&(pd(e.paths.metaPath,e.fingerprint,e.languages,e.opts),Ge(e.paths.outputDb,e.paths.metaPath),e.onStatus("Migrated operational .scipquery.json metadata without rerunning language indexers."));let a=C()-e.monotonicStart,i=ct({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return ja(e.paths.metaPath,i),e.onStatus(`Index unchanged; reused existing SQLite index in ${(a/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:a,reused:!0,skipped:[],lastRefresh:i,shards:wc(e.paths,e.languages,e.opts,e.fingerprint)}}function wc(e,t,n,r){let a=Zt(r,t,n);return t.map(i=>({id:i,language:i,reused:!0,strategy:"reused",fingerprint:Re(a[i]),outputBytes:ne(en(e.outputDb,i)),durationMs:0}))}function Cc(e){let t=xc(O(x(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:O(t,tt(e.outputScip)),tempOutputDb:O(t,tt(e.outputDb)),tempMetaPath:O(t,tt(e.metaPath))}}function jc(e){let t=[],n;try{n=ua(e,{withFileTypes:!0})}catch(a){return{removed:0,errors:[te(a)]}}let r=0;for(let a of n)if(!(!a.name.startsWith("reindex-")||!a.isDirectory()))try{ee(O(e,a.name),{recursive:!0,force:!0}),r+=1}catch(i){t.push(`${a.name}: ${te(i)}`)}return{removed:r,errors:t}}async function Oc(e){let t={...process.env,NODE_OPTIONS:ln(process.env.NODE_OPTIONS,e.maxHeapMb)},n,r=await G("reindex.language-indexers",async()=>(n=await kc(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:a,skippedLanguages:i,reusedLanguages:o,languageFingerprints:s,shards:c,typescriptProjectShardContext:d,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),Fc({run:e,indexedOutputs:a,skippedLanguages:i,reusedLanguages:o})){let f=await G("reindex.publish",()=>qc(e,a,i,o,s,d),{mode:"metadata-only",languages:a.length,reused:o.length}),R=f.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(R/1e3).toFixed(1)}s`),{languages:a.map(T=>T.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:R,reused:!0,skipped:i,lastRefresh:f,shards:c,writeTelemetry:e.writeTelemetry}}let g=await G("reindex.publish",()=>Bc(e,t,a,i,o,s,d,l),{mode:l?"incremental-or-fallback":"full",languages:a.length,reused:o.length,skipped:i.length}),p=g.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:a.map(f=>f.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:i,lastRefresh:g,shards:c,writeTelemetry:e.writeTelemetry}}function Fc(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!L(e.run.paths.outputScip)||!L(e.run.paths.outputDb))return!1;let t=B(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(a=>a.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(a=>n.has(a)&&r.has(a))}async function kc(e,t){let n=e.opts.skipIfUnchanged===!1,r=Ac({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath,projectFingerprint:e.fingerprint});if(n)for(let[u,b]of r)b.reused&&r.set(u,{...b,reused:!1,reason:"forced reindex requested"});let a=[],i=new Set;for(let[u,b]of r)b.reused&&(a.push({language:u,scipPath:b.scipPath}),i.add(u));for(let u of i)e.onStatus(`Reusing cached ${u} SCIP shard (language inputs unchanged).`);let o=r.get("typescript"),s=B(e.paths.outputDb,e.paths.metaPath),c=z(e.paths.metaPath),d=s.state==="legacy"||s.state==="current",l=c?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),g;n&&o&&!o.reused&&(g="forced reindex rebuilds from the compilers");let p=!n&&o&&!o.reused&&d?Ui({projectRoot:e.projectRoot,cacheDir:x(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:re(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:re(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:at(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,...s.state==="current"&&s.generation.publication?.scipCompanion==="deferred"&&s.generation.publication.typescriptOverlayGeneration?{previousOverlayGeneration:s.generation.publication.typescriptOverlayGeneration}:{},onStatus:e.onStatus,onUnavailable:u=>{g=u}}):null,f=new Set(p?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1){let u=e.languages.filter(b=>!i.has(b)&&!f.has(b));if(u.length>0){let b=u.length===1&&u[0]==="typescript"&&g?`: ${g}`:"";throw new Error(`Incremental indexing is unavailable for ${u.join(", ")}${b}. The accepted index was preserved because whole-project rebuilds are disabled; run scip-query reindex --allow-expensive-rebuild only when you explicitly want that fallback.`)}}let R=p||i.has("typescript")?void 0:Dc(e,r),T=R&&n?{...R,classification:new Map([...R.classification].map(([u,b])=>[u,b.reused?{...b,reused:!1,reason:"forced reindex requested"}:b])),reusedProjects:[],missedProjectIds:new Set(R.allProjects.map(u=>`typescript:${u}`))}:R,{preparedRuns:j,skippedLanguages:D,languageOutputScipPaths:I}=Yc({languages:e.languages.filter(u=>!i.has(u)&&!f.has(u)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:T?.allProjects,typescriptShardCostDir:x(e.paths.outputDb),clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),F=T?j.filter(u=>u.language!=="typescript"||T.missedProjectIds.has(u.id)):j,_=await Yi(F,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(fn())for(let u of _)mn({type:"span",name:`reindex.language-indexer.${u.id}`,durationMs:Math.round(u.durationMs),ok:!u.skipped,language:u.language,indexerCommand:u.command,outputBytes:u.outputBytes,measurement:"indexer-run-result"});Kc(x(e.paths.outputDb),e.projectRoot,F,_);let h=[];if(T){Nc(e.paths.outputDb,_,e.writeTelemetry);let u=I.typescript??e.tempPaths.tempOutputScip;h=Lc({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:u,reusedProjects:T.reusedProjects,writeTelemetry:e.writeTelemetry})}let y=[..._,...h],{indexedOutputs:m}=Zc(y,D),w=p?[{language:"typescript",scipPath:p.scipPath}]:[],S=[...a,...w,...m];ed(S,D,e.languages,e.opts.allowPartial,e.onStatus);let P=p?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:p.scipPath,outputScipPath:p.scipPath,durationMs:p.durationMs,command:"watch-service:typescript-index",outputBytes:ne(p.scipPath)??void 0,producedOutputBytes:ne(p.affectedScipPath)??void 0}]:[],v=$c(r,[..._,...P],T?{outputDb:e.paths.outputDb,classification:T.classification}:void 0,g);return{indexedOutputs:S,skippedLanguages:D,reusedLanguages:[...i],languageFingerprints:Gc(r,e.languages),shards:v,typescriptProjectShardContext:T?{projects:T.allProjects,fingerprints:T.fingerprints}:void 0,incrementalTypeScript:p??void 0}}function Dc(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=Y(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let a=ai(e.projectRoot,r),i=ni(n.fingerprint.files,r),o=ri(r,a),s=ii(r,i,o),c=z(e.paths.metaPath),l=Mc(c,s,R=>L(ot(e.paths.outputDb,R))),g=[...l.entries()].filter(([,R])=>R.reused).map(([R])=>R),p=new Set(g),f=new Set(r.filter(R=>!p.has(R)).map(R=>`typescript:${R}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:g,missedProjectIds:f}}function Mc(e,t,n){let r=new Map;for(let a of Object.keys(t)){let i=t[a];if(!e){r.set(a,{reused:!1,reason:"no reindex metadata found",fingerprint:i});continue}let o=e.version===ae&&ut(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[a]:void 0;if(!o){r.set(a,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:i});continue}if(!n(a)){r.set(a,{reused:!1,reason:"cached shard file missing on disk",fingerprint:i});continue}if(N(o)!==N(i)){r.set(a,{reused:!1,reason:"project inputs changed since last index",fingerprint:i});continue}r.set(a,{reused:!0,fingerprint:i})}return r}function Nc(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let a=r.id.slice(11),i=ot(e,a);rt(x(i),{recursive:!0}),Z(n,V(r.scipPath,i,void 0,{shareImmutable:!0}))}}function Lc(e){return e.reusedProjects.map((t,n)=>{let r=ot(e.outputDb,t),a=re(e.tempOutputScip,"typescript-project-cached",n);return Z(e.writeTelemetry,V(r,a,void 0,{shareImmutable:!0})),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:a,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:ne(a)??void 0}})}function Ac(e){let t=z(e.paths.metaPath),n=Zt(e.projectFingerprint,e.languages,e),r=t&&L(e.paths.outputDb)?$e(e.paths.outputDb,e.projectFingerprint,e.languages):null,a=new Map;for(let i of e.languages){let o=en(e.paths.outputDb,i),s=n[i];if(!t){a.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:o});continue}if(t.version!==ae){a.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!ut(t).languageShardReuse||!t.languageFingerprints){a.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:o});continue}let c=t.languageFingerprints[i];if(!c){a.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:o});continue}if(!L(o)){a.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}let d=i==="typescript"?dd(e.projectRoot,c):c;if(N(d)!==N(s)){a.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:o});continue}if(r?.state==="unavailable"||r?.state==="incomplete"&&r.affectedLanguages.includes(i)){a.set(i,{reused:!1,reason:Vt("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:o});continue}a.set(i,{reused:!0,fingerprint:s,scipPath:o})}return a}function $c(e,t,n,r){let a=[];for(let[i,o]of e)o.reused&&a.push({id:i,language:i,reused:!0,strategy:"reused",fingerprint:Re(o.fingerprint),outputBytes:ne(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,c=s?n.classification.get(s):void 0;a.push({id:i.id,language:i.language,reused:!1,strategy:i.command==="watch-service:typescript-index"?"incremental":"full",missReason:c?.reason??o?.reason??i.skipped?.reason,fallbackReason:i.language==="typescript"?r:void 0,fingerprint:c?Re(c.fingerprint):o?Re(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,producedOutputBytes:i.producedOutputBytes,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&a.push({id:`typescript:${i}`,language:"typescript",reused:!0,strategy:"reused",fingerprint:Re(o.fingerprint),outputBytes:ne(ot(n.outputDb,i)),durationMs:0});return a}function Re(e){return Rc("sha256").update(N(e)).digest("hex").slice(0,16)}function ne(e){try{return Qt(e).size}catch{return null}}function Gc(e,t){let n={};for(let r of t){let a=e.get(r);a&&(n[r]=a.fingerprint)}return n}async function Bc(e,t,n,r,a,i,o,s){A(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,d=!1;c&&(d=E("reindex.publish.scip-output",()=>{let h=zc({run:e,indexedOutputs:n,incrementalTypeScript:s,typescriptReused:a.includes("typescript")});return ia(e.paths.outputDb,h,e.writeTelemetry),aa(h,e.tempPaths.tempOutputScip,e.onStatus)}));let l=await G("reindex.publish.sqlite-output",()=>td({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:d,materializeFullFallback:async()=>{if(A(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return d;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Wt({cacheDir:x(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let h=n.map(y=>y.language==="typescript"?{language:y.language,scipPath:s.candidateScipPath}:y);return ia(e.paths.outputDb,h,e.writeTelemetry),d=aa(h,e.tempPaths.tempOutputScip,e.onStatus),d}}));A(e.opts.signal,"Reindex cancelled by its owner."),E("reindex.publish.auxiliary-documents",()=>{Ae(Ne(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),await G("reindex.publish.runtime-boundaries",async()=>{let h=s?.plan.mode==="full-project",y=s?.dependencyGraphUnchanged===!0;h?e.onStatus("Rebuilding compiler-derived runtime-boundary relationships while retaining unchanged per-file extraction facts."):y&&e.onStatus("Reusing runtime-boundary relationships because TypeScript semantics are unchanged."),await Kt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,y,y?void 0:h?s?.changedFiles:s?.affectedFiles,O(x(e.paths.outputDb),Un),h)});let g=E("reindex.publish.sqlite-layout",()=>Ot(e.tempPaths.tempOutputDb,{analyze:Uc(s,l.mode)}));g.added.length>0&&e.onStatus(`Added SQLite query indexes: ${g.added.join(", ")}`),g.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${g.removed.join(", ")}`),E("reindex.publish.coverage",()=>Sa(e,e.tempPaths.tempOutputDb,n.map(h=>h.language)));let p,f=null;l.mode==="incremental"&&s&&E("reindex.publish.reference-fragments",()=>{if(s.dependencyGraphUnchanged){let m=new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});try{f=yt(m),e.onStatus("Preserved exact TypeScript reference fragments and dependency relationships because only trivia changed.")}finally{m.close()}return}let h=null,y=null;try{h=E("reindex.publish.reference-fragments.open-candidate",()=>new $({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip})),y=E("reindex.publish.reference-fragments.open-evidence",()=>new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip})),p=s.dependencyGraphSnapshot?E("reindex.publish.reference-fragments.dependency-graph",()=>Jn(h,s.dependencyGraphSnapshot,s.affectedFiles,s.deletedFiles))??void 0:void 0;let m=new Set(s.deletedFiles),w=m.size===0?s.referenceFragmentsByFile:new Map([...s.referenceFragmentsByFile].filter(([P])=>!m.has(P))),S=E("reindex.publish.reference-fragments.seed",()=>Xn(h,e.fingerprint,w,y,p,new Set(s.affectedFiles)));e.onStatus(`Cached exact TypeScript reference fragments for ${S.affectedFiles} affected document(s) and carried ${S.carriedFiles} unaffected document(s) forward.`),S.skippedAffectedFiles>0&&e.onStatus(`Skipped exact TypeScript reference fragment prefill for ${S.skippedAffectedFiles} affected document(s) whose semantic identity was unavailable.`)}catch(m){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${m instanceof Error?m.message:String(m)}.`)}finally{h?.close(),y?.close()}});let R=at(e.paths.metaPath);l.mode==="incremental"&&s||await fa({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousSnapshot:R,currentSnapshot:e.fingerprint,onStatus:e.onStatus});let T=E("reindex.publish.affected-shadow",()=>l.mode==="incremental"&&s?rd(s,l.changedDocumentPaths):It({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:R,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"})),j=ct({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(h=>h.language),skipped:[...r]}),D=l.mode==="incremental"&&l.scipCompanion==="deferred",{metadata:I,pruneProjects:F}=ha({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:j});I.scipCompanion=D?"deferred":"current",E("reindex.publish.metadata",()=>{ya(e),ba(e.paths.outputDb,F),st(e.tempPaths.tempMetaPath,I)});let _=E("reindex.publish.generation-handoff",()=>gr({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}));return _.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${_.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),l.mode==="incremental"&&s&&E("reindex.publish.dependency-graph",()=>{let h=null;try{h=new $({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let y=s.plan.mode==="full-project"&&s.plan.reasons.length===0?s.changedFiles:s.affectedFiles,m=!1;if(s.dependencyGraphUnchanged){let w=yt(h),S=f&&w?qn(h,"file-dependency-graph",f,w):0;m=S>0,e.onStatus(m?`Carried ${S} unchanged dependency graph product(s) forward without rebuilding them.`:"No persisted dependency graph product required rekeying; the next graph consumer can materialize it.")}else s.dependencyGraphSnapshot?m=Hn(h,s.dependencyGraphSnapshot,y,p):De(h);s.dependencyGraphUnchanged||e.onStatus(m?`Carried the dependency graph forward by replacing ${y.length} changed dependency owner(s).`:"Materialized a fresh dependency graph for the accepted generation because no compatible prior graph was available.")}catch(y){e.onStatus(`Dependency graph carry-forward unavailable: ${y instanceof Error?y.message:String(y)}. The next graph consumer will rebuild it.`)}finally{h?.close()}}),E("reindex.publish.cleanup",()=>{pr(x(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),dr(x(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[])}),E("reindex.publish.shadow-telemetry",()=>ma(e.paths.outputDb,T,e.onStatus)),j}function Uc(e,t){return t!=="incremental"||!e||e.plan.mode==="full-project"?!0:e.affectedFiles.length*20>=e.projectFileCount}async function qc(e,t,n,r,a,i){let o=at(e.paths.metaPath),s=null;try{Z(e.writeTelemetry,V(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=$r("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}Ae(Ne(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),await Kt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=Ot(e.paths.outputDb);c.added.length>0&&e.onStatus(`Added SQLite query indexes: ${c.added.join(", ")}`),c.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${c.removed.join(", ")}`),Sa(e,e.paths.outputDb,t.map(p=>p.language)),s==null&&await fa({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,onStatus:e.onStatus}),s??=It({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=ct({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:g}=ha({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:a,typescriptProjectShardContext:i,lastRefresh:d});return l.scipCompanion=Wc(e.paths),ya(e),ba(e.paths.outputDb,g),st(e.paths.metaPath,l),Ge(e.paths.outputDb,e.paths.metaPath),ma(e.paths.outputDb,s,e.onStatus),d}function Wc(e){let t=z(e.metaPath)?.scipCompanion;if(t)return t;let n=B(e.outputDb,e.metaPath);return n.state==="current"&&n.generation.publication?.scipCompanion==="deferred"?"deferred":"current"}async function fa(e){if(!L(e.previousDbPath))return;let t=W(e.previousSnapshot,e.currentSnapshot);if(t.changes.length===0||ye(t).fullProject)return;let n=null;try{if(n=new $({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),Me(n))return;let r=await G("reindex.publish.affected-shadow.warm-sources",()=>zn(n,{yieldToEventLoop:()=>new Promise(a=>setImmediate(a))}));e.onStatus(`Persisted import products for ${r.files} document(s) before the affected-set shadow.`)}catch(r){e.onStatus(`Affected-set shadow import warm-up unavailable: ${r instanceof Error?r.message:String(r)}.`)}finally{n?.close()}}function at(e){return lt(z(e)?.fingerprint)}function ma(e,t,n){try{Gr(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 ha(e){let t=Hc({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:ae,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function ya(e){A(e.opts.signal,"Reindex cancelled by its owner.");let t=Dn(e.projectRoot,e.fingerprint);if(N(t)===N(e.fingerprint))return;let n=new Map(e.fingerprint.files.map(i=>[i.path,i])),r=new Map(t.files.map(i=>[i.path,i])),a=[...new Set([...n.keys(),...r.keys()])].filter(i=>N(n.get(i))!==N(r.get(i))).slice(0,5);throw new Error(`Project inputs changed during reindex (${a.join(", ")||"unknown path"}); refusing to publish artifacts built from a different filesystem snapshot.`)}function Sa(e,t,n){let r=$e(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${Vt("Candidate SQLite index",r)} Refusing to publish it.`)}function Vt(e,t){if(t.state==="unavailable")return`${e} document coverage could not be verified (${t.reason}); rebuilding cached language shards.`;let n=t.missingPaths.length>0?` First missing path: ${t.missingPaths[0]}.`:"";return`${e} is missing ${t.missingDocumentCount} fingerprinted source document${t.missingDocumentCount===1?"":"s"}; rebuilding affected language shards.${n}`}function Hc(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=z(e.metaPath),n=t?.version===ae?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function ba(e,t){let n=wa(e);if(t===null){ee(n,{recursive:!0,force:!0});return}let r;try{r=ua(n)}catch{return}for(let a of Jc(r,t))ee(O(n,a),{force:!0})}function Jc(e,t){let n=new Set(t.map(r=>`${Mt(r)}.scip`));return e.filter(r=>!n.has(r))}function zc(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(o=>o.language==="typescript");if(!t)return[...e.indexedOutputs];if(!e.typescriptReused)return[...e.indexedOutputs];let n=B(e.run.paths.outputDb,e.run.paths.metaPath),r=n.state==="current"?n.generation.publication?.typescriptOverlayGeneration:void 0;if(!(n.state==="current"?n.generation.publication?.scipCompanion==="deferred":z(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let i=re(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),Wt({cacheDir:x(e.run.paths.outputDb),generationIdentity:r,baseShardPath:t.scipPath,candidateShardPath:i}),e.indexedOutputs.map(o=>o.language==="typescript"?{language:o.language,scipPath:i}:o)}function ia(e,t,n){for(let r of t){let a=en(e,r.language);rt(x(a),{recursive:!0}),r.scipPath!==a&&Z(n,V(r.scipPath,a,void 0,{shareImmutable:!0}))}}async function Xc(e,t){let n=vn();if(n){if(n.source==="path"&&ea()!=="win32"){let r=_n();In(r)||(e?t(`scip on PATH reports ${r??"an unknown version"}; the reviewed version is ${Ce} and compatibility is unverified. Run scip-query setup --install-missing to install the reviewed release.`):(t(`scip on PATH reports ${r??"an unknown version"}; installing the reviewed ${Ce}.`),await Tn(t)))}return}if(ea()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
291
291
|
To install the reviewed version, run: scip-query reindex --install-missing
|
|
292
292
|
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!await wn(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
293
|
-
Install manually from: https://github.com/sourcegraph/scip/releases/tag/${Ce}`)}function
|
|
293
|
+
Install manually from: https://github.com/sourcegraph/scip/releases/tag/${Ce}`)}function Yc(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?re(e.tempOutputScip,i,o):e.tempOutputScip})),a=Object.fromEntries(r.map(({language:i,scipPath:o})=>[i,o]));for(let{language:i,scipPath:o}of r){let s=Qc({...e,language:i,scipPath:o});for(let c of s)"skipped"in c?Pa(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:a}}function Qc(e){if(e.language!=="typescript")return[nt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.typescriptProjectMode==="workspace",n=t?e.preDiscoveredTypeScriptProjects??Y(e.projectRoot,e.typescriptProjects):["."];return n.length===0?[nt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(t&&e.onStatus(`Indexing TypeScript workspace as ${n.length} project shard(s).`),n.flatMap((r,a)=>{let i=t?`typescript:${r}`:"typescript",o=t?`typescript (${r})`:"typescript",s=t?re(e.tempOutputScip,"typescript-project",a):e.scipPath,c={...e,id:i,label:o,scipPath:s,outputScipPath:e.scipPath,pnpmWorkspaces:!1};if(!t&&r==="."&&!e.pnpmWorkspaces){let d=Vc(e,c);if(d)return d}return[nt({...c,...t?{projectPath:r}:{}})]}))}function Kc(e,t,n,r){let a=n.filter(s=>s.shardInputPaths!==void 0);if(a.length===0)return;let i=new Map(r.filter(s=>!s.skipped).map(s=>[s.id,s.durationMs])),o=[];for(let s of a){let c=i.get(s.id);if(c===void 0||!(c>0))return;o.push({inputPaths:s.shardInputPaths,durationMs:c})}try{let s=Ti(o,c=>{try{return Qt(O(t,c)).size}catch{return 1}});s&&Ii(e,s)}catch{}}function Vc(e,t){let n=$t(),r=mt(e.projectRoot,"single");if(!r||!Pi(r.size,n))return null;Ci(e.projectRoot);let a=wi(),i=Ri(r.size,n,a),o=e.typescriptShardCostDir?vi(e.typescriptShardCostDir):null,s=_i(o),c=xi({projectRoot:e.projectRoot,rootConfigPath:"tsconfig.json",inputPaths:[...r],targetFiles:n,shardCount:i,weightOf:l=>{let g=1;try{g=Qt(O(e.projectRoot,l)).size}catch{}return s(l,g)}}),d=Math.min(a,c.length);return e.onStatus(`Indexing ${r.size} TypeScript inputs as ${c.length} ${o?"cost-balanced":"byte-balanced"} compiler shard(s), ${d} at a time.`),c.map((l,g)=>nt({...t,id:`typescript-compiler-shard:${g}`,label:`typescript compiler shard ${g+1}/${c.length}`,scipPath:re(e.tempOutputScip,"typescript-compiler-shard",g),projectPath:l.configPath,temporaryProjectConfigs:[{path:l.configPath,content:l.content}],boundedConcurrency:d,outputComposition:"protobuf-concatenate",shardInputPaths:l.inputPaths}))}function nt(e){let t=_t(e.language),n=Oe(t),r=Ln(t,e.projectRoot),a=e.trustProjectTools&&r?An(t,e.projectRoot):null,i=he(t);if(!a&&!i&&r){let l=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(!a&&!i&&!Nn(t)){if(e.skipAutoInstall){let l=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!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 o=a?.canonicalPath??he(t);if(!o){let l=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}let{binary:s,args:c}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0}),d=zr({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(a&&!a.executable){let l=`${a.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${l}`),{skipped:{language:e.language,reason:l}}}return a&&e.onStatus(`Trusted project-local ${e.language} indexer ${a.relativePath} (${a.sha256.slice(0,12)}\u2026, ${a.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:o,binary:s,args:c,env:Gn(t,e.env,o),...d===void 0?{}:{temporaryRootConfigContent:d},...e.temporaryProjectConfigs===void 0?{}:{temporaryProjectConfigs:e.temporaryProjectConfigs},...e.boundedConcurrency===void 0?{}:{boundedConcurrency:e.boundedConcurrency},...e.outputComposition?{outputComposition:e.outputComposition}:{},...e.shardInputPaths===void 0?{}:{shardInputPaths:e.shardInputPaths},...a?{trustedProjectTool:a}:{}}}}function Zc(e,t){let n=new Set(e.filter(i=>i.skipped&&i.outputComposition).map(i=>`${i.language}\0${i.outputScipPath}`)),r=new Map;for(let i of e)if(i.skipped)Pa(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`;if(n.has(o))continue;let s=r.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[],concatenate:!0};s.scipPaths.push(i.scipPath),i.outputComposition!=="protobuf-concatenate"&&(s.concatenate=!1),r.set(o,s)}let a=[];for(let i of r.values())if(i.scipPaths.length>1)i.concatenate?ir(i.scipPaths,i.outputScipPath):rr(i.scipPaths,i.outputScipPath),a.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&pa(o,i.outputScipPath),a.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:a}}function Pa(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 ed(e,t,n,r,a){if(e.length===0){let i=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
294
294
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
295
295
|
`+i)}if(t.length!==0&&(a(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(i=>i.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
296
296
|
`+t.map(i=>` - ${i.language}: ${i.reason}`).join(`
|
|
297
|
-
`))}function aa(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),a=ar(e.map(i=>i.scipPath),t);return xa(a,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&pa(e[0].scipPath,t);return!1}async function ed(e){let t;if(td(e))try{let a=e.incrementalTypeScript.affectedBatches.length>0?e.incrementalTypeScript.affectedBatches:[{scipPath:e.incrementalTypeScript.affectedScipPath,affectedFiles:e.incrementalTypeScript.affectedFiles,deletedFiles:e.incrementalTypeScript.deletedFiles}],i=new Set,o=0,s=0;for(let[c,d]of a.entries()){let l=O(e.run.tempPaths.runDir,`typescript-affected-${c}.db`);Ra(d.scipPath,e.run.onStatus),e.run.onStatus(`Converting bounded TypeScript batch ${c+1}/${a.length} (${d.affectedFiles.length-d.deletedFiles.length} emitted, ${d.deletedFiles.length} removed) to SQLite...`);let g=performance.now();await oa(d.scipPath,l,e.env,e.run.onStatus,!0,e.run.opts.signal),o+=performance.now()-g,We(e.run.writeTelemetry,te(l)??0);let p=Vr({previousDbPath:e.run.paths.outputDb,miniDbPath:l,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:d.affectedFiles,deletedFiles:d.deletedFiles,reuseCandidate:c>0,deferIntegrity:c<a.length-1,trustedPriorGeneration:!0,writeTelemetry:e.run.writeTelemetry});s+=p.durationMs;for(let f of p.changedDocumentPaths)i.add(f);Z(l,{force:!0})}return e.run.onStatus(`Patched ${e.incrementalTypeScript.affectedFiles.length} SQLite document path(s) across ${a.length} bounded batch(es) in ${(s/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:[...i].sort(),patchDurationMs:s,converterDurationMs:o,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){if(A(e.run.opts.signal,"Reindex cancelled by its owner."),t=a instanceof Error?a.message:String(a),Z(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.opts.allowExpensiveRebuild===!1)throw new Error(`Bounded incremental SQLite publication failed and the whole-project fallback is disabled: ${t}`,{cause:a});e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await oa(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 td(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!L(e.run.paths.outputDb)||!L(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function nd(e,t){let n=C(),r=[...t].sort(),a=new Set(r),i={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!a.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:C()-n,manifest:e.manifest,plan:e.plan,comparison:i,evaluation:It(e.plan,i,e.projectFileCount)}}async function oa(e,t,n,r,a=!1,i){if(A(i,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!L(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{if(a||Ra(e,r),n.SCIP_QUERY_SQLITE_CONVERTER==="scip-cli"){let o=En();if(!o)throw new Error("scip CLI is not available");let s=await ve({command:o,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:i});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}else Z(t,{force:!0}),await Si(ie(e,{maxBytes:Ee,inputKind:"SCIP index"}),t,{signal:i})}catch(o){A(i,"Reindex cancelled by its owner.");let s=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:o})}}function Ra(e,t){let n=nr(e);xa(n,t)}function xa(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function ne(e,t,n){let r=Ec(e)||".scip",a=tt(e,r);return O(x(e),`${a}.${n+1}.${t}${r}`)}async function rd(e,t){for(let n=0;n<2;n++){let r=id(e,t);if(r)return r;let a=ad(e);if(a&&va(t.trigger,a)){t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}.`);let i;try{i=await od(a)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${a.pid}); refusing to steal an active lock: ${ee(s)}`,{cause:s})}if(!i)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${a.pid}) terminated for ${x(e)}; refusing to steal an active lock.`);let o=ft(e,{parseLegacy:it});if(!Pn(e,o,{parseLegacy:it}))throw new Error(`Reindex lock ownership changed before preemption completed for ${x(e)}.`);continue}throw new le(`Another scip-query reindex is already running for ${x(e)}.`)}throw new le(`Could not acquire scip-query reindex lock for ${x(e)}.`)}function id(e,t){let n=U(process.pid),r=bn(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:it});if(r.kind==="acquired"&&r.reclaimed){let a=Ea(r.reclaimed,e);a&&va(t.trigger,a)?t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${x(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function ad(e){return Ea(ft(e,{parseLegacy:it}),e)}var it=e=>{let t=Ia(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Ea(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:x(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Ia(e.parsed,t)}function Ia(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=Ie(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:x(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function va(e,t){return e?.kind==="manual-cli"&&_a(t?.trigger)}function _a(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function od(e){return!oe(e.pid)||(Yt(e),sa(e,"SIGTERM"),await ca(e,2e3))?!0:(Yt(e),sa(e,"SIGKILL"),ca(e,1e3))}function sa(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!oe(e.pid))return;Yt(e)}try{process.kill(e.pid,t)}catch{}}async function ca(e,t){let n=C()+t;for(;C()<n;){if(da(e))return!0;await sd(50)}return da(e)}function Yt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=U(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!z(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function da(e){if(!oe(e.pid))return!0;if(!e.processIdentity)return!1;let t=U(e.pid);return t!==null&&!z(e.processIdentity,t)}function sd(e){return new Promise(t=>setTimeout(t,e))}function Zt(e,t,n){return Object.fromEntries(t.map(r=>{let a=r==="typescript"?Fn(n.typescriptProjects):[],i=r==="clojure"?dd(n.clojureConfigPath):void 0,o=[..._t(r).markerFiles,...a,...i?[i]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:a}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&ld(n),...s,clojureConfigPath:i,files:e.files.filter(c=>un(c.path,r,o)).map(c=>Ta(c,r))}]}))}function Ta(e,t){let n=t==="typescript"&&/(?:^|\/)package\.json$/iu.test(e.path)?e.semanticHash:void 0;return{path:e.path,size:n===void 0?e.size:0,hash:n??e.hash}}function cd(e,t){let n=lt(t);if(!n)return t;let r=n.typescriptProjectMode==="workspace"?X(e,n.typescriptProjects):["."],a=se(r);return{...n,files:n.files.filter(i=>!ce(i.path)||a.has(i.path)).map(i=>{let o=i.semanticHash??we(e,i.path,i.hash);return Ta(o===void 0?i:{...i,semanticHash:o},"typescript")})}}function dd(e){return e?.trim()||void 0}function ld(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function en(e,t){return O(x(e),"language-indexes",`${t}.scip`)}function wa(e){return O(x(e),"language-indexes","typescript-projects")}function ot(e,t){return O(wa(e),`${Mt(t)}.scip`)}function re(e){try{return Te(me(fe(e,"reindex metadata")))}catch{return null}}function Ca(e,t){try{let n=me(fe(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return null;let r=n.metadata;return!n.capabilities.publishableGeneration||!gn(r)||N([...r.indexedLanguages??[]].sort())!==N(t.languages)?null:N(r.fingerprint)===N(t)?"exact":N(la(r.fingerprint))===N(la(t))?"operational-config-compatible":null}catch{return null}}function la(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t=e;return Array.isArray(t.files)?{...t,files:t.files.filter(n=>typeof n!="object"||n===null||Array.isArray(n)||n.path!==".scipquery.json")}:e}function ud(e,t,n,r){let a=Te(me(fe(e,"reindex metadata")));a&&st(e,{...a,fingerprint:t,...a.version===ae?{languageFingerprints:Zt(t,n,r)}:{}})}function st(e,t){Bn(e,t,{spacing:2,trailingNewline:!0})}function ja(e,t){try{let n=Te(me(fe(e,"reindex metadata")));if(!n)return;st(e,{...n,lastRefresh:t})}catch{}}function ct(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:C()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function N(e){return JSON.stringify(e)}var pd={readIdentity:U,setInterval(e,t){let n=setInterval(e,t);return n.unref(),n},clearInterval};function Oa(e,t,n={}){let r=n.runtime??pd,a=n.intervalMs??1e3;if(!Number.isSafeInteger(a)||a<=0)throw new TypeError("parent process monitor interval must be a positive safe integer");let i=!0,o,s=()=>{if(!i)return;let c=r.readIdentity(e.pid);c&&z(e,c)||(i=!1,o&&r.clearInterval(o),t(c?`parent process ${e.pid} changed identity`:`parent process ${e.pid} exited`))};return s(),i&&(o=r.setInterval(s,a)),{stop(){i&&(i=!1,o&&r.clearInterval(o))}}}var Da=process.env.SCIP_REINDEX_PROJECT_ROOT,Ma=process.env.SCIP_REINDEX_OUTPUT_SCIP,Na=process.env.SCIP_REINDEX_OUTPUT_DB,Fa=process.env.SCIP_REINDEX_LANGUAGES,fd=Or(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),md=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",tn=Cd(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),hd=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,yd=wd(process.env.SCIP_REINDEX_TRIGGER_KIND),Sd=process.env.SCIP_REINDEX_TRIGGER_DETAIL,bd=Fr(process.env.SCIP_REINDEX_CHANGE_JOURNAL),Pd=process.env.SCIP_REINDEX_ALLOW_EXPENSIVE!=="0",La=Td(process.env.SCIP_REINDEX_PARENT_IDENTITY);(!Da||!Ma||!Na||!La)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var Rd=Da,xd=Ma,Ed=Na,Id=La,ka=Fa?Fa.split(",").filter(Boolean):void 0,Aa=new AbortController,vd=Oa(Id,e=>{Aa.abort(new Error(`Reindex worker owner lost: ${e}`))});_d();async function _d(){try{await ga({projectRoot:Rd,outputScip:xd,outputDb:Ed,languages:ka?.length?ka:void 0,pnpmWorkspaces:md,typescriptProjectMode:tn.projectMode,typescriptProjects:tn.projects,maxHeapMb:tn.maxHeapMb,clojureConfigPath:hd,indexerConcurrency:fd,trigger:{kind:yd,detail:Sd||void 0},changeJournal:bd,allowExpensiveRebuild:Pd,signal:Aa.signal,onStatus:e=>process.stderr.write(`[reindex] ${xt(e)}
|
|
298
|
-
`)})}catch(e){console.error(`reindex-worker error: ${xt(String(e))}`),process.exitCode=e instanceof le?75:1}finally{
|
|
297
|
+
`))}function aa(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),a=ar(e.map(i=>i.scipPath),t);return xa(a,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&pa(e[0].scipPath,t);return!1}async function td(e){let t;if(nd(e))try{let a=e.incrementalTypeScript.affectedBatches.length>0?e.incrementalTypeScript.affectedBatches:[{scipPath:e.incrementalTypeScript.affectedScipPath,affectedFiles:e.incrementalTypeScript.affectedFiles,deletedFiles:e.incrementalTypeScript.deletedFiles}],i=new Set,o=0,s=0;for(let[c,d]of a.entries()){let l=O(e.run.tempPaths.runDir,`typescript-affected-${c}.db`);Ra(d.scipPath,e.run.onStatus),e.run.onStatus(`Converting bounded TypeScript batch ${c+1}/${a.length} (${d.affectedFiles.length-d.deletedFiles.length} emitted, ${d.deletedFiles.length} removed) to SQLite...`);let g=performance.now();await oa(d.scipPath,l,e.env,e.run.onStatus,!0,e.run.opts.signal),o+=performance.now()-g,We(e.run.writeTelemetry,ne(l)??0);let p=Vr({previousDbPath:e.run.paths.outputDb,miniDbPath:l,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:d.affectedFiles,deletedFiles:d.deletedFiles,reuseCandidate:c>0,deferIntegrity:c<a.length-1,trustedPriorGeneration:!0,writeTelemetry:e.run.writeTelemetry});s+=p.durationMs;for(let f of p.changedDocumentPaths)i.add(f);ee(l,{force:!0})}return e.run.onStatus(`Patched ${e.incrementalTypeScript.affectedFiles.length} SQLite document path(s) across ${a.length} bounded batch(es) in ${(s/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:[...i].sort(),patchDurationMs:s,converterDurationMs:o,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){if(A(e.run.opts.signal,"Reindex cancelled by its owner."),t=a instanceof Error?a.message:String(a),ee(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.opts.allowExpensiveRebuild===!1)throw new Error(`Bounded incremental SQLite publication failed and the whole-project fallback is disabled: ${t}`,{cause:a});e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await oa(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 nd(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!L(e.run.paths.outputDb)||!L(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function rd(e,t){let n=C(),r=[...t].sort(),a=new Set(r),i={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!a.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:C()-n,manifest:e.manifest,plan:e.plan,comparison:i,evaluation:vt(e.plan,i,e.projectFileCount)}}async function oa(e,t,n,r,a=!1,i){if(A(i,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!L(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{if(a||Ra(e,r),n.SCIP_QUERY_SQLITE_CONVERTER==="scip-cli"){let o=En();if(!o)throw new Error("scip CLI is not available");let s=await Ie({command:o,args:["expt-convert","--output",t,e],label:"SCIP SQLite conversion",env:n,maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,timeoutMs:3e5,signal:i});if(s.status!==0)throw new Error(`scip expt-convert exited with ${s.status}${s.stderr.trim()?`: ${s.stderr.trim()}`:""}`)}else ee(t,{force:!0}),await Si(ie(e,{maxBytes:Ee,inputKind:"SCIP index"}),t,{signal:i})}catch(o){A(i,"Reindex cancelled by its owner.");let s=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:o})}}function Ra(e,t){let n=nr(e);xa(n,t)}function xa(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function re(e,t,n){let r=Ec(e)||".scip",a=tt(e,r);return O(x(e),`${a}.${n+1}.${t}${r}`)}async function id(e,t){for(let n=0;n<2;n++){let r=ad(e,t);if(r)return r;let a=od(e);if(a&&Ia(t.trigger,a)){t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}.`);let i;try{i=await sd(a)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${a.pid}); refusing to steal an active lock: ${te(s)}`,{cause:s})}if(!i)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${a.pid}) terminated for ${x(e)}; refusing to steal an active lock.`);let o=ft(e,{parseLegacy:it});if(!Pn(e,o,{parseLegacy:it}))throw new Error(`Reindex lock ownership changed before preemption completed for ${x(e)}.`);continue}throw new le(`Another scip-query reindex is already running for ${x(e)}.`)}throw new le(`Could not acquire scip-query reindex lock for ${x(e)}.`)}function ad(e,t){let n=q(process.pid),r=bn(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:it});if(r.kind==="acquired"&&r.reclaimed){let a=Ea(r.reclaimed,e);a&&Ia(t.trigger,a)?t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${x(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function od(e){return Ea(ft(e,{parseLegacy:it}),e)}var it=e=>{let t=va(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Ea(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:x(t),startedAt:e.record.startedAt,trigger:n.trigger}}return va(e.parsed,t)}function va(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=ve(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:x(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Ia(e,t){return e?.kind==="manual-cli"&&_a(t?.trigger)}function _a(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function sd(e){return!oe(e.pid)||(Yt(e),sa(e,"SIGTERM"),await ca(e,2e3))?!0:(Yt(e),sa(e,"SIGKILL"),ca(e,1e3))}function sa(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!oe(e.pid))return;Yt(e)}try{process.kill(e.pid,t)}catch{}}async function ca(e,t){let n=C()+t;for(;C()<n;){if(da(e))return!0;await cd(50)}return da(e)}function Yt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=q(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!X(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function da(e){if(!oe(e.pid))return!0;if(!e.processIdentity)return!1;let t=q(e.pid);return t!==null&&!X(e.processIdentity,t)}function cd(e){return new Promise(t=>setTimeout(t,e))}function Zt(e,t,n){return Object.fromEntries(t.map(r=>{let a=r==="typescript"?Fn(n.typescriptProjects):[],i=r==="clojure"?ld(n.clojureConfigPath):void 0,o=[..._t(r).markerFiles,...a,...i?[i]:[]],s=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:a}:{typescriptProjectMode:"single",typescriptProjects:[]};return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&ud(n),...s,clojureConfigPath:i,files:e.files.filter(c=>un(c.path,r,o)).map(c=>Ta(c,r))}]}))}function Ta(e,t){let n=t==="typescript"&&/(?:^|\/)package\.json$/iu.test(e.path)?e.semanticHash:void 0;return{path:e.path,size:n===void 0?e.size:0,hash:n??e.hash}}function dd(e,t){let n=lt(t);if(!n)return t;let r=n.typescriptProjectMode==="workspace"?Y(e,n.typescriptProjects):["."],a=se(r);return{...n,files:n.files.filter(i=>!ce(i.path)||a.has(i.path)).map(i=>{let o=i.semanticHash??we(e,i.path,i.hash);return Ta(o===void 0?i:{...i,semanticHash:o},"typescript")})}}function ld(e){return e?.trim()||void 0}function ud(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function en(e,t){return O(x(e),"language-indexes",`${t}.scip`)}function wa(e){return O(x(e),"language-indexes","typescript-projects")}function ot(e,t){return O(wa(e),`${Mt(t)}.scip`)}function z(e){try{return Te(me(fe(e,"reindex metadata")))}catch{return null}}function Ca(e,t){try{let n=me(fe(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return null;let r=n.metadata;return!n.capabilities.publishableGeneration||!gn(r)||N([...r.indexedLanguages??[]].sort())!==N(t.languages)?null:N(r.fingerprint)===N(t)?"exact":N(la(r.fingerprint))===N(la(t))?"operational-config-compatible":null}catch{return null}}function la(e){if(typeof e!="object"||e===null||Array.isArray(e))return e;let t=e;return Array.isArray(t.files)?{...t,files:t.files.filter(n=>typeof n!="object"||n===null||Array.isArray(n)||n.path!==".scipquery.json")}:e}function pd(e,t,n,r){let a=Te(me(fe(e,"reindex metadata")));a&&st(e,{...a,fingerprint:t,...a.version===ae?{languageFingerprints:Zt(t,n,r)}:{}})}function st(e,t){Bn(e,t,{spacing:2,trailingNewline:!0})}function ja(e,t){try{let n=Te(me(fe(e,"reindex metadata")));if(!n)return;st(e,{...n,lastRefresh:t})}catch{}}function ct(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:C()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function N(e){return JSON.stringify(e)}var gd={readIdentity:q,setInterval(e,t){let n=setInterval(e,t);return n.unref(),n},clearInterval};function Oa(e,t,n={}){let r=n.runtime??gd,a=n.intervalMs??1e3;if(!Number.isSafeInteger(a)||a<=0)throw new TypeError("parent process monitor interval must be a positive safe integer");let i=!0,o,s=()=>{if(!i)return;let c=r.readIdentity(e.pid);c&&X(e,c)||(i=!1,o&&r.clearInterval(o),t(c?`parent process ${e.pid} changed identity`:`parent process ${e.pid} exited`))};return s(),i&&(o=r.setInterval(s,a)),{stop(){i&&(i=!1,o&&r.clearInterval(o))}}}var Da=process.env.SCIP_REINDEX_PROJECT_ROOT,Ma=process.env.SCIP_REINDEX_OUTPUT_SCIP,Na=process.env.SCIP_REINDEX_OUTPUT_DB,Fa=process.env.SCIP_REINDEX_LANGUAGES,md=Or(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),hd=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",tn=jd(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),yd=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Sd=Cd(process.env.SCIP_REINDEX_TRIGGER_KIND),bd=process.env.SCIP_REINDEX_TRIGGER_DETAIL,Pd=Fr(process.env.SCIP_REINDEX_CHANGE_JOURNAL),Rd=process.env.SCIP_REINDEX_ALLOW_EXPENSIVE!=="0",La=wd(process.env.SCIP_REINDEX_PARENT_IDENTITY);(!Da||!Ma||!Na||!La)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var xd=Da,Ed=Ma,vd=Na,Id=La,ka=Fa?Fa.split(",").filter(Boolean):void 0,Aa=new AbortController,_d=Oa(Id,e=>{Aa.abort(new Error(`Reindex worker owner lost: ${e}`))});Td();async function Td(){try{await ga({projectRoot:xd,outputScip:Ed,outputDb:vd,languages:ka?.length?ka:void 0,pnpmWorkspaces:hd,typescriptProjectMode:tn.projectMode,typescriptProjects:tn.projects,maxHeapMb:tn.maxHeapMb,clojureConfigPath:yd,indexerConcurrency:md,trigger:{kind:Sd,detail:bd||void 0},changeJournal:Pd,allowExpensiveRebuild:Rd,signal:Aa.signal,onStatus:e=>process.stderr.write(`[reindex] ${xt(e)}
|
|
298
|
+
`)})}catch(e){console.error(`reindex-worker error: ${xt(String(e))}`),process.exitCode=e instanceof le?75:1}finally{_d.stop()}}function wd(e){if(!e)return null;try{return ve(JSON.parse(e))}catch{return null}}function Cd(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function jd(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,a=Array.isArray(n.projects)?n.projects.filter(o=>typeof o=="string"&&o.trim()!==""):void 0,i=typeof n.maxHeapMb=="number"&&Number.isInteger(n.maxHeapMb)&&n.maxHeapMb>0?n.maxHeapMb:void 0;return{projectMode:r,projects:a&&a.length>0?a:void 0,maxHeapMb:i}}catch{return{}}}
|
|
299
299
|
//# sourceMappingURL=reindex-worker.js.map
|