codebaseiq 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-DQMDCD24.js → chunk-27PHVDKL.js} +2 -2
- package/dist/{chunk-ZMI2JSX2.js → chunk-2DMVFAY7.js} +2 -2
- package/dist/{chunk-5PUWMSDU.js → chunk-2E6BTWER.js} +2 -2
- package/dist/{chunk-YESXMKX3.js → chunk-2F5ERMNI.js} +2 -2
- package/dist/chunk-2VKB5CMA.js +60 -0
- package/dist/{chunk-NNJ2KZZG.js → chunk-327YK6TB.js} +4 -4
- package/dist/chunk-347TXATM.js +2 -0
- package/dist/{chunk-VEXUL62T.js → chunk-35YYZD3D.js} +2 -2
- package/dist/chunk-36WRYYTE.js +3 -0
- package/dist/chunk-37TKC6MB.js +2 -0
- package/dist/{chunk-FAJQ7LWY.js → chunk-3AC56WAR.js} +2 -2
- package/dist/{chunk-JE3WZ6II.js → chunk-3NUZVLR7.js} +2 -2
- package/dist/{chunk-UZGZB3VB.js → chunk-3XFJUWJE.js} +2 -2
- package/dist/{chunk-OVTS4DKB.js → chunk-4AOOSCZ7.js} +2 -2
- package/dist/{chunk-LU3BMVH2.js → chunk-4IFISPQW.js} +2 -2
- package/dist/chunk-4NHWNAWQ.js +11 -0
- package/dist/chunk-4O52YNKL.js +5 -0
- package/dist/{chunk-HPJRBHVT.js → chunk-54K6556S.js} +2 -2
- package/dist/{chunk-HRWGYWRJ.js → chunk-57GCCPLS.js} +2 -2
- package/dist/{chunk-J77SU6VA.js → chunk-57KEZDPT.js} +2 -2
- package/dist/{chunk-OFBE4NGP.js → chunk-57KFVPVZ.js} +2 -2
- package/dist/{chunk-WOQBZPIF.js → chunk-5BDK6QC3.js} +2 -2
- package/dist/{chunk-7MGU3HPH.js → chunk-5IO2APSS.js} +2 -2
- package/dist/chunk-5NJPH3QZ.js +61 -0
- package/dist/{chunk-GW6Z3WGY.js → chunk-5WXOEJ4G.js} +2 -2
- package/dist/chunk-5XEVXVTK.js +3 -0
- package/dist/{chunk-RR7SX44N.js → chunk-6OVNYYY4.js} +2 -2
- package/dist/{chunk-ZV3JV5G5.js → chunk-6SDEQTVY.js} +2 -2
- package/dist/{chunk-EF2R3WNQ.js → chunk-6URCE5QY.js} +2 -2
- package/dist/{chunk-UCD3H3UZ.js → chunk-6ZV5EDUT.js} +2 -2
- package/dist/{chunk-C6SBF2WH.js → chunk-77GHPR2R.js} +2 -2
- package/dist/{chunk-YVCIMIOC.js → chunk-7R64XY4Y.js} +2 -2
- package/dist/{chunk-VXYS3FZD.js → chunk-7Z7HCZ7J.js} +2 -2
- package/dist/{chunk-CO5R3UNA.js → chunk-A67HT5FR.js} +2 -2
- package/dist/{chunk-UDS562V4.js → chunk-A7XQT7MH.js} +2 -2
- package/dist/{chunk-RDBI2RXU.js → chunk-ACZDU5GK.js} +2 -2
- package/dist/{chunk-FETNQCFO.js → chunk-AM5SUGHF.js} +2 -2
- package/dist/{chunk-NNOKTMZT.js → chunk-B2E3HZ2A.js} +2 -2
- package/dist/{chunk-CVYSU6BX.js → chunk-BH5CE4LN.js} +2 -2
- package/dist/chunk-BLKYYQ7C.js +543 -0
- package/dist/{chunk-4WKDMDEW.js → chunk-BX2U3QQV.js} +2 -2
- package/dist/{chunk-ZKX2FRS6.js → chunk-CANBLFVQ.js} +2 -2
- package/dist/{chunk-SMRBZ6EC.js → chunk-CCRZLRWJ.js} +2 -2
- package/dist/chunk-CDWSLAPN.js +21 -0
- package/dist/chunk-CIVYHK7U.js +22 -0
- package/dist/{chunk-L57ZKWVG.js → chunk-CMXW7MFV.js} +2 -2
- package/dist/{chunk-T3DGWPXM.js → chunk-CSZOQ7YO.js} +2 -2
- package/dist/{chunk-ZZXSWSN6.js → chunk-CWMHWD56.js} +2 -2
- package/dist/{chunk-6NW7MU72.js → chunk-CZEIHYMP.js} +2 -2
- package/dist/{chunk-DO6WQD2T.js → chunk-D62CTZX6.js} +2 -2
- package/dist/{chunk-XWUOUWYI.js → chunk-DFPAZXLU.js} +2 -2
- package/dist/{chunk-MOVBWNIP.js → chunk-DKJXK3HA.js} +2 -2
- package/dist/{chunk-XMQ23E27.js → chunk-DLC6JDN7.js} +2 -2
- package/dist/chunk-DUKHVPU5.js +4 -0
- package/dist/{chunk-ID63777H.js → chunk-DVYG3JTA.js} +2 -2
- package/dist/{chunk-NE6IU5ZD.js → chunk-EFFMFK7C.js} +2 -2
- package/dist/{chunk-I2T2LLK2.js → chunk-EM5UHLAM.js} +2 -2
- package/dist/chunk-EN4AHLL3.js +3 -0
- package/dist/chunk-EXMVF3JR.js +3 -0
- package/dist/{chunk-SWHMHUKF.js → chunk-FEBLLMTL.js} +2 -2
- package/dist/chunk-FIXYHQ3W.js +3 -0
- package/dist/{chunk-RKEJ6VTF.js → chunk-FLLXYUOL.js} +2 -2
- package/dist/{chunk-KWVHSKHK.js → chunk-FPDL2TUB.js} +2 -2
- package/dist/chunk-FQA3KIFX.js +17 -0
- package/dist/chunk-FWY2PRIF.js +3 -0
- package/dist/chunk-FY5V4V4F.js +2 -0
- package/dist/chunk-G2XUZCF2.js +88 -0
- package/dist/{chunk-QHRNXP3C.js → chunk-GXVDTHFC.js} +2 -2
- package/dist/{chunk-6MUIJMVL.js → chunk-H3CKAL6P.js} +2 -2
- package/dist/chunk-H5QXP63L.js +2 -0
- package/dist/{chunk-VUIYB2V3.js → chunk-HBQGKMM3.js} +2 -2
- package/dist/{chunk-PYAB5SM6.js → chunk-HBXZAGY6.js} +2 -2
- package/dist/{chunk-NNO6A2PO.js → chunk-HCMQZPEO.js} +2 -2
- package/dist/{chunk-Q65CQ4XL.js → chunk-HHBBGWES.js} +2 -2
- package/dist/{chunk-GTXSJDCO.js → chunk-HIEXRDJF.js} +2 -2
- package/dist/{chunk-4FC325IF.js → chunk-HYKSLTAR.js} +2 -2
- package/dist/{chunk-XLQ3GLWZ.js → chunk-I2KP4AGR.js} +2 -2
- package/dist/chunk-I5FCDTK2.js +2 -0
- package/dist/{chunk-QKPLA6IC.js → chunk-I645ZF75.js} +2 -2
- package/dist/{chunk-FDGD5AB5.js → chunk-IBM3F2BJ.js} +2 -2
- package/dist/{chunk-Q72QSKXC.js → chunk-IEL6Q5W3.js} +38 -38
- package/dist/{chunk-NCZUNH3E.js → chunk-IGQQUENU.js} +12 -12
- package/dist/chunk-IGYAZPRX.js +4 -0
- package/dist/chunk-IOVPAZWP.js +3 -0
- package/dist/{chunk-OL6KJP3N.js → chunk-IVJJNVSX.js} +2 -2
- package/dist/{chunk-AKB7V7TV.js → chunk-IWAMYGPN.js} +2 -2
- package/dist/chunk-IYBIBMPF.js +90 -0
- package/dist/{chunk-IOP6FWIM.js → chunk-J24VICI5.js} +2 -2
- package/dist/{chunk-C7QOQX32.js → chunk-JN5LIBT3.js} +2 -2
- package/dist/{chunk-O6QTXQPJ.js → chunk-JOALNFY3.js} +2 -2
- package/dist/{chunk-GCHRX4YW.js → chunk-JUO3Z644.js} +2 -2
- package/dist/{chunk-BJ6SQAEN.js → chunk-JXHLB7TP.js} +2 -2
- package/dist/{chunk-IJ4HMYBE.js → chunk-JYX5UZSZ.js} +2 -2
- package/dist/chunk-K2O7SBAU.js +2 -0
- package/dist/{chunk-OLF4MA5W.js → chunk-K5G7SPAG.js} +2 -2
- package/dist/{chunk-YSNONTJ2.js → chunk-KDYQQJ6X.js} +2 -2
- package/dist/{chunk-7NVGT435.js → chunk-KM4QRWI5.js} +2 -2
- package/dist/{chunk-HKQUXIFO.js → chunk-KNV5VFDV.js} +2 -2
- package/dist/chunk-L3YSDLNB.js +2 -0
- package/dist/{chunk-EZNMUY67.js → chunk-LAGDJXFY.js} +2 -2
- package/dist/{chunk-ENCCHKM6.js → chunk-LY2NB5XR.js} +4 -4
- package/dist/chunk-M4EVGA5S.js +14 -0
- package/dist/chunk-M7LAIM77.js +127 -0
- package/dist/{chunk-BVAJLC5A.js → chunk-MRGTCMDK.js} +2 -2
- package/dist/{chunk-OZYRSMSH.js → chunk-MT5W4DUG.js} +2 -2
- package/dist/{chunk-VE5AVNMP.js → chunk-MTMF4N7F.js} +2 -2
- package/dist/chunk-N3Q3AWGW.js +545 -0
- package/dist/{chunk-TXXOEMZJ.js → chunk-NDGTJHQN.js} +2 -2
- package/dist/chunk-NIO346UL.js +2 -0
- package/dist/chunk-NJA4MMBD.js +2 -0
- package/dist/{chunk-7FND7D7N.js → chunk-NK76RSB6.js} +2 -2
- package/dist/{chunk-H3LGFZVK.js → chunk-NTRW52UR.js} +2 -2
- package/dist/{chunk-JOIRNPPY.js → chunk-OJFLPVBP.js} +2 -2
- package/dist/{chunk-KMITESMT.js → chunk-OMBRP7BB.js} +2 -2
- package/dist/{chunk-UP3BUZR5.js → chunk-OVKZM2XI.js} +2 -2
- package/dist/{chunk-MVB3DAEY.js → chunk-PARCKE3Q.js} +2 -2
- package/dist/{chunk-CAUCPUOF.js → chunk-PFPHS4NO.js} +2 -2
- package/dist/chunk-PHPQ24UG.js +22 -0
- package/dist/chunk-PLZXWZHY.js +77 -0
- package/dist/{chunk-34WBMAYK.js → chunk-PNVZIJ57.js} +2 -2
- package/dist/{chunk-SYDJMPES.js → chunk-QKVTWODE.js} +2 -2
- package/dist/{chunk-FW53T7EB.js → chunk-QLTFXVUI.js} +2 -2
- package/dist/{chunk-PBI2LFKH.js → chunk-QMGWSEPL.js} +2 -2
- package/dist/{chunk-CQP3THUZ.js → chunk-QVHZB75Z.js} +2 -2
- package/dist/{chunk-6BQ3DSPK.js → chunk-QVWDQTMG.js} +2 -2
- package/dist/{chunk-ST7V3SKN.js → chunk-RCPZOPV6.js} +2 -2
- package/dist/chunk-RJWAB4VR.js +345 -0
- package/dist/chunk-RRPK327J.js +20 -0
- package/dist/chunk-RVYLJDXC.js +21 -0
- package/dist/chunk-RWKEXCHU.js +3 -0
- package/dist/{chunk-L4NRUAGJ.js → chunk-S5SKXCND.js} +2 -2
- package/dist/{chunk-RBAS5ZHI.js → chunk-S64NCE2Z.js} +2 -2
- package/dist/{chunk-WMPRTGH2.js → chunk-SF34QLK2.js} +2 -2
- package/dist/{chunk-ANFVSJWQ.js → chunk-SJZQ2PTZ.js} +2 -2
- package/dist/{chunk-4XTAUQFD.js → chunk-SRY26ITJ.js} +2 -2
- package/dist/chunk-SV2LEFVM.js +2 -0
- package/dist/{chunk-7XAN6GKB.js → chunk-T3YFIJ5P.js} +2 -2
- package/dist/chunk-T55YPJGB.js +3 -0
- package/dist/chunk-TAJ6UGCO.js +21 -0
- package/dist/{chunk-PIOMTC27.js → chunk-TUTSO7UZ.js} +2 -2
- package/dist/{chunk-FQKZWM4L.js → chunk-U24M5RQM.js} +5 -5
- package/dist/{chunk-XME3HPXZ.js → chunk-U2XX3BT4.js} +2 -2
- package/dist/{chunk-SZD2KF7Q.js → chunk-UWB5WMC2.js} +2 -2
- package/dist/{chunk-6CS3UQTN.js → chunk-VCL7FK3E.js} +2 -2
- package/dist/{chunk-N3IQCBCF.js → chunk-VCWAJPXQ.js} +2 -2
- package/dist/{chunk-LZYFLFEH.js → chunk-VG55NFXF.js} +2 -2
- package/dist/{chunk-PTAWHLVJ.js → chunk-VLTUX4IF.js} +2 -2
- package/dist/{chunk-JEJLSICM.js → chunk-VVCBMH5O.js} +2 -2
- package/dist/{chunk-JSOYNVWH.js → chunk-VYZQZ4ZN.js} +2 -2
- package/dist/chunk-W3FK73MD.js +8 -0
- package/dist/{chunk-UNBY47BC.js → chunk-W6C6QTXJ.js} +2 -2
- package/dist/chunk-WH5SYOMD.js +2 -0
- package/dist/chunk-WJOQC4P7.js +7 -0
- package/dist/chunk-WO47BIPY.js +3 -0
- package/dist/chunk-WOOTEWQT.js +239 -0
- package/dist/{chunk-UBGWN7I4.js → chunk-X5I2BQGX.js} +2 -2
- package/dist/{chunk-PX4RYAAK.js → chunk-XNUWRTYM.js} +2 -2
- package/dist/{chunk-ICFDQHAM.js → chunk-XUJM6474.js} +2 -2
- package/dist/chunk-XYLV727H.js +21 -0
- package/dist/{chunk-TRRC4ZJ7.js → chunk-YFQPWKHR.js} +2 -2
- package/dist/{chunk-NEDP5RFQ.js → chunk-YIOQJ45A.js} +2 -2
- package/dist/{chunk-Y6KHROC3.js → chunk-YXJ4IAHH.js} +2 -2
- package/dist/chunk-YYFV32WR.js +3 -0
- package/dist/{chunk-BH5F2Q4O.js → chunk-ZB3V5QM7.js} +2 -2
- package/dist/chunk-ZJZQ7Q2Q.js +3 -0
- package/dist/{chunk-EMNIHCRB.js → chunk-ZNQCR656.js} +2 -2
- package/dist/{chunk-TIIC3ZE7.js → chunk-ZOEDRCR4.js} +2 -2
- package/dist/cli-context-TSADTXLB.js +2 -0
- package/dist/cli-context-XEPPF4RX.js +3 -0
- package/dist/cli-program-KJGQEM72.js +7 -0
- package/dist/cli.js +1 -1
- package/dist/{code-DlqpBDd0.d.ts → code-CDe-mIjx.d.ts} +1 -1
- package/dist/code-viewer-YGDON6SY.js +12 -0
- package/dist/code-viewer-ZCTHXQ5C.js +11 -0
- package/dist/command-descriptors-5VAB2MZX.js +335 -0
- package/dist/command-descriptors-EAHKIRAG.js +337 -0
- package/dist/{config-types-BNoC96J3.d.ts → config-types-D6X5S68_.d.ts} +50 -0
- package/dist/{db-D7sauVFH.d.ts → db-DmRNdCtm.d.ts} +1 -1
- package/dist/direct-navigation-B3SGOOBW.js +2 -0
- package/dist/direct-navigation-ZL362KXF.js +3 -0
- package/dist/{graph-evidence-BIFqyisO.d.ts → graph-evidence-Bs54NWws.d.ts} +1 -1
- package/dist/{health-DJaZXg8I.d.ts → health-BnzbSLCE.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-CSUGUHTT.js +2 -0
- package/dist/invocation-command-descriptors-PPVZOIE5.js +3 -0
- package/dist/output-continuation-command-FTVVBVSN.js +2 -0
- package/dist/output-continuation-command-ITPRC3YV.js +3 -0
- package/dist/project-reindex-7HZSLLLY.js +3 -0
- package/dist/project-reindex-NGM3DYBN.js +2 -0
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.d.ts +2 -2
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.d.ts +2 -2
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +2 -2
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +3 -3
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +2 -2
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.d.ts +3 -3
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +2 -2
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +2 -2
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +2 -2
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +3 -3
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +2 -2
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +5 -5
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.d.ts +2 -2
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.d.ts +2 -2
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.d.ts +4 -4
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +2 -2
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.d.ts +2 -2
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +2 -2
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.d.ts +3 -3
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.d.ts +3 -3
- package/dist/reindex.js +31 -31
- package/dist/runtime.d.ts +24 -4
- package/dist/runtime.js +3 -3
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{scip-cli-B7N3haxa.d.ts → scip-cli-BRFKkHQn.d.ts} +1 -1
- package/dist/sentinel-ensure-command-KYYULCFU.js +2 -0
- package/dist/sentinel-ensure-command-RIZA3RY7.js +3 -0
- package/dist/sentinel-hook.js +39 -0
- package/dist/sentinel-worker.js +16 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +6 -6
- package/docs/COMMAND_REFERENCE.md +5 -3
- package/docs/schemas/project-config.schema.json +159 -0
- package/package.json +9 -5
- package/skills/codebaseiq/SKILL.md +1 -1
- package/skills/concrete-plan/SKILL.md +1 -1
- package/ui/view/api.js +450 -0
- package/ui/view/app.js +394 -0
- package/ui/view/builder.js +323 -0
- package/ui/view/file-panel.js +170 -0
- package/ui/view/focus.js +379 -0
- package/ui/view/index.html +54 -0
- package/ui/view/map.js +424 -0
- package/ui/view/styles.css +1125 -0
- package/dist/chunk-2X7V4HS4.js +0 -88
- package/dist/chunk-3IER7Q6H.js +0 -12
- package/dist/chunk-3JSXXYTZ.js +0 -345
- package/dist/chunk-476NR5B7.js +0 -2
- package/dist/chunk-5VKBFZZU.js +0 -3
- package/dist/chunk-ADTBPVUZ.js +0 -21
- package/dist/chunk-BFFZDZQV.js +0 -2
- package/dist/chunk-BMYOV5GP.js +0 -77
- package/dist/chunk-C74PPYLA.js +0 -3
- package/dist/chunk-CWONGW6P.js +0 -3
- package/dist/chunk-DDZ7VHWV.js +0 -20
- package/dist/chunk-DR2LURYU.js +0 -3
- package/dist/chunk-ECQBG7PW.js +0 -564
- package/dist/chunk-FM5BPL4V.js +0 -60
- package/dist/chunk-G6XFR4ZL.js +0 -4
- package/dist/chunk-GTIYTDRE.js +0 -562
- package/dist/chunk-HOA5YGOH.js +0 -3
- package/dist/chunk-KUW32IRO.js +0 -2
- package/dist/chunk-LTA3BRZX.js +0 -2
- package/dist/chunk-NAUD7LCA.js +0 -2
- package/dist/chunk-OGTFJ3XD.js +0 -2
- package/dist/chunk-Q5ELPRKQ.js +0 -2
- package/dist/chunk-QCN62RTF.js +0 -3
- package/dist/chunk-QW7EP6WI.js +0 -21
- package/dist/chunk-RU65DDUP.js +0 -215
- package/dist/chunk-SELM5MER.js +0 -2
- package/dist/chunk-SNNWPCN7.js +0 -4
- package/dist/chunk-TFZB6XTM.js +0 -239
- package/dist/chunk-UXM43C7T.js +0 -3
- package/dist/chunk-VFY6Y2H6.js +0 -61
- package/dist/chunk-WE5RZHZ7.js +0 -5
- package/dist/chunk-Z54RD7VL.js +0 -3
- package/dist/cli-context-3SNLDYBM.js +0 -3
- package/dist/cli-context-T3B7W6GG.js +0 -2
- package/dist/cli-program-YNOXO72B.js +0 -7
- package/dist/command-descriptors-6AOUKWW7.js +0 -346
- package/dist/command-descriptors-ZFKJSRUP.js +0 -344
- package/dist/direct-navigation-DP4LVMRX.js +0 -3
- package/dist/direct-navigation-FLUS3BT6.js +0 -2
- package/dist/invocation-command-descriptors-QT2JMY5J.js +0 -3
- package/dist/invocation-command-descriptors-YN4QJEAX.js +0 -2
- package/dist/output-continuation-command-2V2SL4TD.js +0 -2
- package/dist/output-continuation-command-65J5IP3O.js +0 -3
- package/dist/project-reindex-5JOKXAXT.js +0 -2
- package/dist/project-reindex-UQBIKO4M.js +0 -3
package/dist/chunk-HOA5YGOH.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{u as fe,v as et}from"./chunk-GTIYTDRE.js";import{c as Ye,h as ze}from"./chunk-PYAB5SM6.js";import{U as ue,V as pe,X as b,Y as A,Z as z,b as Ae,c as _e}from"./chunk-NCZUNH3E.js";import{h as he,j as Ze}from"./chunk-Z54RD7VL.js";import{d as Ve}from"./chunk-RU65DDUP.js";import{K as Je,L as Ke,V as Xe,a as oe,k as Qe,l as N}from"./chunk-QW7EP6WI.js";import{e as He}from"./chunk-FM5BPL4V.js";import{b as q,j as S,k as de,l as Be,m as le,n as Ue,r as I,s as Y}from"./chunk-RDBI2RXU.js";import{a as V,b as ie,c as M,d as W}from"./chunk-EF2R3WNQ.js";import{H as De,I as Me,J as w,K as qe,M as je,N as Ge,P as j,Q as Ne,S as ae,T as $e,U as Fe,V as G,W as H,X as ce,h as R,n as Oe,v as se,w as T,x as Le}from"./chunk-WE5RZHZ7.js";import{statSync as tt}from"fs";import{basename as Xt,isAbsolute as Zt,join as $,relative as er}from"path";import{fileURLToPath as tr}from"url";import{watch as rr}from"chokidar";import nr from"ignore";var dt=5e3,rt=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;observationEpoch=0;changeSequence=0;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=Ze(e.config),this.outputDb=e.outputDb??$(Me(this.projectRoot,e.config),"index.db"),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{});let r=e.onError??(n=>console.error(n.message));this.onError=n=>{this.observationEpoch+=1,r(n)},this.clock=e.clock??cr,lt.set(this,mr(e.stopTimeoutMs??dt,"watcher stop timeout")),this.reindexRunner=e.reindexRunner??fr(),this.subscriptionFactory=e.subscriptionFactory??dr,this.budgetInspector=e.budgetInspector??ze,ut.set(this,{gitReader:e.gitReader??Ne,languages:pt(e.languages??e.config.languages),stagedIndexEntries:null,gitSignalPaths:null,lastGitSignal:null}),this.gitignoreFilter=He(e.projectRoot),this.extraIgnore=nr(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,J(this).errors=[],this.sourcePollingFallbackStarted=!1,this.observationEpoch+=1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let n=[...J(this).closures],i=or(this),o=this.clock.now()+i;return this.stopPromise=this.finishStop(e,n,r,o,i).catch(s=>{throw this.stopInProgress=!1,s}),this.stopPromise}observation(){return{epoch:this.observationEpoch,changeSequence:this.changeSequence}}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(e);return}this.pendingTrigger=ot(this.pendingTrigger,e),this.changedFiles+=1,this.changeSequence+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{!this.stopped&&n!=="addDir"&&n!=="unlinkDir"&&this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!gr(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.observationEpoch+=1,this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),sr(J(this),e,i=>this.onError(i));try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Xt(r).startsWith(Ye)||(r===".codebaseiq.json"&&st(this,this.projectRoot),at(this,r)&&this.scheduleReindex({kind:"watch-source",detail:r}))}relativeWatchPath(e){let r=Zt(e)?e:$(this.projectRoot,e);return er(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=ot(this.pendingTrigger,e),this.changedFiles++,this.changeSequence+=1,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.inspectBudget();if(e.state==="paused"){this.dirty=!0;let s=Math.max(this.wallNow()+1,e.until);this.setStatus({state:"budget-paused",until:s,dirty:!0,reason:e.detail,rebuilt:e.rebuilt,estimatedWriteBytes:e.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,s-this.wallNow())));return}let r=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&r<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-r;this.dirty=!0;let a=this.wallNow()+s;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let n=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let i=this.wallNow();this.setStatus({state:"indexing",startedAt:i});let o=this.reindexRunner.start(this.reindexRequest(n));this.activeOperation=o,o.completion.then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=!1;try{a=this.onReindexComplete(s,n)===!0}catch(c){this.onError(c instanceof Error?c:new Error(String(c)))}if(this.dirty&&!this.stopped){if(a){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let c=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:c,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let a=s instanceof Error?s:new Error(String(s));this.onReindexError(a,n),this.onError(a),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===o&&(this.activeOperation=null)})}async finishStop(e,r,n,i,o){let s=[],a=e.map(async p=>{try{await p.close()}catch(m){s.push(`watch subscription close failed: ${String(m)}`)}});a.push(...r),n&&a.push((async()=>{try{let p=await n.cancel();p.state==="degraded"&&s.push(p.reason)}catch(p){s.push(`reindex cancellation failed: ${p instanceof Error?p.message:String(p)}`)}})());let c=a.length,d=a.map(p=>p.finally(()=>{c-=1})),u=await ir(d,i,this.clock),l=J(this);return s.push(...l.errors),l.errors=[],u?this.stopInProgress=!1:(s.push(`watch shutdown exceeded the ${o}ms deadline with ${c} operation(s) still pending`),Promise.all(d).then(()=>{this.stopInProgress=!1})),s.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:s.join("; ")}),{state:"degraded",reasons:s}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(e){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${e instanceof Error?e.message:String(e)}`}}}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){if(this.lastGitState=this.readGitState(),!this.lastGitState)return;let e=v(this);e.gitSignalPaths=this.resolveGitSignalPaths(),e.lastGitSignal=this.gitActivitySignal(),e.stagedIndexEntries=ct(this.projectRoot,e.gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.()}resolveGitSignalPaths(){let e=v(this).gitReader,r=G(this.projectRoot,["rev-parse","--git-dir"],e),n=G(this.projectRoot,["rev-parse","--git-common-dir"],e);if(!r)return null;let i=H(this.projectRoot,r),o=n?H(this.projectRoot,n):i,s=this.lastGitState?.indexPath;return[$(i,"HEAD"),$(o,"packed-refs"),$(o,"refs","heads"),...s?[s]:[]]}gitActivitySignal(){let e=v(this).gitSignalPaths;if(!e)return null;let r="";for(let n of e)try{let i=tt(n);r+=`${n}:${i.mtimeMs}:${i.size};`}catch{r+=`${n}:absent;`}return r}pollGitState(){let e=this.gitActivitySignal();if(e!==null){if(e===v(this).lastGitSignal)return;v(this).lastGitSignal=e}let r=this.lastGitState,n=this.readGitState();if(!r||!n||this.stopped){this.lastGitState=n;return}this.lastGitState=n;let i=r.head!==n.head,o=r.indexPath!==n.indexPath||r.indexMtimeMs!==n.indexMtimeMs||r.indexSize!==n.indexSize;if(!i&&!o)return;let s=v(this),a=s.stagedIndexEntries,c=ct(this.projectRoot,s.gitReader);s.stagedIndexEntries=c;let d=yr(this.projectRoot,s.gitReader,r,n,a,c,i,o),u=null;d!==null&&(d.includes(".codebaseiq.json")&&st(this,this.projectRoot),u=d.filter(l=>at(this,l)),u.length===0)||(i&&o?this.scheduleReindex({kind:"watch-git-state",detail:ge("HEAD and index changed",u)}):i?this.scheduleReindex({kind:"watch-git-head",detail:ge("HEAD changed",u)}):o&&this.scheduleReindex({kind:"watch-git-index",detail:ge(n.indexPath??"index changed",u)}))}readGitState(){let e=v(this).gitReader,r=G(this.projectRoot,["rev-parse","--git-path","index"],e);if(!r)return null;let n=H(this.projectRoot,r),i={head:G(this.projectRoot,["rev-parse","--verify","HEAD"],e),indexPath:n};try{let o=tt(n);i.indexMtimeMs=o.mtimeMs,i.indexSize=o.size}catch{i.indexMtimeMs=void 0,i.indexSize=void 0}return i}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function ir(t,e,r){if(t.length===0)return!0;let n=Promise.all(t).then(()=>!0),i=Math.max(0,e-r.now()),o=null,s=new Promise(c=>{o=r.setTimeout(()=>c(!1),i)}),a=await Promise.race([n,s]);return a&&o&&r.clearTimeout(o),a}var nt=new WeakMap,lt=new WeakMap,ut=new WeakMap;function J(t){let e=nt.get(t);if(e)return e;let r={closures:new Set,errors:[]};return nt.set(t,r),r}function or(t){return lt.get(t)??dt}function v(t){let e=ut.get(t);if(!e)throw new Error("Watcher input state was not initialized.");return e}function sr(t,e,r){let n=Promise.resolve().then(()=>e.close()).catch(i=>{let o=`watch subscription close failed during polling fallback: ${String(i)}`;t.errors.push(o),r(new Error(o))});t.closures.add(n),n.then(()=>t.closures.delete(n))}function ar(t,e=M){let{projectRoot:r,config:n,languages:i,pnpmWorkspaces:o,typescriptProjectMode:s,typescriptProjects:a,clojureConfigPath:c,indexerConcurrency:d,trigger:u}=t,l=he(r),p=Object.keys(l).length>0?l:n,m=Ge(r,p),g=p.indexer?.typescript,f=p.indexer?.clojure,D=e(process.pid);if(!D)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:tr(new URL("./reindex-worker.js",import.meta.url)),env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:r,SCIP_REINDEX_OUTPUT_SCIP:m.indexPath,SCIP_REINDEX_OUTPUT_DB:m.dbPath,SCIP_REINDEX_LANGUAGES:(p.languages??i)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(p.indexerConcurrency??d??""),SCIP_REINDEX_PNPM_WORKSPACES:g?.pnpmWorkspaces??o?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:g?.projectMode??s,projects:g?.projects??a??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:f?.configPath??c??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(D)}}}var cr={now:W,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},dr=(t,e)=>rr(t,e),lr=15*6e4,ur=1e3,pr=64*1024;function hr(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function it(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
|
|
2
|
-
${n}`:r}function fr(t={}){let e=t.timeoutMs??lr,r=t.terminationGraceMs??ur,n=t.maxOutputBytes??pr,i=t.resolveLaunch??ar;return{start(o){let s=i(o),a=new AbortController,c=hr(),d=!1,u=_e({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:e,terminationGraceMs:r,maxStdoutBytes:n,maxStderrBytes:n,outputLimitBehavior:"truncate-tail",signal:a.signal,detached:!0}).then(l=>{if(c={stdoutTail:l.stdout,stderrTail:l.stderr,stdoutTruncated:l.stdoutTruncated,stderrTruncated:l.stderrTruncated},l.status!==0)throw new Error(it(new Error(`Reindex worker exited with ${l.signal?`signal ${l.signal}`:`code ${l.status}`}`),c));return l.durationMs}).catch(l=>{throw l instanceof Ae&&(c={stdoutTail:l.stdout,stderrTail:l.stderr,stdoutTruncated:l.stdoutTruncated,stderrTruncated:l.stderrTruncated}),new Error(it(l,c),{cause:l})}).finally(()=>{d=!0});return{completion:u,async cancel(){d||a.abort();try{await u}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function ot(t,e){return t?t.kind===e.kind?t.detail===e.detail?t:{kind:t.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${t.kind}, ${e.kind}`}:e}function gr(t){return t instanceof Error&&"code"in t&&t.code==="EMFILE"||String(t).includes("EMFILE: too many open files")}function mr(t,e){if(!Number.isSafeInteger(t)||t<=0)throw new Error(`${e} must be a positive integer.`);return t}function pt(t){return t&&t.length>0?[...t]:oe}function st(t,e){try{v(t).languages=pt(he(e).languages)}catch{v(t).languages=oe}}function at(t,e){return Oe(e,v(t).languages)!=="other"}function yr(t,e,r,n,i,o,s,a){let c=new Set;if(s){if(!r.head||!n.head)return null;let d=e.runResult(t,["diff","--name-only","-z","--no-renames","--relative",r.head,n.head,"--"]);if(d.kind!=="success")return null;for(let u of Rr(d.output))c.add(u)}if(a){if(i===null||o===null)return null;for(let d of Sr(i,o))c.add(d)}return[...c].sort()}function ct(t,e){let r=e.runResult(t,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return r.kind==="success"?vr(r.output):null}function Rr(t){return t.split("\0").filter(e=>e.length>0)}function vr(t){let e=t.split("\0");if(e.at(-1)===""&&e.pop(),e.length%2!==0)return null;let r=new Map;for(let n=0;n<e.length;n+=2){let i=e[n],o=e[n+1];if(!i.startsWith(":")||!o)return null;r.set(o,i)}return r}function Sr(t,e){return[...new Set([...t.keys(),...e.keys()])].filter(n=>t.get(n)!==e.get(n))}function ge(t,e){return e===null?`${t}; changed paths unavailable`:e.length===0?t:e.length===1?e[0]:`${e.length} compiler inputs changed`}import{spawn as Dr}from"child_process";import{existsSync as Mr,rmSync as Et}from"fs";import{dirname as qr,resolve as ne}from"path";import{fileURLToPath as jr}from"url";import{createHash as br,randomUUID as me}from"crypto";import{existsSync as wr,linkSync as Ir,readdirSync as Er,rmSync as _}from"fs";import{basename as Cr,dirname as xr,join as y}from"path";var E=1,Pr=10*6e4,kr=10080*6e4,X="requests",F="claims",K="completions",ft="staging";function gt(t,e,r={}){let n=r.now?.()??new Date,i=Ar(r.ttlMs),o=_r(r.idempotencyKey),s=o?`key-${br("sha256").update(o).digest("hex")}`:`request-${(r.randomId??me)()}`,a={version:E,requestId:s,...o?{idempotencyKey:o}:{},createdAt:n.toISOString(),deadlineAt:new Date(n.getTime()+i).toISOString(),detail:e.trim().slice(0,2048)||"stale index observed by a command"},c=bt(t,s),d=Re(t,c,a,r.onStage);if(d.published)return{disposition:"accepted",request:a,achievedDurability:d.achievedDurability,directorySync:d.directorySync};let u=ye(c);if(!u)throw new Error(`Watch refresh request identity ${s} exists but is malformed.`);return{disposition:"duplicate",request:u}}function On(t,e={}){let r=e.now?.()??new Date,n=`claim-${(e.randomId??me)()}`,i=Math.max(1,Math.floor(e.limit??64)),o=Rt(t).sort(Or),s=[];for(let a of o){if(s.length>=i)break;if(ht(t,a.requestId))continue;if(Date.parse(a.deadlineAt)<=r.getTime()){yt(t,{version:E,requestId:a.requestId,outcome:"expired",completedAt:r.toISOString()});continue}let c={version:E,requestId:a.requestId,claimId:n,claimedAt:r.toISOString()};if(Re(t,wt(t,a.requestId),c).published){if(ht(t,a.requestId)){vt(t,a.requestId,n);continue}s.push(a)}}return{claimId:n,requests:s}}function Ln(t,e,r=()=>new Date,n){let i=r().toISOString();for(let o of e.requests)yt(t,{version:E,requestId:o.requestId,claimId:e.claimId,outcome:"completed",completedAt:i});n?.("after-completion"),Wr(t,e),n?.("after-claim-release")}function Wr(t,e){for(let r of e.requests)vt(t,r.requestId,e.claimId)}function Dn(t){let e=0;for(let r of C(y(t,F)))_(r,{force:!0}),e++;return e>0&&T(y(t,F)),St(t),e}function Mn(t){let e=Rt(t),r=new Map,n=Tr(y(t,X),ye);for(let c of C(y(t,K))){let d=Z(c);if(!d){n++;continue}r.set(d.requestId,d)}let i=new Set;for(let c of C(y(t,F))){let d=mt(c);if(!d){n++;continue}i.add(d.requestId)}let o=e.filter(c=>!r.has(c.requestId)&&!i.has(c.requestId)),s=[...r.values()].filter(c=>c.outcome==="completed").length,a=[...r.values()].filter(c=>c.outcome==="expired").length;return{pending:o.length,claimed:e.filter(c=>!r.has(c.requestId)&&i.has(c.requestId)).length,completed:s,expired:a,invalid:n,...o.length>0?{oldestPendingAt:o.map(c=>c.createdAt).reduce((c,d)=>Lr(c,d))}:{}}}function qn(t,e={}){let r=(e.now?.()??new Date).getTime(),n=Math.max(0,e.retentionMs??kr),i=0;for(let o of C(y(t,K))){let s=Z(o);!s||r-Date.parse(s.completedAt)<n||(_(o,{force:!0}),_(bt(t,s.requestId),{force:!0}),i++)}return i>0&&(T(y(t,K)),T(y(t,X))),St(t),i}function ye(t){return ve(t,e=>{let r=e;return r.version===E&&B(r.requestId)&&(r.idempotencyKey===void 0||typeof r.idempotencyKey=="string")&&q(r.createdAt)&&q(r.deadlineAt)&&Date.parse(r.deadlineAt)>=Date.parse(r.createdAt)&&typeof r.detail=="string"&&r.detail.length>0})}function mt(t){return ve(t,e=>{let r=e;return r.version===E&&B(r.requestId)&&B(r.claimId)&&q(r.claimedAt)})}function Z(t){return ve(t,e=>{let r=e;return r.version===E&&B(r.requestId)&&(r.claimId===void 0||B(r.claimId))&&(r.outcome==="completed"||r.outcome==="expired")&&q(r.completedAt)})}function yt(t,e){let r=It(t,e.requestId);if(Re(t,r,e).published)return;let n=Z(r);if(!n||n.requestId!==e.requestId||n.outcome!==e.outcome)throw new Error(`Watch refresh completion ${e.requestId} conflicts with an existing record.`)}function Re(t,e,r,n){let i=y(t,ft),o=xr(e),s=se(i),a=se(o),c=y(i,`${Cr(e)}.${process.pid}.${me()}.tmp`);try{let d=Y(c,r,{spacing:2,trailingNewline:!0});n?.("after-staged");try{Ir(c,e)}catch(l){if(l.code==="EEXIST")return{published:!1};throw l}let u=Le(s,a,d.directorySync,T(o));return n?.("after-published"),{published:!0,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}finally{_(c,{force:!0})}}function Rt(t){let e=[];for(let r of C(y(t,X))){let n=ye(r);n&&e.push(n)}return e}function vt(t,e,r){let n=wt(t,e),i=mt(n);!i||i.claimId!==r||(_(n,{force:!0}),T(y(t,F)))}function St(t){for(let e of C(y(t,ft),".tmp"))_(e,{force:!0})}function Tr(t,e){return C(t).filter(r=>!e(r)).length}function C(t,e=".json"){return wr(t)?Er(t,{withFileTypes:!0}).filter(r=>r.isFile()&&r.name.endsWith(e)).map(r=>y(t,r.name)).sort():[]}function ve(t,e){try{let r=JSON.parse(R(t,"watch refresh request record"));return e(r)?r:null}catch{return null}}function bt(t,e){return y(t,X,`${e}.json`)}function wt(t,e){return y(t,F,`${e}.json`)}function It(t,e){return y(t,K,`${e}.json`)}function ht(t,e){return Z(It(t,e))!==null}function Ar(t){if(t===void 0)return Pr;if(!Number.isFinite(t)||t<=0)throw new Error("Watch refresh request ttlMs must be positive.");return Math.floor(t)}function _r(t){let e=t?.trim();return e?e.slice(0,512):void 0}function B(t){return typeof t=="string"&&/^[a-z0-9][a-z0-9-]{0,127}$/i.test(t)}function Or(t,e){return Date.parse(t.createdAt)-Date.parse(e.createdAt)||t.requestId.localeCompare(e.requestId)}function Lr(t,e){return Date.parse(e)<Date.parse(t)?e:t}var Ct=5e3,Gr=6e3,Nr=1e3,be=10,$r=new Set(["capabilities","check-deps","config-validate","doctor","init","install-skills","reindex","setup","setup-agent","status","suppress","uninstall","watch"]);function ni(t){let e=t.classification;if(e.kind!=="live")return;let{state:r}=e;return r.watcher.state==="idle"&&r.lastError===void 0?r.indexGeneration:void 0}function Fr(t,e=process.env){return e.CODEBASEIQ_SKIP_WATCH_SERVICE!=="1"&&!t.startsWith("__")&&!$r.has(t)}function ii(t){let e=t.env??process.env;if(e.CODEBASEIQ_SKIP_WATCH_SERVICE==="1")return{kind:"skipped",reason:"environment"};if(!Fr(t.commandName,e))return{kind:"skipped",reason:"excluded-command"};if(t.config.watch?.enabled!==!0)return{kind:"skipped",reason:"disabled"};try{let r=Br({projectRoot:t.projectRoot,cacheDir:t.cacheDir,cliVersion:t.cliVersion,gitContext:t.gitContext,runtime:t.runtime});return{kind:r.disposition,state:r.state}}catch(r){return{kind:"failed",message:r instanceof Error?r.message:String(r)}}}function kt(t,e,r){let n=ce(ne(t));if(r&&ce(r.projectRoot)===n)return{projectRoot:n,worktreeKind:"git",worktreeId:r.worktreeId,cliVersion:e};let i=$e(n);if(i.kind==="error")throw new Error(`Could not establish Git worktree identity for ${n}: ${i.message}`);return i.kind==="non-git"?{projectRoot:n,worktreeKind:"non-git",cliVersion:e}:{projectRoot:n,worktreeKind:"git",worktreeId:i.identity.worktreeId,cliVersion:e}}function oi(t){return te(t,kt(t.projectRoot,t.cliVersion,t.gitContext))}function te(t,e){let r=t.runtime??Ce,n=b(t.cacheDir),i=A(n.statePath),o=Ee(n.lockPath);return{identity:e,classification:Ur(i,e,r.now(),r.isProcessAlive),lock:o,lockIsLive:o!==null&&r.isProcessAlive(o.pid),paths:n}}function Br(t){let e=t.runtime??Ce,r=kt(t.projectRoot,t.cliVersion,t.gitContext),n=te(t,r),i=we("ensure",n.classification);if(i.kind==="reuse")return ee(n.paths.activityPath,e),{disposition:"reused",state:i.state};if(i.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${i.state.pid} is still alive but its heartbeat is old. Refusing automatic replacement because civil-clock age alone cannot authorize a process signal.`);if(i.kind==="replace")Ie(i.state,t,e),U(n.paths,i.state.pid,e);else if(i.kind==="start"){if(n.lockIsLive){let a=xt(t,r,e,Math.min(t.startupTimeoutMs??1e3,1e3));if(a)return ee(n.paths.activityPath,e),{disposition:"reused",state:a};throw new Error(`codebaseiq watch is already running for ${ne(t.projectRoot)} (pid ${n.lock?.pid}; lock: ${n.paths.lockPath}) without compatible daemon state. Stop the foreground watcher before starting the service.`)}n.classification.kind==="stale"&&U(n.paths,n.classification.state.pid,e)}else throw new Error(`Unexpected ensure action: ${i.kind}`);if(n=te(t,r),i=we("ensure",n.classification),i.kind==="reuse")return ee(n.paths.activityPath,e),{disposition:"reused",state:i.state};if(i.kind==="refuse-replace")throw new Error(`codebaseiq watch service pid ${i.state.pid} remains alive with an old heartbeat; automatic replacement is not authorized.`);let o=t.serverPath??jr(new URL("./watch-server.js",import.meta.url));e.spawnServer(o,r.projectRoot,t.cliVersion,t.watchOverrides??{});let s=xt(t,r,e,t.startupTimeoutMs??Ct);if(!s)throw new Error(`codebaseiq watch service did not become ready within ${t.startupTimeoutMs??Ct}ms.`);return ee(n.paths.activityPath,e),{disposition:"started",state:s}}function Wt(t){let e=t.runtime??Ce,r=b(t.cacheDir),n=A(r.statePath),i=n?e.isProcessAlive(n.pid)?{kind:"live",state:n}:{kind:"stale",state:n,reason:"dead-process"}:{kind:"stopped"},o=we("stop",i);if(o.kind==="signal-stop")return Ie(o.state,t,e),U(r,o.state.pid,e),{disposition:"stopped",pid:o.state.pid};if(o.kind==="clean-stale")return U(r,o.state.pid,e),{disposition:"stopped",pid:o.state.pid};let s=Ee(r.lockPath);return o.kind==="already-stopped"&&s&&e.isProcessAlive(s.pid)?(Ie(s,t,e),U(r,s.pid,e),{disposition:"stopped",pid:s.pid}):{disposition:"already-stopped"}}function si(t,e,r={}){let{durability:n="durable",...i}=r;n==="durable"?Y(t,e,i):I(t,e,i)}function Tt(t,e=Date.now()){I(t,{version:1,at:new Date(e).toISOString()})}function ai(t,e,r=Date.now(),n={}){gt(b(qr(t)).refreshRequestsPath,e,{...n,now:()=>new Date(r)}),Tt(t,r)}function ci(t){try{let e=JSON.parse(R(t,"watch activity record"));return e.version!==1||!z(e.at)||e.refreshRequestedAt!==void 0&&!z(e.refreshRequestedAt)||e.refreshDetail!==void 0&&typeof e.refreshDetail!="string"?null:{atMs:Date.parse(e.at),...e.refreshRequestedAt===void 0?{}:{refreshRequestedAtMs:Date.parse(e.refreshRequestedAt)},...e.refreshDetail===void 0?{}:{refreshDetail:e.refreshDetail}}}catch{return null}}function di(t,e,r={}){let n=r.pid??process.pid,i=r.isProcessAlive??S,o=()=>{},s=r.readProcessIdentity??M,a=r.now??(()=>new Date),c={...de,wallNow:()=>a().getTime(),isProcessAlive:i,readProcessIdentity:s},d=Be(t,{kind:"watch",pid:n,processIdentity:s(n),detail:{projectRoot:ne(e)},parseLegacy:re,runtime:c});if(d.kind==="contended"){let u=At(d.observation);return{acquired:!1,lockPath:t,message:Qr(t,e,u),release:o}}return{acquired:!0,lockPath:t,message:"",release:()=>{d.lock.release()}}}function Ee(t){return At(le(t,{parseLegacy:re}))}var re=t=>{let e=_t(t);return e?{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}:null};function At(t){if(t.state==="valid"&&t.record?.kind==="watch"){let e=t.record.detail?.projectRoot;return typeof e!="string"?null:{version:1,pid:t.record.pid,...t.record.processIdentity?{processIdentity:t.record.processIdentity}:{},projectRoot:e,startedAt:t.record.startedAt}}return _t(t.parsed)}function _t(t){try{let e=t;if(e.version!==1||typeof e.pid!="number"||!Number.isInteger(e.pid)||e.pid<=0||typeof e.projectRoot!="string"||!z(e.startedAt))return null;let r=e.processIdentity===void 0?null:V(e.processIdentity);return e.processIdentity!==void 0&&(!r||r.pid!==e.pid)?null:{version:1,pid:e.pid,...r?{processIdentity:r}:{},projectRoot:e.projectRoot,startedAt:e.startedAt}}catch{return null}}function Ur(t,e,r,n){if(!t)return{kind:"stopped"};if(t.protocolVersion!==ue)return{kind:"incompatible",state:t,reason:"protocol"};if(t.projectRoot!==e.projectRoot)return{kind:"incompatible",state:t,reason:"project"};let i=e.worktreeKind==="git"?e.worktreeId:void 0;if(t.worktreeId!==i)return{kind:"incompatible",state:t,reason:"worktree"};if(t.cliVersion!==e.cliVersion)return{kind:"incompatible",state:t,reason:"cli-version"};if(!n(t.pid))return{kind:"stale",state:t,reason:"dead-process"};let o=Date.parse(t.heartbeatAt);return r-o>pe?{kind:"stale",state:t,reason:"old-heartbeat"}:{kind:"live",state:t}}function we(t,e){switch(t){case"status":return{kind:"report",classification:e};case"ensure":switch(e.kind){case"stopped":return{kind:"start"};case"stale":return e.reason==="old-heartbeat"?{kind:"refuse-replace",state:e.state,reason:"old-heartbeat"}:{kind:"start"};case"live":return{kind:"reuse",state:e.state};case"incompatible":return{kind:"replace",state:e.state};default:return Se(e)}case"stop":switch(e.kind){case"stopped":return{kind:"already-stopped"};case"stale":return e.reason==="old-heartbeat"?{kind:"signal-stop",state:e.state}:{kind:"clean-stale",state:e.state};case"live":case"incompatible":return{kind:"signal-stop",state:e.state};default:return Se(e)}default:return Se(t)}}function li(t){return t.idleTimeoutMs===0||t.watcher.state!=="idle"?!1:t.nowMs-t.lastActivityAtMs>=t.idleTimeoutMs}function xt(t,e,r,n){let i=r.monotonicNow??W,o=i()+n;for(;i()<=o;){let s=te(t,e).classification;if(s.kind==="live")return s.state;r.sleep(be)}return null}function Ie(t,e,r){let{pid:n}=t;if(!r.isProcessAlive(n))return;Pt(t,r),r.signalProcess(n);let i=e.stopTimeoutMs??Gr,o=r.monotonicNow??W,s=o()+i;for(;o()<=s;){if(!r.isProcessAlive(n))return;r.sleep(be)}if(!r.forceSignalProcess)throw new Error(`codebaseiq watch service pid ${n} did not stop within ${i}ms and forced termination is unavailable.`);Pt(t,r),r.forceSignalProcess(n);let a=e.forceStopTimeoutMs??Nr,c=o()+a;for(;o()<=c;){if(!r.isProcessAlive(n))return;let d=r.readProcessIdentity(n);if(t.processIdentity&&d&&!ie(t.processIdentity,d))return;r.sleep(be)}throw new Error(`codebaseiq watch service pid ${n} remained alive ${a}ms after forced termination.`)}function U(t,e,r){if(Et(t.statePath,{force:!0}),Et(t.activityPath,{force:!0}),Ee(t.lockPath)?.pid===e&&!r.isProcessAlive(e)){let i={...de,wallNow:r.now,isProcessAlive:r.isProcessAlive,readProcessIdentity:r.readProcessIdentity},o=le(t.lockPath,{parseLegacy:re,runtime:i});Ue(t.lockPath,o,{parseLegacy:re,runtime:i})}}function Qr(t,e,r){return`error: codebaseiq watch is already running for ${ne(e)}${r?` (pid ${r.pid}, started ${r.startedAt}; lock: ${t})`:` (lock: ${t})`}. Stop that watcher before starting another.`}function ee(t,e){try{(e.recordActivity??Tt)(t,e.now())}catch(r){let n=Vr(r);if(n!=="EPERM"&&n!=="EACCES"&&n!=="EROFS")throw r}}function Vr(t){return t.code}var Ce={now:Date.now,monotonicNow:W,isProcessAlive:S,readProcessIdentity:M,spawnServer(t,e,r,n){if(!Mr(t))throw new Error(`Watch service helper was not found at ${t}. Run npm run build first.`);Dr(process.execPath,[t,e,r,JSON.stringify(n)],{detached:!0,stdio:"ignore",windowsHide:!0,env:{...process.env,CODEBASEIQ_SKIP_WATCH_SERVICE:"1"}}).unref()},signalProcess(t){process.kill(t,"SIGTERM")},forceSignalProcess(t){process.kill(t,"SIGKILL")},sleep(t){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,t)}};function Pt(t,e){if(!t.processIdentity)throw new Error(`Refusing to signal codebaseiq watch pid ${t.pid}: its ownership record has no process identity.`);let r=e.readProcessIdentity(t.pid);if(!r)throw new Error(`Refusing to signal codebaseiq watch pid ${t.pid}: its process identity is unavailable.`);if(!ie(t.processIdentity,r))throw new Error(`Refusing to signal codebaseiq watch pid ${t.pid}: its process identity does not match the ownership record.`)}function Se(t){throw new Error(`Unhandled watch service value: ${JSON.stringify(t)}`)}import{existsSync as L,lstatSync as P,readdirSync as Dt,realpathSync as Ot,rmSync as x,statSync as Mt}from"fs";import{join as h,resolve as Q,sep as qt}from"path";var Hr=3600*1e3,Yr=2*1024*1024*1024,ke=300*1e3,zr="gc-state.json",Jr="gc.lock",Kr="projects-gc-state.json",Xr="projects-gc.lock",Zr=1440*60*1e3;function en(t){let e=t.leases.filter(a=>a.managed&&!a.live&&!a.busy),r=jt(t.leases,t.locks),n={};for(let a of t.generations)r.has(a.generationId)||(n[a.generationId]=a.unreferencedAt??t.nowMs);let i=t.generations.filter(a=>!r.has(a.generationId)).sort((a,c)=>n[a.generationId]-n[c.generationId]||a.generationId.localeCompare(c.generationId)),o=new Set;for(let a of i)t.nowMs-n[a.generationId]>=t.policy.generationTtlMs&&o.add(a.generationId);let s=t.generations.filter(a=>!o.has(a.generationId)).reduce((a,c)=>a+c.size,0);for(let a of i){if(s<=t.policy.budgetBytes)break;o.has(a.generationId)||(o.add(a.generationId),s-=a.size)}for(let a of o)delete n[a];return{deleteWorktrees:e,deleteGenerations:t.generations.filter(a=>o.has(a.generationId)),deleteLocks:t.locks.filter(a=>!a.live),deleteTemporaries:t.temporaries.filter(a=>!a.live),protectedGenerationIds:[...r].sort(),unreferencedSince:n}}function jt(t,e){let r=new Set(t.filter(n=>n.managed&&(n.live||n.busy)).flatMap(n=>[n.lease.baseGenerationId,n.lease.activeGenerationId]).filter(n=>n!==void 0));for(let n of e)n.live&&r.add(n.generationId);return r}function Ci(t,e,r={}){if(!je())return{kind:"disabled"};let n=ae(t);if(!n)return{kind:"unavailable"};let i=h(w(),"repositories",n.repositoryId),o=(r.now??Date.now)(),s=L(i)?Gt(t,i,n.repositoryId,e,o,r):{kind:"unavailable"};return nn(t,n.repositoryId,e,o,r),tn(o,r),s}function tn(t,e){let r=h(w(),"projects"),n={examined:0,reclaimed:0};if(!L(r))return n;let i=h(r,Kr),o=Ft(i);if(!e.force&&o!==void 0&&t-o<ke)return n;let s=N(h(r,Xr));if(!s)return n;try{for(let a of O(r)){let c=h(r,a),d;try{d=P(c)}catch{continue}if(!(!d.isDirectory()||d.isSymbolicLink())&&(n.examined+=1,!!rn(c,t)))try{x(c,{recursive:!0,force:!0}),n.reclaimed+=1}catch{}}I(i,{version:1,lastSweepAt:new Date(t).toISOString()},{spacing:2,trailingNewline:!0})}finally{s.release()}return n}function rn(t,e){let r=h(t,De),n;try{let s=JSON.parse(R(r,"cache-ownership"));if(typeof s.canonicalProjectRoot!="string"||s.canonicalProjectRoot.length===0)return!1;n=s.canonicalProjectRoot}catch{return!1}if(L(n))return!1;try{if(e-P(t).mtimeMs<Zr)return!1}catch{return!1}let i=A(b(t).statePath);if(i&&S(i.pid))return!1;let o=N(h(t,"cache-lifecycle.lock"));return o===null?!1:(o.release(),!0)}function Gt(t,e,r,n,i,o){let s=h(e,"gc-state.json"),a=$t(s);if(!o.force&&a&&i-Date.parse(a.lastSweepAt)<ke)return{kind:"throttled",sweptAt:a.lastSweepAt};let c=Qe(e,{now:()=>i});if(!c)return{kind:"busy"};try{let d=Nt(t,e,r,a?.unreferencedSince??{}),u=en({nowMs:i,...d,policy:{generationTtlMs:o.policy?.generationTtlMs??Hr,budgetBytes:o.policy?.budgetBytes??Yr}}),l=0,p=0;for(let f of u.deleteWorktrees){if(!We(f.lease))continue;if(!L(f.lease.localCacheDir)){x(f.leasePath,{force:!0}),p+=1;continue}if(!sn(f.lease))continue;let D=N(h(f.lease.localCacheDir,"cache-lifecycle.lock"));if(D)try{if(xe(f.lease,!0))continue;try{Wt({projectRoot:f.lease.projectRoot,cacheDir:f.lease.localCacheDir,cliVersion:n})}catch{continue}if(xe(f.lease,!0))continue;x(f.lease.localCacheDir,{recursive:!0,force:!0}),x(f.leasePath,{force:!0}),p+=1}finally{D.release()}}for(let f of u.deleteLocks)x(f.path,{force:!0});for(let f of u.deleteTemporaries)x(f.path,{recursive:!0,force:!0});for(let f of u.deleteGenerations)x(f.path,{recursive:!0,force:!0}),l+=f.size;Ve(h(e,"evidence.db"));let m={kind:"swept",sweptAt:new Date(i).toISOString(),deletedWorktrees:p,deletedGenerations:u.deleteGenerations.length,deletedBytes:l,protectedGenerations:u.protectedGenerationIds.length},g={version:1,lastSweepAt:m.sweptAt,unreferencedSince:u.unreferencedSince,lastResult:m};return I(s,g,{spacing:2,trailingNewline:!0}),m}catch(d){return{kind:"failed",error:d instanceof Error?d.message:String(d)}}finally{c.release()}}function nn(t,e,r,n,i){let o=h(w(),"repositories");if(!L(o))return;let s=h(o,zr),a=Ft(s);if(!i.force&&a!==void 0&&n-a<ke)return;let c=N(h(o,Jr));if(c)try{for(let d of O(o)){if(d===e||!/^[a-f0-9]{24}$/.test(d))continue;let u=h(o,d),l;try{l=P(u)}catch{continue}if(!l.isDirectory()||l.isSymbolicLink())continue;let p=an(u)??t;Gt(p,u,d,r,n,i)}I(s,{version:1,lastSweepAt:new Date(n).toISOString()},{spacing:2,trailingNewline:!0})}finally{c.release()}}function xi(t,e,r){let n=Je(t,r.dbPath,e);if(n)return{state:"bypassed",reason:n,localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let i=ae(t);if(!i)return{state:"unavailable",reason:"Git worktree identity is unavailable",localCacheDir:r.cacheDir,generations:0,generationBytes:0,protectedGenerations:0,unreferencedGenerations:0,unreferencedBytes:0,temporaryGenerations:0,sharedEvidence:{exists:!1,bytes:0}};let o=h(w(),"repositories",i.repositoryId),s=Te(h(o,"worktrees",`${i.worktreeId}.json`)),a=$t(h(o,"gc-state.json")),c=Nt(t,o,i.repositoryId,a?.unreferencedSince??{}),d=jt(c.leases,c.locks),u=c.generations.filter(g=>!d.has(g.generationId)),l=c.generations.reduce((g,f)=>g+f.size,0),p=Ke(t,e),m=0;return p&&(m=on(p)),{state:"managed",repositoryId:i.repositoryId,worktreeId:i.worktreeId,localCacheDir:r.cacheDir,...s?{baseGenerationId:s.baseGenerationId,activeGenerationId:s.activeGenerationId,lastAction:s.lastAction,reason:s.lastReason,lastSeenAt:s.lastSeenAt}:{},generations:c.generations.length,generationBytes:l,protectedGenerations:c.generations.filter(g=>d.has(g.generationId)).length,unreferencedGenerations:u.length,unreferencedBytes:u.reduce((g,f)=>g+f.size,0),temporaryGenerations:c.temporaries.length,sharedEvidence:{path:p,exists:m>0,bytes:m},cleanup:a?.lastResult}}function on(t){return[t,`${t}-wal`,`${t}-shm`].reduce((e,r)=>{try{return e+Mt(r).size}catch{return e}},0)}function Nt(t,e,r,n){let i=new Set(Fe(t).map(d=>Q(d.path))),o=[];for(let d of O(h(e,"worktrees"))){if(!d.endsWith(".json"))continue;let u=h(e,"worktrees",d),l=Te(u);if(!l)continue;let p=Q(l.projectRoot);o.push({leasePath:u,lease:l,managed:l.repositoryId===r&&We(l),live:i.has(p)||L(p),busy:xe(l)})}let s=[];for(let d of O(h(e,"locks"))){let u=/^([a-f0-9]{64})\.lock$/.exec(d);if(!u)continue;let l=h(e,"locks",d),p=Pe(l),m=p!==void 0&&S(p),g=u[1];s.push({generationId:g,path:l,live:m})}let a=[],c=[];for(let d of O(h(e,"generations"))){let u=/^\.tmp-(\d+)-/.exec(d);if(u){let m=h(e,"generations",d),g=Number(u[1]);try{c.push({path:m,size:Lt(m),live:Number.isSafeInteger(g)&&S(g)})}catch{}continue}if(!/^[a-f0-9]{64}$/.test(d))continue;let l=h(e,"generations",d),p;try{p=P(l)}catch{continue}!p.isDirectory()||p.isSymbolicLink()||a.push({generationId:d,path:l,size:Lt(l),...n[d]===void 0?{}:{unreferencedAt:n[d]}})}return{leases:o,generations:a,locks:s,temporaries:c}}function We(t){if(t.ownershipChecksum!==Xe(t)||j(t.localCacheDir)!==j(qe(t.projectRoot)))return!1;let e=j(h(w(),"projects"));return j(t.localCacheDir).startsWith(`${e}${qt}`)}function sn(t){if(!We(t))return!1;let e=Q(w()),r=Q(h(e,"projects")),n=Q(t.localCacheDir);try{let i=P(e),o=P(r),s=P(n);if(!i.isDirectory()||i.isSymbolicLink()||!o.isDirectory()||o.isSymbolicLink()||!s.isDirectory()||s.isSymbolicLink())return!1;let a=Ot(r);return Ot(n).startsWith(`${a}${qt}`)}catch{return!1}}function an(t){for(let e of O(h(t,"worktrees"))){if(!e.endsWith(".json"))continue;let r=Te(h(t,"worktrees",e));if(r)return r.projectRoot}}function xe(t,e=!1){for(let n of e?["index.lock"]:["index.lock","cache-lifecycle.lock"]){let i=Pe(h(t.localCacheDir,n));if(i!==void 0&&S(i))return!0}let r=Pe(b(t.localCacheDir).lockPath);return r!==void 0&&S(r)}function Te(t){try{let e=JSON.parse(R(t,"worktree cache lease"));return e.version!==1||typeof e.repositoryId!="string"||typeof e.worktreeId!="string"||typeof e.projectRoot!="string"||e.treeOid!==void 0&&typeof e.treeOid!="string"||typeof e.localCacheDir!="string"||e.baseGenerationId!==void 0&&typeof e.baseGenerationId!="string"||e.activeGenerationId!==void 0&&typeof e.activeGenerationId!="string"||typeof e.ownershipChecksum!="string"||!/^[a-f0-9]{64}$/.test(e.ownershipChecksum)||typeof e.lastAction!="string"||e.lastReason!==void 0&&typeof e.lastReason!="string"||typeof e.lastSeenAt!="string"?null:e}catch{return null}}function Pe(t){try{let e=JSON.parse(R(t,"watch lock record"));return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0?e.pid:void 0}catch{return}}function $t(t){try{let e=JSON.parse(R(t,"repository cache GC state"));return e.version!==1||typeof e.lastSweepAt!="string"||!Number.isFinite(Date.parse(e.lastSweepAt))||!e.unreferencedSince||typeof e.unreferencedSince!="object"||!e.lastResult?null:e}catch{return null}}function Ft(t){try{let e=JSON.parse(R(t,"global repository cache GC state"));if(e.version!==1||typeof e.lastSweepAt!="string")return;let r=Date.parse(e.lastSweepAt);return Number.isFinite(r)?r:void 0}catch{return}}function O(t){try{return Dt(t)}catch{return[]}}function Lt(t){let e=0,r=[t];for(;r.length>0;){let n=r.pop();for(let i of Dt(n,{withFileTypes:!0})){let o=h(n,i.name);i.isDirectory()?r.push(o):i.isFile()&&(e+=Mt(o).size)}}return e}import{createHash as Bt}from"crypto";import{tmpdir as cn,userInfo as dn}from"os";import{join as Ut}from"path";var k=1,_i=1*1024*1024,Oi=64*1024*1024,Li=12e4,Di=["NO_COLOR","FORCE_COLOR","CLICOLOR","CLICOLOR_FORCE","TERM","CODEBASEIQ_DEBUG"];function Mi(t){let e=Qt(),r=Bt("sha256").update(`${e}\0${t}`).digest("hex");return process.platform==="win32"?`\\\\.\\pipe\\codebaseiq-lane-${r.slice(0,32)}`:Ut(ln(),`lane-${r.slice(0,24)}.sock`)}function ln(){let t=Qt(),e=Bt("sha256").update(t).digest("hex").slice(0,16);return Ut(cn(),`codebaseiq-${e}`)}function Qt(){try{return dn().username}catch{return`uid-${typeof process.getuid=="function"?process.getuid():"unknown"}`}}function qi(t,e){let r=Buffer.from(JSON.stringify(t),"utf8");if(r.byteLength>e)throw new Error(`query-lane frame of ${r.byteLength} bytes exceeds the ${e}-byte limit`);let n=Buffer.allocUnsafe(4+r.byteLength);return n.writeUInt32LE(r.byteLength,0),r.copy(n,4),n}function ji(t,e,r){let n=Buffer.alloc(0),i=!1,o=s=>{i||(i=!0,r(new Error(s)))};return{push(s){if(!i)for(n=n.byteLength===0?s:Buffer.concat([n,s]);n.byteLength>=4;){let a=n.readUInt32LE(0);if(a>t){o(`query-lane frame of ${a} bytes exceeds the ${t}-byte limit`);return}if(n.byteLength<4+a)return;let c=n.subarray(4,4+a);n=n.subarray(4+a);let d;try{d=JSON.parse(c.toString("utf8"))}catch{o("query-lane frame carried invalid JSON");return}if(e(d),i)return}}}}function Gi(t){if(!t||typeof t!="object")return null;let e=t;return e.protocolVersion!==k||typeof e.projectRoot!="string"||e.projectRoot.length===0?null:e.kind==="ping"?{protocolVersion:k,kind:"ping",projectRoot:e.projectRoot}:e.kind!=="execute"||!Array.isArray(e.argv)||!e.argv.every(r=>typeof r=="string")||typeof e.cwd!="string"||e.deadlineMs!==void 0&&!Number.isFinite(e.deadlineMs)||e.envAllowlist!==void 0&&(typeof e.envAllowlist!="object"||e.envAllowlist===null||Array.isArray(e.envAllowlist)||!Object.values(e.envAllowlist).every(r=>typeof r=="string"))||e.tty!==void 0&&(typeof e.tty!="object"||e.tty===null||typeof e.tty.isTTY!="boolean"||e.tty.columns!==void 0&&!Number.isFinite(e.tty.columns))||e.clientInvocation!==void 0&&(typeof e.clientInvocation!="object"||e.clientInvocation===null||typeof e.clientInvocation.execPath!="string"||e.clientInvocation.execPath.length===0||e.clientInvocation.scriptPath!==void 0&&typeof e.clientInvocation.scriptPath!="string")?null:{...e,kind:"execute"}}function Ni(t){if(!t||typeof t!="object")return null;let e=t;if(e.protocolVersion!==k)return null;if(e.ok===!1)return e.code!=="unsupported"&&e.code!=="invalid-request"&&e.code!=="wrong-project"&&e.code!=="busy"&&e.code!=="stale-index"&&e.code!=="ineligible-command"&&e.code!=="execution-error"||typeof e.message!="string"?null:{ok:!1,protocolVersion:k,code:e.code,message:e.message};if(e.ok!==!0)return null;if(e.kind==="accepted"){let n=e.serverPid;return typeof n!="number"||!Number.isInteger(n)||n<=0?null:{ok:!0,kind:"accepted",protocolVersion:k,serverPid:n}}if(e.kind==="executed"){let n=e;return typeof n.serverPid!="number"||!Number.isInteger(n.serverPid)||n.serverPid<=0||typeof n.exitCode!="number"||!Number.isInteger(n.exitCode)||typeof n.stdout!="string"||typeof n.stderr!="string"||typeof n.generation!="string"||!/^[a-f0-9]{64}$/.test(n.generation)||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)?null:{ok:!0,kind:"executed",protocolVersion:k,serverPid:n.serverPid,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,generation:n.generation,durationMs:n.durationMs}}if(e.kind!=="pong"||typeof e.serverPid!="number"||!Number.isInteger(e.serverPid)||e.serverPid<=0||typeof e.cliVersion!="string"||typeof e.projectRoot!="string"||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration))return null;let r;if(e.processIdentity!==void 0){let n=V(e.processIdentity);if(!n||n.pid!==e.serverPid)return null;r=n}return{ok:!0,kind:"pong",protocolVersion:k,serverPid:e.serverPid,...r?{processIdentity:r}:{},cliVersion:e.cliVersion,projectRoot:e.projectRoot,...e.indexGeneration!==void 0?{indexGeneration:e.indexGeneration}:{}}}var Vt=[{question:"Who can call or reach this?",family:"execution",direction:"incoming"},{question:"What can this call or reach?",family:"execution",direction:"outgoing"},{question:"Where can this value come from?",family:"dataflow",direction:"incoming"},{question:"Where can this value go?",family:"dataflow",direction:"outgoing"},{question:"Which producer and consumer rendezvous?",family:"runtime",direction:"both"},{question:"What resource is observed or changed?",family:"state",direction:"both"},{question:"What occurs before or after this?",family:"temporal",direction:"both"},{question:"What interface constrains this?",family:"contract",direction:"both"},{question:"Are these observations the same entity?",family:"identity",direction:"both"},{question:"What contains or owns this?",family:"ownership",direction:"both"},{question:"What does this statically rely on?",family:"dependencies",direction:"outgoing"}],Ht={execution:{establishes:"Static may-call reachability between resolved program constructs.",nonClaims:["A may-call edge does not prove that a runtime invocation occurred."]},runtime:{establishes:"A source-grounded handoff between producer and consumer participants through a runtime mechanism.",nonClaims:["An unresolved or candidate join does not prove a runtime handoff."]},dataflow:{establishes:"A value, definition, argument, parameter, return, or statically resolved value may flow to another construct.",nonClaims:["Current partial providers do not establish general interprocedural definition-use coverage."]},state:{establishes:"A construct reads, writes, creates, deletes, or otherwise changes an identified state resource.",nonClaims:["A state edge does not prove transactionality, durability, or exclusive ownership unless qualified."]},temporal:{establishes:"One observed construct is locally ordered before or after another under the reported source evidence.",nonClaims:["Source order does not imply cross-process happens-before or durability."]},contract:{establishes:"A program construct implements, constrains, or is typed by an identified contract.",nonClaims:["Contract identity does not prove runtime invocation or conformance outside reported checks."]},identity:{establishes:"Two observations refer to the same compiler-owned or source-owned program entity.",nonClaims:["Shared identity does not establish execution or value transfer."]},ownership:{establishes:"A source construct, symbol, runtime observation, or state resource is contained or owned by another program entity.",nonClaims:["Structural ownership does not establish lifetime, singleton scope, or runtime execution unless qualified."]},dependencies:{establishes:"A file, module, or symbol statically relies on another indexed entity.",nonClaims:["A dependency edge does not establish that the depended-on code executes."]}};function Yt(t){return fe.flatMap(e=>e.relations.filter(r=>r.family===t).map(r=>({...r,providerId:e.id,providerLabel:e.label})))}function zt(t){return[...new Set(fe.filter(e=>e.relations.some(r=>r.family===t)).map(e=>e.label))]}var Ui=et.map(t=>({family:t,...Ht[t],providers:zt(t),relations:Yt(t)}));function Jt(t){return{family:t,...Ht[t],providers:zt(t),relations:Yt(t)}}var Hi=["search","outline","entrypoints","evidence","inspect","code"];function Yi(){return Vt.map(t=>{let e=Jt(t.family);return{...t,establishes:e.establishes,evidenceStrengths:Kt(e.relations.flatMap(r=>r.evidenceStrengths)),supportCeilings:Kt(e.relations.map(r=>r.supportCeiling)),nonClaim:e.nonClaims.join(" ")}})}function Kt(t){return[...new Set(t)]}export{rt as a,gt as b,On as c,Ln as d,Wr as e,Dn as f,Mn as g,qn as h,ni as i,Fr as j,ii as k,kt as l,oi as m,Br as n,Wt as o,si as p,ai as q,ci as r,di as s,li as t,Ci as u,xi as v,k as w,_i as x,Oi as y,Li as z,Di as A,Mi as B,qi as C,ji as D,Gi as E,Ni as F,Ui as G,Hi as H,Yi as I};
|
|
3
|
-
//# sourceMappingURL=chunk-HOA5YGOH.js.map
|
package/dist/chunk-KUW32IRO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{$ as p,aa as x,h as d}from"./chunk-WE5RZHZ7.js";import{b as g,d as f}from"./chunk-2Q2LW5JW.js";import{execFileSync as b}from"child_process";import{createHash as v}from"crypto";import{existsSync as s,statSync as j}from"fs";import{createRequire as B}from"module";import{platform as N}from"os";import{dirname as m,join as a}from"path";var S=B(import.meta.url),K={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function l(n){return[n.indexerBinary,...n.binaryAliases??[]]}function k(n){let e=l(n);return e.length===1?e[0]:e.join(" or ")}function u(n){for(let e of l(n)){let r=f(e);if(r)return r}return w(n)}function q(n){return u(n)!==null||L(n)}function L(n){return T(n)!==null}function w(n){let e=T(n);if(!e)return null;let t=JSON.parse(d(e,"indexer package manifest")).bin;if(!t)return null;if(typeof t=="string")return a(m(e),t);for(let o of l(n)){let i=t[o];if(i)return a(m(e),i)}return null}function T(n){if(!n.bundledNpmPackage)return null;try{return S.resolve(`${n.bundledNpmPackage}/package.json`)}catch{return null}}function O(n,e){for(let r of n.projectLocalBinaries??[]){let t=a(e,r);if(s(t))return t}return null}function E(n,e){for(let r of n.projectLocalBinaries??[]){let t=a(e,r);if(s(t))return I(e,r,t)}return null}function G(n,e){let r=D(n,e);if(!r||r.canonicalPath!==e.canonicalPath||r.sha256!==e.sha256||r.size!==e.size||r.mtimeMs!==e.mtimeMs||r.device!==e.device||r.inode!==e.inode||r.executable!==e.executable)throw new Error(`refusing changed project-local indexer ${e.relativePath}; review the current file and rerun with --trust-project-tools`)}function D(n,e){try{return I(n,e.relativePath,e.configuredPath)}catch{return null}}function I(n,e,r){let t={maxBytes:268435456,inputKind:"project-local indexer"},o=p(n,e,t),i=x(n,e,t),h=j(o.absolutePath);return{configuredPath:r,canonicalPath:o.absolutePath,relativePath:e,sha256:v("sha256").update(i).digest("hex"),size:o.size,mtimeMs:o.mtimeMs,device:o.device,inode:o.inode,executable:(h.mode&73)!==0}}function R(n,e,r={}){return(r.trustProjectTools?E(n,e)?.canonicalPath:null)??u(n)}function W(n,e=process.env,r=n.indexerBinary){if(n.indexerBinary!=="scip-dotnet"||c(r,e))return e;let t=P(r,e);return t?{...e,DOTNET_ROOT:t}:e}function Y(n,e,r={}){let t=k(n),o=e?R(n,e,r):u(n);if(!o)return{language:n.language,binaryLabel:t,installed:!1,runnable:!1,resolvedBinary:null,installUrl:n.installUrl,...e&&O(n,e)?{note:"project-local indexer available only with --trust-project-tools"}:{}};if(n.indexerBinary!=="scip-dotnet")return{language:n.language,binaryLabel:t,installed:!0,runnable:!0,resolvedBinary:o};let i=J(o);return{language:n.language,binaryLabel:t,installed:!0,runnable:i.runnable,resolvedBinary:o,installUrl:n.installUrl,note:i.note}}function J(n){if(c(n,process.env))return{runnable:!0};let e=P(n,process.env);if(e)return{runnable:!0,note:`using .NET 9 runtime from ${e}`};let r=y(process.env);return{runnable:!1,note:r.length>0?`.NET 9 runtime still unavailable after checking ${r.join(", ")}`:"binary is present, but scip-dotnet still needs a .NET 9 runtime"}}function P(n,e){for(let r of y(e))if(c(n,{...e,DOTNET_ROOT:r}))return r;return null}function y(n){let e=[],r=n.DOTNET_ROOT;if(r&&s(r)&&e.push(r),N()==="darwin"&&g("brew"))try{let t=b("brew",["--prefix","dotnet@9"],{stdio:"pipe",windowsHide:!0,env:n,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),o=a(t,"libexec");s(o)&&!e.includes(o)&&e.push(o)}catch{}return e}function c(n,e){try{return b(n,["--version"],{stdio:"pipe",windowsHide:!0,env:e,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}export{K as a,k as b,u as c,q as d,O as e,E as f,G as g,W as h,Y as i};
|
|
2
|
-
//# sourceMappingURL=chunk-KUW32IRO.js.map
|
package/dist/chunk-LTA3BRZX.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{Wa as v,bb as s,eb as E,fb as V,lb as I}from"./chunk-GTIYTDRE.js";import{c as y}from"./chunk-ZZ3MWF33.js";import{G as h,P as S,d as w}from"./chunk-Z54RD7VL.js";import{G as x}from"./chunk-WE5RZHZ7.js";var ce={defaultRole:"repository-observation"};function pe(e,n=[]){return{defaultRole:e,...n.length>0?{rules:n}:{}}}function k(e,n){for(let t of e.rules??[]){if(t.when.kind==="option-present"){let r=n.options[t.when.name];if(r!==void 0&&r!==!1)return t.role;continue}if((t.when.kind==="argument"?n.args[t.when.index]:n.options[t.when.name])===t.when.equals)return t.role}return e.defaultRole}function fe(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(n=>n.role)])]}function A(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}import{AsyncLocalStorage as z}from"async_hooks";var U=1,j=1;var F={policyId:"codebaseiq:unresolved-repository-policy",policyVersion:j,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function N(e){return{schemaVersion:U,origin:e.contract.origin,coverage:$(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:w(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??F,...e.contract.families?{families:e.contract.families}:{}}}function $(e){return e?e.complete===!0?{state:"complete",returned:e.returned,totalKnown:!0,total:e.total??e.returned,omitted:0}:e.totalKnown?{state:"partial",returned:e.returned,totalKnown:!0,...e.total===void 0?{}:{total:e.total},...e.omitted===void 0?{}:{omitted:e.omitted}}:{state:"unknown",returned:e.returned,totalKnown:!1}:{state:"unknown",returned:0,totalKnown:!1}}var W="codebaseiq-result";var G=1,Y=1,_=1,L=1;function M(e){let n=e.resultSchemaVersion??Y;if(!X(n))throw new Error("CLI result schema version must be a positive safe integer.");let{producerVersion:t,...o}=e;return{kind:W,schemaVersion:G,producer:{name:"codebaseiq",version:t},resultSchemaVersion:n,...o}}function J(e,n){return JSON.stringify(e,null,n?0:2)}function X(e){return Number.isSafeInteger(e)&&Number(e)>0}var P=Symbol("option-value-source"),T=new Map,D=new Map,B=new Map,H=new z;function Ie(e,n){return H.run(e,n)}function ke(e){T=new Map(e)}function Ae(e){D=new Map(e)}function Ne(e){B=new Map(e)}function m(e){return(...n)=>{let{args:t,opts:o}=le(n);S(r=>{I(r.generation.identity),e({db:r,args:t,opts:o})})}}function R(e,n){return m(t=>{let o=V(t.db,e,d(t.opts,"full"),{quiet:d(t.opts,"json")});n({...t,budget:o})})}function _e(e){return m(n=>c(n,e,{kind:"list"}))}function Le(e){return m(n=>c(n,e,{kind:"table",headers:e.headers,dashWidths:e.dashWidths}))}function Me(e){return m(n=>c(n,e,{kind:"grouped",key:e.key}))}function Z(e){return m(n=>b(n,e))}function Je(e){return Z({commandName:e.commandName,query:e.query,emptyMessage:e.emptyMessage,heuristicLabel:e.heuristicLabel,before:e.before,render:(n,t)=>s.sectionedReport(e.sections(n,t)),toJson:e.toJson,coverage:e.coverage,agentResult:e.agentResult,after:e.after})}function ee(e,n){return R(e,t=>b(t,{...n,commandName:n.commandName??e}))}function Pe(e,n){return ee(e,{commandName:n.commandName??e,query:n.query,emptyMessage:n.emptyMessage,heuristicLabel:n.heuristicLabel,before:n.before,render:(t,o)=>s.sectionedReport(n.sections(t,o)),toJson:n.toJson,coverage:n.coverage,agentResult:n.agentResult,after:n.after})}function Te(e,n){return R(e,t=>c(t,{...n,commandName:e},{kind:"list"}))}function De(e,n){return R(e,t=>c(t,{...n,commandName:e},{kind:"grouped",key:n.key}))}function Be(e,n){return String(e[n])}function He(e,n){let t=e[n];return typeof t=="string"?[t]:Array.isArray(t)&&t.every(o=>typeof o=="string")?t:[]}function Qe(e,n){let t=e[n];return typeof t=="string"?t:void 0}function qe(e,n){let t=e[n];return typeof t=="string"?t:void 0}function Q(e,n){let t=e[n];return typeof t=="number"?t:void 0}function d(e,n){return!!e[n]}function Ke(e,n){let t=e[n];return Array.isArray(t)&&t.every(o=>typeof o=="string")?t:[]}function Ue(e,n,t){return Q(e,n)??t}function je(e,n,t){let o=Q(e,n),r=o!==void 0&&ne(e,n)!=="default";if(d(e,"full")){if(r)throw new Error("--full cannot be combined with --limit. Use --full for all findings, or --limit N for a capped report.");return Number.MAX_SAFE_INTEGER}return o??t}function ne(e,n){return e[P]?.(n)}function c(e,n,t){b(e,{commandName:n.commandName,query:n.query,emptyMessage:(o,r)=>o.length===0&&n.emptyMessage?n.emptyMessage(r):void 0,heuristicLabel:n.heuristicLabel,render:(o,r)=>{t.kind==="list"?s.list(o,i=>n.format(i,r)):t.kind==="table"?s.table(t.headers,o.map(i=>n.format(i,r)),t.dashWidths):s.groupedByFile(o,i=>n.format(i,r),t.key?i=>t.key(i,r):void 0)},toJson:n.toJson,coverage:n.coverage,agentResult:n.agentResult,before:n.before,after:n.after})}function b(e,n){let t=n.query(e);if(d(e.opts,"json")){if(!n.commandName)throw new Error("JSON output requires a command name so its result contract can be identified.");oe(n.commandName,e.args,e.opts,n.toJson?n.toJson(t,e):t,{analysisBudget:te(e),coverage:n.coverage?.(t,e),agentResult:n.agentResult?.(t,e),resultSchemaVersion:n.resultSchemaVersion});return}let o=n.emptyMessage?.(t,e);if(o){s.empty(o);return}n.heuristicLabel&&E(n.heuristicLabel),n.before?.(t,e),n.render(t,e),n.after?.(t,e)}function te(e){return e.budget?.analysisBudget}function oe(e,n,t,o,r={}){let i=T.get(e),a=D.get(e),u=B.get(e),p=a?k(a.operation,{args:n,options:t}):void 0,f=H.getStore();if(f!==void 0&&p!==void 0&&f!==p)throw new Error(`Command ${e} changed operation role during execution: selected ${f}, rendered ${p}.`);let g=f??p,O=de(o),C=r.coverage??ae(a,o,r.analysisBudget),l=C&&O&&!C.resolution?{...C,resolution:O}:C;if(l&&ie(l),d(t,"resultOnly")){let K=Object.hasOwn(r,"resultOnly")?r.resultOnly:o;y(JSON.stringify(K,null,d(t,"compact")?0:2));return}let q=M({producerVersion:x,command:e,...g?{operationRole:g}:{},...i?{evidence:i}:{},...r.analysisBudget?{analysisBudget:r.analysisBudget}:{},args:ue(n),options:t,result:o,...l?{coverage:l}:{},...r.agentResult!==void 0?{agentResult:r.agentResult}:{},...re(g,i,r.analysisBudget,l,u,r.observationReceipt),...r.resultSchemaVersion===void 0?{}:{resultSchemaVersion:r.resultSchemaVersion}});y(J(q,d(t,"compact")))}function re(e,n,t,o,r,i){if(!e||!A(e))return{};let a=h(),u=i??(a?v({projectRoot:a.config.projectRoot,db:a,...r?{observedSourceKinds:r.observedSources}:{}}):void 0);return u?{evidenceContext:{schemaVersion:_,operationRole:e,receipt:u,analysisManifest:{schemaVersion:L,...n?{evidence:n}:{},...t?{analysisBudget:t}:{},...o?{coverage:o}:{},...r?{claimQualification:N({contract:r,receipt:u,...o?{coverage:o}:{}})}:{}}}}:{}}function ie(e){if(!Number.isSafeInteger(e.returned)||e.returned<0)throw new Error("Invocation coverage returned count must be a non-negative safe integer.");if(e.complete!==!0&&e.complete!==!1&&e.complete!==null)throw new Error("Invocation coverage complete must be true, false, or null.");if(e.complete===!0){if(!e.totalKnown)throw new Error("Complete invocation coverage must know its total.");if(!Number.isSafeInteger(e.total)||e.total!==e.returned)throw new Error("Complete invocation coverage total must equal returned.");if(e.omitted!==0)throw new Error("Complete invocation coverage cannot omit results.");if(e.omittedIdentities!==void 0)throw new Error("Complete invocation coverage cannot name omitted identities.");if(e.continuation!==void 0)throw new Error("Complete invocation coverage cannot provide a continuation.")}else if(e.totalKnown){if(e.complete!==!1)throw new Error("Known incomplete invocation coverage must set complete to false.");if(!Number.isSafeInteger(e.total)||e.total<e.returned)throw new Error("Known invocation coverage total must be a safe integer at least as large as returned.");let n=e.total-e.returned;if(e.omitted!==n)throw new Error("Known invocation coverage omitted count must equal total minus returned.");if(n===0)throw new Error("Known incomplete invocation coverage must omit at least one result.");if(e.omittedIdentities&&e.omittedIdentities.length!==n)throw new Error("Omitted identity count must equal the disclosed omitted count.")}else{if(e.total!==void 0||e.omitted!==void 0)throw new Error("Unknown invocation coverage cannot claim a total or omitted count.");if(e.omittedIdentities!==void 0)throw new Error("Unknown invocation coverage cannot claim omitted identities.")}if(e.continuation&&(e.continuation.cursor.length===0||e.continuation.indexGeneration.length===0))throw new Error("Invocation coverage continuation requires a cursor and index generation.");if(e.resolution){if(!Number.isSafeInteger(e.resolution.totalCandidates)||e.resolution.totalCandidates<0)throw new Error("Invocation resolution candidate count must be a non-negative safe integer.");if(e.resolution.state==="exact"&&e.resolution.totalCandidates!==1)throw new Error("Exact invocation resolution must name exactly one candidate.");if(e.resolution.state==="missing"&&e.resolution.totalCandidates!==0)throw new Error("Missing invocation resolution cannot name candidates.");if(e.resolution.state==="ambiguous"&&e.resolution.totalCandidates<2)throw new Error("Ambiguous invocation resolution must name at least two candidates.")}}function ae(e,n,t){if(!e)return;let o=se(e,n);return e.coverage==="complete"?{complete:!0,totalKnown:!0,returned:o,total:o,omitted:0}:e.coverage==="sampled"?{complete:!1,totalKnown:!1,returned:o}:e.coverage==="bounded"&&t?{complete:!1,totalKnown:!1,returned:o}:{complete:null,totalKnown:!1,returned:o}}function se(e,n){let t=e.resultUnits??{kind:"report"};if(t.kind==="rows")return Array.isArray(n)?n.length:0;if(t.kind==="field"){if(!n||typeof n!="object")return 0;let o=n[t.field];return Array.isArray(o)?o.length:o==null?0:1}return n==null?0:1}function de(e){if(!e||typeof e!="object"||Array.isArray(e))return;let n=e;if(n.matched===!1)return{state:"missing",totalCandidates:0};if(n.matched!==!0||!Number.isSafeInteger(n.totalMatches))return;let t=n.totalMatches;return t<=0?{state:"missing",totalCandidates:0}:t===1?{state:"exact",totalCandidates:t}:{state:"ambiguous",totalCandidates:t}}function ue(e){return e.filter(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean")}function le(e){if(e.length===0)return{args:[],opts:{}};let n=e[e.length-1];return{args:e.slice(0,-1),opts:me(n)}}function me(e){if(!e||typeof e!="object")return{};let n=e,t=typeof n.optsWithGlobals=="function"?n.optsWithGlobals.bind(n):typeof n.opts=="function"?n.opts.bind(n):null;if(t){let o=t();return!o||typeof o!="object"?{}:(typeof n.getOptionValueSource=="function"&&Object.defineProperty(o,P,{value:r=>n.getOptionValueSource(r),enumerable:!1}),o)}return e}export{ce as a,pe as b,k as c,fe as d,Ie as e,ke as f,Ae as g,Ne as h,m as i,R as j,_e as k,Le as l,Me as m,Z as n,Je as o,ee as p,Pe as q,Te as r,De as s,Be as t,He as u,Qe as v,qe as w,Q as x,d as y,Ke as z,Ue as A,je as B,ne as C,oe as D,le as E,me as F};
|
|
2
|
-
//# sourceMappingURL=chunk-LTA3BRZX.js.map
|
package/dist/chunk-NAUD7LCA.js
DELETED
package/dist/chunk-OGTFJ3XD.js
DELETED
package/dist/chunk-Q5ELPRKQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var s=new Set(["code","outline","refs"]),c=["--symbol","--at","--search","--view","--edge","--direction","--subtype","--connecting","--inventory-only","--fold","--depth","--max-edges"];function d(t){if(t[2]!=="evidence")return;let i=t[3];if(!i||i.startsWith("-"))return;if(t.slice(4).some(e=>c.some(r=>e===r||e.startsWith(`${r}=`)))){t.splice(3,1,"--symbol",i);return}t[2]="evidence-source"}function a(t){return t!==void 0&&s.has(t)}async function p(t){if(t==="continue"){let{outputContinuationCommandDescriptor:n}=await import("./output-continuation-command-2V2SL4TD.js");return[n]}if(a(t)){let{directNavigationQueryCommandDescriptors:n}=await import("./direct-navigation-FLUS3BT6.js"),o=n.find(e=>e.id===t);if(!o)throw new Error(`Direct navigation command descriptor is unavailable: ${t}`);return[o]}let{commandDescriptors:i}=await import("./command-descriptors-ZFKJSRUP.js");return i}export{d as a,a as b,p as c};
|
|
2
|
-
//# sourceMappingURL=chunk-Q5ELPRKQ.js.map
|
package/dist/chunk-QCN62RTF.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{d as R,e as k}from"./chunk-DO6WQD2T.js";import{h as f,i as L,v as E,w as v}from"./chunk-SNNWPCN7.js";import{connect as D}from"net";import{performance as S}from"perf_hooks";import{createHash as b}from"crypto";import{tmpdir as V,userInfo as j}from"os";import{join as h}from"path";var c=1,Q=1*1024*1024,_=64*1024*1024,y=12e4,x=["NO_COLOR","FORCE_COLOR","CLICOLOR","CLICOLOR_FORCE","TERM","CODEBASEIQ_DEBUG"],P=1500;function O(t){let e=T(),r=b("sha256").update(`${e}\0${t}`).digest("hex");return process.platform==="win32"?`\\\\.\\pipe\\codebaseiq-lane-${r.slice(0,32)}`:h(Y(),`lane-${r.slice(0,24)}.sock`)}function Y(){let t=T(),e=b("sha256").update(t).digest("hex").slice(0,16);return h(V(),`codebaseiq-${e}`)}function T(){try{return j().username}catch{return`uid-${typeof process.getuid=="function"?process.getuid():"unknown"}`}}function A(t,e){let r=Buffer.from(JSON.stringify(t),"utf8");if(r.byteLength>e)throw new Error(`query-lane frame of ${r.byteLength} bytes exceeds the ${e}-byte limit`);let n=Buffer.allocUnsafe(4+r.byteLength);return n.writeUInt32LE(r.byteLength,0),r.copy(n,4),n}function w(t,e,r){let n=Buffer.alloc(0),u=!1,i=s=>{u||(u=!0,r(new Error(s)))};return{push(s){if(!u)for(n=n.byteLength===0?s:Buffer.concat([n,s]);n.byteLength>=4;){let a=n.readUInt32LE(0);if(a>t){i(`query-lane frame of ${a} bytes exceeds the ${t}-byte limit`);return}if(n.byteLength<4+a)return;let l=n.subarray(4,4+a);n=n.subarray(4+a);let o;try{o=JSON.parse(l.toString("utf8"))}catch{i("query-lane frame carried invalid JSON");return}if(e(o),u)return}}}}function N(t){if(!t||typeof t!="object")return null;let e=t;if(e.protocolVersion!==c)return null;if(e.ok===!1)return e.code!=="unsupported"&&e.code!=="invalid-request"&&e.code!=="wrong-project"&&e.code!=="busy"&&e.code!=="stale-index"&&e.code!=="ineligible-command"&&e.code!=="execution-error"||typeof e.message!="string"?null:{ok:!1,protocolVersion:c,code:e.code,message:e.message};if(e.ok!==!0)return null;if(e.kind==="accepted"){let n=e.serverPid;return typeof n!="number"||!Number.isInteger(n)||n<=0?null:{ok:!0,kind:"accepted",protocolVersion:c,serverPid:n}}if(e.kind==="executed"){let n=e;return typeof n.serverPid!="number"||!Number.isInteger(n.serverPid)||n.serverPid<=0||typeof n.exitCode!="number"||!Number.isInteger(n.exitCode)||typeof n.stdout!="string"||typeof n.stderr!="string"||typeof n.generation!="string"||!/^[a-f0-9]{64}$/.test(n.generation)||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)?null:{ok:!0,kind:"executed",protocolVersion:c,serverPid:n.serverPid,exitCode:n.exitCode,stdout:n.stdout,stderr:n.stderr,generation:n.generation,durationMs:n.durationMs}}if(e.kind!=="pong"||typeof e.serverPid!="number"||!Number.isInteger(e.serverPid)||e.serverPid<=0||typeof e.cliVersion!="string"||typeof e.projectRoot!="string"||e.indexGeneration!==void 0&&!/^[a-f0-9]{64}$/.test(e.indexGeneration))return null;let r;if(e.processIdentity!==void 0){let n=E(e.processIdentity);if(!n||n.pid!==e.serverPid)return null;r=n}return{ok:!0,kind:"pong",protocolVersion:c,serverPid:e.serverPid,...r?{processIdentity:r}:{},cliVersion:e.cliVersion,projectRoot:e.projectRoot,...e.indexGeneration!==void 0?{indexGeneration:e.indexGeneration}:{}}}var I=250,C=2e3,q="CODEBASEIQ_NO_DAEMON",$="CODEBASEIQ_DAEMON";async function se(t,e={}){let r=await M(t,{protocolVersion:c,kind:"ping",projectRoot:f(t.projectRoot)},e);if(r.kind!=="ok")return r;let n=r.response;return n.ok!==!0?{kind:"incompatible",reason:`query lane refused ping: ${n.code}: ${n.message}`}:n.kind!=="pong"?{kind:"incompatible",reason:"query lane answered ping with a non-pong response"}:n.serverPid!==r.state.pid?{kind:"incompatible",reason:"query lane responder is not the advertised watch service process"}:n.processIdentity&&r.state.processIdentity&&!v(n.processIdentity,r.state.processIdentity)?{kind:"incompatible",reason:"query lane responder identity differs from the advertised service"}:{kind:"ok",pong:n,roundTripMs:r.roundTripMs,state:r.state}}async function ie(t){let e=t[0];if(!e||e.startsWith("-"))return{served:!1,reason:"no eligible command was invoked"};if(process.env.CODEBASEIQ_INDEX_DB)return{served:!1,reason:"an explicit index database is pinned by the environment"};if(process.env.CODEBASEIQ_SESSION)return{served:!1,reason:"session-ledger evidence runs in-process"};let r;try{let{resolveProjectRoot:d,resolveCliProjectContext:p,sharedCachePreparationEligible:U}=await import("./cli-context-3SNLDYBM.js");if(!U(e))return{served:!1,reason:`command ${e} always executes in-process`};let m=d(),g=p(m);r={projectRoot:m,cacheDir:g.paths.cacheDir,enabled:process.env[$]==="1"||g.config.daemon?.enabled===!0}}catch(d){return{served:!1,reason:`project resolution failed: ${d instanceof Error?d.message:d}`}}if(!r.enabled)return{served:!1,reason:"resident execution is not enabled for this project"};let{normalizeLegacyEvidenceInvocation:n}=await import("./invocation-command-descriptors-QT2JMY5J.js"),u=["node","codebaseiq",...t];n(u);let i=u.slice(2),s={};for(let d of x){let p=process.env[d];p!==void 0&&(s[d]=p)}let a={protocolVersion:c,kind:"execute",projectRoot:f(r.projectRoot),argv:i,cwd:process.cwd(),envAllowlist:s,tty:{isTTY:process.stdout.isTTY===!0,...typeof process.stdout.columns=="number"?{columns:process.stdout.columns}:{}},deadlineMs:y,clientInvocation:{execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{}}},l=await M(r,a,{acceptTimeoutMs:P,responseTimeoutMs:y+5e3});if(l.kind!=="ok")return{served:!1,reason:l.reason};let o=l.response;return o.ok!==!0||o.kind!=="executed"?{served:!1,reason:o.ok===!1?`${o.code}: ${o.message}`:"the lane answered with a non-execution response"}:o.serverPid!==l.state.pid?{served:!1,reason:"the executing process is not the advertised watch service"}:(o.stdout.length>0&&process.stdout.write(o.stdout),o.stderr.length>0&&process.stderr.write(o.stderr),process.exitCode=o.exitCode,{served:!0,exitCode:o.exitCode})}async function M(t,e,r={}){if(process.env[q]==="1")return{kind:"unavailable",reason:`${q}=1 disables the query lane`};let n=B(t);if("reason"in n)return n;let u=r.socketPathOverride??O(t.cacheDir),i=S.now(),s=await W(u,e,r);if("reason"in s)return s;let a=N(s.value);return a?{kind:"ok",response:a,roundTripMs:S.now()-i,state:n.state}:{kind:"incompatible",reason:"query lane returned a response this client cannot validate"}}function F(t){return!!t&&typeof t=="object"&&t.kind==="accepted"&&t.ok===!0}function B(t){let e=k(R(t.cacheDir).statePath);return e?e.projectRoot!==f(t.projectRoot)?{kind:"unavailable",reason:"the published watch service serves a different project root"}:e.queryLane===void 0?{kind:"unavailable",reason:"the running watch service does not advertise a query lane"}:e.queryLane.protocolVersion!==c?{kind:"incompatible",reason:`query lane protocol ${e.queryLane.protocolVersion} does not match client protocol ${c}`}:L(e.pid)?{state:e}:{kind:"unavailable",reason:"the advertised watch service process is not alive"}:{kind:"unavailable",reason:"no watch service state is published for this cache"}}function W(t,e,r){return new Promise(n=>{let u=!1,i=o=>{u||(u=!0,clearTimeout(a),s.destroy(),n(o))},s=D({path:t,timeout:r.connectTimeoutMs??I}),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out"}),(r.connectTimeoutMs??I)+(r.acceptTimeoutMs??r.responseTimeoutMs??C)),l=w(_,o=>{if(F(o)){clearTimeout(a),a=setTimeout(()=>i({kind:"unavailable",reason:"query lane response timed out after acknowledgement"}),r.responseTimeoutMs??C);return}i({value:o})},o=>i({kind:"unavailable",reason:`query lane response was malformed: ${o.message}`}));s.on("timeout",()=>i({kind:"unavailable",reason:"query lane connection timed out"})),s.on("error",o=>i({kind:"unavailable",reason:`query lane connection failed: ${o.message}`})),s.on("close",()=>i({kind:"unavailable",reason:"query lane closed before responding"})),s.on("data",o=>l.push(o)),s.on("connect",()=>{s.setTimeout(0);try{s.write(A(e,Q))}catch(o){i({kind:"unavailable",reason:`query lane request could not be encoded: ${o instanceof Error?o.message:String(o)}`})}})})}export{se as a,ie as b};
|
|
3
|
-
//# sourceMappingURL=chunk-QCN62RTF.js.map
|
package/dist/chunk-QW7EP6WI.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import{c as Yt}from"./chunk-FM5BPL4V.js";import{a as _,b as Vt,i as I,j as ie,l as Te,o as Ce,r as F,s as G}from"./chunk-RDBI2RXU.js";import{a as $t,b as zt,c as te,d as re}from"./chunk-EF2R3WNQ.js";import{C as Qt,D as K,F as Pe,G as Ht,J as Ut,K as ze,L as Ge,M as We,P as Ve,S as oe,U as Jt,a as v,b as J,c as R,f as S,g as E,ga as Qe,h as b,ha as He,l as Bt,m as Y,q as Wt,v as Ee,w as j,x as ne}from"./chunk-WE5RZHZ7.js";var Kt=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"],ho=["entry-surface","generated-code","compatibility-shim","reflection-or-registration","test-fixture","intentional-twin","historical-coupling-ended","detector-counterexample"];var Ue=2,z=3;var Je=new Set(Kt);function Ae(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${En(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!==Ue&&r!==z)return{kind:"unsupported",version:r,direction:r<Ue?"older":"future"};let n=In(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:bn(i)};return r===Ue?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function Ro(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Xt(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 bn(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 In(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!Vt(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!xn(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!wn(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&&!Rn(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===z&&e.typescriptProjectShards!==void 0&&!vn(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function vo(e){return e.version===z&&e.sqliteLayoutVersion===1}function xn(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Je.has(t))?!1:new Set(e).size===e.length}function wn(e){return Array.isArray(e)&&e.every(t=>_(t)&&typeof t.language=="string"&&Je.has(t.language)&&typeof t.reason=="string")}function Rn(e){return _(e)&&Object.entries(e).every(([t,r])=>Je.has(t)&&_(r))}function vn(e){return _(e)&&Object.values(e).every(t=>_(t)&&Array.isArray(t.files)&&t.files.every(Wt))}function En(e){return e instanceof Error?e.message:String(e)}import Vn from"better-sqlite3";import{createHash as An,randomUUID as kn}from"crypto";import{existsSync as W,mkdirSync as Dn,readdirSync as Ln,rmSync as ir,statSync as or}from"fs";import{basename as On,dirname as se,join as x}from"path";import{join as Pn}from"path";function ke(e,t){return e.reason instanceof Error?e.reason:new Error(t)}function Zt(e,t){if(e?.aborted)throw ke(e,t)}var Gn=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 er(e,t={}){return T(Pn(e,"gc.lock"),t)}function T(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??re,o=i()+r;do{let a=tr(e);if(a)return rr(a);let s=o-i();if(s<=0)return null;Tn(Math.min(n,s))}while(i()<=o);return null}async function ko(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??re,o=i()+r;do{Zt(t.signal,"Lock acquisition was aborted.");let a=tr(e);if(a)return rr(a);let s=o-i();if(s<=0)return null;await Cn(Math.min(n,s),t.signal)}while(i()<=o);return null}function tr(e){let t=Te(e,{kind:"generic",parseLegacy:Gn});return t.kind==="acquired"?t.lock:null}function rr(e){return{release:()=>{e.release()}}}function Tn(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}function Cn(e,t){return t?.aborted?Promise.reject(ke(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?ke(t,"Lock acquisition was aborted."):new Error("Lock acquisition was aborted."))};t?.addEventListener("abort",o,{once:!0})})}var V=1,Ze=1,ce=".codebaseiq-generations",De="manifest.json",ar="readers",Mn="gc.lock",_n=128,ae=new Map,sr={pid:process.pid,now:()=>new Date,randomToken:()=>kn(),isProcessAlive:ie,readProcessIdentity:te,resolveImmutableGeneration:dr};function m(e){return x(se(e),ce)}function de(e){return x(m(e),Mn)}function cr(e,t=sr){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:tt(e),release(){}};let a=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(a))throw new Error("SQLite generation reader token is unsafe.");let s=x(m(e.dbPath),ar);Dn(s,{recursive:!0});let c=x(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,ir(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 jn(e,n.identity)}function jn(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(x(se(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return{generation:lr(e,n.currentGeneration),release(){}}}finally{r.release()}}function et(e,t,r=sr,n={}){let i=x(m(e),ar);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 Ln(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let l=x(i,d.name),p;try{p=Fn(JSON.parse(b(l,"SQLite generation reader lease")))}catch{p=null}if(!p){c+=1;for(let h of t)o.add(h);continue}if(!Nn(p,r)){n.removeStale!==!1&&(ir(l,{force:!0}),s+=1);continue}a+=1,o.add(p.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function Fn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:$t(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 Nn(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||zt(e.processIdentity,r)}function C(e){try{let t=JSON.parse(b(x(m(e),"state.json"),"SQLite generation state"));return Bn(t)?t:null}catch{return null}}function le(e,t){return ue(m(e),t)}function ue(e,t){try{let r=JSON.parse(b(x(e,t,De),"SQLite generation manifest"));return qn(r,t)?r:null}catch{return null}}function tt(e){let t=C(e.dbPath);if(t){let r=dr(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(x(se(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return lr(e,t?.currentGeneration)}function zo(e){let t=C(e);if(t)return t.currentGeneration;try{let r=x(se(e),"meta.json"),n=W(r)?b(r,"reindex metadata"):void 0;return ur(e,n)}catch{return null}}function N(e){return Xt(Ae(e))??e}function dr(e,t){try{let r=x(m(e.dbPath),t),n=le(e.dbPath,t);if(!n)return null;let i=Ye(r,n.database),o=n.index?Ye(r,n.index):void 0,a=n.metadata?Ye(r,n.metadata):void 0;return!Ke(i,n.database)||n.index&&(!o||!Ke(o,n.index))||n.metadata&&(!a||!Ke(a,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:b(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function lr(e,t){let r=O(e.dbPath),n=x(se(e.dbPath),"meta.json"),i=W(n)?b(n,"reindex metadata"):void 0,o=W(e.indexPath)?e.indexPath:void 0;return{identity:t??ur(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function ur(e,t){let r=An("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=or(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Ye(e,t){if(On(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return x(e,t.file)}function Ke(e,t){if(!W(e))return!1;let r=nr(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=nr(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(ae.set(n,!0);ae.size>_n;){let a=ae.keys().next().value;if(a===void 0)break;ae.delete(a)}return!0}function nr(e){let t=or(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function qn(e,t){return e.version===Ze&&e.identity===t&&Xe(e.database)&&(e.index===void 0||Xe(e.index))&&(e.metadata===void 0||Xe(e.metadata))}function Xe(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 Bn(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")&&$n(e.stableMirrors)&&zn(e.previousGeneration)&&Wn(e.publication)}function $n(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 zn(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 Wn(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 Qn=["busy_timeout = 5000","query_only = ON","temp_store = MEMORY","cache_size = -64000","mmap_size = 268435456"],rt=class{constructor(t,r){this.connection=t;this.releaseGenerationReader=r}connection;releaseGenerationReader;active=!0;initialize(t){try{for(let r of Qn)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}},Hn=["node_modules",".git","dist","build","out","coverage","target",".next",".nuxt",".cache",".turbo",".nbb",".cpcache",".shadow-cljs",".codebaseiq-cache","__pycache__",".venv","venv"],pr=class{db;config;generation;pathFilter;connection;connectionOwnership;statementCache=new Map;closed=!1;constructor(t,r){this.config=t,this.pathFilter=r??null;let n=Kn(t),i=new rt(n.db,n.release);try{i.initialize(Yn),this.generation=n.generation,this.connection=n.db,this.connectionOwnership=i,this.db=Un(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=>Hn.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{Yt(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 Un(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 Jn(r)}})}function Jn(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 Yn(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)Pe(n.relative_path)}function Kn(e){for(let t=0;t<4;t+=1){let r=cr(e),n=r.generation,i;try{i=new Vn(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=tt(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 cn,randomUUID as no}from"crypto";import{existsSync as B,lstatSync as Tt,mkdirSync as ee,mkdtempSync as dn,readdirSync as ln,realpathSync as un,renameSync as U,rmSync as q,statSync as Be}from"fs";import{dirname as Ct,join as u,resolve as we}from"path";import{setTimeout as io}from"timers/promises";import{pathToFileURL as nn}from"url";import{deserializeSCIP as pn}from"@c4312/scip";import oo from"better-sqlite3";import{execFileSync as Xn}from"child_process";import{existsSync as Zn,readdirSync as gr}from"fs";import{extname as mr,join as yr}from"path";var hr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),ei=[{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 nt(e){let t=[],r=ti(e),n=oi(e);for(let i of ei){if(ri(e,i.files)){t.push(i.language);continue}if(ni(r,i.globs)){t.push(i.language);continue}si(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&fr(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&fr(t,"c"),t}function ti(e){try{return gr(e)}catch{return[]}}function ri(e,t){return t?.length?t.some(r=>Zn(yr(e,r))):!1}function ni(e,t){return t?.length?e.some(r=>t.some(n=>ii(r,n))):!1}function ii(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 oi(e){let t=ai(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=gr(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=yr(i,a.name);if(a.isDirectory()){hr.has(a.name)||n.push(s);continue}let c=mr(a.name).toLowerCase();c&&r.add(c)}}return r}function ai(e){try{let t=Xn("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=>hr.has(o)))continue;let i=mr(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function si(e,t){return t?.length?t.some(r=>e.has(r)):!1}function fr(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{lstatSync as xi,readdirSync as wi}from"fs";import{join as Ri,relative as vi,resolve as pt,sep as Ei}from"path";import{createHash as ci}from"crypto";import{existsSync as pe,mkdirSync as di,readdirSync as Sr,renameSync as li,rmSync as br,writeFileSync as ui}from"fs";import{join as M}from"path";import{create as xr,fromBinary as wr,toBinary as pi}from"@bufbuild/protobuf";import{deserializeSCIP as Le,DocumentSchema as ot,IndexSchema as Rr,serializeSCIP as vr}from"@c4312/scip";var Oe=1,fe="typescript-scip-fragments";function sa(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=wr(ot,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);r.push(s)}let n=vr(xr(Rr,{documents:r,externalSymbols:[]})),i=Le(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 fi(e){let t=Le(e.indexBytes);Lr(t.metadata,Or(e)),Dr(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=pi(ot,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(Tr(e.cacheDir,{relativePath:a,bytes:s,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Cr(e,n);return Ar(e.cacheDir,i),i}function ca(e){let t=ge(e.cacheDir);if(!pe(st(t,e.generationIdentity)))return fi(e);let r=Er({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 da(e){let t=Er({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,Tr(e.cacheDir,o,s))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Cr(e,[...r.values()]);return Ar(e.cacheDir,i),i}function Er(e){let t=ge(e.cacheDir),r=st(t,e.generationIdentity),n;try{n=at(E(r,{maxBytes:v,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=S(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 Pr(e){let t=Gr(e);return it(t.baseIndex,t.completeDocuments,"assembled")}function la(e){let t=Gr(e);return gi(t.deletedAffectedPaths),{completeIndexBytes:it(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:it(t.baseIndex,t.affectedDocuments,"affected")}}function Gr(e){let t=Le(e.baseIndexBytes);Lr(t.metadata,Or(e)),Dr(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=wr(ot,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 it(e,t,r){let n=vr(xr(Rr,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Le(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function gi(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function ua(e,t){let r=ge(e);if(!pe(r.generationDir))return;let n=new Set(t.map(a=>kr(a))),i=Sr(r.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>n.has(s))){let s=at(E(M(r.generationDir,a),{maxBytes:v,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)n.has(a)||br(M(r.generationDir,a),{force:!0});if(pe(r.blobDir))for(let a of Sr(r.blobDir))o.has(a)||br(M(r.blobDir,a),{force:!0})}function Tr(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);di(a.blobDir,{recursive:!0});let s=M(a.blobDir,`${o}.scipdoc`);if(pe(s)){let c=S(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`;ui(c,i),li(c,s)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function Cr(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:Oe,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function Ar(e,t){let r=ge(e),n=st(r,t.generationIdentity);if(pe(n)){let i=at(E(n,{maxBytes:v,inputKind:"TypeScript fragment manifest"}));if(Ir(i)!==Ir(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}F(n,t,{spacing:2,trailingNewline:!0})}function Ir(e){return H(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function at(e){let t=JSON.parse(e);if(t.version!==Oe||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 st(e,t){return M(e.generationDir,kr(t))}function kr(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${H(e)}.json`}function Dr(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Lr(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 Or(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 ci("sha256").update(e).digest("hex")}import{createHash as mi}from"crypto";import{existsSync as me,mkdirSync as yi,readdirSync as ct,renameSync as hi,rmSync as Mr,writeFileSync as Si}from"fs";import{join as P}from"path";var Me=1,ba=64*1024*1024,he="typescript-scip-overlays";function Ia(e){let t=jr(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=ut(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);n.add(a),r.set(a,bi(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Me,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 Ii(e.cacheDir,i),i}function xa(e){let t=jr(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=S(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 Pr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function wa(e,t){let r=Se(e),n=P(r,"generations");if(!me(n))return;let i=new Set(t.map(lt)),o=new Set;for(let s of ct(n).filter(c=>i.has(c))){let c=dt(E(P(n,s),{maxBytes:v,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of ct(n))i.has(s)||Mr(P(n,s),{force:!0});let a=P(r,"blobs");if(me(a))for(let s of ct(a))o.has(s)||Mr(P(a,s),{force:!0})}function jr(e,t){let r=P(Se(e),"generations",lt(t));if(!me(r))return null;let n=dt(E(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function bi(e,t){let r=ut(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");yi(o,{recursive:!0});let a=P(o,`${i}.scipdoc`);if(me(a)){let s=S(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`;Si(s,n),hi(s,a)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Ii(e,t){let r=P(Se(e),"generations",lt(t.generationIdentity));if(me(r)){let n=dt(E(r,{maxBytes:v,inputKind:"TypeScript overlay manifest"}));if(_r(n)!==_r(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}F(r,t,{spacing:2,trailingNewline:!0})}function dt(e){let t=JSON.parse(e);if(t.version!==Me||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(ut(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 lt(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${ye(e)}.json`}function _r(e){return ye(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function ut(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 mi("sha256").update(e).digest("hex")}var be=1,ft="language-indexes",Fr=["index.db","index.scip","meta.json"],Nr=[ft,fe,he];function _e(e){let t=[];for(let r of Fr)Pi(e,r),t.push(r);for(let r of Nr)qr(e,r,t);return{version:be,files:t.sort()}}function je(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(!Fr.includes(e)&&!Nr.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function A(e,t){let r=je(t),n=pt(e),i=pt(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Ei}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function qr(e,t,r){let n=Ri(e,t),i;try{i=wi(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()?qr(e,a,r):o.isFile()&&r.push(je(a))}}function Pi(e,t){let r=A(e,t),n;try{n=xi(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(vi(pt(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{writeFileSync as mt}from"fs";import{create as X}from"@bufbuild/protobuf";import{deserializeSCIP as yt,serializeSCIP as ht,DocumentSchema as Li,IndexSchema as $r,MetadataSchema as zr,SymbolInformationSchema as Oi}from"@c4312/scip";import{writeFileSync as Gi}from"fs";import{create as Br}from"@bufbuild/protobuf";import{deserializeSCIP as Ti,DocumentSchema as Ci,IndexSchema as Ai,serializeSCIP as ki,SymbolRole as Di}from"@c4312/scip";function Oa(e){let t;try{t=Ti(S(e,{inputKind:"SCIP sanitization input",maxBytes:R}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=gt(t);return r.touchedDocuments>0&&Gi(e,Buffer.from(ki(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function gt(e){let t=new Set,r=new Map;for(let a of e.documents){r.set(a,Pe(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&Di.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(Br(Ci,{language:a.language,relativePath:s,occurrences:c,symbols:a.symbols,text:a.text,positionEncoding:a.positionEncoding}))}return{index:i===0?e:Br(Ai,{metadata:e.metadata,documents:o,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:i}}function Wr(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=_i(e),r=ji(e.flatMap(i=>i.documents??[])),n=Qr(e.flatMap(i=>i.externalSymbols??[]));return X($r,{metadata:t,documents:r,externalSymbols:n})}function $a(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>yt(S(i,{inputKind:"SCIP merge input",maxBytes:R}))),n=Wr(r);return mt(t,Buffer.from(ht(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function za(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>yt(S(i,{inputKind:"SCIP merge input",maxBytes:R}))),n=gt(Wr(r));return mt(t,Buffer.from(ht(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Mi(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($r,{metadata:X(zr,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function Vr(e,t,r){let n=yt(S(e,{inputKind:"SCIP normalization input",maxBytes:R})),i=Mi(n,t,r);mt(e,Buffer.from(ht(i)))}function _i(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&&Qt(r);return n===r?t:X(zr,{...t,projectRoot:n})}function ji(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(Li,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:Fi([...n.occurrences,...r.occurrences]),symbols:Qr([...n.symbols,...r.symbols]),text:qi(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function Fi(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 Qr(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(Oi,{symbol:n.symbol,documentation:Bi([...n.documentation,...r.documentation]),relationships:Ni([...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 Ni(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 qi(e,t){return e?t?e.length>=t.length?e:t:e:t}function Bi(e){return[...new Set(e)]}import{createHash as Rt}from"crypto";import{closeSync as $i,existsSync as g,mkdirSync as zi,openSync as Wi,readSync as Vi,readdirSync as vt,renameSync as xt,rmSync as Ie,statSync as Z}from"fs";import{basename as Yr,dirname as k,join as f,relative as Hr}from"path";var wt=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Kr(e){let t=m(e.outputDb),r=Yi(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Gt({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||It(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),It(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),It(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,d={...a,stableMirrors:Pt(e.outputDb,e.outputScip)};G(f(t,"state.json"),d,{spacing:2,trailingNewline:!0});let l=Xr(e.outputDb,{now:e.now}),p=ne(i.directorySync,s.directorySync);return{currentGeneration:c,...r?{previousGeneration:r}:{},retention:l,achievedDurability:p==="synced"?"directory-durable":"file-flushed",directorySync:p}}function Qi(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)?Xi(r,e,t):void 0;if(s&&!ue(a,s))return null;let c=Gt({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:Pt(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 rs(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=Gt({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?tn(e,n.currentGeneration):void 0,s={version:V,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Pt(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}),Xr(e,{now:r}),s}function Xr(e,t={}){let r=Hi(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=Zr(e),c=et(e,s.map(w=>w.identity),{isProcessAlive:t.isProcessAlive??ie,readProcessIdentity:t.readProcessIdentity??te}),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((w,$e)=>w+$e.logicalBytes,0),h=0,D=0;for(let w of s){if(l<=r.maxGenerations&&p<=r.maxLogicalBytes)break;d.has(w.identity)||(t.onBeforeRemove?.(w.identity),Ie(w.path,{recursive:!0,force:!0}),l-=1,p-=w.logicalBytes,h+=1,D+=w.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 Ur(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{Ur(e,s)}catch{}return s}finally{o.release()}}function ns(e){let t=m(e);if(!g(t))return{state:"absent",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,malformedReaderLeases:0,limits:{...wt},reason:"local immutable generation store does not exist"};let r=Ui(e),n=r?.limits??{...wt},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=Zr(e),a=C(e),s=et(e,o.map(d=>d.identity),{isProcessAlive:ie,readProcessIdentity:te},{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 Hi(e={}){let t={...wt,...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 Zr(e){let t=m(e);return g(t)?vt(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):en(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 en(e){let t=0;for(let r of vt(e,{withFileTypes:!0})){let n=f(e,r.name);r.isDirectory()?t+=en(n):r.isFile()&&(t+=Z(n).size)}return t}function Ur(e,t){F(f(m(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function Ui(e){try{let t=JSON.parse(b(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 Et(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?Ji(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 Ji(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")))||!Jr(e,r.database))return!1;let i=f(k(e),"index.scip");if(r.index&&!Jr(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(b(t,"reindex metadata"))===N(b(o,"immutable reindex metadata"))}function Jr(e,t){return g(e)&&Z(e).isFile()&&Z(e).size===t.size}function Yi(e){let t=Qi(e.outputDb,e.outputScip,e.metaPath);return t?tn(e.outputDb,t.currentGeneration):void 0}function Pt(e,t){return{databaseFileIdentity:O(e),...g(t)?{indexFileIdentity:O(t)}:{}}}function tn(e,t){let r=f(m(e),t),n=f(r,Yr(e)),i=f(r,"meta.json");return{generationIdentity:t,databasePath:Hr(k(e),n),...g(i)?{metadataPath:Hr(k(e),i)}:{}}}function Ki(e){if(g(e)){for(let t of vt(e,{withFileTypes:!0}))if(t.isDirectory()&&t.name.endsWith(".tmp"))try{Ie(f(e,t.name),{recursive:!0,force:!0})}catch{}}}function Xi(e,t,r=f(k(t),"index.scip")){let n=Rt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(Fe(t)),g(r)&&n.update(`\0${Fe(r)}`),g(e)&&n.update(`\0${N(b(e,"reindex metadata"))}`),n.digest("hex")}function Gt(e){let t=St(e.databasePath),r=e.indexPath?St(e.indexPath):void 0,n=e.metadataPath?St(e.metadataPath):void 0,i=e.forcedIdentity??Zi(t,r,e.metadataPath),o=f(e.generationRoot,i),a=f(o,De);if(g(a)){let d=ue(e.generationRoot,i);if(d&&rn(o,d.database,t)&&to(o,d.index,r)&&ro(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=[Ee(e.generationRoot)];Ki(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;Ie(c,{recursive:!0,force:!0}),zi(c,{recursive:!0});try{s.push(bt(e.databasePath,f(c,t.file))),r&&e.indexPath&&s.push(bt(e.indexPath,f(c,r.file))),n&&e.metadataPath&&s.push(bt(e.metadataPath,f(c,n.file)));let d=G(f(c,De),{version:Ze,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)),I(()=>xt(c,o)),s.push(j(e.generationRoot))}finally{try{Ie(c,{recursive:!0,force:!0})}catch{}}return{identity:i,directorySync:ne(...s)}}function Zi(e,t,r){let n=Rt("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${N(b(r,"reindex metadata"))}`),n.digest("hex")}function St(e){return{file:Yr(e),size:Z(e).size,sha256:Fe(e)}}function Fe(e){let t=Rt("sha256"),r=Wi(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=eo(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{$i(r)}return t.digest("hex")}function eo(e,t){let r=0;for(;r<t.length;){let n=Vi(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function bt(e,t){return Ce(e,t,{mode:292})}function rn(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&&Fe(n)===t.sha256}function to(e,t,r){return!t||!r?t===r:rn(e,t,r)}function ro(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=f(e,t.file);return g(n)&&N(b(n,"stored reindex metadata"))===N(b(r,"candidate reindex metadata"))}function It(e,t){I(()=>Ie(`${t}.tmp-replace`,{force:!0})),I(()=>xt(e,`${t}.tmp-replace`)),I(()=>xt(`${t}.tmp-replace`,t))}var Lt=1,on="CODEBASEIQ_SHARED_CACHE",ao=2,Ne=JSON.stringify({cliVersion:Ht,artifactCatalogVersion:be,postIndexAugmentationSchemaVersion:ao,sqliteGenerationStoreVersion:V,typescriptFragmentStoreVersion:Oe,typescriptOverlayStoreVersion:Me}),Ot="manifest.json",so="shared-cache.json",Mt=[ft,fe,he];function At(e,t){if(!e.clean||!e.treeOid)return;let r=Sn(JSON.stringify({version:Lt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Ne}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Ne,generationId:r,repositoryCacheDir:Ge(e.repositoryId)}}function fn(e,t,r){if(process.env[on]==="0")return`${on}=0`;if(!We(r))return"explicit cache or database override";if(Ve(Ct(t))!==Ve(ze(e))||t!==u(Ct(t),"index.db"))return"index database is outside the managed worktree cache"}function ks(e,t,r){if(!We(t))return;let n=r??oe(e);return n?u(Ge(n.repositoryId),"evidence.db"):void 0}function $(e,t=!0){let r=Ft(e),n;try{n=mn(E(u(r,Ot),{inputKind:"shared-generation manifest",maxBytes:v}))}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=Be(o);if(!a.isFile()||a.size!==i.size||Y(o,{inputKind:"shared-generation artifact",maxBytes:R})!==i.sha256)return null}}catch{return null}return n}function Ds(e,t,r){if(!e.treeOid)return null;let n=He(t,r),i=u(Ut(),"repositories",e.repositoryId),o;try{let c=Tt(i);if(!c.isDirectory()||c.isSymbolicLink())return null;o=un(i)}catch{return null}let a=u(o,"generations"),s=[];try{for(let c of ln(a)){if(!/^[a-f0-9]{64}$/.test(c))continue;let d=u(a,c),l;try{l=Tt(d)}catch{continue}if(!(!l.isDirectory()||l.isSymbolicLink()))try{let p=mn(E(u(d,Ot),{inputKind:"shared-generation baseline manifest",maxBytes:v}));p.generationId===c&&p.repositoryId===e.repositoryId&&p.treeOid===e.treeOid&&p.producerIdentity===Ne&&po(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 gn(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 co(e)}finally{t.release()}}function co(e){let t=$(e.snapshot);if(t)return an(e.snapshot,t);if(!Re(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=sn(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=_e(e.sourceCacheDir),i=u(e.snapshot.repositoryCacheDir,"generations"),o=[Ee(i)],a=dn(u(i,`.tmp-${process.pid}-`));try{let s=[];for(let y of n.files){let L=A(e.sourceCacheDir,y),w=A(a,y);o.push(ve(L,w,292)),e.onPublicationStage?.("after-artifact-flushed",y);let $e=Be(w).size;s.push({path:y,size:$e,sha256:Y(w,{inputKind:"staged shared-generation artifact",maxBytes:R})})}let c=pn(S(u(a,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:R})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let d=qt(e.sourceProjectRoot);if(!K(c,d))throw new Error("shared SCIP generation root does not match its source worktree");if(sn(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let l={version:Lt,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,Ot),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=Ft(e.snapshot);try{if(B(h)&&!$(e.snapshot)){let y=`${h}.corrupt-${process.pid}-${Date.now()}`;I(()=>U(h,y)),q(y,{recursive:!0,force:!0})}I(()=>U(a,h))}catch(y){let L=$(e.snapshot);if(L)return an(e.snapshot,L);throw y}e.onPublicationStage?.("after-generation-renamed"),o.push(j(i)),e.onPublicationStage?.("after-generations-directory-synced");let D=ne(...o);return{kind:"published",manifest:l,achievedDurability:D==="synced"?"directory-durable":"file-flushed",directorySync:D}}finally{q(a,{recursive:!0,force:!0})}}function an(e,t){let r=j(u(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function kt(e){let t=Ft(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=dn(u(e.targetCacheDir,".shared-hydrate-")),yo(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),Be(l).size!==c.size||Y(l,{inputKind:"hydrated shared-generation artifact",maxBytes:R})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=qt(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&Vr(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=fo(e.targetCacheDir,n),o=!0,go(n,e.targetCacheDir,i),Kr({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=Et(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&&Dt(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&mo(e.targetCacheDir,i),a}finally{n&&q(n,{recursive:!0,force:!0}),r.release()}}function Ls(e,t,r,n){let i=fn(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 qe(o,r.cacheDir,"missed",void 0,"worktree has uncommitted changes"),{kind:"missed",reason:"worktree has uncommitted changes"};let a=t.languages??nt(e),s=Qe(e,a,yn(t)),c=At(o,s);if(!c)return{kind:"missed",reason:"clean committed snapshot is unavailable"};let d=$(c);if(d)return kt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId};let l=lo(c,e);return l?(d=l.manifest,kt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e,action:"peer-imported"}),{kind:"peer-imported",generationId:c.generationId,sourceProjectRoot:l.sourceProjectRoot}):(qe(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 Os(e,t,r,n){let i=fn(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 qe(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??nt(e),s=Qe(e,a,yn(t)),c=At(o,s);if(!c)return qe(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)?(Dt(c,r.cacheDir,"local-fresh"),{kind:"local-fresh"}):(kt({snapshot:c,manifest:d,targetCacheDir:r.cacheDir,targetProjectRoot:e}),{kind:"attached",generationId:c.generationId});let l=jt(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)?(gn({snapshot:c,sourceCacheDir:r.cacheDir,sourceProjectRoot:e,sourceStillValid:()=>{let p=oe(e);return(p?At(p,s):void 0)?.generationId===c.generationId}}),Dt(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 Ms(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??re,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=Te(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 io(Math.min(n,l))}return $(e)?{kind:"generation-ready"}:{kind:"timeout"}}function Dt(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:_t(i)};return Nt(e.repositoryCacheDir,o,!0),o}function _s(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:_t(n)};return Nt(e.repositoryCacheDir,i,!0),i}function qe(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:_t(o)};return Nt(Ge(e.repositoryId),a,!1),a}function _t(e){return Sn(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:we(e.projectRoot),localCacheDir:we(e.localCacheDir)}))}function mn(e){let t=JSON.parse(e);if(t.version!==Lt||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!==Ne||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(je(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 Ce(e,t,{mode:r})}function lo(e,t){for(let r of Jt(t)){if(we(r.path)===we(t))continue;let n=ze(r.path),i=jt(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:gn({snapshot:e,sourceCacheDir:n,sourceProjectRoot:r.path}).manifest,sourceProjectRoot:r.path}}catch{continue}}return null}function uo(e,t,r){ee(e,{recursive:!0}),G(u(e,so),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function sn(e){try{let t=_e(e),r=cn("sha256");for(let n of t.files){let i=A(e,n),o=Be(i).size;r.update(n).update("\0").update(String(o)).update("\0"),Bt(i,{inputKind:"source-generation artifact",maxBytes:R},a=>r.update(a)),r.update("\0")}return r.digest("hex")}catch{return null}}function jt(e){try{let t=Ae(E(u(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:v}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function yn(e){return{pnpmWorkspaces:e.indexer?.typescript?.pnpmWorkspaces,typescriptProjectMode:e.indexer?.typescript?.projectMode,typescriptProjects:e.indexer?.typescript?.projects,clojureConfigPath:e.indexer?.clojure?.configPath}}function po(e,t){let r=He(e.languages,e);return JSON.stringify(r)===JSON.stringify(t)}function Ft(e){return u(e.repositoryCacheDir,"generations",e.generationId)}function Nt(e,t,r){let n=er(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}),uo(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function fo(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 Mt){let c=u(e,s),d=B(c);if(d){let l=Tt(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&&hn(o,u(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:a}}function go(e,t,r){for(let n of Mt){let i=u(t,n);if(r.managedDirectories.get(n)){let a=u(r.root,"managed",n);ee(Ct(a),{recursive:!0}),I(()=>U(i,a))}let o=u(e,n);B(o)&&I(()=>U(o,i))}}function mo(e,t){for(let i of Mt){let o=u(e,i),a=u(t.root,"managed",i);t.managedDirectories.get(i)?B(a)&&(q(o,{recursive:!0,force:!0}),I(()=>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-${no()}`;ve(u(t.root,"stable",i),s),I(()=>q(a,{force:!0})),I(()=>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)&&I(()=>U(n,r))}function hn(e,t){ee(t,{recursive:!0});for(let r of ln(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()?hn(n,i):r.isFile()&&ve(n,i)}}function yo(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=jt(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=_e(e),s=Et(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 oo(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=qt(t),p=(i?a.files.filter(h=>h.endsWith(".scip")):["index.scip"]).every(h=>{let D=pn(S(A(e,h),{inputKind:"shared SCIP validation artifact",maxBytes:R})).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 qt(e){try{return nn(un(e)).href}catch{return nn(we(e)).href}}function Sn(e){return cn("sha256").update(e).digest("hex")}function Fs(e){return typeof e=="object"&&e!==null}function Ns(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}export{Kt as a,ho as b,z as c,Ae as d,Ro as e,Xt as f,bn as g,vo as h,ke as i,Zt as j,er as k,T as l,ko as m,zo as n,pr as o,Fs as p,Ns as q,nt as r,Oa as s,$a as t,za as u,sa as v,ca as w,da as x,la as y,ua as z,ba as A,Ia as B,xa as C,wa as D,Kr as E,Qi as F,rs as G,ns as H,Et as I,At as J,fn as K,ks as L,$ as M,Ds as N,gn as O,kt as P,Ls as Q,Os as R,Ms as S,Dt as T,_s as U,_t as V};
|
|
21
|
-
//# sourceMappingURL=chunk-QW7EP6WI.js.map
|