codebaseiq 0.3.1 → 0.4.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 +65 -0
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-7GAK2F3H.js → chunk-23AD24QZ.js} +12 -12
- package/dist/chunk-24TEZJST.js +2 -0
- package/dist/{chunk-356EZBIP.js → chunk-26EDDGAX.js} +2 -2
- package/dist/{chunk-O2M3VNDY.js → chunk-26EZWQ24.js} +2 -2
- package/dist/{chunk-U33PMPNW.js → chunk-2L3NCI52.js} +2 -2
- package/dist/{chunk-MSI3K7PJ.js → chunk-2QJAVISG.js} +2 -2
- package/dist/{chunk-4LK5OIPW.js → chunk-2ZBZRYX4.js} +2 -2
- package/dist/{chunk-JYRJYXUV.js → chunk-33AXWMO2.js} +2 -2
- package/dist/{chunk-EQNMD62X.js → chunk-37K55EG3.js} +2 -2
- package/dist/{chunk-LCW3PSGL.js → chunk-3EFZ5KQ4.js} +2 -2
- package/dist/{chunk-D7DOB27N.js → chunk-3F23W57G.js} +2 -2
- package/dist/{chunk-BGGB5N53.js → chunk-3GKKCVKK.js} +2 -2
- package/dist/{chunk-MQW6SJ4P.js → chunk-3SYRGMCL.js} +2 -2
- package/dist/{chunk-DWBAESVW.js → chunk-3VDL7GTY.js} +2 -2
- package/dist/{chunk-BFANZRQ5.js → chunk-3XBZ5PKL.js} +2 -2
- package/dist/{chunk-K6FNTQQW.js → chunk-42PXSE74.js} +2 -2
- package/dist/{chunk-ALOEHWJS.js → chunk-4GIERC2P.js} +2 -2
- package/dist/{chunk-W7YLRXZE.js → chunk-4UXDBRIF.js} +2 -2
- package/dist/chunk-4XMZYLW5.js +2 -0
- package/dist/{chunk-JSB43EX6.js → chunk-55NUXP2V.js} +2 -2
- package/dist/chunk-5AJQCOZZ.js +21 -0
- package/dist/{chunk-L37EQYAX.js → chunk-5NUPFZFA.js} +2 -2
- package/dist/{chunk-PIFYOWS4.js → chunk-65QIFIF6.js} +2 -2
- package/dist/{chunk-SUE7SHZL.js → chunk-66Q5VLH6.js} +2 -2
- package/dist/{chunk-KFTHI2R6.js → chunk-6CQPIIS7.js} +2 -2
- package/dist/{chunk-GV2CEZCW.js → chunk-6CTSFS7R.js} +2 -2
- package/dist/{chunk-SB53KPWA.js → chunk-6EBUAKJT.js} +2 -2
- package/dist/chunk-6I55VYFG.js +4 -0
- package/dist/chunk-6NUURWPF.js +3 -0
- package/dist/{chunk-TEMM2FEL.js → chunk-6P5QMOM7.js} +2 -2
- package/dist/{chunk-3LQJRS4I.js → chunk-6S5FE4ZF.js} +2 -2
- package/dist/chunk-74LRKLNC.js +22 -0
- package/dist/{chunk-NNG6M6XD.js → chunk-75A23IID.js} +2 -2
- package/dist/chunk-75VNTSO6.js +7 -0
- package/dist/chunk-7HBBVZJ6.js +3 -0
- package/dist/{chunk-AGGR2BKS.js → chunk-7PPBMBH6.js} +2 -2
- package/dist/{chunk-DECN422G.js → chunk-7WG57A5X.js} +2 -2
- package/dist/{chunk-ILGTMRMZ.js → chunk-7XHZX6FX.js} +2 -2
- package/dist/{chunk-OKAF4OQS.js → chunk-A5HJ3CJW.js} +2 -2
- package/dist/{chunk-JNXI6NQ7.js → chunk-AJ5HVC5Z.js} +2 -2
- package/dist/{chunk-SZ4P7MF7.js → chunk-AYRHOFLV.js} +2 -2
- package/dist/chunk-AZDY3EKD.js +93 -0
- package/dist/{chunk-SA7G6GJX.js → chunk-AZZNG5Z2.js} +2 -2
- package/dist/chunk-BEKCTUPY.js +3 -0
- package/dist/{chunk-PTR3EOXC.js → chunk-BKKX2OU5.js} +2 -2
- package/dist/{chunk-5LL4KEHO.js → chunk-BQKRYKDD.js} +2 -2
- package/dist/{chunk-UIAUPFBJ.js → chunk-BVDQU2XJ.js} +2 -2
- package/dist/chunk-C3PPB2T5.js +5 -0
- package/dist/chunk-CABIZQXQ.js +21 -0
- package/dist/{chunk-M2Y6PCFE.js → chunk-CAH322MC.js} +2 -2
- package/dist/{chunk-EIBGSU2R.js → chunk-CBOOHUK4.js} +2 -2
- package/dist/chunk-CFIICAOM.js +2 -0
- package/dist/{chunk-UMEPSVKT.js → chunk-CPWYEPWQ.js} +2 -2
- package/dist/{chunk-LQHYYIOB.js → chunk-CRT7I7RJ.js} +2 -2
- package/dist/{chunk-IZDPGOZR.js → chunk-CZVSQQDU.js} +2 -2
- package/dist/{chunk-TNJGTQWO.js → chunk-D3KE26FS.js} +2 -2
- package/dist/{chunk-CB5AVJMM.js → chunk-DNRHRVKS.js} +2 -2
- package/dist/{chunk-SGMNWYTH.js → chunk-DOQLO74K.js} +2 -2
- package/dist/{chunk-DDRA3QKN.js → chunk-DP3EJ6XL.js} +2 -2
- package/dist/{chunk-OWJWOEDU.js → chunk-DQZF7MP6.js} +2 -2
- package/dist/{chunk-VSGOIZMQ.js → chunk-DTM4EHD2.js} +2 -2
- package/dist/{chunk-YRKP7PM7.js → chunk-DUM7GR6B.js} +2 -2
- package/dist/{chunk-HNXRVGMY.js → chunk-DZ4QOIRY.js} +2 -2
- package/dist/{chunk-CSPDQLLU.js → chunk-E3R6TJ5T.js} +2 -2
- package/dist/chunk-E4DP45YU.js +3 -0
- package/dist/{chunk-PUVNH4PO.js → chunk-E5U6N5WI.js} +2 -2
- package/dist/chunk-E7T22WET.js +21 -0
- package/dist/{chunk-QEOWONKY.js → chunk-ED7ZAZ5V.js} +2 -2
- package/dist/{chunk-RCIGX23V.js → chunk-EDMG5CSO.js} +2 -2
- package/dist/{chunk-IHSLIIL3.js → chunk-EOSUV7H5.js} +2 -2
- package/dist/{chunk-EHPOTEQX.js → chunk-ESWVTSHU.js} +2 -2
- package/dist/{chunk-57OPIQFM.js → chunk-ETZBIG6K.js} +2 -2
- package/dist/chunk-EYSJHKX6.js +3 -0
- package/dist/{chunk-MC46AL7B.js → chunk-F4AGM7ZE.js} +37 -37
- package/dist/{chunk-EOKVZXNF.js → chunk-FPUJRBHL.js} +55 -55
- package/dist/{chunk-CCIYWXX6.js → chunk-G2UU6PQP.js} +2 -2
- package/dist/{chunk-C6WKPKCF.js → chunk-G3KRXNNT.js} +2 -2
- package/dist/{chunk-TEANKHUU.js → chunk-G3ZBP72R.js} +2 -2
- package/dist/{chunk-ELYMY5S2.js → chunk-GC4I33OD.js} +2 -2
- package/dist/{chunk-NDKOVQFG.js → chunk-GLXEWYQY.js} +2 -2
- package/dist/{chunk-CYJS33YX.js → chunk-GRHNPFHT.js} +2 -2
- package/dist/{chunk-QY7QB7I6.js → chunk-GWESWURK.js} +2 -2
- package/dist/{chunk-R4OJGTMP.js → chunk-GXOFPAIR.js} +2 -2
- package/dist/{chunk-OBC7HSSO.js → chunk-H4FGIFEU.js} +2 -2
- package/dist/{chunk-LKUTSP4G.js → chunk-HOGS6JFP.js} +2 -2
- package/dist/{chunk-RIO3JXHM.js → chunk-HSJLK5MC.js} +2 -2
- package/dist/{chunk-BWL3PMPT.js → chunk-HTPEUJ42.js} +2 -2
- package/dist/{chunk-DJKOXMNG.js → chunk-IBPXUGJV.js} +2 -2
- package/dist/{chunk-2XBJRZEM.js → chunk-ITA3N7G6.js} +2 -2
- package/dist/chunk-JG5OWAEB.js +22 -0
- package/dist/{chunk-LSZYMN2A.js → chunk-JGJKRTTB.js} +2 -2
- package/dist/{chunk-TJWVT4DO.js → chunk-JGXLB7PR.js} +2 -2
- package/dist/{chunk-5TZNHP4T.js → chunk-JKUF2UG6.js} +2 -2
- package/dist/{chunk-CIYA2KZN.js → chunk-JOYASZRF.js} +2 -2
- package/dist/{chunk-U7NUXDQO.js → chunk-K3PFL5QQ.js} +2 -2
- package/dist/{chunk-WK2IQJPK.js → chunk-KAXBWTSX.js} +2 -2
- package/dist/{chunk-5ZI2PPI7.js → chunk-KHHAGHAW.js} +2 -2
- package/dist/{chunk-UW6KD57C.js → chunk-KJLUQVBG.js} +2 -2
- package/dist/{chunk-WWCV4E6J.js → chunk-KOVUXHIZ.js} +2 -2
- package/dist/chunk-KPMMOAV5.js +4 -0
- package/dist/{chunk-2Z7K66D7.js → chunk-LKJZNGMA.js} +2 -2
- package/dist/{chunk-3VJ3OCRE.js → chunk-LMPOC372.js} +2 -2
- package/dist/{chunk-F3QSL4W2.js → chunk-LTPNP6D5.js} +2 -2
- package/dist/{chunk-O2KWU34K.js → chunk-M3IBH6C3.js} +9 -9
- package/dist/{chunk-UJIXCI3L.js → chunk-MAGBSB6E.js} +2 -2
- package/dist/{chunk-QMOZZ2VX.js → chunk-MFMHD36E.js} +2 -2
- package/dist/{chunk-LMTSB3TB.js → chunk-MJX2J5QE.js} +2 -2
- package/dist/{chunk-WO6OFKUC.js → chunk-N26LGGSF.js} +2 -2
- package/dist/{chunk-J7AMBVWF.js → chunk-NB2DAVPP.js} +2 -2
- package/dist/{chunk-MDFT325O.js → chunk-NJDXNYLG.js} +2 -2
- package/dist/{chunk-BRQL7AFJ.js → chunk-NMKQOIYZ.js} +2 -2
- package/dist/{chunk-ICUL7XRT.js → chunk-NRNVMB2R.js} +2 -2
- package/dist/{chunk-JAFDMV5I.js → chunk-O5BWFNIH.js} +2 -2
- package/dist/{chunk-3H2H5ODK.js → chunk-O7PCDZ5B.js} +2 -2
- package/dist/{chunk-KPZGTB2O.js → chunk-OAJYNPRU.js} +2 -2
- package/dist/{chunk-KUKWHP4R.js → chunk-OFUC6R46.js} +2 -2
- package/dist/chunk-OSZ7PW5K.js +5 -0
- package/dist/{chunk-B3UYV66Z.js → chunk-OZ2M2X7A.js} +2 -2
- package/dist/{chunk-6O3KXIDL.js → chunk-OZI44VCR.js} +2 -2
- package/dist/{chunk-XN3EKMLI.js → chunk-PCKIKOUA.js} +2 -2
- package/dist/{chunk-I3OK27P7.js → chunk-PFMQRHC6.js} +2 -2
- package/dist/{chunk-K4S2VH42.js → chunk-PVKSZBX5.js} +2 -2
- package/dist/{chunk-NEWHKGVD.js → chunk-QANCT4MO.js} +2 -2
- package/dist/{chunk-ZNH33XIB.js → chunk-QEWN7BLP.js} +2 -2
- package/dist/{chunk-OQUCBKOI.js → chunk-QFJ46F6F.js} +2 -2
- package/dist/{chunk-2E6OUPCF.js → chunk-QPQWR6CW.js} +2 -2
- package/dist/{chunk-YTJHCGYB.js → chunk-QX4HDF2I.js} +2 -2
- package/dist/{chunk-KLX6NSWT.js → chunk-R2F2CTBA.js} +2 -2
- package/dist/{chunk-2OMXFE64.js → chunk-R7PXHYMY.js} +2 -2
- package/dist/{chunk-F74LZWCE.js → chunk-RGBZDOUO.js} +2 -2
- package/dist/{chunk-362QOSFD.js → chunk-RNPG5P4P.js} +2 -2
- package/dist/{chunk-D62CTZX6.js → chunk-RS6UYNEP.js} +2 -2
- package/dist/{chunk-VGWZ4MOY.js → chunk-RVBRPBLQ.js} +2 -2
- package/dist/{chunk-BGYRF5YX.js → chunk-RWAZCEJD.js} +2 -2
- package/dist/{chunk-Z66XYVLZ.js → chunk-RWDIONS7.js} +2 -2
- package/dist/{chunk-CJTKGAGH.js → chunk-S3CJYDXP.js} +2 -2
- package/dist/{chunk-53ELMZRF.js → chunk-S6UTKCBT.js} +2 -2
- package/dist/chunk-SLLFJXTW.js +27 -0
- package/dist/{chunk-TOTWJZIX.js → chunk-T3KTMLQT.js} +2 -2
- package/dist/{chunk-HJTM3C4Y.js → chunk-TB575ZGO.js} +2 -2
- package/dist/{chunk-YHPG3S2U.js → chunk-TG4GMU73.js} +2 -2
- package/dist/{chunk-N2XDMNVI.js → chunk-THKM7OXM.js} +2 -2
- package/dist/{chunk-GVAF222T.js → chunk-TNLOX4TN.js} +2 -2
- package/dist/{chunk-BPKNP3KZ.js → chunk-UHFZDQZJ.js} +2 -2
- package/dist/{chunk-YT4DVWUV.js → chunk-UUMAM5LM.js} +2 -2
- package/dist/{chunk-TLTSESB4.js → chunk-UUT5P3V7.js} +2 -2
- package/dist/{chunk-W7QDASTN.js → chunk-VEPK6M5C.js} +2 -2
- package/dist/{chunk-XJBK3QDV.js → chunk-VPCHKZ3I.js} +2 -2
- package/dist/{chunk-3ON3A2QV.js → chunk-VZY3XOBU.js} +2 -2
- package/dist/{chunk-XQAVQVIL.js → chunk-W6E6ME7G.js} +2 -2
- package/dist/{chunk-KEJ2HLRW.js → chunk-WGYZBS5S.js} +2 -2
- package/dist/{chunk-5MPBSFZH.js → chunk-WUP24Q4U.js} +2 -2
- package/dist/chunk-WXUHXSLN.js +2 -0
- package/dist/{chunk-F5CJO5JN.js → chunk-X4YZD2MP.js} +2 -2
- package/dist/chunk-XARPGCTL.js +2 -0
- package/dist/{chunk-5FWR5HLG.js → chunk-XDQ6QJF5.js} +20 -20
- package/dist/{chunk-JCMFBF4Z.js → chunk-XRH7R5SX.js} +2 -2
- package/dist/{chunk-T2M5HWBQ.js → chunk-XVJ2E7W7.js} +2 -2
- package/dist/{chunk-AXQCHG77.js → chunk-Y7GFAU5N.js} +2 -2
- package/dist/{chunk-T6MQNNAC.js → chunk-YBDLHFZZ.js} +2 -2
- package/dist/{chunk-ZB4C5TTR.js → chunk-YI3CJPOY.js} +2 -2
- package/dist/chunk-YMAGXBLT.js +3 -0
- package/dist/{chunk-MZNMASFM.js → chunk-YRAGNEBZ.js} +2 -2
- package/dist/chunk-YXZAAQHZ.js +3 -0
- package/dist/chunk-Z2L5H2HF.js +3 -0
- package/dist/{chunk-5CR4U5X2.js → chunk-ZHK7TVAJ.js} +2 -2
- package/dist/chunk-ZJNV27DZ.js +4 -0
- package/dist/{chunk-GQLDYCWS.js → chunk-ZQ6GAIUV.js} +2 -2
- package/dist/{chunk-4GWN76B2.js → chunk-ZQE2QYAC.js} +2 -2
- package/dist/chunk-ZUQ2MDFT.js +2 -0
- package/dist/cli-context-4R2LREXQ.js +3 -0
- package/dist/cli-context-6X7JYARX.js +2 -0
- package/dist/cli-failure-RECEHOM2.js +3 -0
- package/dist/cli-program-MXA3WTAO.js +7 -0
- package/dist/cli.js +1 -1
- package/dist/{code-viewer-AMRXV444.js → code-viewer-C6HE4DFC.js} +2 -2
- package/dist/{code-viewer-EXI5SFFR.js → code-viewer-XHSSAMBX.js} +2 -2
- package/dist/{command-descriptors-ROIOTCCW.js → command-descriptors-NWW34Z54.js} +171 -171
- package/dist/{command-descriptors-H6A4UY72.js → command-descriptors-XHK3PK2I.js} +116 -116
- package/dist/{command-panels-SZONPMLJ.js → command-panels-OXMCJ2QZ.js} +2 -2
- package/dist/direct-navigation-236VXYBZ.js +3 -0
- package/dist/direct-navigation-36YSILY6.js +2 -0
- package/dist/index.js +1 -1
- package/dist/invocation-command-descriptors-35JULLNR.js +3 -0
- package/dist/invocation-command-descriptors-FEWSFUO2.js +2 -0
- package/dist/output-continuation-command-MJBVH3A5.js +2 -0
- package/dist/output-continuation-command-TBXIOPHQ.js +3 -0
- package/dist/project-reindex-5TCGOVSK.js +2 -0
- package/dist/project-reindex-BUNTSYKM.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/anchors.js +1 -1
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.js +1 -1
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/reference-neighborhood.js +1 -1
- package/dist/queries/reference-reachability.js +1 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.js +1 -1
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system-map.js +1 -1
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/value-flow.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +1 -1
- package/dist/reindex.js +30 -30
- package/dist/runtime.js +1 -1
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/sentinel-ensure-command-3MZCLPQY.js +2 -0
- package/dist/sentinel-ensure-command-LEWHIRLL.js +3 -0
- package/dist/sentinel-worker.js +1 -1
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +6 -6
- package/docs/COMMAND_REFERENCE.md +2 -2
- package/docs/SECURITY_MODEL.md +3 -0
- package/package.json +1 -1
- package/skills/codebaseiq/SKILL.md +15 -3
- package/dist/chunk-2I2UHZET.js +0 -2
- package/dist/chunk-5T44HG5Y.js +0 -88
- package/dist/chunk-5YBDBY5L.js +0 -2
- package/dist/chunk-6EYESTJM.js +0 -3
- package/dist/chunk-6FXXYYQM.js +0 -22
- package/dist/chunk-7UCDGXRW.js +0 -8
- package/dist/chunk-BIADXGC3.js +0 -22
- package/dist/chunk-CLPCFGRT.js +0 -3
- package/dist/chunk-DUKHVPU5.js +0 -4
- package/dist/chunk-G7GVV2TV.js +0 -27
- package/dist/chunk-KUKKLWJD.js +0 -3
- package/dist/chunk-KWRQVLPX.js +0 -3
- package/dist/chunk-MEUHIDI3.js +0 -7
- package/dist/chunk-OP6BUIV6.js +0 -2
- package/dist/chunk-OQ3DK7FW.js +0 -2
- package/dist/chunk-OT5ISJSR.js +0 -2
- package/dist/chunk-SX72EVMY.js +0 -3
- package/dist/chunk-T75DS2E6.js +0 -21
- package/dist/chunk-UC2FD2PS.js +0 -4
- package/dist/chunk-UQYQBLJX.js +0 -5
- package/dist/chunk-V4NGDIEA.js +0 -21
- package/dist/chunk-XUPFA6GH.js +0 -2
- package/dist/chunk-YPBKBYPS.js +0 -21
- package/dist/chunk-ZMA5HWXY.js +0 -3
- package/dist/cli-context-FJL2JHOE.js +0 -3
- package/dist/cli-context-PQNWHMCQ.js +0 -2
- package/dist/cli-program-SCHOHOQE.js +0 -7
- package/dist/direct-navigation-3JOYP2MO.js +0 -3
- package/dist/direct-navigation-SJMJLBY7.js +0 -2
- package/dist/invocation-command-descriptors-GMZX3UAD.js +0 -2
- package/dist/invocation-command-descriptors-HNMKDEF6.js +0 -3
- package/dist/output-continuation-command-5NWVDQT7.js +0 -2
- package/dist/output-continuation-command-RNEHNYPU.js +0 -3
- package/dist/project-reindex-MIW5CYEG.js +0 -3
- package/dist/project-reindex-VQ23LWDA.js +0 -2
- package/dist/sentinel-ensure-command-H66AZ3VE.js +0 -2
- package/dist/sentinel-ensure-command-R4YAUCJB.js +0 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Me,b as Fe}from"./chunk-PIFYOWS4.js";import"./chunk-ILMHV3KM.js";import"./chunk-XN3EKMLI.js";import{a as ke}from"./chunk-5YBDBY5L.js";import{l as ve}from"./chunk-V4NGDIEA.js";import{D as ee,T as xe,a as Re,n as Ee,o as Z}from"./chunk-JNXI6NQ7.js";import"./chunk-ZZ3MWF33.js";import{a as X,o as ge}from"./chunk-K4S2VH42.js";import"./chunk-YUKYB54I.js";import"./chunk-JAFDMV5I.js";import"./chunk-P5XHIJHI.js";import"./chunk-EQNMD62X.js";import"./chunk-LSZYMN2A.js";import"./chunk-JYRJYXUV.js";import"./chunk-CIYA2KZN.js";import{H as me}from"./chunk-C6WKPKCF.js";import"./chunk-XQAVQVIL.js";import{c as q,d as C,e as U}from"./chunk-DRENNWRG.js";import"./chunk-SV2LEFVM.js";import{N as ye,a as I,b as be,c as he,da as we,ga as Q,ma as Se}from"./chunk-MEUHIDI3.js";import"./chunk-5FWR5HLG.js";import{d as ae,e as ce,n as fe}from"./chunk-T75DS2E6.js";import{e as O,g as pe}from"./chunk-YT4DVWUV.js";import"./chunk-RCIGX23V.js";import{j as ue,r as de}from"./chunk-D7DOB27N.js";import"./chunk-R2NOK63J.js";import"./chunk-6O3KXIDL.js";import{G as Y,T as le,Y as z,a as oe,f as se,h as ie}from"./chunk-UQYQBLJX.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?X(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):X(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=xe(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=ge(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=pe(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
|
|
1
|
+
import{a as Me,b as Fe}from"./chunk-65QIFIF6.js";import"./chunk-ILMHV3KM.js";import"./chunk-PCKIKOUA.js";import{a as ke}from"./chunk-WXUHXSLN.js";import{l as ve}from"./chunk-CABIZQXQ.js";import{D as ee,T as xe,a as Re,n as Ee,o as Z}from"./chunk-AJ5HVC5Z.js";import"./chunk-ZZ3MWF33.js";import{a as X,o as ge}from"./chunk-PVKSZBX5.js";import"./chunk-YUKYB54I.js";import"./chunk-O5BWFNIH.js";import"./chunk-P5XHIJHI.js";import"./chunk-37K55EG3.js";import"./chunk-JGJKRTTB.js";import"./chunk-33AXWMO2.js";import"./chunk-JOYASZRF.js";import{H as me}from"./chunk-G3KRXNNT.js";import"./chunk-W6E6ME7G.js";import{c as q,d as C,e as U}from"./chunk-DRENNWRG.js";import"./chunk-SV2LEFVM.js";import{C as Se,t as we,w as Q}from"./chunk-ZJNV27DZ.js";import{N as ye,a as I,b as be,c as he}from"./chunk-75VNTSO6.js";import"./chunk-XDQ6QJF5.js";import{d as ae,e as ce,n as fe}from"./chunk-E7T22WET.js";import{e as O,g as pe}from"./chunk-UUMAM5LM.js";import"./chunk-EDMG5CSO.js";import{j as ue,r as de}from"./chunk-3F23W57G.js";import"./chunk-R2NOK63J.js";import"./chunk-OZI44VCR.js";import{G as Y,X as le,a as oe,aa as z,f as se,h as ie}from"./chunk-C3PPB2T5.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?X(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):X(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=xe(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=ge(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=pe(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
|
|
2
2
|
`),E=x.length>He,P=E?x.slice(0,He):x;return{status:200,body:{status:"matched",definition:{symbol:i,name:C(i),file:d,startLine:R,endLine:a.endLine+1,signature:p?.entry.signature??null,documentation:Wt(b?.documentation),editorUri:ne(n.projectRoot,d,R)},parent:p?.parent?{symbol:p.parent.symbol,name:p.parent.name}:null,members:(p?.entry.children??[]).map(S=>({symbol:S.symbol,name:S.name,line:S.startLine})),lanes:Qt(y.lanes,n.projectRoot),fileImports:n.queries.codeMapFile(e,d,"imports")?.dependsOn??[],coverage:y.coverage,source:{startLine:R,endLine:R+P.length-1,text:P.join(`
|
|
3
3
|
`),truncated:E,stale:et(a)},...M&&y.statements?{statements:Jt(y.statements)}:{},generation:D(e)}}}function Ze(e,t,n){let r=t.get("file");if(!r)return k(e,"file is required.");let s=t.get("start"),o=t.get("end"),i=s===null?1:Ke(s);if(i===null)return k(e,"start must be a positive integer.");let a=o===null?i+We-1:Ke(o);if(a===null||a<i)return k(e,"end must be an integer at or after start.");let d=B(r);if(d===null||d===""||!n.queries.isIndexedFile(e,d))return L(e,`No indexed file at "${T(r)}".`);let p=Math.min(a,i+We-1),m=n.queries.code(e,`${d}:${i}-${p}`);return m?{status:200,body:{file:d,startLine:m.startLine+1,endLine:m.endLine+1,text:m.source,stale:et(m),generation:D(e)}}:L(e,`Lines ${i}-${p} are outside "${d}".`)}function B(e){if([...e].some(r=>r.charCodeAt(0)<32))return null;let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:/u.test(t))return null;let n=t.split("/").filter(r=>r!==""&&r!==".");return n.includes("..")?null:n.join("/")}function ne(e,t,n){return Ht(_t(e,t),n)}function Ht(e,t){let r=e.replaceAll("\\","/").replace(/[%#? ]/gu,s=>encodeURIComponent(s));return`vscode://file${r.startsWith("/")?"":"/"}${r}:${t}`}function Wt(e){if(!e)return null;let t=e.replace(Gt,"").trim();return t===""?null:t}function et(e){return e.freshness?.semantic.state==="stale"}function Jt(e){return{...e,edges:e.edges.map(Kt)}}function Kt(e){return{...e,from:Je(e.from),to:Je(e.to)}}function Je(e){let{location:t}=e;return t?{...e,location:{...t,line:t.line+1,...t.endLine!==void 0?{endLine:t.endLine+1}:{}}}:e}function Yt(e){let t=[{name:"root",path:""}],n="";for(let r of e.split("/"))n=n===""?r:`${n}/${r}`,t.push({name:r,path:n});return t}function tt(e,t,n){let r=n.queries.fileSymbolFacts(e,t),s=Xt(t),o=n.queries.outline(e,t).flatMap(a=>U(a.symbol)==="namespace"&&s.has(C(a.symbol))?a.children:[a]),i=(a,d)=>({symbol:a.symbol,name:C(a.symbol),kind:r.get(a.symbol)?.kind??zt(a.symbol,d),startLine:a.startLine+1,endLine:a.endLine+1,signature:a.signature,children:a.children.map(p=>i(p,a.symbol))});return o.map(a=>i(a))}function zt(e,t){let n=U(e);return n==="method"?t!==void 0&&U(t)==="type"?"method":"function":n==="term"?"variable":n??"unknown"}function Xt(e){let t=Ge.basename(e);return new Set([t,t.slice(0,Math.max(0,t.length-Ge.extname(t).length))])}function nt(e,t,n=null){for(let r of e){if(r.symbol===t)return{entry:r,parent:n};let s=nt(r.children,t,r);if(s)return s}return null}function Qt(e,t){let n={};for(let r of $t)n[r]=(e[r]??[]).map(s=>{let{line:o,...i}=s,a={...i};return o!==void 0&&(a.line=o+1),s.file!==void 0&&(a.editorUri=ne(t,s.file,(o??0)+1)),a});return n}function rt(e){return e===null||e===""?"references":e==="references"||e==="imports"?e:null}function Ke(e){if(!/^\d{1,9}$/u.test(e))return null;let t=Number(e);return t>=1?t:null}function D(e){return e.generation.identity}function k(e,t){return{status:400,body:{error:t,generation:D(e)}}}function L(e,t,n={}){return{status:404,body:{error:t,...n,generation:D(e)}}}function T(e){return e.length>200?`${e.slice(0,200)}...`:e}import{createHash as ct,randomBytes as Zt,timingSafeEqual as en}from"crypto";import{existsSync as A}from"fs";import{createServer as tn}from"http";import{createRequire as nn}from"module";import{dirname as rn,join as H}from"path";import{fileURLToPath as on}from"url";var _="127.0.0.1",sn=80,an="__CODEBASEIQ_TOKEN__",cn="x-codebaseiq-token",ot=64*1024,un=18e4,st=50,it=["reuse","rework","compose"],ln="cytoscape.esm.min.mjs",dn=["index.html","styles.css","app.js","api.js","map.js","file-panel.js","focus.js","builder.js"],fn={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8"},pn=["default-src 'self'","script-src 'self'","style-src 'self' 'unsafe-inline'","img-src 'self' data:","connect-src 'self'","frame-ancestors 'none'"].join("; ");function mn(){for(let e of["../ui/view/","../../../ui/view/"]){let t=on(new URL(e,import.meta.url));if(A(H(t,"index.html")))return t}}function gn(){try{let e=nn(import.meta.url).resolve("cytoscape"),t=H(rn(e),ln);return A(t)?t:void 0}catch{return}}function at(e,t){return{body:se(e,{maxBytes:oe,inputKind:"viewer asset"}),contentType:t}}function bn(e,t){let n=e.uiDirectory??mn();if(!n||!A(H(n,"index.html")))throw new Error("The viewer UI files were not found; reinstall codebaseiq or rebuild the package.");let r=new Map;for(let i of dn){let a=H(n,i);if(!A(a))continue;let d=at(a,fn[i.slice(i.lastIndexOf("."))]??"application/octet-stream");r.set(i,i==="index.html"?{...d,body:Buffer.from(d.body.toString("utf8").replaceAll(an,t),"utf8")}:d)}let s=e.cytoscapePath??gn(),o=s&&A(s)?at(s,"text/javascript"):void 0;return{assets:r,...o?{vendor:o}:{}}}async function ut(e){let t=e.token??Zt(24).toString("base64url"),{assets:n,vendor:r}=bn(e,t),s=e.builderTimeoutMs??un,o=ct("sha256").update(t).digest(),i=0,a=!1,d=new Set,p=()=>lt(i),m=()=>yn(i),b=(c,u,g)=>{let h=JSON.stringify({generation:e.database.generation(),...g});c.writeHead(u,{...G(),"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(h)}),c.end(h)},M=(c,u)=>{c.writeHead(200,{...G(),"Content-Type":u.contentType,"Content-Length":u.body.byteLength,...u.contentType.startsWith("text/html")?{"Content-Security-Policy":pn}:{}}),c.end(u.body)},y=(c,u,g,h={})=>{c.writeHead(u,{...G(),"Content-Type":"text/plain; charset=utf-8","Content-Length":Buffer.byteLength(g),...h}),c.end(g)},R=(c,u,g)=>{let h=hn.get(u);if(!h){b(c,404,{error:"Not found."});return}let v=h(e.database.acquire(),g,e.routes);b(c,v.status,v.body)},x=(c,u)=>{if(u==="/"){let v=n.get("index.html");v?M(c,v):y(c,404,"Not found.");return}if(u==="/favicon.ico"){c.writeHead(204,G()),c.end();return}if(u==="/vendor/cytoscape.mjs"&&r){M(c,r);return}let g=u.startsWith("/assets/")?u.slice(8):void 0,h=g===void 0?void 0:n.get(g);h?M(c,h):y(c,404,"Not found.")},E=async(c,u)=>{let g=c.headers.origin;if(g!==void 0&&!m().has(g)){b(u,403,{error:"Origin is not allowed."});return}if(!wn(c.headers["content-type"])){b(u,415,{error:"Content-Type must be application/json."});return}if(!Sn(o,c.headers[cn])){b(u,403,{error:"The viewer token is missing or wrong; reload the page."});return}let h=e.builder;if(!h){b(u,501,{error:"The symbol builder is not available in this viewer."});return}if(a){b(u,409,{error:"A builder query is already running."});return}a=!0;try{let v=await vn(c,ot);if(v===void 0){b(u,400,{error:`The request body must be at most ${ot/1024} KiB.`});return}let V=Rn(v);if(!V.ok){b(u,400,{error:V.error});return}await P(u,h,V.request,V.diagnostics)}finally{a=!1}},P=async(c,u,g,h)=>{let v=new AbortController;d.add(v);let V=()=>{c.writableEnded||v.abort(new Error("The client disconnected."))};c.on("close",V);let W;try{let $=await new Promise(J=>{W=setTimeout(()=>{v.abort(new Error("The builder query timed out.")),J({kind:"timeout"})},s),u(g,v.signal).then(K=>J({kind:"done",response:K}),K=>J({kind:"failed",error:K}))});if(c.destroyed)return;$.kind==="timeout"?b(c,504,{error:`The builder query took longer than ${Math.round(s/1e3)} s.`}):$.kind==="failed"?b(c,502,{error:re($.error)}):b(c,200,{...$.response,...h.length>0?{probeDiagnostics:h}:{}})}finally{W&&clearTimeout(W),c.off("close",V),d.delete(v)}},S=async(c,u)=>{if(!p().has((c.headers.host??"").toLowerCase())){y(u,403,"Forbidden host.");return}let g;try{g=new URL(c.url??"/",`http://${_}`)}catch{y(u,400,"Bad request.");return}let h=c.method??"GET";if(g.pathname==="/api/builder"){h==="POST"?await E(c,u):b(u,405,{error:"Use POST."});return}if(h!=="GET"&&h!=="HEAD"){y(u,405,"Method not allowed.",{Allow:"GET, HEAD"});return}g.pathname.startsWith("/api/")?R(u,g.pathname,g.searchParams):x(u,g.pathname)},l=tn((c,u)=>{S(c,u).catch(g=>{if(u.headersSent){u.destroy();return}b(u,500,{error:re(g)})})});await new Promise((c,u)=>{l.once("error",u),l.listen({host:_,port:e.port??0},()=>{l.off("error",u),c()})}),l.on("error",c=>{process.stderr.write(`codebaseiq view: server error: ${re(c)}
|
|
4
4
|
`)});let f=l.address();i=typeof f=="object"&&f?f.port:0;let w=`http://${_}:${i}`;return{port:i,origin:w,url:`${w}/`,token:t,close(){for(let c of d)c.abort(new Error("The viewer is shutting down."));return new Promise(c=>{l.close(()=>c()),l.closeAllConnections()})}}}var hn=new Map([["/api/meta",(e,t,n)=>Ye(e,n)],["/api/scope",ze],["/api/file",Xe],["/api/symbol",Qe],["/api/source",Ze]]);function lt(e){let t=new Set([`${_}:${e}`,`localhost:${e}`]);return e===sn&&(t.add(_),t.add("localhost")),t}function yn(e){return new Set([...lt(e)].map(t=>`http://${t}`))}function G(){return{"Cache-Control":"no-store","X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer"}}function wn(e){return e!==void 0&&e.split(";")[0].trim().toLowerCase()==="application/json"}function Sn(e,t){return typeof t!="string"||t===""?!1:en(ct("sha256").update(t).digest(),e)}function vn(e,t){return new Promise((n,r)=>{let s=[],o=0,i=!1;e.on("data",a=>{o+=a.byteLength,o>t?(i=!0,s.length=0):i||s.push(a)}),e.on("end",()=>n(i?void 0:Buffer.concat(s).toString("utf8"))),e.on("error",r)})}function Rn(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"The request body must be valid JSON."}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,error:"The request body must be a JSON object."};let n=t,r={},s=[];if(n.description!==void 0){if(typeof n.description!="string")return{ok:!1,error:"description must be a string."};n.description.trim()!==""&&(r.description=n.description)}if(n.probes!==void 0){let o=he(n.probes);s=o.diagnostics,(be(o.probes)||o.probes.kinds.length>0)&&(r.probes=o.probes)}if(n.mode!==void 0){if(typeof n.mode!="string"||!I.includes(n.mode))return{ok:!1,error:`mode must be one of ${I.join(", ")}.`};r.mode=n.mode}if(n.bucket!==void 0){if(typeof n.bucket!="string"||!it.includes(n.bucket))return{ok:!1,error:`bucket must be one of ${it.join(", ")}.`};r.bucket=n.bucket}if(n.limit!==void 0){let o=n.limit;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>st)return{ok:!1,error:`limit must be an integer from 1 to ${st}.`};r.limit=o}return r.description===void 0&&r.probes===void 0?{ok:!1,error:"Give a description or at least one probe."}:{ok:!0,request:r,diagnostics:s}}function re(e){return e instanceof Error?e.message:String(e)}var kn="view-server.json",ft="127.0.0.1",Ln=1e3,Dn=5e3,Pn=2e3,gt={isProcessAlive:ue,canConnect(e,t){return new Promise(n=>{let r=xn({host:ft,port:e}),s=o=>{r.destroy(),n(o)};r.setTimeout(t,()=>s(!1)),r.once("connect",()=>s(!0)),r.once("error",()=>s(!1))})},async fetchProjectRoot(e,t){try{let n=await fetch(`http://${ft}:${e}/api/meta`,{signal:AbortSignal.timeout(t)});if(!n.ok)return{kind:"answered",projectRoot:void 0};let r=await n.json();return{kind:"answered",projectRoot:typeof r.projectRoot=="string"?r.projectRoot:void 0}}catch{return{kind:"unanswered"}}}};function pt(e,t){let n=new URL(e);return t.focus!==void 0?n.searchParams.set("focus",t.focus):t.file!==void 0?n.searchParams.set("file",t.file):t.scope!==void 0&&n.searchParams.set("scope",t.scope),n.toString()}async function bt(e,t,n=gt){let r=ht(e);if(!r||!n.isProcessAlive(r.pid)||!await n.canConnect(r.port,Ln))return;let s=await n.fetchProjectRoot(r.port,Dn);if(s.kind==="unanswered")return r;let o=s.projectRoot;if(!(o===void 0||z(dt(o))!==z(dt(t))))return r}async function Vn(e,t,n=gt){let r=await bt(e,t.projectRoot,n);if(r&&r.pid!==t.pid)return process.stderr.write(`warning: a viewer (pid ${r.pid}, ${r.url}) is already recorded for this project, so this one is not.
|
|
@@ -8,4 +8,4 @@ import{a as Me,b as Fe}from"./chunk-PIFYOWS4.js";import"./chunk-ILMHV3KM.js";imp
|
|
|
8
8
|
`)}function Cn(e,t){return e?.code==="EADDRINUSE"&&t?new Error(`Port ${t} is already in use; choose another with --port.`):e instanceof Error?e:new Error(String(e))}function Nn(e,t){try{let n=ye(e.projectRoot,e.config),r=Fe({settings:n,storeRoot:Me(e.paths.cacheDir),languages:Bn(t.acquire()),openDb:()=>t.acquire(),env:Tn(process.env)});return{run:(s,o)=>r.query(s,{signal:o}),defaultMode:n.mode,close:()=>r.close()}}catch(n){return process.stderr.write(`codebaseiq view: the symbol builder is unavailable: ${yt(n)}
|
|
9
9
|
`),{defaultMode:"agent",close:()=>{}}}}function Tn(e){return Object.fromEntries(Object.entries(e).filter(([t])=>t!=="CLAUDECODE"&&!t.startsWith("CODEX_")))}function Bn(e){let t=e.generation.metadataRaw;return(t?ce(ae(t))?.indexedLanguages:void 0)??[]}function In(e,t,n){let r;return()=>{let s=Date.now();if(r&&s-r.at<Pn)return r.value;let o;try{let{classification:i}=ve({projectRoot:e,cacheDir:t.paths.cacheDir,cliVersion:Y,...n?{gitContext:n}:{}});o=i.kind==="live"?i.state.watcher.state:i.kind}catch{o="unknown"}return r={at:s,value:o},o}}function jn(){let e=new WeakMap;return{normalizeMapScope:j,codeMapScope:De,nearestMapScope:Pe,codeMapFile:Ve,isIndexedFile(t,n){let r=e.get(t);return r||(r=new Set(O(t,{includeIgnored:!1})),e.set(t,r)),r.has(n)},outline:Ee,fileSymbolFacts(t,n){let r=new Map;for(let s of me(t,n))r.set(s.symbol,{kind:s.kind===null?null:An(s.kind),documentation:s.documentation});return r},resolveFocus:_e,symbolFocusLanes:$e,code:Z,fileIsStale(t,n){return Z(t,`${n}:1-1`)?.freshness?.semantic.state==="stale"}}}function An(e){let t=Re(e).toLowerCase();return t==="unknown"||t==="unspecifiedkind"?null:t}function _n(e){let t=()=>{let s=ht(e.stateFile);s?.pid===e.state.pid&&s.startedAt===e.state.startedAt&&En(e.stateFile,{force:!0})},n=!1,r=()=>{n||(n=!0,e.server.close().finally(()=>{e.builder.close(),e.database.close(),t(),console.log(`
|
|
10
10
|
Stopped.`),process.exit(0)}))};process.on("SIGINT",r),process.on("SIGTERM",r),process.on("exit",t)}function yt(e){return e instanceof Error?e.message:String(e)}export{kn as VIEW_STATE_FILE,jn as createViewerQueries,bt as findRunningViewer,ht as readViewerState,Vn as recordRunningViewer,jr as runCodeViewer,Tn as viewerBuilderEnvironment,pt as viewerDeepLink};
|
|
11
|
-
//# sourceMappingURL=code-viewer-
|
|
11
|
+
//# sourceMappingURL=code-viewer-C6HE4DFC.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as ke}from"./chunk-KUKKLWJD.js";import{a as Me,b as Fe}from"./chunk-L37EQYAX.js";import{r as xe}from"./chunk-BIADXGC3.js";import{H as ee,X as Ee,f as ve,v as Re,w as Z}from"./chunk-OWJWOEDU.js";import"./chunk-B2OB55RR.js";import"./chunk-XZEE23VG.js";import{K as ge,_ as be,a as I,b as pe,ba as X,c as me,ha as he}from"./chunk-7UCDGXRW.js";import"./chunk-EN4AHLL3.js";import{Ha as Se,ca as Q,ga as q,ha as C,ia as U,k as O,m as ye,ta as we}from"./chunk-EOKVZXNF.js";import"./chunk-D62CTZX6.js";import{E as ue,F as le,X as de,Z as fe,l as z}from"./chunk-5T44HG5Y.js";import{d as oe,i as Y,j as se,k as ie,p as ae,r as ce}from"./chunk-DUKHVPU5.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?Q(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):Q(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=Ee(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=Se(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=ye(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
|
|
2
|
+
import{a as ke}from"./chunk-7HBBVZJ6.js";import{a as Me,b as Fe}from"./chunk-5NUPFZFA.js";import{q as xe}from"./chunk-JG5OWAEB.js";import{H as ee,X as Ee,f as ve,v as Re,w as Z}from"./chunk-DQZF7MP6.js";import"./chunk-B2OB55RR.js";import"./chunk-XZEE23VG.js";import{A as he,r as be,u as X}from"./chunk-OSZ7PW5K.js";import"./chunk-EN4AHLL3.js";import{Ha as Se,ca as Q,ga as q,ha as C,ia as U,k as O,m as ye,ta as we}from"./chunk-FPUJRBHL.js";import"./chunk-RS6UYNEP.js";import{$ as I,E as ue,F as le,Ja as ge,W as de,Y as fe,aa as pe,ba as me,l as z}from"./chunk-AZDY3EKD.js";import{e as oe,j as Y,k as se,l as ie,q as ae,s as ce}from"./chunk-KPMMOAV5.js";import"./chunk-Z2L5H2HF.js";import{rmSync as En}from"fs";import{createConnection as xn}from"net";import{basename as Mn,join as Fn,resolve as dt}from"path";import{spawn as wt}from"child_process";var St=/^https?:\/\//iu,vt=2e3;function Le(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;if(!St.test(e))return Promise.resolve({launched:!1});if(Et(r.CI))return Promise.resolve({launched:!1});if(n!=="win32"&&n!=="darwin"&&!r.DISPLAY&&!r.WAYLAND_DISPLAY)return Promise.resolve({launched:!1});let{command:s,args:o}=Rt(n,e);return new Promise(i=>{let a;try{a=(t.spawn??wt)(s,o,{detached:!0,stdio:"ignore",windowsHide:!0})}catch{i({launched:!1});return}let d=m=>{clearTimeout(p),i({launched:m})},p=setTimeout(()=>d(!0),vt);a.once("spawn",()=>d(!0)),a.on("error",()=>d(!1)),a.unref()})}function Rt(e,t){return e==="win32"?{command:"rundll32.exe",args:["url.dll,FileProtocolHandler",t]}:e==="darwin"?{command:"open",args:[t]}:{command:"xdg-open",args:[t]}}function Et(e){return e!==void 0&&e!==""&&e!=="0"&&e.toLowerCase()!=="false"}var xt=5;function j(e){let t=e.trim().replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);return t=t.replace(/^\/+/,"").replace(/\/+$/,""),t==="."?"":t}function Mt(e,t,n,r){let s=j(n),o=s?`${s}/`:"",i=[...new Set(e)].filter(l=>l.startsWith(o)).sort(F);if(i.length===0)return null;let a=new Set(i),d=new Map;for(let l of i){let f=l.slice(o.length),w=f.indexOf("/"),c=w<0?l:`${o}${f.slice(0,w)}`,u=d.get(c)??{kind:w<0?"file":"dir",files:[]};u.files.push(l),d.set(c,u)}let p=new Map,m=[];for(let[l,f]of d){let w=f.kind==="dir"?Ft(f.files):l;for(let c of f.files)p.set(c,w);m.push({id:w,kind:f.kind,name:f.kind==="dir"?w.slice(o.length):l.slice(o.length),path:w,files:f.files.length,internalEdges:0,cycle:null})}m.sort((l,f)=>(l.kind===f.kind?0:l.kind==="dir"?-1:1)||F(l.name,f.name));let b=new Map(m.map(l=>[l.id,l])),M=s?s.split("/"):[],y=new Map,R=new Map,x=0,E=(l,f,w)=>{x+=1;let c=`${l}\0${f}`,u=y.get(c)??{from:l,to:f,count:0,cycle:!1,samples:[]};u.count+=1,u.samples.length<xt&&u.samples.push(w),y.set(c,u)},P=l=>{let f=kt(M,l);return R.has(f)||R.set(f,{id:f,kind:"external",path:f}),f};for(let l of[...t.keys()].sort(F)){let f=a.has(l);for(let w of[...t.get(l)].sort(F)){let c=a.has(w);if(!f&&!c||!f&&l.startsWith(o)||!c&&w.startsWith(o))continue;let u={from:l,to:w};if(f&&c){let g=p.get(l),h=p.get(w);g===h?(x+=1,b.get(g).internalEdges+=1):E(g,h,u)}else f?E(p.get(l),P(w),u):E(P(l),p.get(w),u)}}let S=Lt(m,y);for(let l of m)l.cycle=S.get(l.id)??null;for(let l of y.values()){let f=S.get(l.from);l.cycle=f!==void 0&&f===S.get(l.to)}return{scope:s,basis:r,breadcrumbs:Dt(M),nodes:m,external:[...R.values()].sort((l,f)=>F(l.path,f.path)),edges:[...y.values()].sort((l,f)=>F(l.from,f.from)||F(l.to,f.to)),totals:{files:i.length,edges:x}}}function De(e,t){return Mt(O(e,{includeIgnored:!1}),Oe(e,t.basis),t.scope,t.basis)}function Pe(e,t){let n=O(e,{includeIgnored:!1}),r=j(t);for(;r;){let s=`${r}/`;if(n.some(i=>i.startsWith(s)))return r;let o=r.lastIndexOf("/");r=o<0?"":r.slice(0,o)}return""}function Ve(e,t,n){let r=j(t);if(!O(e,{includeIgnored:!1}).includes(r))return null;let s=Oe(e,n),o=[];for(let[i,a]of s)a.has(r)&&o.push(i);return{file:r,dependsOn:[...s.get(r)??[]].sort(F),dependedOnBy:o.sort(F)}}function Oe(e,t){return t==="imports"?Q(e,void 0,{scipEdges:"imports-only",sourceEdges:"imports-and-reexports"}):Q(e)}function Ft(e){let t=e.map(r=>r.split("/").slice(0,-1)),n=[...t[0]];for(let r of t){let s=0;for(;s<n.length&&s<r.length&&n[s]===r[s];)s+=1;n.length=s}return n.join("/")}function kt(e,t){let n=t.split("/"),r=0;for(;r<e.length&&r<n.length&&e[r]===n[r];)r+=1;return n.slice(0,r+1).join("/")}function Lt(e,t){let n=new Map(e.map(o=>[o.id,new Set]));for(let o of t.values())n.has(o.from)&&n.has(o.to)&&n.get(o.from).add(o.to);let r=Ee(n).components.filter(o=>o.length>1).map(o=>[...o].sort(F)).sort((o,i)=>F(o[0],i[0])),s=new Map;return r.forEach((o,i)=>{for(let a of o)s.set(a,i+1)}),s}function Dt(e){return[{name:"root",path:""},...e.map((t,n)=>({name:t,path:e.slice(0,n+1).join("/")}))]}function F(e,t){return e<t?-1:e>t?1:0}var Ce=["callers","callees","contracts","data","state","runtime"],Pt={families:["execution","identity","contract","dataflow","state","runtime"],subtypes:["call","result-callback","references","uses-contract-symbol","argument-to-parameter","constant-to-parameter","property-to-parameter","return-to-parameter","return-to-call-result","reads-resource","writes-resource","deletes-resource","enqueues-resource","consumes-resource","runtime-handoff","discriminator-dispatch"],direction:"both",maxDepth:1,maxEdges:2e3},Ne={exact:0,derived:1,mixed:2,candidate:3,unknown:4},N="root",Vt=new Set(["source-construct","runtime-boundary-participant","call-result","argument-expression","static-value"]);function _e(e,t){let n=t.trim();if(!n)return{status:"missing"};let r=Se(e,n),s=r.match;if(!s)return{status:"missing"};let o=new Map,i=(a,d,p)=>{o.has(a)||o.set(a,{symbol:a,name:q(a),file:d,line:p})};i(s.symbol,s.relativePath,s.startLine);for(let a of r.candidates)i(a.symbol,a.relativePath,a.startLine);return o.size===1&&At(n,s)?{status:"matched",symbol:s.symbol}:{status:"ambiguous",candidates:[...o.values()],total:r.total}}function $e(e,t,n={}){let r=ee(e,{symbols:[t]},Pt),s=r.targets[0]?.nodeIds[0],o=s?Bt(r,s):null,i=s&&o?qe(r,s,It(o)):Tt(r);if(!n.statements)return i;let a=ee(e,{symbols:[t]},{view:"complete",maxDepth:1,maxEdges:400});return{...i,statements:{inventory:a.inventory??[],edges:a.edges.map(jt)}}}function qe(e,t,n){let r=new Map(Ce.map(i=>[i,new Map])),s=[];for(let i of e.edges){let a=Te(i.from,t,n),d=Te(i.to,t,n);if(!a||!d)continue;let p,m;if(a===N&&d!==N)p=!1,m=d;else if(d===N&&a!==N)p=!0,m=a;else continue;if(i.family==="identity"){p&&i.subtype==="references"&&s.push({target:m,edge:i});continue}let b=Ot(i,p);b&&je(r.get(b),m,i,!1)}let o=r.get("callers");for(let{target:i,edge:a}of s){let d=o.get(i.key);(!d||d.reference)&&je(o,i,a,!0)}return{lanes:Object.fromEntries(Ce.map(i=>[i,Nt(r.get(i))])),coverage:{status:e.coverage.status,omittedEdges:e.coverage.omittedEdges}}}function Ot(e,t){let{family:n,subtype:r}=e;return n==="execution"&&(r==="call"||r==="result-callback")?t?"callers":"callees":n==="contract"&&r==="uses-contract-symbol"?t?null:"contracts":n==="dataflow"&&(r.endsWith("-to-parameter")||r==="return-to-call-result")?"data":n==="state"?"state":n==="runtime"?"runtime":null}function Te(e,t,n){if(e.id===t)return N;if(e.kind==="symbol"&&e.symbol)return Be(e.symbol,e.label,e);if(e.kind==="structural-region")return{key:`region:${e.id}`,kind:"region",label:e.label};if(e.kind==="program-resource"||e.kind==="runtime-state-resource")return{key:`resource:${e.id}`,kind:"resource",label:e.label,...te(e),...e.kind==="program-resource"&&Ie(e,n)?{local:!0}:{}};if(Ie(e,n))return N;if(e.location&&Vt.has(e.kind))return{key:`location:${e.id}`,kind:"location",label:e.label,...te(e)};let r=Ct(e);return r?Be(r,q(r),e):null}function Be(e,t,n){return{key:`symbol:${e}`,kind:"symbol",label:t,symbol:e,...te(n)}}function te(e){return e.location?{file:e.location.file,line:e.location.line}:{}}function Ie(e,t){return e.location!==null&&e.location.file===t.file&&e.location.line>=t.startLine&&e.location.line<=t.endLine}function Ct(e){if(e.kind!=="parameter")return null;let[t,n]=e.id.split(":");return t==="parameter"&&n?decodeURIComponent(n):null}function je(e,t,n,r){let s=e.get(t.key);if(!s){e.set(t.key,{kind:t.kind,label:t.label,...t.symbol?{symbol:t.symbol}:{},...t.file!==void 0?{file:t.file,line:t.line}:{},subtypes:[n.subtype],count:1,strength:n.evidenceStrength,...t.local?{local:!0}:{},...r?{reference:!0}:{}});return}s.count+=1,s.subtypes.includes(n.subtype)||s.subtypes.push(n.subtype),Ne[n.evidenceStrength]<Ne[s.strength]&&(s.strength=n.evidenceStrength)}function Nt(e){return[...e.values()].map(t=>({...t,subtypes:[...t.subtypes].sort()})).sort((t,n)=>Ae(t.label,n.label)||Ae(t.file??"",n.file??"")||(t.line??0)-(n.line??0))}function Tt(e){return qe({...e,edges:[]},"",{file:"",startLine:0,endLine:-1})}function Bt(e,t){for(let n of e.edges){if(n.from.id===t)return n.from;if(n.to.id===t)return n.to}return null}function It(e){return e.location?{file:e.location.file,startLine:e.location.line,endLine:e.location.endLine??e.location.line}:{file:"",startLine:0,endLine:-1}}function jt(e){return{id:e.id,family:e.family,subtype:e.subtype,from:e.from,to:e.to,strength:e.evidenceStrength,methods:e.evidenceMethods}}function At(e,t){if(e===t.symbol)return!0;let n=e.replace(/\\/g,"/").replace(/\(\)$/u,""),r=C(t.symbol);if(n===q(t.symbol).replace(/\(\)$/u,"")||n===r)return!0;let s=e.match(/^(.+):(\d+)(?:-(\d+))?$/);if(s){let i=ye(s[1]);return t.relativePath===i||t.relativePath.endsWith(`/${i}`)}let o=n.lastIndexOf("/");return o>0&&n.slice(o+1)===r&&t.relativePath.toLowerCase().includes(n.slice(0,o).toLowerCase())}function Ae(e,t){return e<t?-1:e>t?1:0}function Ue(e){let t=e.published??fe,n=e.open(),r=null,s=o=>{try{o.close()}catch{}};return{acquire(){if(!n)throw new Error("The viewer database is closed.");let o=t(e.dbPath);if(o!==null&&o!==n.generation.identity&&o!==r)try{let i=e.open();s(n),n=i,r=o}catch{}return n},generation(){return n?.generation.identity??null},close(){let o=n;n=void 0,o&&s(o)}}}import{posix as Ge,resolve as _t}from"path";var He=400,We=2e3,$t=["callers","callees","contracts","data","state","runtime"],qt=4096,Ut=/:\d+(?:-\d+)?$/u,Gt=/^\s*```[^\n]*\n[\s\S]*?```[^\S\n]*(?:\n|$)/u;function Ye(e,t){return{status:200,body:{projectRoot:t.projectRoot,projectName:t.meta.projectName,cliVersion:t.meta.cliVersion,generation:D(e),watcher:{state:t.meta.watcherState()},builder:{available:t.meta.builder.available,modes:[...I],defaultMode:t.meta.builder.defaultMode}}}}function ze(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path")??"",o=B(s);if(o===null)return L(e,`Path is outside the project: ${T(s)}`,{nearest:""});let i=n.queries.normalizeMapScope(o),a=n.queries.codeMapScope(e,{scope:i,basis:r});return a?{status:200,body:{...a,generation:D(e)}}:L(e,`No indexed files under "${i}".`,{nearest:n.queries.nearestMapScope(e,i)})}function Xe(e,t,n){let r=rt(t.get("basis"));if(r===null)return k(e,'basis must be "references" or "imports".');let s=t.get("path");if(!s)return k(e,"path is required.");let o=B(s);if(o===null||o===""||!n.queries.isIndexedFile(e,o))return L(e,`No indexed file at "${T(s)}".`);let i=n.queries.codeMapFile(e,o,r);return{status:200,body:{file:o,breadcrumbs:Yt(o),editorUri:ne(n.projectRoot,o,1),outline:tt(e,o,n),dependsOn:i?.dependsOn??[],dependedOnBy:i?.dependedOnBy??[],stale:n.queries.fileIsStale(e,o),generation:D(e)}}}function Qe(e,t,n){let r=t.get("symbol"),s=t.get("focus"),o=r||s;if(!o)return k(e,"symbol or focus is required.");if(o.length>qt)return k(e,"The selector is too long.");let i=r||"";if(!r){let S=n.queries.resolveFocus(e,o);if(S.status==="ambiguous")return{status:200,body:{status:"ambiguous",candidates:S.candidates.map(l=>({symbol:l.symbol,name:l.name,file:l.file,line:l.line+1})),total:S.total,generation:D(e)}};if(S.status==="missing")return L(e,`No symbol matches "${T(o)}".`);i=S.symbol}let a=Ut.test(i)?null:n.queries.code(e,i);if(!a||a.symbol!==i||a.symbol===a.relativePath||!n.queries.isIndexedFile(e,a.relativePath))return L(e,`No indexed definition for "${T(i)}".`);let d=a.relativePath,p=nt(tt(e,d,n),i),m=n.queries.fileSymbolFacts(e,d);if(!p&&!m.has(i))return L(e,`No indexed definition for "${T(i)}".`);let b=m.get(i),M=t.get("statements")==="1",y=n.queries.symbolFocusLanes(e,i,M?{statements:!0}:void 0),R=a.startLine+1,x=a.source.split(`
|
|
3
3
|
`),E=x.length>He,P=E?x.slice(0,He):x;return{status:200,body:{status:"matched",definition:{symbol:i,name:C(i),file:d,startLine:R,endLine:a.endLine+1,signature:p?.entry.signature??null,documentation:Wt(b?.documentation),editorUri:ne(n.projectRoot,d,R)},parent:p?.parent?{symbol:p.parent.symbol,name:p.parent.name}:null,members:(p?.entry.children??[]).map(S=>({symbol:S.symbol,name:S.name,line:S.startLine})),lanes:Qt(y.lanes,n.projectRoot),fileImports:n.queries.codeMapFile(e,d,"imports")?.dependsOn??[],coverage:y.coverage,source:{startLine:R,endLine:R+P.length-1,text:P.join(`
|
|
4
4
|
`),truncated:E,stale:et(a)},...M&&y.statements?{statements:Jt(y.statements)}:{},generation:D(e)}}}function Ze(e,t,n){let r=t.get("file");if(!r)return k(e,"file is required.");let s=t.get("start"),o=t.get("end"),i=s===null?1:Ke(s);if(i===null)return k(e,"start must be a positive integer.");let a=o===null?i+We-1:Ke(o);if(a===null||a<i)return k(e,"end must be an integer at or after start.");let d=B(r);if(d===null||d===""||!n.queries.isIndexedFile(e,d))return L(e,`No indexed file at "${T(r)}".`);let p=Math.min(a,i+We-1),m=n.queries.code(e,`${d}:${i}-${p}`);return m?{status:200,body:{file:d,startLine:m.startLine+1,endLine:m.endLine+1,text:m.source,stale:et(m),generation:D(e)}}:L(e,`Lines ${i}-${p} are outside "${d}".`)}function B(e){if([...e].some(r=>r.charCodeAt(0)<32))return null;let t=e.replaceAll("\\","/");if(t.startsWith("/")||/^[A-Za-z]:/u.test(t))return null;let n=t.split("/").filter(r=>r!==""&&r!==".");return n.includes("..")?null:n.join("/")}function ne(e,t,n){return Ht(_t(e,t),n)}function Ht(e,t){let r=e.replaceAll("\\","/").replace(/[%#? ]/gu,s=>encodeURIComponent(s));return`vscode://file${r.startsWith("/")?"":"/"}${r}:${t}`}function Wt(e){if(!e)return null;let t=e.replace(Gt,"").trim();return t===""?null:t}function et(e){return e.freshness?.semantic.state==="stale"}function Jt(e){return{...e,edges:e.edges.map(Kt)}}function Kt(e){return{...e,from:Je(e.from),to:Je(e.to)}}function Je(e){let{location:t}=e;return t?{...e,location:{...t,line:t.line+1,...t.endLine!==void 0?{endLine:t.endLine+1}:{}}}:e}function Yt(e){let t=[{name:"root",path:""}],n="";for(let r of e.split("/"))n=n===""?r:`${n}/${r}`,t.push({name:r,path:n});return t}function tt(e,t,n){let r=n.queries.fileSymbolFacts(e,t),s=Xt(t),o=n.queries.outline(e,t).flatMap(a=>U(a.symbol)==="namespace"&&s.has(C(a.symbol))?a.children:[a]),i=(a,d)=>({symbol:a.symbol,name:C(a.symbol),kind:r.get(a.symbol)?.kind??zt(a.symbol,d),startLine:a.startLine+1,endLine:a.endLine+1,signature:a.signature,children:a.children.map(p=>i(p,a.symbol))});return o.map(a=>i(a))}function zt(e,t){let n=U(e);return n==="method"?t!==void 0&&U(t)==="type"?"method":"function":n==="term"?"variable":n??"unknown"}function Xt(e){let t=Ge.basename(e);return new Set([t,t.slice(0,Math.max(0,t.length-Ge.extname(t).length))])}function nt(e,t,n=null){for(let r of e){if(r.symbol===t)return{entry:r,parent:n};let s=nt(r.children,t,r);if(s)return s}return null}function Qt(e,t){let n={};for(let r of $t)n[r]=(e[r]??[]).map(s=>{let{line:o,...i}=s,a={...i};return o!==void 0&&(a.line=o+1),s.file!==void 0&&(a.editorUri=ne(t,s.file,(o??0)+1)),a});return n}function rt(e){return e===null||e===""?"references":e==="references"||e==="imports"?e:null}function Ke(e){if(!/^\d{1,9}$/u.test(e))return null;let t=Number(e);return t>=1?t:null}function D(e){return e.generation.identity}function k(e,t){return{status:400,body:{error:t,generation:D(e)}}}function L(e,t,n={}){return{status:404,body:{error:t,...n,generation:D(e)}}}function T(e){return e.length>200?`${e.slice(0,200)}...`:e}import{createHash as ct,randomBytes as Zt,timingSafeEqual as en}from"crypto";import{existsSync as A}from"fs";import{createServer as tn}from"http";import{createRequire as nn}from"module";import{dirname as rn,join as H}from"path";import{fileURLToPath as on}from"url";var _="127.0.0.1",sn=80,an="__CODEBASEIQ_TOKEN__",cn="x-codebaseiq-token",ot=64*1024,un=18e4,st=50,it=["reuse","rework","compose"],ln="cytoscape.esm.min.mjs",dn=["index.html","styles.css","app.js","api.js","map.js","file-panel.js","focus.js","builder.js"],fn={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".js":"text/javascript; charset=utf-8"},pn=["default-src 'self'","script-src 'self'","style-src 'self' 'unsafe-inline'","img-src 'self' data:","connect-src 'self'","frame-ancestors 'none'"].join("; ");function mn(){for(let e of["../ui/view/","../../../ui/view/"]){let t=on(new URL(e,import.meta.url));if(A(H(t,"index.html")))return t}}function gn(){try{let e=nn(import.meta.url).resolve("cytoscape"),t=H(rn(e),ln);return A(t)?t:void 0}catch{return}}function at(e,t){return{body:ae(e,{maxBytes:ie,inputKind:"viewer asset"}),contentType:t}}function bn(e,t){let n=e.uiDirectory??mn();if(!n||!A(H(n,"index.html")))throw new Error("The viewer UI files were not found; reinstall codebaseiq or rebuild the package.");let r=new Map;for(let i of dn){let a=H(n,i);if(!A(a))continue;let d=at(a,fn[i.slice(i.lastIndexOf("."))]??"application/octet-stream");r.set(i,i==="index.html"?{...d,body:Buffer.from(d.body.toString("utf8").replaceAll(an,t),"utf8")}:d)}let s=e.cytoscapePath??gn(),o=s&&A(s)?at(s,"text/javascript"):void 0;return{assets:r,...o?{vendor:o}:{}}}async function ut(e){let t=e.token??Zt(24).toString("base64url"),{assets:n,vendor:r}=bn(e,t),s=e.builderTimeoutMs??un,o=ct("sha256").update(t).digest(),i=0,a=!1,d=new Set,p=()=>lt(i),m=()=>yn(i),b=(c,u,g)=>{let h=JSON.stringify({generation:e.database.generation(),...g});c.writeHead(u,{...G(),"Content-Type":"application/json; charset=utf-8","Content-Length":Buffer.byteLength(h)}),c.end(h)},M=(c,u)=>{c.writeHead(200,{...G(),"Content-Type":u.contentType,"Content-Length":u.body.byteLength,...u.contentType.startsWith("text/html")?{"Content-Security-Policy":pn}:{}}),c.end(u.body)},y=(c,u,g,h={})=>{c.writeHead(u,{...G(),"Content-Type":"text/plain; charset=utf-8","Content-Length":Buffer.byteLength(g),...h}),c.end(g)},R=(c,u,g)=>{let h=hn.get(u);if(!h){b(c,404,{error:"Not found."});return}let v=h(e.database.acquire(),g,e.routes);b(c,v.status,v.body)},x=(c,u)=>{if(u==="/"){let v=n.get("index.html");v?M(c,v):y(c,404,"Not found.");return}if(u==="/favicon.ico"){c.writeHead(204,G()),c.end();return}if(u==="/vendor/cytoscape.mjs"&&r){M(c,r);return}let g=u.startsWith("/assets/")?u.slice(8):void 0,h=g===void 0?void 0:n.get(g);h?M(c,h):y(c,404,"Not found.")},E=async(c,u)=>{let g=c.headers.origin;if(g!==void 0&&!m().has(g)){b(u,403,{error:"Origin is not allowed."});return}if(!wn(c.headers["content-type"])){b(u,415,{error:"Content-Type must be application/json."});return}if(!Sn(o,c.headers[cn])){b(u,403,{error:"The viewer token is missing or wrong; reload the page."});return}let h=e.builder;if(!h){b(u,501,{error:"The symbol builder is not available in this viewer."});return}if(a){b(u,409,{error:"A builder query is already running."});return}a=!0;try{let v=await vn(c,ot);if(v===void 0){b(u,400,{error:`The request body must be at most ${ot/1024} KiB.`});return}let V=Rn(v);if(!V.ok){b(u,400,{error:V.error});return}await P(u,h,V.request,V.diagnostics)}finally{a=!1}},P=async(c,u,g,h)=>{let v=new AbortController;d.add(v);let V=()=>{c.writableEnded||v.abort(new Error("The client disconnected."))};c.on("close",V);let W;try{let $=await new Promise(J=>{W=setTimeout(()=>{v.abort(new Error("The builder query timed out.")),J({kind:"timeout"})},s),u(g,v.signal).then(K=>J({kind:"done",response:K}),K=>J({kind:"failed",error:K}))});if(c.destroyed)return;$.kind==="timeout"?b(c,504,{error:`The builder query took longer than ${Math.round(s/1e3)} s.`}):$.kind==="failed"?b(c,502,{error:re($.error)}):b(c,200,{...$.response,...h.length>0?{probeDiagnostics:h}:{}})}finally{W&&clearTimeout(W),c.off("close",V),d.delete(v)}},S=async(c,u)=>{if(!p().has((c.headers.host??"").toLowerCase())){y(u,403,"Forbidden host.");return}let g;try{g=new URL(c.url??"/",`http://${_}`)}catch{y(u,400,"Bad request.");return}let h=c.method??"GET";if(g.pathname==="/api/builder"){h==="POST"?await E(c,u):b(u,405,{error:"Use POST."});return}if(h!=="GET"&&h!=="HEAD"){y(u,405,"Method not allowed.",{Allow:"GET, HEAD"});return}g.pathname.startsWith("/api/")?R(u,g.pathname,g.searchParams):x(u,g.pathname)},l=tn((c,u)=>{S(c,u).catch(g=>{if(u.headersSent){u.destroy();return}b(u,500,{error:re(g)})})});await new Promise((c,u)=>{l.once("error",u),l.listen({host:_,port:e.port??0},()=>{l.off("error",u),c()})}),l.on("error",c=>{process.stderr.write(`codebaseiq view: server error: ${re(c)}
|
|
5
5
|
`)});let f=l.address();i=typeof f=="object"&&f?f.port:0;let w=`http://${_}:${i}`;return{port:i,origin:w,url:`${w}/`,token:t,close(){for(let c of d)c.abort(new Error("The viewer is shutting down."));return new Promise(c=>{l.close(()=>c()),l.closeAllConnections()})}}}var hn=new Map([["/api/meta",(e,t,n)=>Ye(e,n)],["/api/scope",ze],["/api/file",Xe],["/api/symbol",Qe],["/api/source",Ze]]);function lt(e){let t=new Set([`${_}:${e}`,`localhost:${e}`]);return e===sn&&(t.add(_),t.add("localhost")),t}function yn(e){return new Set([...lt(e)].map(t=>`http://${t}`))}function G(){return{"Cache-Control":"no-store","X-Content-Type-Options":"nosniff","Referrer-Policy":"no-referrer"}}function wn(e){return e!==void 0&&e.split(";")[0].trim().toLowerCase()==="application/json"}function Sn(e,t){return typeof t!="string"||t===""?!1:en(ct("sha256").update(t).digest(),e)}function vn(e,t){return new Promise((n,r)=>{let s=[],o=0,i=!1;e.on("data",a=>{o+=a.byteLength,o>t?(i=!0,s.length=0):i||s.push(a)}),e.on("end",()=>n(i?void 0:Buffer.concat(s).toString("utf8"))),e.on("error",r)})}function Rn(e){let t;try{t=JSON.parse(e)}catch{return{ok:!1,error:"The request body must be valid JSON."}}if(typeof t!="object"||t===null||Array.isArray(t))return{ok:!1,error:"The request body must be a JSON object."};let n=t,r={},s=[];if(n.description!==void 0){if(typeof n.description!="string")return{ok:!1,error:"description must be a string."};n.description.trim()!==""&&(r.description=n.description)}if(n.probes!==void 0){let o=me(n.probes);s=o.diagnostics,(pe(o.probes)||o.probes.kinds.length>0)&&(r.probes=o.probes)}if(n.mode!==void 0){if(typeof n.mode!="string"||!I.includes(n.mode))return{ok:!1,error:`mode must be one of ${I.join(", ")}.`};r.mode=n.mode}if(n.bucket!==void 0){if(typeof n.bucket!="string"||!it.includes(n.bucket))return{ok:!1,error:`bucket must be one of ${it.join(", ")}.`};r.bucket=n.bucket}if(n.limit!==void 0){let o=n.limit;if(typeof o!="number"||!Number.isInteger(o)||o<1||o>st)return{ok:!1,error:`limit must be an integer from 1 to ${st}.`};r.limit=o}return r.description===void 0&&r.probes===void 0?{ok:!1,error:"Give a description or at least one probe."}:{ok:!0,request:r,diagnostics:s}}function re(e){return e instanceof Error?e.message:String(e)}var kn="view-server.json",ft="127.0.0.1",Ln=1e3,Dn=5e3,Pn=2e3,gt={isProcessAlive:se,canConnect(e,t){return new Promise(n=>{let r=xn({host:ft,port:e}),s=o=>{r.destroy(),n(o)};r.setTimeout(t,()=>s(!1)),r.once("connect",()=>s(!0)),r.once("error",()=>s(!1))})},async fetchProjectRoot(e,t){try{let n=await fetch(`http://${ft}:${e}/api/meta`,{signal:AbortSignal.timeout(t)});if(!n.ok)return{kind:"answered",projectRoot:void 0};let r=await n.json();return{kind:"answered",projectRoot:typeof r.projectRoot=="string"?r.projectRoot:void 0}}catch{return{kind:"unanswered"}}}};function pt(e,t){let n=new URL(e);return t.focus!==void 0?n.searchParams.set("focus",t.focus):t.file!==void 0?n.searchParams.set("file",t.file):t.scope!==void 0&&n.searchParams.set("scope",t.scope),n.toString()}async function bt(e,t,n=gt){let r=ht(e);if(!r||!n.isProcessAlive(r.pid)||!await n.canConnect(r.port,Ln))return;let s=await n.fetchProjectRoot(r.port,Dn);if(s.kind==="unanswered")return r;let o=s.projectRoot;if(!(o===void 0||Y(dt(o))!==Y(dt(t))))return r}async function Vn(e,t,n=gt){let r=await bt(e,t.projectRoot,n);if(r&&r.pid!==t.pid)return process.stderr.write(`warning: a viewer (pid ${r.pid}, ${r.url}) is already recorded for this project, so this one is not.
|
|
@@ -9,4 +9,4 @@ import{a as ke}from"./chunk-KUKKLWJD.js";import{a as Me,b as Fe}from"./chunk-L37
|
|
|
9
9
|
`)}function Cn(e,t){return e?.code==="EADDRINUSE"&&t?new Error(`Port ${t} is already in use; choose another with --port.`):e instanceof Error?e:new Error(String(e))}function Nn(e,t){try{let n=ge(e.projectRoot,e.config),r=Fe({settings:n,storeRoot:Me(e.paths.cacheDir),languages:Bn(t.acquire()),openDb:()=>t.acquire(),env:Tn(process.env)});return{run:(s,o)=>r.query(s,{signal:o}),defaultMode:n.mode,close:()=>r.close()}}catch(n){return process.stderr.write(`codebaseiq view: the symbol builder is unavailable: ${yt(n)}
|
|
10
10
|
`),{defaultMode:"agent",close:()=>{}}}}function Tn(e){return Object.fromEntries(Object.entries(e).filter(([t])=>t!=="CLAUDECODE"&&!t.startsWith("CODEX_")))}function Bn(e){let t=e.generation.metadataRaw;return(t?le(ue(t))?.indexedLanguages:void 0)??[]}function In(e,t,n){let r;return()=>{let s=Date.now();if(r&&s-r.at<Pn)return r.value;let o;try{let{classification:i}=xe({projectRoot:e,cacheDir:t.paths.cacheDir,cliVersion:z,...n?{gitContext:n}:{}});o=i.kind==="live"?i.state.watcher.state:i.kind}catch{o="unknown"}return r={at:s,value:o},o}}function jn(){let e=new WeakMap;return{normalizeMapScope:j,codeMapScope:De,nearestMapScope:Pe,codeMapFile:Ve,isIndexedFile(t,n){let r=e.get(t);return r||(r=new Set(O(t,{includeIgnored:!1})),e.set(t,r)),r.has(n)},outline:Re,fileSymbolFacts(t,n){let r=new Map;for(let s of we(t,n))r.set(s.symbol,{kind:s.kind===null?null:An(s.kind),documentation:s.documentation});return r},resolveFocus:_e,symbolFocusLanes:$e,code:Z,fileIsStale(t,n){return Z(t,`${n}:1-1`)?.freshness?.semantic.state==="stale"}}}function An(e){let t=ve(e).toLowerCase();return t==="unknown"||t==="unspecifiedkind"?null:t}function _n(e){let t=()=>{let s=ht(e.stateFile);s?.pid===e.state.pid&&s.startedAt===e.state.startedAt&&En(e.stateFile,{force:!0})},n=!1,r=()=>{n||(n=!0,e.server.close().finally(()=>{e.builder.close(),e.database.close(),t(),console.log(`
|
|
11
11
|
Stopped.`),process.exit(0)}))};process.on("SIGINT",r),process.on("SIGTERM",r),process.on("exit",t)}function yt(e){return e instanceof Error?e.message:String(e)}export{kn as VIEW_STATE_FILE,jn as createViewerQueries,bt as findRunningViewer,ht as readViewerState,Vn as recordRunningViewer,jr as runCodeViewer,Tn as viewerBuilderEnvironment,pt as viewerDeepLink};
|
|
12
|
-
//# sourceMappingURL=code-viewer-
|
|
12
|
+
//# sourceMappingURL=code-viewer-XHSSAMBX.js.map
|