codebaseiq 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +59 -2
- package/README.md +1 -1
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-WH5SYOMD.js → chunk-2E6OUPCF.js} +2 -2
- package/dist/chunk-2I2UHZET.js +2 -0
- package/dist/{chunk-CSZOQ7YO.js → chunk-2OMXFE64.js} +2 -2
- package/dist/{chunk-57KFVPVZ.js → chunk-2XBJRZEM.js} +2 -2
- package/dist/{chunk-PFPHS4NO.js → chunk-2Z7K66D7.js} +2 -2
- package/dist/{chunk-5WXOEJ4G.js → chunk-356EZBIP.js} +2 -2
- package/dist/{chunk-DLC6JDN7.js → chunk-3H2H5ODK.js} +2 -2
- package/dist/{chunk-HBQGKMM3.js → chunk-3LQJRS4I.js} +2 -2
- package/dist/{chunk-H3CKAL6P.js → chunk-3ON3A2QV.js} +2 -2
- package/dist/{chunk-MTMF4N7F.js → chunk-3VJ3OCRE.js} +2 -2
- package/dist/{chunk-QMGWSEPL.js → chunk-4GWN76B2.js} +2 -2
- package/dist/{chunk-IBM3F2BJ.js → chunk-4LK5OIPW.js} +2 -2
- package/dist/{chunk-6SDEQTVY.js → chunk-53ELMZRF.js} +2 -2
- package/dist/{chunk-OJFLPVBP.js → chunk-57OPIQFM.js} +2 -2
- package/dist/{chunk-2E6BTWER.js → chunk-5CR4U5X2.js} +2 -2
- package/dist/{chunk-IYBIBMPF.js → chunk-5FWR5HLG.js} +2 -2
- package/dist/{chunk-HHBBGWES.js → chunk-5LL4KEHO.js} +2 -2
- package/dist/{chunk-NTRW52UR.js → chunk-5MPBSFZH.js} +2 -2
- package/dist/chunk-5T44HG5Y.js +88 -0
- package/dist/chunk-5TZNHP4T.js +8 -0
- package/dist/{chunk-L3YSDLNB.js → chunk-5YBDBY5L.js} +2 -2
- package/dist/{chunk-YFQPWKHR.js → chunk-5ZI2PPI7.js} +2 -2
- package/dist/{chunk-WO47BIPY.js → chunk-6EYESTJM.js} +2 -2
- package/dist/{chunk-PHPQ24UG.js → chunk-6FXXYYQM.js} +2 -2
- package/dist/chunk-6O3KXIDL.js +2 -0
- package/dist/{chunk-PLZXWZHY.js → chunk-7GAK2F3H.js} +2 -2
- package/dist/{chunk-W3FK73MD.js → chunk-7UCDGXRW.js} +2 -2
- package/dist/{chunk-U2XX3BT4.js → chunk-AGGR2BKS.js} +2 -2
- package/dist/{chunk-ZB3V5QM7.js → chunk-ALOEHWJS.js} +2 -2
- package/dist/{chunk-NDGTJHQN.js → chunk-AXQCHG77.js} +2 -2
- package/dist/{chunk-X5I2BQGX.js → chunk-BFANZRQ5.js} +2 -2
- package/dist/{chunk-VVCBMH5O.js → chunk-BGGB5N53.js} +2 -2
- package/dist/{chunk-PARCKE3Q.js → chunk-BGYRF5YX.js} +2 -2
- package/dist/{chunk-CIVYHK7U.js → chunk-BIADXGC3.js} +2 -2
- package/dist/{chunk-NK76RSB6.js → chunk-BPKNP3KZ.js} +2 -2
- package/dist/{chunk-ZOEDRCR4.js → chunk-BRQL7AFJ.js} +2 -2
- package/dist/{chunk-KDYQQJ6X.js → chunk-BWL3PMPT.js} +2 -2
- package/dist/{chunk-M7LAIM77.js → chunk-C6WKPKCF.js} +2 -2
- package/dist/{chunk-37TKC6MB.js → chunk-CB5AVJMM.js} +2 -2
- package/dist/{chunk-BX2U3QQV.js → chunk-CCIYWXX6.js} +2 -2
- package/dist/{chunk-3AC56WAR.js → chunk-CIYA2KZN.js} +2 -2
- package/dist/{chunk-6OVNYYY4.js → chunk-CJTKGAGH.js} +2 -2
- package/dist/{chunk-FIXYHQ3W.js → chunk-CLPCFGRT.js} +2 -2
- package/dist/{chunk-LY2NB5XR.js → chunk-CSPDQLLU.js} +2 -2
- package/dist/{chunk-CMXW7MFV.js → chunk-CYJS33YX.js} +2 -2
- package/dist/{chunk-ACZDU5GK.js → chunk-D7DOB27N.js} +7 -7
- package/dist/{chunk-XUJM6474.js → chunk-DDRA3QKN.js} +2 -2
- package/dist/{chunk-3NUZVLR7.js → chunk-DECN422G.js} +2 -2
- package/dist/{chunk-RRPK327J.js → chunk-DJKOXMNG.js} +2 -2
- package/dist/{chunk-SJZQ2PTZ.js → chunk-DWBAESVW.js} +2 -2
- package/dist/{chunk-S5SKXCND.js → chunk-EHPOTEQX.js} +2 -2
- package/dist/chunk-EIBGSU2R.js +2 -0
- package/dist/{chunk-DVYG3JTA.js → chunk-ELYMY5S2.js} +2 -2
- package/dist/chunk-EOKVZXNF.js +355 -0
- package/dist/chunk-EQNMD62X.js +51 -0
- package/dist/{chunk-YIOQJ45A.js → chunk-F3QSL4W2.js} +2 -2
- package/dist/{chunk-VG55NFXF.js → chunk-F5CJO5JN.js} +2 -2
- package/dist/{chunk-JOALNFY3.js → chunk-F74LZWCE.js} +2 -2
- package/dist/chunk-G7GVV2TV.js +27 -0
- package/dist/{chunk-U24M5RQM.js → chunk-GQLDYCWS.js} +2 -2
- package/dist/{chunk-B2E3HZ2A.js → chunk-GV2CEZCW.js} +2 -2
- package/dist/{chunk-AM5SUGHF.js → chunk-GVAF222T.js} +2 -2
- package/dist/{chunk-T3YFIJ5P.js → chunk-HJTM3C4Y.js} +2 -2
- package/dist/{chunk-FY5V4V4F.js → chunk-HNXRVGMY.js} +2 -2
- package/dist/{chunk-UWB5WMC2.js → chunk-I3OK27P7.js} +2 -2
- package/dist/{chunk-RVYLJDXC.js → chunk-ICUL7XRT.js} +2 -2
- package/dist/{chunk-QVHZB75Z.js → chunk-IHSLIIL3.js} +2 -2
- package/dist/chunk-ILGTMRMZ.js +2 -0
- package/dist/{chunk-XNUWRTYM.js → chunk-IZDPGOZR.js} +2 -2
- package/dist/{chunk-BH5CE4LN.js → chunk-J7AMBVWF.js} +2 -2
- package/dist/chunk-JAFDMV5I.js +2 -0
- package/dist/{chunk-YXJ4IAHH.js → chunk-JCMFBF4Z.js} +2 -2
- package/dist/{chunk-BLKYYQ7C.js → chunk-JNXI6NQ7.js} +95 -95
- package/dist/{chunk-DKJXK3HA.js → chunk-JSB43EX6.js} +2 -2
- package/dist/chunk-JYRJYXUV.js +2 -0
- package/dist/chunk-K4S2VH42.js +82 -0
- package/dist/{chunk-QLTFXVUI.js → chunk-K6FNTQQW.js} +2 -2
- package/dist/{chunk-JYX5UZSZ.js → chunk-KEJ2HLRW.js} +2 -2
- package/dist/{chunk-VCWAJPXQ.js → chunk-KFTHI2R6.js} +2 -2
- package/dist/chunk-KLX6NSWT.js +3 -0
- package/dist/{chunk-DFPAZXLU.js → chunk-KPZGTB2O.js} +2 -2
- package/dist/{chunk-T55YPJGB.js → chunk-KUKKLWJD.js} +2 -2
- package/dist/{chunk-RWKEXCHU.js → chunk-KUKWHP4R.js} +2 -2
- package/dist/{chunk-ZJZQ7Q2Q.js → chunk-KWRQVLPX.js} +2 -2
- package/dist/{chunk-FQA3KIFX.js → chunk-L37EQYAX.js} +2 -2
- package/dist/{chunk-PNVZIJ57.js → chunk-LCW3PSGL.js} +2 -2
- package/dist/{chunk-7Z7HCZ7J.js → chunk-LKUTSP4G.js} +2 -2
- package/dist/{chunk-HIEXRDJF.js → chunk-LMTSB3TB.js} +2 -2
- package/dist/{chunk-SF34QLK2.js → chunk-LQHYYIOB.js} +2 -2
- package/dist/{chunk-EXMVF3JR.js → chunk-LSZYMN2A.js} +3 -3
- package/dist/{chunk-RCPZOPV6.js → chunk-M2Y6PCFE.js} +2 -2
- package/dist/chunk-MC46AL7B.js +343 -0
- package/dist/{chunk-SRY26ITJ.js → chunk-MDFT325O.js} +2 -2
- package/dist/{chunk-WJOQC4P7.js → chunk-MEUHIDI3.js} +2 -2
- package/dist/{chunk-FLLXYUOL.js → chunk-MQW6SJ4P.js} +2 -2
- package/dist/{chunk-57KEZDPT.js → chunk-MSI3K7PJ.js} +2 -2
- package/dist/{chunk-27PHVDKL.js → chunk-MZNMASFM.js} +2 -2
- package/dist/{chunk-VYZQZ4ZN.js → chunk-N2XDMNVI.js} +2 -2
- package/dist/{chunk-JN5LIBT3.js → chunk-NDKOVQFG.js} +2 -2
- package/dist/{chunk-W6C6QTXJ.js → chunk-NEWHKGVD.js} +2 -2
- package/dist/chunk-NNG6M6XD.js +3 -0
- package/dist/chunk-O2KWU34K.js +278 -0
- package/dist/{chunk-HBXZAGY6.js → chunk-O2M3VNDY.js} +2 -2
- package/dist/{chunk-FPDL2TUB.js → chunk-OBC7HSSO.js} +2 -2
- package/dist/{chunk-J24VICI5.js → chunk-OKAF4OQS.js} +2 -2
- package/dist/{chunk-I5FCDTK2.js → chunk-OP6BUIV6.js} +2 -2
- package/dist/{chunk-2DMVFAY7.js → chunk-OQ3DK7FW.js} +2 -2
- package/dist/{chunk-FEBLLMTL.js → chunk-OQUCBKOI.js} +2 -2
- package/dist/chunk-OT5ISJSR.js +2 -0
- package/dist/{chunk-N3Q3AWGW.js → chunk-OWJWOEDU.js} +96 -96
- package/dist/{chunk-M4EVGA5S.js → chunk-PIFYOWS4.js} +3 -3
- package/dist/{chunk-35YYZD3D.js → chunk-PTR3EOXC.js} +2 -2
- package/dist/{chunk-5XEVXVTK.js → chunk-PUVNH4PO.js} +2 -2
- package/dist/{chunk-I645ZF75.js → chunk-QEOWONKY.js} +2 -2
- package/dist/{chunk-JXHLB7TP.js → chunk-QMOZZ2VX.js} +2 -2
- package/dist/{chunk-NIO346UL.js → chunk-QY7QB7I6.js} +2 -2
- package/dist/{chunk-YYFV32WR.js → chunk-R4OJGTMP.js} +2 -2
- package/dist/{chunk-2VKB5CMA.js → chunk-RCIGX23V.js} +2 -2
- package/dist/{chunk-TUTSO7UZ.js → chunk-RIO3JXHM.js} +2 -2
- package/dist/{chunk-4IFISPQW.js → chunk-SA7G6GJX.js} +2 -2
- package/dist/{chunk-OMBRP7BB.js → chunk-SB53KPWA.js} +2 -2
- package/dist/chunk-SB7NASHU.js +2 -0
- package/dist/{chunk-3XFJUWJE.js → chunk-SGMNWYTH.js} +2 -2
- package/dist/{chunk-A7XQT7MH.js → chunk-SUE7SHZL.js} +2 -2
- package/dist/{chunk-IOVPAZWP.js → chunk-SX72EVMY.js} +2 -2
- package/dist/{chunk-OVKZM2XI.js → chunk-SZ4P7MF7.js} +2 -2
- package/dist/{chunk-EM5UHLAM.js → chunk-T2M5HWBQ.js} +2 -2
- package/dist/{chunk-CZEIHYMP.js → chunk-T6MQNNAC.js} +2 -2
- package/dist/chunk-T75DS2E6.js +21 -0
- package/dist/{chunk-57GCCPLS.js → chunk-TEANKHUU.js} +2 -2
- package/dist/{chunk-MT5W4DUG.js → chunk-TEMM2FEL.js} +2 -2
- package/dist/{chunk-I2KP4AGR.js → chunk-TJWVT4DO.js} +2 -2
- package/dist/{chunk-77GHPR2R.js → chunk-TLTSESB4.js} +2 -2
- package/dist/{chunk-KM4QRWI5.js → chunk-TNJGTQWO.js} +2 -2
- package/dist/{chunk-EFFMFK7C.js → chunk-TOTWJZIX.js} +2 -2
- package/dist/{chunk-54K6556S.js → chunk-U33PMPNW.js} +2 -2
- package/dist/{chunk-GXVDTHFC.js → chunk-U7NUXDQO.js} +2 -2
- package/dist/chunk-UC2FD2PS.js +4 -0
- package/dist/{chunk-MRGTCMDK.js → chunk-UIAUPFBJ.js} +2 -2
- package/dist/{chunk-LAGDJXFY.js → chunk-UJIXCI3L.js} +2 -2
- package/dist/{chunk-IVJJNVSX.js → chunk-UMEPSVKT.js} +2 -2
- package/dist/{chunk-4O52YNKL.js → chunk-UQYQBLJX.js} +2 -2
- package/dist/{chunk-JUO3Z644.js → chunk-UW6KD57C.js} +2 -2
- package/dist/{chunk-TAJ6UGCO.js → chunk-V4NGDIEA.js} +3 -3
- package/dist/{chunk-VLTUX4IF.js → chunk-VGWZ4MOY.js} +2 -2
- package/dist/{chunk-KNV5VFDV.js → chunk-VSGOIZMQ.js} +2 -2
- package/dist/{chunk-K5G7SPAG.js → chunk-W7QDASTN.js} +4 -4
- package/dist/{chunk-IWAMYGPN.js → chunk-W7YLRXZE.js} +2 -2
- package/dist/{chunk-QKVTWODE.js → chunk-WK2IQJPK.js} +2 -2
- package/dist/{chunk-HYKSLTAR.js → chunk-WO6OFKUC.js} +2 -2
- package/dist/{chunk-S64NCE2Z.js → chunk-WWCV4E6J.js} +2 -2
- package/dist/{chunk-2F5ERMNI.js → chunk-XJBK3QDV.js} +2 -2
- package/dist/{chunk-IGYAZPRX.js → chunk-XN3EKMLI.js} +2 -2
- package/dist/{chunk-FWY2PRIF.js → chunk-XQAVQVIL.js} +2 -2
- package/dist/{chunk-NJA4MMBD.js → chunk-XUPFA6GH.js} +2 -2
- package/dist/{chunk-4AOOSCZ7.js → chunk-YHPG3S2U.js} +2 -2
- package/dist/{chunk-CDWSLAPN.js → chunk-YPBKBYPS.js} +2 -2
- package/dist/{chunk-5BDK6QC3.js → chunk-YRKP7PM7.js} +2 -2
- package/dist/{chunk-4NHWNAWQ.js → chunk-YT4DVWUV.js} +2 -2
- package/dist/{chunk-5NJPH3QZ.js → chunk-YTJHCGYB.js} +2 -2
- package/dist/{chunk-ZNQCR656.js → chunk-Z66XYVLZ.js} +2 -2
- package/dist/{chunk-A67HT5FR.js → chunk-ZB4C5TTR.js} +2 -2
- package/dist/chunk-ZMA5HWXY.js +3 -0
- package/dist/{chunk-CWMHWD56.js → chunk-ZNH33XIB.js} +2 -2
- package/dist/{cli-context-XEPPF4RX.js → cli-context-FJL2JHOE.js} +2 -2
- package/dist/{cli-context-TSADTXLB.js → cli-context-PQNWHMCQ.js} +2 -2
- package/dist/{cli-program-KJGQEM72.js → cli-program-SCHOHOQE.js} +2 -2
- package/dist/cli.js +1 -1
- package/dist/{code-CDe-mIjx.d.ts → code-DfX3xeWy.d.ts} +1 -1
- package/dist/{code-viewer-ZCTHXQ5C.js → code-viewer-AMRXV444.js} +2 -2
- package/dist/{code-viewer-YGDON6SY.js → code-viewer-EXI5SFFR.js} +2 -2
- package/dist/{command-descriptors-5VAB2MZX.js → command-descriptors-H6A4UY72.js} +129 -129
- package/dist/{command-descriptors-EAHKIRAG.js → command-descriptors-ROIOTCCW.js} +130 -130
- package/dist/{db-DmRNdCtm.d.ts → db-BoG_PWYH.d.ts} +1 -1
- package/dist/direct-navigation-3JOYP2MO.js +3 -0
- package/dist/direct-navigation-SJMJLBY7.js +2 -0
- package/dist/{graph-evidence-Bs54NWws.d.ts → graph-evidence-D1jx1Cql.d.ts} +1 -1
- package/dist/{health-BnzbSLCE.d.ts → health-DkYBS5BI.d.ts} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-GMZX3UAD.js +2 -0
- package/dist/invocation-command-descriptors-HNMKDEF6.js +3 -0
- package/dist/{scip-cli-BRFKkHQn.d.ts → maintenance-types-CdL5eQii.d.ts} +1 -20
- package/dist/output-continuation-command-5NWVDQT7.js +2 -0
- package/dist/output-continuation-command-RNEHNYPU.js +3 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-MIW5CYEG.js +3 -0
- package/dist/project-reindex-VQ23LWDA.js +2 -0
- package/dist/queries/affected.d.ts +1 -1
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.d.ts +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.d.ts +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.d.ts +2 -2
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +1 -1
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.d.ts +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +2 -2
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.d.ts +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +2 -2
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +4 -4
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.d.ts +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.d.ts +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.d.ts +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.d.ts +3 -3
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +1 -1
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +1 -1
- package/dist/queries/surface.d.ts +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.d.ts +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.d.ts +2 -2
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +2 -2
- package/dist/reindex.d.ts +2 -4
- package/dist/reindex.js +71 -32
- package/dist/runtime.d.ts +1 -2
- package/dist/runtime.js +3 -3
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/sentinel-ensure-command-H66AZ3VE.js +2 -0
- package/dist/sentinel-ensure-command-R4YAUCJB.js +3 -0
- package/dist/sentinel-worker.js +1 -1
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +2 -2
- package/docs/INDEX_GENERATIONS.md +2 -2
- package/docs/NPM_RELEASE.md +323 -0
- package/docs/schemas/npm-release-state.schema.json +4 -13
- package/package.json +3 -11
- package/dist/chunk-2Q2LW5JW.js +0 -14
- package/dist/chunk-327YK6TB.js +0 -4
- package/dist/chunk-347TXATM.js +0 -2
- package/dist/chunk-36WRYYTE.js +0 -3
- package/dist/chunk-5IO2APSS.js +0 -2
- package/dist/chunk-6OAHRI2D.js +0 -6
- package/dist/chunk-6URCE5QY.js +0 -2
- package/dist/chunk-6ZV5EDUT.js +0 -5
- package/dist/chunk-7R64XY4Y.js +0 -12
- package/dist/chunk-CANBLFVQ.js +0 -15
- package/dist/chunk-CCRZLRWJ.js +0 -2
- package/dist/chunk-G2XUZCF2.js +0 -88
- package/dist/chunk-H5QXP63L.js +0 -2
- package/dist/chunk-HCMQZPEO.js +0 -2
- package/dist/chunk-IEL6Q5W3.js +0 -308
- package/dist/chunk-IGQQUENU.js +0 -109
- package/dist/chunk-K2O7SBAU.js +0 -2
- package/dist/chunk-QVWDQTMG.js +0 -2
- package/dist/chunk-RJWAB4VR.js +0 -345
- package/dist/chunk-VCL7FK3E.js +0 -3
- package/dist/chunk-WOOTEWQT.js +0 -239
- package/dist/chunk-XYLV727H.js +0 -21
- package/dist/chunk-YMGZZEW4.js +0 -2
- package/dist/direct-navigation-B3SGOOBW.js +0 -2
- package/dist/direct-navigation-ZL362KXF.js +0 -3
- package/dist/invocation-command-descriptors-CSUGUHTT.js +0 -2
- package/dist/invocation-command-descriptors-PPVZOIE5.js +0 -3
- package/dist/output-continuation-command-FTVVBVSN.js +0 -2
- package/dist/output-continuation-command-ITPRC3YV.js +0 -3
- package/dist/project-reindex-7HZSLLLY.js +0 -3
- package/dist/project-reindex-NGM3DYBN.js +0 -2
- package/dist/sentinel-ensure-command-KYYULCFU.js +0 -2
- package/dist/sentinel-ensure-command-RIZA3RY7.js +0 -3
- package/docs/WINDOWS_SIDECAR_RELEASE.md +0 -424
- package/docs/schemas/windows-sidecar-provenance.schema.json +0 -137
- package/scripts/build-codebaseiq-windows.mjs +0 -197
- package/scripts/codebaseiq-windows-provenance.mjs +0 -364
- package/scripts/verify-codebaseiq-windows.mjs +0 -29
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as te,b as N,e as V,f as j,g as B,h as re,i as se}from"./chunk-NMTSZXCL.js";import{b as _}from"./chunk-B75HZHUP.js";import{c as q}from"./chunk-NK76RSB6.js";import{a as ie}from"./chunk-OJFLPVBP.js";import{b as ne}from"./chunk-57KEZDPT.js";import{a as D}from"./chunk-3XFJUWJE.js";import{d as v,e as K,h as $}from"./chunk-AM5SUGHF.js";import{a as E}from"./chunk-JOALNFY3.js";import{a as Y}from"./chunk-RVYLJDXC.js";import{h as z,l as J,t as Q,v as ee,w as U,x as H}from"./chunk-PLZXWZHY.js";import{a as A,d as y}from"./chunk-3LCDIREB.js";function Ie(e,n,t={}){let{minSimilarity:i=.4,limit:r=20}=t,s=()=>Ge(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"}),a=Be(e,n,{semantic:t.semantic!==!1});if(a.kind==="not-callable")return[];if(a.kind==="callee-evidence-unusable")return s();let o=a.target;if(!$(o.symbol))return[];if(o.callees.size===0)return s();let c=we(e,o,i,{scanLimit:t.scanLimit,semantic:t.semantic!==!1});return c.length>0?c.slice(0,r):s()}function Tn(e,n,t,i={}){let r=D(e,n),s=D(e,t);if(!r||!s)return null;let a=Ie(e,r.symbol,{minSimilarity:0,limit:Number.POSITIVE_INFINITY,semantic:i.semantic,scanLimit:i.scanLimit}).find(m=>m.symbolB===s.symbol||m.symbolA===s.symbol);if(!a)return null;let o=r.endLine-r.startLine+1,c=s.endLine-s.startLine+1;return{symbolA:{symbol:r.symbol,shortName:v(r.symbol),file:r.relativePath,loc:o},symbolB:{symbol:s.symbol,shortName:v(s.symbol),file:s.relativePath,loc:c},similarity:a.similarity,similarityBasis:a.similarityBasis??"callees",sharedEvidence:a.sharedCallees,uniqueToA:a.uniqueToA,uniqueToB:a.uniqueToB,evidenceClass:a.evidenceClass,actionTier:a.actionTier,recommendation:a.recommendation,consolidationStrategy:ve(a)}}function ve(e){let n=e.similarityBasis==="source-tokens"?"source-token":"tracked callee";return e.sharedCallees.length===0?`No shared ${n} evidence survived similar's weighting. Inspect the source before attempting consolidation.`:e.uniqueToA.length===0&&e.uniqueToB.length===0?`The functions have identical ${n} evidence under similar's weighting. Verify signatures, guards, and return values before consolidating.`:e.uniqueToA.length===0?`A's ${n} evidence is a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToB.length===0?`B's ${n} evidence is a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToA.length<=2&&e.uniqueToB.length<=2?`Create a shared helper around the ${e.sharedCallees.length} shared ${n}(s). Pass the ${e.uniqueToA.length+e.uniqueToB.length} divergent point(s) as parameters or callbacks.`:`Extract the ${e.sharedCallees.length} shared ${n}(s) into a common helper. Keep each function's unique logic outside that helper (${e.uniqueToA.length} item(s) in A, ${e.uniqueToB.length} in B).`}function we(e,n,t,i){let r=G(e).calleeIndex({minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),s=_e(n,r.corpus),a=Pe(s,r),o=Te(s,r),c=j(o),m=B(s.callees,o),g=[];for(let f of a){if(f.callees.size<3)continue;let l=B(f.callees,o),u=ce(s,f,o,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0,medianIdf:c,magnitudeA:m,magnitudeB:l});u&&g.push(u)}return g.sort((f,l)=>l.similarity-f.similarity),g}function Te(e,n){let t=new Map(n.docFreq);for(let i of e.callees)t.set(i,(t.get(i)??0)+1);return V(t,n.corpus.length+1)}function ce(e,n,t,i){let r=Le(e,n,t,i);if(!Re(r,i))return null;let{similarity:s,significantShared:a,trivialShared:o}=r,c=a.length>0?a:o,m=pe(c,"callees");return{symbolA:e.symbol,shortNameA:v(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:v(n.symbol),fileB:n.file,similarity:s,similarityBasis:"callees",sharedCallees:c.map(v),uniqueToA:[...N(e.callees,n.callees)].map(v),uniqueToB:[...N(n.callees,e.callees)].map(v),...m}}function Me(e,n,t,i){let r=i.magnitudeA??B(e.callees,t),s=i.magnitudeB??B(n.callees,t),a=0,o=0,c=0,m=i.medianIdf??j(t);for(let l of e.callees){if(!n.callees.has(l))continue;let u=t.get(l)??0;a+=u*u,c+=1,u>=m&&(o+=1)}if(c===0)return!1;let g=r*s;return(g>0?a/g:0)<i.minSimilarity?!1:o>=i.requireSignificantShared||c>=i.requireSharedCount}function Le(e,n,t,i){return i.magnitudeA===void 0||i.magnitudeB===void 0?re(e.callees,n.callees,t,{medianIdf:i.medianIdf}):se(e.callees,n.callees,t,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB})}function Re(e,n){if(e.similarity<n.minSimilarity)return!1;let t=e.significantShared.length+e.trivialShared.length;return e.significantShared.length>=n.requireSignificantShared||t>=n.requireSharedCount}function Mn(e,n={}){let{minSimilarity:t=.5,limit:i=20,scope:r,minCallees:s=4,crossFileOnly:a=!1,scanLimit:o}=n,c=n.semantic!==!1,m=A(),g=0,f=0,l=0,u=0,d=0,p=0,b=0;return y("similar.all",()=>{let h=G(e).calleeIndex({minCallees:s,scope:r,scanLimit:o,semantic:c}),S=h.corpus;g=S.length;let F=n.focusFiles,I=[],P=0;return y("similar.all.pair-scan",()=>{for(let k=0;k<S.length;k+=1){let x=S[k],M=F?.has(x.file)??!1,w=h.weightedMagnitudes[k],T=new Set;for(let O of x.callees){let L=h.candidateIndexesByCallee.get(O);if(L)for(let R of L)R<=k||F&&!M&&!F.has(S[R].file)||T.add(R)}m&&(l+=T.size,T.size>0&&(f+=1));for(let O of T){let L=S[O];if(a&&x.file===L.file){m&&(d+=1);continue}if(ue(x,L)){m&&(p+=1);continue}m&&(u+=1);let R=ce(x,L,h.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:h.medianIdf,magnitudeA:w,magnitudeB:h.weightedMagnitudes[O]});R&&(Ae(I,R,i,P),m&&(b+=1),P+=1)}}},()=>({corpusSize:g,candidateSets:f,candidatePairs:l,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:b,topResults:I.length})),y("similar.all.sort-project",()=>(I.sort((k,x)=>x.result.similarity-k.result.similarity||k.order-x.order),I.map(k=>k.result)),()=>({topResults:I.length}))},()=>({minSimilarity:t,limit:i,scope:r,minCallees:s,crossFileOnly:a,scanLimit:o,semantic:c,corpusSize:g,candidateSets:f,candidatePairs:l,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:b}))}function Ln(e,n={}){let{minSimilarity:t=.5,scope:i,minCallees:r=4,crossFileOnly:s=!1,scanLimit:a}=n,o=n.semantic!==!1,c=A(),m=0,g=0,f=0,l=0,u=0,d=0,p=0;return y("similar.all-count",()=>{let C=G(e).calleeIndex({minCallees:r,scope:i,scanLimit:a,semantic:o}),h=C.corpus;m=h.length;let S=n.focusFiles;return y("similar.all-count.pair-scan",()=>{for(let F=0;F<h.length;F+=1){let I=h[F],P=S?.has(I.file)??!1,k=C.weightedMagnitudes[F],x=new Set;for(let M of I.callees){let w=C.candidateIndexesByCallee.get(M);if(w)for(let T of w)T<=F||S&&!P&&!S.has(h[T].file)||x.add(T)}c&&(f+=x.size,x.size>0&&(g+=1));for(let M of x){let w=h[M];if(s&&I.file===w.file){c&&(u+=1);continue}if(ue(I,w)){c&&(d+=1);continue}c&&(l+=1),Me(I,w,C.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:C.medianIdf,magnitudeA:k,magnitudeB:C.weightedMagnitudes[M]})&&(p+=1)}}},()=>({corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:l,crossFileSkips:u,signatureSkips:d,insertedResults:p})),p},()=>({minSimilarity:t,scope:i,minCallees:r,crossFileOnly:s,scanLimit:a,semantic:o,corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:l,crossFileSkips:u,signatureSkips:d,insertedResults:p}))}function ue(e,n){if(e.paramCount<0||n.paramCount<0)return!1;let t=Math.abs(e.paramCount-n.paramCount),i=Math.max(2,Math.ceil(Math.max(e.paramCount,n.paramCount)*.5));return t>i}var me=Q({kind:"source-fingerprints",invalidation:ee("source-fingerprints"),serialize:cn,deserialize:ln});function Ae(e,n,t,i){if(t<=0)return;if(e.length<t){e.push({result:n,order:i});return}let r=0;for(let a=1;a<e.length;a+=1){let o=e[a],c=e[r];(o.result.similarity<c.result.similarity||o.result.similarity===c.result.similarity&&o.order>c.order)&&(r=a)}let s=e[r];n.similarity<=s.result.similarity||(e[r]={result:n,order:i})}var Ee=["ScipDatabase#all","ScipDatabase#get","ScipDatabase#prepare","ScipDatabase#pathExclusionsFor","ScipDatabase#isIgnored","ScipDatabase#symbolNoiseFor","PerDbValue#get","PerDbValue#has",":storage:db:ScipDatabase:all",":storage:db:ScipDatabase:get",":storage:db:ScipDatabase:prepare",":storage:db:ScipDatabase:pathExclusionsFor",":storage:db:ScipDatabase:isIgnored",":storage:db:ScipDatabase:symbolNoiseFor",":storage:per-db-cache:PerDbValue:get",":storage:per-db-cache:PerDbValue:has"];function Be(e,n,t){let i=D(e,n);if(!i)return{kind:"not-callable"};if(!$(i.symbol))return{kind:"not-callable"};let r=new q(e),s=ne(e,i,{semantic:t.semantic,semanticEvidence:ie});return s.semanticIncomplete||s.semanticUnavailable?{kind:"callee-evidence-unusable"}:{kind:"resolved",target:{symbol:i.symbol,file:i.relativePath,callees:ge(s.rows.map(a=>a.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}}var ze=z("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),De=z("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function de(e,n){let{minCallees:t,scope:i,excludeSymbol:r,scanLimit:s}=n,a=n.semantic!==!1,o=ze.get(e,()=>new Map),c=`${t}|${i??""}|${s??""}|${a}`,m=!0,g=0,f=0;return y("similar.callee-fingerprints.resolve",()=>{let l=o.get(c);if(m=l!==void 0,l||(l=Oe(e,{minCallees:t,scope:i,scanLimit:s,semantic:a}),o.set(c,l)),g=l.length,r===void 0)return l;let u=l.filter(d=>d.symbol!==r);return f=l.length-u.length,u},()=>({minCallees:t,scope:i,scanLimit:s,semantic:a,cacheHit:m,corpusSize:g,excludeSymbol:r!==void 0,excludedSymbols:f}))}function qe(e,n){let{minCallees:t,scope:i,scanLimit:r}=n,s=n.semantic!==!1,a=De.get(e,()=>new Map),o=`${t}|${i??""}|${r??""}|${s}`,c=!0,m=0,g=0,f=0;return y("similar.callee-index.resolve",()=>{let l=a.get(o);return c=l!==void 0,l||(l=Ne(de(e,{minCallees:t,scope:i,scanLimit:r,semantic:s})),a.set(o,l)),m=l.corpus.length,g=l.docFreq.size,f=l.candidateIndexesByCallee.size,l},()=>({minCallees:t,scope:i,scanLimit:r,semantic:s,cacheHit:c,corpusSize:m,indexedCallees:g,candidateBuckets:f}))}function G(e){return{calleeCorpus:n=>de(e,n),calleeIndex:n=>qe(e,n),sourceCorpus:(n={})=>Ce(e,n),sourceIndex:(n={})=>le(e,n),sourceCandidates:(n,t)=>(t.candidateMode??"full")==="target-pruned"?Qe(e,n,{minSimilarity:t.minSimilarity,scanLimit:t.scanLimit}):Ye(n,le(e,{scanLimit:t.scanLimit}))}}function Ne(e){let n=A(),t=0,i=y("similar.callee-index.doc-frequency",()=>{let l=new Map;for(let u of e)for(let d of u.callees)l.set(d,(l.get(d)??0)+1);return t=l.size,l},()=>({corpusSize:e.length,uniqueCallees:t})),r=Math.max(8,Math.ceil(Math.sqrt(e.length))),s=y("similar.callee-index.idf-weights",()=>V(i,e.length),()=>({corpusSize:e.length,uniqueCallees:i.size})),a=y("similar.callee-index.weighted-magnitudes",()=>e.map(l=>B(l.callees,s)),()=>({corpusSize:e.length})),o=0,c=0,m=0,g=y("similar.callee-index.candidate-buckets",()=>{let l=new Map;for(let u=0;u<e.length;u+=1){let d=e[u];for(let p of d.callees){if((i.get(p)??0)>r){n&&(c+=1);continue}let b=l.get(p);b||(b=[],l.set(p,b)),b.push(u),n&&(o+=1)}}return n&&(m=l.size),l},()=>({corpusSize:e.length,buckets:m,candidateRefs:o,ubiquitousSkips:c,ubiquityThreshold:r})),f=y("similar.callee-index.median-idf",()=>j(s),()=>({uniqueCallees:s.size}));return{corpus:e,candidateIndexesByCallee:g,docFreq:i,idfWeights:s,weightedMagnitudes:a,medianIdf:f,ubiquityThreshold:r}}function Pe(e,n){let t=new Map;for(let i of e.callees)for(let r of n.candidateIndexesByCallee.get(i)??[]){let s=n.corpus[r];s.symbol!==e.symbol&&t.set(s.symbol,s)}return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function Oe(e,n){let{minCallees:t,scope:i,scanLimit:r,semantic:s}=n,a=A(),o=new q(e),c=0,m=y("similar.callee-fingerprints.candidates",()=>{let p=_(o.productionCallableDefinitions({scope:i,minLoc:5,sortByLocDesc:typeof r=="number"&&r>0}),r);return c=p.length,p},()=>({scope:i,scanLimit:r,candidateCount:c})),g=0,f=y("similar.callee-fingerprints.callee-map",()=>{let p=o.calleeEvidenceMap(m,{semantic:s});if(a)for(let b of p.rows.values())g+=b.length;return p},()=>({candidateCount:c,semantic:s,calleeEdges:g})),l=0,u=0,d=0;return y("similar.callee-fingerprints.shape",()=>{let b=m.filter(S=>!f.incompleteSymbolIds.has(S.symbolId)&&!f.unavailableSymbolIds.has(S.symbolId)).map(S=>({symbol:S.symbol,file:S.relativePath,callees:ge((f.rows.get(S.symbolId)??[]).map(F=>F.symbol)),paramCount:o.callableSignature(S)?.paramCount??-1})),C=$e(b);a&&(d=C.filter((S,F)=>S.callees.size!==b[F].callees.size).length);let h=C.filter(S=>S.callees.size>=t);return l=h.length,a&&(u=h.reduce((S,F)=>S+F.callees.size,0)),h},()=>({candidateCount:c,fingerprintCount:l,retainedCalleeCount:u,minCallees:t,siblingSaturatedFingerprints:d}))}var fe=5;function $e(e){let n=new Map;for(let t of e){let i=n.get(t.file);i||(i=new Map,n.set(t.file,i));for(let r of t.callees)i.set(r,(i.get(r)??0)+1)}return e.map(t=>{let i=n.get(t.file);if(!i)return t;let r=[...t.callees].filter(a=>(i.get(a)??0)>=fe);if(r.length===0)return t;let s=new Set(t.callees);for(let a of r)s.delete(a);return{...t,callees:s}})}function _e(e,n){let t=new Map;for(let s of n)if(!(s.file!==e.file||s.symbol===e.symbol))for(let a of s.callees)t.set(a,(t.get(a)??0)+1);let i=[...e.callees].filter(s=>(t.get(s)??0)+1>=fe);if(i.length===0)return e;let r=new Set(e.callees);for(let s of i)r.delete(s);return{...e,callees:r}}function ge(e){return new Set([...e].filter(n=>!je(n)))}function je(e){return Ee.some(n=>e.includes(n))}function Ge(e,n,t){let i=Ve(e,n);if(!i||i.tokens.size<3)return[];let r=t.minSimilarity>=.5?t.minSimilarity:.3,s=[],a=t.candidateMode??"full",o=0,c=0,m=0,g=0;return y("similar.source-shape",()=>{let l=G(e).sourceCandidates(i,{minSimilarity:r,scanLimit:t.scanLimit,candidateMode:a});o=l.length;for(let u of l){if(u.symbol===i.symbol||u.tokens.size<3)continue;c+=1;let d=te(i.tokens,u.tokens);if(d.size<2){m+=1;continue}let p=new Set([...i.tokens,...u.tokens]),b=p.size>0?d.size/p.size:0;if(b<r){g+=1;continue}s.push({symbolA:i.symbol,shortNameA:v(i.symbol),fileA:i.file,symbolB:u.symbol,shortNameB:v(u.symbol),fileB:u.file,similarity:b,similarityBasis:"source-tokens",sharedCallees:[...d].sort(),uniqueToA:[...N(i.tokens,u.tokens)].sort(),uniqueToB:[...N(u.tokens,i.tokens)].sort(),...pe([...d],"source-tokens")})}return s.sort((u,d)=>d.similarity-u.similarity||u.shortNameB.localeCompare(d.shortNameB)),s.slice(0,t.limit)},()=>({symbol:i.symbol,file:i.file,targetTokens:i.tokens.size,candidateMode:a,candidates:o,comparedPairs:c,sharedSkips:m,similaritySkips:g,results:s.length}))}function pe(e,n){let t=e.flatMap(W),i=e.flatMap(b=>ae(b,n)),r=Z(t,be),s=Z(t,Se),a=Z(i,X),o=[...new Set(i.filter(oe))],c=e.filter(b=>{let C=ae(b,n);return C.some(h=>X.has(h))&&C.some(oe)}).length,m=[];r.length>0&&m.push(`access/query scaffolding: ${r.slice(0,5).join(", ")}`),s.length>0&&m.push(`framework/generic scaffolding: ${s.slice(0,5).join(", ")}`),a.length>0&&m.push(`domain behavior verbs: ${a.slice(0,5).join(", ")}`),a.length>0&&o.length>0&&m.push(`domain-specific terms: ${o.slice(0,5).join(", ")}`);let g=n==="source-tokens"&&t.length>0&&t.every(b=>ye.has(b));g&&m.push("shared source tokens are generic scaffolding");let f=a.length>0&&o.length>0,l=r.length+s.length>0,u=n==="callees"&&f&&e.length>=4&&o.length>=4&&c>=2,d=u?"domain-behavior":f?l?"mixed":"domain-behavior":r.length>0?"access-query-scaffolding":s.length>0||g?"framework-scaffolding":"structural-overlap";d==="structural-overlap"&&e.length>0&&m.push(`shared ${n} overlap has no recognized domain or scaffolding category`);let p=d==="domain-behavior"&&(e.length>=3||u)?"direct":"signal";return{evidenceClass:d,actionTier:p,evidenceClassReasons:m,recommendation:Ue(d,p)}}function Ue(e,n){return n==="direct"?"Shared domain behavior looks concrete; review for an extract/reuse opportunity.":e==="mixed"?"Shared evidence mixes domain behavior with scaffolding; review semantics before extracting anything.":e==="access-query-scaffolding"?"Shared evidence is mostly access/query scaffolding; compare product semantics before reusing code.":e==="structural-overlap"?"Shared structure has no domain or scaffolding classification; inspect names and behavior before reusing code.":"Shared evidence is mostly framework or generic scaffolding; treat as a contextual signal."}function Z(e,n){return[...new Set(e.filter(t=>n.has(t)))]}function W(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>1)}function ae(e,n){if(n==="source-tokens")return W(e);let t=K(e);return W(t.length>0?t:He(e))}function He(e){return e.replace(/[()`]/g," ").replace(/\.[a-z][a-z0-9]+(?=\s|$)/gi," ").split(/[:/\\\s]+/).map(i=>i.trim()).filter(i=>/[A-Za-z]/.test(i)).at(-1)?.replace(/\.$/,"")??e}function oe(e){return e.length>3&&!X.has(e)&&!be.has(e)&&!Se.has(e)&&!ye.has(e)&&!Ke.has(e)}var X=new Set(["archive","assign","book","cancel","create","delete","ensure","export","import","notify","persist","publish","restore","schedule","send","set","submit","sync","update","upload","validate","write"]),be=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),Se=new Set(["bytes","computed","crypto","describe","effect","expect","fetch","filter","hex","hook","json","map","mounted","on","promise","random","react","reduce","ref","render","state","test","token","trim","uuid","vue","watch"]),ye=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),Ke=new Set(["best","backend","conflict","database","effect","effects","error","errors","frontend","found","helpers","javascript","module","modules","scip","shared","source","typescript","utils","with","workflow","workflows"]);function Ve(e,n){let t=D(e,n);if(!t||!$(t.symbol))return null;let i=Ze(e,t);return i?{symbol:t.symbol,file:t.relativePath,tokens:i}:null}function Ze(e,n){let t=K(n.symbol),i=sn(e,n.relativePath,n.startLine,n.endLine,t),r=ke(i,t);return r.size>0?r:null}var We=z("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),Xe=z("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function he(e){return`${e.scanLimit??""}`}function Ce(e,n={}){let t=We.get(e,()=>new Map),i=he(n),r=t.get(i);return r||(r=rn(e,n),t.set(i,r)),r}function le(e,n={}){let t=Xe.get(e,()=>new Map),i=he(n),r=t.get(i);return r||(r=Je(Ce(e,n)),t.set(i,r)),r}function Je(e){let n=new Map;for(let r of e)for(let s of r.tokens)n.set(s,(n.get(s)??0)+1);let t=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=new Map;for(let r of e)for(let s of r.tokens){if((n.get(s)??0)>t)continue;let a=i.get(s);a||(a=[],i.set(s,a)),a.push(r)}return{corpus:e,candidateByToken:i,docFreq:n,ubiquityThreshold:t}}function Ye(e,n){let t=new Map;for(let i of e.tokens)for(let r of n.candidateByToken.get(i)??[])r.symbol!==e.symbol&&t.set(r.symbol,r);return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function Qe(e,n,t){let i=A(),r=new q(e),s=en(n.tokens.size,t.minSimilarity),a=0,o=0,c=0,m=y("similar.source-shape.target-files",()=>{let d=[...n.tokens],p=[];for(let b of Y(e,{includeIgnored:!1})){a+=1;let C=U(e,b);C&&(o+=1,nn(C,d,s)&&p.push(b))}return c=p.length,p},()=>({symbol:n.symbol,targetTokens:n.tokens.size,requiredSharedTokens:s,scannedFiles:a,readableFiles:o,candidateFiles:c})),g=0,f=y("similar.source-shape.target-definitions",()=>{let d=_(r.productionCallableDefinitions({files:m,sortByLocDesc:typeof t.scanLimit=="number"&&t.scanLimit>0}),t.scanLimit);return g=d.length,d},()=>({symbol:n.symbol,candidateFiles:c,scanLimit:t.scanLimit,definitionCount:g})),l=0;return y("similar.source-shape.target-fingerprints",()=>{let d=Fe(e,f);return i&&(l=d.length),d},()=>({symbol:n.symbol,definitionCount:g,fingerprintCount:l})).filter(d=>d.symbol!==n.symbol)}function en(e,n){return Math.max(2,Math.ceil(e*n))}function nn(e,n,t){if(n.length<t)return!1;let i=e.toLowerCase(),r=0;for(let s of n)if(tn(i,s)&&(r+=1,r>=t))return!0;return!1}function tn(e,n){return n==="num"?/\b\d+\b/.test(e):e.includes(n)}function rn(e,n={}){let t=new q(e),{scanLimit:i}=n,r=_(t.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return Fe(e,r)}function Fe(e,n){let t=new Map;for(let r of n){let s=t.get(r.relativePath)??[];s.push(r),t.set(r.relativePath,s)}let i=new Map;for(let[r,s]of t){let a=U(e,r);if(!a)continue;let o=J(e,r,a),c=on(e,r,o),m=!1,g=null;for(let f of s){let l=an(f),u=c.get(l),d=u?new Set(u.tokens):null;d||(g??=H(e,r),d=ke(xe(g,f.startLine,f.endLine,f.leaf),f.leaf),c.set(l,{key:l,symbol:f.symbol,startLine:f.startLine,endLine:f.endLine,leaf:f.leaf,tokens:[...d].sort()}),m=!0),d.size>0&&i.set(f.symbol,{symbol:f.symbol,file:f.relativePath,tokens:d})}m&&un(e,r,o,c)}return n.map(r=>i.get(r.symbol)).filter(r=>!!r)}function sn(e,n,t,i,r){let s=H(e,n);return s.length===0?"":xe(s,t,i,r)}function xe(e,n,t,i){if(t>=n&&t-n<=12)return e.slice(n,t+1).join(`
|
|
1
|
+
import{a as te,b as N,e as V,f as j,g as B,h as re,i as se}from"./chunk-NMTSZXCL.js";import{b as _}from"./chunk-B75HZHUP.js";import{c as q}from"./chunk-BPKNP3KZ.js";import{a as ie}from"./chunk-57OPIQFM.js";import{b as ne}from"./chunk-MSI3K7PJ.js";import{a as D}from"./chunk-SGMNWYTH.js";import{d as v,e as K,h as $}from"./chunk-GVAF222T.js";import{a as E}from"./chunk-F74LZWCE.js";import{a as Y}from"./chunk-ICUL7XRT.js";import{h as z,l as J,t as Q,v as ee,w as U,x as H}from"./chunk-7GAK2F3H.js";import{a as A,d as y}from"./chunk-3LCDIREB.js";function Ie(e,n,t={}){let{minSimilarity:i=.4,limit:r=20}=t,s=()=>Ge(e,n,{minSimilarity:i,limit:r,scanLimit:t.scanLimit,candidateMode:t.sourceCandidateMode??"full"}),a=Be(e,n,{semantic:t.semantic!==!1});if(a.kind==="not-callable")return[];if(a.kind==="callee-evidence-unusable")return s();let o=a.target;if(!$(o.symbol))return[];if(o.callees.size===0)return s();let c=we(e,o,i,{scanLimit:t.scanLimit,semantic:t.semantic!==!1});return c.length>0?c.slice(0,r):s()}function Tn(e,n,t,i={}){let r=D(e,n),s=D(e,t);if(!r||!s)return null;let a=Ie(e,r.symbol,{minSimilarity:0,limit:Number.POSITIVE_INFINITY,semantic:i.semantic,scanLimit:i.scanLimit}).find(m=>m.symbolB===s.symbol||m.symbolA===s.symbol);if(!a)return null;let o=r.endLine-r.startLine+1,c=s.endLine-s.startLine+1;return{symbolA:{symbol:r.symbol,shortName:v(r.symbol),file:r.relativePath,loc:o},symbolB:{symbol:s.symbol,shortName:v(s.symbol),file:s.relativePath,loc:c},similarity:a.similarity,similarityBasis:a.similarityBasis??"callees",sharedEvidence:a.sharedCallees,uniqueToA:a.uniqueToA,uniqueToB:a.uniqueToB,evidenceClass:a.evidenceClass,actionTier:a.actionTier,recommendation:a.recommendation,consolidationStrategy:ve(a)}}function ve(e){let n=e.similarityBasis==="source-tokens"?"source-token":"tracked callee";return e.sharedCallees.length===0?`No shared ${n} evidence survived similar's weighting. Inspect the source before attempting consolidation.`:e.uniqueToA.length===0&&e.uniqueToB.length===0?`The functions have identical ${n} evidence under similar's weighting. Verify signatures, guards, and return values before consolidating.`:e.uniqueToA.length===0?`A's ${n} evidence is a subset of B's. B may subsume part of A's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToB.length===0?`B's ${n} evidence is a subset of A's. A may subsume part of B's structure, but verify signatures, guards, and non-call logic first.`:e.uniqueToA.length<=2&&e.uniqueToB.length<=2?`Create a shared helper around the ${e.sharedCallees.length} shared ${n}(s). Pass the ${e.uniqueToA.length+e.uniqueToB.length} divergent point(s) as parameters or callbacks.`:`Extract the ${e.sharedCallees.length} shared ${n}(s) into a common helper. Keep each function's unique logic outside that helper (${e.uniqueToA.length} item(s) in A, ${e.uniqueToB.length} in B).`}function we(e,n,t,i){let r=G(e).calleeIndex({minCallees:3,scanLimit:i.scanLimit,semantic:i.semantic}),s=_e(n,r.corpus),a=Pe(s,r),o=Te(s,r),c=j(o),m=B(s.callees,o),g=[];for(let f of a){if(f.callees.size<3)continue;let l=B(f.callees,o),u=ce(s,f,o,{minSimilarity:t,requireSignificantShared:1,requireSharedCount:0,medianIdf:c,magnitudeA:m,magnitudeB:l});u&&g.push(u)}return g.sort((f,l)=>l.similarity-f.similarity),g}function Te(e,n){let t=new Map(n.docFreq);for(let i of e.callees)t.set(i,(t.get(i)??0)+1);return V(t,n.corpus.length+1)}function ce(e,n,t,i){let r=Le(e,n,t,i);if(!Re(r,i))return null;let{similarity:s,significantShared:a,trivialShared:o}=r,c=a.length>0?a:o,m=pe(c,"callees");return{symbolA:e.symbol,shortNameA:v(e.symbol),fileA:e.file,symbolB:n.symbol,shortNameB:v(n.symbol),fileB:n.file,similarity:s,similarityBasis:"callees",sharedCallees:c.map(v),uniqueToA:[...N(e.callees,n.callees)].map(v),uniqueToB:[...N(n.callees,e.callees)].map(v),...m}}function Me(e,n,t,i){let r=i.magnitudeA??B(e.callees,t),s=i.magnitudeB??B(n.callees,t),a=0,o=0,c=0,m=i.medianIdf??j(t);for(let l of e.callees){if(!n.callees.has(l))continue;let u=t.get(l)??0;a+=u*u,c+=1,u>=m&&(o+=1)}if(c===0)return!1;let g=r*s;return(g>0?a/g:0)<i.minSimilarity?!1:o>=i.requireSignificantShared||c>=i.requireSharedCount}function Le(e,n,t,i){return i.magnitudeA===void 0||i.magnitudeB===void 0?re(e.callees,n.callees,t,{medianIdf:i.medianIdf}):se(e.callees,n.callees,t,{medianIdf:i.medianIdf,magnitudeA:i.magnitudeA,magnitudeB:i.magnitudeB})}function Re(e,n){if(e.similarity<n.minSimilarity)return!1;let t=e.significantShared.length+e.trivialShared.length;return e.significantShared.length>=n.requireSignificantShared||t>=n.requireSharedCount}function Mn(e,n={}){let{minSimilarity:t=.5,limit:i=20,scope:r,minCallees:s=4,crossFileOnly:a=!1,scanLimit:o}=n,c=n.semantic!==!1,m=A(),g=0,f=0,l=0,u=0,d=0,p=0,b=0;return y("similar.all",()=>{let h=G(e).calleeIndex({minCallees:s,scope:r,scanLimit:o,semantic:c}),S=h.corpus;g=S.length;let F=n.focusFiles,I=[],P=0;return y("similar.all.pair-scan",()=>{for(let k=0;k<S.length;k+=1){let x=S[k],M=F?.has(x.file)??!1,w=h.weightedMagnitudes[k],T=new Set;for(let O of x.callees){let L=h.candidateIndexesByCallee.get(O);if(L)for(let R of L)R<=k||F&&!M&&!F.has(S[R].file)||T.add(R)}m&&(l+=T.size,T.size>0&&(f+=1));for(let O of T){let L=S[O];if(a&&x.file===L.file){m&&(d+=1);continue}if(ue(x,L)){m&&(p+=1);continue}m&&(u+=1);let R=ce(x,L,h.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:h.medianIdf,magnitudeA:w,magnitudeB:h.weightedMagnitudes[O]});R&&(Ae(I,R,i,P),m&&(b+=1),P+=1)}}},()=>({corpusSize:g,candidateSets:f,candidatePairs:l,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:b,topResults:I.length})),y("similar.all.sort-project",()=>(I.sort((k,x)=>x.result.similarity-k.result.similarity||k.order-x.order),I.map(k=>k.result)),()=>({topResults:I.length}))},()=>({minSimilarity:t,limit:i,scope:r,minCallees:s,crossFileOnly:a,scanLimit:o,semantic:c,corpusSize:g,candidateSets:f,candidatePairs:l,comparedPairs:u,crossFileSkips:d,signatureSkips:p,insertedResults:b}))}function Ln(e,n={}){let{minSimilarity:t=.5,scope:i,minCallees:r=4,crossFileOnly:s=!1,scanLimit:a}=n,o=n.semantic!==!1,c=A(),m=0,g=0,f=0,l=0,u=0,d=0,p=0;return y("similar.all-count",()=>{let C=G(e).calleeIndex({minCallees:r,scope:i,scanLimit:a,semantic:o}),h=C.corpus;m=h.length;let S=n.focusFiles;return y("similar.all-count.pair-scan",()=>{for(let F=0;F<h.length;F+=1){let I=h[F],P=S?.has(I.file)??!1,k=C.weightedMagnitudes[F],x=new Set;for(let M of I.callees){let w=C.candidateIndexesByCallee.get(M);if(w)for(let T of w)T<=F||S&&!P&&!S.has(h[T].file)||x.add(T)}c&&(f+=x.size,x.size>0&&(g+=1));for(let M of x){let w=h[M];if(s&&I.file===w.file){c&&(u+=1);continue}if(ue(I,w)){c&&(d+=1);continue}c&&(l+=1),Me(I,w,C.idfWeights,{minSimilarity:t,requireSignificantShared:2,requireSharedCount:4,medianIdf:C.medianIdf,magnitudeA:k,magnitudeB:C.weightedMagnitudes[M]})&&(p+=1)}}},()=>({corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:l,crossFileSkips:u,signatureSkips:d,insertedResults:p})),p},()=>({minSimilarity:t,scope:i,minCallees:r,crossFileOnly:s,scanLimit:a,semantic:o,corpusSize:m,candidateSets:g,candidatePairs:f,comparedPairs:l,crossFileSkips:u,signatureSkips:d,insertedResults:p}))}function ue(e,n){if(e.paramCount<0||n.paramCount<0)return!1;let t=Math.abs(e.paramCount-n.paramCount),i=Math.max(2,Math.ceil(Math.max(e.paramCount,n.paramCount)*.5));return t>i}var me=Q({kind:"source-fingerprints",invalidation:ee("source-fingerprints"),serialize:cn,deserialize:ln});function Ae(e,n,t,i){if(t<=0)return;if(e.length<t){e.push({result:n,order:i});return}let r=0;for(let a=1;a<e.length;a+=1){let o=e[a],c=e[r];(o.result.similarity<c.result.similarity||o.result.similarity===c.result.similarity&&o.order>c.order)&&(r=a)}let s=e[r];n.similarity<=s.result.similarity||(e[r]={result:n,order:i})}var Ee=["ScipDatabase#all","ScipDatabase#get","ScipDatabase#prepare","ScipDatabase#pathExclusionsFor","ScipDatabase#isIgnored","ScipDatabase#symbolNoiseFor","PerDbValue#get","PerDbValue#has",":storage:db:ScipDatabase:all",":storage:db:ScipDatabase:get",":storage:db:ScipDatabase:prepare",":storage:db:ScipDatabase:pathExclusionsFor",":storage:db:ScipDatabase:isIgnored",":storage:db:ScipDatabase:symbolNoiseFor",":storage:per-db-cache:PerDbValue:get",":storage:per-db-cache:PerDbValue:has"];function Be(e,n,t){let i=D(e,n);if(!i)return{kind:"not-callable"};if(!$(i.symbol))return{kind:"not-callable"};let r=new q(e),s=ne(e,i,{semantic:t.semantic,semanticEvidence:ie});return s.semanticIncomplete||s.semanticUnavailable?{kind:"callee-evidence-unusable"}:{kind:"resolved",target:{symbol:i.symbol,file:i.relativePath,callees:ge(s.rows.map(a=>a.symbol)),paramCount:r.callableSignature(i)?.paramCount??-1}}}var ze=z("callee-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),De=z("callee-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function de(e,n){let{minCallees:t,scope:i,excludeSymbol:r,scanLimit:s}=n,a=n.semantic!==!1,o=ze.get(e,()=>new Map),c=`${t}|${i??""}|${s??""}|${a}`,m=!0,g=0,f=0;return y("similar.callee-fingerprints.resolve",()=>{let l=o.get(c);if(m=l!==void 0,l||(l=Oe(e,{minCallees:t,scope:i,scanLimit:s,semantic:a}),o.set(c,l)),g=l.length,r===void 0)return l;let u=l.filter(d=>d.symbol!==r);return f=l.length-u.length,u},()=>({minCallees:t,scope:i,scanLimit:s,semantic:a,cacheHit:m,corpusSize:g,excludeSymbol:r!==void 0,excludedSymbols:f}))}function qe(e,n){let{minCallees:t,scope:i,scanLimit:r}=n,s=n.semantic!==!1,a=De.get(e,()=>new Map),o=`${t}|${i??""}|${r??""}|${s}`,c=!0,m=0,g=0,f=0;return y("similar.callee-index.resolve",()=>{let l=a.get(o);return c=l!==void 0,l||(l=Ne(de(e,{minCallees:t,scope:i,scanLimit:r,semantic:s})),a.set(o,l)),m=l.corpus.length,g=l.docFreq.size,f=l.candidateIndexesByCallee.size,l},()=>({minCallees:t,scope:i,scanLimit:r,semantic:s,cacheHit:c,corpusSize:m,indexedCallees:g,candidateBuckets:f}))}function G(e){return{calleeCorpus:n=>de(e,n),calleeIndex:n=>qe(e,n),sourceCorpus:(n={})=>Ce(e,n),sourceIndex:(n={})=>le(e,n),sourceCandidates:(n,t)=>(t.candidateMode??"full")==="target-pruned"?Qe(e,n,{minSimilarity:t.minSimilarity,scanLimit:t.scanLimit}):Ye(n,le(e,{scanLimit:t.scanLimit}))}}function Ne(e){let n=A(),t=0,i=y("similar.callee-index.doc-frequency",()=>{let l=new Map;for(let u of e)for(let d of u.callees)l.set(d,(l.get(d)??0)+1);return t=l.size,l},()=>({corpusSize:e.length,uniqueCallees:t})),r=Math.max(8,Math.ceil(Math.sqrt(e.length))),s=y("similar.callee-index.idf-weights",()=>V(i,e.length),()=>({corpusSize:e.length,uniqueCallees:i.size})),a=y("similar.callee-index.weighted-magnitudes",()=>e.map(l=>B(l.callees,s)),()=>({corpusSize:e.length})),o=0,c=0,m=0,g=y("similar.callee-index.candidate-buckets",()=>{let l=new Map;for(let u=0;u<e.length;u+=1){let d=e[u];for(let p of d.callees){if((i.get(p)??0)>r){n&&(c+=1);continue}let b=l.get(p);b||(b=[],l.set(p,b)),b.push(u),n&&(o+=1)}}return n&&(m=l.size),l},()=>({corpusSize:e.length,buckets:m,candidateRefs:o,ubiquitousSkips:c,ubiquityThreshold:r})),f=y("similar.callee-index.median-idf",()=>j(s),()=>({uniqueCallees:s.size}));return{corpus:e,candidateIndexesByCallee:g,docFreq:i,idfWeights:s,weightedMagnitudes:a,medianIdf:f,ubiquityThreshold:r}}function Pe(e,n){let t=new Map;for(let i of e.callees)for(let r of n.candidateIndexesByCallee.get(i)??[]){let s=n.corpus[r];s.symbol!==e.symbol&&t.set(s.symbol,s)}return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function Oe(e,n){let{minCallees:t,scope:i,scanLimit:r,semantic:s}=n,a=A(),o=new q(e),c=0,m=y("similar.callee-fingerprints.candidates",()=>{let p=_(o.productionCallableDefinitions({scope:i,minLoc:5,sortByLocDesc:typeof r=="number"&&r>0}),r);return c=p.length,p},()=>({scope:i,scanLimit:r,candidateCount:c})),g=0,f=y("similar.callee-fingerprints.callee-map",()=>{let p=o.calleeEvidenceMap(m,{semantic:s});if(a)for(let b of p.rows.values())g+=b.length;return p},()=>({candidateCount:c,semantic:s,calleeEdges:g})),l=0,u=0,d=0;return y("similar.callee-fingerprints.shape",()=>{let b=m.filter(S=>!f.incompleteSymbolIds.has(S.symbolId)&&!f.unavailableSymbolIds.has(S.symbolId)).map(S=>({symbol:S.symbol,file:S.relativePath,callees:ge((f.rows.get(S.symbolId)??[]).map(F=>F.symbol)),paramCount:o.callableSignature(S)?.paramCount??-1})),C=$e(b);a&&(d=C.filter((S,F)=>S.callees.size!==b[F].callees.size).length);let h=C.filter(S=>S.callees.size>=t);return l=h.length,a&&(u=h.reduce((S,F)=>S+F.callees.size,0)),h},()=>({candidateCount:c,fingerprintCount:l,retainedCalleeCount:u,minCallees:t,siblingSaturatedFingerprints:d}))}var fe=5;function $e(e){let n=new Map;for(let t of e){let i=n.get(t.file);i||(i=new Map,n.set(t.file,i));for(let r of t.callees)i.set(r,(i.get(r)??0)+1)}return e.map(t=>{let i=n.get(t.file);if(!i)return t;let r=[...t.callees].filter(a=>(i.get(a)??0)>=fe);if(r.length===0)return t;let s=new Set(t.callees);for(let a of r)s.delete(a);return{...t,callees:s}})}function _e(e,n){let t=new Map;for(let s of n)if(!(s.file!==e.file||s.symbol===e.symbol))for(let a of s.callees)t.set(a,(t.get(a)??0)+1);let i=[...e.callees].filter(s=>(t.get(s)??0)+1>=fe);if(i.length===0)return e;let r=new Set(e.callees);for(let s of i)r.delete(s);return{...e,callees:r}}function ge(e){return new Set([...e].filter(n=>!je(n)))}function je(e){return Ee.some(n=>e.includes(n))}function Ge(e,n,t){let i=Ve(e,n);if(!i||i.tokens.size<3)return[];let r=t.minSimilarity>=.5?t.minSimilarity:.3,s=[],a=t.candidateMode??"full",o=0,c=0,m=0,g=0;return y("similar.source-shape",()=>{let l=G(e).sourceCandidates(i,{minSimilarity:r,scanLimit:t.scanLimit,candidateMode:a});o=l.length;for(let u of l){if(u.symbol===i.symbol||u.tokens.size<3)continue;c+=1;let d=te(i.tokens,u.tokens);if(d.size<2){m+=1;continue}let p=new Set([...i.tokens,...u.tokens]),b=p.size>0?d.size/p.size:0;if(b<r){g+=1;continue}s.push({symbolA:i.symbol,shortNameA:v(i.symbol),fileA:i.file,symbolB:u.symbol,shortNameB:v(u.symbol),fileB:u.file,similarity:b,similarityBasis:"source-tokens",sharedCallees:[...d].sort(),uniqueToA:[...N(i.tokens,u.tokens)].sort(),uniqueToB:[...N(u.tokens,i.tokens)].sort(),...pe([...d],"source-tokens")})}return s.sort((u,d)=>d.similarity-u.similarity||u.shortNameB.localeCompare(d.shortNameB)),s.slice(0,t.limit)},()=>({symbol:i.symbol,file:i.file,targetTokens:i.tokens.size,candidateMode:a,candidates:o,comparedPairs:c,sharedSkips:m,similaritySkips:g,results:s.length}))}function pe(e,n){let t=e.flatMap(W),i=e.flatMap(b=>ae(b,n)),r=Z(t,be),s=Z(t,Se),a=Z(i,X),o=[...new Set(i.filter(oe))],c=e.filter(b=>{let C=ae(b,n);return C.some(h=>X.has(h))&&C.some(oe)}).length,m=[];r.length>0&&m.push(`access/query scaffolding: ${r.slice(0,5).join(", ")}`),s.length>0&&m.push(`framework/generic scaffolding: ${s.slice(0,5).join(", ")}`),a.length>0&&m.push(`domain behavior verbs: ${a.slice(0,5).join(", ")}`),a.length>0&&o.length>0&&m.push(`domain-specific terms: ${o.slice(0,5).join(", ")}`);let g=n==="source-tokens"&&t.length>0&&t.every(b=>ye.has(b));g&&m.push("shared source tokens are generic scaffolding");let f=a.length>0&&o.length>0,l=r.length+s.length>0,u=n==="callees"&&f&&e.length>=4&&o.length>=4&&c>=2,d=u?"domain-behavior":f?l?"mixed":"domain-behavior":r.length>0?"access-query-scaffolding":s.length>0||g?"framework-scaffolding":"structural-overlap";d==="structural-overlap"&&e.length>0&&m.push(`shared ${n} overlap has no recognized domain or scaffolding category`);let p=d==="domain-behavior"&&(e.length>=3||u)?"direct":"signal";return{evidenceClass:d,actionTier:p,evidenceClassReasons:m,recommendation:Ue(d,p)}}function Ue(e,n){return n==="direct"?"Shared domain behavior looks concrete; review for an extract/reuse opportunity.":e==="mixed"?"Shared evidence mixes domain behavior with scaffolding; review semantics before extracting anything.":e==="access-query-scaffolding"?"Shared evidence is mostly access/query scaffolding; compare product semantics before reusing code.":e==="structural-overlap"?"Shared structure has no domain or scaffolding classification; inspect names and behavior before reusing code.":"Shared evidence is mostly framework or generic scaffolding; treat as a contextual signal."}function Z(e,n){return[...new Set(e.filter(t=>n.has(t)))]}function W(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").toLowerCase().split(/[^a-z0-9]+/).filter(n=>n.length>1)}function ae(e,n){if(n==="source-tokens")return W(e);let t=K(e);return W(t.length>0?t:He(e))}function He(e){return e.replace(/[()`]/g," ").replace(/\.[a-z][a-z0-9]+(?=\s|$)/gi," ").split(/[:/\\\s]+/).map(i=>i.trim()).filter(i=>/[A-Za-z]/.test(i)).at(-1)?.replace(/\.$/,"")??e}function oe(e){return e.length>3&&!X.has(e)&&!be.has(e)&&!Se.has(e)&&!ye.has(e)&&!Ke.has(e)}var X=new Set(["archive","assign","book","cancel","create","delete","ensure","export","import","notify","persist","publish","restore","schedule","send","set","submit","sync","update","upload","validate","write"]),be=new Set(["access","auth","authorize","cache","context","db","find","get","guard","list","permission","permissions","prisma","query","request","response","role","route","session","sql","where"]),Se=new Set(["bytes","computed","crypto","describe","effect","expect","fetch","filter","hex","hook","json","map","mounted","on","promise","random","react","reduce","ref","render","state","test","token","trim","uuid","vue","watch"]),ye=new Set(["bytes","crypto","data","false","get","hex","id","key","map","name","num","random","result","secret","set","string","to","token","true","type","value"]),Ke=new Set(["best","backend","conflict","database","effect","effects","error","errors","frontend","found","helpers","javascript","module","modules","scip","shared","source","typescript","utils","with","workflow","workflows"]);function Ve(e,n){let t=D(e,n);if(!t||!$(t.symbol))return null;let i=Ze(e,t);return i?{symbol:t.symbol,file:t.relativePath,tokens:i}:null}function Ze(e,n){let t=K(n.symbol),i=sn(e,n.relativePath,n.startLine,n.endLine,t),r=ke(i,t);return r.size>0?r:null}var We=z("source-fingerprint-corpus",{clearGroups:["whole-project","definition-catalog"]}),Xe=z("source-fingerprint-index",{clearGroups:["whole-project","definition-catalog"]});function he(e){return`${e.scanLimit??""}`}function Ce(e,n={}){let t=We.get(e,()=>new Map),i=he(n),r=t.get(i);return r||(r=rn(e,n),t.set(i,r)),r}function le(e,n={}){let t=Xe.get(e,()=>new Map),i=he(n),r=t.get(i);return r||(r=Je(Ce(e,n)),t.set(i,r)),r}function Je(e){let n=new Map;for(let r of e)for(let s of r.tokens)n.set(s,(n.get(s)??0)+1);let t=Math.max(8,Math.ceil(Math.sqrt(e.length))),i=new Map;for(let r of e)for(let s of r.tokens){if((n.get(s)??0)>t)continue;let a=i.get(s);a||(a=[],i.set(s,a)),a.push(r)}return{corpus:e,candidateByToken:i,docFreq:n,ubiquityThreshold:t}}function Ye(e,n){let t=new Map;for(let i of e.tokens)for(let r of n.candidateByToken.get(i)??[])r.symbol!==e.symbol&&t.set(r.symbol,r);return t.size>0?[...t.values()]:n.corpus.filter(i=>i.symbol!==e.symbol)}function Qe(e,n,t){let i=A(),r=new q(e),s=en(n.tokens.size,t.minSimilarity),a=0,o=0,c=0,m=y("similar.source-shape.target-files",()=>{let d=[...n.tokens],p=[];for(let b of Y(e,{includeIgnored:!1})){a+=1;let C=U(e,b);C&&(o+=1,nn(C,d,s)&&p.push(b))}return c=p.length,p},()=>({symbol:n.symbol,targetTokens:n.tokens.size,requiredSharedTokens:s,scannedFiles:a,readableFiles:o,candidateFiles:c})),g=0,f=y("similar.source-shape.target-definitions",()=>{let d=_(r.productionCallableDefinitions({files:m,sortByLocDesc:typeof t.scanLimit=="number"&&t.scanLimit>0}),t.scanLimit);return g=d.length,d},()=>({symbol:n.symbol,candidateFiles:c,scanLimit:t.scanLimit,definitionCount:g})),l=0;return y("similar.source-shape.target-fingerprints",()=>{let d=Fe(e,f);return i&&(l=d.length),d},()=>({symbol:n.symbol,definitionCount:g,fingerprintCount:l})).filter(d=>d.symbol!==n.symbol)}function en(e,n){return Math.max(2,Math.ceil(e*n))}function nn(e,n,t){if(n.length<t)return!1;let i=e.toLowerCase(),r=0;for(let s of n)if(tn(i,s)&&(r+=1,r>=t))return!0;return!1}function tn(e,n){return n==="num"?/\b\d+\b/.test(e):e.includes(n)}function rn(e,n={}){let t=new q(e),{scanLimit:i}=n,r=_(t.productionCallableDefinitions({sortByLocDesc:typeof i=="number"&&i>0}),i);return Fe(e,r)}function Fe(e,n){let t=new Map;for(let r of n){let s=t.get(r.relativePath)??[];s.push(r),t.set(r.relativePath,s)}let i=new Map;for(let[r,s]of t){let a=U(e,r);if(!a)continue;let o=J(e,r,a),c=on(e,r,o),m=!1,g=null;for(let f of s){let l=an(f),u=c.get(l),d=u?new Set(u.tokens):null;d||(g??=H(e,r),d=ke(xe(g,f.startLine,f.endLine,f.leaf),f.leaf),c.set(l,{key:l,symbol:f.symbol,startLine:f.startLine,endLine:f.endLine,leaf:f.leaf,tokens:[...d].sort()}),m=!0),d.size>0&&i.set(f.symbol,{symbol:f.symbol,file:f.relativePath,tokens:d})}m&&un(e,r,o,c)}return n.map(r=>i.get(r.symbol)).filter(r=>!!r)}function sn(e,n,t,i,r){let s=H(e,n);return s.length===0?"":xe(s,t,i,r)}function xe(e,n,t,i){if(t>=n&&t-n<=12)return e.slice(n,t+1).join(`
|
|
2
2
|
`);let r=[new RegExp(`\\bdef\\s+${E(i)}\\b`),new RegExp(`\\bfun\\s+${E(i)}\\b`),new RegExp(`\\bfn\\s+${E(i)}\\b`),new RegExp(`\\bfunction\\s+${E(i)}\\b`),new RegExp(`\\b${E(i)}\\s*\\(`)],s=e.findIndex(a=>r.some(o=>o.test(a)));if(s>=0){let a=s;for(let o=s+1;o<e.length&&o<=s+8;o++){let c=e[o]??"";if(o>s&&dn(c)||(a=o,c.trim()===""&&o>s+1))break}return e.slice(s,a+1).join(`
|
|
3
3
|
`)}return e.slice(n,Math.min(e.length,n+8)).join(`
|
|
4
4
|
`)}function an(e){return`${e.symbol}\0${e.startLine}\0${e.endLine}\0${e.leaf}`}function on(e,n,t){return me.read(e,n,t)??new Map}function ln(e){try{let n=JSON.parse(e);if(!Array.isArray(n.entries))return null;let t=new Map;for(let i of n.entries){if(!i||typeof i.key!="string"||typeof i.symbol!="string"||typeof i.startLine!="number"||typeof i.endLine!="number"||typeof i.leaf!="string"||!Array.isArray(i.tokens)||!i.tokens.every(r=>typeof r=="string"))return null;t.set(i.key,i)}return t}catch{return null}}function cn(e){let n={entries:[...e.values()].sort((t,i)=>t.key.localeCompare(i.key))};return JSON.stringify(n)}function un(e,n,t,i){me.write(e,n,t,new Map(i))}function ke(e,n){if(!e)return new Set;let t=new Set(["public","private","protected","final","static","class","def","fun","fn","function","return","string","bool","boolean","void","unit","self","this","new","const","let","var","end","pub"]),i=mn(n),s=e.replace(/["'`]/g," ").replace(/\b\d+\b/g," NUM ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[^A-Za-z0-9_]+/g," ").replace(/_/g," ").toLowerCase().split(/\s+/).map(a=>a.trim()).filter(a=>a.length>1).filter(a=>!t.has(a)).filter(a=>!i.has(a));return new Set(s)}function mn(e){return new Set(e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").split(/[^A-Za-z0-9_]+|_/).map(n=>n.toLowerCase()).filter(n=>n.length>1))}function dn(e){return/^\s*(?:def|fun|fn|function|class|trait|module|object|enum|interface|public|private|protected)\b/.test(e)}export{Ie as a,Tn as b,Te as c,ce as d,Mn as e,Ln as f,Ae as g,de as h,qe as i,G as j,Ne as k,Pe as l,fe as m,$e as n,ge as o,pe as p};
|
|
5
|
-
//# sourceMappingURL=chunk-
|
|
5
|
+
//# sourceMappingURL=chunk-SUE7SHZL.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$ as K,G as W,H as $,K as R,T as J,a as S,fa as q,g as m,h as b,i as A,j as G}from"./chunk-327YK6TB.js";import{createRequire as ce}from"module";import{existsSync as le,readdirSync as ue,statSync as pe}from"fs";import u from"path";import{AsyncLocalStorage as oe}from"async_hooks";var ae=new oe;function j(e,t){let n=C(e);if(!n||n.missing.has(t))return;let r=n.files.get(t);if(r)return r;let i=n.readBaseFile?.(t);return i&&n.files.set(t,i),i}function F(e,t){let n=C(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function U(e,t){return C(e)?.fingerprints.get(t)}function P(e){return C(e)?.paths}function C(e){let t=ae.getStore();if(t)return t.projectRoot===q(e)?t:void 0}var fe=ce(import.meta.url),X=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function ge(e,t=[]){let n=u.resolve(e),r=t.flatMap(s=>he(n,s));if(r.length>0)return Y(n,V(r));let i=de(n),o=V(i),c=me(n,o)?[n,...o]:o,a=c.length>0?c:[n];return Y(n,a)}function Z(e,t,n=[]){let r;try{r=fe("ts-morph")}catch{return null}let i=u.resolve(e),o=t==="workspace"?ge(i,n):["."],c=new Set;for(let a of o){let s=a==="."?i:u.join(i,a),l=u.join(s,"tsconfig.json"),p=je(r.ts,i);if(!p.fileExists(l))return null;let g=r.ts.readConfigFile(l,p.readFile);if(g.error)return null;let f=r.ts.parseJsonConfigFileContent(g.config,p,s);if(f.errors.length>0)return null;for(let h of f.fileNames){let d=u.resolve(h);m(i,d)&&c.add(u.relative(i,d).split(u.sep).join("/"))}}return c}function Y(e,t){return[...new Set(t.map(n=>x(e,n)))].sort((n,r)=>n.localeCompare(r))}function de(e){let t=P(e);if(t)return t.flatMap(i=>{if(i.split("/").some(c=>X.has(c)))return[];let o=u.join(e,...i.split("/"));return Q(e,o)?[u.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=ue(i,{withFileTypes:!0})}catch{continue}for(let c of o){let a=u.join(i,c.name);if(c.isDirectory()){!X.has(c.name)&&!c.name.startsWith(".")&&r.push(a);continue}c.isFile()&&Q(e,a)&&n.push(u.dirname(a))}}return n}function he(e,t){let n=t.trim();if(!n)return[];let r=u.resolve(e,n);if(!m(e,r))return[];let i=P(e);if(i){let o=x(e,r);if(i.includes(o)&&M(u.basename(r)))return[u.dirname(r)];let c=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(c))?[r]:[]}try{let o=pe(r);if(o.isDirectory())return[r];if(o.isFile()&&M(u.basename(r)))return[u.dirname(r)]}catch{return[]}return[]}function Q(e,t){if(!M(u.basename(t)))return!1;let n=ee(e,t);return n?u.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function M(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function V(e){let t=[...new Set(e.map(n=>u.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&be(n,r)))}function me(e,t){if(t.length===0||t.some(r=>u.resolve(r)===e))return!1;let n=u.join(e,"tsconfig.json");return Se(e,n)&&ye(e,n)}function ye(e,t){let r=ee(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!u.extname(i))):!1}function ee(e,t){try{let n=JSON.parse(Pe(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Se(e,t){let n=x(e,t),r=F(e,n);return r?r==="present":le(t)}function Pe(e,t){let n=x(e,t);if(P(e)){let i=j(e,n);if(!i)throw Object.assign(new Error(`Snapshot file ${n} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return $(t,"TypeScript project config")}function je(e,t){let n=P(t);if(!n)return e.sys;let r=u.resolve(t),i=new Set(n),o=Fe(r,n),c=e,a=s=>{let l=u.resolve(s);return m(r,l)?x(r,l):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(s){let l=a(s);return l===null?e.sys.fileExists(s):i.has(l)},readFile(s){let l=a(s);return l===null?e.sys.readFile(s):j(r,l)?.content.toString("utf8")},readDirectory(s,l,p,g,f){let h=u.resolve(s);return m(r,h)?c.matchFiles(h,l,p,g,e.sys.useCaseSensitiveFileNames,r,f,d=>o.get(u.resolve(d))??{files:[],directories:[]},d=>d):e.sys.readDirectory(s,l,p,g,f)}}}function Fe(e,t){let n=new Map,r=new Map,i=o=>{n.has(o)||n.set(o,new Set),r.has(o)||r.set(o,new Set)};i(e);for(let o of t){let c=o.split("/"),a=e;for(let s=0;s<c.length-1;s+=1){let l=c[s];i(a),r.get(a).add(l),a=u.join(a,l),i(a)}n.get(a).add(c.at(-1))}return new Map([...n].map(([o,c])=>[o,{files:[...c].sort(),directories:[...r.get(o)??[]].sort()}]))}function x(e,t){let n=u.relative(e,t);return n?n.split(u.sep).join("/"):"."}function be(e,t){let n=u.relative(e,t);return!!n&&!n.startsWith("..")&&!u.isAbsolute(n)}import{execFileSync as Ne}from"child_process";import{createHash as ne}from"crypto";import{closeSync as De,fstatSync as re,lstatSync as N,openSync as _e,readdirSync as He,readFileSync as Le,readlinkSync as Ae,realpathSync as I}from"fs";import{isAbsolute as Ge,join as D,relative as We,resolve as $e,sep as Re}from"path";import{execFileSync as k}from"child_process";import{createHash as xe}from"crypto";import{mkdirSync as ve,renameSync as we,writeFileSync as Ce}from"fs";import{basename as ze,dirname as Ie,join as Te}from"path";var Ee="git-content-hashes.json",Oe=32*1024*1024,Me=2e5,z=3e4;function B(){return{env:K(),encoding:"utf8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:z,killSignal:"SIGKILL"}}function te(e){let t,n;try{t=k("git",["-C",e,"ls-files","-s","-z","--","."],{...B(),timeout:z}),n=k("git",["-C",e,"status","--porcelain=v1","-z","--untracked-files=all","--no-renames","--","."],{...B(),timeout:z})}catch{return null}let r=new Map,i=[];for(let p of t.split("\0")){if(!p)continue;let g=p.indexOf(" "),f=g>0?p.slice(0,g).split(" "):[];if(f.length!==3)continue;let[h,d,w]=f,y=p.slice(g+1);if(h!=="100644"&&h!=="100755"||w!=="0"){r.delete(y);continue}r.set(y,d),ze(y)===".gitattributes"&&i.push(`${y}:${d}`)}let o=new Set;for(let p of n.split("\0"))p.length>=4&&p[2]===" "&&o.add(p.slice(3));let c=ke(e,i),a=Te(J(e),Ee),s=Be(a,c),l=new Map;return{lookup(p){if(o.has(p))return;let g=r.get(p);if(g)return l.get(g)??s.entries[g]},seed(p,g){if(o.has(p))return;let f=r.get(p);!f||s.entries[f]||l.has(f)||l.set(f,g)},persist(){if(l.size===0)return;let p=new Set(r.values()),g={};for(let[f,h]of Object.entries(s.entries))p.has(f)&&(g[f]=h);for(let[f,h]of l)g[f]=h;if(!(Object.keys(g).length>Me))try{ve(Ie(a),{recursive:!0});let f=`${a}.${process.pid}.tmp`;Ce(f,JSON.stringify({version:1,salt:c,entries:g})),we(f,a)}catch{}}}}function ke(e,t){let n="";try{n=k("git",["-C",e,"config","--get-regexp","^core\\.(autocrlf|eol|safecrlf)$"],{...B(),timeout:z})}catch{}return xe("sha256").update(JSON.stringify([n.trim(),t.sort()])).digest("hex")}function Be(e,t){let n={version:1,salt:t,entries:{}};try{let r=W(e,{maxBytes:Oe,inputKind:"git-content-hash-store"}),i=JSON.parse(r);if(i.version!==1||i.salt!==t||!i.entries||typeof i.entries!="object")return n;let o={};for(let[c,a]of Object.entries(i.entries))/^[0-9a-f]{40,64}$/.test(c)&&a&&typeof a.size=="number"&&Number.isInteger(a.size)&&a.size>=0&&typeof a.hash=="string"&&/^[0-9a-f]{64}$/.test(a.hash)&&(o[c]={size:a.size,hash:a.hash});return{version:1,salt:t,entries:o}}catch{return n}}var T=64*1024*1024,v=class extends Error{constructor(n,r,i,o){super(`${n} ${JSON.stringify(r)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="CODEBASEIQ_INPUT_TOO_LARGE"};function Je(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function ie(e,t,n={}){let r=b(t),i=I(e),o=$e(i,...r.split("/"));if(!m(i,o)||o===i)throw new S(t,"outside-project");let c=I(o);if(!m(i,c)||c===i)throw new S(t,"outside-project");let a=N(c);if(!a.isFile())throw new S(t,"not-a-file");let s={projectRoot:i,relativePath:r,absolutePath:c,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},l=n.maxBytes??T;if(se(l),s.size>l)throw new v(n.inputKind??"project file",s.relativePath,s.size,l);return s}function Ke(e,t,n={}){let r=b(t),i=F(e,r);if(i){if(i==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(r)} does not exist.`),{code:"ENOENT"});let s=j(e,r);if(!s)throw new S(r,"changed-during-read");let l=n.maxBytes??T;if(se(l),s.size>l)throw new v(n.inputKind??"project file",r,s.size,l);return Buffer.from(s.content)}let o=ie(e,t,n),c=n.maxBytes??T,a=_e(o.absolutePath,"r");try{let s=re(a);if(!s.isFile()||s.dev!==o.device||s.ino!==o.inode||s.size!==o.size)throw new S(t,"changed-during-read");if(s.size>c)throw new v(n.inputKind??"project file",o.relativePath,s.size,c);let l=Le(a),p=re(a);if(p.dev!==s.dev||p.ino!==s.ino||p.size!==s.size||l.byteLength!==s.size)throw new S(t,"changed-during-read");return l}finally{De(a)}}function Et(e,t,n={}){return Ke(e,t,n).toString("utf8")}function _(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function Ot(e,t){try{return ie(e,t),!0}catch(n){if(_(n))return!1;throw n}}function se(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}function qe(e){return(P(e)??Ze(e)??et(e)).filter(t=>t&&!H(t)).sort()}function Ue(e,t={}){let n=(t.includePaths??[]).map(b),r=[...new Set([...qe(e),...n])].filter(s=>!H(s)).filter(s=>!t.language||G(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort(),i=I(e),o,c=()=>o??=te(i),a=r.flatMap(s=>{let l=U(e,s);if(l)return[{path:s,size:l.fingerprintSize??l.size,hash:l.sha256}];let p=F(e,s);if(p==="present"){let d=j(e,s);if(d)return[{path:s,size:d.fingerprintSize??d.size,hash:d.sha256}]}let g=p===void 0?c():null,f=g?.lookup(s);if(f)return[{path:s,size:f.size,hash:f.hash}];let h=D(e,s);try{if(N(h).isSymbolicLink()){let E=I(h),O=We(i,E);if(O===".."||O.startsWith(`..${Re}`)||Ge(O))throw new Error("external symlink");let L=Ae(h);return[{path:s,size:Buffer.byteLength(L),hash:ne("sha256").update("symlink\0").update(L).digest("hex")}]}let d=ne("sha256"),w=R(h,{inputKind:"project fingerprint input",maxBytes:T},E=>d.update(E)),y=d.digest("hex");return g?.seed(s,{size:w,hash:y}),[{path:s,size:w,hash:y}]}catch(d){return _(d)?[]:[{path:s,size:-1,hash:"unreadable"}]}});return o?.persist(),a}function Mt(e,t,n){let r=Qe(t,n),i=[...r.typescriptProjects.filter(c=>Ye(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?Z(e,r.typescriptProjectMode,r.typescriptProjects):null;return{...r,files:Ue(e,{includePath:c=>{let a=A(c,t,i);return a==="other"?!1:a!=="source"||!Xe(c)||!o?!0:o.has(c)},includePaths:i})}}function Xe(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function Ye(e,t){let n;try{n=b(t)}catch{return!1}let r=F(e,n);if(r)return r==="present";try{return N(D(e,n)).isFile()}catch(i){if(_(i))return!1;throw i}}function Qe(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:Je(t.typescriptProjects),clojureConfigPath:Ve(t.clojureConfigPath)}}function Ve(e){return e?.trim()||void 0}function Ze(e){try{return Ne("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}).split(`
|
|
1
|
+
import{$ as K,G as W,H as $,K as R,T as J,a as S,fa as q,g as m,h as b,i as A,j as G}from"./chunk-UC2FD2PS.js";import{createRequire as ce}from"module";import{existsSync as le,readdirSync as ue,statSync as pe}from"fs";import u from"path";import{AsyncLocalStorage as oe}from"async_hooks";var ae=new oe;function j(e,t){let n=C(e);if(!n||n.missing.has(t))return;let r=n.files.get(t);if(r)return r;let i=n.readBaseFile?.(t);return i&&n.files.set(t,i),i}function F(e,t){let n=C(e);if(n)return n.missing.has(t)?"missing":n.paths.includes(t)?"present":"missing"}function U(e,t){return C(e)?.fingerprints.get(t)}function P(e){return C(e)?.paths}function C(e){let t=ae.getStore();if(t)return t.projectRoot===q(e)?t:void 0}var fe=ce(import.meta.url),X=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function ge(e,t=[]){let n=u.resolve(e),r=t.flatMap(s=>he(n,s));if(r.length>0)return Y(n,V(r));let i=de(n),o=V(i),c=me(n,o)?[n,...o]:o,a=c.length>0?c:[n];return Y(n,a)}function Z(e,t,n=[]){let r;try{r=fe("ts-morph")}catch{return null}let i=u.resolve(e),o=t==="workspace"?ge(i,n):["."],c=new Set;for(let a of o){let s=a==="."?i:u.join(i,a),l=u.join(s,"tsconfig.json"),p=je(r.ts,i);if(!p.fileExists(l))return null;let g=r.ts.readConfigFile(l,p.readFile);if(g.error)return null;let f=r.ts.parseJsonConfigFileContent(g.config,p,s);if(f.errors.length>0)return null;for(let h of f.fileNames){let d=u.resolve(h);m(i,d)&&c.add(u.relative(i,d).split(u.sep).join("/"))}}return c}function Y(e,t){return[...new Set(t.map(n=>x(e,n)))].sort((n,r)=>n.localeCompare(r))}function de(e){let t=P(e);if(t)return t.flatMap(i=>{if(i.split("/").some(c=>X.has(c)))return[];let o=u.join(e,...i.split("/"));return Q(e,o)?[u.dirname(o)]:[]});let n=[],r=[e];for(;r.length>0;){let i=r.pop(),o;try{o=ue(i,{withFileTypes:!0})}catch{continue}for(let c of o){let a=u.join(i,c.name);if(c.isDirectory()){!X.has(c.name)&&!c.name.startsWith(".")&&r.push(a);continue}c.isFile()&&Q(e,a)&&n.push(u.dirname(a))}}return n}function he(e,t){let n=t.trim();if(!n)return[];let r=u.resolve(e,n);if(!m(e,r))return[];let i=P(e);if(i){let o=x(e,r);if(i.includes(o)&&M(u.basename(r)))return[u.dirname(r)];let c=o==="."?"":`${o}/`;return i.some(a=>a.startsWith(c))?[r]:[]}try{let o=pe(r);if(o.isDirectory())return[r];if(o.isFile()&&M(u.basename(r)))return[u.dirname(r)]}catch{return[]}return[]}function Q(e,t){if(!M(u.basename(t)))return!1;let n=ee(e,t);return n?u.basename(t)==="tsconfig.json"||"include"in n||"files"in n||"references"in n:!1}function M(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function V(e){let t=[...new Set(e.map(n=>u.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&be(n,r)))}function me(e,t){if(t.length===0||t.some(r=>u.resolve(r)===e))return!1;let n=u.join(e,"tsconfig.json");return Se(e,n)&&ye(e,n)}function ye(e,t){let r=ee(e,t)?.include;return Array.isArray(r)?r.some(i=>typeof i=="string"&&i.trim()!==""&&!i.startsWith("!")&&(i.includes("/")||i.includes("**")||!u.extname(i))):!1}function ee(e,t){try{let n=JSON.parse(Pe(e,t));return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Se(e,t){let n=x(e,t),r=F(e,n);return r?r==="present":le(t)}function Pe(e,t){let n=x(e,t);if(P(e)){let i=j(e,n);if(!i)throw Object.assign(new Error(`Snapshot file ${n} is missing.`),{code:"ENOENT"});return i.content.toString("utf8")}return $(t,"TypeScript project config")}function je(e,t){let n=P(t);if(!n)return e.sys;let r=u.resolve(t),i=new Set(n),o=Fe(r,n),c=e,a=s=>{let l=u.resolve(s);return m(r,l)?x(r,l):null};return{useCaseSensitiveFileNames:e.sys.useCaseSensitiveFileNames,fileExists(s){let l=a(s);return l===null?e.sys.fileExists(s):i.has(l)},readFile(s){let l=a(s);return l===null?e.sys.readFile(s):j(r,l)?.content.toString("utf8")},readDirectory(s,l,p,g,f){let h=u.resolve(s);return m(r,h)?c.matchFiles(h,l,p,g,e.sys.useCaseSensitiveFileNames,r,f,d=>o.get(u.resolve(d))??{files:[],directories:[]},d=>d):e.sys.readDirectory(s,l,p,g,f)}}}function Fe(e,t){let n=new Map,r=new Map,i=o=>{n.has(o)||n.set(o,new Set),r.has(o)||r.set(o,new Set)};i(e);for(let o of t){let c=o.split("/"),a=e;for(let s=0;s<c.length-1;s+=1){let l=c[s];i(a),r.get(a).add(l),a=u.join(a,l),i(a)}n.get(a).add(c.at(-1))}return new Map([...n].map(([o,c])=>[o,{files:[...c].sort(),directories:[...r.get(o)??[]].sort()}]))}function x(e,t){let n=u.relative(e,t);return n?n.split(u.sep).join("/"):"."}function be(e,t){let n=u.relative(e,t);return!!n&&!n.startsWith("..")&&!u.isAbsolute(n)}import{execFileSync as Ne}from"child_process";import{createHash as ne}from"crypto";import{closeSync as De,fstatSync as re,lstatSync as N,openSync as _e,readdirSync as He,readFileSync as Le,readlinkSync as Ae,realpathSync as I}from"fs";import{isAbsolute as Ge,join as D,relative as We,resolve as $e,sep as Re}from"path";import{execFileSync as k}from"child_process";import{createHash as xe}from"crypto";import{mkdirSync as ve,renameSync as we,writeFileSync as Ce}from"fs";import{basename as ze,dirname as Ie,join as Te}from"path";var Ee="git-content-hashes.json",Oe=32*1024*1024,Me=2e5,z=3e4;function B(){return{env:K(),encoding:"utf8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:z,killSignal:"SIGKILL"}}function te(e){let t,n;try{t=k("git",["-C",e,"ls-files","-s","-z","--","."],{...B(),timeout:z}),n=k("git",["-C",e,"status","--porcelain=v1","-z","--untracked-files=all","--no-renames","--","."],{...B(),timeout:z})}catch{return null}let r=new Map,i=[];for(let p of t.split("\0")){if(!p)continue;let g=p.indexOf(" "),f=g>0?p.slice(0,g).split(" "):[];if(f.length!==3)continue;let[h,d,w]=f,y=p.slice(g+1);if(h!=="100644"&&h!=="100755"||w!=="0"){r.delete(y);continue}r.set(y,d),ze(y)===".gitattributes"&&i.push(`${y}:${d}`)}let o=new Set;for(let p of n.split("\0"))p.length>=4&&p[2]===" "&&o.add(p.slice(3));let c=ke(e,i),a=Te(J(e),Ee),s=Be(a,c),l=new Map;return{lookup(p){if(o.has(p))return;let g=r.get(p);if(g)return l.get(g)??s.entries[g]},seed(p,g){if(o.has(p))return;let f=r.get(p);!f||s.entries[f]||l.has(f)||l.set(f,g)},persist(){if(l.size===0)return;let p=new Set(r.values()),g={};for(let[f,h]of Object.entries(s.entries))p.has(f)&&(g[f]=h);for(let[f,h]of l)g[f]=h;if(!(Object.keys(g).length>Me))try{ve(Ie(a),{recursive:!0});let f=`${a}.${process.pid}.tmp`;Ce(f,JSON.stringify({version:1,salt:c,entries:g})),we(f,a)}catch{}}}}function ke(e,t){let n="";try{n=k("git",["-C",e,"config","--get-regexp","^core\\.(autocrlf|eol|safecrlf)$"],{...B(),timeout:z})}catch{}return xe("sha256").update(JSON.stringify([n.trim(),t.sort()])).digest("hex")}function Be(e,t){let n={version:1,salt:t,entries:{}};try{let r=W(e,{maxBytes:Oe,inputKind:"git-content-hash-store"}),i=JSON.parse(r);if(i.version!==1||i.salt!==t||!i.entries||typeof i.entries!="object")return n;let o={};for(let[c,a]of Object.entries(i.entries))/^[0-9a-f]{40,64}$/.test(c)&&a&&typeof a.size=="number"&&Number.isInteger(a.size)&&a.size>=0&&typeof a.hash=="string"&&/^[0-9a-f]{64}$/.test(a.hash)&&(o[c]={size:a.size,hash:a.hash});return{version:1,salt:t,entries:o}}catch{return n}}var T=64*1024*1024,v=class extends Error{constructor(n,r,i,o){super(`${n} ${JSON.stringify(r)} is ${i} bytes; the safety limit is ${o} bytes`);this.inputKind=n;this.inputPath=r;this.observedBytes=i;this.limitBytes=o;this.name="InputTooLargeError"}inputKind;inputPath;observedBytes;limitBytes;code="CODEBASEIQ_INPUT_TOO_LARGE"};function Je(e){return[...new Set((e??[]).map(t=>t.trim()).filter(Boolean))].sort((t,n)=>t.localeCompare(n))}function ie(e,t,n={}){let r=b(t),i=I(e),o=$e(i,...r.split("/"));if(!m(i,o)||o===i)throw new S(t,"outside-project");let c=I(o);if(!m(i,c)||c===i)throw new S(t,"outside-project");let a=N(c);if(!a.isFile())throw new S(t,"not-a-file");let s={projectRoot:i,relativePath:r,absolutePath:c,size:a.size,mtimeMs:a.mtimeMs,device:a.dev,inode:a.ino},l=n.maxBytes??T;if(se(l),s.size>l)throw new v(n.inputKind??"project file",s.relativePath,s.size,l);return s}function Ke(e,t,n={}){let r=b(t),i=F(e,r);if(i){if(i==="missing")throw Object.assign(new Error(`Snapshot project file ${JSON.stringify(r)} does not exist.`),{code:"ENOENT"});let s=j(e,r);if(!s)throw new S(r,"changed-during-read");let l=n.maxBytes??T;if(se(l),s.size>l)throw new v(n.inputKind??"project file",r,s.size,l);return Buffer.from(s.content)}let o=ie(e,t,n),c=n.maxBytes??T,a=_e(o.absolutePath,"r");try{let s=re(a);if(!s.isFile()||s.dev!==o.device||s.ino!==o.inode||s.size!==o.size)throw new S(t,"changed-during-read");if(s.size>c)throw new v(n.inputKind??"project file",o.relativePath,s.size,c);let l=Le(a),p=re(a);if(p.dev!==s.dev||p.ino!==s.ino||p.size!==s.size||l.byteLength!==s.size)throw new S(t,"changed-during-read");return l}finally{De(a)}}function Et(e,t,n={}){return Ke(e,t,n).toString("utf8")}function _(e){return typeof e=="object"&&e!==null&&"code"in e&&(e.code==="ENOENT"||e.code==="ENOTDIR")}function Ot(e,t){try{return ie(e,t),!0}catch(n){if(_(n))return!1;throw n}}function se(e){if(!Number.isSafeInteger(e)||e<0)throw new RangeError(`maxBytes must be a non-negative safe integer; received ${e}`)}function qe(e){return(P(e)??Ze(e)??et(e)).filter(t=>t&&!H(t)).sort()}function Ue(e,t={}){let n=(t.includePaths??[]).map(b),r=[...new Set([...qe(e),...n])].filter(s=>!H(s)).filter(s=>!t.language||G(s,t.language,t.markerFiles)).filter(s=>!t.includePath||t.includePath(s)).sort(),i=I(e),o,c=()=>o??=te(i),a=r.flatMap(s=>{let l=U(e,s);if(l)return[{path:s,size:l.fingerprintSize??l.size,hash:l.sha256}];let p=F(e,s);if(p==="present"){let d=j(e,s);if(d)return[{path:s,size:d.fingerprintSize??d.size,hash:d.sha256}]}let g=p===void 0?c():null,f=g?.lookup(s);if(f)return[{path:s,size:f.size,hash:f.hash}];let h=D(e,s);try{if(N(h).isSymbolicLink()){let E=I(h),O=We(i,E);if(O===".."||O.startsWith(`..${Re}`)||Ge(O))throw new Error("external symlink");let L=Ae(h);return[{path:s,size:Buffer.byteLength(L),hash:ne("sha256").update("symlink\0").update(L).digest("hex")}]}let d=ne("sha256"),w=R(h,{inputKind:"project fingerprint input",maxBytes:T},E=>d.update(E)),y=d.digest("hex");return g?.seed(s,{size:w,hash:y}),[{path:s,size:w,hash:y}]}catch(d){return _(d)?[]:[{path:s,size:-1,hash:"unreadable"}]}});return o?.persist(),a}function Mt(e,t,n){let r=Qe(t,n),i=[...r.typescriptProjects.filter(c=>Ye(e,c)),...r.clojureConfigPath?[r.clojureConfigPath]:[]],o=r.languages.includes("typescript")?Z(e,r.typescriptProjectMode,r.typescriptProjects):null;return{...r,files:Ue(e,{includePath:c=>{let a=A(c,t,i);return a==="other"?!1:a!=="source"||!Xe(c)||!o?!0:o.has(c)},includePaths:i})}}function Xe(e){return/\.(?:[cm]?[jt]sx?|vue)$/iu.test(e)}function Ye(e,t){let n;try{n=b(t)}catch{return!1}let r=F(e,n);if(r)return r==="present";try{return N(D(e,n)).isFile()}catch(i){if(_(i))return!1;throw i}}function Qe(e,t){return{version:3,languages:[...e].sort(),pnpmWorkspaces:t.typescriptProjectMode!=="workspace"&&t.pnpmWorkspaces===!0,typescriptProjectMode:t.typescriptProjectMode??"single",typescriptProjects:Je(t.typescriptProjects),clojureConfigPath:Ve(t.clojureConfigPath)}}function Ve(e){return e?.trim()||void 0}function Ze(e){try{return Ne("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:50*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}).split(`
|
|
2
2
|
`).filter(Boolean)}catch{return null}}function et(e){let t=[],n=[""];for(;n.length>0;){let r=n.pop(),i=r?D(e,r):e,o;try{o=He(i,{withFileTypes:!0})}catch{continue}for(let c of o){let a=r?`${r}/${c.name}`:c.name;if(c.isDirectory()){H(a)||n.push(a);continue}t.push(a)}}return t}function H(e){let t=e.split("/");return e==="meta.json"||t[0]===".codebaseiq"&&(t[1]==="events"||t[1]==="ledger"||t[1]==="releases"||t[1]==="suppressions")||t.some(n=>tt.has(n))||e.endsWith(".db")||e.endsWith(".db-wal")||e.endsWith(".db-shm")||e.endsWith(".scip")}var tt=new Set([".git","node_modules",".codebaseiq-cache",".codebaseiq-generations",".stryker-tmp","dist","build","coverage",".next",".nuxt","target"]);export{ge as a,v as b,Je as c,ie as d,Ke as e,Et as f,_ as g,Ot as h,qe as i,Ue as j,Mt as k,Qe as l};
|
|
3
|
-
//# sourceMappingURL=chunk-
|
|
3
|
+
//# sourceMappingURL=chunk-SX72EVMY.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as f}from"./chunk-
|
|
1
|
+
import{c as f}from"./chunk-BPKNP3KZ.js";import{a as b,d as g}from"./chunk-NDKOVQFG.js";import{d as m}from"./chunk-GVAF222T.js";import{o as u,p as _,q as a}from"./chunk-F74LZWCE.js";import{a as l}from"./chunk-ICUL7XRT.js";import{w as p}from"./chunk-7GAK2F3H.js";function B(e,t={}){let{scope:o,limit:r}=t,i=new f(e),s=T([...x(e,o),...y(e,i,o)]);return F(s),r?s.slice(0,r):s}function x(e,t){let o=[];for(let r of N(e,t)){if(e.isIgnored(r.barrel_path)||e.isIgnored(r.original_path)||g(e,r.barrel_path)||p(e,r.barrel_path)&&a(e,r.barrel_path).length===0)continue;let i=I(e,r),s=i?.barrel_consumers??0,n=i?.direct_consumers??0;s!==0||n!==0||o.push({barrelFile:r.barrel_path,symbol:r.symbol,shortName:m(r.symbol),originalFile:r.original_path,barrelConsumers:s,directConsumers:n,...h(e,r.barrel_path)})}return o}function N(e,t){let o=t?"AND barrel_d.relative_path LIKE ?":"",r=t?[`%${t}%`]:[];return e.all(`WITH barrel_refs AS MATERIALIZED (
|
|
2
2
|
SELECT DISTINCT
|
|
3
3
|
barrel_d.id AS barrel_doc_id,
|
|
4
4
|
barrel_d.relative_path AS barrel_path,
|
|
@@ -71,4 +71,4 @@ import{c as f}from"./chunk-NK76RSB6.js";import{a as b,d as g}from"./chunk-JN5LIB
|
|
|
71
71
|
${e.pathExclusionsFor("consumer_d")}
|
|
72
72
|
GROUP BY consumer_d.id
|
|
73
73
|
)`,t.barrel_doc_id,t.symbol_id,t.barrel_doc_id,t.original_doc_id)}function y(e,t,o){let r=[],i=C(e);for(let s of O(e,o))E(i,s,s)>0||r.push(...D(e,t,s,i));return r}function O(e,t){return l(e,{scope:t,includeIgnored:!1}).filter(o=>a(e,o).length>0||u(e,o).length>0)}function D(e,t,o,r){let i=a(e,o).filter(n=>n.sourcePath&&!e.isIgnored(n.sourcePath)).flatMap(n=>R(e,t,o,n.sourcePath,r,[A(n.specifier)])),s=u(e,o).filter(n=>n.sourcePath&&!e.isIgnored(n.sourcePath)).flatMap(n=>R(e,t,o,n.sourcePath,r,n.kind==="named"&&n.names.length>0?n.names:[n.kind==="star"?`* from ${n.sourcePath}`:`* namespace from ${n.sourcePath}`]));return[...i,...s]}function R(e,t,o,r,i,s){let n=t.definitionsForFile(r);return s.map(c=>{let d=n.find(S=>S.leaf===c);return{barrelFile:o,symbol:d?.symbol??`source-reexport:${o}:${c}`,shortName:d?m(d.symbol):c,originalFile:r,barrelConsumers:0,directConsumers:E(i,r,o),...h(e,o)}})}function A(e){return e.split("::").at(-1)?.split("/").at(-1)?.replace(/\.[^.]+$/,"")??e}function h(e,t){return b(e,t)?{actionTier:"signal",surfaceEvidence:["barrel file is declared on the package public surface"],recommendation:"Review the package API before removing this re-export; local consumers are zero, but external consumers may import through the public barrel."}:{actionTier:"direct",surfaceEvidence:[],recommendation:"Remove this unused re-export when the barrel is not part of an external API surface."}}function C(e){let t=new Map;for(let o of l(e,{includeIgnored:!1}))for(let r of _(e,o)){if(!r.sourcePath)continue;let i=t.get(r.sourcePath)??new Set;i.add(o),t.set(r.sourcePath,i)}return t}function E(e,t,o){let r=e.get(t);return r?r.size-(r.has(o)?1:0):0}function T(e){let t=new Set,o=[];for(let r of e){let i=`${r.barrelFile}|${r.symbol}|${r.originalFile}`;t.has(i)||(t.add(i),o.push(r))}return o}function F(e){e.sort((t,o)=>o.directConsumers-t.directConsumers||t.barrelFile.localeCompare(o.barrelFile)||t.shortName.localeCompare(o.shortName))}export{B as a};
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-SZ4P7MF7.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as C,b as x,c as K,d as $}from"./chunk-
|
|
1
|
+
import{a as C,b as x,c as K,d as $}from"./chunk-QY7QB7I6.js";import{a as A}from"./chunk-DGXRDLV5.js";import{b as L,c as R}from"./chunk-BPKNP3KZ.js";import{a as y}from"./chunk-BGBBVSH4.js";import{h as M}from"./chunk-NDKOVQFG.js";import{a as k}from"./chunk-BRQL7AFJ.js";import{b as F,d as P,e as g}from"./chunk-GVAF222T.js";import{l as T}from"./chunk-F74LZWCE.js";import{w as I}from"./chunk-7GAK2F3H.js";function me(t,e){let{scope:n,minLoc:i=3,maxLoc:s=80,limit:a=30,includeLowConfidence:c=!1,scanLimit:o}=e??{},f=e?.semantic!==!1,r=new R(t),d=r.scopedDefinitions(n),b=Q(r,n),l={high:0,medium:1,low:2};return A({candidates:()=>U(t,r,d,{minLoc:i,maxLoc:s}),orderCandidates:(u,m)=>y(m)-y(u)||u.relativePath.localeCompare(m.relativePath),scanLimit:o,profile:{name:"stale-abstractions"},prepare:u=>{let m=W(u),p=O(t,r,u,m,{semantic:f}),S=u.filter(h=>{if(p.incompleteSymbolIds.has(h.symbolId)||p.unavailableSymbolIds.has(h.symbolId)||r.hasSuppressionComment(h))return!1;let D=v(t,h,p.consumerFileMap,m);return D.realConsumers.length<=1&&!D.transitivelyReachable&&j(h,D.realConsumers.length,b)});return{...p,singletonBackedClassIds:H(t,r,d,S,{semantic:f}),candidateIndex:m}},evaluate:(u,m)=>{if(m.incompleteSymbolIds.has(u.symbolId)||m.unavailableSymbolIds.has(u.symbolId)||r.hasSuppressionComment(u)||m.singletonBackedClassIds.has(u.symbolId))return null;let p=v(t,u,m.consumerFileMap,m.candidateIndex);if(p.transitivelyReachable||p.realConsumers.length>1||p.realConsumers.length===0&&p.barrelConsumers>0||!j(p.definition,p.realConsumers.length,b))return null;let S=V(t,p);return!c&&S.confidence==="low"?null:S},orderResults:(u,m)=>l[u.confidence]-l[m.confidence]||m.loc-u.loc||u.file.localeCompare(m.file)||u.startLine-m.startLine,limit:a})}function U(t,e,n,i){return n.filter(s=>s.isTypeLike&&y(s)>=i.minLoc).filter(s=>y(s)<=i.maxLoc).filter(s=>!t.isIgnored(s.relativePath)).filter(s=>!s.relativePath.endsWith(".d.ts")).filter(s=>k(s.relativePath)!=="test").filter(s=>!M(t,s.symbol,s.relativePath)).filter(s=>!X(s.symbol))}function B(t,e,n,i){return x(C(t,e).forDefinitions(n,{semantic:i.semantic,sourceFallback:i.sourceFallback}))}function O(t,e,n,i,s){let a=B(t,e,n,{semantic:!1,sourceFallback:!1}),c=n.filter(l=>{let u=v(t,l,a,i);return u.realConsumers.length<=1&&!(u.realConsumers.length>0&&w(l.relativePath))}),o=C(t,e).forDefinitions(c,{semantic:s.semantic,sourceFallback:!1}),f=new Set([...o.values()].filter(l=>l.semanticIncomplete).map(l=>l.definition.symbolId)),r=new Set([...o.values()].filter(l=>l.semanticUnavailable).map(l=>l.definition.symbolId)),d=s.semantic&&c.length>0?L(a,x(o)):a,b=c.filter(l=>v(t,l,d,i).realConsumers.length<=1);return{consumerFileMap:L(d,B(t,e,b,{semantic:!1,sourceFallback:!0})),incompleteSymbolIds:f,unavailableSymbolIds:r}}function W(t){let e=new Map;for(let n of t){let i=e.get(n.relativePath);i||(i=new Map,e.set(n.relativePath,i));let s=g(n.symbol);s&&i.set(s,n)}return e}function v(t,e,n,i){let a=[...n.get(e.symbolId)??new Set].filter(d=>d!==e.relativePath&&!t.isIgnored(d)),{realConsumers:c,barrelConsumers:o,importOnlyConsumers:f}=K(t,e,a),r=Y(t,e,n,i);return{definition:e,realConsumers:c,barrelConsumers:o+f,transitivelyReachable:r}}function V(t,e){let n=N(t,e.definition.relativePath,e.definition.startLine),i=w(e.definition.relativePath)?!0:ee(t,e.definition),{confidence:s,reason:a}=ne(e.realConsumers.length,n,i),c=z(e.realConsumers.length,n,i);return{symbol:e.definition.symbol,shortName:P(e.definition.symbol),file:e.definition.relativePath,startLine:e.definition.startLine,endLine:e.definition.endLine,loc:y(e.definition),consumers:e.realConsumers.length,barrelConsumers:e.barrelConsumers,kind:n,definerUsesType:i,confidence:s,reason:a,actionTier:c.actionTier,stalenessKind:c.stalenessKind,recommendation:c.recommendation}}function z(t,e,n){return t===0?{actionTier:"direct",stalenessKind:"unused-abstraction",recommendation:"Delete the abstraction or wire the missing consumer after checking public/package surfaces."}:e==="class"?{actionTier:"signal",stalenessKind:"one-to-one-class-encapsulation",recommendation:"Treat as weak signal: a one-consumer class may be intentional encapsulation, so inline only after reviewing ownership and state boundaries."}:n?{actionTier:"signal",stalenessKind:"single-consumer-abstraction",recommendation:"Review whether this single-consumer abstraction earns its name or should be folded into the owning feature."}:{actionTier:"signal",stalenessKind:"misplaced-single-consumer-type",recommendation:"Review moving or co-locating the type with its only real consumer; keep it here only if this file owns the public contract."}}function H(t,e,n,i,s){let a=_(t,Z(n),i),c=a.map(d=>d.singleton);if(a.length===0)return new Set;let o=C(t,e).forDefinitions(c,{semantic:s.semantic,sourceFallback:!0}),f=x(o),r=new Set;for(let{singleton:d,classId:b}of a){let l=o.get(d.symbolId);(l?.semanticIncomplete||l?.semanticUnavailable||G(t,d,f))&&r.add(b)}return r}function Z(t){let e=new Map;for(let n of t){let i=g(n.symbol);i&&e.set(E(n.relativePath,i),n)}return e}function _(t,e,n){let i=[];for(let s of n){let a=q(t,e,s);a&&i.push({singleton:a,classId:s.symbolId})}return i}function q(t,e,n){if(N(t,n.relativePath,n.startLine)!=="class")return null;let i=g(n.symbol);if(!i)return null;let s=J(t,n.relativePath,i);return s?e.get(E(n.relativePath,s))??null:null}function G(t,e,n){let i=g(e.symbol),s=n.get(e.symbolId);return!i||!s?!1:[...s].some(a=>a!==e.relativePath&&!t.isIgnored(a)&&!$(t,a,i))}function E(t,e){return`${t}\0${e}`}function J(t,e,n){let i=I(t,e);if(!i)return null;let s=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\bexport\\s+const\\s+([A-Za-z_$][\\w$]*)\\s*=\\s*new\\s+${s}\\s*\\(`);return i.match(a)?.[1]??null}function Q(t,e){return new Set(t.scopedDefinitions(e).filter(n=>n.isFunctionLike).map(n=>n.relativePath))}function X(t){let e=F(t);if("kind"in e)return!1;let n=e.descriptors;if(n.length<2)return!1;let i=n[n.length-1],s=n[n.length-2];return i?.suffix==="type"&&s?.suffix==="type"}function w(t){let n=(t.split("/").pop()??"").replace(/\.[^.]+$/,"");return!!(n==="types"||n.endsWith("-types")||n==="models"||n==="schema"||n==="common"||n==="protocol"||n==="proto"||n==="dto"||n==="mod"||n==="contracts"||/(^|\/)types(\/|\.)/.test(t)||/(^|\/)models?(\/|\.)/.test(t)||/(^|\/)proto(?:col)?(\/|\.)/.test(t)||/(^|\/)schema(\/|\.)/.test(t)||/(^|\/)contracts?(\/|\.)/.test(t))}function j(t,e,n){return!(w(t.relativePath)&&e>0||e===0&&n.has(t.relativePath))}function Y(t,e,n,i){let s=T(t,e.relativePath),a=g(e.symbol);if(!a)return!1;let c=i.get(e.relativePath);if(!c)return!1;let o=[...s.get(a)??[]],f=new Set;for(;o.length>0;){let r=o.pop();if(f.has(r))continue;f.add(r);let d=c.get(r);if(!d)continue;let b=n.get(d.symbolId);if(b){for(let l of b)if(l!==e.relativePath&&!t.isIgnored(l))return!0}for(let l of s.get(r)??[])o.push(l)}return!1}function N(t,e,n){let i=I(t,e);if(!i)return"other";let s=i.split(`
|
|
2
2
|
`),a=Math.max(0,n-2),c=Math.min(s.length-1,n+2);for(let o=a;o<=c;o++){let r=(s[o]??"").replace(/^\s*\/\/.*$/g,"");if(/\b(?:export\s+)?(?:abstract\s+)?class\s+\w/.test(r))return"class";if(/\b(?:export\s+)?interface\s+\w/.test(r))return"interface";if(/\b(?:export\s+)?type\s+\w/.test(r))return"type";if(/\b(?:export\s+)?(?:const\s+)?enum\s+\w/.test(r))return"enum"}return"other"}function ee(t,e){let n=I(t,e.relativePath);if(!n)return!1;let i=g(e.symbol);if(!i)return!1;let s=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`\\b${s}\\b`),c=n.split(`
|
|
3
3
|
`);for(let o=0;o<c.length;o++)if(!(o>=e.startLine&&o<=e.endLine)&&a.test(c[o]??""))return!0;return!1}function ne(t,e,n){return t===0?{confidence:"high",reason:"unused \u2014 no consumers and defining file has no real usage"}:t===1&&e==="class"?{confidence:"low",reason:"1 consumer + class kind \u2014 likely 1:1 encapsulation, not over-abstraction"}:t===1&&!n?{confidence:"high",reason:"1 consumer + defining file never uses it \u2014 type belongs with its consumer"}:{confidence:"medium",reason:"1 consumer \u2014 single-use abstraction"}}export{me as a};
|
|
4
|
-
//# sourceMappingURL=chunk-
|
|
4
|
+
//# sourceMappingURL=chunk-T2M5HWBQ.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as y}from"./chunk-
|
|
1
|
+
import{a as y}from"./chunk-U7NUXDQO.js";import{b as f}from"./chunk-SGMNWYTH.js";import{c as h,d as w}from"./chunk-SGX43S2L.js";import{d as u,e as m,h as b,p,q as g}from"./chunk-GVAF222T.js";import{dirname as $,isAbsolute as k,relative as x,resolve as v}from"path";var C=new Set(w());function R(t,e){return`tests/generated/twin-ab/${d(t)}-vs-${d(e)}.test.ts`}function d(t){return(t.split(/[/#]/).pop()||t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"symbol"}function P(t,e,a,n){let{refA:l,refB:s,outFile:r}=typeof e=="string"?{refA:e,refB:a,outFile:n}:e;if(typeof l!="string"||typeof s!="string"||typeof r!="string")throw new TypeError("twinAb requires refA, refB, and outFile.");if(!k(r))throw new TypeError("twinAb outFile must be an absolute path.");let i=A(t,l);if(!i.ok)return i;let o=A(t,s);if(!o.ok)return o;let c=i.symbol.paramCount===null||o.symbol.paramCount===null?null:i.symbol.paramCount===o.symbol.paramCount,S=N(i.symbol,o.symbol,t.config.projectRoot,r,c);return{ok:!0,a:i.symbol,b:o.symbol,signatureCompatible:c,testSource:S}}function A(t,e){let n=f(t,e).match;if(!n)return{ok:!1,reason:`${e} does not resolve to an indexed symbol.`};let s=t.get("SELECT kind FROM global_symbols WHERE id = ?",n.symbolId)?.kind??null;if(!(s!==null?C.has(s):b(n.symbol)))return{ok:!1,reason:`${e} resolves to ${u(n.symbol)}${s!==null?` with SCIP kind ${h(s)}`:""} \u2014 twin-ab compares call outputs, so both referents must be functions or methods.`};if(!y(t,n))return{ok:!1,reason:`${e} (${u(n.symbol)} at ${n.relativePath}:${n.startLine+1}) is not exported \u2014 twin-ab needs an importable named binding for both twins.`};let i=t.get("SELECT documentation FROM global_symbols WHERE id = ?",n.symbolId),o=p(g(i?.documentation??null));return{ok:!0,symbol:{ref:e,symbol:n.symbol,shortName:m(n.symbol)||u(n.symbol),file:n.relativePath,startLine:n.startLine,signature:o,paramCount:o?E(o):null}}}function E(t){let e=t.indexOf("(");if(e===-1)return null;let a=0,n=-1;for(let i=e;i<t.length;i+=1){let o=t[i];if(o==="(")a+=1;else if(o===")"&&(a-=1,a===0)){n=i;break}}if(n===-1)return null;let l=t.slice(e+1,n).trim();if(!l)return 0;let s=1,r=0;for(let i of l)i==="("||i==="["||i==="{"?r+=1:i===")"||i==="]"||i==="}"?r=Math.max(0,r-1):i===","&&r===0&&(s+=1);return s}function T(t,e,a){let n=$(e),l=v(t,a),r=x(n,l).replace(/\\/g,"/").replace(/\.tsx?$/,".js");return r.startsWith(".")?r:`./${r}`}function N(t,e,a,n,l){let s=T(a,n,t.file),r=T(a,n,e.file),i=l===null?"Signature comparison: unknown (one or both signatures unavailable in the index) \u2014 check by hand.":l?"Signature comparison: param counts match.":"Signature comparison: param counts DIFFER \u2014 twins may not be directly comparable; check by hand.";return`/**
|
|
2
2
|
* Generated by 'codebaseiq twin-ab'. Cleanup integrity scenario.
|
|
3
3
|
* ("cross-examine same-concept twins"): where one concept is computed in
|
|
4
4
|
* more than one place, feed both the same input and require the same
|
|
@@ -37,4 +37,4 @@ describe.skipIf(inputs.length === 0)('twin-ab: ${t.shortName} vs ${e.shortName}'
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
`}export{R as a,P as b};
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-T6MQNNAC.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import{a as Ee,b as We,e as Kt}from"./chunk-RCIGX23V.js";import{a as _,b as Wt,i as b,j as ie,l as Ce,o as Ae,r as F,s as G}from"./chunk-D7DOB27N.js";import{a as te,c as Ut,d as Jt,e as ne}from"./chunk-6O3KXIDL.js";import{C as Vt,D as K,F as Ge,G as Qt,J as Ht,K as Ve,L as Te,M as Qe,P as He,T as oe,V as Yt,a as R,b as J,c as E,f as w,g as v,h as S,ha as Ue,ia as Je,l as $t,m as Y,q as zt,v as Pe,w as j,x as re}from"./chunk-UQYQBLJX.js";var Xt=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],mo=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Ye=2,z=3;var Ke=new Set(Xt);function ke(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${Pn(a)}`}}if(!_(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let r=t.version;if(!Number.isInteger(r))return{kind:"malformed",reason:"version must be an integer"};if(r!==Ye&&r!==z)return{kind:"unsupported",version:r,direction:r<Ye?"older":"future"};let n=xn(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:In(i)};return r===Ye?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function xo(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Zt(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===z?t.sqliteLayoutVersion:void 0})}function In(e){let t=e.fingerprint!==void 0,r=_(e.fingerprint),n=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===z?e:null;return{usableForQuery:n,usableForEvidenceCache:t,publishableGeneration:i&&r&&n,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function xn(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Wt(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!wn(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!Rn(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===z&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===z&&e.languageFingerprints!==void 0&&!vn(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===z&&e.typescriptProjectShards!==void 0&&!En(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function wo(e){return e.version===z&&e.sqliteLayoutVersion===2}function wn(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Ke.has(t))?!1:new Set(e).size===e.length}function Rn(e){return Array.isArray(e)&&e.every(t=>_(t)&&typeof t.language=="string"&&Ke.has(t.language)&&typeof t.reason=="string")}function vn(e){return _(e)&&Object.entries(e).every(([t,r])=>Ke.has(t)&&_(r))}function En(e){return _(e)&&Object.values(e).every(t=>_(t)&&Array.isArray(t.files)&&t.files.every(zt))}function Pn(e){return e instanceof Error?e.message:String(e)}import Qn from"better-sqlite3";import{createHash as kn,randomUUID as Dn}from"crypto";import{existsSync as W,mkdirSync as Ln,readdirSync as On,rmSync as or,statSync as ar}from"fs";import{basename as Mn,dirname as se,join as I}from"path";import{join as Gn}from"path";function De(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function er(e,t){if(e?.aborted)throw De(e,t)}var Tn=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function tr(e,t={}){return T(Gn(e,"gc.lock"),t)}function T(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??te,o=i()+r;do{let a=rr(e);if(a)return nr(a);let s=o-i();if(s<=0)return null;Cn(Math.min(n,s))}while(i()<=o);return null}async function Co(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??te,o=i()+r;do{er(t.signal,"Lock acquisition was aborted.");let a=rr(e);if(a)return nr(a);let s=o-i();if(s<=0)return null;await An(Math.min(n,s),t.signal)}while(i()<=o);return null}function rr(e){let t=Ce(e,{kind:"generic",parseLegacy:Tn});return t.kind==="acquired"?t.lock:null}function nr(e){return{release:()=>{e.release()}}}function Cn(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function An(e,t){return t?.aborted?Promise.reject(De(t,"Lock acquisition was aborted.")):new Promise((r,n)=>{let i=setTimeout(()=>{t?.removeEventListener("abort",o),r()},e),o=()=>{clearTimeout(i),t?.removeEventListener("abort",o),n(t?De(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}var V=1,tt=1,ce=".codebaseiq-generations",Le="manifest.json",sr="readers",_n="gc.lock",jn=128,ae=new Map,cr={pid:process.pid,now:()=>new Date,randomToken:()=>Dn(),isProcessAlive:ie,readProcessIdentity:ne,resolveImmutableGeneration:lr};function m(e){return I(se(e),ce)}function de(e){return I(m(e),_n)}function dr(e,t=cr){let r=T(de(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let o=C(e.dbPath);if(!o||!le(e.dbPath,o.currentGeneration))return{generation:nt(e),release(){}};let a=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(a))throw new Error("SQLite generation reader token is unsafe.");let s=I(m(e.dbPath),sr);Ln(s,{recursive:!0});let c=I(s,`${t.pid}-${a}.json`),d=t.readProcessIdentity(t.pid);F(c,{version:1,token:a,generationIdentity:o.currentGeneration,pid:t.pid,...d?{processIdentity:d}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let l=!1;n={identity:o.currentGeneration,required:o.artifactSet==="immutable-v1",release(){l||(l=!0,or(c,{force:!0}))}}}finally{r.release()}let i;try{i=t.resolveImmutableGeneration(e,n.identity)}catch(o){throw n.release(),o}if(i?.source==="immutable"&&i.identity===n.identity)return{generation:i,release:n.release};if(n.release(),n.required)throw new Error(`Published SQLite generation ${n.identity} is missing or invalid.`);return Fn(e,n.identity)}function Fn(e,t){let r=T(de(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");try{let n=C(e.dbPath);if(n?.currentGeneration!==t)throw new Error("SQLite index publication changed while opening a legacy generation.");if(W(I(se(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return{generation:ur(e,n.currentGeneration),release(){}}}finally{r.release()}}function rt(e,t,r=cr,n={}){let i=I(m(e),sr);if(!W(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,a=0,s=0,c=0;for(let d of On(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=I(i,d.name),p;try{p=Nn(JSON.parse(S(l,"SQLite generation reader lease")))}catch{p=null}if(!p){c+=1;for(let h of t)o.add(h);continue}if(!qn(p,r)){n.removeStale!==!1&&(or(l,{force:!0}),s+=1);continue}a+=1,o.add(p.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function Nn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:Ut(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...r?{processIdentity:r}:{},acquiredAt:t.acquiredAt}}function qn(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||Jt(e.processIdentity,r)}function C(e){try{let t=JSON.parse(S(I(m(e),"state.json"),"SQLite generation state"));return $n(t)?t:null}catch{return null}}function le(e,t){return ue(m(e),t)}function ue(e,t){try{let r=JSON.parse(S(I(e,t,Le),"SQLite generation manifest"));return Bn(r,t)?r:null}catch{return null}}function nt(e){let t=C(e.dbPath);if(t){let r=lr(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(W(I(se(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return ur(e,t?.currentGeneration)}function Bo(e){let t=C(e);if(t)return t.currentGeneration;try{let r=I(se(e),"meta.json"),n=W(r)?S(r,"reindex metadata"):void 0;return pr(e,n)}catch{return null}}function N(e){return Zt(ke(e))??e}function lr(e,t){try{let r=I(m(e.dbPath),t),n=le(e.dbPath,t);if(!n)return null;let i=Xe(r,n.database),o=n.index?Xe(r,n.index):void 0,a=n.metadata?Xe(r,n.metadata):void 0;return!Ze(i,n.database)||n.index&&(!o||!Ze(o,n.index))||n.metadata&&(!a||!Ze(a,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:S(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function ur(e,t){let r=O(e.dbPath),n=I(se(e.dbPath),"meta.json"),i=W(n)?S(n,"reindex metadata"):void 0,o=W(e.indexPath)?e.indexPath:void 0;return{identity:t??pr(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function pr(e,t){let r=kn("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(N(t)),r.update(`\0${O(e)}`),r.digest("hex")}function O(e){let t=ar(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Xe(e,t){if(Mn(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return I(e,t.file)}function Ze(e,t){if(!W(e))return!1;let r=ir(e);if(!r||r.size!==t.size)return!1;let n=`${e}\0${t.sha256}\0${r.identity}`;if(ae.has(n))return!0;let i=Y(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=ir(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(ae.set(n,!0);ae.size>jn;){let a=ae.keys().next().value;if(a===void 0)break;ae.delete(a)}return!0}function ir(e){let t=ar(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function Bn(e,t){return e.version===tt&&e.identity===t&&et(e.database)&&(e.index===void 0||et(e.index))&&(e.metadata===void 0||et(e.metadata))}function et(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function $n(e){return e.version===V&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&zn(e.stableMirrors)&&Wn(e.previousGeneration)&&Vn(e.publication)}function zn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function Wn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Vn(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}var Hn=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],it=class{constructor(t,r){this.connection=t;this.releaseGenerationReader=r}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let r of Hn)this.connection.pragma(r);t(this.connection)}catch(r){try{this.close()}catch(n){throw new AggregateError([r,n],"SQLite initialization and rollback both failed.",{cause:n})}throw r}}close(){if(!this.active)return;this.active=!1;let t,r;try{this.connection.close()}catch(n){t=n}try{this.releaseGenerationReader()}catch(n){r=n}if(t!==void 0&&r!==void 0)throw new AggregateError([t,r],"SQLite connection close and generation-reader release both failed.");if(t!==void 0)throw t;if(r!==void 0)throw r}},Un=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".codebaseiq-cache","__pycache__",".venv","venv"],fr=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;closed=!1;constructor(t,r){this.config=t,this.pathFilter=r??null;let n=Xn(t),i=new it(n.db,n.release);try{i.initialize(Kn),this.generation=n.generation,this.connection=n.db,this.connectionOwnership=i,this.db=Jn(n.db)}catch(o){try{i.close()}catch(a){throw new AggregateError([o,a],"SQLite construction and rollback both failed.",{cause:a})}throw o}}isIgnored(t){return this.pathFilter?.isIgnored(t)??!1}get localSymbolPredicate(){return`(
|
|
2
|
+
EXISTS (
|
|
3
|
+
SELECT 1
|
|
4
|
+
FROM defn_enclosing_ranges local_der
|
|
5
|
+
JOIN documents local_d ON local_der.document_id = local_d.id
|
|
6
|
+
WHERE local_der.symbol_id = gs.id
|
|
7
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
8
|
+
)
|
|
9
|
+
OR EXISTS (
|
|
10
|
+
SELECT 1
|
|
11
|
+
FROM mentions local_m
|
|
12
|
+
JOIN chunks local_c ON local_m.chunk_id = local_c.id
|
|
13
|
+
JOIN documents local_d ON local_c.document_id = local_d.id
|
|
14
|
+
WHERE local_m.symbol_id = gs.id
|
|
15
|
+
AND local_m.role = 1
|
|
16
|
+
${this.pathExclusionsFor("local_d").trimStart()}
|
|
17
|
+
)
|
|
18
|
+
)`}get pathExclusions(){return this.pathExclusionsFor("d")}get symbolNoise(){return this.symbolNoiseFor("gs")}pathExclusionsFor(...t){return t.flatMap(r=>Un.flatMap(n=>[`AND ${r}.relative_path NOT LIKE '${n}/%'`,`AND ${r}.relative_path NOT LIKE '%/${n}/%'`])).join(`
|
|
19
|
+
`)}symbolNoiseFor(t){return`AND ${t}.symbol NOT LIKE '%().(%' AND ${t}.symbol NOT LIKE '%typeLiteral%'`}all(t,...r){return this.statement(t).all(...r)}get(t,...r){return this.statement(t).get(...r)}close(){if(this.closed)return;this.closed=!0,this.statementCache.clear();let t,r;try{Kt(this)}catch(n){t=n}try{this.connectionOwnership.close()}catch(n){r=n}if(t!==void 0&&r!==void 0)throw new AggregateError([t,r],"Database-owned resource and SQLite connection cleanup both failed.");if(t!==void 0)throw t;if(r!==void 0)throw r}statement(t){let r=this.statementCache.get(t);return r||(r=this.connection.prepare(t),this.statementCache.set(t,r)),r}};function Jn(e){return Object.freeze({prepare(t){let r=e.prepare(t);if(!r.readonly||!r.reader)throw new Error("ScipDatabase.db only permits read-only statements that return rows.");return Yn(r)}})}function Yn(e){let t={get:(...r)=>e.get(...r),all:(...r)=>e.all(...r),iterate:(...r)=>e.iterate(...r),pluck(r){return r===void 0?e.pluck():e.pluck(r),t},expand(r){return r===void 0?e.expand():e.expand(r),t},raw(r){return r===void 0?e.raw():e.raw(r),t},bind(...r){return e.bind(...r),t},columns:()=>e.columns(),safeIntegers(r){return r===void 0?e.safeIntegers():e.safeIntegers(r),t}};return Object.freeze(t)}function Kn(e){if(!e.prepare("SELECT 1 AS present FROM sqlite_master WHERE type = 'table' AND name = 'documents'").get())return;let r=e.prepare("SELECT relative_path FROM documents").iterate();for(let n of r)Ge(n.relative_path)}function Xn(e){for(let t=0;t<4;t+=1){let r=dr(e),n=r.generation,i;try{i=new Qn(Ee(n.databasePath),{readonly:!0,fileMustExist:!0})}catch(o){throw r.release(),o}if(n.source==="immutable")return{db:i,generation:n,release:r.release};try{let o=nt(e);if(n.databaseFileIdentity===O(n.databasePath)&&o.source==="legacy"&&o.identity===n.identity&&o.databaseFileIdentity===n.databaseFileIdentity&&o.metadataRaw===n.metadataRaw)return{db:i,generation:n,release:r.release}}catch(o){throw i.close(),r.release(),o}i.close(),r.release()}throw new Error("SQLite index publication changed repeatedly while opening a coherent generation.")}import{createHash as ln,randomUUID as to}from"crypto";import{existsSync as B,lstatSync as Ct,mkdirSync as ee,readdirSync as un,realpathSync as pn,renameSync as U,rmSync as q,statSync as $e}from"fs";import{dirname as At,join as u,resolve as we}from"path";import{setTimeout as ro}from"timers/promises";import{pathToFileURL as an}from"url";import{deserializeSCIP as fn}from"@c4312/scip";import no from"better-sqlite3";import{execFileSync as Zn}from"child_process";import{existsSync as ei,readdirSync as mr}from"fs";import{extname as yr,join as hr}from"path";var Sr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),ti=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function ot(e){let t=[],r=ri(e),n=ai(e);for(let i of ti){if(ni(e,i.files)){t.push(i.language);continue}if(ii(r,i.globs)){t.push(i.language);continue}ci(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&gr(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&gr(t,"c"),t}function ri(e){try{return mr(e)}catch{return[]}}function ni(e,t){return t?.length?t.some(r=>ei(hr(e,r))):!1}function ii(e,t){return t?.length?e.some(r=>t.some(n=>oi(r,n))):!1}function oi(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function ai(e){let t=si(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=mr(i,{withFileTypes:!0})}catch{continue}for(let a of o){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let s=hr(i,a.name);if(a.isDirectory()){Sr.has(a.name)||n.push(s);continue}let c=yr(a.name).toLowerCase();c&&r.add(c)}}return r}function si(e){try{let t=Zn("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"}),r=new Set;for(let n of t.split(`
|
|
20
|
+
`)){if(!n||n.split("/").some(o=>Sr.has(o)))continue;let i=yr(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function ci(e,t){return t?.length?t.some(r=>e.has(r)):!1}function gr(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{lstatSync as wi,readdirSync as Ri}from"fs";import{join as vi,relative as Ei,resolve as gt,sep as Pi}from"path";import{createHash as di}from"crypto";import{existsSync as pe,mkdirSync as li,readdirSync as br,renameSync as ui,rmSync as Ir,writeFileSync as pi}from"fs";import{join as M}from"path";import{create as wr,fromBinary as Rr,toBinary as fi}from"@bufbuild/protobuf";import{deserializeSCIP as Oe,DocumentSchema as st,IndexSchema as vr,serializeSCIP as Er}from"@c4312/scip";var Me=1,fe="typescript-scip-fragments";function aa(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let a=Q(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=Rr(st,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);r.push(s)}let n=Er(wr(vr,{documents:r,externalSymbols:[]})),i=Oe(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function ge(e){let t=M(e,fe);return{rootDir:t,blobDir:M(t,"blobs"),generationDir:M(t,"generations")}}function gi(e){let t=Oe(e.indexBytes);Or(t.metadata,Mr(e)),Lr(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let a=Q(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);r.add(a);let s=fi(st,o),c=e.documentIdentities.get(a)??(e.allowUntrackedDocuments?H(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:a,contentHash:H(s)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${a}`);n.push(Cr(e.cacheDir,{relativePath:a,bytes:s,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ar(e,n);return kr(e.cacheDir,i),i}function sa(e){let t=ge(e.cacheDir);if(!pe(dt(t,e.generationIdentity)))return gi(e);let r=Pr({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function ca(e){let t=Pr({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let a=Q(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(n.add(a),!r.has(a))throw new Error(`TypeScript fragment replacement has no prior document: ${a}`);let s=e.documentIdentities.get(a);if(!s)throw new Error(`missing TypeScript document identity: ${a}`);o.bytes===null?r.delete(a):r.set(a,Cr(e.cacheDir,o,s))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ar(e,[...r.values()]);return kr(e.cacheDir,i),i}function Pr(e){let t=ge(e.cacheDir),r=dt(t,e.generationIdentity),n;try{n=ct(v(r,{maxBytes:R,inputKind:"TypeScript fragment manifest"}))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let a=M(t.blobDir,`${o.blobHash}.scipdoc`),s=w(a,{maxBytes:J,inputKind:"TypeScript fragment blob"});if(s.byteLength!==o.byteLength||H(s)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,s)}return{manifest:n,fragments:i}}function Gr(e){let t=Tr(e);return at(t.baseIndex,t.completeDocuments,"assembled")}function da(e){let t=Tr(e);return mi(t.deletedAffectedPaths),{completeIndexBytes:at(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:at(t.baseIndex,t.affectedDocuments,"affected")}}function Tr(e){let t=Oe(e.baseIndexBytes);Or(t.metadata,Mr(e)),Lr(t.externalSymbols);let r=new Map;for(let s of e.fragments){let c=Q(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,s)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=Q(s.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let d=r.get(c);if(!d){i.push(s);continue}if(r.delete(c),d.bytes===null){a.push(c);continue}let l=Rr(st,d.bytes);if(l.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${l.relativePath}`);i.push(l),o.push(l)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function at(e,t,r){let n=Er(wr(vr,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Oe(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function mi(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function la(e,t){let r=ge(e);if(!pe(r.generationDir))return;let n=new Set(t.map(a=>Dr(a))),i=br(r.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>n.has(s))){let s=ct(v(M(r.generationDir,a),{maxBytes:R,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)n.has(a)||Ir(M(r.generationDir,a),{force:!0});if(pe(r.blobDir))for(let a of br(r.blobDir))o.has(a)||Ir(M(r.blobDir,a),{force:!0})}function Cr(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=Q(t.relativePath),i=Buffer.from(t.bytes),o=H(i),a=ge(e);li(a.blobDir,{recursive:!0});let s=M(a.blobDir,`${o}.scipdoc`);if(pe(s)){let c=w(s,{maxBytes:J,inputKind:"TypeScript fragment blob"});if(c.byteLength!==i.byteLength||H(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${s}.${process.pid}.${Date.now()}.tmp`;pi(c,i),ui(c,s)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Ar(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:Me,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function kr(e,t){let r=ge(e),n=dt(r,t.generationIdentity);if(pe(n)){let i=ct(v(n,{maxBytes:R,inputKind:"TypeScript fragment manifest"}));if(xr(i)!==xr(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}F(n,t,{spacing:2,trailingNewline:!0})}function xr(e){return H(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function ct(e){let t=JSON.parse(e);if(t.version!==Me||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Q(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function dt(e,t){return M(e.generationDir,Dr(t))}function Dr(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${H(e)}.json`}function Lr(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Or(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Mr(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Q(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function H(e){return di("sha256").update(e).digest("hex")}import{createHash as yi}from"crypto";import{existsSync as me,mkdirSync as hi,readdirSync as lt,renameSync as Si,rmSync as _r,writeFileSync as bi}from"fs";import{join as P}from"path";var _e=1,Sa=64*1024*1024,he="typescript-scip-overlays";function ba(e){let t=Fr(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let a=ft(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);n.add(a),r.set(a,Ii(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:_e,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,a)=>o.relativePath.localeCompare(a.relativePath))};return xi(e.cacheDir,i),i}function Ia(e){let t=Fr(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=w(P(Se(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:J,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||ye(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Gr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function xa(e,t){let r=Se(e),n=P(r,"generations");if(!me(n))return;let i=new Set(t.map(pt)),o=new Set;for(let s of lt(n).filter(c=>i.has(c))){let c=ut(v(P(n,s),{maxBytes:R,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of lt(n))i.has(s)||_r(P(n,s),{force:!0});let a=P(r,"blobs");if(me(a))for(let s of lt(a))o.has(s)||_r(P(a,s),{force:!0})}function Fr(e,t){let r=P(Se(e),"generations",pt(t));if(!me(r))return null;let n=ut(v(r,{maxBytes:R,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function Ii(e,t){let r=ft(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=ye(n),o=P(Se(e),"blobs");hi(o,{recursive:!0});let a=P(o,`${i}.scipdoc`);if(me(a)){let s=w(a,{maxBytes:J,inputKind:"TypeScript overlay blob"});if(s.byteLength!==n.byteLength||ye(s)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let s=`${a}.${process.pid}.${Date.now()}.tmp`;bi(s,n),Si(s,a)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function xi(e,t){let r=P(Se(e),"generations",pt(t.generationIdentity));if(me(r)){let n=ut(v(r,{maxBytes:R,inputKind:"TypeScript overlay manifest"}));if(jr(n)!==jr(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}F(r,t,{spacing:2,trailingNewline:!0})}function ut(e){let t=JSON.parse(e);if(t.version!==_e||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(ft(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function Se(e){return P(e,he)}function pt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${ye(e)}.json`}function jr(e){return ye(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function ft(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function ye(e){return yi("sha256").update(e).digest("hex")}var be=1,mt="language-indexes",Nr=["index.db","index.scip","meta.json"],qr=[mt,fe,he];function je(e){let t=[];for(let r of Nr)Gi(e,r),t.push(r);for(let r of qr)Br(e,r,t);return{version:be,files:t.sort()}}function Fe(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Nr.includes(e)&&!qr.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function A(e,t){let r=Fe(t),n=gt(e),i=gt(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Pi}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Br(e,t,r){let n=vi(e,t),i;try{i=Ri(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?Br(e,a,r):o.isFile()&&r.push(Fe(a))}}function Gi(e,t){let r=A(e,t),n;try{n=wi(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Ei(gt(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{writeFileSync as yt}from"fs";import{create as X}from"@bufbuild/protobuf";import{deserializeSCIP as ht,serializeSCIP as St,DocumentSchema as ki,IndexSchema as Wr,MetadataSchema as Vr,SymbolInformationSchema as Di}from"@c4312/scip";import{create as $r}from"@bufbuild/protobuf";import{DocumentSchema as Ti,IndexSchema as Ci,SymbolRole as Ai}from"@c4312/scip";function zr(e){let t=new Set,r=new Map;for(let a of e.documents){r.set(a,Ge(a.relativePath));for(let s of a.symbols)s.symbol&&t.add(s.symbol)}for(let a of e.externalSymbols)a.symbol&&t.add(a.symbol);let n=0,i=0,o=[];for(let a of e.documents){let s=r.get(a),c=a.occurrences.filter(d=>(d.symbolRoles&Ai.Definition)===0||t.has(d.symbol)?!0:(n+=1,!1));if(s===a.relativePath&&c.length===a.occurrences.length){o.push(a);continue}i+=1,o.push($r(Ti,{language:a.language,relativePath:s,occurrences:c,symbols:a.symbols,text:a.text,positionEncoding:a.positionEncoding}))}return{index:i===0?e:$r(Ci,{metadata:e.metadata,documents:o,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:i}}function Qr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Oi(e),r=Mi(e.flatMap(i=>i.documents??[])),n=Ur(e.flatMap(i=>i.externalSymbols??[]));return X(Wr,{metadata:t,documents:r,externalSymbols:n})}function Fa(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>ht(w(i,{inputKind:"SCIP merge input",maxBytes:E}))),n=Qr(r);return yt(t,Buffer.from(St(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function Na(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>ht(w(i,{inputKind:"SCIP merge input",maxBytes:E}))),n=zr(Qr(r));return yt(t,Buffer.from(St(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Li(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(!K(n.projectRoot,t))throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return X(Wr,{metadata:X(Vr,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Hr(e,t,r){let n=ht(w(e,{inputKind:"SCIP normalization input",maxBytes:E})),i=Li(n,t,r);yt(e,Buffer.from(St(i)))}function Oi(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let i of e.slice(1)){let o=i.metadata?.projectRoot;if(r&&o&&!K(o,r))throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${o}`)}let n=r&&Vt(r);return n===r?t:X(Vr,{...t,projectRoot:n})}function Mi(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,X(ki,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:_i([...n.occurrences,...r.occurrences]),symbols:Ur([...n.symbols,...r.symbols]),text:Fi(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function _i(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function Ur(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,X(Di,{symbol:n.symbol,documentation:Ni([...n.documentation,...r.documentation]),relationships:ji([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function ji(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function Fi(e,t){return e?t?e.length>=t.length?e:t:e:t}function Ni(e){return[...new Set(e)]}import{createHash as vt}from"crypto";import{closeSync as qi,existsSync as g,mkdirSync as Bi,openSync as $i,readSync as zi,readdirSync as Et,renameSync as wt,rmSync as Ie,statSync as Z}from"fs";import{basename as Xr,dirname as k,join as f,relative as Jr}from"path";var Rt=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Zr(e){let t=m(e.outputDb),r=Ui(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Tt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:g(n)?n:void 0,metadataPath:g(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),a={version:V,currentGeneration:i.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:o},s=G(f(t,"state.json"),a,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||xt(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),xt(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),xt(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,d={...a,stableMirrors:Gt(e.outputDb,e.outputScip)};G(f(t,"state.json"),d,{spacing:2,trailingNewline:!0});let l=en(e.outputDb,{now:e.now}),p=re(i.directorySync,s.directorySync);return{currentGeneration:c,...r?{previousGeneration:r}:{},retention:l,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function Wi(e,t,r,n=()=>new Date){if(!g(e))return null;let i=C(e),o=f(m(e),"state.json");if(i?.artifactSet==="immutable-v1"&&le(e,i.currentGeneration))return i;let a=m(e),s=!i&&g(o)?Yi(r,e,t):void 0;if(s&&!ue(a,s))return null;let c=Tt({generationRoot:a,databasePath:e,indexPath:g(t)?t:void 0,metadataPath:g(r)?r:void 0,forcedIdentity:i?.currentGeneration??s}),d={version:V,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:Gt(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return G(f(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function Xa(e,t,r=()=>new Date){if(!g(e)||!g(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=C(e),i=m(e),o=Tt({generationRoot:i,databasePath:e,indexPath:g(f(k(e),"index.scip"))?f(k(e),"index.scip"):void 0,metadataPath:t}),a=n&&n.currentGeneration!==o.identity?nn(e,n.currentGeneration):void 0,s={version:V,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Gt(e,f(k(e),"index.scip")),...a?{previousGeneration:a}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return G(f(m(e),"state.json"),s,{spacing:2,trailingNewline:!0}),en(e,{now:r}),s}function en(e,t={}){let r=Vi(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=T(de(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:"another process owns local generation retention"};try{let a=C(e),s=tn(e),c=rt(e,s.map(x=>x.identity),{isProcessAlive:t.isProcessAlive??ie,readProcessIdentity:t.readProcessIdentity??ne}),d=new Set(c.protectedGenerations);a?.currentGeneration&&d.add(a.currentGeneration),a?.previousGeneration?.generationIdentity&&d.add(a.previousGeneration.generationIdentity);let l=s.length,p=s.reduce((x,ze)=>x+ze.logicalBytes,0),h=0,D=0;for(let x of s){if(l<=r.maxGenerations&&p<=r.maxLogicalBytes)break;d.has(x.identity)||(t.onBeforeRemove?.(x.identity),Ie(x.path,{recursive:!0,force:!0}),l-=1,p-=x.logicalBytes,h+=1,D+=x.logicalBytes)}let y=l>r.maxGenerations||p>r.maxLogicalBytes,L={state:y?"protected":h>0?"collected":"within-bounds",generationCount:l,logicalBytes:p,protectedGenerations:d.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:h,removedLogicalBytes:D,limits:r,at:i,...y?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return Yr(e,L),L}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:a instanceof Error?a.message:String(a)};try{Yr(e,s)}catch{}return s}finally{o.release()}}function Za(e){let t=m(e);if(!g(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...Rt},reason:"local immutable generation store does not exist"};let r=Qi(e),n=r?.limits??{...Rt},i=T(de(e),{waitMs:0});if(!i)return{state:"deferred",generationCount:r?.generationCount??0,logicalBytes:r?.logicalBytes??0,protectedGenerations:r?.protectedGenerations??0,activeReaderLeases:r?.activeReaderLeases??0,malformedReaderLeases:r?.malformedReaderLeases??0,limits:n,...r?{lastCollection:r}:{},reason:"another process owns local generation retention"};try{let o=tn(e),a=C(e),s=rt(e,o.map(d=>d.identity),{isProcessAlive:ie,readProcessIdentity:ne},{removeStale:!1}),c=new Set(s.protectedGenerations);return a?.currentGeneration&&c.add(a.currentGeneration),a?.previousGeneration?.generationIdentity&&c.add(a.previousGeneration.generationIdentity),{state:"managed",generationCount:o.length,logicalBytes:o.reduce((d,l)=>d+l.logicalBytes,0),...o[0]?{oldestGenerationAt:new Date(o[0].modifiedAtMs).toISOString()}:{},protectedGenerations:c.size,activeReaderLeases:s.activeLeases,malformedReaderLeases:s.malformedLeases,limits:n,...r?{lastCollection:r}:{},...s.malformedLeases>0?{reason:"malformed reader ownership evidence prevents unsafe collection"}:{}}}catch(o){return{state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:n,...r?{lastCollection:r}:{},reason:o instanceof Error?o.message:String(o)}}finally{i.release()}}function Vi(e={}){let t={...Rt,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function tn(e){let t=m(e);return g(t)?Et(t,{withFileTypes:!0}).filter(r=>r.isDirectory()&&/^[a-f0-9]{64}$/.test(r.name)).map(r=>{let n=f(t,r.name),i=ue(t,r.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):rn(n);return{identity:r.name,path:n,logicalBytes:o,modifiedAtMs:Z(n).mtimeMs}}).sort((r,n)=>r.modifiedAtMs-n.modifiedAtMs||r.identity.localeCompare(n.identity)):[]}function rn(e){let t=0;for(let r of Et(e,{withFileTypes:!0})){let n=f(e,r.name);r.isDirectory()?t+=rn(n):r.isFile()&&(t+=Z(n).size)}return t}function Yr(e,t){F(f(m(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function Qi(e){try{let t=JSON.parse(S(f(m(e),"gc.json"),"local SQLite generation GC status"));return!t||t.state!=="within-bounds"&&t.state!=="collected"&&t.state!=="protected"&&t.state!=="deferred"&&t.state!=="error"||!Number.isSafeInteger(t.generationCount)||t.generationCount<0||!Number.isFinite(t.logicalBytes)||t.logicalBytes<0||!Number.isFinite(Date.parse(t.at))?void 0:t}catch{return}}function Pt(e,t=f(k(e),"meta.json")){let r=f(m(e),"state.json");if(!g(r))return{state:"legacy",statePath:r};let n=C(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=le(e,n.currentGeneration),o=i!==null,a=i?Hi(e,t,i,n):!1,s=n.previousGeneration?g(f(k(e),n.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:r,currentMatches:a,recoveryExists:s,generation:n,reason:o?a?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:a,recoveryExists:s,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function Hi(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==O(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==O(f(k(e),"index.scip")))||!Kr(e,r.database))return!1;let i=f(k(e),"index.scip");if(r.index&&!Kr(i,r.index))return!1;if(!r.metadata)return!g(t);if(!g(t))return!1;let o=f(m(e),r.identity,r.metadata.file);return g(o)&&N(S(t,"reindex metadata"))===N(S(o,"immutable reindex metadata"))}function Kr(e,t){return g(e)&&Z(e).isFile()&&Z(e).size===t.size}function Ui(e){let t=Wi(e.outputDb,e.outputScip,e.metaPath);return t?nn(e.outputDb,t.currentGeneration):void 0}function Gt(e,t){return{databaseFileIdentity:O(e),...g(t)?{indexFileIdentity:O(t)}:{}}}function nn(e,t){let r=f(m(e),t),n=f(r,Xr(e)),i=f(r,"meta.json");return{generationIdentity:t,databasePath:Jr(k(e),n),...g(i)?{metadataPath:Jr(k(e),i)}:{}}}function Ji(e){if(g(e)){for(let t of Et(e,{withFileTypes:!0}))if(t.isDirectory()&&t.name.endsWith(".tmp"))try{Ie(f(e,t.name),{recursive:!0,force:!0})}catch{}}}function Yi(e,t,r=f(k(t),"index.scip")){let n=vt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Ne(t)),g(r)&&n.update(`\0${Ne(r)}`),g(e)&&n.update(`\0${N(S(e,"reindex metadata"))}`),n.digest("hex")}function Tt(e){let t=bt(e.databasePath),r=e.indexPath?bt(e.indexPath):void 0,n=e.metadataPath?bt(e.metadataPath):void 0,i=e.forcedIdentity??Ki(t,r,e.metadataPath),o=f(e.generationRoot,i),a=f(o,Le);if(g(a)){let d=ue(e.generationRoot,i);if(d&&on(o,d.database,t)&&Zi(o,d.index,r)&&eo(o,d.metadata,e.metadataPath))return{identity:i,directorySync:j(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let s=[Pe(e.generationRoot)];Ji(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Ie(c,{recursive:!0,force:!0}),Bi(c,{recursive:!0});try{s.push(It(e.databasePath,f(c,t.file))),r&&e.indexPath&&s.push(It(e.indexPath,f(c,r.file))),n&&e.metadataPath&&s.push(It(e.metadataPath,f(c,n.file)));let d=G(f(c,Le),{version:tt,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(j(c)),b(()=>wt(c,o)),s.push(j(e.generationRoot))}finally{try{Ie(c,{recursive:!0,force:!0})}catch{}}return{identity:i,directorySync:re(...s)}}function Ki(e,t,r){let n=vt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${N(S(r,"reindex metadata"))}`),n.digest("hex")}function bt(e){return{file:Xr(e),size:Z(e).size,sha256:Ne(e)}}function Ne(e){let t=vt("sha256"),r=$i(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Xi(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{qi(r)}return t.digest("hex")}function Xi(e,t){let r=0;for(;r<t.length;){let n=zi(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function It(e,t){return Ae(e,t,{mode:292})}function on(e,t,r){let n=f(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&g(n)&&Z(n).size===t.size&&Ne(n)===t.sha256}function Zi(e,t,r){return!t||!r?t===r:on(e,t,r)}function eo(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=f(e,t.file);return g(n)&&N(S(n,"stored reindex metadata"))===N(S(r,"candidate reindex metadata"))}function xt(e,t){b(()=>Ie(`${t}.tmp-replace`,{force:!0})),b(()=>wt(e,`${t}.tmp-replace`)),b(()=>wt(`${t}.tmp-replace`,t))}var Ot=1,sn="CODEBASEIQ_SHARED_CACHE",io=2,qe=JSON.stringify({cliVersion:Qt,artifactCatalogVersion:be,postIndexAugmentationSchemaVersion:io,sqliteGenerationStoreVersion:V,typescriptFragmentStoreVersion:Me,typescriptOverlayStoreVersion:_e}),Mt="manifest.json",oo="shared-cache.json",_t=[mt,fe,he];function kt(e,t){if(!e.clean||!e.treeOid)return;let r=bn(JSON.stringify({version:Ot,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:qe}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:qe,generationId:r,repositoryCacheDir:Te(e.repositoryId)}}function gn(e,t,r){if(process.env[sn]==="0")return`${sn}=0`;if(!Qe(r))return"explicit cache or database override";if(He(At(t))!==He(Ve(e))||t!==u(At(t),"index.db"))return"index database is outside the managed worktree cache"}function Ts(e,t,r){if(!Qe(t))return;let n=r??oe(e);return n?u(Te(n.repositoryId),"evidence.db"):void 0}function $(e,t=!0){let r=Nt(e),n;try{n=yn(v(u(r,Mt),{inputKind:"shared-generation manifest",maxBytes:R}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=A(r,i.path),a=$e(o);if(!a.isFile()||a.size!==i.size||Y(o,{inputKind:"shared-generation artifact",maxBytes:E})!==i.sha256)return null}}catch{return null}return n}function Cs(e,t,r){if(!e.treeOid)return null;let n=Je(t,r),i=u(Ht(),"repositories",e.repositoryId),o;try{let c=Ct(i);if(!c.isDirectory()||c.isSymbolicLink())return null;o=pn(i)}catch{return null}let a=u(o,"generations"),s=[];try{for(let c of un(a)){if(!/^[a-f0-9]{64}$/.test(c))continue;let d=u(a,c),l;try{l=Ct(d)}catch{continue}if(!(!l.isDirectory()||l.isSymbolicLink()))try{let p=yn(v(u(d,Mt),{inputKind:"shared-generation baseline manifest",maxBytes:R}));p.generationId===c&&p.repositoryId===e.repositoryId&&p.treeOid===e.treeOid&&p.producerIdentity===qe&&lo(p.fingerprint,n)&&s.push(p)}catch{continue}}}catch{return null}s.sort((c,d)=>Date.parse(d.createdAt)-Date.parse(c.createdAt)||c.generationId.localeCompare(d.generationId));for(let c of s){let d={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:c.fingerprint,producerIdentity:c.producerIdentity,generationId:c.generationId,repositoryCacheDir:o},l=$(d);if(l)return{snapshot:d,manifest:l}}return null}function mn(e){let t=T(u(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return ao(e)}finally{t.release()}}function ao(e){let t=$(e.snapshot);if(t)return cn(e.snapshot,t);if(!Re(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=dn(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=je(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Pe(i)],a=We(u(i,`.tmp-${process.pid}-`));try{let s=[];for(let y of n.files){let L=A(e.sourceCacheDir,y),x=A(a,y);o.push(ve(L,x,292)),e.onPublicationStage?.("after-artifact-flushed",y);let ze=$e(x).size;s.push({path:y,size:ze,sha256:Y(x,{inputKind:"staged shared-generation artifact",maxBytes:E})})}let c=fn(w(u(a,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:E})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let d=Bt(e.sourceProjectRoot);if(!K(c,d))throw new Error("shared SCIP generation root does not match its source worktree");if(dn(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Ot,artifactCatalogVersion:be,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((y,L)=>y.path.localeCompare(L.path))},p=G(u(a,Mt),l,{spacing:2,trailingNewline:!0});p.directorySync!=="not-requested"&&o.push(p.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(j(a)),e.onPublicationStage?.("after-staging-directory-synced");let h=Nt(e.snapshot);try{if(B(h)&&!$(e.snapshot)){let y=`${h}.corrupt-${process.pid}-${Date.now()}`;b(()=>U(h,y)),q(y,{recursive:!0,force:!0})}b(()=>U(a,h))}catch(y){let L=$(e.snapshot);if(L)return cn(e.snapshot,L);throw y}e.onPublicationStage?.("after-generation-renamed"),o.push(j(i)),e.onPublicationStage?.("after-generations-directory-synced");let D=re(...o);return{kind:"published",manifest:l,achievedDurability:D==="synced"?"directory-durable":"file-flushed",directorySync:D}}finally{q(a,{recursive:!0,force:!0})}}function cn(e,t){let r=j(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function Dt(e){let t=Nt(e.snapshot);ee(e.targetCacheDir,{recursive:!0});let r=T(u(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=We(u(e.targetCacheDir,".shared-hydrate-")),go(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let d=A(t,c.path),l=A(n,c.path);if(ve(d,l),$e(l).size!==c.size||Y(l,{inputKind:"hydrated shared-generation artifact",maxBytes:E})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=Bt(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Hr(A(n,c.path),e.manifest.scipProjectRoot,a);if(!Re(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=uo(e.targetCacheDir,n),o=!0,po(n,e.targetCacheDir,i),Zr({tempOutputScip:u(n,"index.scip"),tempOutputDb:u(n,"index.db"),tempMetaPath:u(n,"meta.json"),outputScip:u(e.targetCacheDir,"index.scip"),outputDb:u(e.targetCacheDir,"index.db"),metaPath:u(e.targetCacheDir,"meta.json"),now:e.now});let s=Pt(u(e.targetCacheDir,"index.db"),u(e.targetCacheDir,"meta.json"));if(s.state==="invalid"||s.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${s.reason}`);e.persistLease!==!1&&Lt(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&fo(e.targetCacheDir,i),a}finally{n&&q(n,{recursive:!0,force:!0}),r.release()}}function As(e,t,r,n){let i=gn(e,r.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=n??oe(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return Be(o,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let a=t.languages??ot(e),s=Ue(e,a,hn(t)),c=kt(o,s);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let d=$(c);if(d)return Dt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let l=so(c,e);return l?(d=l.manifest,Dt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:l.sourceProjectRoot}):(Be(o,r.cacheDir,"missed",void 0,"no exact shared or peer generation exists"),{kind:"missed",reason:"no exact shared or peer generation exists"})}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}function ks(e,t,r,n){let i=gn(e,r.dbPath,t);if(i)return{kind:"bypassed",reason:i};try{let o=n??oe(e);if(!o)return{kind:"missed",reason:"Git worktree identity is unavailable"};if(!o.clean)return Be(o,r.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let a=t.languages??ot(e),s=Ue(e,a,hn(t)),c=kt(o,s);if(!c)return Be(o,r.cacheDir,"missed",void 0,"worktree is not a clean committed snapshot"),{kind:"missed",reason:"worktree is not a clean committed snapshot"};let d=$(c);if(d)return Re(r.cacheDir,e,s)?(Lt(c,r.cacheDir,"local-fresh"),{kind:"local-fresh"}):(Dt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let l=Ft(r.cacheDir);return!l||JSON.stringify(l.fingerprint)!==JSON.stringify(s)||JSON.stringify([...l.indexedLanguages??[]].sort())!==JSON.stringify([...a].sort())?{kind:"missed",reason:"local metadata does not match the clean worktree snapshot"}:Re(r.cacheDir,e,s)?(mn({snapshot:c,sourceCacheDir:r.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let p=oe(e);return(p?kt(p,s):void 0)?.generationId===c.generationId}}),Lt(c,r.cacheDir,"built"),{kind:"built",generationId:c.generationId}):{kind:"missed",reason:"local index artifacts are incomplete or incompatible"}}catch(o){return{kind:"failed",reason:o instanceof Error?o.message:String(o)}}}async function Ds(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??te,o=i()+r,a=u(e.repositoryCacheDir,"locks"),s=u(a,`${e.generationId}.lock`),c=d=>{if(!d||typeof d!="object"||Array.isArray(d))return null;let l=d.pid;return typeof l=="number"&&Number.isSafeInteger(l)&&l>0?{pid:l}:null};for(;i()<=o;){if($(e))return{kind:"generation-ready"};let d=Ce(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(d.kind==="acquired")return{kind:"owner",release:()=>d.lock.release()};let l=o-i();if(l<=0)break;await ro(Math.min(n,l))}return $(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Lt(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:jt(i)};return qt(e.repositoryCacheDir,o,!0),o}function Ls(e,t,r=void 0){let n={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(r??(()=>new Date))().toISOString()},i={...n,ownershipChecksum:jt(n)};return qt(e.repositoryCacheDir,i,!0),i}function Be(e,t,r,n=void 0,i=void 0){let o={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,lastAction:r,...i?{lastReason:i}:{},lastSeenAt:(n??(()=>new Date))().toISOString()},a={...o,ownershipChecksum:jt(o)};return qt(Te(e.repositoryId),a,!1),a}function jt(e){return bn(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:we(e.projectRoot),localCacheDir:we(e.localCacheDir)}))}function yn(e){let t=JSON.parse(e);if(t.version!==Ot||t.artifactCatalogVersion!==be||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==qe||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(Fe(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function ve(e,t,r=384){return Ae(e,t,{mode:r})}function so(e,t){for(let r of Yt(t)){if(we(r.path)===we(t))continue;let n=Ve(r.path),i=Ft(n);if(!(!i||JSON.stringify(i.fingerprint)!==JSON.stringify(e.fingerprint)||JSON.stringify([...i.indexedLanguages??[]].sort())!==JSON.stringify([...e.fingerprint.languages].sort()))&&Re(n,r.path,e.fingerprint))try{return{manifest:mn({snapshot:e,sourceCacheDir:n,sourceProjectRoot:r.path}).manifest,sourceProjectRoot:r.path}}catch{continue}}return null}function co(e,t,r){ee(e,{recursive:!0}),G(u(e,oo),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function dn(e){try{let t=je(e),r=ln("sha256");for(let n of t.files){let i=A(e,n),o=$e(i).size;r.update(n).update("\0").update(String(o)).update("\0"),$t(i,{inputKind:"source-generation artifact",maxBytes:E},a=>r.update(a)),r.update("\0")}return r.digest("hex")}catch{return null}}function Ft(e){try{let t=ke(v(u(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:R}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function hn(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function lo(e,t){let r=Je(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function Nt(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function qt(e,t,r){let n=tr(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!B(u(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=u(e,"worktrees");ee(i,{recursive:!0}),G(u(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),co(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function uo(e,t){let r=u(t,".rollback"),n=new Map,i=new Map;ee(r,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=u(e,s),d=B(c);n.set(s,d),d&&ve(c,u(r,"stable",s))}for(let s of _t){let c=u(e,s),d=B(c);if(d){let l=Ct(c);if(!l.isDirectory()||l.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=u(e,ce),a=B(o);return a&&Sn(o,u(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:a}}function po(e,t,r){for(let n of _t){let i=u(t,n);if(r.managedDirectories.get(n)){let a=u(r.root,"managed",n);ee(At(a),{recursive:!0}),b(()=>U(i,a))}let o=u(e,n);B(o)&&b(()=>U(o,i))}}function fo(e,t){for(let i of _t){let o=u(e,i),a=u(t.root,"managed",i);t.managedDirectories.get(i)?B(a)&&(q(o,{recursive:!0,force:!0}),b(()=>U(a,o))):q(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=u(e,i);if(!o){q(a,{force:!0});continue}let s=`${a}.shared-restore-${to()}`;ve(u(t.root,"stable",i),s),b(()=>q(a,{force:!0})),b(()=>U(s,a))}let r=u(e,ce);q(r,{recursive:!0,force:!0});let n=u(t.root,"sqlite-generations");t.generationStoreExisted&&B(n)&&b(()=>U(n,r))}function Sn(e,t){ee(t,{recursive:!0});for(let r of un(e,{withFileTypes:!0})){let n=u(e,r.name),i=u(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?Sn(n,i):r.isFile()&&ve(n,i)}}function go(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Re(e,t,r,n=!0,i=!0){try{let o=Ft(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return xe("source validation rejected metadata"),!1;let a=je(e),s=Pt(u(e,"index.db"),u(e,"meta.json"));if(n?s.state!=="current":s.state==="invalid"||s.state==="drifted")return xe(`source validation rejected SQLite generation state ${s.state}`),!1;let c=new no(Ee(u(e,"index.db")),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let d=Bt(t),p=(i?a.files.filter(h=>h.endsWith(".scip")):["index.scip"]).every(h=>{let D=fn(w(A(e,h),{inputKind:"shared SCIP validation artifact",maxBytes:E})).metadata?.projectRoot,y=D!==void 0&&K(D,d);return y||xe(`source validation rejected SCIP root for ${h}: ${String(D)}`),y});return p||xe("source validation rejected SCIP project roots"),p}catch(o){return xe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function xe(e){process.env.CODEBASEIQ_DEBUG&&console.error(`shared-cache: ${e}`)}function Bt(e){try{return an(pn(e)).href}catch{return an(we(e)).href}}function bn(e){return ln("sha256").update(e).digest("hex")}function Ms(e){return typeof e=="object"&&e!==null}function _s(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}export{Xt as a,mo as b,z as c,ke as d,xo as e,Zt as f,In as g,wo as h,De as i,er as j,tr as k,T as l,Co as m,Bo as n,fr as o,Ms as p,_s as q,ot as r,zr as s,Fa as t,Na as u,aa as v,sa as w,ca as x,da as y,la as z,Sa as A,ba as B,Ia as C,xa as D,Zr as E,Wi as F,Xa as G,Za as H,Pt as I,kt as J,gn as K,Ts as L,$ as M,Cs as N,mn as O,Dt as P,As as Q,ks as R,Ds as S,Lt as T,Ls as U,jt as V};
|
|
21
|
+
//# sourceMappingURL=chunk-T75DS2E6.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-LMTSB3TB.js";var _=`SELECT COUNT(*) AS shared
|
|
2
2
|
FROM (
|
|
3
3
|
SELECT definition_m.symbol_id
|
|
4
4
|
FROM documents definition_d
|
|
@@ -46,4 +46,4 @@ import{a as s}from"./chunk-HIEXRDJF.js";var _=`SELECT COUNT(*) AS shared
|
|
|
46
46
|
GROUP BY file1, file2
|
|
47
47
|
ORDER BY shared DESC, file1, file2
|
|
48
48
|
LIMIT ?`,...o,n).filter(d=>!e.isIgnored(d.file1)&&!e.isIgnored(d.file2)).map(d=>c(d.file1,d.file2,d.shared))}function h(e,i={}){return f(e,i)}function c(e,i,n){return{file1:e,file2:i,sharedSymbols:n,actionTier:"signal",couplingKind:"shared-symbol-coupling",evidenceReasons:[`${n} symbol(s) are defined in one file and referenced by the other`],recommendation:"Review whether the shared symbol surface is an intentional boundary or hidden coordination pressure before moving code."}}export{l as a,N as b,f as c,h as d};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
49
|
+
//# sourceMappingURL=chunk-TEANKHUU.js.map
|