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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-P5XHIJHI.js";import{c as ie}from"./chunk-SMNXQT5Z.js";import"./chunk-IZYYAFN5.js";import{A as ee,B as ne,C as te,D as re,F as se,a as E,c as z,d as M,e as B,f as Y,l as q,n as J,r as Q,s as X,t as x,u as T,v as U,w as G,x as L,y as Z}from"./chunk-AIE7TFJW.js";import{a as $,g as H}from"./chunk-HGFDYOVB.js";import{a as D,d as k}from"./chunk-MNE7YG56.js";import{b as P,g as N}from"./chunk-46XGSFNI.js";import m from"process";import{randomUUID as Fe}from"crypto";import{rmSync as Ke}from"fs";import{resolve as _}from"path";import{pathToFileURL as je}from"url";import{spawn as Ee}from"child_process";import{createHash as we,randomUUID as ke}from"crypto";import{existsSync as Ae,realpathSync as Sn,rmSync as In}from"fs";import{tmpdir as Mn}from"os";import{resolve as hn}from"path";import{createHash as Se}from"crypto";import{resolve as Ie}from"path";var y=3;function v(e){return Se("sha256").update(x({kind:"scip-query-durable-rust-mailbox",protocolVersion:y,sessionDir:Ie(e)})).digest("hex")}function F(e,n){if(!E(e)||typeof e.id!="string"||!e.id)return A("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return A("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return A("Durable Rust semantic helper received a partially versioned request without a protocol version.");let o=oe(e.request);if(!o)return A("Durable Rust semantic helper received an invalid legacy request kind or payload.");let c=n.nowMs+Math.max(1,o.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:T,protocolVersion:y,id:e.id,operationKey:L("rust-semantic-v2",{id:e.id,request:o}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:c,sessionIdentity:n.sessionIdentity,request:o}}}let t=ge(e,n);if(!t.ok)return t;if(e.protocolVersion!==y)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let l=oe(e.request);return l?t.operationKey!==L("rust-semantic-v3",l)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==l.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:T,protocolVersion:y,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:l}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function ge(e,n){if(e.mailboxVersion!==T||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!ae(e.operationKey)||e.id!==Z(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!ae(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==y)return A("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function oe(e){return!E(e)||typeof e.identityKey!="string"||!e.identityKey||!B(e.timeoutMs)||e.workerEnvironment!==void 0&&!z(e.workerEnvironment)?null:e.kind==="semantic"&&Me(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&De(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function Me(e){return!E(e)||!w(e.projectRoot)||!w(e.rustAnalyzerBinary)||!le(e.definitions)?!1:O(e.referenceDefinitions)&&O(e.calleeDefinitions)&&O(e.signatureDefinitions)&&I(e.requestTimeoutMs)&&I(e.readinessDeadlineMs)&&I(e.referenceRetryTimeoutMs)&&I(e.diagnosticsTimeoutMs)&&I(e.settleDelayMs)&&de(e.concurrency)&&W(e.includeReferences)&&W(e.includeCallees)&&W(e.includeSignatures)}function De(e){return!E(e)||!w(e.projectRoot)||!w(e.rustAnalyzerBinary)||!w(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>E(n)&&w(n.id)&&w(n.file)&&M(n.line)&&M(n.column))?!1:I(e.requestTimeoutMs)&&I(e.readinessDeadlineMs)&&I(e.diagnosticsTimeoutMs)&&I(e.settleDelayMs)&&de(e.concurrency)}function le(e){return Array.isArray(e)&&e.every(he)}function O(e){return e===void 0||le(e)}function he(e){return E(e)&&M(e.symbolId)&&M(e.documentId)&&M(e.startLine)&&ue(e.startChar)&&M(e.endLine)&&ue(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function A(e){return{ok:!1,code:"malformed-request",error:e}}function ae(e){return/^[a-f0-9]{64}$/.test(e)}function w(e){return typeof e=="string"&&e.length>0}function de(e){return e===void 0||B(e)}function ue(e){return e===void 0||M(e)}function I(e){return e===void 0||Y(e)}function W(e){return e===void 0||typeof e=="boolean"}var C=class{constructor(n,t=xe){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let l=_e(n.request),o=t==="reused"&&l!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===l?this.semanticResponseCache.response:null;if(o)return ce(!0,n.request.definitions.length),{session:t,response:o};let c=this.requester.requestSemantic(n.request,n.timeoutMs);return l!==null&&qe(c)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:l,response:c}),ce(!1,n.request.definitions.length),{session:t,response:c}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function _e(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return Ce(x(t))}function qe(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function ce(e,n){$()&&H({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function xe(e){for(let n of Object.keys(process.env))ve(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function Te(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function ve(e){return Te(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var qn={now:Date.now,monotonicNow:D,randomId:ke,isProcessAlive:q,readProcessIdentity:k,spawnServer(e,n,t){if(!Ae(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);Ee(process.execPath,[e,n,t],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function Ce(e){return we("sha256").update(e).digest("hex")}import{existsSync as Pe,mkdtempSync as pe,rmSync as K}from"fs";import{tmpdir as Re}from"os";import{join as j}from"path";import{fileURLToPath as fe,pathToFileURL as Ne}from"url";import{SHARE_ENV as Be,Worker as Ue}from"worker_threads";function me(e={}){let n=null,t=null,l=1,o=!1,c=null,g=null,h=r=>{r&&K(r,{recursive:!0,force:!0})},b=()=>{if(c)return;let r=n,a=t;n=null,t=null;let d=r?r.terminate():Promise.resolve(0);c=Promise.allSettled([d,ie(a,{gracefulMs:1e3,forceMs:1e3})]).then(([u,s])=>{let S=(s.status==="fulfilled"?s.value:[{reaped:!1,detail:String(s.reason)}]).filter(R=>!R.reaped);if(u.status==="rejected"||S.length>0){g=new Error(`Rust semantic worker cleanup did not complete; ownership evidence remains at ${a??"unknown"}.`);return}h(a)}).finally(()=>{c=null})},f=()=>{if(n)return n;if(c)throw new Error("The previous Rust semantic session worker is still terminating; retry the request.");if(g)throw g;let r=e.semanticWorkerPath?Ne(e.semanticWorkerPath):We();if(!Pe(fe(r)))throw new Error(`Rust semantic session worker was not found at ${fe(r)}. Run npm run build before using built semantic Rust queries.`);return t=pe(j(Re(),"scip-query-rust-session-")),n=new Ue(r,e.shareEnvironment?{env:Be}:void 0),n.unref(),n},i=()=>{let r=t??pe(j(Re(),"scip-query-rust-session-"));return t=r,j(r,`${l++}.json`)};return{requestSemantic(r,a){if(o)throw new Error("Rust semantic session was already disposed.");let d=f(),u=i(),s=new SharedArrayBuffer(4),p=new Int32Array(s);if(d.postMessage({kind:"semantic",request:r,responsePath:u,sharedBuffer:s}),Atomics.wait(p,0,0,a)==="timed-out")throw b(),new Error(`Rust semantic session worker timed out after ${(a/1e3).toFixed(0)}s`);try{let R=Le(N(u,{maxBytes:P,inputKind:"Rust semantic worker response"}));if(!R.ok)throw new Error(R.error);return R.response}finally{K(u,{force:!0})}},requestImportDefinitions(r,a){if(o)throw new Error("Rust semantic session was already disposed.");let d=f(),u=i(),s=new SharedArrayBuffer(4),p=new Int32Array(s);if(d.postMessage({kind:"import-definitions",request:r,responsePath:u,sharedBuffer:s}),Atomics.wait(p,0,0,a)==="timed-out")throw b(),new Error(`Rust semantic import-definition session worker timed out after ${(a/1e3).toFixed(0)}s`);try{let R=Oe(N(u,{maxBytes:P,inputKind:"Rust import-definition worker response"}));if(!R.ok)throw new Error(R.error);return R.response}finally{K(u,{force:!0})}},shutdown(){if(o)return;if(o=!0,!n){h(t),t=null;return}let r=i(),a=new SharedArrayBuffer(4),d=new Int32Array(a);n.postMessage({kind:"shutdown",responsePath:r,sharedBuffer:a}),Atomics.wait(d,0,0,5e3),b()}}}function Le(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Oe(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function We(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var Ve=10*6e4,ye=10,ze=250,Ye=1e3;function $e(e,n,t={}){let l=U(e),o=t.now??(t.nowMs===void 0?Date.now:()=>t.nowMs),c=o(),g=v(e),h=ee(l,{ownerId:t.ownerId??tn,nowMs:c,limits:t.limits,owner:rn,liveness:sn}),b=0;for(let f of h){let i=null,r,a="handler-error";try{let d=ne(f,t.limits),u;try{u=JSON.parse(d)}catch{throw a="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let s=F(u,{claimRequestId:f.requestId,sessionIdentity:g,nowMs:o()});if(!s.ok)throw a=s.code,r=s.responseIdentity,new Error(s.error);i=s.value,r={id:i.id,sessionIdentity:i.sessionIdentity,deadlineAtMs:i.deadlineAtMs};let p=He(i.request,t.monotonicNowMs??D());t.beforeRequest?.(p);let S=n.handle(p),R=o();if(i.deadlineAtMs<R)throw a="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");te(l,f,{ok:!0,protocolVersion:y,id:i.id,sessionIdentity:i.sessionIdentity,deadlineAtMs:i.deadlineAtMs,...S},{nowMs:R,limits:t.limits})}catch(d){let u=o(),s=r??(i?{id:i.id,sessionIdentity:i.sessionIdentity,deadlineAtMs:i.deadlineAtMs}:void 0),p=d instanceof Error?d.message:String(d);re(l,f,{ok:!1,protocolVersion:y,id:s?.id??f.requestId,...s?{sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:{},errorCode:a,error:p},p,{nowMs:u,limits:t.limits})}b+=1}return b}function He(e,n){let t=n+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:t}}}async function Je(e,n){let t=U(e);G(t);let l=_(e,"server.lock"),o=Ge(l);if(!o)return;let c=new C(()=>me({semanticWorkerPath:n,shareEnvironment:!0})),g=!1,h=D(),b=Number.NEGATIVE_INFINITY,f,i=0,r=k(m.pid),a=v(e),d=()=>{g=!0};m.once("SIGINT",d),m.once("SIGTERM",d);let u=(s=!1,p=s?"durable":"visibility")=>{let S=Date.now(),R=D();if(!s&&R-b<Ye)return;b=R;let V={protocolVersion:y,sessionIdentity:a,pid:m.pid,...r?{processIdentity:r}:{},heartbeatAtMs:S,...f===void 0?{}:{busyUntilMs:f},mailbox:se(t)};p==="durable"?X(_(e,"server.json"),V):Q(_(e,"server.json"),V)};try{u(!0);let s=Ze();for(;!g&&D()-h<s;){let p=$e(e,c,{beforeRequest(S){f=Date.now()+S.timeoutMs+5e3,u(!0,"visibility")}});p>0?(i=0,h=D(),f=void 0,u(!0,"visibility")):(i+=1,u()),await en(Qe(p,i))}}finally{c.shutdown(),Ke(_(e,"server.json"),{force:!0}),o.release()}}function Qe(e,n=1){if(e>0)return ye;let t=Math.max(0,Math.min(5,n-1));return Math.min(ze,ye*2**t)}var Xe=e=>{let n=Number(e);return Number.isInteger(n)&&n>0?{pid:n}:null};function Ge(e){let n=J(e,{kind:"rust-durable-session-server",parseLegacy:Xe});return n.kind==="acquired"?n.lock:null}function Ze(){let e=Number(m.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Ve}function en(e){return new Promise(n=>setTimeout(n,e))}var nn=m.argv[1]?je(_(m.argv[1])).href:null;if(nn===import.meta.url){let e=m.argv[2],n=m.argv[3];!e||!n?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),m.exitCode=1):await Je(e,n)}var tn=`rust-semantic-${m.pid}-${Fe()}`,be=k(m.pid),rn={pid:m.pid,...be?{processIdentity:be}:{}},sn={isProcessAlive:q,readProcessIdentity:k};export{Ge as acquireDurableRustSessionServerLock,Qe as durableSessionLoopDelayMs,$e as processDurableRustSessionRequests};
|
|
1
|
+
import{j as U}from"./chunk-DHKBIOXF.js";import{e as E,f as A,g as O,h as C,m as V}from"./chunk-CT5SI2I4.js";import"./chunk-54EOGFBR.js";import"./chunk-F4FNK44D.js";import"./chunk-T6FRID7Y.js";import"./chunk-Q7HB7BFJ.js";import{a as v,c as h,g as x,h as q,l as _,m as N,q as T,r as g,s as k,t as P,v as B}from"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as L,d as b}from"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";import n from"process";import{randomUUID as H}from"crypto";import{rmSync as J}from"fs";import{resolve as S}from"path";import{pathToFileURL as W}from"url";var X=10*6e4,F=10,G=250,z=1e3;function Y(e,t,s={}){let M=_(e),d=s.now??(s.nowMs===void 0?Date.now:()=>s.nowMs),f=d(),y=A(e),w=T(M,{ownerId:s.ownerId??oe,nowMs:f,limits:s.limits,owner:re,liveness:ne}),R=0;for(let i of w){let o=null,c,m="handler-error";try{let u=g(i,s.limits),a;try{a=JSON.parse(u)}catch{throw m="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let r=O(a,{claimRequestId:i.requestId,sessionIdentity:y,nowMs:d()});if(!r.ok)throw m=r.code,c=r.responseIdentity,new Error(r.error);o=r.value,c={id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs};let l=$(o.request,s.monotonicNowMs??b());s.beforeRequest?.(l);let p=t.handle(l),I=d();if(o.deadlineAtMs<I)throw m="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");k(M,i,{ok:!0,protocolVersion:E,id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs,...p},{nowMs:I,limits:s.limits})}catch(u){let a=d(),r=c??(o?{id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs}:void 0),l=u instanceof Error?u.message:String(u);P(M,i,{ok:!1,protocolVersion:E,id:r?.id??i.requestId,...r?{sessionIdentity:r.sessionIdentity,deadlineAtMs:r.deadlineAtMs}:{},errorCode:m,error:l},l,{nowMs:a,limits:s.limits})}R+=1}return R}function $(e,t){let s=t+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:s}}}async function K(e,t){let s=_(e);N(s);let M=S(e,"server.lock"),d=ee(M);if(!d)return;let f=new C(()=>V({semanticWorkerPath:t,shareEnvironment:!0})),y=!1,w=b(),R=Number.NEGATIVE_INFINITY,i,o=0,c=L(n.pid),m=A(e),u=()=>{y=!0};n.once("SIGINT",u),n.once("SIGTERM",u);let a=(r=!1,l=r?"durable":"visibility")=>{let p=Date.now(),I=b();if(!r&&I-R<z)return;R=I;let D={protocolVersion:E,sessionIdentity:m,pid:n.pid,...c?{processIdentity:c}:{},heartbeatAtMs:p,...i===void 0?{}:{busyUntilMs:i},mailbox:B(s)};l==="durable"?q(S(e,"server.json"),D):x(S(e,"server.json"),D)};try{a(!0);let r=te();for(;!y&&b()-w<r;){let l=Y(e,f,{beforeRequest(p){i=Date.now()+p.timeoutMs+5e3,a(!0,"visibility")}});l>0?(o=0,w=b(),i=void 0,a(!0,"visibility")):(o+=1,a()),await U(Q(l,o))}}finally{f.shutdown(),J(S(e,"server.json"),{force:!0}),d.release()}}function Q(e,t=1){if(e>0)return F;let s=Math.max(0,Math.min(5,t-1));return Math.min(G,F*2**s)}var Z=e=>{let t=Number(e);return Number.isInteger(t)&&t>0?{pid:t}:null};function ee(e){let t=h(e,{kind:"rust-durable-session-server",parseLegacy:Z});return t.kind==="acquired"?t.lock:null}function te(){let e=Number(n.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:X}var se=n.argv[1]?W(S(n.argv[1])).href:null;if(se===import.meta.url){let e=n.argv[2],t=n.argv[3];!e||!t?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),n.exitCode=1):await K(e,t)}var oe=`rust-semantic-${n.pid}-${H()}`,j=L(n.pid),re={pid:n.pid,...j?{processIdentity:j}:{}},ne={isProcessAlive:v,readProcessIdentity:L};export{ee as acquireDurableRustSessionServerLock,Q as durableSessionLoopDelayMs,Y as processDurableRustSessionRequests};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-server.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as me,B as pe,C as D,a as te,b as ie,c as C,d as N,e as G,f as E,g as B,h as F,i as se,j as re,k as oe,l as ae,n as H,o as U,p as K,q as W,r as le,u as ce,v as ue,w as de,x as fe,y as S}from"./chunk-DQLPXMH6.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import"./chunk-SMNXQT5Z.js";import"./chunk-IZYYAFN5.js";import{l as q,m as ee}from"./chunk-WUPW3UN3.js";import{a as j,f as d,g as M}from"./chunk-HGFDYOVB.js";import"./chunk-MNE7YG56.js";import"./chunk-46XGSFNI.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,S(e.client,r,c)),o,s.deadlineMs):S(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>D(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>D(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,S(e.client,l,f)),u,o.deadlineMs):S(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>D(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>D(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
|
|
1
|
+
import{b as H,c as U,d as K,e as W,f as le,i as ce,j as ue,k as de,l as fe,m as D,o as me,p as pe}from"./chunk-K5MZYZV7.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import{b as te,c as ie,d as C,e as N,f as G,h as E,i as B,j as S}from"./chunk-DHKBIOXF.js";import{d as F,e as se,f as re,g as oe,h as ae}from"./chunk-T6FRID7Y.js";import"./chunk-Q7HB7BFJ.js";import{a as j,f as d,g as M}from"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import{da as q,ea as ee}from"./chunk-4DCKBY6T.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,D(e.client,r,c)),o,s.deadlineMs):D(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>S(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>S(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,D(e.client,l,f)),u,o.deadlineMs):D(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>S(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>S(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-worker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l,l as m,m as n,n as o,o as p,p as q}from"./chunk-K5MZYZV7.js";import{a}from"./chunk-ILMHV3KM.js";import"./chunk-DHKBIOXF.js";import"./chunk-T6FRID7Y.js";import"./chunk-Q7HB7BFJ.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";export{q as calleesForDefinition,l as cargoManifestsForDefinitions,i as hoverToRustSignature,h as hoverWithRetry,m as openDefinitionDocuments,p as referencesWithCompletion,o as referencesWithRetry,b as runRustAnalyzerReferenceBatch,a as runWithConcurrency,j as rustAnalyzerInitializationOptions,k as rustAnalyzerSessionRoot,d as rustRequestCalleeDefinitions,c as rustRequestReferenceDefinitions,f as rustRequestSessionDefinitions,e as rustRequestSignatureDefinitions,g as signatureForDefinition,n as waitForOpenedDocuments};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-worker.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as SupportedLanguage } from './config-types-
|
|
1
|
+
import { a as SupportedLanguage } from './config-types-Cm-VSEBb.js';
|
|
2
2
|
|
|
3
3
|
type WatcherStatus = {
|
|
4
4
|
state: 'idle';
|
|
@@ -13,6 +13,13 @@ type WatcherStatus = {
|
|
|
13
13
|
state: 'cooldown';
|
|
14
14
|
until: number;
|
|
15
15
|
dirty: boolean;
|
|
16
|
+
} | {
|
|
17
|
+
state: 'budget-paused';
|
|
18
|
+
until: number;
|
|
19
|
+
dirty: boolean;
|
|
20
|
+
reason: string;
|
|
21
|
+
rebuilt: number;
|
|
22
|
+
estimatedWriteBytes: number;
|
|
16
23
|
} | {
|
|
17
24
|
state: 'draining';
|
|
18
25
|
startedAt: number;
|
|
@@ -38,6 +45,30 @@ interface LastRefreshMetadata {
|
|
|
38
45
|
error?: string;
|
|
39
46
|
}
|
|
40
47
|
|
|
48
|
+
/**
|
|
49
|
+
* A project-input change journal is a bounded record of filesystem events
|
|
50
|
+
* observed after one accepted SQLite generation. The generation identity and
|
|
51
|
+
* completeness flag are what let a reindexer use the paths as authoritative
|
|
52
|
+
* invalidation input instead of as advisory log text.
|
|
53
|
+
*/
|
|
54
|
+
declare const PROJECT_INPUT_CHANGE_JOURNAL_VERSION = 1;
|
|
55
|
+
type ProjectInputChangeKind = 'add' | 'change' | 'delete';
|
|
56
|
+
interface ProjectInputChangeEntry {
|
|
57
|
+
/** Normalized project-relative path. */
|
|
58
|
+
path: string;
|
|
59
|
+
kind: ProjectInputChangeKind;
|
|
60
|
+
}
|
|
61
|
+
interface ProjectInputChangeJournal {
|
|
62
|
+
version: typeof PROJECT_INPUT_CHANGE_JOURNAL_VERSION;
|
|
63
|
+
/** Immutable SQLite generation from which these changes were observed. */
|
|
64
|
+
baseGeneration: string | null;
|
|
65
|
+
/** False means the paths are diagnostic only and must not drive incremental reuse. */
|
|
66
|
+
complete: boolean;
|
|
67
|
+
/** Stable explanation for an incomplete journal. */
|
|
68
|
+
incompleteReason?: string;
|
|
69
|
+
entries: ProjectInputChangeEntry[];
|
|
70
|
+
}
|
|
71
|
+
|
|
41
72
|
/**
|
|
42
73
|
* Check if the `scip` CLI binary is available on PATH or packaged with scip-query.
|
|
43
74
|
*/
|
|
@@ -57,4 +88,4 @@ declare function printScipInstallInstructions(): void;
|
|
|
57
88
|
*/
|
|
58
89
|
declare function tryInstallScipCli(onStatus: (msg: string) => void): boolean;
|
|
59
90
|
|
|
60
|
-
export { type LastRefreshMetadata as L, type RefreshTrigger as R, type WatcherStatus as W, getScipVersion as g, isScipInstalled as i, printScipInstallInstructions as p, tryInstallScipCli as t };
|
|
91
|
+
export { type LastRefreshMetadata as L, type ProjectInputChangeJournal as P, type RefreshTrigger as R, type WatcherStatus as W, getScipVersion as g, isScipInstalled as i, printScipInstallInstructions as p, tryInstallScipCli as t };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-3FQ3KMCD.js";import"./chunk-ZBNL3QCY.js";import"./chunk-BGBBVSH4.js";import"./chunk-WULAPQUD.js";import"./chunk-MTDBHTSF.js";import"./chunk-FTSQNONX.js";import"./chunk-35ELD3RM.js";import"./chunk-GTDP2SKQ.js";import"./chunk-OUB4J26T.js";import"./chunk-2I3RSUWX.js";import"./chunk-4N6QSEMZ.js";import"./chunk-OIRWZIYL.js";import"./chunk-VGRUM7JI.js";import"./chunk-YUKYB54I.js";import"./chunk-GFLTPNWV.js";import"./chunk-CT5SI2I4.js";import"./chunk-54EOGFBR.js";import"./chunk-F4FNK44D.js";import"./chunk-T6FRID7Y.js";import"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import"./chunk-DHEQMPLW.js";import"./chunk-SEUJVWT2.js";import"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-VWLIOEEF.js";import"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";export{a as referenceReachability,b as slice};
|
|
2
|
+
//# sourceMappingURL=slice-U6S6LBSB.js.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { F as FileKind } from './file-kind-BKCVMNUf.js';
|
|
2
|
+
import { S as SourceObservationFreshness } from './repository-text-C0Q8VYdN.js';
|
|
3
|
+
import { S as SourceSnippet } from './source-snippet-_wrcgmZc.js';
|
|
4
|
+
|
|
5
|
+
interface SourceSearchIdentity {
|
|
6
|
+
relativePath: string;
|
|
7
|
+
focusLine: number;
|
|
8
|
+
ownerSymbol: string | null;
|
|
9
|
+
ownerShort: string | null;
|
|
10
|
+
ownerStartLine: number | null;
|
|
11
|
+
ownerEndLine: number | null;
|
|
12
|
+
fileKind: FileKind;
|
|
13
|
+
freshness?: SourceObservationFreshness;
|
|
14
|
+
}
|
|
15
|
+
interface SourceSearchMatch extends SourceSnippet {
|
|
16
|
+
ownerSymbol: string | null;
|
|
17
|
+
ownerShort: string | null;
|
|
18
|
+
ownerStartLine?: number | null;
|
|
19
|
+
ownerEndLine?: number | null;
|
|
20
|
+
fileKind?: FileKind;
|
|
21
|
+
freshness?: SourceObservationFreshness;
|
|
22
|
+
}
|
|
23
|
+
interface SourceSearchFileCoverage {
|
|
24
|
+
relativePath: string;
|
|
25
|
+
matchingLines: number;
|
|
26
|
+
returnedMatches: number;
|
|
27
|
+
freshness?: SourceObservationFreshness;
|
|
28
|
+
}
|
|
29
|
+
interface SourceSearchScopeHint {
|
|
30
|
+
scope: string;
|
|
31
|
+
matchingLines: number;
|
|
32
|
+
matchingFiles: number;
|
|
33
|
+
}
|
|
34
|
+
interface SourceSearchIdentityCoverage {
|
|
35
|
+
mode: 'complete' | 'bounded';
|
|
36
|
+
returned: number;
|
|
37
|
+
total: number;
|
|
38
|
+
omitted: number;
|
|
39
|
+
}
|
|
40
|
+
interface SourceSearchTextCoverage {
|
|
41
|
+
basis: 'current-project-text-files';
|
|
42
|
+
candidateFiles: number;
|
|
43
|
+
scannedTextFiles: number;
|
|
44
|
+
scannedBytes: number;
|
|
45
|
+
skippedBinaryPaths: string[];
|
|
46
|
+
skippedUnreadablePaths: string[];
|
|
47
|
+
skippedOversizedPaths: string[];
|
|
48
|
+
semanticFiles: {
|
|
49
|
+
aligned: number;
|
|
50
|
+
stale: number;
|
|
51
|
+
unavailable: number;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
interface SourceSearchResult {
|
|
55
|
+
pattern: string;
|
|
56
|
+
mode: 'literal' | 'regexp';
|
|
57
|
+
identities?: SourceSearchIdentity[];
|
|
58
|
+
identityManifest?: SourceSearchIdentity[];
|
|
59
|
+
identityCoverage?: SourceSearchIdentityCoverage;
|
|
60
|
+
matches: SourceSearchMatch[];
|
|
61
|
+
matchingLines: number;
|
|
62
|
+
matchingFiles?: number;
|
|
63
|
+
omittedMatches: number;
|
|
64
|
+
fileCoverage?: SourceSearchFileCoverage[];
|
|
65
|
+
scopeHints?: SourceSearchScopeHint[];
|
|
66
|
+
omittedScopeHints?: number;
|
|
67
|
+
scannedFiles: number;
|
|
68
|
+
textCoverage?: SourceSearchTextCoverage;
|
|
69
|
+
}
|
|
70
|
+
interface SourceSearchOptions {
|
|
71
|
+
scope?: string;
|
|
72
|
+
context?: number;
|
|
73
|
+
limit?: number;
|
|
74
|
+
regexp?: boolean;
|
|
75
|
+
ignoreCase?: boolean;
|
|
76
|
+
ranking?: 'structural';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type { SourceSearchFileCoverage as S, SourceSearchIdentity as a, SourceSearchIdentityCoverage as b, SourceSearchMatch as c, SourceSearchOptions as d, SourceSearchResult as e, SourceSearchScopeHint as f, SourceSearchTextCoverage as g };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface SourceSnippet {
|
|
2
|
+
relativePath: string;
|
|
3
|
+
startLine: number;
|
|
4
|
+
endLine: number;
|
|
5
|
+
focusLine: number;
|
|
6
|
+
source: string;
|
|
7
|
+
}
|
|
8
|
+
interface SourceUnitSnippet extends SourceSnippet {
|
|
9
|
+
unitType: string | null;
|
|
10
|
+
unitStartLine: number;
|
|
11
|
+
unitEndLine: number;
|
|
12
|
+
omittedLines: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export type { SourceSnippet as S, SourceUnitSnippet as a };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-4IIMPWMR.js";import"./chunk-SKUMCCC5.js";import"./chunk-ZBNL3QCY.js";import"./chunk-BGBBVSH4.js";import"./chunk-WULAPQUD.js";import"./chunk-MTDBHTSF.js";import"./chunk-FTSQNONX.js";import"./chunk-35ELD3RM.js";import"./chunk-GTDP2SKQ.js";import"./chunk-OUB4J26T.js";import"./chunk-2I3RSUWX.js";import"./chunk-4N6QSEMZ.js";import"./chunk-OIRWZIYL.js";import"./chunk-VGRUM7JI.js";import"./chunk-YUKYB54I.js";import"./chunk-GFLTPNWV.js";import"./chunk-CT5SI2I4.js";import"./chunk-54EOGFBR.js";import"./chunk-F4FNK44D.js";import"./chunk-T6FRID7Y.js";import"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import"./chunk-DHEQMPLW.js";import"./chunk-SEUJVWT2.js";import"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-VWLIOEEF.js";import"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";export{b as consumerSurface,a as surface};
|
|
2
|
+
//# sourceMappingURL=surface-C7SS5CDQ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-ANWGXPPN.js";import{a as c}from"./chunk-26CT72HM.js";import{b as i,e as m}from"./chunk-VGRUM7JI.js";import"./chunk-MXNGIEPU.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-VWLIOEEF.js";import{c as l}from"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-4DCKBY6T.js";function g(o,t){let s=i(o,t),e=f(s);for(let n of e)console.log(n)}function R(o,t,s="No results found for resolved symbol."){return i(o,t).match?s:p(t,m(o,t,5))}function S(o,t,s,e){return{...a(o,t),[e]:s}}function p(o,t){let s=`No definition matched '${o}'.`;return t.length>0?`${s} Suggestions: ${t.join(", ")}`:s}function f(o){if(!o.match||o.total<=1)return[];let t=o.match,s=Math.max(0,o.total-1),e=[`Resolved: ${l(t.symbol)} (${t.relativePath}) -- ${s} other definition(s) share this name; qualify as <dir/leaf> to target another.`],n=o.candidates.slice(0,3);return n.length>0&&e.push(`Alternates: ${n.map(r=>`${r.shortName} (${r.relativePath}:${c(r.startLine)})`).join("; ")}`),e.push(""),e}export{p as noMatchMessage,g as symbolResolutionBefore,R as symbolResolutionEmptyMessage,a as symbolResolutionJson,S as withSymbolResolutionJson};
|
|
2
|
+
//# sourceMappingURL=symbol-resolution-3FVEKDTJ.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-XRXCANFQ.js";import"./chunk-SKUMCCC5.js";import"./chunk-OIRWZIYL.js";import"./chunk-VGRUM7JI.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-VWLIOEEF.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-4DCKBY6T.js";export{b as moduleMap,a as system};
|
|
2
|
+
//# sourceMappingURL=system-6K2NOO5C.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b,c}from"./chunk-WZQFY5S7.js";import"./chunk-EA4SH4U5.js";import"./chunk-PZEI2TVL.js";import"./chunk-FTSQNONX.js";import"./chunk-35ELD3RM.js";import"./chunk-GTDP2SKQ.js";import"./chunk-OUB4J26T.js";import"./chunk-2I3RSUWX.js";import"./chunk-4N6QSEMZ.js";import"./chunk-OIRWZIYL.js";import"./chunk-VGRUM7JI.js";import"./chunk-GFLTPNWV.js";import"./chunk-CT5SI2I4.js";import"./chunk-54EOGFBR.js";import"./chunk-F4FNK44D.js";import"./chunk-T6FRID7Y.js";import"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import"./chunk-SEUJVWT2.js";import"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-VWLIOEEF.js";import"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";export{c as qualifiedTraceEvidence,a as trace,b as traceEvidence};
|
|
2
|
+
//# sourceMappingURL=trace-II5K2TMH.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as m}from"./chunk-CN2WGM7D.js";import"./chunk-BHE44MHT.js";import{a as u}from"./chunk-ZD3Z54IW.js";import{e as d,f as c}from"./chunk-5ZJH6DDE.js";import"./chunk-MEI3PTUK.js";import"./chunk-DHEQMPLW.js";import"./chunk-SEUJVWT2.js";import"./chunk-AUP6YI5M.js";import"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-7IOAZRVL.js";import"./chunk-VWLIOEEF.js";import"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import{c as a,d as p}from"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";import{parentPort as s,workerData as f}from"worker_threads";var o=b(f);if(!s)throw new Error("TypeScript mailbox worker requires a parent port.");if(o.kind==="index"){let t=new c({projectRoot:o.projectRoot,currentGeneration:()=>d(o.dbPath),...o.maxActiveSessions===void 0?{}:{maxActiveSessions:o.maxActiveSessions},...o.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:o.softMemoryLimitMb}});s.on("message",e=>{let r=S(e);y(r,()=>t.handle(r.payload.baseGeneration,r.payload.request),()=>t.status())})}else{let t=new u({openDb:()=>m(o.projectRoot)});s.on("message",e=>{let r=S(e),i=a();p(r.payload.profileEnvironment??{});try{y(r,()=>t.handle(r.payload.generation,r.payload.request),()=>t.status())}finally{p(i)}})}function y(t,e,r){let i;try{if(Date.now()>t.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let n=e();if(Date.now()>t.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");i={kind:"response",requestId:t.requestId,ok:!0,result:n,status:r()}}catch(n){i={kind:"response",requestId:t.requestId,ok:!1,error:n instanceof Error?n.message:String(n),status:r()}}s.postMessage(i)}function b(t){if(!t||typeof t!="object")throw new Error("TypeScript mailbox worker data is missing.");let e=t;if(e.kind==="index"&&typeof e.projectRoot=="string"&&typeof e.dbPath=="string"&&l(e.maxActiveSessions)&&l(e.softMemoryLimitMb))return{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath,...e.maxActiveSessions===void 0?{}:{maxActiveSessions:e.maxActiveSessions},...e.softMemoryLimitMb===void 0?{}:{softMemoryLimitMb:e.softMemoryLimitMb}};if(e.kind==="semantic"&&typeof e.projectRoot=="string")return{kind:"semantic",projectRoot:e.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function l(t){return t===void 0||Number.isInteger(t)&&t>0}function S(t){if(!t||typeof t!="object")throw new Error("TypeScript mailbox worker request is missing.");let e=t;if(e.kind!=="request"||typeof e.requestId!="string"||!Number.isSafeInteger(e.deadlineAtMs)||typeof e.payload!="object"||e.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return e}
|
|
2
2
|
//# sourceMappingURL=typescript-mailbox-worker.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a}from"./chunk-LHTT5C3Z.js";import"./chunk-LXLD46LH.js";import"./chunk-3TNRNKAT.js";import"./chunk-7KCZELVM.js";import"./chunk-Z3GCK3PD.js";import"./chunk-PZEI2TVL.js";import"./chunk-ZBNL3QCY.js";import"./chunk-BGBBVSH4.js";import"./chunk-WULAPQUD.js";import"./chunk-MTDBHTSF.js";import"./chunk-FTSQNONX.js";import"./chunk-35ELD3RM.js";import"./chunk-SWFAFA4G.js";import"./chunk-3EX7DNBC.js";import"./chunk-GTDP2SKQ.js";import"./chunk-OUB4J26T.js";import"./chunk-2I3RSUWX.js";import"./chunk-4N6QSEMZ.js";import"./chunk-OIRWZIYL.js";import"./chunk-VGRUM7JI.js";import"./chunk-YUKYB54I.js";import"./chunk-GFLTPNWV.js";import"./chunk-CT5SI2I4.js";import"./chunk-54EOGFBR.js";import"./chunk-F4FNK44D.js";import"./chunk-T6FRID7Y.js";import"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import"./chunk-DHEQMPLW.js";import"./chunk-SEUJVWT2.js";import"./chunk-SF7X6QNW.js";import"./chunk-SDPA5DKN.js";import"./chunk-DOPCR5BY.js";import"./chunk-VWLIOEEF.js";import"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import"./chunk-3VLJ2DCA.js";import"./chunk-4DCKBY6T.js";export{a as valueFlow};
|
|
2
|
+
//# sourceMappingURL=value-flow-MKFUUE5B.js.map
|
package/dist/watch-server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import{c as vt,f as yt,g as ee,h as Le,i as L,j as Wt,k as re,m as Tt,n as Et,o as Pt}from"./chunk-L5GJNV2T.js";import"./chunk-IZYYAFN5.js";import{b as Ct,c as ie,d as ne,e as Oe,f as se,g as Mt,h as De,i as At,k as qt}from"./chunk-DAFAHMNB.js";import{Aa as kt,B as gt,g as ke,h as st,i as ot,j as K,l as We,m as ct,n as lt,o as dt,p as Ee,q as ut,r as Pe,s as ft,t as mt,va as Rt,ya as te,za as xt}from"./chunk-HZ72SESS.js";import{g as St}from"./chunk-FJH2NW7J.js";import"./chunk-WUPW3UN3.js";import{A as wt,B as bt,C as Ae,D as qe,E as _e,F as It,b as N,i as xe,j as _,k as nt,l as I,m as Ce,n as ht,o as Me,p as pt,r as Q,s as Z}from"./chunk-AIE7TFJW.js";import"./chunk-HGFDYOVB.js";import{a as b,b as at,c as Te,d as x}from"./chunk-MNE7YG56.js";import{h as E}from"./chunk-46XGSFNI.js";import R from"process";import{rmSync as kr}from"fs";import{resolve as Ei}from"path";import{pathToFileURL as Pi}from"url";import{statSync as Tr}from"fs";import{basename as Er,isAbsolute as Pr,join as Cr,relative as Mr}from"path";import{watch as Ar}from"chokidar";import qr from"ignore";var Dt=5e3,ae=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ne(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??jr,jt.set(this,Hr(e.stopTimeoutMs??Dt,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??Vr(),this.subscriptionFactory=e.subscriptionFactory??Nr,this.gitignoreFilter=St(e.projectRoot),this.extraIgnore=qr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,oe(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...oe(this).closures],n=Lr(this),s=this.clock.now()+n;return this.stopPromise=this.finishStop(e,i,r,s,n).catch(a=>{throw this.stopInProgress=!1,a}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=Ot(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,n)=>this.isIgnoredWatchPath(i,n?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(i,n)=>{this.stopped||this.handleFileChange(n)}),r.on("error",i=>this.handleSourceWatcherError(r,i,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,i){if(i||this.sourcePollingFallbackStarted||!Ur(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(n=>n!==e),Or(oe(this),e,n=>this.onError(n));try{this.startSourceWatcher(!0)}catch(n){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`))}}isIgnoredWatchPath(e,r){let i=this.relativeWatchPath(e);if(!i)return!1;let n=r?`${i}/`:i;return n===".git/"||n.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Er(r).startsWith(vt)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(e){let r=Pr(e)?e:Cr(this.projectRoot,e);return Mr(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=Ot(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let a=this.wallNow()+s;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=this.wallNow();this.setStatus({state:"indexing",startedAt:i});let n=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=n,n.completion.then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=!1;try{a=this.onReindexComplete(s,r)===!0}catch(o){this.onError(o instanceof Error?o:new Error(String(o)))}if(this.dirty&&!this.stopped){if(a){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let o=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=s instanceof Error?s:new Error(String(s));this.onReindexError(a,r),this.onError(a),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===n&&(this.activeOperation=null)})}async finishStop(e,r,i,n,s){let a=[],o=e.map(async m=>{try{await m.close()}catch(h){a.push(`watch subscription close failed: ${String(h)}`)}});o.push(...r),i&&o.push((async()=>{try{let m=await i.cancel();m.state==="degraded"&&a.push(m.reason)}catch(m){a.push(`reindex cancellation failed: ${m instanceof Error?m.message:String(m)}`)}})());let c=o.length,l=o.map(m=>m.finally(()=>{c-=1})),u=await _r(l,n,this.clock),d=oe(this);return a.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(a.push(`watch shutdown exceeded the ${s}ms deadline with ${c} operation(s) still pending`),Promise.all(l).then(()=>{this.stopInProgress=!1})),a.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:a.join("; ")}),{state:"degraded",reasons:a}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let i=e.head!==r.head,n=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;i&&n?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):i?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):n&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let e=Ee(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let r=ut(this.projectRoot,e),i={head:Ee(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let n=Tr(r);i.indexMtimeMs=n.mtimeMs,i.indexSize=n.size}catch{i.indexMtimeMs=void 0,i.indexSize=void 0}return i}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function _r(t,e,r){if(t.length===0)return!0;let i=Promise.all(t).then(()=>!0),n=Math.max(0,e-r.now()),s=null,a=new Promise(c=>{s=r.setTimeout(()=>c(!1),n)}),o=await Promise.race([i,a]);return o&&s&&r.clearTimeout(s),o}var _t=new WeakMap,jt=new WeakMap;function oe(t){let e=_t.get(t);if(e)return e;let r={closures:new Set,errors:[]};return _t.set(t,r),r}function Lr(t){return jt.get(t)??Dt}function Or(t,e,r){let i=Promise.resolve().then(()=>e.close()).catch(n=>{let s=`watch subscription close failed during polling fallback: ${String(n)}`;t.errors.push(s),r(new Error(s))});t.closures.add(i),i.then(()=>t.closures.delete(i))}function Dr(t){let{projectRoot:e,config:r,languages:i,pnpmWorkspaces:n,typescriptProjectMode:s,typescriptProjects:a,clojureConfigPath:o,indexerConcurrency:c,trigger:l}=t,u=ie(e),d=Object.keys(u).length>0?u:r,m=K(e,d),h=d.indexer?.typescript,g=d.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:e,SCIP_REINDEX_OUTPUT_SCIP:m.indexPath,SCIP_REINDEX_OUTPUT_DB:m.dbPath,SCIP_REINDEX_LANGUAGES:(d.languages??i)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(d.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:h?.pnpmWorkspaces??n?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:h?.projectMode??s,projects:h?.projects??a??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:g?.configPath??o??"",SCIP_REINDEX_TRIGGER_KIND:l.kind,SCIP_REINDEX_TRIGGER_DETAIL:l.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var jr={now:b,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Nr=(t,e)=>Ar(t,e),Gr=15*6e4,Fr=1e3,$r=64*1024;function Br(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function Lt(t,e){let r=t instanceof Error?t.message:String(t),i=e.stderrTail.trim()||e.stdoutTail.trim();return i?`${r}
|
|
2
|
-
${i}`:r}function Vr(t={}){let e=t.timeoutMs??Gr,r=t.terminationGraceMs??Fr,i=t.maxOutputBytes??$r,n=t.resolveLaunch??Dr;return{start(s){let a=n(s),o=new AbortController,c=Br(),l=!1,u=Et({command:process.execPath,args:[...process.execArgv,a.workerPath],label:"watch reindex worker",env:a.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:o.signal,detached:!0}).then(d=>{if(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated},d.status!==0)throw new Error(Lt(new Error(`Reindex worker exited with ${d.signal?`signal ${d.signal}`:`code ${d.status}`}`),c));return d.durationMs}).catch(d=>{throw d instanceof Tt&&(c={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(Lt(d,c),{cause:d})}).finally(()=>{l=!0});return{completion:u,async cancel(){l||o.abort();try{await u}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function Ot(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function Ur(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}function Hr(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}import{spawn as oi}from"child_process";import{existsSync as ai,rmSync as er}from"fs";import{dirname as mn,resolve as Ue}from"path";import{fileURLToPath as Sn}from"url";import{createHash as zr,randomUUID as je}from"crypto";import{existsSync as Yr,linkSync as Jr,readdirSync as Xr,rmSync as O}from"fs";import{basename as Kr,dirname as Qr,join as v}from"path";var A=1,Zr=10*6e4,ei=10080*6e4,le="requests",G="claims",ce="completions",Gt="staging";function Ft(t,e,r={}){let i=r.now?.()??new Date,n=ri(r.ttlMs),s=ii(r.idempotencyKey),a=s?`key-${zr("sha256").update(s).digest("hex")}`:`request-${(r.randomId??je)()}`,o={version:A,requestId:a,...s?{idempotencyKey:s}:{},createdAt:i.toISOString(),deadlineAt:new Date(i.getTime()+n).toISOString(),detail:e.trim().slice(0,2048)||"stale index observed by a command"},c=Kt(t,a),l=Fe(t,c,o,r.onStage);if(l.published)return{disposition:"accepted",request:o,achievedDurability:l.achievedDurability,directorySync:l.directorySync};let u=Ge(c);if(!u)throw new Error(`Watch refresh request identity ${a} exists but is malformed.`);return{disposition:"duplicate",request:u}}function $t(t,e={}){let r=e.now?.()??new Date,i=`claim-${(e.randomId??je)()}`,n=Math.max(1,Math.floor(e.limit??64)),s=Yt(t).sort(ni),a=[];for(let o of s){if(a.length>=n)break;if(Nt(t,o.requestId))continue;if(Date.parse(o.deadlineAt)<=r.getTime()){zt(t,{version:A,requestId:o.requestId,outcome:"expired",completedAt:r.toISOString()});continue}let c={version:A,requestId:o.requestId,claimId:i,claimedAt:r.toISOString()};if(Fe(t,Qt(t,o.requestId),c).published){if(Nt(t,o.requestId)){Jt(t,o.requestId,i);continue}a.push(o)}}return{claimId:i,requests:a}}function Bt(t,e,r=()=>new Date,i){let n=r().toISOString();for(let s of e.requests)zt(t,{version:A,requestId:s.requestId,claimId:e.claimId,outcome:"completed",completedAt:n});i?.("after-completion"),de(t,e),i?.("after-claim-release")}function de(t,e){for(let r of e.requests)Jt(t,r.requestId,e.claimId)}function Vt(t){let e=0;for(let r of q(v(t,G)))O(r,{force:!0}),e++;return e>0&&_(v(t,G)),Xt(t),e}function Ne(t){let e=Yt(t),r=new Map,i=ti(v(t,le),Ge);for(let c of q(v(t,ce))){let l=ue(c);if(!l){i++;continue}r.set(l.requestId,l)}let n=new Set;for(let c of q(v(t,G))){let l=Ht(c);if(!l){i++;continue}n.add(l.requestId)}let s=e.filter(c=>!r.has(c.requestId)&&!n.has(c.requestId)),a=[...r.values()].filter(c=>c.outcome==="completed").length,o=[...r.values()].filter(c=>c.outcome==="expired").length;return{pending:s.length,claimed:e.filter(c=>!r.has(c.requestId)&&n.has(c.requestId)).length,completed:a,expired:o,invalid:i,...s.length>0?{oldestPendingAt:s.map(c=>c.createdAt).reduce((c,l)=>si(c,l))}:{}}}function Ut(t,e={}){let r=(e.now?.()??new Date).getTime(),i=Math.max(0,e.retentionMs??ei),n=0;for(let s of q(v(t,ce))){let a=ue(s);!a||r-Date.parse(a.completedAt)<i||(O(s,{force:!0}),O(Kt(t,a.requestId),{force:!0}),n++)}return n>0&&(_(v(t,ce)),_(v(t,le))),Xt(t),n}function Ge(t){return $e(t,e=>{let r=e;return r.version===A&&F(r.requestId)&&(r.idempotencyKey===void 0||typeof r.idempotencyKey=="string")&&N(r.createdAt)&&N(r.deadlineAt)&&Date.parse(r.deadlineAt)>=Date.parse(r.createdAt)&&typeof r.detail=="string"&&r.detail.length>0})}function Ht(t){return $e(t,e=>{let r=e;return r.version===A&&F(r.requestId)&&F(r.claimId)&&N(r.claimedAt)})}function ue(t){return $e(t,e=>{let r=e;return r.version===A&&F(r.requestId)&&(r.claimId===void 0||F(r.claimId))&&(r.outcome==="completed"||r.outcome==="expired")&&N(r.completedAt)})}function zt(t,e){let r=Zt(t,e.requestId);if(Fe(t,r,e).published)return;let i=ue(r);if(!i||i.requestId!==e.requestId||i.outcome!==e.outcome)throw new Error(`Watch refresh completion ${e.requestId} conflicts with an existing record.`)}function Fe(t,e,r,i){let n=v(t,Gt),s=Qr(e),a=xe(n),o=xe(s),c=v(n,`${Kr(e)}.${process.pid}.${je()}.tmp`);try{let l=Z(c,r,{spacing:2,trailingNewline:!0});i?.("after-staged");try{Jr(c,e)}catch(d){if(d.code==="EEXIST")return{published:!1};throw d}let u=nt(a,o,l.directorySync,_(s));return i?.("after-published"),{published:!0,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}finally{O(c,{force:!0})}}function Yt(t){let e=[];for(let r of q(v(t,le))){let i=Ge(r);i&&e.push(i)}return e}function Jt(t,e,r){let i=Qt(t,e),n=Ht(i);!n||n.claimId!==r||(O(i,{force:!0}),_(v(t,G)))}function Xt(t){for(let e of q(v(t,Gt),".tmp"))O(e,{force:!0})}function ti(t,e){return q(t).filter(r=>!e(r)).length}function q(t,e=".json"){return Yr(t)?Xr(t,{withFileTypes:!0}).filter(r=>r.isFile()&&r.name.endsWith(e)).map(r=>v(t,r.name)).sort():[]}function $e(t,e){try{let r=JSON.parse(E(t,"watch refresh request record"));return e(r)?r:null}catch{return null}}function Kt(t,e){return v(t,le,`${e}.json`)}function Qt(t,e){return v(t,G,`${e}.json`)}function Zt(t,e){return v(t,ce,`${e}.json`)}function Nt(t,e){return ue(Zt(t,e))!==null}function ri(t){if(t===void 0)return Zr;if(!Number.isFinite(t)||t<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(t)}function ii(t){let e=t?.trim();return e?e.slice(0,512):void 0}function F(t){return typeof t=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(t)}function ni(t,e){return Date.parse(t.createdAt)-Date.parse(e.createdAt)||t.requestId.localeCompare(e.requestId)}function si(t,e){return Date.parse(e)<Date.parse(t)?e:t}var ci=6e3,li=1e3,tr=10;function nr(t,e,r){let i=Pe(Ue(t));if(r&&Pe(r.projectRoot)===i)return{projectRoot:i,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:e};let n=lt(i);if(n.kind==="error")throw new Error(`Could not establish Git worktree identity for ${i}: ${n.message}`);return n.kind==="non-git"?{projectRoot:i,worktreeKind:"non-git",cliVersion:e}:{projectRoot:i,worktreeKind:"git",worktreeId:n.identity.worktreeId,cliVersion:e}}function sr(t){let e=t.runtime??hi,r=L(t.cacheDir),i=Wt(r.statePath),n=i?e.isProcessAlive(i.pid)?{kind:"live",state:i}:{kind:"stale",state:i,reason:"dead-process"}:{kind:"stopped"},s=di("stop",n);if(s.kind==="signal-stop")return rr(s.state,t,e),Be(r,s.state.pid,e),{disposition:"stopped",pid:s.state.pid};if(s.kind==="clean-stale")return Be(r,s.state.pid,e),{disposition:"stopped",pid:s.state.pid};let a=lr(r.lockPath);return s.kind==="already-stopped"&&a&&e.isProcessAlive(a.pid)?(rr(a,t,e),Be(r,a.pid,e),{disposition:"stopped",pid:a.pid}):{disposition:"already-stopped"}}function or(t,e,r={}){let{durability:i="durable",...n}=r;i==="durable"?Z(t,e,n):Q(t,e,n)}function ar(t){try{let e=JSON.parse(E(t,"watch activity record"));return e.version!==1||!re(e.at)||e.refreshRequestedAt!==void 0&&!re(e.refreshRequestedAt)||e.refreshDetail!==void 0&&typeof e.refreshDetail!="string"?null:{atMs:Date.parse(e.at),...e.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(e.refreshRequestedAt)},...e.refreshDetail===void 0?{}:{refreshDetail:e.refreshDetail}}}catch{return null}}function cr(t,e,r={}){let i=r.pid??process.pid,n=r.isProcessAlive??I,s=()=>{},a=r.readProcessIdentity??x,o=r.now??(()=>new Date),c={...Ce,wallNow:()=>o().getTime(),isProcessAlive:n,readProcessIdentity:a},l=ht(t,{kind:"watch",pid:i,processIdentity:a(i),detail:{projectRoot:Ue(e)},parseLegacy:he,runtime:c});if(l.kind==="contended"){let u=dr(l.observation);return{acquired:!1,lockPath:t,message:ui(t,e,u),release:s}}return{acquired:!0,lockPath:t,message:"",release:()=>{l.lock.release()}}}function lr(t){return dr(Me(t,{parseLegacy:he}))}var he=t=>{let e=ur(t);return e?{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}:null};function dr(t){if(t.state==="valid"&&t.record?.kind==="watch"){let e=t.record.detail?.projectRoot;return typeof e!="string"?null:{version:1,pid:t.record.pid,...t.record.processIdentity?{processIdentity:t.record.processIdentity}:{},projectRoot:e,startedAt:t.record.startedAt}}return ur(t.parsed)}function ur(t){try{let e=t;if(e.version!==1||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||!re(e.startedAt))return null;let r=e.processIdentity===void 0?null:at(e.processIdentity);return e.processIdentity!==void 0&&(!r||r.pid!==e.pid)?null:{version:1,pid:e.pid,...r?{processIdentity:r}:{},projectRoot:e.projectRoot,startedAt:e.startedAt}}catch{return null}}function di(t,e){switch(t){case"status":return{kind:"report",classification:e};case"ensure":switch(e.kind){case"stopped":return{kind:"start"};case"stale":return e.reason==="old-heartbeat"?{kind:"refuse-replace",state:e.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:e.state};case"incompatible":return{kind:"replace",state:e.state};default:return Ve(e)}case"stop":switch(e.kind){case"stopped":return{kind:"already-stopped"};case"stale":return e.reason==="old-heartbeat"?{kind:"signal-stop",state:e.state}:{kind:"clean-stale",state:e.state};case"live":case"incompatible":return{kind:"signal-stop",state:e.state};default:return Ve(e)}default:return Ve(t)}}function hr(t){return t.idleTimeoutMs===0||t.watcher.state!=="idle"?!1:t.nowMs-t.lastActivityAtMs>=t.idleTimeoutMs}function rr(t,e,r){let{pid:i}=t;if(!r.isProcessAlive(i))return;ir(t,r),r.signalProcess(i);let n=e.stopTimeoutMs??ci,s=r.monotonicNow??b,a=s()+n;for(;s()<=a;){if(!r.isProcessAlive(i))return;r.sleep(tr)}if(!r.forceSignalProcess)throw new Error(`scip-query watch service pid ${i} did not stop within ${n}ms and forced termination is unavailable.`);ir(t,r),r.forceSignalProcess(i);let o=e.forceStopTimeoutMs??li,c=s()+o;for(;s()<=c;){if(!r.isProcessAlive(i))return;let l=r.readProcessIdentity(i);if(t.processIdentity&&l&&!Te(t.processIdentity,l))return;r.sleep(tr)}throw new Error(`scip-query watch service pid ${i} remained alive ${o}ms after forced termination.`)}function Be(t,e,r){if(er(t.statePath,{force:!0}),er(t.activityPath,{force:!0}),lr(t.lockPath)?.pid===e&&!r.isProcessAlive(e)){let n={...Ce,wallNow:r.now,isProcessAlive:r.isProcessAlive,readProcessIdentity:r.readProcessIdentity},s=Me(t.lockPath,{parseLegacy:he,runtime:n});pt(t.lockPath,s,{parseLegacy:he,runtime:n})}}function ui(t,e,r){return`error: scip-query watch is already running for ${Ue(e)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${t})`:` (lock: ${t})`}. Stop that watcher before starting another.`}var hi={now:Date.now,monotonicNow:b,isProcessAlive:I,readProcessIdentity:x,spawnServer(t,e,r,i){if(!ai(t))throw new Error(`Watch service helper was not found at ${t}. Run npm run build first.`);oi(process.execPath,[t,e,r,JSON.stringify(i)],{detached:!0,stdio:"ignore",env:{...process.env,SCIP_QUERY_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(t){process.kill(t,"SIGTERM")},forceSignalProcess(t){process.kill(t,"SIGKILL")},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function ir(t,e){if(!t.processIdentity)throw new Error(`Refusing to signal scip-query watch pid ${t.pid}: its ownership record has no process identity.`);let r=e.readProcessIdentity(t.pid);if(!r)throw new Error(`Refusing to signal scip-query watch pid ${t.pid}: its process identity is unavailable.`);if(!Te(t.processIdentity,r))throw new Error(`Refusing to signal scip-query watch pid ${t.pid}: its process identity does not match the ownership record.`)}function Ve(t){throw new Error(`Unhandled watch service value: ${JSON.stringify(t)}`)}import{existsSync as gr,lstatSync as pe,readdirSync as Sr,realpathSync as pr,rmSync as $,statSync as pi}from"fs";import{join as y,resolve as B,sep as fr}from"path";var fi=3600*1e3,mi=2*1024*1024*1024,gi=300*1e3;function Si(t){let e=t.leases.filter(o=>o.managed&&!o.live&&!o.busy),r=vi(t.leases,t.locks),i={};for(let o of t.generations)r.has(o.generationId)||(i[o.generationId]=o.unreferencedAt??t.nowMs);let n=t.generations.filter(o=>!r.has(o.generationId)).sort((o,c)=>i[o.generationId]-i[c.generationId]||o.generationId.localeCompare(c.generationId)),s=new Set;for(let o of n)t.nowMs-i[o.generationId]>=t.policy.generationTtlMs&&s.add(o.generationId);let a=t.generations.filter(o=>!s.has(o.generationId)).reduce((o,c)=>o+c.size,0);for(let o of n){if(a<=t.policy.budgetBytes)break;s.has(o.generationId)||(s.add(o.generationId),a-=o.size)}for(let o of s)delete i[o];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(o=>s.has(o.generationId)),deleteLocks:t.locks.filter(o=>!o.live),deleteTemporaries:t.temporaries.filter(o=>!o.live),protectedGenerationIds:[...r].sort(),unreferencedSince:i}}function vi(t,e){let r=new Set(t.filter(i=>i.managed&&(i.live||i.busy)).flatMap(i=>[i.lease.baseGenerationId,i.lease.activeGenerationId]).filter(i=>i!==void 0));for(let i of e)i.live&&r.add(i.generationId);return r}function vr(t,e,r={}){if(!ot())return{kind:"disabled"};let i=ct(t);if(!i)return{kind:"unavailable"};let n=y(ke(),"repositories",i.repositoryId);if(!gr(n))return{kind:"unavailable"};let s=(r.now??Date.now)(),a=y(n,"gc-state.json"),o=wi(a);if(!r.force&&o&&s-Date.parse(o.lastSweepAt)<gi)return{kind:"throttled",sweptAt:o.lastSweepAt};let c=ft(n,{now:()=>s});if(!c)return{kind:"busy"};try{let l=yi(t,n,i.repositoryId,o?.unreferencedSince??{}),u=Si({nowMs:s,...l,policy:{generationTtlMs:r.policy?.generationTtlMs??fi,budgetBytes:r.policy?.budgetBytes??mi}}),d=0,m=0;for(let p of u.deleteWorktrees){if(!yr(p.lease))continue;let S=mt(y(p.lease.localCacheDir,"cache-lifecycle.lock"));if(S)try{if(ze(p.lease,!0))continue;try{sr({projectRoot:p.lease.projectRoot,cacheDir:p.lease.localCacheDir,cliVersion:e})}catch{continue}if(ze(p.lease,!0))continue;$(p.lease.localCacheDir,{recursive:!0,force:!0}),$(p.leasePath,{force:!0}),m+=1}finally{S.release()}}for(let p of u.deleteLocks)$(p.path,{force:!0});for(let p of u.deleteTemporaries)$(p.path,{recursive:!0,force:!0});for(let p of u.deleteGenerations)$(p.path,{recursive:!0,force:!0}),d+=p.size;gt(y(n,"evidence.db"));let h={kind:"swept",sweptAt:new Date(s).toISOString(),deletedWorktrees:m,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},g={version:1,lastSweepAt:h.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:h};return Q(a,g,{spacing:2,trailingNewline:!0}),h}catch(l){return{kind:"failed",error:l instanceof Error?l.message:String(l)}}finally{c.release()}}function yi(t,e,r,i){let n=new Set(dt(t).map(l=>B(l.path))),s=[];for(let l of He(y(e,"worktrees"))){if(!l.endsWith(".json"))continue;let u=y(e,"worktrees",l),d=Ri(u);if(!d)continue;let m=B(d.projectRoot);s.push({leasePath:u,lease:d,managed:d.repositoryId===r&&yr(d),live:n.has(m)||gr(m),busy:ze(d)})}let a=[];for(let l of He(y(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(l);if(!u)continue;let d=y(e,"locks",l),m=Ye(d),h=m!==void 0&&I(m),g=u[1];a.push({generationId:g,path:d,live:h})}let o=[],c=[];for(let l of He(y(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(l);if(u){let h=y(e,"generations",l),g=Number(u[1]);try{c.push({path:h,size:mr(h),live:Number.isSafeInteger(g)&&I(g)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(l))continue;let d=y(e,"generations",l),m;try{m=pe(d)}catch{continue}!m.isDirectory()||m.isSymbolicLink()||o.push({generationId:l,path:d,size:mr(d),...i[l]===void 0?{}:{unreferencedAt:i[l]}})}return{leases:s,generations:o,locks:a,temporaries:c}}function yr(t){if(t.ownershipChecksum!==Rt(t)||We(t.localCacheDir)!==We(st(t.projectRoot)))return!1;let e=B(ke()),r=B(y(e,"projects")),i=B(t.localCacheDir);if(!i.startsWith(`${r}${fr}`))return!1;try{let n=pe(e),s=pe(r),a=pe(i);if(!n.isDirectory()||n.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink()||!a.isDirectory()||a.isSymbolicLink())return!1;let o=pr(r);return pr(i).startsWith(`${o}${fr}`)}catch{return!1}}function ze(t,e=!1){for(let i of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let n=Ye(y(t.localCacheDir,i));if(n!==void 0&&I(n))return!0}let r=Ye(L(t.localCacheDir).lockPath);return r!==void 0&&I(r)}function Ri(t){try{let e=JSON.parse(E(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function Ye(t){try{let e=JSON.parse(E(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function wi(t){try{let e=JSON.parse(E(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function He(t){try{return Sr(t)}catch{return[]}}function mr(t){let e=0,r=[t];for(;r.length>0;){let i=r.pop();for(let n of Sr(i,{withFileTypes:!0})){let s=y(i,n.name);n.isDirectory()?r.push(s):n.isFile()&&(e+=pi(s).size)}}return e}var fe=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(e,r={}){this.root=e,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Ne(e)}initializeAfterOwnershipAcquired(){let e=Vt(this.root),r=Ut(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:e,prunedHistory:r}}observeLegacyRequest(e,r){Ft(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${e}`,now:()=>new Date(e)}),this.refreshStatus()}poll(e,r){if(this.active||e.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=$t(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(bi(i)),!0}catch(n){throw de(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Bt(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(de(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Ne(this.root)}};function bi(t){if(t.requests.length===1)return t.requests[0].detail;let r=[...new Set(t.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${t.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{randomUUID as xi}from"crypto";import{Worker as ki}from"worker_threads";var me=class{constructor(e){this.options=e;this.now=e.now??Date.now,this.setTimer=e.setTimer??setTimeout,this.clearTimer=e.clearTimer??clearTimeout}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}start(e){if(!this.canAccept())return!1;if(e.deadlineAtMs<this.now()){try{this.options.onReject(e,`${this.options.name} request expired before processing.`)}catch(s){this.closed=!0,this.options.onFatal(Je(s))}return!0}let r=this.ensureWorker(),i=Math.max(1,Math.min(2147483647,e.deadlineAtMs-this.now())),n=this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},i);this.active={request:e,timer:n};try{r.postMessage({kind:"request",...e})}catch(s){this.failActiveAfterTermination(Rr(s))}return!0}async close(e=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.active){await this.failActiveAfterTermination(e);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let e=this.options.createWorker(),r=++this.workerGeneration;return e.on("message",i=>this.handleMessage(r,i)),e.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`)}),e.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`))}),this.worker=e,e}handleMessage(e,r){if(e!==this.workerGeneration||this.closed||!this.active)return;let i=Ii(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status)}catch(s){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(Je(s));return}this.releaseActive(n)}async failActiveAfterTermination(e){if(this.activeFailure){await this.activeFailure;return}let r=this.active;if(!r){await this.terminateWorker();return}this.clearTimer(r.timer);let i=(async()=>{if(await this.terminateWorker()){try{this.options.onReject(r.request,e)}catch(s){this.closed=!0,this.options.onFatal(Je(s));return}this.releaseActive(r)}})();this.activeFailure=i;try{await i}finally{this.activeFailure===i&&(this.activeFailure=null)}}releaseActive(e){this.active===e&&(this.active=null,this.clearTimer(e.timer))}async terminateWorker(){if(this.terminating)return this.terminating;let e=this.worker;if(!e)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await e.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Rr(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function Ii(t){if(!t||typeof t!="object")return null;let e=t;if(e.kind!=="response"||typeof e.requestId!="string"||!("status"in e))return null;if(e.ok===!0){if(!("result"in e)||"error"in e)return null}else if(e.ok===!1){if("result"in e||typeof e.error!="string")return null}else return null;return e}function Je(t){return t instanceof Error?t:new Error(String(t))}function Rr(t){return t instanceof Error?t.message:String(t)}function wr(t){let e=()=>({protocolVersion:te,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return Ir({name:"TypeScript index",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:kt,createWorker:()=>xr(t,{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath}),complete(r,i,n,s){Ae(t.paths,r,{ok:!0,protocolVersion:te,id:i.id,baseGeneration:i.baseGeneration,response:n},{nowMs:s,limits:t.limits})},reject(r,i,n,s){qe(t.paths,r,{ok:!1,protocolVersion:te,id:i,error:n},n,{nowMs:s,limits:t.limits})},onBusy:t.onBusy,onFatal:t.onFatal})}function br(t){let e=()=>({protocolVersion:se,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return Ir({name:"TypeScript semantic",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:At,createWorker:()=>xr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,s){Ae(t.paths,r,{ok:!0,protocolVersion:se,id:i.id,generation:i.generation,response:n},{nowMs:s,limits:t.limits})},reject(r,i,n,s){qe(t.paths,r,{ok:!1,protocolVersion:se,id:i,error:n},n,{nowMs:s,limits:t.limits})},onBusy:t.onBusy,onFatal:t.onFatal})}function Ir(t){let e=t.now??Date.now,r=x(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${t.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${xi()}`,s={...t.limits,maxBatch:1},a=null,o=t.initialStatus(),c=!1,l=h=>{c=!0,t.onFatal(h)},u=new me({name:t.name,createWorker:t.createWorker,now:e,onComplete(h,g,p){let S=d(h.requestId);o=p,t.complete(S.claim,S.envelope,g,e()),m(S)},onReject(h,g,p){let S=d(h.requestId);p!==void 0&&(o=p),t.reject(S.claim,S.envelope.id,g,e()),m(S)},onStatus(h){o=h},onFatal:l});return{poll(){if(c||!u.canAccept())return 0;let h=wt(t.paths,{ownerId:n,nowMs:e(),limits:s,owner:i,liveness:{isProcessAlive:I,readProcessIdentity:x}})[0];if(!h)return 0;let g=h.requestId;try{let p=t.parseEnvelope(bt(h,s));if(g=p.id,p.id!==h.requestId)throw new Error(`${t.name} request identity does not match its mailbox path.`);if(p.deadlineAtMs<e())throw new Error(`${t.name} request expired before processing.`);if(a={claim:h,envelope:p},t.onBusy?.(p.deadlineAtMs),!u.start({requestId:p.id,deadlineAtMs:p.deadlineAtMs,payload:p}))throw new Error(`${t.name} worker lane closed admission after claiming a request.`)}catch(p){let S=Ti(p);try{t.reject(h,g,S,e()),a?.claim===h&&m(a)}catch(k){l(Wi(k))}}return 1},status(){return{...o,mailbox:It(t.paths)}},async close(h){await u.close(h)}};function d(h){let g=a;if(!g||g.envelope.id!==h)throw new Error(`${t.name} parent lost the active mailbox claim.`);return g}function m(h){a===h&&(a=null,t.onBusy?.(void 0))}}function xr(t,e){if(t.createWorker)return t.createWorker(e);let r=t.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new ki(r,{workerData:e})}function Wi(t){return t instanceof Error?t:new Error(String(t))}function Ti(t){return t instanceof Error?t.message:String(t)}var Ci=1e3,Mi=250,Ai=6e4,qi=10,_i=50,Li=250;function Oi(t,e=1){if(t>0)return qi;let r=Math.max(0,Math.min(3,e-1));return Math.min(Li,_i*2**r)}async function Di(t,e){let r=e.processIndexRequests(),i=e.processSemanticRequests(),n=r+i,s=n>0?0:t+1;if(e.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),e.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!0};let a=Oi(n,s);return await e.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:s,stopped:!1,delayMs:a}}function ji(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}async function Ni(t,e,r={}){let i=nr(t,e),n=i.projectRoot,s=ie(n);s.watch={...s.watch,...r};let a=ne(s);if(!a.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let o=K(n,s),c=L(o.cacheDir),l=x(R.pid),u=cr(c.lockPath,n,{readProcessIdentity:f=>f===R.pid?l:x(f)});if(!u.acquired)return;let d=new fe(c.refreshRequestsPath,{retryDelayMs:Math.max(1e3,a.cooldownMs)});d.initializeAfterOwnershipAcquired();let m=Date.now(),h=b(),g=m,p=h,S={state:"idle"},k,V,W,U,ge=ee(o.dbPath),Se=!1,Xe=!1,Ke=0,Qe=Number.NEGATIVE_INFINITY,Ze=Number.NEGATIVE_INFINITY,et=Number.NEGATIVE_INFINITY,tt=Number.NEGATIVE_INFINITY,ve,ye,rt=0,Re=Mt(o.cacheDir),we=xt(o.cacheDir);qt(Re),Ct(we);let w=(f=!1,C=f?"durable":"visibility")=>{if(!Xe)return;let J=Date.now(),X=b();!f&&X-Qe<Ci||(Qe=X,or(c.statePath,{version:1,protocolVersion:Le,pid:R.pid,...l?{processIdentity:l}:{},projectRoot:n,...i.worktreeId?{worktreeId:i.worktreeId}:{},cliVersion:e,startedAt:new Date(m).toISOString(),heartbeatAt:new Date(J).toISOString(),lastActivityAt:new Date(g).toISOString(),...a.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date(g+a.idleTimeoutMs).toISOString()},watcher:S,...S.state==="idle"&&k?{indexGeneration:k}:{},...V?{lastRefresh:V}:{},...W?{lastError:W}:{},reindexActivity:ge,refreshRequests:d.status(),typescriptSemantic:{...be.status(),...ve===void 0?{}:{busyUntil:new Date(ve).toISOString()}},typescriptIndex:{...Ie.status(),...ye===void 0?{}:{busyUntil:new Date(ye).toISOString()}}},{durability:C}))},P=()=>{g=Date.now(),p=b()},it=f=>{P(),U??=f,W={at:new Date().toISOString(),message:f.message},w(!0,"visibility")},be=br({paths:Re,projectRoot:n,onBusy(f){ve=f===void 0?void 0:f+5e3,w(!0,"visibility")},onFatal:it}),Ie=wr({paths:we,projectRoot:n,dbPath:o.dbPath,onBusy(f){ye=f===void 0?void 0:f+5e3,w(!0,"visibility")},onFatal:it}),H=new ae({projectRoot:n,config:{...s,watch:a},languages:s.languages,onStatus(f){S=f,f.state!=="idle"&&(k=void 0),f.state!=="idle"&&P(),w(!0)},onReindexComplete(){P();let f=Oe(n,s,o);return V=f.lastRefresh,k=f.state==="fresh"?De(o.dbPath)??void 0:void 0,ge=ee(o.dbPath),d.completeActive(),W=void 0,w(!0),f.state==="fresh"},onReindexError(){d.failActive()},onRefreshSuppressed(f){let C=yt(o.dbPath,f);C.state==="failed"&&(W={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${C.reason}`},w(!0,"visibility")),ge=ee(o.dbPath)},onError(f){P(),k=void 0,W={at:new Date().toISOString(),message:f.message},w(!0)}}),z=()=>{Se=!0};R.once("SIGINT",z),R.once("SIGTERM",z);let D=!1,Y,j;try{H.start();let f=Oe(n,s,o);V=f.lastRefresh,k=f.state==="fresh"?De(o.dbPath)??void 0:void 0;let C=ji(f.state);for(C&&H.requestRefresh(C,{immediate:!0}),P(),Xe=!0,w(!0);!Se;){let J=await Di(rt,{processIndexRequests:()=>Ie.poll(),processSemanticRequests:()=>be.poll(),afterMailboxPoll:({processedRequests:X})=>{let M=b();if(M-tt>=Ai&&(tt=M,_e(we),_e(Re)),M-et>=6e4&&(et=M,vr(n,e)),M-Ze>=Mi){Ze=M;let T=ar(c.activityPath);T&&T.atMs>g&&(g=T.atMs,p=M),T?.refreshRequestedAtMs!==void 0&&T.refreshRequestedAtMs>Ke&&(Ke=T.refreshRequestedAtMs,d.observeLegacyRequest(T.refreshRequestedAtMs,T.refreshDetail??"stale index observed by a legacy command")),d.poll(S,Wr=>{P(),H.requestRefresh({kind:"watch-demand",detail:Wr},{immediate:!0})})}X>0&&(P(),w(!0,"visibility")),w()},shouldStop:()=>Se||U!==void 0||hr({watcher:S,lastActivityAtMs:p,nowMs:b(),idleTimeoutMs:a.idleTimeoutMs}),wait:Gi});if(rt=J.consecutiveIdlePolls,J.stopped)break}}catch(f){D=!0,Y=f}finally{R.off("SIGINT",z),R.off("SIGTERM",z),await Promise.all([be.close("TypeScript semantic service stopped before completing the request."),Ie.close("TypeScript index service stopped before completing the request.")]);let f=await H.stop();f.state==="stopped"?(kr(c.statePath,{force:!0}),kr(c.activityPath,{force:!0}),u.release()):(W={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${f.reasons.join("; ")}`},w(!0),j=new Error(W.message))}if(!D&&U&&(D=!0,Y=U),D&&j)throw new AggregateError([Y,j],"Watch service execution and shutdown both failed.");if(D)throw Y;if(j)throw j}function Gi(t){return new Promise(e=>setTimeout(e,t))}function Fi(t,e={report:r=>console.error(r),exit:r=>R.exit(r)}){return e.report(`watch-service: ${Pt(t instanceof Error?t.message:String(t))}`),e.exit(1)}var $i=R.argv[1]?Pi(Ei(R.argv[1])).href:null;if($i===import.meta.url){let t=R.argv[2],e=R.argv[3],r=Bi(R.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),R.exitCode=1;else try{await Ni(t,e,r)}catch(i){Fi(i)}}function Bi(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{Di as runWatchServiceLoopIteration,Ni as runWatchServiceServer,ji as startupRefreshTrigger,Fi as terminateWatchServiceProcess,Oi as watchServiceLoopDelayMs};
|
|
1
|
+
import{b as Ke,c as Qe,f as ht,i as pt,j as re,k as ft,l as Te}from"./chunk-IUJ3ZFEE.js";import{b as Ct}from"./chunk-ZD3Z54IW.js";import{b as ie,c as vt,d as Rt,g as bt}from"./chunk-5ZJH6DDE.js";import{a as We,b as Pt,c as Wt,d as Et,e as Ee,f as Mt,g as Me,h as At,i as Lt,j as _t,k as Gt,l as Dt,m as jt,n as Ot}from"./chunk-G2F6T5BV.js";import{a as It}from"./chunk-MXNGIEPU.js";import{a as wt,c as ne}from"./chunk-UZFCZ7SJ.js";import"./chunk-Q7HB7BFJ.js";import{d as U,e as se,f as Ce,g as xt}from"./chunk-MEI3PTUK.js";import"./chunk-DHEQMPLW.js";import{a as oe,b as kt,c as Pe,d as Tt}from"./chunk-SEUJVWT2.js";import{z as mt}from"./chunk-AUP6YI5M.js";import{c as ct,d as we,q as lt}from"./chunk-SF7X6QNW.js";import{d as dt}from"./chunk-SDPA5DKN.js";import{a as ve}from"./chunk-DOPCR5BY.js";import{a as ut}from"./chunk-7IOAZRVL.js";import"./chunk-VWLIOEEF.js";import{a as M,g as be,q as gt,r as yt,s as Ie,t as xe,u as ke,v as St}from"./chunk-G6OGPXJW.js";import"./chunk-DRENNWRG.js";import"./chunk-H5EXS3HM.js";import"./chunk-HGFDYOVB.js";import{c as P,d as W}from"./chunk-3VLJ2DCA.js";import{E as et,F as B,G as tt,I as rt,J as te,L as $,O as it,P as nt,S as st,T as ot,U as Re,V as at,h as b,l as Ze}from"./chunk-4DCKBY6T.js";import v from"process";import{rmSync as yr}from"fs";import{resolve as Ri}from"path";import{pathToFileURL as wi}from"url";import{lstatSync as vr}from"fs";function Nt(t,e){let r=ae(t);if(r.kind!=="directory")throw new Error(`Watcher root is not a directory: ${t}`);if(!e)return{projectRoot:t,projectDirectory:r};let i=ae(e);if(i.kind!=="directory")throw new Error(`Git control path is not a directory: ${e}`);return{projectRoot:t,projectDirectory:r,gitControlDirectory:{path:e,identity:i}}}function qt(t){try{if(!Ft(t.projectDirectory,ae(t.projectRoot)))return!1;let e=t.gitControlDirectory;return!e||Ft(e.identity,ae(e.path))}catch{return!1}}function ae(t){let e=vr(t,{bigint:!0}),r=e.isDirectory()?"directory":e.isFile()?"file":void 0;if(!r||e.isSymbolicLink())throw new Error(`Unsupported watcher identity path: ${t}`);return{device:e.dev,inode:e.ino,birthtimeNs:e.birthtimeNs,kind:r}}function Ft(t,e){return t.device===e.device&&t.inode===e.inode&&t.birthtimeNs===e.birthtimeNs&&t.kind===e.kind}import{existsSync as Qt,lstatSync as wr,statSync as br}from"fs";import{basename as Ir,dirname as xr,isAbsolute as Le,join as T,relative as Zt,resolve as er}from"path";import{watch as kr}from"chokidar";import Tr from"ignore";var tr=5e3,le=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;pendingChanges=new Map;pendingChangesComplete=!0;pendingChangesIncompleteReason;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;preferFilesystemGitState=!0;watchGitLayout=null;localCacheWatchPath;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=se(e.config),this.outputDb=e.outputDb??T(et(this.projectRoot,e.config),"index.db"),this.preferFilesystemGitState=e.gitReader===void 0,this.localCacheWatchPath=Jr(this.projectRoot,xr(this.outputDb)),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??Mr,rr.set(this,Vr(e.stopTimeoutMs??tr,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??jr(),this.subscriptionFactory=e.subscriptionFactory??Ar,this.budgetInspector=e.budgetInspector??ft,ir.set(this,{gitReader:e.gitReader??it,languages:nr(e.languages??e.config.languages),stagedIndexEntries:null}),this.gitignoreFilter=ut(e.projectRoot),this.extraIgnore=Tr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,ce(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...ce(this).closures],n=Pr(this),o=this.clock.now()+n;return this.stopPromise=this.finishStop(e,i,r,o,n).catch(c=>{throw this.stopInProgress=!1,c}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`),!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=Jt(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,n)=>this.isIgnoredWatchPath(i,n?.isDirectory()??!1),usePolling:e,ignorePermissionErrors:!0,...e?{interval:5e3,binaryInterval:1e4}:{}});r.on("all",(i,n)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(i,n)}),r.on("error",i=>this.handleSourceWatcherError(r,i,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,i){if(this.markPendingChangesIncomplete("source-watcher-error"),i||this.sourcePollingFallbackStarted||!Nr(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(n=>n!==e),Wr(ce(this),e,n=>this.onError(n));try{this.startSourceWatcher(!0)}catch(n){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`))}}isIgnoredWatchPath(e,r){let i=this.relativeWatchPath(e);if(!i)return!1;if(Vt(i,this.localCacheWatchPath))return!0;let n=r?`${i}/`:i;return this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)}handleFileChange(e,r){let i=this.relativeWatchPath(r);if(!i||i===".."||i.startsWith("../")||Vt(i,this.localCacheWatchPath)||this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)||i.endsWith("index.db")||i.endsWith("index.scip")||i.endsWith("index.db.tmp")||Ir(i).startsWith(ht)||(i===".scipquery.json"&&Xt(this,this.projectRoot),!Yt(this,i)))return;let n=Or(e);n||this.markPendingChangesIncomplete(`unsupported-source-event:${e}`),this.scheduleReindex({kind:"watch-source",detail:i},n?[{path:i,kind:n}]:void 0,n!==void 0)}relativeWatchPath(e){let r=Le(e)?e:T(this.projectRoot,e);return Zt(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e,r,i=!1){this.pendingTrigger=Jt(this.pendingTrigger,e),i||this.markPendingChangesIncomplete(`unstructured-trigger:${e.kind}`);for(let o of r??[])this.recordPendingChange(o);if(this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let n=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:n}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget(),r=e.state!=="paused";if(e.state==="paused"&&e.reason!=="rebuild-count"){this.dirty=!0;let l=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:l,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,l-this.wallNow())));return}let i=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&i<this.watchConfig.cooldownMs){let l=this.watchConfig.cooldownMs-i;this.dirty=!0;let a=this.wallNow()+l;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},l);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let o=this.consumePendingChangeJournal(),c=this.wallNow();this.setStatus({state:"indexing",startedAt:c});let s=this.reindexRunner.start(this.reindexRequest(n,r,o));this.activeOperation=s,s.completion.then(l=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=!1;try{a=this.onReindexComplete(l,n,{pendingChanges:this.dirty})===!0}catch(u){this.onError(u instanceof Error?u:new Error(String(u)))}if(this.dirty&&!this.stopped){if(a){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.resetPendingChanges(),this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let u=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:u,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(l=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=l instanceof Error?l:new Error(String(l));this.restorePendingChangeJournal(o),this.onReindexError(a,n),this.onError(a),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===s&&(this.activeOperation=null)})}async finishStop(e,r,i,n,o){let c=[],s=e.map(async p=>{try{await p.close()}catch(h){c.push(`watch subscription close failed: ${String(h)}`)}});s.push(...r),i&&s.push((async()=>{try{let p=await i.cancel();p.state==="degraded"&&c.push(p.reason)}catch(p){c.push(`reindex cancellation failed: ${p instanceof Error?p.message:String(p)}`)}})());let l=s.length,a=s.map(p=>p.finally(()=>{l-=1})),u=await Cr(a,n,this.clock),d=ce(this);return c.push(...d.errors),d.errors=[],u?this.stopInProgress=!1:(c.push(`watch shutdown exceeded the ${o}ms deadline with ${l} operation(s) still pending`),Promise.all(a).then(()=>{this.stopInProgress=!1})),c.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:c.join("; ")}),{state:"degraded",reasons:c}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(e){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e,r=!0,i){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e,changeJournal:i,allowExpensiveRebuild:r}}setStatus(e){this.status=e,this.onStatus(e)}recordPendingChange(e){if(this.pendingChanges.size>=1024&&!this.pendingChanges.has(e.path)){this.pendingChanges.clear(),this.markPendingChangesIncomplete("change-entry-limit");return}let r=this.pendingChanges.get(e.path),i=Fr(r,e.kind);i===null?this.pendingChanges.delete(e.path):this.pendingChanges.set(e.path,i)}markPendingChangesIncomplete(e){this.pendingChangesComplete=!1,this.pendingChangesIncompleteReason??=e}consumePendingChangeJournal(){let e=lt(this.outputDb),r=[...this.pendingChanges.entries()].map(([c,s])=>({path:c,kind:s})).sort((c,s)=>c.path.localeCompare(s.path)),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;e||(i=!1,n??="accepted-generation-unavailable");let o={version:1,baseGeneration:e,complete:i,...n?{incompleteReason:n}:{},entries:r};return Te(o)||(o={version:1,baseGeneration:e,complete:!1,incompleteReason:"change-journal-byte-limit",entries:[]}),this.resetPendingChanges(),o}restorePendingChangeJournal(e){let r=[...this.pendingChanges.entries()].map(([o,c])=>({path:o,kind:c})),i=this.pendingChangesComplete,n=this.pendingChangesIncompleteReason;this.resetPendingChanges(),e.complete||this.markPendingChangesIncomplete(e.incompleteReason??"failed-reindex");for(let o of e.entries)this.recordPendingChange(o);i||this.markPendingChangesIncomplete(n??"failed-reindex");for(let o of r)this.recordPendingChange(o)}resetPendingChanges(){this.pendingChanges.clear(),this.pendingChangesComplete=!0,this.pendingChangesIncompleteReason=void 0}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(A(this).stagedIndexEntries=Kt(this.projectRoot,A(this).gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){if(this.reindexInFlight||this.stopped)return;let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let i=e.head!==r.head,n=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;if(!i&&!n)return;let o=A(this),c=o.stagedIndexEntries,s=Kt(this.projectRoot,o.gitReader);o.stagedIndexEntries=s;let l=zr(this.projectRoot,o.gitReader,e,r,c,s,i,n),a=null;if(l!==null&&(l.includes(".scipquery.json")&&Xt(this,this.projectRoot),a=l.filter(d=>Yt(this,d)),a.length===0))return;let u=a?.map(d=>({path:d,kind:Qt(T(this.projectRoot,d))?"change":"delete"}));i&&n?this.scheduleReindex({kind:"watch-git-state",detail:Ae("HEAD and index changed",a)},u,u!==void 0):i?this.scheduleReindex({kind:"watch-git-head",detail:Ae("HEAD changed",a)},u,u!==void 0):n&&this.scheduleReindex({kind:"watch-git-index",detail:Ae(r.indexPath??"index changed",a)},u,u!==void 0)}readGitState(){if(this.preferFilesystemGitState){let e=this.readFilesystemGitState();if(e)return e}return this.readGitStateFromGit()}readFilesystemGitState(){let e=this.watchGitLayout??qr(this.projectRoot);if(!e)return null;this.watchGitLayout=e;let r=Br(e.gitDir);return r?Ht(r,e.indexPath):null}readGitStateFromGit(){let e=A(this).gitReader,r=Re(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let i=at(this.projectRoot,r);return Ht(Re(this.projectRoot,["rev-parse","--verify","HEAD"],e),i)}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Cr(t,e,r){if(t.length===0)return!0;let i=Promise.all(t).then(()=>!0),n=Math.max(0,e-r.now()),o=null,c=new Promise(l=>{o=r.setTimeout(()=>l(!1),n)}),s=await Promise.race([i,c]);return s&&o&&r.clearTimeout(o),s}var $t=new WeakMap,rr=new WeakMap,ir=new WeakMap;function ce(t){let e=$t.get(t);if(e)return e;let r={closures:new Set,errors:[]};return $t.set(t,r),r}function Pr(t){return rr.get(t)??tr}function A(t){let e=ir.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function Wr(t,e,r){let i=Promise.resolve().then(()=>e.close()).catch(n=>{let o=`watch subscription close failed during polling fallback: ${String(n)}`;t.errors.push(o),r(new Error(o))});t.closures.add(i),i.then(()=>t.closures.delete(i))}function Er(t,e=P){let{projectRoot:r,config:i,languages:n,pnpmWorkspaces:o,typescriptProjectMode:c,typescriptProjects:s,clojureConfigPath:l,indexerConcurrency:a,trigger:u}=t,d=U(r),p=Object.keys(d).length>0?d:i,h=te(r,p),g=p.indexer?.typescript,f=p.indexer?.clojure,y=e(process.pid);if(!y)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:r,SCIP_REINDEX_OUTPUT_SCIP:h.indexPath,SCIP_REINDEX_OUTPUT_DB:h.dbPath,SCIP_REINDEX_LANGUAGES:(p.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(p.indexerConcurrency??a??""),SCIP_REINDEX_PNPM_WORKSPACES:g?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:g?.projectMode??c,projects:g?.projects??s??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:f?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_CHANGE_JOURNAL:t.changeJournal?Te(t.changeJournal)??"":"",SCIP_REINDEX_ALLOW_EXPENSIVE:t.allowExpensiveRebuild===!1?"0":"1",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(y)}}}var Mr={now:W,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Ar=(t,e)=>kr(t,e),Lr=15*6e4,_r=1e3,Gr=64*1024;function Dr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function Ut(t,e){let r=t instanceof Error?t.message:String(t),i=e.stderrTail.trim()||e.stdoutTail.trim();return i?`${r}
|
|
2
|
+
${i}`:r}function jr(t={}){let e=t.timeoutMs??Lr,r=t.terminationGraceMs??_r,i=t.maxOutputBytes??Gr,n=t.resolveLaunch??Er;return{start(o){let c=n(o),s=new AbortController,l=Dr(),a=!1,u=Qe({command:process.execPath,args:[...process.execArgv,c.workerPath],label:"watch reindex worker",env:c.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:s.signal,detached:!0}).then(d=>{if(l={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated},d.status!==0)throw new Error(Ut(new Error(`Reindex worker exited with ${d.signal?`signal ${d.signal}`:`code ${d.status}`}`),l));return d.durationMs}).catch(d=>{throw d instanceof Ke&&(l={stdoutTail:d.stdout,stderrTail:d.stderr,stdoutTruncated:d.stdoutTruncated,stderrTruncated:d.stderrTruncated}),new Error(Ut(d,l),{cause:d})}).finally(()=>{a=!0});return{completion:u,async cancel(){a||s.abort();try{await u}catch{}return{state:"exited",diagnostics:l}},diagnostics:()=>l}}}}function Jt(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function Or(t){if(t==="add")return"add";if(t==="change")return"change";if(t==="unlink")return"delete"}function Fr(t,e){return t?t==="add"?e==="delete"?null:"add":t==="delete"&&e==="add"?"change":e:e}function Nr(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}var _e=/^[0-9a-f]{40,64}$/i;function Vt(t,e){return t===".git"||t.startsWith(".git/")||t==="node_modules"||t.startsWith("node_modules/")||t.endsWith("/node_modules")||t.includes("/node_modules/")?!0:e!==void 0&&(t===e||t.startsWith(`${e}/`))}function qr(t){let e=T(t,".git");try{let r=wr(e),i;if(r.isDirectory())i=e;else if(r.isFile()){let n=/^gitdir:\s*(.+)\s*$/m.exec(b(e,"Git directory marker"));if(!n?.[1])return null;let o=n[1].trim();i=Le(o)?o:er(t,o)}else return null;return Qt(i)?{gitDir:i,indexPath:T(i,"index")}:null}catch{return null}}function Br(t){let e;try{e=b(T(t,"HEAD"),"Git HEAD").trim()}catch{return}if(_e.test(e))return e.toLowerCase();let r=/^ref:\s*(.+)$/.exec(e)?.[1]?.trim();if(!r)return;let i=$r(t);return zt(t,r)??zt(i,r)??Ur(i,r)}function $r(t){try{let e=b(T(t,"commondir"),"Git common-directory marker").trim();return e?Le(e)?e:er(t,e):t}catch{return t}}function zt(t,e){try{let r=b(T(t,e),"Git reference").trim();return _e.test(r)?r.toLowerCase():void 0}catch{return}}function Ur(t,e){try{for(let r of b(T(t,"packed-refs"),"Git packed references").split(`
|
|
3
|
+
`)){if(r.startsWith("#")||r.startsWith("^"))continue;let i=r.indexOf(" ");if(i===-1)continue;let n=r.slice(0,i);if(r.slice(i+1).trim()===e&&_e.test(n))return n.toLowerCase()}}catch{return}}function Ht(t,e){let r={head:t,indexPath:e};try{let i=br(e);r.indexMtimeMs=i.mtimeMs,r.indexSize=i.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}function Jr(t,e){let r=Zt(t,e).replaceAll("\\","/");if(!(!r||r===".."||r.startsWith("../")))return r}function Vr(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function nr(t){return t&&t.length>0?[...t]:ve}function Xt(t,e){try{A(t).languages=nr(U(e).languages)}catch{A(t).languages=ve}}function Yt(t,e){return Ze(e,A(t).languages)!=="other"}function zr(t,e,r,i,n,o,c,s){let l=new Set;if(c){if(!r.head||!i.head)return null;let a=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,i.head,"--"]);if(a.kind!=="success")return null;for(let u of Hr(a.output))l.add(u)}if(s){if(n===null||o===null)return null;for(let a of Yr(n,o))l.add(a)}return[...l].sort()}function Kt(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?Xr(r.output):null}function Hr(t){return t.split("\0").filter(e=>e.length>0)}function Xr(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let i=0;i<e.length;i+=2){let n=e[i],o=e[i+1];if(!n.startsWith(":")||!o)return null;r.set(o,n)}return r}function Yr(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(i=>t.get(i)!==e.get(i))}function Ae(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{existsSync as de,lstatSync as J,readdirSync as ar,realpathSync as sr,rmSync as G,statSync as Kr}from"fs";import{join as S,resolve as V,sep as cr}from"path";var Qr=3600*1e3,Zr=2*1024*1024*1024,ue=300*1e3,ei="gc-state.json",ti="gc.lock";function ri(t){let e=t.leases.filter(s=>s.managed&&!s.live&&!s.busy),r=ii(t.leases,t.locks),i={};for(let s of t.generations)r.has(s.generationId)||(i[s.generationId]=s.unreferencedAt??t.nowMs);let n=t.generations.filter(s=>!r.has(s.generationId)).sort((s,l)=>i[s.generationId]-i[l.generationId]||s.generationId.localeCompare(l.generationId)),o=new Set;for(let s of n)t.nowMs-i[s.generationId]>=t.policy.generationTtlMs&&o.add(s.generationId);let c=t.generations.filter(s=>!o.has(s.generationId)).reduce((s,l)=>s+l.size,0);for(let s of n){if(c<=t.policy.budgetBytes)break;o.has(s.generationId)||(o.add(s.generationId),c-=s.size)}for(let s of o)delete i[s];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(s=>o.has(s.generationId)),deleteLocks:t.locks.filter(s=>!s.live),deleteTemporaries:t.temporaries.filter(s=>!s.live),protectedGenerationIds:[...r].sort(),unreferencedSince:i}}function ii(t,e){let r=new Set(t.filter(i=>i.managed&&(i.live||i.busy)).flatMap(i=>[i.lease.baseGenerationId,i.lease.activeGenerationId]).filter(i=>i!==void 0));for(let i of e)i.live&&r.add(i.generationId);return r}function lr(t,e,r={}){if(!rt())return{kind:"disabled"};let i=r.repositoryId===void 0?nt(t)?.repositoryId:r.repositoryId;if(!i)return{kind:"unavailable"};let n=S(B(),"repositories",i),o=(r.now??Date.now)(),c=de(n)?dr(t,n,i,e,o,r):{kind:"unavailable"};return ni(t,i,e,o,r),c}function dr(t,e,r,i,n,o){let c=S(e,"gc-state.json"),s=ci(c);if(!o.force&&s&&n-Date.parse(s.lastSweepAt)<ue)return{kind:"throttled",sweptAt:s.lastSweepAt};let l=ct(e,{now:()=>n});if(!l)return{kind:"busy"};try{let a=si(t,e,r,s?.unreferencedSince??{}),u=ri({nowMs:n,...a,policy:{generationTtlMs:o.policy?.generationTtlMs??Qr,budgetBytes:o.policy?.budgetBytes??Zr}}),d=0,p=0;for(let f of u.deleteWorktrees){if(!je(f.lease))continue;if(!de(f.lease.localCacheDir)){G(f.leasePath,{force:!0}),p+=1;continue}if(!oi(f.lease))continue;let y=we(S(f.lease.localCacheDir,"cache-lifecycle.lock"));if(y)try{if(Ge(f.lease,!0))continue;try{_t({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:i})}catch{continue}if(Ge(f.lease,!0))continue;G(f.lease.localCacheDir,{recursive:!0,force:!0}),G(f.leasePath,{force:!0}),p+=1}finally{y.release()}}for(let f of u.deleteLocks)G(f.path,{force:!0});for(let f of u.deleteTemporaries)G(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)G(f.path,{recursive:!0,force:!0}),d+=f.size;dt(S(e,"evidence.db"));let h={kind:"swept",sweptAt:new Date(n).toISOString(),deletedWorktrees:p,deletedGenerations:u.deleteGenerations.length,deletedBytes:d,protectedGenerations:u.protectedGenerationIds.length},g={version:1,lastSweepAt:h.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:h};return be(c,g,{spacing:2,trailingNewline:!0}),h}catch(a){return{kind:"failed",error:a instanceof Error?a.message:String(a)}}finally{l.release()}}function ni(t,e,r,i,n){let o=S(B(),"repositories");if(!de(o))return;let c=S(o,ei),s=li(c);if(!n.force&&s!==void 0&&i-s<ue)return;let l=we(S(o,ti));if(l)try{for(let a of z(o)){if(a===e||!/^[a-f0-9]{24}$/.test(a))continue;let u=S(o,a),d;try{d=J(u)}catch{continue}if(!d.isDirectory()||d.isSymbolicLink())continue;let p=ai(u)??t;dr(p,u,a,r,i,n)}be(c,{version:1,lastSweepAt:new Date(i).toISOString()},{spacing:2,trailingNewline:!0})}finally{l.release()}}function si(t,e,r,i){let n=new Set(ot(t).map(a=>V(a.path))),o=[];for(let a of z(S(e,"worktrees"))){if(!a.endsWith(".json"))continue;let u=S(e,"worktrees",a),d=ur(u);if(!d)continue;let p=V(d.projectRoot);o.push({leasePath:u,lease:d,managed:d.repositoryId===r&&je(d),live:n.has(p)||de(p),busy:Ge(d)})}let c=[];for(let a of z(S(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(a);if(!u)continue;let d=S(e,"locks",a),p=De(d),h=p!==void 0&&M(p),g=u[1];c.push({generationId:g,path:d,live:h})}let s=[],l=[];for(let a of z(S(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(a);if(u){let h=S(e,"generations",a),g=Number(u[1]);try{l.push({path:h,size:or(h),live:Number.isSafeInteger(g)&&M(g)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(a))continue;let d=S(e,"generations",a),p;try{p=J(d)}catch{continue}!p.isDirectory()||p.isSymbolicLink()||s.push({generationId:a,path:d,size:or(d),...i[a]===void 0?{}:{unreferencedAt:i[a]}})}return{leases:o,generations:s,locks:c,temporaries:l}}function je(t){if(t.ownershipChecksum!==mt(t)||$(t.localCacheDir)!==$(tt(t.projectRoot)))return!1;let e=$(S(B(),"projects"));return $(t.localCacheDir).startsWith(`${e}${cr}`)}function oi(t){if(!je(t))return!1;let e=V(B()),r=V(S(e,"projects")),i=V(t.localCacheDir);try{let n=J(e),o=J(r),c=J(i);if(!n.isDirectory()||n.isSymbolicLink()||!o.isDirectory()||o.isSymbolicLink()||!c.isDirectory()||c.isSymbolicLink())return!1;let s=sr(r);return sr(i).startsWith(`${s}${cr}`)}catch{return!1}}function ai(t){for(let e of z(S(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=ur(S(t,"worktrees",e));if(r)return r.projectRoot}}function Ge(t,e=!1){for(let i of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let n=De(S(t.localCacheDir,i));if(n!==void 0&&M(n))return!0}let r=De(ne(t.localCacheDir).lockPath);return r!==void 0&&M(r)}function ur(t){try{let e=JSON.parse(b(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function De(t){try{let e=JSON.parse(b(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function ci(t){try{let e=JSON.parse(b(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function li(t){try{let e=JSON.parse(b(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function z(t){try{return ar(t)}catch{return[]}}function or(t){let e=0,r=[t];for(;r.length>0;){let i=r.pop();for(let n of ar(i,{withFileTypes:!0})){let o=S(i,n.name);n.isDirectory()?r.push(o):n.isFile()&&(e+=Kr(o).size)}}return e}var he=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(e,r={}){this.root=e,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Me(e)}initializeAfterOwnershipAcquired(){let e=Mt(this.root),r=At(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:e,prunedHistory:r}}observeLegacyRequest(e,r){Pt(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${e}`,now:()=>new Date(e)}),this.refreshStatus()}poll(e,r){if(this.active||e.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=Wt(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(di(i)),!0}catch(n){throw Ee(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Et(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(Ee(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Me(this.root)}};function di(t){if(t.requests.length===1)return t.requests[0].detail;let r=[...new Set(t.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${t.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{randomUUID as hi}from"crypto";import{Worker as pi}from"worker_threads";var pe=class{constructor(e){this.options=e;if(this.now=e.now??Date.now,this.setTimer=e.setTimer??setTimeout,this.clearTimer=e.clearTimer??clearTimeout,e.maxWorkerFailureRetries!==void 0&&(!Number.isInteger(e.maxWorkerFailureRetries)||e.maxWorkerFailureRetries<0))throw new Error("Worker maxWorkerFailureRetries must be a non-negative integer.")}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;idleTimer=null;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}hasWorker(){return this.worker!==null}start(e){if(!this.canAccept())return!1;if(this.clearIdleTimer(),e.deadlineAtMs<this.now()){try{this.options.onReject(e,`${this.options.name} request expired before processing.`)}catch(n){this.closed=!0,this.options.onFatal(Oe(n))}return!0}let r=this.ensureWorker(),i=this.deadlineTimer(e);this.active={request:e,timer:i,workerFailureRetries:0,workerFailureReasons:[]};try{r.postMessage({kind:"request",...e})}catch(n){this.failActiveAfterTermination(Fe(n),!0)}return!0}async close(e=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.clearIdleTimer(),this.active){await this.failActiveAfterTermination(e);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let e=this.options.createWorker(),r=++this.workerGeneration;return e.on("message",i=>this.handleMessage(r,i)),e.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`,!0)}),e.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`,!0))}),this.worker=e,e}handleMessage(e,r){if(e!==this.workerGeneration||this.closed||!this.active)return;let i=ui(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active,o;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status),o=this.options.retireAfterResponse?.(i.status)??!1}catch(c){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(Oe(c));return}this.releaseActive(n),o?this.terminateWorker():this.scheduleIdleTermination()}async failActiveAfterTermination(e,r=!1){if(this.activeFailure){await this.activeFailure;return}let i=this.active;if(!i){await this.terminateWorker();return}this.clearTimer(i.timer),r&&i.workerFailureReasons.push(e);let n=(async()=>{if(!await this.terminateWorker())return;let c=this.options.maxWorkerFailureRetries??0;if(r&&!this.closed&&i.workerFailureRetries<c&&this.now()<=i.request.deadlineAtMs){i.workerFailureRetries+=1;try{let l=this.ensureWorker();i.timer=this.deadlineTimer(i.request),l.postMessage({kind:"request",...i.request});return}catch(l){let a=`Cold Worker retry failed: ${Fe(l)}`;if(i.workerFailureReasons.push(a),e=`${e} ${a}`,!await this.terminateWorker())return}}let s=i.workerFailureReasons.length===0?e:[...new Set([...i.workerFailureReasons,e])].join(" Cold Worker retry: ");try{this.options.onReject(i.request,s)}catch(l){this.closed=!0,this.options.onFatal(Oe(l));return}this.releaseActive(i)})();this.activeFailure=n;try{await n}finally{this.activeFailure===n&&(this.activeFailure=null)}}deadlineTimer(e){let r=Math.max(1,Math.min(2147483647,e.deadlineAtMs-this.now()));return this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},r)}releaseActive(e){this.active===e&&(this.active=null,this.clearTimer(e.timer))}scheduleIdleTermination(){let e=this.options.idleTtlMs;!e||e<=0||this.closed||this.active||!this.worker||(this.clearIdleTimer(),this.idleTimer=this.setTimer(()=>{this.idleTimer=null,!(this.closed||this.active||!this.worker)&&this.terminateWorker()},e))}clearIdleTimer(){this.idleTimer&&(this.clearTimer(this.idleTimer),this.idleTimer=null)}async terminateWorker(){if(this.clearIdleTimer(),this.terminating)return this.terminating;let e=this.worker;if(!e)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await e.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Fe(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function ui(t){if(!t||typeof t!="object")return null;let e=t;if(e.kind!=="response"||typeof e.requestId!="string"||!("status"in e))return null;if(e.ok===!0){if(!("result"in e)||"error"in e)return null}else if(e.ok===!1){if("result"in e||typeof e.error!="string")return null}else return null;return e}function Oe(t){return t instanceof Error?t:new Error(String(t))}function Fe(t){return t instanceof Error?t.message:String(t)}var fi=6e4,mi=10*6e4;function hr(t){let e=t.maxActiveSessions??8,r=t.workerSoftMemoryMb??yi(),i=()=>({protocolVersion:ie,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,sessionsEvicted:0,activeSessions:0,maxActiveSessions:e,softMemoryLimitBytes:r*1024*1024,retireRequested:!1,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return fr({name:"TypeScript index",paths:t.paths,now:t.now,limits:t.limits,initialStatus:i,parseEnvelope:Rt,createWorker:()=>gr(t,{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath,maxActiveSessions:e,softMemoryLimitMb:r}),complete(n,o,c,s){Ie(t.paths,n,{ok:!0,protocolVersion:ie,id:o.id,baseGeneration:o.baseGeneration,response:c},{nowMs:s,limits:t.limits})},reject(n,o,c,s){xe(t.paths,n,{ok:!1,protocolVersion:ie,id:o,error:c},c,{nowMs:s,limits:t.limits})},idleTtlMs:t.workerIdleMs??mi,maxWorkerFailureRetries:1,retireAfterResponse:n=>n.retireRequested===!0,statusWhenWorkerAbsent:n=>({...n,state:"idle",activeSessions:0,heapUsedBytes:0,retireRequested:!1}),onBusy:t.onBusy,onFatal:t.onFatal})}function pr(t){let e=()=>({protocolVersion:oe,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return fr({name:"TypeScript semantic",paths:t.paths,now:t.now,limits:t.limits,initialStatus:e,parseEnvelope:Tt,createWorker:()=>gr(t,{kind:"semantic",projectRoot:t.projectRoot}),complete(r,i,n,o){Ie(t.paths,r,{ok:!0,protocolVersion:oe,id:i.id,generation:i.generation,response:n},{nowMs:o,limits:t.limits})},reject(r,i,n,o){xe(t.paths,r,{ok:!1,protocolVersion:oe,id:i,error:n},n,{nowMs:o,limits:t.limits})},idleTtlMs:fi,onBusy:t.onBusy,onFatal:t.onFatal})}function fr(t){let e=t.now??Date.now,r=P(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${t.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${hi()}`,o={...t.limits,maxBatch:1},c=null,s=t.initialStatus(),l=!1,a=h=>{l=!0,t.onFatal(h)},u=new pe({name:t.name,createWorker:t.createWorker,now:e,idleTtlMs:t.idleTtlMs,maxWorkerFailureRetries:t.maxWorkerFailureRetries,retireAfterResponse:t.retireAfterResponse,onComplete(h,g,f){let y=d(h.requestId);s=f,t.complete(y.claim,y.envelope,g,e()),p(y)},onReject(h,g,f){let y=d(h.requestId);f!==void 0&&(s=f),t.reject(y.claim,y.envelope.id,g,e()),p(y)},onStatus(h){s=h},onFatal:a});return{poll(){if(l||!u.canAccept())return 0;let h=gt(t.paths,{ownerId:n,nowMs:e(),limits:o,owner:i,liveness:{isProcessAlive:M,readProcessIdentity:P}})[0];if(!h)return 0;let g=h.requestId;try{let f=t.parseEnvelope(yt(h,o));if(g=f.id,f.id!==h.requestId)throw new Error(`${t.name} request identity does not match its mailbox path.`);if(f.deadlineAtMs<e())throw new Error(`${t.name} request expired before processing.`);if(c={claim:h,envelope:f},t.onBusy?.(f.deadlineAtMs),!u.start({requestId:f.id,deadlineAtMs:f.deadlineAtMs,payload:f}))throw new Error(`${t.name} worker lane closed admission after claiming a request.`)}catch(f){let y=vi(f);try{t.reject(h,g,y,e()),c?.claim===h&&p(c)}catch(D){a(Si(D))}}return 1},status(){return{...u.hasWorker()||!t.statusWhenWorkerAbsent?s:t.statusWhenWorkerAbsent(s),mailbox:St(t.paths)}},async close(h){await u.close(h)}};function d(h){let g=c;if(!g||g.envelope.id!==h)throw new Error(`${t.name} parent lost the active mailbox claim.`);return g}function p(h){c===h&&(c=null,t.onBusy?.(void 0))}}var gi=8192;function mr(){let t=Number.parseInt(process.env.SCIP_TS_WORKER_HEAP_MB??"",10);return Number.isFinite(t)&&t>0?t:gi}function yi(){return Math.max(1,Math.floor(mr()*.7))}function gr(t,e){if(t.createWorker)return t.createWorker(e);let r=t.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new pi(r,{workerData:e,resourceLimits:{maxOldGenerationSizeMb:mr()}})}function Si(t){return t instanceof Error?t:new Error(String(t))}function vi(t){return t instanceof Error?t.message:String(t)}var Sr=2e3,bi=5e3,Ii=5e3,xi=6e4,ki=10,Ti=50,Ci=1e4;function Pi(t,e=1){if(t>0)return ki;let r=Math.max(0,Math.min(8,e-1));return Math.min(Ci,Ti*2**r)}function Wi(t,e){let r;return{begin(){return r||(e.requestStop(),e.closeWake(),r=t.stop(),r.catch(()=>{})),r}}}async function Ei(t,e){let r=e.processIndexRequests(),i=e.processSemanticRequests(),n=r+i,o=n>0?0:t+1;if(e.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),e.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!0};let c=Pi(n,o);return await e.wait(c),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!1,delayMs:c}}function Mi(t){return t==="fresh"?null:{kind:"watch-startup",detail:`index ${t} when watch service started`}}async function Ai(t,e,r={}){let i=Lt(t,e),n=i.projectRoot,o=i.worktreeKind==="git"?Li(n,i.worktreeId):void 0,c=Nt(n,o),s=U(n);s.watch={...s.watch,...r};let l=se(s);if(!l.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let a=te(n,s),u=ne(a.cacheDir),d=P(v.pid),p=jt(u.lockPath,n,{readProcessIdentity:m=>m===v.pid?d:P(m)});if(!p.acquired)return;let h=new he(u.refreshRequestsPath,{retryDelayMs:Math.max(1e3,l.cooldownMs)});h.initializeAfterOwnershipAcquired();let g=Date.now(),f=W(),y=g,D=f,j={state:"idle"},L,H,C,X,fe=re(a.dbPath),Y=!1,Ne=!1,qe=0,Be=Number.NEGATIVE_INFINITY,$e=Number.NEGATIVE_INFINITY,Ue=Number.NEGATIVE_INFINITY,Je=Number.NEGATIVE_INFINITY,Ve=Number.NEGATIVE_INFINITY,me,ge,ze=0,O=kt(a.cacheDir),F=vt(a.cacheDir);Ct(O),bt(F);let He=We([F.pendingDir,F.legacyRequestDir,O.pendingDir,O.legacyRequestDir,u.refreshRequestsPath]),K,R=(m=!1,w=m?"durable":"visibility")=>{if(!Ne)return;let _=Date.now(),I=W();!m&&I-Be<Sr||(Be=I,Gt(u.statePath,{version:1,protocolVersion:wt,pid:v.pid,...d?{processIdentity:d}:{},projectRoot:n,...i.worktreeId?{worktreeId:i.worktreeId}:{},cliVersion:e,startedAt:new Date(g).toISOString(),heartbeatAt:new Date(_).toISOString(),lastActivityAt:new Date(y).toISOString(),...l.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date(y+l.idleTimeoutMs).toISOString()},watcher:j,...j.state==="idle"&&L?{indexGeneration:L}:{},...H?{lastRefresh:H}:{},...C?{lastError:C}:{},reindexActivity:fe,refreshRequests:h.status(),typescriptSemantic:{...ye.status(),...me===void 0?{}:{busyUntil:new Date(me).toISOString()}},typescriptIndex:{...Se.status(),...ge===void 0?{}:{busyUntil:new Date(ge).toISOString()}}},{durability:w}))},E=()=>{y=Date.now(),D=W()},Xe=m=>{E(),X??=m,C={at:new Date().toISOString(),message:m.message},R(!0,"visibility")},ye=pr({paths:O,projectRoot:n,onBusy(m){me=m===void 0?void 0:m+5e3,R(!0,"visibility")},onFatal:Xe}),Se=hr({paths:F,projectRoot:n,dbPath:a.dbPath,...s.indexer?.typescript?.maxWarmSessions===void 0?{}:{maxActiveSessions:s.indexer.typescript.maxWarmSessions},...s.indexer?.typescript?.workerIdleMs===void 0?{}:{workerIdleMs:s.indexer.typescript.workerIdleMs},...s.indexer?.typescript?.workerSoftMemoryMb===void 0?{}:{workerSoftMemoryMb:s.indexer.typescript.workerSoftMemoryMb},onBusy(m){ge=m===void 0?void 0:m+5e3,R(!0,"visibility")},onFatal:Xe}),Q=new le({projectRoot:n,config:{...s,watch:l},outputDb:a.dbPath,languages:s.languages,onStatus(m){j=m,m.state!=="idle"&&(L=void 0),m.state!=="idle"&&E(),R(!0)},onReindexComplete(m,w,_){E();let I=_?.pendingChanges!==!1?Ce(n,s,a):xt(a);return H=I.lastRefresh,L=I.state==="fresh"?Pe(a.dbPath)??void 0:void 0,fe=re(a.dbPath),h.completeActive(),C=void 0,R(!0),I.state==="fresh"},onReindexError(){h.failActive()},onRefreshSuppressed(m){let w=pt(a.dbPath,m);w.state==="failed"&&(C={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${w.reason}`},R(!0,"visibility")),fe=re(a.dbPath)},onError(m){E(),L=void 0,C={at:new Date().toISOString(),message:m.message},R(!0)}}),Ye=Wi(Q,{requestStop(){Y=!0},closeWake(){He.close()}}),Z=()=>{Ye.begin()};v.once("SIGINT",Z),v.once("SIGTERM",Z);let N=!1,ee,q;try{Q.start();let m=Ce(n,s,a);H=m.lastRefresh,L=m.state==="fresh"?Pe(a.dbPath)??void 0:void 0;let w=Mi(m.state);for(E(),Ne=!0,R(!0),K=setInterval(()=>R(),Sr),K.unref?.(),w&&Q.requestRefresh(w,{immediate:!0});!Y;){let _=await Ei(ze,{processIndexRequests:()=>Se.poll(),processSemanticRequests:()=>ye.poll(),afterMailboxPoll:({processedRequests:I})=>{let k=W();if(k-Ue>=Ii&&(Ue=k,!qt(c))){Y=!0;return}if(k-Ve>=xi&&(Ve=k,ke(F),ke(O)),k-Je>=ue&&(Je=k,lr(n,e)),k-$e>=bi){$e=k;let x=Dt(u.activityPath);x&&x.atMs>y&&(y=x.atMs,D=k),x?.refreshRequestedAtMs!==void 0&&x.refreshRequestedAtMs>qe&&(qe=x.refreshRequestedAtMs,h.observeLegacyRequest(x.refreshRequestedAtMs,x.refreshDetail??"stale index observed by a legacy command"))}h.poll(j,x=>{E(),Q.requestRefresh({kind:"watch-demand",detail:x},{immediate:!0})}),I>0&&(E(),R(!0,"visibility")),R()},shouldStop:()=>Y||X!==void 0||Ot({watcher:j,lastActivityAtMs:D,nowMs:W(),idleTimeoutMs:l.idleTimeoutMs}),wait:I=>He.wait(I)});if(ze=_.consecutiveIdlePolls,_.stopped)break}}catch(m){N=!0,ee=m}finally{v.off("SIGINT",Z),v.off("SIGTERM",Z),K!==void 0&&clearInterval(K);let m=Ye.begin();await Promise.all([ye.close("TypeScript semantic service stopped before completing the request."),Se.close("TypeScript index service stopped before completing the request.")]);let w=await m;w.state==="stopped"?(yr(u.statePath,{force:!0}),yr(u.activityPath,{force:!0}),p.release()):(C={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${w.reasons.join("; ")}`},R(!0),q=new Error(C.message))}if(!N&&X&&(N=!0,ee=X),N&&q)throw new AggregateError([ee,q],"Watch service execution and shutdown both failed.");if(N)throw ee;if(q)throw q}function Li(t,e){let r=st(t);if(r.kind!=="worktree"||r.identity.worktreeId!==e)throw new Error(`Git worktree identity changed while starting the watch service for ${t}.`);return r.identity.gitDir}function _i(t,e={report:r=>console.error(r),exit:r=>v.exit(r)}){return e.report(`watch-service: ${It(t instanceof Error?t.message:String(t))}`),e.exit(1)}var Gi=v.argv[1]?wi(Ri(v.argv[1])).href:null;if(Gi===import.meta.url){let t=v.argv[2],e=v.argv[3],r=Di(v.argv[4]);if(!t||!e)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Ai(t,e,r)}catch(i){_i(i)}}function Di(t){if(!t)return{};try{let e=JSON.parse(t);return e&&typeof e=="object"?e:{}}catch{return{}}}export{We as createPathChangeWake,Wi as createWatchServiceShutdown,Ei as runWatchServiceLoopIteration,Ai as runWatchServiceServer,Mi as startupRefreshTrigger,_i as terminateWatchServiceProcess,Pi as watchServiceLoopDelayMs};
|
|
3
4
|
//# sourceMappingURL=watch-server.js.map
|