scip-query 0.20.0 → 0.21.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 +69 -0
- package/README.md +255 -884
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-CI3O6PQG.js +2 -0
- package/dist/call-graph-6QTUTXH7.js +2 -0
- package/dist/call-graph-evidence-lZa2dwQA.d.ts +11 -0
- package/dist/change-analysis-types-CCtoCHbC.d.ts +9 -0
- package/dist/chunk-26CT72HM.js +2 -0
- package/dist/{chunk-7PIO7NKH.js → chunk-2COFMIVK.js} +2 -2
- package/dist/chunk-2H4IAJHO.js +2 -0
- package/dist/chunk-2I3RSUWX.js +16 -0
- package/dist/chunk-2RP27XLR.js +2 -0
- package/dist/chunk-2ZBMOQGG.js +3 -0
- package/dist/{chunk-HX4GQPZP.js → chunk-32A42O5B.js} +3 -3
- package/dist/chunk-35ELD3RM.js +2 -0
- package/dist/chunk-35IW3P4H.js +2 -0
- package/dist/{chunk-DQGFVPUV.js → chunk-3653GTR7.js} +3 -3
- package/dist/chunk-3EX7DNBC.js +2 -0
- package/dist/chunk-3FQ3KMCD.js +2 -0
- package/dist/{chunk-5E4WNAVD.js → chunk-3PII3JI5.js} +2 -2
- package/dist/chunk-3TNRNKAT.js +2 -0
- package/dist/chunk-3VLJ2DCA.js +2 -0
- package/dist/{chunk-XSRF6Q77.js → chunk-46JLFIGA.js} +2 -2
- package/dist/chunk-4DCKBY6T.js +5 -0
- package/dist/chunk-4EXFZP6H.js +2 -0
- package/dist/chunk-4IIMPWMR.js +29 -0
- package/dist/chunk-4ILHWBYF.js +2 -0
- package/dist/chunk-4N6QSEMZ.js +10 -0
- package/dist/chunk-4OE2JO6I.js +2 -0
- package/dist/{chunk-7BAVHKMJ.js → chunk-4S4DF62J.js} +9 -9
- package/dist/chunk-4UUCUASK.js +554 -0
- package/dist/chunk-5236NQV3.js +2 -0
- package/dist/chunk-54EOGFBR.js +2 -0
- package/dist/{chunk-LY4WC4AD.js → chunk-5H7IWVXJ.js} +2 -2
- package/dist/chunk-5IZTXSOL.js +117 -0
- package/dist/{chunk-AZJQQKDD.js → chunk-5SE323LF.js} +2 -2
- package/dist/chunk-5ZJH6DDE.js +2 -0
- package/dist/chunk-63MBA7EG.js +3 -0
- package/dist/chunk-6BJ7SOY7.js +2 -0
- package/dist/chunk-6GJAP4OE.js +2 -0
- package/dist/chunk-6IEVHGWG.js +26 -0
- package/dist/chunk-6SWA6B24.js +7 -0
- package/dist/chunk-6T7H2AFY.js +3 -0
- package/dist/chunk-73Z33VFI.js +4 -0
- package/dist/chunk-7COHFNJK.js +38 -0
- package/dist/chunk-7HU2IJ2T.js +3 -0
- package/dist/chunk-7IOAZRVL.js +60 -0
- package/dist/chunk-7KCZELVM.js +2 -0
- package/dist/chunk-7PPYXENX.js +2 -0
- package/dist/chunk-7TWP3MCP.js +2 -0
- package/dist/chunk-AA7K3XLM.js +21 -0
- package/dist/chunk-AJVMVE7X.js +7 -0
- package/dist/chunk-ANWGXPPN.js +4 -0
- package/dist/chunk-APLKXICZ.js +3 -0
- package/dist/{chunk-JDOEX4E6.js → chunk-AQDWTCDC.js} +2 -2
- package/dist/chunk-AUP6YI5M.js +2 -0
- package/dist/chunk-B7ECWJAZ.js +2 -0
- package/dist/{chunk-ZHXX42OH.js → chunk-BATIVRU2.js} +4 -4
- package/dist/chunk-BBEDPVPB.js +4 -0
- package/dist/chunk-BBWPOMGU.js +2 -0
- package/dist/chunk-BD6CV7PN.js +2 -0
- package/dist/{chunk-XKWKXZKW.js → chunk-BHE44MHT.js} +2 -2
- package/dist/chunk-BOJ5SVE2.js +2 -0
- package/dist/chunk-BZYSGZRK.js +2 -0
- package/dist/chunk-CA5RE6H7.js +2 -0
- package/dist/chunk-CKDOY6JA.js +2 -0
- package/dist/chunk-CN2WGM7D.js +2 -0
- package/dist/chunk-COTMS5KM.js +3 -0
- package/dist/chunk-CSDDOUA4.js +3 -0
- package/dist/chunk-CT5SI2I4.js +2 -0
- package/dist/chunk-D5EKVZPI.js +2 -0
- package/dist/{chunk-FKSELJQF.js → chunk-D5W4UZY5.js} +2 -2
- package/dist/{chunk-RUJURYSV.js → chunk-DEUGHURX.js} +2 -2
- package/dist/chunk-DHKBIOXF.js +7 -0
- package/dist/chunk-DMQ7ZKJG.js +81 -0
- package/dist/chunk-DMUGTKMD.js +2 -0
- package/dist/chunk-DOPCR5BY.js +2 -0
- package/dist/chunk-DRENNWRG.js +2 -0
- package/dist/chunk-E4EJBGDZ.js +2 -0
- package/dist/chunk-E7BJXRNV.js +2 -0
- package/dist/chunk-EA4SH4U5.js +5 -0
- package/dist/{chunk-L7AW2QB5.js → chunk-EKZRF57O.js} +2 -2
- package/dist/chunk-ELNRLMC5.js +29 -0
- package/dist/chunk-F4FNK44D.js +2 -0
- package/dist/chunk-F7WQ337U.js +308 -0
- package/dist/chunk-FEQIQ26E.js +2 -0
- package/dist/chunk-FGB567HK.js +23 -0
- package/dist/chunk-FHV7NMFU.js +29 -0
- package/dist/chunk-FN6EJM6Q.js +2 -0
- package/dist/chunk-FTSQNONX.js +2 -0
- package/dist/chunk-FUG6RPYY.js +6 -0
- package/dist/chunk-G2F6T5BV.js +2 -0
- package/dist/chunk-G6OGPXJW.js +9 -0
- package/dist/chunk-GFLTPNWV.js +3 -0
- package/dist/chunk-GTDP2SKQ.js +2 -0
- package/dist/chunk-H46QMB7E.js +2 -0
- package/dist/chunk-H5EXS3HM.js +2 -0
- package/dist/chunk-HEOMG7IM.js +8 -0
- package/dist/chunk-HG5YI7PV.js +2 -0
- package/dist/{chunk-7SQQWSY3.js → chunk-HGKEAP7F.js} +2 -2
- package/dist/chunk-HUZNZ3H2.js +2 -0
- package/dist/chunk-HWLCBKFE.js +2 -0
- package/dist/chunk-I3U2FN2T.js +13 -0
- package/dist/{chunk-JAYYFEQY.js → chunk-I7PFL5P3.js} +2 -2
- package/dist/{chunk-2HPVVXM5.js → chunk-ICHBVITH.js} +2 -2
- package/dist/chunk-ICUQONOG.js +38 -0
- package/dist/chunk-IDPLC3FI.js +5 -0
- package/dist/{chunk-A73XVBCR.js → chunk-IGKKTHJR.js} +2 -2
- package/dist/chunk-IOKWFRFQ.js +4 -0
- package/dist/chunk-IPAL6DP2.js +3 -0
- package/dist/chunk-IUJ3ZFEE.js +7 -0
- package/dist/chunk-IXJ26KJJ.js +16 -0
- package/dist/chunk-IYV2YBHM.js +2 -0
- package/dist/chunk-JVZNWJBH.js +2 -0
- package/dist/chunk-K5MZYZV7.js +3 -0
- package/dist/{chunk-3G66UZBH.js → chunk-KFK7GF5C.js} +2 -2
- package/dist/chunk-KTRGJLY7.js +18 -0
- package/dist/chunk-KW6B5OL4.js +2 -0
- package/dist/chunk-KWARB5FZ.js +2 -0
- package/dist/chunk-LHTT5C3Z.js +2 -0
- package/dist/chunk-LPGDO2XA.js +3 -0
- package/dist/chunk-LXLD46LH.js +21 -0
- package/dist/chunk-MEI3PTUK.js +2 -0
- package/dist/chunk-MJNV7OCG.js +5 -0
- package/dist/chunk-MO226P4Q.js +4 -0
- package/dist/{chunk-3CLX5EOX.js → chunk-MOBF2GH6.js} +2 -2
- package/dist/chunk-MXNGIEPU.js +3 -0
- package/dist/chunk-MYUKI5VN.js +4 -0
- package/dist/{chunk-TFRAYKN6.js → chunk-N5C65OFK.js} +2 -2
- package/dist/{chunk-PXY7F6Y4.js → chunk-O2RM7E7L.js} +5 -5
- package/dist/chunk-OFUBXBYX.js +3 -0
- package/dist/chunk-OFY4HTMI.js +2 -0
- package/dist/chunk-OIRWZIYL.js +38 -0
- package/dist/chunk-OIVZ7PW6.js +438 -0
- package/dist/chunk-ORBKAUCH.js +4 -0
- package/dist/chunk-OUB4J26T.js +2 -0
- package/dist/chunk-OVPS2ILI.js +20 -0
- package/dist/chunk-PHSPBQM6.js +5 -0
- package/dist/{chunk-JVYA47YU.js → chunk-PIZY2GX6.js} +2 -2
- package/dist/chunk-PNISDVYC.js +3 -0
- package/dist/chunk-PQOL42AW.js +2 -0
- package/dist/chunk-PUVZNFVY.js +11 -0
- package/dist/chunk-PZEI2TVL.js +4 -0
- package/dist/{chunk-ZK26BAQL.js → chunk-Q2J2VZZT.js} +2 -2
- package/dist/chunk-Q7HB7BFJ.js +2 -0
- package/dist/{chunk-ZTETIQ35.js → chunk-QBANU5BQ.js} +2 -2
- package/dist/chunk-QD7IFBCR.js +10 -0
- package/dist/chunk-QDCCHMVZ.js +2 -0
- package/dist/chunk-QLQBZOJH.js +3 -0
- package/dist/{chunk-PQCI4SQX.js → chunk-QXR5QPSF.js} +2 -2
- package/dist/chunk-R2MOKIVO.js +2 -0
- package/dist/{chunk-EN3O7VJA.js → chunk-RFWAUHVW.js} +2 -2
- package/dist/chunk-RGCJ4646.js +16 -0
- package/dist/{chunk-BPAPWKP6.js → chunk-S3RTPPLQ.js} +8 -8
- package/dist/chunk-S73HBCGI.js +11 -0
- package/dist/chunk-SDPA5DKN.js +210 -0
- package/dist/chunk-SEUJVWT2.js +3 -0
- package/dist/chunk-SF7X6QNW.js +2 -0
- package/dist/chunk-SKUMCCC5.js +2 -0
- package/dist/chunk-SSSJO4RG.js +2 -0
- package/dist/chunk-SWFAFA4G.js +49 -0
- package/dist/chunk-SYUNTKO2.js +2 -0
- package/dist/chunk-T6FRID7Y.js +3 -0
- package/dist/chunk-TGWNNMPF.js +3 -0
- package/dist/chunk-TM5XEDDR.js +4 -0
- package/dist/chunk-TNOHGHZQ.js +2 -0
- package/dist/chunk-U2GPTA5U.js +3 -0
- package/dist/{chunk-SXP2MBJH.js → chunk-U7DR7MJD.js} +2 -2
- package/dist/chunk-U7LRSQG6.js +3 -0
- package/dist/chunk-UL4VJUMD.js +2 -0
- package/dist/chunk-UNORWZIJ.js +16 -0
- package/dist/chunk-UQ7XPRWU.js +2 -0
- package/dist/{chunk-6SHPK5ZE.js → chunk-URMZLV2N.js} +2 -2
- package/dist/chunk-URTX2BEA.js +6 -0
- package/dist/chunk-UZFCZ7SJ.js +2 -0
- package/dist/{chunk-KMKTIO2G.js → chunk-V7LQZTTZ.js} +2 -2
- package/dist/chunk-VETXXOYU.js +3 -0
- package/dist/chunk-VGRUM7JI.js +3 -0
- package/dist/{chunk-WXZLAAWK.js → chunk-VNKYRJKN.js} +2 -2
- package/dist/chunk-VWLIOEEF.js +11 -0
- package/dist/chunk-WB6LGCFB.js +6 -0
- package/dist/{chunk-W4ETQAXM.js → chunk-WK4FD4PG.js} +2 -2
- package/dist/{chunk-O64IZ6UX.js → chunk-WKPZCQLI.js} +2 -2
- package/dist/chunk-WSG3DK5H.js +2 -0
- package/dist/chunk-WULAPQUD.js +38 -0
- package/dist/chunk-WZQFY5S7.js +4 -0
- package/dist/chunk-X434XZAI.js +2 -0
- package/dist/chunk-X7PJJYKX.js +29 -0
- package/dist/chunk-XDAUYDFT.js +2 -0
- package/dist/chunk-XITQLISP.js +2 -0
- package/dist/chunk-XRXCANFQ.js +4 -0
- package/dist/chunk-XVDMJMES.js +3 -0
- package/dist/chunk-XXJ7WL3F.js +35 -0
- package/dist/chunk-Y4XQ7LES.js +9 -0
- package/dist/chunk-YIEFEPG6.js +16 -0
- package/dist/chunk-YRVERHJR.js +49 -0
- package/dist/{chunk-CJST5ETY.js → chunk-YUFWLWIC.js} +2 -2
- package/dist/chunk-YUKYB54I.js +1 -0
- package/dist/chunk-Z3GCK3PD.js +3 -0
- package/dist/chunk-ZBNL3QCY.js +4 -0
- package/dist/chunk-ZD3Z54IW.js +2 -0
- package/dist/chunk-ZDVDSDFG.js +4 -0
- package/dist/{chunk-32LVLCLN.js → chunk-ZHSARYVS.js} +3 -3
- package/dist/{chunk-BDCC2NPY.js → chunk-ZW44MCJM.js} +2 -2
- package/dist/{chunk-N5W4YZMK.js → chunk-ZYREOING.js} +2 -2
- package/dist/cli-main.js +8 -0
- package/dist/cli.js +1 -3
- package/dist/code-CczEvHui.d.ts +121 -0
- package/dist/code-EQL6ZBLH.js +2 -0
- package/dist/code-result-json-6E4J6LGZ.js +2 -0
- package/dist/command-descriptors-QH3G2OVD.js +346 -0
- package/dist/{config-types-jVM3D7MA.d.ts → config-types-Cm-VSEBb.d.ts} +189 -23
- package/dist/dataflow-2BLMUZBP.js +2 -0
- package/dist/{db-B5PM5yNk.d.ts → db-LKJXAlNS.d.ts} +1 -1
- package/dist/dependence-slice-MGAJDZXB.js +2 -0
- package/dist/deps-GQMUYVKW.js +2 -0
- package/dist/direct-navigation-6RUJKLAV.js +3 -0
- package/dist/entry-map-V2NQP5JU.js +2 -0
- package/dist/exploration-topology-BG4v30HZ.d.ts +256 -0
- package/dist/file-dep-graph-Bqg3t3Px.d.ts +4 -0
- package/dist/file-kind-BKCVMNUf.d.ts +10 -0
- package/dist/files-VM53I4IU.js +2 -0
- package/dist/graph-evidence-CbUPCSKV.d.ts +126 -0
- package/dist/graph-exploration-contract-CqDsnPQL.d.ts +7 -0
- package/dist/{health-Do5TKSJI.d.ts → health-Wl5G_LRt.d.ts} +33 -34
- package/dist/hierarchy-D553WRSZ.js +2 -0
- package/dist/imports-DOZAJWLW.js +2 -0
- package/dist/index.d.ts +4 -31
- package/dist/index.js +1 -1
- package/dist/members-HE67475K.js +2 -0
- package/dist/methods-K5JK4PPH.js +2 -0
- package/dist/next-anchor-candidates-BwMczMvX.d.ts +90 -0
- package/dist/output-continuation-command-LKBUTNRL.js +3 -0
- package/dist/output-pagination-VAWOGX4R.js +19 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-4ARU6QCM.js +3 -0
- package/dist/queries/affected.d.ts +22 -4
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +123 -0
- package/dist/queries/anchors.js +2 -0
- package/dist/queries/architecture.d.ts +3 -2
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +26 -7
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +17 -3
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +5 -26
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +145 -0
- package/dist/queries/context.js +2 -0
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +8 -3
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +34 -7
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +40 -14
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +3 -3
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +4 -38
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.d.ts +47 -0
- package/dist/queries/dependence-slice.js +2 -0
- package/dist/queries/dependency-depth.d.ts +49 -0
- package/dist/queries/dependency-depth.js +2 -0
- package/dist/queries/deps.d.ts +4 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +3 -3
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +4 -4
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +121 -0
- package/dist/queries/entry-map.js +2 -0
- package/dist/queries/evidence.d.ts +70 -0
- package/dist/queries/evidence.js +2 -0
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +18 -5
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +4 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +5 -3
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +11 -5
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +4 -4
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +56 -136
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +3 -3
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +5 -9
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +27 -64
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.d.ts +4 -0
- package/dist/queries/reference-neighborhood.js +2 -0
- package/dist/queries/reference-reachability.d.ts +48 -0
- package/dist/queries/reference-reachability.js +2 -0
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +3 -36
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.d.ts +209 -0
- package/dist/queries/source-inspection.js +2 -0
- package/dist/queries/source-search.d.ts +13 -0
- package/dist/queries/source-search.js +2 -0
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +13 -4
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +449 -0
- package/dist/queries/system-map.js +2 -0
- package/dist/queries/system.d.ts +5 -3
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +47 -3
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +3 -3
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +3 -3
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.d.ts +43 -0
- package/dist/queries/value-flow.js +2 -0
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/query-service-fastpath.js +6 -0
- package/dist/query-service-server.js +5 -0
- package/dist/refs-NBHKL4UQ.js +2 -0
- package/dist/refs-pagination-BBVTIHMH.js +2 -0
- package/dist/reindex-worker.js +27 -45
- package/dist/reindex.d.ts +62 -42
- package/dist/reindex.js +32 -33
- package/dist/repository-text-C0Q8VYdN.d.ts +19 -0
- package/dist/runtime.d.ts +286 -7
- package/dist/runtime.js +4 -3
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{scip-cli-BnEwZRLJ.d.ts → scip-cli-CppzF5MK.d.ts} +33 -2
- package/dist/slice-U6S6LBSB.js +2 -0
- package/dist/source-search-types-Dwz8KeuW.d.ts +79 -0
- package/dist/source-snippet-_wrcgmZc.d.ts +15 -0
- package/dist/stats-OOJ74B32.js +2 -0
- package/dist/surface-C7SS5CDQ.js +2 -0
- package/dist/symbol-resolution-3FVEKDTJ.js +2 -0
- package/dist/system-6K2NOO5C.js +2 -0
- package/dist/trace-II5K2TMH.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/value-flow-MKFUUE5B.js +2 -0
- package/dist/watch-server.js +3 -2
- package/docs/AGENT_GUIDE.md +133 -476
- package/docs/AI_FAILURE_MODES.md +30 -301
- package/docs/API.md +1 -1
- package/docs/API_EVOLUTION.md +6 -0
- package/docs/CLI_JSON_OUTPUT.md +207 -29
- package/docs/COMMAND_REFERENCE.md +255 -154
- package/docs/CONFIGURATION_WRITE_SAFETY.md +14 -13
- package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +84 -0
- package/docs/DETECTOR_GUIDE.md +46 -138
- package/docs/DURABILITY.md +7 -1
- package/docs/INDEX_GENERATIONS.md +6 -0
- package/docs/LOCK_PROTOCOL.md +8 -0
- package/docs/REINDEX_METADATA_COMPATIBILITY.md +13 -3
- package/docs/SECURITY_MODEL.md +39 -42
- package/docs/accuracy-audit-checklist.md +4 -0
- package/docs/accuracy-hardening-goal.md +9 -2
- package/docs/analyzer-inventory.md +59 -264
- package/docs/analyzer-validation-protocol.md +62 -170
- package/docs/architecture-coherence-vision.md +18 -12
- package/docs/locality-analyzer-design.md +1 -1
- package/docs/schemas/cli-json-envelope.schema.json +212 -27
- package/docs/schemas/cli-json-export-receipt.schema.json +25 -0
- package/docs/schemas/cli-output-page.schema.json +1 -1
- package/docs/schemas/observation-receipt.schema.json +164 -0
- package/docs/schemas/project-config.schema.json +27 -45
- package/docs/schemas/suppression-record.schema.json +1 -34
- package/package.json +65 -8
- package/skills/concrete-plan/SKILL.md +8 -0
- package/skills/concrete-plan/agents/openai.yaml +4 -0
- package/skills/scip-explore/SKILL.md +3 -85
- package/skills/scip-explore/agents/openai.yaml +3 -3
- package/skills/scip-integrity-audit/SKILL.md +185 -0
- package/skills/scip-integrity-audit/agents/openai.yaml +4 -0
- package/skills/scip-plan/SKILL.md +67 -49
- package/skills/scip-plan/agents/openai.yaml +3 -3
- package/skills/scip-query/SKILL.md +77 -77
- package/skills/scip-query/agents/openai.yaml +3 -3
- package/skills/scip-setup/SKILL.md +10 -102
- package/skills/scip-setup/agents/openai.yaml +3 -3
- package/dist/chunk-26QA6FAI.js +0 -8
- package/dist/chunk-2KAZEZ6M.js +0 -2
- package/dist/chunk-3ORVDL3H.js +0 -2
- package/dist/chunk-46XGSFNI.js +0 -2
- package/dist/chunk-4MAK2HOY.js +0 -6
- package/dist/chunk-4TURLRL5.js +0 -16
- package/dist/chunk-4UQVNCQE.js +0 -2
- package/dist/chunk-55Q3WLZX.js +0 -2
- package/dist/chunk-5I5G2QOX.js +0 -3
- package/dist/chunk-6LDJQXAH.js +0 -2
- package/dist/chunk-6O5TICIZ.js +0 -3
- package/dist/chunk-7O5IKBTZ.js +0 -16
- package/dist/chunk-7S5E7KWT.js +0 -2
- package/dist/chunk-7WPLAODU.js +0 -5
- package/dist/chunk-AFHORGLH.js +0 -42
- package/dist/chunk-AIE7TFJW.js +0 -9
- package/dist/chunk-AQOFWNQJ.js +0 -1
- package/dist/chunk-B2PX5I6M.js +0 -2
- package/dist/chunk-B75HZHUP.js +0 -2
- package/dist/chunk-B7PBSLZN.js +0 -2
- package/dist/chunk-BBW6JFHN.js +0 -2
- package/dist/chunk-BNXCIFVY.js +0 -2
- package/dist/chunk-BS2NMXQZ.js +0 -4
- package/dist/chunk-C3KV2II6.js +0 -2
- package/dist/chunk-C43RDDP4.js +0 -20
- package/dist/chunk-DAFAHMNB.js +0 -42
- package/dist/chunk-DQLPXMH6.js +0 -8
- package/dist/chunk-EKZTZXHZ.js +0 -117
- package/dist/chunk-EW2NTSFA.js +0 -18
- package/dist/chunk-F3Z4OUDS.js +0 -8
- package/dist/chunk-FJH2NW7J.js +0 -66
- package/dist/chunk-FTFP6O3L.js +0 -11
- package/dist/chunk-FYLK2DEJ.js +0 -2
- package/dist/chunk-GH74ASD6.js +0 -11
- package/dist/chunk-GMXWZP2B.js +0 -2
- package/dist/chunk-GOUBFH5O.js +0 -3
- package/dist/chunk-HLF2TX6R.js +0 -2
- package/dist/chunk-HX7M4BDI.js +0 -30
- package/dist/chunk-HZ72SESS.js +0 -128
- package/dist/chunk-IB2N4FIY.js +0 -10
- package/dist/chunk-IZYYAFN5.js +0 -2
- package/dist/chunk-JFGGXWQF.js +0 -947
- package/dist/chunk-JN4NMBEX.js +0 -8
- package/dist/chunk-JW56N3KI.js +0 -4
- package/dist/chunk-JZ2OXNWB.js +0 -2
- package/dist/chunk-KFZNKUNT.js +0 -2
- package/dist/chunk-L5GJNV2T.js +0 -8
- package/dist/chunk-L7JDSCDF.js +0 -4
- package/dist/chunk-LU47HG23.js +0 -14
- package/dist/chunk-LVY7NPF7.js +0 -2
- package/dist/chunk-MKCDWWGV.js +0 -4
- package/dist/chunk-MNE7YG56.js +0 -2
- package/dist/chunk-MRXBEXSY.js +0 -26
- package/dist/chunk-MV7OWDUX.js +0 -2
- package/dist/chunk-NGEXCJJW.js +0 -11
- package/dist/chunk-NIW6JDC5.js +0 -29
- package/dist/chunk-PBUQFCNB.js +0 -16
- package/dist/chunk-POAVPHH7.js +0 -2
- package/dist/chunk-QZ4JVECJ.js +0 -2
- package/dist/chunk-RDO52JGY.js +0 -2
- package/dist/chunk-RJT3TUUZ.js +0 -2
- package/dist/chunk-RVLDN63O.js +0 -4
- package/dist/chunk-RXOXSKY3.js +0 -2
- package/dist/chunk-S7OYBOCK.js +0 -2
- package/dist/chunk-SMNXQT5Z.js +0 -3
- package/dist/chunk-SRAFT254.js +0 -2
- package/dist/chunk-T7YQSHPQ.js +0 -3
- package/dist/chunk-UJCOIXDY.js +0 -2
- package/dist/chunk-UJPRPGCO.js +0 -13
- package/dist/chunk-WCCFZ7V7.js +0 -113
- package/dist/chunk-WUPW3UN3.js +0 -3
- package/dist/chunk-X54AGLVX.js +0 -2
- package/dist/chunk-Y2MVPNKY.js +0 -5
- package/dist/chunk-YKUU5AIC.js +0 -3
- package/dist/chunk-YLCJLTPL.js +0 -2
- package/dist/chunk-YTQVETEO.js +0 -2
- package/dist/chunk-Z4N3MZYA.js +0 -38
- package/dist/chunk-ZJOOT3BG.js +0 -2
- package/dist/command-descriptors-DSS46KXI.js +0 -642
- package/dist/diff-gate-types-B0QYpDv1.d.ts +0 -11
- package/dist/direct-navigation-6YHV6IB5.js +0 -3
- package/dist/queries/diff-gate.d.ts +0 -253
- package/dist/queries/diff-gate.js +0 -2
- package/docs/COMMITTED_RECORD_COMPATIBILITY.md +0 -154
- package/docs/analyzer-validation-ledger.md +0 -516
- package/docs/schemas/outcome-event-record.schema.json +0 -95
- package/skills/_shared/SKILL.md +0 -101
- package/skills/_shared/agents/openai.yaml +0 -4
- package/skills/_shared/references/agent-contract-catalog.md +0 -105
- package/skills/_shared/references/command-catalog.md +0 -118
- package/skills/_shared/references/detector-precision-and-diffgate.md +0 -59
- package/skills/_shared/references/evidence-and-dead-code.md +0 -25
- package/skills/scip-audit/SKILL.md +0 -77
- package/skills/scip-audit/agents/openai.yaml +0 -4
- package/skills/scip-audit/references/claims.md +0 -98
- package/skills/scip-audit/references/cleanup.md +0 -100
- package/skills/scip-audit/references/directory.md +0 -222
- package/skills/scip-audit/references/frontend.md +0 -130
- package/skills/scip-audit/references/integrity.md +0 -154
- package/skills/scip-audit/references/maintainability.md +0 -162
- package/skills/scip-audit/references/twin-drift.md +0 -104
- package/skills/scip-diagnose/SKILL.md +0 -52
- package/skills/scip-diagnose/agents/openai.yaml +0 -4
- package/skills/scip-diagnose/references/debug.md +0 -117
- package/skills/scip-diagnose/references/probe-reachability.md +0 -77
- package/skills/scip-diagnose/references/root-cause.md +0 -145
- package/skills/scip-diagnose/references/triage.md +0 -119
- package/skills/scip-explore/references/diagrams.md +0 -40
- package/skills/scip-explore/references/language-playbook.md +0 -49
- package/skills/scip-improve/SKILL.md +0 -56
- package/skills/scip-improve/agents/openai.yaml +0 -4
- package/skills/scip-improve/references/cleanup-batches.md +0 -53
- package/skills/scip-improve/references/directory-moves.md +0 -53
- package/skills/scip-improve/references/doc-reconcile.md +0 -30
- package/skills/scip-improve/references/frontend-extraction.md +0 -39
- package/skills/scip-improve/references/maintainability-mechanism.md +0 -43
- package/skills/scip-improve/references/twin-drift.md +0 -35
- package/skills/scip-plan/references/api-impact.md +0 -19
- package/skills/scip-plan/references/conductor.md +0 -41
- package/skills/scip-plan/references/high-assurance.md +0 -43
- package/skills/scip-plan/references/hyper-optimization.md +0 -50
- package/skills/scip-plan/references/tla-model.md +0 -88
- package/skills/scip-setup/references/bootstrap-workflow.md +0 -119
- package/skills/scip-setup/references/language-verification.md +0 -61
- package/skills/scip-setup/references/lifecycle-commands.md +0 -119
- package/skills/scip-setup/references/per-repo-triage.md +0 -24
- package/skills/scip-verify/SKILL.md +0 -229
- package/skills/scip-verify/agents/openai.yaml +0 -4
- package/skills/scip-verify/references/calibrate-detectors.md +0 -170
package/dist/reindex-worker.js
CHANGED
|
@@ -1,22 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
d1.relative_path AS from_file,
|
|
3
|
-
d2.relative_path AS to_file
|
|
4
|
-
FROM mentions m
|
|
5
|
-
JOIN chunks c ON m.chunk_id = c.id
|
|
6
|
-
JOIN documents d1 ON c.document_id = d1.id
|
|
7
|
-
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
8
|
-
JOIN (
|
|
9
|
-
SELECT m2.symbol_id, c2.document_id
|
|
10
|
-
FROM mentions m2
|
|
11
|
-
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
12
|
-
WHERE m2.role = 1
|
|
13
|
-
GROUP BY m2.symbol_id
|
|
14
|
-
) sym_def ON sym_def.symbol_id = gs.id
|
|
15
|
-
JOIN documents d2 ON sym_def.document_id = d2.id
|
|
16
|
-
WHERE d1.id != d2.id
|
|
17
|
-
${a}
|
|
18
|
-
${e.pathExclusionsFor("d1","d2")}
|
|
19
|
-
${r}`,...i)}function _i(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function he(e){let t=me(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let p=re(u.path,["typescript"]);return p==="config"||p==="ambient"}).map(u=>u.path),a=me([...t,...i]),o=a.find(u=>!r.has(u)),s=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,d=!o&&a.some(u=>An(r.get(u))),c=z(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:me(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,p){if(!n.has(u))return G("target-outside-project");if(s)return G("duplicate-input-path");if(o)return G("missing-input-fingerprint");if(d)return G("unreadable-input");let h=[],g,m;if(e.graph===null)h.push("dependency-graph-unavailable"),m="whole-project",g=a;else{let P=ji(u,e.graph,l);if(P.find(x=>!r.has(x)))return G("missing-input-fingerprint");if(g=me([...P,...i]),g.some(x=>An(r.get(x))))return G("unreadable-input");m="dependency-closure"}let S=g.map(P=>Ti(r.get(P)));return{version:1,key:z(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:c,inputs:S})),mode:m,inputFiles:g,reasons:h}}}}function Fi(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let o of[...t.get(a)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function ji(e,t,n){let r=n.get(e);if(r)return r;let i=Fi(e,t);return n.set(e,i),i}function Ti(e){return{path:e.path,size:e.size,hash:e.hash}}function An(e){return e.size<0||e.hash==="unreadable"}function G(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function me(e){return[...new Set(e)].sort()}var As=Lt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Ln(e){return k(e,{includeIgnored:!1}).filter(X).sort()}var wi="typescript-reference-fragment-v2",Di=Ct({kind:"typescript-reference-fragments",invalidation:ce("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:ki});function Nn(e,t,n,r=e){let i=Ln(e),a=he({projectFiles:i,snapshot:t,graph:$(e),engineIdentity:Ut()}),o=[...n].map(([s,d])=>({relativePath:s,contentHash:a.identityFor(s,wi).key,value:[...d]}));if(o.some(s=>s.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return Di.writeBatch(r,o.map(s=>({...s,contentHash:s.contentHash}))),o.length}function ki(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(Mi)?null:t}catch{return null}}function Mi(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as Ai}from"crypto";import{existsSync as Li}from"fs";import{dirname as Ni,join as $n}from"path";function He(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 ye(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=He(e),o=new Set(a.reasons);return r.some(s=>!i.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),Cn(r,i,o)):o.size>0?Cn(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:Oi(r,t,i),reasons:[]}}function Cn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Oi(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let d of s){if(!n.has(d))continue;let c=r.get(d)??new Set;c.add(o),r.set(d,c)}let i=new Set(e),a=[...e];for(let o=0;o<a.length;o+=1){let s=a[o];if(s!==void 0)for(let d of r.get(s)??[])i.has(d)||(i.add(d),a.push(d))}return[...i].sort()}var Ci="<global-symbols>";function $i(e){let t=[];for(let n of e.all(`
|
|
1
|
+
import{a as $e,b as Mt}from"./chunk-BZYSGZRK.js";import{a as fe,b as ee}from"./chunk-UNORWZIJ.js";import{a as Mn}from"./chunk-ILMHV3KM.js";import{e as tn,f as nn,g as rn,i as an}from"./chunk-SWFAFA4G.js";import"./chunk-3EX7DNBC.js";import{a as Zt,c as en}from"./chunk-GTDP2SKQ.js";import"./chunk-OUB4J26T.js";import"./chunk-2I3RSUWX.js";import"./chunk-4N6QSEMZ.js";import{b as Vt,c as Yt,d as Kt}from"./chunk-OIRWZIYL.js";import"./chunk-VGRUM7JI.js";import"./chunk-YUKYB54I.js";import"./chunk-GFLTPNWV.js";import{a as X,b as pe,c as Z,d as Wt,e as qt,f as Jt,g as Ht,h as zt,j as Ln}from"./chunk-54EOGFBR.js";import{a as Ot,b as At}from"./chunk-F4FNK44D.js";import{a as k}from"./chunk-BHE44MHT.js";import{a as Et,b as wt,c as ce,d as on,e as sn,g as qe,h as pn,m as Cn}from"./chunk-IUJ3ZFEE.js";import{a as ze,b as Se,c as Fn,e as Dn,f as An}from"./chunk-5ZJH6DDE.js";import{a as Qe}from"./chunk-MXNGIEPU.js";import{b as kn,c as On,d as Xe}from"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import{a as cn,b as dn,c as ln,d as un,e as me,f as gn,g as fn,h as mn,i as hn,j as yn,k as Sn,l as bn,m as Je,n as C,o as he,q as Pn,s as He,t as xn,u as Rn,v as ye,w as vn,x as In,y as En}from"./chunk-AUP6YI5M.js";import{a as Ct,b as j,d as Gt,q as Be,u as We}from"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import{c as K,d as le,e as Me,g as Le,h as Ft}from"./chunk-DOPCR5BY.js";import"./chunk-7IOAZRVL.js";import{f as ge}from"./chunk-VWLIOEEF.js";import{a as H,c as Nt,d as Ge,e as $t,g as Xt,h as Qt,k as wn,n as _n,o as jn,p as Tn}from"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import{a as Dt,e as D,f as U,g as kt}from"./chunk-HGFDYOVB.js";import{a as se,b as G,c as L,d as P}from"./chunk-3VLJ2DCA.js";import{B as Ce,K as Ne,P as ue,W as Lt,X as z,_ as Ut,a as vt,c as It,f as ae,g as ie,h as oe,ia as Ue,ja as Bt,l as _t,m as jt,n as Tt,o as de,q as I}from"./chunk-4DCKBY6T.js";import{createHash as Zi}from"crypto";import{existsSync as w,mkdirSync as Fe,mkdtempSync as eo,readdirSync as Lr,renameSync as Cr,rmSync as Q,statSync as to}from"fs";import{basename as Te,dirname as h,extname as no,join as E,resolve as jr}from"path";import{platform as ro}from"os";import{execFileSync as da}from"child_process";import{constants as la,copyFileSync as Nn,statSync as ua}from"fs";import{platform as pa}from"os";var ga=Object.freeze({size:e=>ua(e).size,clone:ma,copy:(e,t)=>Nn(e,t)}),fa=new Set(["ENOSYS","ENOTSUP","EOPNOTSUPP","EINVAL","EXDEV","ENOTTY"]);function B(e,t,n=ga){let r=n.size(e);try{return n.clone(e,t),{method:"reflink",bytes:r}}catch(a){if(!ya(a))throw a}return n.copy(e,t),{method:"copy",bytes:r}}function ma(e,t){if(pa()!=="darwin"){Nn(e,t,la.COPYFILE_FICLONE_FORCE);return}try{da("/bin/cp",["-c",e,t],{timeout:6e4,maxBuffer:64*1024,stdio:["ignore","ignore","pipe"]})}catch(n){throw ha(n)}}function ha(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 ya(e){let t=e?.code;return t!==void 0&&fa.has(t)}function $n(){return{reflinkedBytes:0,fallbackCopiedBytes:0}}function W(e,t){t.method==="reflink"?e.reflinkedBytes+=t.bytes:e.fallbackCopiedBytes+=t.bytes}import{dirname as Sa,join as ba}from"path";function Gn(e={}){return{id:"runtime-boundaries",facts:["runtime-boundary-observation","runtime-boundary-link"],run:({projectRoot:t,dbPath:n,onStatus:r})=>{let a=new k({projectRoot:t,dbPath:n,indexPath:e.indexPath??ba(Sa(n),"index.scip")}),i,o=!1,s=!1;try{let l=e.reuseExisting||e.affectedFiles?an(a):null;e.reuseExisting&&l?.extractorVersion===tn?(i=l,o=!0):(i=nn(a,{...l?{previousGraph:l}:{},...e.affectedFiles?{affectedFiles:e.affectedFiles}:{},profileSpan:D}),s=(i.coverage.filesReused??0)>0)}finally{a.close()}o||rn(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(l=>`${l.id} ${l.durationMs.toFixed(0)}ms`).join(", ")}.`),c}}}import{createHash as xa}from"crypto";import{existsSync as Ra}from"fs";import{dirname as va,join as Bn}from"path";function Ve(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 be(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=Ve(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"),Un(r,a,o)):o.size>0?Un(r,a,o):{mode:"closure",changedFiles:r,affectedFiles:Pa(r,t,a),reasons:[]}}function Un(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Pa(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 l=r.get(c)??new Set;l.add(o),r.set(c,l)}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()}var Ia="<global-symbols>";function Ea(e){let t=[];for(let n of e.all(`
|
|
20
2
|
SELECT relative_path, language, position_encoding, text
|
|
21
3
|
FROM documents
|
|
22
4
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -43,7 +25,7 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
43
25
|
FROM defn_enclosing_ranges r
|
|
44
26
|
JOIN documents d ON d.id = r.document_id
|
|
45
27
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
46
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
28
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:Ye(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
47
29
|
SELECT d.relative_path,
|
|
48
30
|
c.chunk_index,
|
|
49
31
|
m.role,
|
|
@@ -58,7 +40,7 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
58
40
|
JOIN chunks c ON c.id = m.chunk_id
|
|
59
41
|
JOIN documents d ON d.id = c.document_id
|
|
60
42
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
61
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
43
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:Ye(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
62
44
|
SELECT g.symbol,
|
|
63
45
|
g.display_name,
|
|
64
46
|
g.kind,
|
|
@@ -72,18 +54,18 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
72
54
|
) AND NOT EXISTS (
|
|
73
55
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
74
56
|
)
|
|
75
|
-
`))t.push({relativePath:
|
|
76
|
-
`);n.set(r,a.digest("hex"))}return n}function Bi(e,t){let n=[],r=[],i=[],a=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let d=e.get(s),c=t.get(s);d===void 0?n.push(s):c===void 0?i.push(s):d!==c?r.push(s):a.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function ze(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),o=e.affectedFiles.filter(d=>!i.has(d)).sort(),s=t.changedFiles.length-a.length;return{passed:a.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:a,extraFiles:o}}function Xe(e,t=zi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),o=(c,l)=>{let u=r();return qn(e.refreshResult,c,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,d=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),d=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let c=[...new Set([...t.indexedPaths(s),...t.indexedPaths(d)])].sort(),l=ie(e.previousSnapshot,e.currentSnapshot),u=new Set(c),p=l.changes.length>0&&!He(l).fullProject&&l.changes.every(S=>u.has(S.path)),h=ye(l,p?t.dependencyGraph(s):new Map,c),g=Bi(t.factDigests(s),t.factDigests(d)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:ze(h,g,c.length)}}catch(c){return o("oracle-error",c instanceof Error?c.message:String(c))}finally{Gn(s),Gn(d)}}function Bn(e,t,n,r=Date.now()){return qn(e,t,r,0,n)}function Ui(e){let t=Ni(e);return{latestPath:$n(t,"affected-shadow-latest.json"),historyPath:$n(t,"affected-shadow.jsonl")}}function Un(e,t,n=Xi){let r=Ui(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var qi=8*1024*1024,Wi=qt;function Hi(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 Ji(e,t,n=qi){Wt(e,Hi(t),{maxSegmentBytes:n,previousSuffix:Wi})}function Je(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 zi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:b,databaseExists:e=>Li(e),openDatabase:(e,t,n)=>new O({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>k(e),dependencyGraph:e=>$(e),factDigests:e=>$i(e)},Xi={appendHistory:Ji,writeLatest:(e,t)=>Mt(e,t,{spacing:2,trailingNewline:!0})};function qn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function Gn(e){try{e?.close()}catch{}}import{readdirSync as Qi}from"fs";import{isAbsolute as Wn,join as Vi,resolve as Yi}from"path";var Se="@sourcegraph/scip-typescript@0.4.0",Hn="scip-python-plus@0.7.5",Jn="github.com/sourcegraph/scip-go@v0.2.7",zn="scip-dotnet@0.2.14",Ki="scip_dart@1.6.2",Zi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],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","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],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:["pom.xml","build.gradle"],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:["build.sbt"],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:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:N.language,indexerBinary:N.indexerBinary,checkCommand:`${N.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:N.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[],installUrl:N.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:["pyproject.toml","setup.py"],installMethods:[{label:"npm",identity:Hn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Hn]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",Wn(r)?r:Yi(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],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:["Gemfile"],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:["go.mod"],installMethods:[{label:"go install",identity:Jn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Jn]}],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:["CMakeLists.txt","Makefile"],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:["CMakeLists.txt","Makefile"],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",Xn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",identity:zn,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",Xn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",identity:zn,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:["pubspec.yaml"],installMethods:[{label:"dart pub",identity:Ki,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})=>Wn(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Qe(e){return Zi[e]}function Xn(e,t){let n;try{n=Qi(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Vi(e,i);return null}import{createHash as ea}from"crypto";import{copyFileSync as ta,existsSync as Qn,rmSync as Vn}from"fs";import{resolve as na}from"path";import Zn from"better-sqlite3";var ra={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}]},ia={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 er(e){let t=b(),n=aa(e.affectedFiles);if(oa(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Vn(e.candidateDbPath,{force:!0}),!Qn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Qn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Yn(e.previousDbPath,"previous SQLite generation",!1),Yn(e.miniDbPath,"incremental SQLite mini database"),ta(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Zn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ve(r,"main","candidate SQLite generation"),Ve(r,"incremental","incremental SQLite mini database"),sa(r,n),ca(r,n.length);let i=Ye(r,"main",!0),a=M(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{da(r),la(r),ua(r),e.onStage?.("after-delete"),pa(r),e.onStage?.("after-symbol-reconciliation"),ga(r),e.onStage?.("after-insert"),fa(r),ma(r,n.length,a),e.onStage?.("before-commit")}).immediate(),tr(r,"main","candidate SQLite generation");let d=[...ha(r)].filter(([c,l])=>i.get(c)!==l).map(([c])=>c).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:b()-t}}catch(i){try{r?.close()}finally{Vn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function aa(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function oa(e,t,n){let r=[e,t,n].map(i=>na(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Yn(e,t,n=!0){let r=new Zn(e,{readonly:!0,fileMustExist:!0});try{Ve(r,"main",t),n&&tr(r,"main",t)}finally{r.close()}}function Ve(e,t,n){for(let[r,i]of Object.entries(ra)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:d,notnull:c,pk:l})=>({name:s,type:d.toUpperCase(),notnull:c,pk:l}));if(JSON.stringify(o)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ia)){let a=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(a?.tbl_name!==i.table||JSON.stringify(o)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Kn(e,t,"documents",["relative_path"],n),Kn(e,t,"global_symbols",["symbol"],n)}function Kn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(c=>c.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function tr(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 sa(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function ca(e,t){let n=M(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=M(e,`SELECT COUNT(*) AS value
|
|
57
|
+
`))t.push({relativePath:Ia,kind:"global-symbol",values:Ye(n)});return wa(t)}function wa(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=xa("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 _a(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),l=t.get(s);c===void 0?n.push(s):l===void 0?a.push(s):c!==l?r.push(s):i.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:a,changedFiles:[...n,...r,...a].sort(),unchangedFiles:i}}function Ke(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 Ze(e,t=Oa){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,a=t.wallNow??t.now,i=r(),o=(l,d)=>{let u=r();return Hn(e.refreshResult,l,n?u:a(),Math.max(0,u-i),d)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let l=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),d=de(e.previousSnapshot,e.currentSnapshot),u=new Set(l),p=d.changes.length>0&&!Ve(d).fullProject&&d.changes.every(O=>u.has(O.path)),m=be(d,p?t.dependencyGraph(s):new Map,l),g=_a(t.factDigests(s),t.factDigests(c)),y=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?y:a()).toISOString(),durationMs:Math.max(0,y-i),manifest:d,plan:m,comparison:g,evaluation:Ke(m,g,l.length)}}catch(l){return o("oracle-error",l instanceof Error?l.message:String(l))}finally{Wn(s),Wn(c)}}function qn(e,t,n,r=Date.now()){return Hn(e,t,r,0,n)}function ja(e){let t=va(e);return{latestPath:Bn(t,"affected-shadow-latest.json"),historyPath:Bn(t,"affected-shadow.jsonl")}}function Jn(e,t,n=Aa){let r=ja(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Ta=8*1024*1024,Fa=on;function Da(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 ka(e,t,n=Ta){sn(e,Da(t),{maxSegmentBytes:n,previousSuffix:Fa})}function Ye(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 Oa={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>Ra(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>ge(e),dependencyGraph:e=>Vt(e),factDigests:e=>Ea(e)},Aa={appendHistory:ka,writeLatest:(e,t)=>Xt(e,t,{spacing:2,trailingNewline:!0})};function Hn(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 Wn(e){try{e?.close()}catch{}}import{readdirSync as Ma}from"fs";import{isAbsolute as zn,join as La,resolve as Ca}from"path";var Pe="@sourcegraph/scip-typescript@0.4.0",Xn="scip-python-plus@0.7.5",Qn="github.com/sourcegraph/scip-go@v0.2.7",Vn="scip-dotnet@0.2.14",Na="scip_dart@1.6.2",$a={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>r?{binary:n,args:["index","--output",e,"--no-progress-bar",r]}:t?{binary:n,args:["index","--pnpm-workspaces","--output",e,"--no-progress-bar"]}:{binary:n,args:["index","--output",e,"--no-progress-bar"]},markerFiles:[...I.typescript],installMethods:[{label:"npm",identity:Pe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Pe]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--no-progress-bar"]}),markerFiles:[...I.javascript],installMethods:[{label:"npm",identity:Pe,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Pe]}],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:[...I.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:[...I.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:[...I.kotlin],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:X.language,indexerBinary:X.indexerBinary,checkCommand:`${X.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:X.indexerBinary,args:["scip",".","--output",e]}),markerFiles:[...I.rust],installMethods:[],installUrl:X.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:[...I.python],installMethods:[{label:"npm",identity:Xn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Xn]}],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",zn(r)?r:Ca(e,r)),{binary:n,args:a}},markerFiles:[...I.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:[...I.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:[...I.go],installMethods:[{label:"go install",identity:Qn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Qn]}],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:[...I.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:[...I.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",Yn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.csharp],installMethods:[{label:"dotnet",identity:Vn,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",Yn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:[...I.vb],installMethods:[{label:"dotnet",identity:Vn,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:[...I.dart],installMethods:[{label:"dart pub",identity:Na,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})=>zn(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:[...I.php],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Kn(e){if(!(e.projectPath||e.pnpmWorkspaces)){if(e.language==="typescript")return"{}";if(e.language==="javascript")return'{"compilerOptions":{"allowJs":true}}'}}function et(e){return $a[e]}function Yn(e,t){let n;try{n=Ma(e)}catch{return null}for(let r of t)for(let a of n)if(a.endsWith(r))return La(e,a);return null}import{createHash as Ga}from"crypto";import{existsSync as Zn,rmSync as er}from"fs";import{resolve as Ua}from"path";import rr from"better-sqlite3";var Ba={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}]},Wa={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 ar(e){let t=P(),n=qa(e.affectedFiles);if(Ja(e.previousDbPath,e.miniDbPath,e.candidateDbPath),er(e.candidateDbPath,{force:!0}),!Zn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Zn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");tr(e.previousDbPath,"previous SQLite generation",!1),tr(e.miniDbPath,"incremental SQLite mini database");let r=B(e.previousDbPath,e.candidateDbPath);e.writeTelemetry&&W(e.writeTelemetry,r);let a=null;try{a=new rr(e.candidateDbPath,{fileMustExist:!0}),a.pragma("busy_timeout = 5000"),a.pragma("foreign_keys = ON"),a.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),tt(a,"main","candidate SQLite generation"),tt(a,"incremental","incremental SQLite mini database"),Ha(a,n);let{priorAffectedCount:i}=za(a,n.length),o=nt(a,"main",!0),s=N(a,"SELECT COUNT(*) AS value FROM main.documents");a.transaction(()=>{Xa(a),Qa(a),Va(a),e.onStage?.("after-delete"),Ya(a),e.onStage?.("after-symbol-reconciliation"),Ka(a),e.onStage?.("after-insert"),Za(a),ei(a,n.length,s,i),e.onStage?.("before-commit")}).immediate(),ir(a,"main","candidate SQLite generation");let d=[...ti(a)].filter(([u,p])=>o.get(u)!==p).map(([u])=>u).sort();return a.exec("DETACH DATABASE incremental"),a.close(),a=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:P()-t}}catch(i){try{a?.close()}finally{er(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function qa(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Ja(e,t,n){let r=[e,t,n].map(a=>Ua(a));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function tr(e,t,n=!0){let r=new rr(e,{readonly:!0,fileMustExist:!0});try{tt(r,"main",t),n&&ir(r,"main",t)}finally{r.close()}}function tt(e,t,n){for(let[r,a]of Object.entries(Ba)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:l,pk:d})=>({name:s,type:c.toUpperCase(),notnull:l,pk:d}));if(JSON.stringify(o)!==JSON.stringify(a))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,a]of Object.entries(Wa)){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}`)}nr(e,t,"documents",["relative_path"],n),nr(e,t,"global_symbols",["symbol"],n)}function nr(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(l=>l.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${a} lost the unique ${n}(${r.join(", ")}) constraint`)}function ir(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 Ha(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(a=>{for(let i of a)n.run(i)})(t)}function za(e,t){let n=N(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=N(e,`SELECT COUNT(*) AS value
|
|
77
59
|
FROM main.documents d
|
|
78
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),
|
|
60
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),a=e.prepare(`SELECT p.relative_path
|
|
79
61
|
FROM temp.incremental_affected_paths p
|
|
80
62
|
LEFT JOIN incremental.documents d ON d.relative_path = p.relative_path
|
|
81
63
|
WHERE d.id IS NULL
|
|
82
|
-
LIMIT 1`).pluck().get(),
|
|
64
|
+
LIMIT 1`).pluck().get(),i=e.prepare(`SELECT d.relative_path
|
|
83
65
|
FROM incremental.documents d
|
|
84
66
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
85
67
|
WHERE p.relative_path IS NULL
|
|
86
|
-
LIMIT 1`).pluck().get();if(n!==t||
|
|
68
|
+
LIMIT 1`).pluck().get();if(n!==t||a!==void 0||i!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set");return{priorAffectedCount:r}}function Xa(e){e.exec(`
|
|
87
69
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
88
70
|
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
89
71
|
SELECT g.symbol
|
|
@@ -110,7 +92,7 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
110
92
|
FROM incremental.mentions m
|
|
111
93
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
112
94
|
WHERE m.role = 1;
|
|
113
|
-
`)}function
|
|
95
|
+
`)}function Qa(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
114
96
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
115
97
|
UNION
|
|
116
98
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
@@ -133,7 +115,7 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
133
115
|
SELECT u.symbol
|
|
134
116
|
FROM unaffected_definitions u
|
|
135
117
|
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
136
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function
|
|
118
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Va(e){e.exec(`
|
|
137
119
|
DELETE FROM main.mentions
|
|
138
120
|
WHERE chunk_id IN (
|
|
139
121
|
SELECT c.id
|
|
@@ -155,7 +137,7 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
155
137
|
);
|
|
156
138
|
DELETE FROM main.documents
|
|
157
139
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
158
|
-
`)}function
|
|
140
|
+
`)}function Ya(e){e.exec(`
|
|
159
141
|
UPDATE main.global_symbols
|
|
160
142
|
SET display_name = NULL,
|
|
161
143
|
kind = NULL,
|
|
@@ -197,7 +179,7 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
197
179
|
WHERE source.symbol = main.global_symbols.symbol
|
|
198
180
|
)
|
|
199
181
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
200
|
-
`)}function
|
|
182
|
+
`)}function Ka(e){let t=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=N(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
|
|
201
183
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
202
184
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
203
185
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
@@ -212,18 +194,18 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
212
194
|
r.start_line, r.start_char, r.end_line, r.end_char
|
|
213
195
|
FROM incremental.defn_enclosing_ranges r
|
|
214
196
|
JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
215
|
-
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function
|
|
197
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function Za(e){e.exec(`
|
|
216
198
|
DELETE FROM main.global_symbols
|
|
217
199
|
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
218
200
|
AND NOT EXISTS (
|
|
219
201
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
220
202
|
);
|
|
221
|
-
`)}function
|
|
203
|
+
`)}function ei(e,t,n,r){let a=N(e,"SELECT COUNT(*) AS value FROM main.documents"),i=N(e,`SELECT COUNT(*) AS value
|
|
222
204
|
FROM main.documents d
|
|
223
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(
|
|
205
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),o=n-r+t;if(a!==o||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let s=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),c=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(s!==void 0||c!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function ti(e){let t=nt(e,"main",!0),n=nt(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function nt(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",a=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
|
|
224
206
|
FROM ${t}.documents d
|
|
225
207
|
${r}
|
|
226
|
-
ORDER BY d.relative_path`).all(),
|
|
208
|
+
ORDER BY d.relative_path`).all(),i=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
227
209
|
FROM ${t}.chunks c
|
|
228
210
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
229
211
|
${r}
|
|
@@ -242,17 +224,17 @@ import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILM
|
|
|
242
224
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
243
225
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
244
226
|
${r}
|
|
245
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),
|
|
246
|
-
`);
|
|
247
|
-
`;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function rt(e){try{let t=ne(e,{maxBytes:yt,inputKind:"TypeScript project manifest"}),n=JSON.parse(ka(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as Ma,readdirSync as Oa,statSync as Aa}from"fs";import I from"path";var La=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Y(e,t=[]){let n=I.resolve(e),r=t.flatMap(d=>Ca(n,d));if(r.length>0)return pr(n,gr(r));let i=Na(n),a=gr(i),o=Ga(n,a)?[n,...a]:a,s=o.length>0?o:[n];return pr(n,s)}function pr(e,t){return[...new Set(t.map(n=>Ua(e,n)))].sort((n,r)=>n.localeCompare(r))}function Na(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Oa(r,{withFileTypes:!0})}catch{continue}for(let a of i){let o=I.join(r,a.name);if(a.isDirectory()){!La.has(a.name)&&!a.name.startsWith(".")&&n.push(o);continue}a.isFile()&&$a(o)&&t.push(I.dirname(o))}}return t}function Ca(e,t){let n=t.trim();if(!n)return[];let r=I.resolve(e,n);if(!H(e,r))return[];try{let i=Aa(r);if(i.isDirectory())return[r];if(i.isFile()&&fr(I.basename(r)))return[I.dirname(r)]}catch{return[]}return[]}function $a(e){if(!fr(I.basename(e)))return!1;let t=mr(e);return t?I.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function fr(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function gr(e){let t=[...new Set(e.map(n=>I.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&qa(n,r)))}function Ga(e,t){if(t.length===0||t.some(r=>I.resolve(r)===e))return!1;let n=I.join(e,"tsconfig.json");return Ma(n)&&Ba(n)}function Ba(e){let n=mr(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!I.extname(r))):!1}function mr(e){try{let t=JSON.parse(D(e,"TypeScript project config"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Ua(e,t){let n=I.relative(e,t);return n?n.split(I.sep).join("/"):"."}function qa(e,t){let n=I.relative(e,t);return!!n&&!n.startsWith("..")&&!I.isAbsolute(n)}import{createHash as eo}from"crypto";import{existsSync as it,statSync as to,writeFileSync as at}from"fs";import{join as no}from"path";import{randomUUID as Wa}from"crypto";import{existsSync as Ha}from"fs";var Ja=12e4,za=5,Re=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=vt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ka(),this.runtime=n.runtime??Za,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=Sn(this.cacheDir),r=hn(this.cacheDir),i=Ue(n.statePath);if(!hr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),o=a+this.timeoutMs,s=(this.runtime.monotonicNow??b)()+this.timeoutMs,d=gn("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),c=fn(d),l=mn(r,{mailboxVersion:pn,operationKey:d,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:o,protocolVersion:pe,id:c,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??b)()<=s;){if(Ha(l.responsePath))return Xa(ne(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),c,d,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Ue(n.statePath);if(!hr(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(za)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function hr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===pe&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&J(e.processIdentity,r))}function Xa(e,t,n,r,i,a){let o=JSON.parse(e);if(o.protocolVersion!==pe||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)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=Qa(o.response,i),d=[...new Set(a)].sort(),c=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(c)!==JSON.stringify(d))throw new Error("TypeScript index service omitted or added an affected document.");return s}function Qa(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Va)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let o=a.bytesBase64===null?null:Ya(a.bytesBase64);return{relativePath:a.relativePath,bytes:o,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Va(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 Ya(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ka(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Ja}var Za={now:Date.now,monotonicNow:b,randomId:Wa,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:L,readProcessIdentity:A};function ro(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=ie(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!X(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=ye(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=io([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=yr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=yr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=br(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let d=br(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return d?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:Sr(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Sr(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:d,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function io(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Pr(e){let t=b();try{if(!it(e.previousDbPath)||!it(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Be();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new O({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=k(a,{includeIgnored:!1}).filter(X).sort(),s=$(a)}finally{a.close()}let d=performance.now()-n,c=ro({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?Y(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:it(no(e.projectRoot,"tsconfig.json"))});if(!c.eligible)throw new Error(c.reason);let l=yn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Re({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:c.tsconfigPath,projectArgument:c.projectArgument,projectIdentity:c.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles}),h=performance.now()-n,g=to(e.previousShardPath).size>=en;n=performance.now();let m=g?null:ke(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:De}),S=g?{completeIndexBytes:null,affectedIndexBytes:Vt(p.fragments)}:Zt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?tn({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,nextGenerationIdentity:c.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Yt({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.previousFragmentGeneration,documentIdentities:c.previousDocumentIdentities,allowUntrackedDocuments:!0}),Kt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.nextFragmentGeneration,fragments:p.fragments,documentIdentities:c.nextDocumentIdentities}));let P=performance.now()-n;n=performance.now(),S.completeIndexBytes&&at(e.candidateShardPath,S.completeIndexBytes),at(e.candidateAffectedScipPath,S.affectedIndexBytes);let v=performance.now()-n,x={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:b()-t,cold:p.cold,changedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:c.previousFragmentGeneration,nextFragmentGeneration:c.nextFragmentGeneration,manifest:c.manifest,plan:c.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(p.fragments.map(E=>[E.relativePath,E.referenceFragments])),timings:{runtimeMs:i,graphMs:d,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:P,writeMs:v}};return e.onStatus(`Incremental TypeScript index emitted ${x.affectedFiles.length} affected document(s) in ${(x.durationMs/1e3).toFixed(3)}s (${x.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${P.toFixed(0)}ms, write ${v.toFixed(0)}ms).`),x}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function xr(e){let t=Be();if(!t.available)throw new Error(t.reason);let n=nn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:ke(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:De}),packageVersion:t.packageVersion});at(e.candidateShardPath,n)}function yr(e,t,n){let r=e.files.filter(i=>re(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return ot(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Sr(e,t){return ot(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function br(e,t,n,r,i){let a=new Set(e.files.map(d=>d.path)),o=he({projectFiles:t.filter(d=>a.has(d)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let d of i){let c=o.identityFor(d,"typescript-scip-document-v1");if(c.key){s.set(d,c.key);continue}if(a.has(d))return null;s.set(d,ot(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return s}function ot(e){return eo("sha256").update(e).digest("hex")}import{existsSync as Ie,renameSync as ct,rmSync as dt,statSync as ao}from"fs";import{cpus as oo}from"os";import{join as Ir}from"path";function so(e,t,n){if(!e.defaultOutputPath)return;let r=Ir(t,e.defaultOutputPath);n!==r&&Ie(r)&&ct(r,n)}function co(e,t,n){if(!e.defaultOutputPath)return null;let r=Ir(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return dt(i,{force:!0}),Ie(r)?(ct(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function lo(e){e&&(dt(e.defaultOutputPath,{force:!0}),e.backupPath&&Ie(e.backupPath)&&ct(e.backupPath,e.defaultOutputPath))}function uo(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,oo().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function vr(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),a=e.filter(c=>!c.config.defaultOutputPath),o=[],s=uo(a.length,r),d=await Rn(a,s,c=>st(c,t,n));if(s>1){let c=new Map;for(let l of d.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),c.set(u.id,(await st(u,t,n)).result))}o.push(...d.map(({result:l})=>c.get(l.id)??l))}else o.push(...d.map(({result:c})=>c));for(let c of i)o.push((await st(c,t,n)).result);return o.sort((c,l)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===l.id))}async function st(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),dt(e.scipPath,{force:!0});let r=co(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=b();try{e.trustedProjectTool&&wn(t,e.trustedProjectTool);let s=Pt(e.binary,e.args),d=await xn({command:s.binary,args:s.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:po(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(d.status!==0){let c=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${c?`:
|
|
248
|
-
${
|
|
249
|
-
`)[0]}`,l=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-a,command:i,skipped:{language:e.language,reason:l}},retryable:go(s)}}finally{lo(r)}if(!Ie(e.scipPath)){let s=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-a,command:i,skipped:{language:e.language,reason:d}},retryable:!1}}let o;try{o=ao(e.scipPath).size}catch{o=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-a,command:i,outputBytes:o},retryable:!1}}function po(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):bn.indexer}function go(e){return e instanceof Pn?e.kind==="spawn"&&Rr(e.cause):Rr(e)}function Rr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as _r}from"child_process";import{homedir as Er,platform as fo}from"os";import{delimiter as mo,join as ve}from"path";function Fr(e,t){let n=e.installMethods,r=fe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!oe(i.prerequisite))continue;let a=ho(i);t(`Installing immutable ${i.identity} via ${i.label} into ${a}; expected executable: ${r}.`);try{_r(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:fo()==="win32"});let o=C(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${o}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function ho(e){if(e.binary==="npm")return lt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=lt("go",["env","GOBIN"]);if(t)return t;let n=lt("go",["env","GOPATH"]);if(n)return ve(n.split(mo)[0],"bin")}return e.binary==="dotnet"?ve(process.env.DOTNET_CLI_HOME??Er(),".dotnet","tools"):e.binary==="dart"?ve(process.env.PUB_CACHE??ve(Er(),".pub-cache"),"bin"):e.destination}function lt(e,t){try{return _r(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Cr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,a=vo(e),o=Date.now(),s=b();_e(y(a.outputScip),{recursive:!0}),_e(y(a.outputDb),{recursive:!0});let d=e.languages??Ht(t);if(d.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${d.join(", ")}`);let c=T("reindex.fingerprint",()=>kt(t,d,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:d.length}),l,u;if(e.skipIfUnchanged!==!1&&!cn(t,a.outputDb)&&jr(a.outputScip)===jr(R(y(a.outputDb),"index.scip"))){let m=se(t);if(l=m?ue(m,c):void 0,l){let S=$e(l);if(S){if(!Io(a,c))try{Ge({snapshot:l,manifest:S,targetCacheDir:y(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${U(f)}`)}}else{let f=await ln(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let P=$e(l);if(P)try{Ge({snapshot:l,manifest:P,targetCacheDir:y(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(v){r(`Shared generation attach failed after waiting; continuing locally: ${U(v)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=Ft(R(y(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${y(a.outputDb)}.`);let h;try{h=await W("reindex.lock",()=>Yo(R(y(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:d.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{on(a.outputDb,a.outputScip,a.metaPath);let m=jo(y(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let _ of m.errors)r(`Could not remove abandoned reindex workspace: ${_}`);let S=null,f=T("reindex.reuse-check",()=>(S=Eo({opts:e,paths:a,languages:d,fingerprint:c,start:o,monotonicStart:s,onStatus:r}),S),()=>({languages:d.length,reused:S!==null}));if(f){Tr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r});let _=Ce(a.outputDb,f);return _.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${_.reason}`),Ae(t,y(a.outputDb)),f}await W("reindex.scip-cli-ready",()=>qo(i,r));let P=Fo(a);g=P.runDir;let v,x=await W("reindex.fresh",async()=>(v=await To({opts:e,languages:d,projectRoot:t,paths:a,tempPaths:P,fingerprint:c,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),v),()=>({languages:d.length,reused:v?.reused,skipped:v?.skipped.length}));Tr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r});let E=Ce(a.outputDb,x);return E.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${E.reason}`),Ae(t,y(a.outputDb)),x}catch(m){let S=we({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:m instanceof Error?m.message:String(m)});Yr(a.metaPath,S);let f=Qt(a.outputDb,S);throw f.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${f.reason}`),m}finally{g&&B(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function Tr(e){if(e.snapshot)try{let t=se(e.projectRoot),n=t?ue(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=dn({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=se(e.projectRoot);return(i?ue(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});un(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${U(t)}`)}}function Io(e,t){if(!j(e.outputScip)||!j(e.outputDb)||!Vr(e.metaPath,t))return!1;let n=Q(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function U(e){return e instanceof Error?e.message:String(e)}function vo(e){let t=e.outputScip??R(e.projectRoot,"index.scip"),n=e.outputDb??R(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:R(y(n),"meta.json")}}function Eo(e){let t=Q(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!j(e.paths.outputScip)||!j(e.paths.outputDb)||!Vr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;le(de(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=b()-e.monotonicStart,r=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Yr(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:_o(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function _o(e,t,n,r){let i=Xr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:K(i[a]),outputBytes:Z(ft(e.outputDb,a)),durationMs:0}))}function Fo(e){let t=bo(R(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:R(t,Ee(e.outputScip)),tempOutputDb:R(t,Ee(e.outputDb)),tempMetaPath:R(t,Ee(e.metaPath))}}function jo(e){let t=[],n;try{n=Lr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[U(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{B(R(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${U(a)}`)}return{removed:r,errors:t}}async function To(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await W("reindex.language-indexers",async()=>(n=await Do(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:o,languageFingerprints:s,shards:d,typescriptProjectShardContext:c,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),wo({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:o})){let h=T("reindex.publish",()=>Go(e,i,a,o,s,c),{mode:"metadata-only",languages:i.length,reused:o.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:d}}let u=T("reindex.publish",()=>$o(e,t,i,a,o,s,c,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:o.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:d}}function wo(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!j(e.run.paths.outputScip)||!j(e.run.paths.outputDb))return!1;let t=Q(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Do(e,t){let n=Lo({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[F,ht]of n)ht.reused&&(r.push({language:F,scipPath:ht.scipPath}),i.add(F));for(let F of i)e.onStatus(`Reusing cached ${F} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),o=Q(e.paths.outputDb,e.paths.metaPath),s=te(e.paths.metaPath),d=o.state==="legacy"||o.state==="current",c=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&d?Pr({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:ee(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:ee(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:c,previousSnapshot:gt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:ko(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=Wo({languages:e.languages.filter(F=>!i.has(F)&&!u.has(F)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),S=p?h.filter(F=>F.language!=="typescript"||p.missedProjectIds.has(F.id)):h,f=await vr(S,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),P=[];if(p){Oo(e.paths.outputDb,f);let F=m.typescript??e.tempPaths.tempOutputScip;P=Ao({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:F,reusedProjects:p.reusedProjects})}let v=[...f,...P],{indexedOutputs:x}=Jo(v,g),E=l?[{language:"typescript",scipPath:l.scipPath}]:[],_=[...r,...E,...x];zo(_,g,e.languages,e.opts.allowPartial,e.onStatus);let ii=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Z(l.scipPath)??void 0}]:[],ai=No(n,[...f,...ii],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:_,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:Co(n,e.languages),shards:ai,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function ko(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=Y(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=cr(e.projectRoot,r),a=ar(n.fingerprint.files,r),o=or(r,i),s=sr(r,a,o),d=te(e.paths.metaPath),l=Mo(d,s,g=>j(Te(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:u,missedProjectIds:h}}function Mo(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let o=e.version===q&&Oe(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(w(o)!==w(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Oo(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=Te(e,r);_e(y(i),{recursive:!0}),je(n.scipPath,i)}}function Ao(e){return e.reusedProjects.map((t,n)=>{let r=Te(e.outputDb,t),i=ee(e.tempOutputScip,"typescript-project-cached",n);return je(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Z(i)??void 0}})}function Lo(e){let t=te(e.paths.metaPath),n=Xr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=ft(e.paths.outputDb,i),o=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:a});continue}if(t.version!==q){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:a});continue}if(!Oe(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:a});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:a});continue}if(!j(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:a});continue}if(w(s)!==w(o)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:o,scipPath:a})}return r}function No(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:K(a.fingerprint),outputBytes:Z(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),o=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??a?.reason??i.skipped?.reason,fingerprint:s?K(s.fingerprint):a?K(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:K(a.fingerprint),outputBytes:Z(Te(n.outputDb,i)),durationMs:0});return r}function K(e){return So("sha256").update(w(e)).digest("hex").slice(0,16)}function Z(e){try{return Po(e).size}catch{return null}}function Co(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function $o(e,t,n,r,i,a,o,s){let d=!s||s.completeScipUpdated,c=!1;d&&(wr(e.paths.outputDb,n),c=Dr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=Xo({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:d,completeScipSanitized:c,materializeFullFallback:()=>{if(!s||s.completeScipUpdated)return c;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),xr({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let x=n.map(E=>E.language==="typescript"?{language:E.language,scipPath:s.candidateScipPath}:E);return wr(e.paths.outputDb,x),c=Dr(x,e.tempPaths.tempOutputScip,e.onStatus),c}});le(de(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let u=Ke(e.tempPaths.tempOutputDb);if(u.added.length>0&&e.onStatus(`Added SQLite query indexes: ${u.added.join(", ")}`),u.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${u.removed.join(", ")}`),l.mode==="incremental"&&s){let x=null,E=null;try{x=new O({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),E=new O({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let _=Nn(x,e.fingerprint,s.referenceFragmentsByFile,E);e.onStatus(`Cached exact TypeScript reference fragments for ${_} affected document(s).`)}catch(_){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${_ instanceof Error?_.message:String(_)}.`)}finally{x?.close(),E?.close()}}let p=gt(e.paths.metaPath),h=l.mode==="incremental"&&s?Vo(s,l.changedDocumentPaths):Xe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),g=we({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(x=>x.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",S={...a};m&&delete S.typescript;let{metadata:f,pruneProjects:P}=Gr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:S,typescriptProjectShardContext:o,lastRefresh:g});f.scipCompanion=m?"deferred":"current",Br(e.paths.outputDb,P),mt(e.tempPaths.tempMetaPath,f);let v=an({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 v.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${v.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),rn(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),$r(e.paths.outputDb,h,e.onStatus),g}function Go(e,t,n,r,i,a){let o=gt(e.paths.metaPath),s=null;try{je(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(p){s=Bn("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}le(de(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let d=Ke(e.paths.outputDb);d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),s??=Xe({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 c=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:u}=Gr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:c});return Br(e.paths.outputDb,u),mt(e.paths.metaPath,l),sn(e.paths.outputDb,e.paths.metaPath),$r(e.paths.outputDb,s,e.onStatus),c}function gt(e){return St(te(e)?.fingerprint)}function $r(e,t,n){try{Un(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 Gr(e){let t=Bo({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:q,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 Bo(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=te(e.metaPath),n=t?.version===q?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 Br(e,t){let n=Qr(e);if(t===null){B(n,{recursive:!0,force:!0});return}let r;try{r=Lr(n)}catch{return}for(let i of Uo(r,t))B(R(n,i),{force:!0})}function Uo(e,t){let n=new Set(t.map(r=>`${nt(r)}.scip`));return e.filter(r=>!n.has(r))}function wr(e,t){for(let n of t){let r=ft(e,n.language);_e(y(r),{recursive:!0}),n.scipPath!==r&&je(n.scipPath,r)}}async function qo(e,t){if(!Le()){if(Ro()==="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.
|
|
227
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[d,u]of Object.entries({documents:a,chunks:i,definitions:o,mentions:s}))for(let p of u){let m=JSON.stringify([d,p]),g=c.get(p.relative_path)??[];g.push(m),c.set(p.relative_path,g)}let l=new Map;for(let[d,u]of[...c].sort(([p],[m])=>p.localeCompare(m))){let p=Ga("sha256");for(let m of u.sort())p.update(m).update(`
|
|
228
|
+
`);l.set(d,p.digest("hex"))}return l}function N(e,t){return e.prepare(t).get().value}import ni from"better-sqlite3";var xe="idx_mentions_definitions",ri=["symbol_id","chunk_id"];function rt(e){let t=new ni(e),n=[],r=[],a=[];try{return t.transaction(()=>{ai(t,n),Re(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&or(t,"global_symbols").some(s=>s.name!=="idx_global_symbols_symbol"&&s.unique&&s.columns.join("\0")==="symbol")?(t.exec('DROP INDEX "idx_global_symbols_symbol"'),r.push("idx_global_symbols_symbol")):Re(t,"idx_global_symbols_symbol")&&a.push("idx_global_symbols_symbol");let i=Re(t,"idx_chunks_doc_id"),o=or(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");i?.join("\0")==="document_id"&&o?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):i&&a.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:a,analyzed:!0}}catch(i){if(i.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw i}finally{t.close()}}function ai(e,t){let n=sr(e,xe);if(n){let r=n.columns.join("\0")===ri.join("\0"),a=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!a||n.table!=="mentions")throw new Error(`${xe} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${xe}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(xe)}function or(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Re(e,n.name)??[]}))}function Re(e,t){return sr(e,t)?.columns??null}function sr(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 ii}from"crypto";import{existsSync as at,readdirSync as oi}from"fs";import{dirname as it,join as ve,relative as si,resolve as ot,sep as cr}from"path";function dr(e,t){let n=t.includes("."),r={};for(let i of t)r[i]=[];let a=[];for(let i of e){let o=gr(i.path,t);o?r[o].push(i):n?r["."].push(i):a.push(i)}return{files:r,shared:a}}function lr(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=gr(s,e);c&&c!==a&&o.add(c)}}return ci(e,r)}function ur(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 st(e){if(e===".")return"root";let t=ii("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function pr(e,t){let n=ot(e),r={};for(let a of t)r[a]=di(n,a);return r}function gr(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 ci(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 di(e,t){let n=t==="."?e:ve(e,t),r=li(n),a=ui(n),i=a?pi(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 li(e){let t=ve(e,"package.json");if(!at(t))return{name:void 0,dependencyNames:[],failed:!1};let n=ct(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,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 ui(e){let t=ve(e,"tsconfig.json");if(at(t))return t;let n;try{n=oi(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,a)=>r.localeCompare(a)),n.length>0?ve(e,n[0]):void 0}function pi(e,t){let n=ct(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=gi(n.value,e,t),a=fr(e,n.value,t,0);return{pathsTargets:a.pathsTargets,referencesPaths:r,failed:a.failed}}function gi(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let a=it(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=mr(s,a,n);c&&i.add(c)}return[...i]}function fr(e,t,n,r){let a=fi(t);if(a)return{pathsTargets:mi(a,it(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let i=hi(t.extends,e,n);if(!i)return{pathsTargets:[],failed:!1};let o=ct(i);return o.ok?fr(i,o.value,n,r+1):{pathsTargets:[],failed:!0}}function fi(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 mi(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=mr(i,t,n);o&&r.add(o)}return[...r]}function hi(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=ot(it(t),r);if(a.endsWith(".json")||(a=`${a}.json`),!a.split(cr).includes("node_modules")&&Ce(n,a)&&at(a))return a}function mr(e,t,n){let r=e.replace(/\/?\*+$/,""),a=ot(t,r===""?".":r);if(!Ce(n,a))return;let o=si(n,a).split(cr).join("/");return o===""?".":o}function yi(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]!==`
|
|
229
|
+
`;)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 ct(e){try{let t=ie(e,{maxBytes:vt,inputKind:"TypeScript project manifest"}),n=JSON.parse(yi(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as ji}from"crypto";import{existsSync as lt,writeFileSync as xr}from"fs";import{join as Ti}from"path";import{randomUUID as Si}from"crypto";import{existsSync as bi}from"fs";var Pi=12e4,xi=5,te=class extends Error{name="TypeScriptIndexMemoryPressureError"},Ie=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;emitLocally;localHost=null;constructor(t,n={}){this.projectRoot=Lt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??wi(),this.runtime=n.runtime??_i,this.mailboxLimits=n.mailboxLimits??{},this.emitLocally=n.emitLocally}request(t){let n=On(this.cacheDir),r=Fn(this.cacheDir),a=Xe(n.statePath);if(!hr(a,this.projectRoot,this.runtime))return this.requestLocally(t);let i=this.runtime.now(),o=i+this.timeoutMs,s=(this.runtime.monotonicNow??P)()+this.timeoutMs,c=_n("typescript-index-v4",{baseGeneration:this.baseGeneration,request:t}),l=jn(c),d=Tn(r,{mailboxVersion:wn,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:i,deadlineAtMs:o,protocolVersion:Se,id:l,baseGeneration:this.baseGeneration,request:t},{nowMs:i,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=s;){if(bi(d.responsePath))return Ri(ie(d.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),l,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Xe(n.statePath);if(!hr(u,this.projectRoot,this.runtime))return this.requestLocally(t);this.runtime.sleep(xi)}return this.requestLocally(t)}requestLocally(t){return this.emitLocally?dt(this.emitLocally(t),t.producerIdentity,t.affectedFiles):(this.localHost??=new An({projectRoot:this.projectRoot,currentGeneration:()=>this.baseGeneration}),dt(yr(this.localHost.handle(this.baseGeneration,t),t.producerIdentity),t.producerIdentity,t.affectedFiles))}};function hr(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===Se&&n.isProcessAlive(e.pid)&&Number.isFinite(a)&&n.now()-a<=kn&&(!e.processIdentity||r!=null&&G(e.processIdentity,r))}function Ri(e,t,n,r,a,i){let o=JSON.parse(e);if(o.protocolVersion!==Se||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 vi(s)?new te(s):new Error(s)}return dt(yr(o.response,a),a,i)}function vi(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 dt(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 yr(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(Ii)||r.has(i.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(i.relativePath);let o=i.bytesBase64===null?null:Ei(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 Ii(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 Ei(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function wi(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Pi}var _i={now:Date.now,monotonicNow:P,randomId:Si,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:H,readProcessIdentity:L};function Fi(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=de(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};let r=n.changes.filter(y=>y.inputKind==="source"&&We(y.path));if(r.some(y=>y.kind!=="modified"&&y.kind!=="added"))return{eligible:!1,reason:"TypeScript project membership changed"};if(r.length===0)return{eligible:!1,reason:"change is not a modified TypeScript source file"};let a=r.filter(y=>y.kind==="added").map(y=>y.path),i=r.filter(y=>y.kind==="modified"),o={...n,changes:r},s=Di(i,a,e.graph,e.projectFiles);if(!s.eligible)return s;let c=s.plan,l=ki(c,t,e.graph);if(!l)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let d=Sr(e.currentSnapshot,e.projectFiles,e.producerIdentity),u=Sr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(d!==u)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let p=Pr(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!p)return{eligible:!1,reason:"prior document identity unavailable"};let m=Pr(e.currentSnapshot,[...new Set([...e.projectFiles,...a])],e.graph,e.producerIdentity,c.affectedFiles);if(!m)return{eligible:!1,reason:"next document identity unavailable"};let g=l.length===1?l[0]:void 0;return{eligible:!0,manifest:o,plan:c,projectIdentity:d,previousFragmentGeneration:br(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:br(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:p,nextDocumentIdentities:m,projects:l,...g?{tsconfigPath:g.tsconfigPath,projectArgument:g.projectArgument}:{}}}function Di(e,t,n,r){if(e.length===0)return t.length===0?{eligible:!1,reason:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...t].sort(),affectedFiles:[...t].sort(),reasons:[]}};let a=be({version:1,changes:[...e],projectIdentityChanged:!1,uncertainty:[]},n,r);return a.mode!=="closure"||a.affectedFiles.length===0?{eligible:!1,reason:a.reasons.length>0?`affected set widened: ${a.reasons.join(", ")}`:"empty affected set"}:{eligible:!0,plan:{mode:"closure",changedFiles:[...new Set([...a.changedFiles,...t])].sort(),affectedFiles:[...new Set([...a.affectedFiles,...t])].sort(),reasons:[]}}}function ki(e,t,n){let r=new Map;for(let i of e.affectedFiles){let o=Oi(i,t);if(!o)return null;let s=r.get(o)??[];s.push(i),r.set(o,s)}let a=[];for(let[i,o]of[...r].sort(([s],[c])=>s.localeCompare(c))){let s=new Set(o),c=e.changedFiles.filter(l=>s.has(l)||o.some(d=>Ai(d,l,n)));if(c.length===0)return null;a.push({projectArgument:i,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,modifiedFiles:c,affectedFiles:[...o].sort()})}return a}function Oi(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)=>Ee(o)-Ee(i)||i.localeCompare(o)),a=r[0];return r[1]&&Ee(r[1])===Ee(a)?null:a}function Ee(e){return e==="."?0:e.split("/").filter(Boolean).length}function Ai(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 Rr(e){let t=P();try{if(!lt(e.previousDbPath)||!lt(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ze();if(!r.available)throw new Error(r.reason);let a=performance.now()-n;n=performance.now();let i=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s,c;try{o=ge(i,{includeIgnored:!1}).filter(We).sort(),c=Yt(i),s=c.graph}finally{i.close()}let l=performance.now()-n,d=Fi({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?z(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:lt(Ti(e.projectRoot,"tsconfig.json"))});if(!d.eligible)throw new Error(d.reason);let u=Dn(e.previousDbPath);if(!u)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Ie({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:u}),m=d.projects.map(f=>p.request({kind:"emit-documents",tsconfigPath:f.tsconfigPath,projectArgument:f.projectArgument,projectIdentity:d.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:f.modifiedFiles,affectedFiles:f.affectedFiles})),g=m.flatMap(f=>f.fragments),y=performance.now()-n;n=performance.now();let O=gn(g),F=performance.now()-n;n=performance.now(),mn({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,nextGenerationIdentity:d.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g});let _=performance.now()-n;n=performance.now(),xr(e.candidateAffectedScipPath,O);let b=performance.now()-n,x={scipPath:e.previousShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!1,durationMs:P()-t,cold:m.some(f=>f.cold),changedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:d.previousFragmentGeneration,nextFragmentGeneration:d.nextFragmentGeneration,manifest:d.manifest,plan:d.plan,projectFileCount:o.length,dependencyGraphSnapshot:c,referenceFragmentsByFile:new Map(g.map(f=>[f.relativePath,f.referenceFragments])),timings:{runtimeMs:a,graphMs:l,requestMs:y,serviceMs:m.reduce((f,R)=>f+R.durationMs,0),assemblyMs:F,fragmentStoreMs:_,writeMs:b}};return e.onStatus(`Incremental TypeScript index emitted ${x.affectedFiles.length} affected document(s) across ${d.projects.length} project(s) in ${(x.durationMs/1e3).toFixed(3)}s (${x.cold?"cold":"warm"} service; whole SCIP deferred; runtime ${a.toFixed(0)}ms, graph ${l.toFixed(0)}ms, request ${y.toFixed(0)}ms, assembly ${F.toFixed(0)}ms, fragments ${_.toFixed(0)}ms, write ${b.toFixed(0)}ms).`),x}catch(n){let r=n instanceof Error?n.message:String(n);if(e.onUnavailable?.(r),n instanceof te)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}. Falling back to the whole-project indexer.`),null}}function ut(e){let t=ze();if(!t.available)throw new Error(t.reason);let n=hn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:ae(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:It}),packageVersion:t.packageVersion});xr(e.candidateShardPath,n)}function Sr(e,t,n){let r=e.files.filter(a=>{let i=_t(a.path,e.languages);return i==="config"||i==="ambient"}).map(a=>({path:a.path,size:a.size,hash:a.hash})).sort((a,i)=>a.path.localeCompare(i.path));return pt(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function br(e,t){return pt(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Pr(e,t,n,r,a){let i=new Set(e.files.map(c=>c.path)),o=Zt({projectFiles:t.filter(c=>i.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of a){let l=o.identityFor(c,"typescript-scip-document-v1");if(l.key){s.set(c,l.key);continue}if(i.has(c))return null;s.set(c,pt(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function pt(e){return ji("sha256").update(e).digest("hex")}import{closeSync as Mi,existsSync as we,fstatSync as Li,lstatSync as Ci,openSync as Ni,renameSync as ft,rmSync as _e,statSync as $i,writeSync as Gi}from"fs";import{cpus as Ui}from"os";import{join as mt}from"path";function Bi(e,t){if(e.temporaryRootConfigContent===void 0)return null;let n=mt(t,"tsconfig.json"),r=Buffer.from(e.temporaryRootConfigContent,"utf8"),a;try{a=Ni(n,"wx",384)}catch(i){if(i.code==="EEXIST")return null;throw i}try{Gi(a,r);let i=Li(a);return{path:n,content:r,device:i.dev,inode:i.ino}}finally{Mi(a)}}function Wi(e){if(e)try{let t=Ci(e.path);if(!t.isFile()||t.dev!==e.device||t.ino!==e.inode||t.size!==e.content.byteLength)return;let n;try{n=ae(e.path,{maxBytes:e.content.byteLength,inputKind:"temporary TypeScript index configuration"})}catch{return}if(!n.equals(e.content))return;_e(e.path)}catch(t){if(t.code!=="ENOENT")throw t}}function qi(e,t,n){if(!e.defaultOutputPath)return;let r=mt(t,e.defaultOutputPath);n!==r&&we(r)&&ft(r,n)}function Ji(e,t,n){if(!e.defaultOutputPath)return null;let r=mt(t,e.defaultOutputPath);if(r===n)return null;let a=`${n}.default-output-backup`;return _e(a,{force:!0}),we(r)?(ft(r,a),{defaultOutputPath:r,backupPath:a}):{defaultOutputPath:r,backupPath:null}}function Hi(e){e&&(_e(e.defaultOutputPath,{force:!0}),e.backupPath&&we(e.backupPath)&&ft(e.backupPath,e.defaultOutputPath))}function zi(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,Ui().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Ir(e,t,n,r,a){j(a,"Reindex cancelled by its owner.");let i=e.filter(d=>d.config.defaultOutputPath),o=e.filter(d=>!d.config.defaultOutputPath),s=[],c=zi(o.length,r),l=await Mn(o,c,d=>gt(d,t,n,a));if(c>1){let d=new Map;for(let u of l.filter(p=>p.result.skipped&&p.retryable)){let p=o.find(m=>m.id===u.result.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),j(a,"Reindex cancelled by its owner."),d.set(p.id,(await gt(p,t,n,a)).result))}s.push(...l.map(({result:u})=>d.get(u.id)??u))}else s.push(...l.map(({result:d})=>d));for(let d of i)j(a,"Reindex cancelled by its owner."),s.push((await gt(d,t,n,a)).result);return s.sort((d,u)=>e.findIndex(p=>p.id===d.id)-e.findIndex(p=>p.id===u.id))}async function gt(e,t,n,r){j(r,"Reindex cancelled by its owner."),n(`Indexing ${e.label} with ${e.resolvedBinary}...`),_e(e.scipPath,{force:!0});let a=Ji(e.config,t,e.scipPath),i=Bi(e,t),o=[e.binary,...e.args].join(" "),s=P();try{e.trustedProjectTool&&Ht(t,e.trustedProjectTool);let l=At(e.binary,e.args),d=await ce({command:l.binary,args:l.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Xi(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024,signal:r});if(d.status!==0){let u=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${u?`:
|
|
230
|
+
${u}`:""}`)}qi(e.config,t,e.scipPath)}catch(l){if(r?.aborted)throw Ct(r,"Reindex cancelled by its owner.");let d=l instanceof Error?l.message:String(l),u=`${e.resolvedBinary} indexer failed: ${d.split(`
|
|
231
|
+
`)[0]}`,p=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-s,command:o,skipped:{language:e.language,reason:p}},retryable:Qi(l)}}finally{Hi(a),Wi(i)}if(!we(e.scipPath)){let l=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?l:`${e.label}: ${l}`;return n(`Skipping ${e.label}: ${l}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-s,command:o,skipped:{language:e.language,reason:d}},retryable:!1}}let c;try{c=$i(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:P()-s,command:o,outputBytes:c},retryable:!1}}function Xi(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):Et.indexer}function Qi(e){return e instanceof wt?e.kind==="spawn"&&vr(e.cause):vr(e)}function vr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as wr}from"child_process";import{homedir as Er,platform as Vi}from"os";import{delimiter as Yi,join as je}from"path";function _r(e,t){let n=e.installMethods,r=pe(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(!Ot(a.prerequisite))continue;let i=Ki(a);t(`Installing immutable ${a.identity} via ${a.label} into ${i}; expected executable: ${r}.`);try{wr(a.binary,a.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Vi()==="win32"});let o=Z(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 Ki(e){if(e.binary==="npm")return ht("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=ht("go",["env","GOBIN"]);if(t)return t;let n=ht("go",["env","GOPATH"]);if(n)return je(n.split(Yi)[0],"bin")}return e.binary==="dotnet"?je(process.env.DOTNET_CLI_HOME??Er(),".dotnet","tools"):e.binary==="dart"?je(process.env.PUB_CACHE??je(Er(),".pub-cache"),"bin"):e.destination}function ht(e,t){try{return wr(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Nr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,a=e.skipAutoInstall===!0||e.installMissing!==!0,i=oo(e),o=Date.now(),s=P();Fe(h(i.outputScip),{recursive:!0}),Fe(h(i.outputDb),{recursive:!0});let c=e.languages??cn(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let l=ke(i.metaPath),d=D("reindex.fingerprint",()=>Bt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath},l,e.changeJournal,Be(i.outputDb)),{languages:c.length}),u=d.fingerprint,p=d.mode==="delta"?e.changeJournal?.entries.filter(f=>f.kind!=="add").length??0:0,m=Math.max(0,(l?.files.length??0)-p);r(d.mode==="delta"?`Project fingerprint revalidated ${d.changedPaths.length} changed path(s), reused ${m} accepted file fingerprint(s), and accepted ${u.files.length} input(s)`:`Project fingerprint used full scan: ${d.reason}`);let g,y;if(e.skipIfUnchanged!==!1&&!Pn(t,i.outputDb)&&jr(i.outputScip)===jr(E(h(i.outputDb),"index.scip"))){let f=ue(t);if(g=f?.clean?he(f,u):void 0,f&&!f.clean&&!io(i)){let R=xn(f,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath});if(R)try{ye({snapshot:R.snapshot,manifest:R.manifest,targetCacheDir:h(i.outputDb),targetProjectRoot:t,persistLease:!1}),En(R.snapshot,h(i.outputDb)),r(`Forked shared baseline ${R.snapshot.generationId.slice(0,12)} for dirty worktree reindex`)}catch(v){r(`Shared baseline fork failed; continuing locally: ${q(v)}`)}}else if(g){let R=He(g);if(R){if(!ao(i,u))try{ye({snapshot:g,manifest:R,targetCacheDir:h(i.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${g.generationId.slice(0,12)}`)}catch(v){r(`Shared generation attach failed; continuing locally: ${q(v)}`)}}else{let v=await vn(g);if(v.kind==="owner")y=v.release;else if(v.kind==="generation-ready"){let $=He(g);if($)try{ye({snapshot:g,manifest:$,targetCacheDir:h(i.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${g.generationId.slice(0,12)} after waiting`)}catch(M){r(`Shared generation attach failed after waiting; continuing locally: ${q(M)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let F=Gt(E(h(i.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!F)throw y?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${h(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 _;try{_=await U("reindex.lock",()=>Mo(E(h(i.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(f){throw F.release(),y?.(),f}let b=null,x=$n();try{d.mode==="delta"&&Be(i.outputDb)!==e.changeJournal?.baseGeneration&&(u=Ue(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),d={mode:"full",fingerprint:u,reason:"accepted-generation-changed-before-lock"},g=void 0,y?.(),y=void 0,r("Project fingerprint used full scan: accepted-generation-changed-before-lock")),bn(i.outputDb,i.outputScip,i.metaPath);let f=uo(h(i.outputDb));f.removed>0&&r(`Removed ${f.removed} abandoned reindex workspace(s)`);for(let re of f.errors)r(`Could not remove abandoned reindex workspace: ${re}`);let R=null,v=D("reindex.reuse-check",()=>(R=so({opts:e,paths:i,languages:c,fingerprint:u,start:o,monotonicStart:s,onStatus:r}),R),()=>({languages:c.length,reused:R!==null}));if(v){Tr({snapshot:g,paths:i,projectRoot:t,fingerprint:u,onStatus:r});let re=qe(i.outputDb,v);return re.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${re.reason}`),Ne(t,h(i.outputDb)),v}await U("reindex.scip-cli-ready",()=>_o(a,r));let $=lo(i);b=$.runDir;let M,S=await U("reindex.fresh",async()=>(M=await po({opts:e,languages:c,projectRoot:t,paths:i,tempPaths:$,fingerprint:u,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:a,onStatus:r,writeTelemetry:x}),M),()=>({languages:c.length,reused:M?.reused,skipped:M?.skipped.length}));Tr({snapshot:g,paths:i,projectRoot:t,fingerprint:u,onStatus:r});let A=qe(i.outputDb,S);return A.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${A.reason}`),Ne(t,h(i.outputDb)),S}catch(f){let R=Ae({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:f instanceof Error?f.message:String(f)});Zr(i.metaPath,R);let v=pn(i.outputDb,R);throw v.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${v.reason}`),f}finally{b&&Q(b,{recursive:!0,force:!0}),_(),F.release(),y?.()}}function Tr(e){if(e.snapshot)try{let t=ue(e.projectRoot),n=t?he(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=Rn({snapshot:e.snapshot,sourceCacheDir:h(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let a=ue(e.projectRoot);return(a?he(a,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});In(e.snapshot,h(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: ${q(t)}`)}}function ao(e,t){if(!w(e.outputScip)||!w(e.outputDb)||!Kr(e.metaPath,t))return!1;let n=C(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function io(e){if(!w(e.outputScip)||!w(e.outputDb)||!J(e.metaPath))return!1;let t=C(e.outputDb,e.metaPath);return t.state!=="invalid"&&t.state!=="drifted"}function q(e){return e instanceof Error?e.message:String(e)}function bt(e,t,n,r,a,i){try{ee(Gn({indexPath:n,reuseExisting:a,affectedFiles:i}),{projectRoot:e,dbPath:t,onStatus:r})}catch(o){r(`Runtime-boundary extraction unavailable: ${o instanceof Error?o.message:String(o)}.`)}}function oo(e){let t=e.outputScip??E(e.projectRoot,"index.scip"),n=e.outputDb??E(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:E(h(n),"meta.json")}}function so(e){let t=C(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!w(e.paths.outputScip)||!w(e.paths.outputDb)||!Kr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;let n=me(e.paths.outputDb,e.fingerprint,e.languages);if(n.state!=="complete")return e.onStatus(Pt("Accepted SQLite index",n)),null;ee(fe(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),bt(e.opts.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0),C(e.paths.outputDb,e.paths.metaPath).state==="drifted"&&(Je(e.paths.outputDb,e.paths.metaPath),e.onStatus("Published refreshed SQLite generation after post-index augmentation"));let r=P()-e.monotonicStart,a=Ae({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Zr(e.paths.metaPath,a),e.onStatus(`Index unchanged; reused existing SQLite index in ${(r/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:r,reused:!0,skipped:[],lastRefresh:a,shards:co(e.paths,e.languages,e.opts,e.fingerprint)}}function co(e,t,n,r){let a=Vr(r,t,n);return t.map(i=>({id:i,language:i,reused:!0,strategy:"reused",fingerprint:ne(a[i]),outputBytes:V(xt(e.outputDb,i)),durationMs:0}))}function lo(e){let t=eo(E(h(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:E(t,Te(e.outputScip)),tempOutputDb:E(t,Te(e.outputDb)),tempMetaPath:E(t,Te(e.metaPath))}}function uo(e){let t=[],n;try{n=Lr(e,{withFileTypes:!0})}catch(a){return{removed:0,errors:[q(a)]}}let r=0;for(let a of n)if(!(!a.name.startsWith("reindex-")||!a.isDirectory()))try{Q(E(e,a.name),{recursive:!0,force:!0}),r+=1}catch(i){t.push(`${a.name}: ${q(i)}`)}return{removed:r,errors:t}}async function po(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await U("reindex.language-indexers",async()=>(n=await fo(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:l,incrementalTypeScript:d}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),go({run:e,indexedOutputs:a,skippedLanguages:i,reusedLanguages:o})){let m=D("reindex.publish",()=>vo(e,a,i,o,s,l),{mode:"metadata-only",languages:a.length,reused:o.length}),g=m.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:a.map(y=>y.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:i,lastRefresh:m,shards:c,writeTelemetry:e.writeTelemetry}}let u=await U("reindex.publish",()=>Ro(e,t,a,i,o,s,l,d),{mode:d?"incremental-or-fallback":"full",languages:a.length,reused:o.length,skipped:i.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:a.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:i,lastRefresh:u,shards:c,writeTelemetry:e.writeTelemetry}}function go(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!w(e.run.paths.outputScip)||!w(e.run.paths.outputDb))return!1;let t=C(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 fo(e,t){let n=bo({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}),r=[],a=new Set;for(let[S,A]of n)A.reused&&(r.push({language:S,scipPath:A.scipPath}),a.add(S));for(let S of a)e.onStatus(`Reusing cached ${S} SCIP shard (language inputs unchanged).`);let i=n.get("typescript"),o=C(e.paths.outputDb,e.paths.metaPath),s=J(e.paths.metaPath),c=o.state==="legacy"||o.state==="current",l=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),d,u=i&&!i.reused&&c?Rr({projectRoot:e.projectRoot,cacheDir:h(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:i.scipPath,candidateShardPath:Y(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Y(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:l,previousSnapshot:ke(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus,onUnavailable:S=>{d=S}}):null,p=new Set(u?["typescript"]:[]);if(e.opts.allowExpensiveRebuild===!1)for(let S of e.languages){if(a.has(S)||p.has(S))continue;let A=n.get(S);A&&w(A.scipPath)&&(r.push({language:S,scipPath:A.scipPath}),a.add(S),e.onStatus(`Skipping expensive ${S} full rebuild because the watch full-rebuild budget is exhausted.`))}let m=u||a.has("typescript")?void 0:mo(e,n),{preparedRuns:g,skippedLanguages:y,languageOutputScipPaths:O}=jo({languages:e.languages.filter(S=>!a.has(S)&&!p.has(S)),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:m?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),F=m?g.filter(S=>S.language!=="typescript"||m.missedProjectIds.has(S.id)):g,_=await Ir(F,e.projectRoot,e.onStatus,e.opts.indexerConcurrency,e.opts.signal);if(Dt())for(let S of _)kt({type:"span",name:`reindex.language-indexer.${S.id}`,durationMs:Math.round(S.durationMs),ok:!S.skipped,language:S.language,indexerCommand:S.command,outputBytes:S.outputBytes,measurement:"indexer-run-result"});let b=[];if(m){yo(e.paths.outputDb,_,e.writeTelemetry);let S=O.typescript??e.tempPaths.tempOutputScip;b=So({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:S,reusedProjects:m.reusedProjects,writeTelemetry:e.writeTelemetry})}let x=[..._,...b],{indexedOutputs:f}=Fo(x,y),R=u?[{language:"typescript",scipPath:u.scipPath}]:[],v=[...r,...R,...f];Do(v,y,e.languages,e.opts.allowPartial,e.onStatus);let $=u?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:u.scipPath,outputScipPath:u.scipPath,durationMs:u.durationMs,command:"watch-service:typescript-index",outputBytes:V(u.scipPath)??void 0,producedOutputBytes:V(u.affectedScipPath)??void 0}]:[],M=Po(n,[..._,...$],m?{outputDb:e.paths.outputDb,classification:m.classification}:void 0,d);return{indexedOutputs:v,skippedLanguages:y,reusedLanguages:[...a],languageFingerprints:xo(n,e.languages),shards:M,typescriptProjectShardContext:m?{projects:m.allProjects,fingerprints:m.fingerprints}:void 0,incrementalTypeScript:u??void 0}}function mo(e,t){let n=t.get("typescript");if(!n||n.reused||n.cacheIntegrityFailed||e.opts.typescriptProjectMode!=="workspace")return;let r=z(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let a=pr(e.projectRoot,r),i=dr(n.fingerprint.files,r),o=lr(r,a),s=ur(r,i,o),c=J(e.paths.metaPath),d=ho(c,s,g=>w(Oe(e.paths.outputDb,g))),u=[...d.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),m=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:d,reusedProjects:u,missedProjectIds:m}}function ho(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===K&&Le(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(T(o)!==T(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 yo(e,t,n){for(let r of t){if(r.skipped||!r.id.startsWith("typescript:"))continue;let a=r.id.slice(11),i=Oe(e,a);Fe(h(i),{recursive:!0}),W(n,B(r.scipPath,i))}}function So(e){return e.reusedProjects.map((t,n)=>{let r=Oe(e.outputDb,t),a=Y(e.tempOutputScip,"typescript-project-cached",n);return W(e.writeTelemetry,B(r,a)),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:a,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:V(a)??void 0}})}function bo(e){let t=J(e.paths.metaPath),n=Vr(e.projectFingerprint,e.languages,e),r=t&&w(e.paths.outputDb)?me(e.paths.outputDb,e.projectFingerprint,e.languages):null,a=new Map;for(let i of e.languages){let o=xt(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!==K){a.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:o});continue}if(!Le(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(!w(o)){a.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:o});continue}if(T(c)!==T(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:Pt("accepted SQLite index",r),cacheIntegrityFailed:!0,fingerprint:s,scipPath:o});continue}a.set(i,{reused:!0,fingerprint:s,scipPath:o})}return a}function Po(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:ne(o.fingerprint),outputBytes:V(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?ne(c.fingerprint):o?ne(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:ne(o.fingerprint),outputBytes:V(Oe(n.outputDb,i)),durationMs:0});return a}function ne(e){return Zi("sha256").update(T(e)).digest("hex").slice(0,16)}function V(e){try{return to(e).size}catch{return null}}function xo(e,t){let n={};for(let r of t){let a=e.get(r);a&&(n[r]=a.fingerprint)}return n}async function Ro(e,t,n,r,a,i,o,s){j(e.opts.signal,"Reindex cancelled by its owner.");let c=!s||s.completeScipUpdated,l=!1;c&&(l=D("reindex.publish.scip-output",()=>{let b=wo({run:e,indexedOutputs:n,incrementalTypeScript:s});return Fr(e.paths.outputDb,b,e.writeTelemetry),Dr(b,e.tempPaths.tempOutputScip,e.onStatus)}));let d=await U("reindex.publish.sqlite-output",()=>ko({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:l,materializeFullFallback:async()=>{if(j(e.opts.signal,"Reindex cancelled by its owner."),!s||s.completeScipUpdated)return l;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),ut({cacheDir:h(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let b=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:s.candidateScipPath}:x);return Fr(e.paths.outputDb,b,e.writeTelemetry),l=Dr(b,e.tempPaths.tempOutputScip,e.onStatus),l}}));j(e.opts.signal,"Reindex cancelled by its owner."),D("reindex.publish.auxiliary-documents",()=>{ee(fe(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus})}),D("reindex.publish.runtime-boundaries",()=>bt(e.projectRoot,e.tempPaths.tempOutputDb,e.tempPaths.tempOutputScip,e.onStatus,!1,s?.affectedFiles));let u=D("reindex.publish.sqlite-layout",()=>rt(e.tempPaths.tempOutputDb));if(u.added.length>0&&e.onStatus(`Added SQLite query indexes: ${u.added.join(", ")}`),u.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${u.removed.join(", ")}`),Br(e,e.tempPaths.tempOutputDb,n.map(b=>b.language)),d.mode==="incremental"&&s){let b=null,x=null;try{b=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let f=en(b,e.fingerprint,s.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${f} affected document(s).`)}catch(f){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${f instanceof Error?f.message:String(f)}.`)}finally{b?.close(),x?.close()}}let p=ke(e.paths.metaPath),m=d.mode==="incremental"&&s?Ao(s,d.changedDocumentPaths):Ze({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),g=Ae({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(b=>b.language),skipped:[...r]}),y=d.mode==="incremental"&&d.scipCompanion==="deferred",{metadata:O,pruneProjects:F}=Gr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:a,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:g});O.scipCompanion=y?"deferred":"current",Ur(e),Wr(e.paths.outputDb,F),Rt(e.tempPaths.tempMetaPath,O);let _=Sn({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:d.mode==="incremental"&&d.scipCompanion==="deferred",publication:d.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:d.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:d.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:d.patchDurationMs,scipCompanion:d.scipCompanion,...d.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:d.converterDurationMs,scipCompanion:"current",...d.fallbackReason?{fallbackReason:d.fallbackReason}:{}}});if(_.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${_.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),d.mode==="incremental"&&s){let b=null;try{b=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let x=Kt(b,s.dependencyGraphSnapshot,s.affectedFiles);e.onStatus(x?`Carried the dependency graph forward by replacing ${s.affectedFiles.length} affected document(s).`:"Dependency graph carry-forward was ineligible; the next graph consumer will rebuild it.")}catch(x){e.onStatus(`Dependency graph carry-forward unavailable: ${x instanceof Error?x.message:String(x)}. The next graph consumer will rebuild it.`)}finally{b?.close()}}return yn(h(e.paths.outputDb),d.mode==="incremental"&&d.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),fn(h(e.paths.outputDb),s?.completeScipUpdated?[s.nextFragmentGeneration]:[]),$r(e.paths.outputDb,m,e.onStatus),g}function vo(e,t,n,r,a,i){let o=ke(e.paths.metaPath),s=null;try{W(e.writeTelemetry,B(e.paths.outputDb,e.tempPaths.tempOutputDb))}catch(p){s=qn("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}ee(fe(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),bt(e.projectRoot,e.paths.outputDb,e.paths.outputScip,e.onStatus,!0);let c=rt(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(", ")}`),Br(e,e.paths.outputDb,t.map(p=>p.language)),s??=Ze({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 l=Ae({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:d,pruneProjects:u}=Gr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:a,typescriptProjectShardContext:i,lastRefresh:l});return Ur(e),Wr(e.paths.outputDb,u),Rt(e.paths.metaPath,d),Je(e.paths.outputDb,e.paths.metaPath),$r(e.paths.outputDb,s,e.onStatus),l}function ke(e){return Tt(J(e)?.fingerprint)}function $r(e,t,n){try{Jn(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 Gr(e){let t=Io({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:K,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 Ur(e){j(e.opts.signal,"Reindex cancelled by its owner.");let t=Ue(e.projectRoot,e.languages,{pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath});if(T(t)!==T(e.fingerprint))throw new Error("Project inputs changed during reindex; refusing to publish artifacts built from a different filesystem snapshot.")}function Br(e,t,n){let r=me(t,e.fingerprint,n);if(r.state!=="complete")throw new Error(`${Pt("Candidate SQLite index",r)} Refusing to publish it.`)}function Pt(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 Io(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=J(e.metaPath),n=t?.version===K?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 Wr(e,t){let n=Yr(e);if(t===null){Q(n,{recursive:!0,force:!0});return}let r;try{r=Lr(n)}catch{return}for(let a of Eo(r,t))Q(E(n,a),{force:!0})}function Eo(e,t){let n=new Set(t.map(r=>`${st(r)}.scip`));return e.filter(r=>!n.has(r))}function wo(e){if(e.incrementalTypeScript?.completeScipUpdated)return[...e.indexedOutputs];let t=e.indexedOutputs.find(o=>o.language==="typescript");if(!t)return[...e.indexedOutputs];let n=C(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":J(e.run.paths.metaPath)?.scipCompanion==="deferred")||!r)return[...e.indexedOutputs];let i=Y(e.run.tempPaths.tempOutputScip,"typescript-deferred",0);return e.run.onStatus("Materializing the deferred whole TypeScript SCIP companion for complete publication..."),ut({cacheDir:h(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 Fr(e,t,n){for(let r of t){let a=xt(e,r.language);Fe(h(a),{recursive:!0}),r.scipPath!==a&&W(n,B(r.scipPath,a))}}async function _o(e,t){if(!$e()){if(ro()==="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.
|
|
250
232
|
To install the reviewed version, run: scip-query reindex --install-missing
|
|
251
|
-
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!
|
|
252
|
-
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function
|
|
233
|
+
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!Mt(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
234
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function jo(e){let t=[],n=[],r=e.languages.map((i,o)=>({language:i,scipPath:e.languages.length>1?Y(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=To({...e,language:i,scipPath:o});for(let c of s)"skipped"in c?qr(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:a}}function To(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[yt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??z(e.projectRoot,e.typescriptProjects);return t.length===0?[yt({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>yt({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:Y(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function yt(e){let t=et(e.language),n=pe(t),r=qt(t,e.projectRoot),a=e.trustProjectTools&&r?Jt(t,e.projectRoot):null,i=Z(t);if(!a&&!i&&r){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}if(!a&&!i&&!Wt(t)){if(e.skipAutoInstall){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!_r(t,e.onStatus)){let d=`${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}: ${d}`),{skipped:{language:e.language,reason:d}}}}let o=a?.canonicalPath??Z(t);if(!o){let d=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${d}`),{skipped:{language:e.language,reason:d}}}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}),l=Kn({language:e.language,projectPath:e.projectPath,pnpmWorkspaces:e.pnpmWorkspaces});if(a&&!a.executable){let d=`${a.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${d}`),{skipped:{language:e.language,reason:d}}}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:zt(t,e.env,o),...l===void 0?{}:{temporaryRootConfigContent:l},...a?{trustedProjectTool:a}:{}}}}function Fo(e,t){let n=new Map;for(let a of e)if(a.skipped)qr(t,a.skipped);else{let i=`${a.language}\0${a.outputScipPath}`,o=n.get(i)??{language:a.language,outputScipPath:a.outputScipPath,scipPaths:[]};o.scipPaths.push(a.scipPath),n.set(i,o)}let r=[];for(let a of n.values())if(a.scipPaths.length>1)ln(a.scipPaths,a.outputScipPath),r.push({language:a.language,scipPath:a.outputScipPath});else{let i=a.scipPaths[0];i!==a.outputScipPath&&Cr(i,a.outputScipPath),r.push({language:a.language,scipPath:a.outputScipPath})}return{indexedOutputs:r}}function qr(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 Do(e,t,n,r,a){if(e.length===0){let i=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
253
235
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
254
|
-
`+
|
|
255
|
-
`+t.map(
|
|
256
|
-
`))}function Dr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Xt(e.map(a=>a.scipPath),t);return Wr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Nr(e[0].scipPath,t);return!1}function Xo(e){let t;if(Qo(e)){let i=R(e.run.tempPaths.runDir,"typescript-affected.db");try{qr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();kr(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let o=er({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),B(i,{force:!0}),B(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=e.materializeFullFallback());let r=performance.now();return kr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Qo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!j(e.run.paths.outputDb)||!j(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 Vo(e,t){let n=b(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!i.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:b()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:ze(e.plan,a,e.projectFileCount)}}function kr(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!j(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||qr(e,r);let a=Le();if(!a)throw new Error("scip CLI is not available");yo(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(a){let o=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:a})}}function qr(e,t){let n=Jt(e);Wr(n,t)}function Wr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function ee(e,t,n){let r=xo(e)||".scip",i=Ee(e,r);return R(y(e),`${i}.${n+1}.${t}${r}`)}async function Yo(e,t){for(let n=0;n<2;n++){let r=Ko(e,t);if(r)return r;let i=Zo(e);if(i&&zr(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await ts(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${U(s)}`,{cause:s})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${y(e)}; refusing to steal an active lock.`);let o=Ne(e,{parseLegacy:Fe});if(!_t(e,o,{parseLegacy:Fe}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${y(e)}.`)}function Ko(e,t){let n=A(process.pid),r=Et(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:Fe});if(r.kind==="acquired"&&r.reclaimed){let i=Hr(r.reclaimed,e);i&&zr(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Zo(e){return Hr(Ne(e,{parseLegacy:Fe}),e)}var Fe=e=>{let t=Jr(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Hr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Jr(e.parsed,t)}function Jr(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=It(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function zr(e,t){return e?.kind==="manual-cli"&&es(t?.trigger)}function es(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function ts(e){return!L(e.pid)||(pt(e),Mr(e,"SIGTERM"),await Or(e,2e3))?!0:(pt(e),Mr(e,"SIGKILL"),Or(e,1e3))}function Mr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!L(e.pid))return;pt(e)}try{process.kill(e.pid,t)}catch{}}async function Or(e,t){let n=b()+t;for(;b()<n;){if(Ar(e))return!0;await ns(50)}return Ar(e)}function pt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=A(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!J(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Ar(e){if(!L(e.pid))return!0;if(!e.processIdentity)return!1;let t=A(e.pid);return t!==null&&!J(e.processIdentity,t)}function ns(e){return new Promise(t=>setTimeout(t,e))}function Xr(e,t,n){return Object.fromEntries(t.map(r=>{let i=Qe(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:jt(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},o=r==="clojure"?rs(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&is(n),...a,clojureConfigPath:o,files:Dt(e,{language:r,markerFiles:i})}]}))}function rs(e){return e?.trim()||void 0}function is(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ft(e,t){return R(y(e),"language-indexes",`${t}.scip`)}function Qr(e){return R(y(e),"language-indexes","typescript-projects")}function Te(e,t){return R(Qr(e),`${nt(t)}.scip`)}function te(e){try{return Me(ae(D(e,"reindex metadata")))}catch{return null}}function Vr(e,t){try{let n=ae(D(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&bt(r)&&w(r.fingerprint)===w(t)&&w([...r.indexedLanguages??[]].sort())===w(t.languages)}catch{return!1}}function mt(e,t){Ot(e,t,{spacing:2,trailingNewline:!0})}function Yr(e,t){try{let n=Me(ae(D(e,"reindex metadata")));if(!n)return;mt(e,{...n,lastRefresh:t})}catch{}}function we(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:b()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function w(e){return JSON.stringify(e)}var ti=process.env.SCIP_REINDEX_PROJECT_ROOT,ni=process.env.SCIP_REINDEX_OUTPUT_SCIP,ri=process.env.SCIP_REINDEX_OUTPUT_DB,Kr=process.env.SCIP_REINDEX_LANGUAGES,as=In(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),os=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",Zr=us(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),ss=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,cs=ls(process.env.SCIP_REINDEX_TRIGGER_KIND),ds=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!ti||!ni||!ri)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ei=Kr?Kr.split(",").filter(Boolean):void 0;Cr({projectRoot:ti,outputScip:ni,outputDb:ri,languages:ei?.length?ei:void 0,pnpmWorkspaces:os,typescriptProjectMode:Zr.projectMode,typescriptProjects:Zr.projects,clojureConfigPath:ss,indexerConcurrency:as,trigger:{kind:cs,detail:ds||void 0},onStatus:e=>process.stderr.write(`[reindex] ${qe(e)}
|
|
257
|
-
`)})
|
|
236
|
+
`+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.
|
|
237
|
+
`+t.map(i=>` - ${i.language}: ${i.reason}`).join(`
|
|
238
|
+
`))}function Dr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),a=un(e.map(i=>i.scipPath),t);return Hr(a,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Cr(e[0].scipPath,t);return!1}async function ko(e){let t;if(Oo(e)){let a=E(e.run.tempPaths.runDir,"typescript-affected.db");try{Jr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let i=performance.now();await kr(e.incrementalTypeScript.affectedScipPath,a,e.env,e.run.onStatus,!0,e.run.opts.signal),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-i).toFixed(0)}ms.`);let o=ar({previousDbPath:e.run.paths.outputDb,miniDbPath:a,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles,writeTelemetry:e.run.writeTelemetry});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-i,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(i){j(e.run.opts.signal,"Reindex cancelled by its owner."),t=i instanceof Error?i.message:String(i),Q(a,{force:!0}),Q(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=await e.materializeFullFallback());let r=performance.now();return await kr(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 Oo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!w(e.run.paths.outputDb)||!w(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 Ao(e,t){let n=P(),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:P()-n,manifest:e.manifest,plan:e.plan,comparison:i,evaluation:Ke(e.plan,i,e.projectFileCount)}}async function kr(e,t,n,r,a=!1,i){if(j(i,"Reindex cancelled by its owner."),r("Converting to SQLite..."),!w(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{a||Jr(e,r);let o=$e();if(!o)throw new Error("scip CLI is not available");let s=await ce({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()}`:""}`)}catch(o){j(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 Jr(e,t){let n=dn(e);Hr(n,t)}function Hr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Y(e,t,n){let r=no(e)||".scip",a=Te(e,r);return E(h(e),`${a}.${n+1}.${t}${r}`)}async function Mo(e,t){for(let n=0;n<2;n++){let r=Lo(e,t);if(r)return r;let a=Co(e);if(a&&Qr(t.trigger,a)){t.onStatus(`Manual reindex preempting watcher refresh started at ${a.startedAt}.`);let i;try{i=await $o(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: ${q(s)}`,{cause:s})}if(!i)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${a.pid}) terminated for ${h(e)}; refusing to steal an active lock.`);let o=Ge(e,{parseLegacy:De});if(!$t(e,o,{parseLegacy:De}))throw new Error(`Reindex lock ownership changed before preemption completed for ${h(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${h(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${h(e)}.`)}function Lo(e,t){let n=L(process.pid),r=Nt(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:De});if(r.kind==="acquired"&&r.reclaimed){let a=zr(r.reclaimed,e);a&&Qr(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 ${h(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Co(e){return zr(Ge(e,{parseLegacy:De}),e)}var De=e=>{let t=Xr(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function zr(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:h(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Xr(e.parsed,t)}function Xr(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=se(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:h(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Qr(e,t){return e?.kind==="manual-cli"&&No(t?.trigger)}function No(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function $o(e){return!H(e.pid)||(St(e),Or(e,"SIGTERM"),await Ar(e,2e3))?!0:(St(e),Or(e,"SIGKILL"),Ar(e,1e3))}function Or(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!H(e.pid))return;St(e)}try{process.kill(e.pid,t)}catch{}}async function Ar(e,t){let n=P()+t;for(;P()<n;){if(Mr(e))return!0;await Go(50)}return Mr(e)}function St(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=L(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!G(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Mr(e){if(!H(e.pid))return!0;if(!e.processIdentity)return!1;let t=L(e.pid);return t!==null&&!G(e.processIdentity,t)}function Go(e){return new Promise(t=>setTimeout(t,e))}function Vr(e,t,n){return Object.fromEntries(t.map(r=>{let a=r==="typescript"?Ut(n.typescriptProjects):[],i=r==="clojure"?Uo(n.clojureConfigPath):void 0,o=[...et(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"&&Bo(n),...s,clojureConfigPath:i,files:e.files.filter(c=>jt(c.path,r,o))}]}))}function Uo(e){return e?.trim()||void 0}function Bo(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function xt(e,t){return E(h(e),"language-indexes",`${t}.scip`)}function Yr(e){return E(h(e),"language-indexes","typescript-projects")}function Oe(e,t){return E(Yr(e),`${st(t)}.scip`)}function J(e){try{return Me(le(oe(e,"reindex metadata")))}catch{return null}}function Kr(e,t){try{let n=le(oe(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&Ft(r)&&T(r.fingerprint)===T(t)&&T([...r.indexedLanguages??[]].sort())===T(t.languages)}catch{return!1}}function Rt(e,t){Qt(e,t,{spacing:2,trailingNewline:!0})}function Zr(e,t){try{let n=Me(le(oe(e,"reindex metadata")));if(!n)return;Rt(e,{...n,lastRefresh:t})}catch{}}function Ae(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:P()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function T(e){return JSON.stringify(e)}var Wo={readIdentity:L,setInterval(e,t){let n=setInterval(e,t);return n.unref(),n},clearInterval};function ea(e,t,n={}){let r=n.runtime??Wo,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&&G(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 aa=process.env.SCIP_REINDEX_PROJECT_ROOT,ia=process.env.SCIP_REINDEX_OUTPUT_SCIP,oa=process.env.SCIP_REINDEX_OUTPUT_DB,ta=process.env.SCIP_REINDEX_LANGUAGES,qo=Ln(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),Jo=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",na=is(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Ho=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,zo=as(process.env.SCIP_REINDEX_TRIGGER_KIND),Xo=process.env.SCIP_REINDEX_TRIGGER_DETAIL,Qo=Cn(process.env.SCIP_REINDEX_CHANGE_JOURNAL),Vo=process.env.SCIP_REINDEX_ALLOW_EXPENSIVE!=="0",sa=rs(process.env.SCIP_REINDEX_PARENT_IDENTITY);(!aa||!ia||!oa||!sa)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var Yo=aa,Ko=ia,Zo=oa,es=sa,ra=ta?ta.split(",").filter(Boolean):void 0,ca=new AbortController,ts=ea(es,e=>{ca.abort(new Error(`Reindex worker owner lost: ${e}`))});ns();async function ns(){try{await Nr({projectRoot:Yo,outputScip:Ko,outputDb:Zo,languages:ra?.length?ra:void 0,pnpmWorkspaces:Jo,typescriptProjectMode:na.projectMode,typescriptProjects:na.projects,clojureConfigPath:Ho,indexerConcurrency:qo,trigger:{kind:zo,detail:Xo||void 0},changeJournal:Qo,allowExpensiveRebuild:Vo,signal:ca.signal,onStatus:e=>process.stderr.write(`[reindex] ${Qe(e)}
|
|
239
|
+
`)})}catch(e){console.error(`reindex-worker error: ${Qe(String(e))}`),process.exitCode=1}finally{ts.stop()}}function rs(e){if(!e)return null;try{return se(JSON.parse(e))}catch{return null}}function as(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 is(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(i=>typeof i=="string"&&i.trim()!==""):void 0;return{projectMode:r,projects:a&&a.length>0?a:void 0}}catch{return{}}}
|
|
258
240
|
//# sourceMappingURL=reindex-worker.js.map
|