codebaseiq 0.3.0 → 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 +80 -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-33AXWMO2.js +2 -0
- package/dist/{chunk-EQNMD62X.js → chunk-37K55EG3.js} +2 -2
- package/dist/{chunk-ITSJMNUD.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-PFC44E6D.js → chunk-3VDL7GTY.js} +2 -2
- package/dist/{chunk-7JELP5YE.js → chunk-3XBZ5PKL.js} +2 -2
- package/dist/{chunk-75KJGYX7.js → chunk-42PXSE74.js} +2 -2
- package/dist/{chunk-FEIZXBLH.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-6BF3VYEF.js → chunk-55NUXP2V.js} +2 -2
- package/dist/chunk-5AJQCOZZ.js +21 -0
- package/dist/{chunk-5DSL3NT2.js → chunk-5NUPFZFA.js} +2 -2
- package/dist/{chunk-RJVAPMHF.js → chunk-65QIFIF6.js} +2 -2
- package/dist/{chunk-36JC5BG2.js → chunk-66Q5VLH6.js} +2 -2
- package/dist/{chunk-D7AZAOZX.js → chunk-6CQPIIS7.js} +2 -2
- package/dist/{chunk-GV2CEZCW.js → chunk-6CTSFS7R.js} +2 -2
- package/dist/{chunk-Q4XEU3UH.js → chunk-6EBUAKJT.js} +2 -2
- package/dist/chunk-6I55VYFG.js +4 -0
- package/dist/chunk-6NUURWPF.js +3 -0
- package/dist/{chunk-MHWMEZDA.js → chunk-6P5QMOM7.js} +2 -2
- package/dist/{chunk-LZSQ6X7E.js → chunk-6S5FE4ZF.js} +2 -2
- package/dist/chunk-74LRKLNC.js +22 -0
- package/dist/chunk-75A23IID.js +3 -0
- package/dist/chunk-75VNTSO6.js +7 -0
- package/dist/chunk-7HBBVZJ6.js +3 -0
- package/dist/{chunk-VWYGCMV5.js → chunk-7PPBMBH6.js} +2 -2
- package/dist/{chunk-3RSBGWGL.js → chunk-7WG57A5X.js} +2 -2
- package/dist/{chunk-FWQGH2N2.js → chunk-7XHZX6FX.js} +2 -2
- package/dist/{chunk-RIYJ4L33.js → chunk-A5HJ3CJW.js} +2 -2
- package/dist/{chunk-LONKINMJ.js → chunk-AJ5HVC5Z.js} +2 -2
- package/dist/{chunk-ZAFGY22Q.js → chunk-AYRHOFLV.js} +2 -2
- package/dist/chunk-AZDY3EKD.js +93 -0
- package/dist/{chunk-CW6AXOLR.js → chunk-AZZNG5Z2.js} +2 -2
- package/dist/chunk-BEKCTUPY.js +3 -0
- package/dist/{chunk-CR3OG6SQ.js → chunk-BKKX2OU5.js} +2 -2
- package/dist/{chunk-5LL4KEHO.js → chunk-BQKRYKDD.js} +2 -2
- package/dist/{chunk-FOZ74V56.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-XMJ53WG4.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-GP7C5VAE.js → chunk-DNRHRVKS.js} +2 -2
- package/dist/{chunk-SGMNWYTH.js → chunk-DOQLO74K.js} +2 -2
- package/dist/{chunk-AURCQHSG.js → chunk-DP3EJ6XL.js} +2 -2
- package/dist/{chunk-C7QWUBR2.js → chunk-DQZF7MP6.js} +2 -2
- package/dist/{chunk-E52K4L2W.js → chunk-DTM4EHD2.js} +2 -2
- package/dist/{chunk-YRKP7PM7.js → chunk-DUM7GR6B.js} +2 -2
- package/dist/{chunk-I22IZYDI.js → chunk-DZ4QOIRY.js} +2 -2
- package/dist/{chunk-EXZ7VLRY.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-FQTIFWLR.js → chunk-ESWVTSHU.js} +2 -2
- package/dist/{chunk-6VREELBC.js → chunk-ETZBIG6K.js} +2 -2
- package/dist/chunk-EYSJHKX6.js +3 -0
- package/dist/{chunk-Q23IMHXS.js → chunk-F4AGM7ZE.js} +37 -37
- package/dist/{chunk-FTTV7IRX.js → chunk-FPUJRBHL.js} +50 -50
- 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-NBCQZSGR.js → chunk-GC4I33OD.js} +2 -2
- package/dist/{chunk-NDKOVQFG.js → chunk-GLXEWYQY.js} +2 -2
- package/dist/{chunk-AEXQYQD7.js → chunk-GRHNPFHT.js} +2 -2
- package/dist/{chunk-NBZKSTXP.js → chunk-GWESWURK.js} +2 -2
- package/dist/{chunk-Q3ZCQY2Y.js → chunk-GXOFPAIR.js} +2 -2
- package/dist/{chunk-USOAJHY7.js → chunk-H4FGIFEU.js} +2 -2
- package/dist/{chunk-LKUTSP4G.js → chunk-HOGS6JFP.js} +2 -2
- package/dist/{chunk-UQE4XFSA.js → chunk-HSJLK5MC.js} +2 -2
- package/dist/{chunk-BWL3PMPT.js → chunk-HTPEUJ42.js} +2 -2
- package/dist/{chunk-3RR2K7EZ.js → chunk-IBPXUGJV.js} +2 -2
- package/dist/{chunk-BFBIMTCJ.js → chunk-ITA3N7G6.js} +2 -2
- package/dist/chunk-JG5OWAEB.js +22 -0
- package/dist/{chunk-2PRONPAS.js → chunk-JGJKRTTB.js} +2 -2
- package/dist/{chunk-TJWVT4DO.js → chunk-JGXLB7PR.js} +2 -2
- package/dist/{chunk-K7JLSGCJ.js → chunk-JKUF2UG6.js} +3 -3
- 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-GDHWOA57.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-MVRGB4KJ.js → chunk-M3IBH6C3.js} +9 -9
- package/dist/{chunk-PHNCEUXX.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-PTQPPPG2.js → chunk-N26LGGSF.js} +2 -2
- package/dist/{chunk-J7AMBVWF.js → chunk-NB2DAVPP.js} +2 -2
- package/dist/{chunk-JYI7CV25.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-DDN2F6GB.js → chunk-O5BWFNIH.js} +2 -2
- package/dist/{chunk-HVFB3PME.js → chunk-O7PCDZ5B.js} +2 -2
- package/dist/{chunk-KPZGTB2O.js → chunk-OAJYNPRU.js} +2 -2
- package/dist/{chunk-2EDX3JT5.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-NCJILOAK.js → chunk-PFMQRHC6.js} +2 -2
- package/dist/chunk-PVKSZBX5.js +82 -0
- 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-J3GLP7Q5.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-5IZRKWTZ.js → chunk-RWAZCEJD.js} +2 -2
- package/dist/{chunk-ZQ62NNKN.js → chunk-RWDIONS7.js} +2 -2
- package/dist/{chunk-HQA7EBSK.js → chunk-S3CJYDXP.js} +2 -2
- package/dist/{chunk-GL6UTNUB.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-67VJAYVR.js → chunk-TB575ZGO.js} +2 -2
- package/dist/{chunk-YHPG3S2U.js → chunk-TG4GMU73.js} +2 -2
- package/dist/{chunk-CVHOQONG.js → chunk-THKM7OXM.js} +2 -2
- package/dist/{chunk-GVAF222T.js → chunk-TNLOX4TN.js} +2 -2
- package/dist/{chunk-HENP2O4A.js → chunk-UHFZDQZJ.js} +2 -2
- package/dist/{chunk-YT4DVWUV.js → chunk-UUMAM5LM.js} +2 -2
- package/dist/{chunk-JX6ZWDOS.js → chunk-UUT5P3V7.js} +2 -2
- package/dist/{chunk-Z6RL7XOE.js → chunk-VEPK6M5C.js} +2 -2
- package/dist/{chunk-C7OUW52M.js → chunk-VPCHKZ3I.js} +2 -2
- package/dist/{chunk-GIDCP7KV.js → chunk-VZY3XOBU.js} +2 -2
- package/dist/{chunk-XQAVQVIL.js → chunk-W6E6ME7G.js} +2 -2
- package/dist/{chunk-XQPPURLQ.js → chunk-WGYZBS5S.js} +2 -2
- package/dist/{chunk-GUFPEFBG.js → chunk-WUP24Q4U.js} +2 -2
- package/dist/chunk-WXUHXSLN.js +2 -0
- package/dist/{chunk-HINZQKSY.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-BBP7HVBJ.js → chunk-XVJ2E7W7.js} +2 -2
- package/dist/{chunk-D53LWANR.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-JSNTHRLQ.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-TPO7XC5Z.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-VHLBLIUM.js → code-viewer-C6HE4DFC.js} +2 -2
- package/dist/{code-viewer-KIXEYQNJ.js → code-viewer-XHSSAMBX.js} +2 -2
- package/dist/{command-descriptors-YCLATF5I.js → command-descriptors-NWW34Z54.js} +171 -171
- package/dist/{command-descriptors-F5P2V3NW.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-23C5AD3B.js +0 -2
- package/dist/chunk-2I2UHZET.js +0 -2
- package/dist/chunk-5IC2WZAL.js +0 -22
- package/dist/chunk-5T44HG5Y.js +0 -88
- package/dist/chunk-6JMAVFL4.js +0 -3
- package/dist/chunk-6WAPPQ5F.js +0 -82
- package/dist/chunk-7UCDGXRW.js +0 -8
- package/dist/chunk-AQI4N64O.js +0 -22
- package/dist/chunk-DAKIGMIK.js +0 -21
- package/dist/chunk-DUKHVPU5.js +0 -4
- package/dist/chunk-DVWO7RBC.js +0 -2
- package/dist/chunk-FH5WG4LE.js +0 -2
- package/dist/chunk-GQXXOS55.js +0 -2
- package/dist/chunk-GWYZVVKY.js +0 -21
- package/dist/chunk-JFIA2JI3.js +0 -3
- package/dist/chunk-JLZLLLW5.js +0 -3
- package/dist/chunk-MEUHIDI3.js +0 -7
- package/dist/chunk-OFGOOL6U.js +0 -3
- package/dist/chunk-P4NVCOM7.js +0 -2
- package/dist/chunk-SMDIEDM4.js +0 -27
- package/dist/chunk-SX72EVMY.js +0 -3
- package/dist/chunk-T5X7DK6C.js +0 -3
- package/dist/chunk-T75DS2E6.js +0 -21
- package/dist/chunk-TJBOJUVN.js +0 -3
- package/dist/chunk-UC2FD2PS.js +0 -4
- package/dist/chunk-UQYQBLJX.js +0 -5
- package/dist/chunk-Z35GOVEH.js +0 -2
- package/dist/cli-context-FJL2JHOE.js +0 -3
- package/dist/cli-context-PQNWHMCQ.js +0 -2
- package/dist/cli-program-UO7PZD6V.js +0 -7
- package/dist/direct-navigation-4XJTXIDT.js +0 -2
- package/dist/direct-navigation-J5MVYYAD.js +0 -3
- package/dist/invocation-command-descriptors-RWV4VAI4.js +0 -2
- package/dist/invocation-command-descriptors-U76PN7IY.js +0 -3
- package/dist/output-continuation-command-BL25S26S.js +0 -3
- package/dist/output-continuation-command-BTETTXEC.js +0 -2
- package/dist/project-reindex-CRJU3IFG.js +0 -2
- package/dist/project-reindex-TQFCOA2O.js +0 -3
- package/dist/sentinel-ensure-command-OSWGCFFL.js +0 -3
- package/dist/sentinel-ensure-command-SPW7XQLB.js +0 -2
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as _e,g as Pe,i as Ae,j as Ne}from"./chunk-
|
|
1
|
+
import{d as _e,g as Pe,i as Ae,j as Ne}from"./chunk-JKUF2UG6.js";import{a as Te}from"./chunk-LTPNP6D5.js";import{c as Se,e as F,f as Oe,k as Ie,l as Ee}from"./chunk-75A23IID.js";import"./chunk-OANDYLJQ.js";import"./chunk-3LCDIREB.js";import{A as be,B as ve,G as Ce,I as Re,Q as xe,U as we,Z as z,ba as ke,fa as P,ga as L,i as ye,n as l,p as g,q as x,r as m,t as _}from"./chunk-6I55VYFG.js";import{existsSync as ln,mkdirSync as Pi}from"fs";import{randomUUID as un}from"crypto";import{dirname as Mi,isAbsolute as ji,join as et,relative as Vi,resolve as Di}from"path";var S=1,I=2,Vt="./node_modules/codebaseiq/docs/schemas/project-config.schema.json";function X(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(c){return{kind:"malformed",reason:`invalid JSON: ${c instanceof Error?c.message:String(c)}`}}if(!l(t))return{kind:"malformed",reason:"project config must be a JSON object"};let n=t.schemaVersion;if(n!==void 0&&!Number.isInteger(n))return{kind:"malformed",reason:"schemaVersion must be an integer"};let i=n===void 0?S:n;if(i!==S&&i!==I)return{kind:"unsupported",schemaVersion:i,direction:i<S?"older":"future"};let r=t.$schema;if(r!==void 0&&(typeof r!="string"||r.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let s=$(t),o=i!==I||typeof t.$schema!="string";return i===S?{kind:"legacy",sourceVersion:S,config:s,needsMigration:o}:{kind:"supported",sourceVersion:I,config:s,needsMigration:o}}function $(e){let t=e,{$schema:n,schemaVersion:i,...r}=t;return{$schema:typeof n=="string"&&n.trim()!==""?n:Vt,schemaVersion:I,...r}}function Me(e){return`${JSON.stringify($(e),null,2)}
|
|
2
2
|
`}import{createHash as Dt}from"crypto";var h=1,R=2,W=1,N=1,A="sha256",te=1;function Le(e,t,n){if(!m(e)||!qe(t))throw new Error("Observation identity requires a bounded projection name and positive projection version.");return{schemaVersion:W,canonicalizationVersion:N,hashAlgorithm:A,projection:{name:e,version:t},digest:Dt(A).update(Ft(e,t,n)).digest("hex")}}function Ft(e,t,n){return`{"canonicalizationVersion":${N},"projection":${JSON.stringify(e)},"projectionVersion":${t},"value":${JSON.stringify(n)}}`}function ne(e){if(!l(e))return{kind:"malformed",reason:"observation receipt must be an object"};let t=e.schemaVersion;if(!Number.isInteger(t))return{kind:"malformed",reason:"observation receipt schemaVersion must be an integer"};if(t===h)return Ut(e)?{kind:"legacy",schemaVersion:h,receipt:e}:{kind:"malformed",reason:"observation receipt v1 fields are malformed or contradictory"};if(t===R)return Jt(e)?{kind:"supported",schemaVersion:R,receipt:e}:{kind:"malformed",reason:"observation receipt v2 facts are malformed or contradictory"};let n=t;return{kind:"unsupported",schemaVersion:n,direction:n<h?"older":"future"}}function B(e){let t=ne(e);return t.kind==="legacy"||t.kind==="supported"}function ie(e,t){return{collaborationDomain:O(y(e,n=>n.facts.collaborationDomain),y(t,n=>n.facts.collaborationDomain)),repositoryLineage:O(y(e,n=>n.facts.repositoryLineage),y(t,n=>n.facts.repositoryLineage)),workspaceInstance:O(y(e,n=>n.facts.workspaceInstance),y(t,n=>n.facts.workspaceInstance)),wholeContent:O(y(e,n=>n.facts.wholeContent),y(t,n=>n.facts.wholeContent)),relevantInputs:Lt(e,t),indexInput:O(y(e,n=>n.facts.index?.inputs),y(t,n=>n.facts.index?.inputs)),indexGeneration:$t(e,t),observationStability:Bt(e,t)}}function G(e,t,n=ie(e,t)){let i=[["collaborationDomain",n.collaborationDomain],["wholeContent",n.wholeContent],["observationStability",n.observationStability]],r=[];for(let[o,c]of i)c.state!=="established"&&r.push(`${o}:${c.state}`);for(let[o,c]of[["left",e],["right",t]]){let a=Gt(c);a!=="not-applicable"&&a!=="established"&&r.push(`${o}IndexAlignment:${a}`)}let s=i.some(([,o])=>o.state==="disproven")||r.some(o=>o.endsWith(":disproven"));return{policyVersion:te,authority:r.length===0?"completion":s?"none":"advisory",requiredRelationships:["collaborationDomain","wholeContent","observationStability"],reasons:r}}function $e(e){return e.schemaVersion===h?e.index?.generationIdentity:e.facts.index?.generation.digest}function We(e){return e.schemaVersion===h?void 0:e.facts.workspaceInstance?.digest}function Be(e){if(e.schemaVersion===h)return e.index?.alignment??"not-established";let t=e.stabilityProofs.filter(n=>n.source!=="process");return t.some(n=>n.kind==="invalidated")?"invalidated":t.length>0&&t.every(n=>n.kind==="immutable"||n.kind==="fixed-snapshot")?"fixed":t.some(n=>n.kind==="bracketed")?"bracketed":"not-established"}function Lt(e,t){let n=je(e),i=je(t);return[...new Set([...n.keys(),...i.keys()])].sort().map(s=>{let o=n.get(s),c=i.get(s),a=o?.subject??c?.subject??s,d=o?.identity.projection.name??c?.identity.projection.name??s;return{subject:a,projection:d,judgment:O(o?.identity,c?.identity)}})}function je(e){return e.schemaVersion!==R?new Map:new Map((e.facts.relevantInputs??[]).map(t=>[`${t.subject}\0${t.identity.projection.name}`,t]))}function $t(e,t){return e.schemaVersion===h&&t.schemaVersion===h?Wt(e.index?.generationIdentity,t.index?.generationIdentity):e.schemaVersion===h||t.schemaVersion===h?v("unknown",["legacy-fact-not-comparable"],De(e),De(t)):O(e.facts.index?.generation,t.facts.index?.generation)}function Wt(e,t){let n=e?[{kind:"legacy-index-generation",value:e}]:[],i=t?[{kind:"legacy-index-generation",value:t}]:[];return e===void 0||t===void 0?Ge(n,i):v(e===t?"established":"disproven",[e===t?"identities-equal":"identities-different"],n,i)}function O(e,t){let n=e?[{kind:"identity",identity:e}]:[],i=t?[{kind:"identity",identity:t}]:[];return!e||!t?Ge(n,i):re(e,t)?v(e.digest===t.digest?"established":"disproven",[e.digest===t.digest?"identities-equal":"identities-different"],n,i):v("unknown",["identity-projections-not-comparable"],n,i)}function Bt(e,t){if(e.schemaVersion===h||t.schemaVersion===h)return v("unknown",["legacy-fact-not-comparable"],[],[]);let n=Fe(e),i=Fe(t),r=Ve(e),s=Ve(t);return r==="invalidated"||s==="invalidated"?v("disproven",[...r==="invalidated"?["left-observation-invalidated"]:[],...s==="invalidated"?["right-observation-invalidated"]:[]],n,i):r!=="fixed"||s!=="fixed"?v("unknown",[...r==="no-repository-source"?["left-observation-has-no-repository-source"]:r!=="fixed"?["left-observation-not-fixed"]:[],...s==="no-repository-source"?["right-observation-has-no-repository-source"]:s!=="fixed"?["right-observation-not-fixed"]:[]],n,i):v("established",["all-observed-sources-fixed"],n,i)}function Ve(e){let t=e.observedSources.filter(i=>i.kind!=="process");if(t.length===0)return"no-repository-source";let n=new Map(e.stabilityProofs.map(i=>[i.source,i.kind]));return t.some(i=>n.get(i.kind)==="invalidated")?"invalidated":t.every(i=>{let r=n.get(i.kind);return r==="immutable"||r==="fixed-snapshot"})?"fixed":"unknown"}function Gt(e){if(e.schemaVersion!==R)return e.index?"unknown":"not-applicable";if(!e.observedSources.some(i=>i.kind==="index-generation"))return"not-applicable";let t=e.facts.index?.inputs;if(!t)return"unknown";let n=(e.facts.relevantInputs??[]).find(i=>re(i.identity,t))?.identity;return n?n.digest===t.digest?"established":"disproven":"unknown"}function y(e,t){return e.schemaVersion===R?t(e):void 0}function De(e){return e.schemaVersion===h&&e.index?[{kind:"legacy-index-generation",value:e.index.generationIdentity}]:e.schemaVersion===R&&e.facts.index?[{kind:"identity",identity:e.facts.index.generation}]:[]}function Fe(e){return e.stabilityProofs.map(t=>({kind:"stability",proof:t}))}function Ge(e,t){let n=e.length===0&&t.length===0?"both-facts-missing":e.length===0?"left-fact-missing":"right-fact-missing";return v("unknown",[n],e,t)}function v(e,t,n,i){return{state:e,reasons:t,facts:{left:n,right:i}}}function re(e,t){return e.schemaVersion===t.schemaVersion&&e.canonicalizationVersion===t.canonicalizationVersion&&e.hashAlgorithm===t.hashAlgorithm&&e.projection.name===t.projection.name&&e.projection.version===t.projection.version}function Ut(e){if(!l(e))return!1;let t=e.index,n=e.worktree;return Je(e.observedAt)&&m(e.projectIdentity)&&Xt(e.authorityKind)&&(t===void 0||l(t)&&m(t.generationIdentity)&&(t.source==="immutable"||t.source==="legacy")&&(t.alignment==="not-certified"||t.alignment==="leased"))&&(n===void 0||l(n)&&m(n.identity)&&typeof n.clean=="boolean"&&(n.headCommit===void 0||m(n.headCommit))&&(n.treeOid===void 0||m(n.treeOid)))&&zt(e.authorityKind,t,n)}function Jt(e){if(!l(e))return!1;let t=e.facts,n=e.observedSources,i=e.stabilityProofs;if(!Je(e.observedAt)||!l(t)||!Array.isArray(n)||n.length===0||!n.every(Yt)||!ee(n,a=>a.kind)||!Array.isArray(i)||!i.every(Kt)||!ee(i,a=>a.source)||i.some(a=>!n.some(d=>d.kind===a.source))||!i.every(a=>Qt(a,t))||["collaborationDomain","repositoryLineage","workspaceInstance","wholeContent"].some(a=>t[a]!==void 0&&!C(t[a])))return!1;let s=t.relevantInputs;if(s!==void 0&&(!Array.isArray(s)||!s.every(qt)||!ee(s,a=>`${a.subject}\0${a.identity.projection.name}`)))return!1;let o=t.index;if(o!==void 0&&(!l(o)||!C(o.generation)||o.inputs!==void 0&&!C(o.inputs)||o.source!=="immutable"&&o.source!=="legacy"))return!1;let c=e.diagnostics;return(c===void 0||l(c)&&(c.clean===void 0||typeof c.clean=="boolean")&&(c.headCommit===void 0||m(c.headCommit))&&(c.treeOid===void 0||m(c.treeOid)))&&Ht(t,n)}function C(e){return!l(e)||!l(e.projection)?!1:e.schemaVersion===W&&e.canonicalizationVersion===N&&e.hashAlgorithm===A&&m(e.projection.name)&&qe(e.projection.version)&&typeof e.digest=="string"&&/^[a-f0-9]{64}$/u.test(e.digest)}function qt(e){return l(e)&&m(e.subject)&&C(e.identity)}function Yt(e){return l(e)&&Ue(e.kind)&&(e.identity===void 0||C(e.identity))}function Kt(e){return l(e)&&Ue(e.source)&&(e.kind==="immutable"||e.kind==="fixed-snapshot"||e.kind==="bracketed"||e.kind==="not-established"||e.kind==="invalidated")}function Ht(e,t){let n=e.index,i=t.find(a=>a.kind==="index-generation");if(i){if(!l(n)||!C(n.generation)||i.identity&&!Z(i.identity,n.generation))return!1}else if(n!==void 0)return!1;let r=e.workspaceInstance,s=t.find(a=>a.kind==="live-workspace");if(s?.identity&&(!C(r)||!Z(s.identity,r)))return!1;let o=e.wholeContent,c=t.find(a=>a.kind==="repository-snapshot");return!(c?.identity&&(!C(o)||!Z(c.identity,o)))}function Qt(e,t){return e.kind==="not-established"||e.kind==="invalidated"?!0:e.source==="index-generation"?e.kind==="immutable"&&l(t.index)&&t.index.source==="immutable":e.source==="repository-snapshot"?e.kind==="fixed-snapshot":e.source==="live-workspace"?e.kind==="bracketed":!1}function Z(e,t){return re(e,t)&&e.digest===t.digest}function zt(e,t,n){return e==="index-worktree"?t!==void 0&&n!==void 0:e==="index-only"?t!==void 0&&n===void 0:e==="worktree-only"?t===void 0&&n!==void 0:e==="process-local"&&t===void 0&&n===void 0}function Xt(e){return e==="index-worktree"||e==="index-only"||e==="worktree-only"||e==="process-local"}function Ue(e){return e==="index-generation"||e==="repository-snapshot"||e==="live-workspace"||e==="process"}function Je(e){return typeof e=="string"&&!Number.isNaN(Date.parse(e))}function qe(e){return Number.isSafeInteger(e)&&e>0}function ee(e,t){return new Set(e.map(t)).size===e.length}import{createHash as Ye}from"crypto";import{closeSync as Zt,fstatSync as Ke,openSync as en,rmSync as tn}from"fs";import{dirname as nn}from"path";var rn=2e3,on=10,sn=3,J=class extends Error{constructor(n,i,r){super(`Concurrent edit detected for ${n}; expected revision ${Qe(i)}, but found ${Qe(r)}. The latest file was left untouched.`);this.path=n;this.original=i;this.latest=r;this.name="FileRevisionConflictError"}path;original;latest};function ze(e,t,n={}){let i=an(e,n.lockTimeoutMs??rn,n.monotonicNow??F);try{let r=Math.max(0,Math.floor(n.maxRetries??sn));for(let s=0;;s+=1){let o=U(e),c=t(o,s);if(c.kind==="unchanged")return{changed:!1,attempts:s+1,previous:o,current:o};n.onBeforeCommit?.({attempt:s,snapshot:o,mutation:c});let a=U(e);if(!dn(o.revision,a.revision)){if(s<r)continue;throw new J(e,o.revision,a.revision)}try{cn(e,c,o.revision)}catch(d){if(d.code==="EEXIST"){let p=U(e);if(s<r)continue;throw new J(e,o.revision,p.revision)}throw d}return{changed:!0,attempts:s+1,previous:o,current:U(e)}}}finally{i.release()}}function U(e){for(let t=0;t<4;t+=1){let n;try{n=en(e,"r");let i=He(Ke(n)),r=Re(n,{maxBytes:ve,inputKind:"revisioned text file"}),s=He(Ke(n));if(!Xe(i,s))continue;return{path:e,text:r,revision:{exists:!0,hash:Ye("sha256").update(r).digest("hex"),identity:s}}}catch(i){if(i.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:Ye("sha256").update("").digest("hex")}};throw i}finally{n!==void 0&&Zt(n)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function an(e,t,n){let i=`${e}.codebaseiq-write.lock`,r=n()+Math.max(0,t);for(;;){let s=Oe(i,{kind:"revisioned-file-mutation",detail:{target:e}});if(s.kind==="acquired")return s.lock;if(n()>=r)throw new Error(`Timed out after ${t}ms waiting to update ${e}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,on)}}function cn(e,t,n){if(t.kind==="delete"){if(!n.exists)return;tn(e),xe(nn(e));return}let i=t.mode??n.identity?.mode;n.exists?Ie(e,t.text,{durability:"durable",mode:i}):Ee(e,t.text,{durability:"durable",mode:i})}function dn(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&Xe(e.identity,t.identity))}function He(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function Xe(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function Qe(e){return e.exists?e.hash.slice(0,12):"<absent>"}var M=".codebaseiq.json";var tt=2e3,nt=5e3,oe=nt,se=3*6e4,pn=60*6e4,ae={enabled:!0,windowMs:15*6e4,maxRebuilds:2,maxEstimatedWriteBytes:1024*1024*1024},fn={enabled:!1,debounceMs:tt,cooldownMs:oe,gitPollMs:2e3,idleTimeoutMs:se,autoRefresh:!0,ignore:[],resourceBudget:ae};var Bi=new Set(_);function q(e){let t=et(e,M);if(!ln(t))return{};let n;try{n=Ce(t,{maxBytes:be,inputKind:"codebaseiq project config"})}catch(i){let r=i instanceof Error?i.message:String(i);throw new Error(`unable to read ${M} at ${t}: ${r}`,{cause:i})}return rt(X(n),t,"read").config}function it(e){return{...fn,...e.watch,idleTimeoutMs:e.watch?.idleTimeoutMs??(e.daemon?.enabled===!0?pn:se),cooldownMs:Math.max(nt,e.watch?.cooldownMs??oe),resourceBudget:{...ae,...e.watch?.resourceBudget}}}function hn(e,t){return mn(e,t).configPath}function mn(e,t){let n=et(e,M),i=un(),r={collaborationDomainId:i,languages:t,watch:{enabled:!0,debounceMs:tt,cooldownMs:oe,gitPollMs:2e3,idleTimeoutMs:se,autoRefresh:!0,resourceBudget:{...ae}}},s=ze(n,o=>{if(!o.revision.exists)return{kind:"write",text:Ze(r)};let c=gn(o,r);return c.config.collaborationDomainId?{kind:"unchanged"}:{kind:"write",text:Ze({...c.config,collaborationDomainId:i})}});return{configPath:n,changed:s.changed}}function gn(e,t){if(!e.revision.exists)return{config:$(t),needsMigration:!0};let n=rt(X(e.text),e.path,"update");return{config:n.config,needsMigration:n.needsMigration}}function Ze(e){return Me(e)}function rt(e,t,n){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let r=n==="read"?`invalid ${M} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${r} The file was left untouched.`)}let i=n==="read"?`invalid ${M} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${i} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this codebaseiq reads legacy v${S} and current v${I}). Upgrade codebaseiq before retrying; the file was left untouched.`)}import{statSync as ot}from"fs";import{basename as yn,isAbsolute as bn,join as j,relative as vn}from"path";import{fileURLToPath as Cn}from"url";import{watch as Rn}from"chokidar";import Sn from"ignore";var pt=5e3,de=class{projectRoot;config;watchConfig;outputDb;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onFileChanged;onBulkChange;onError;reindexRunner;subscriptionFactory;budgetInspector;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;budgetTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fileChangeTimer=null;pendingFileChanges=new Set;bulkChangePending=!1;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;observationEpoch=0;changeSequence=0;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=it(t.config),this.outputDb=t.outputDb??j(we(this.projectRoot,t.config),"index.db"),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onReindexError=t.onReindexError??(()=>{}),this.onRefreshSuppressed=t.onRefreshSuppressed??(()=>{}),this.onFileChanged=t.onFileChanged,this.onBulkChange=t.onBulkChange;let n=t.onError??(i=>console.error(i.message));this.onError=i=>{this.observationEpoch+=1,n(i)},this.clock=t.clock??En,ft.set(this,jn(t.stopTimeoutMs??pt,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??gt(),this.subscriptionFactory=t.subscriptionFactory??wn,this.budgetInspector=t.budgetInspector??Pe,ht.set(this,{gitReader:t.gitReader??ke,languages:yt(t.languages??t.config.languages),stagedIndexEntries:null,gitSignalPaths:null,lastGitSignal:null}),this.gitignoreFilter=Te(t.projectRoot),this.extraIgnore=Sn(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,Y(this).errors=[],this.sourcePollingFallbackStarted=!1,this.observationEpoch+=1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let t=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearBudgetTimer(),this.clearGitPollTimer(),this.clearFileChangeWindow();let n=this.activeOperation;n&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let i=[...Y(this).closures],r=xn(this),s=this.clock.now()+r;return this.stopPromise=this.finishStop(t,i,n,s,r).catch(o=>{throw this.stopInProgress=!1,o}),this.stopPromise}observation(){return{epoch:this.observationEpoch,changeSequence:this.changeSequence}}requestRefresh(t,n={}){if(!this.stopped){if(!n.immediate||this.reindexInFlight||this.status.state==="cooldown"||this.status.state==="budget-paused"){this.scheduleReindex(t);return}this.pendingTrigger=ct(this.pendingTrigger,t),this.changedFiles+=1,this.changeSequence+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let n=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(i,r)=>this.isIgnoredWatchPath(i,r?.isDirectory()??!1),usePolling:t,...t?{interval:500,binaryInterval:1e3}:{}});n.on("all",(i,r)=>{!this.stopped&&i!=="addDir"&&i!=="unlinkDir"&&this.handleFileChange(r)}),n.on("error",i=>this.handleSourceWatcherError(n,i,t)),this.fsWatchers.push(n)}handleSourceWatcherError(t,n,i){if(i||this.sourcePollingFallbackStarted||!Mn(n)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(n)}`));return}this.observationEpoch+=1,this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(r=>r!==t),In(Y(this),t,r=>this.onError(r));try{this.startSourceWatcher(!0)}catch(r){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`))}}isIgnoredWatchPath(t,n){let i=this.relativeWatchPath(t);if(!i)return!1;let r=n?`${i}/`:i;return r===".git/"||r.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)}handleFileChange(t){let n=this.relativeWatchPath(t);!n||n===".."||n.startsWith("../")||n===".git"||n.startsWith(".git/")||this.gitignoreFilter.isIgnored(n)||this.extraIgnore.ignores(n)||n.endsWith("index.db")||n.endsWith("index.scip")||n.endsWith("index.db.tmp")||yn(n).startsWith(_e)||(n===".codebaseiq.json"&&dt(this,this.projectRoot),lt(this,n)&&(this.noteFileChange(n),this.scheduleReindex({kind:"watch-source",detail:n})))}noteFileChange(t){!this.onFileChanged&&!this.onBulkChange||(this.bulkChangePending||(this.pendingFileChanges.add(t),this.pendingFileChanges.size>Tn&&(this.pendingFileChanges.clear(),this.bulkChangePending=!0)),this.fileChangeTimer??=this.clock.setTimeout(()=>this.flushFileChangeWindow(),kn))}flushFileChangeWindow(){if(this.fileChangeTimer=null,this.stopped)return;let t=[...this.pendingFileChanges],n=this.bulkChangePending;this.pendingFileChanges.clear(),this.bulkChangePending=!1;try{n?this.onBulkChange?.():this.onFileChanged?.(t)}catch{}}clearFileChangeWindow(){this.fileChangeTimer&&(this.clock.clearTimeout(this.fileChangeTimer),this.fileChangeTimer=null),this.pendingFileChanges.clear(),this.bulkChangePending=!1}relativeWatchPath(t){let n=bn(t)?t:j(this.projectRoot,t);return vn(this.projectRoot,n).replaceAll("\\","/")}scheduleReindex(t){if(this.pendingTrigger=ct(this.pendingTrigger,t),this.changedFiles++,this.changeSequence+=1,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}if(this.status.state==="budget-paused"){this.dirty=!0,this.setStatus({...this.status,dirty:!0});return}this.clearDebounceTimer();let n=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:n}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=this.inspectBudget();if(t.state==="paused"){this.dirty=!0;let o=Math.max(this.wallNow()+1,t.until);this.setStatus({state:"budget-paused",until:o,dirty:!0,reason:t.detail,rebuilt:t.rebuilt,estimatedWriteBytes:t.estimatedWriteBytes}),this.clearBudgetTimer(),this.budgetTimer=this.clock.setTimeout(()=>{this.budgetTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},Math.min(2147483647,Math.max(1,o-this.wallNow())));return}let n=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&n<this.watchConfig.cooldownMs){let o=this.watchConfig.cooldownMs-n;this.dirty=!0;let c=this.wallNow()+o;this.setStatus({state:"cooldown",until:c,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},o);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let i=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let r=this.wallNow();this.setStatus({state:"indexing",startedAt:r});let s=this.reindexRunner.start(this.reindexRequest(i));this.activeOperation=s,s.completion.then(o=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let c=!1;try{c=this.onReindexComplete(o,i)===!0}catch(a){this.onError(a instanceof Error?a:new Error(String(a)))}if(this.dirty&&!this.stopped){if(c){let d=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(d),this.setStatus({state:"idle"});return}let a=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(o=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let c=o instanceof Error?o:new Error(String(o));this.onReindexError(c,i),this.onError(c),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===s&&(this.activeOperation=null)})}async finishStop(t,n,i,r,s){let o=[],c=t.map(async f=>{try{await f.close()}catch(D){o.push(`watch subscription close failed: ${String(D)}`)}});c.push(...n),i&&c.push((async()=>{try{let f=await i.cancel();f.state==="degraded"&&o.push(f.reason)}catch(f){o.push(`reindex cancellation failed: ${f instanceof Error?f.message:String(f)}`)}})());let a=c.length,d=c.map(f=>f.finally(()=>{a-=1})),p=await On(d,r,this.clock),u=Y(this);return o.push(...u.errors),u.errors=[],p?this.stopInProgress=!1:(o.push(`watch shutdown exceeded the ${s}ms deadline with ${a} operation(s) still pending`),Promise.all(d).then(()=>{this.stopInProgress=!1})),o.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:o.join("; ")}),{state:"degraded",reasons:o}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}inspectBudget(){try{return this.budgetInspector(this.outputDb,this.watchConfig.resourceBudget,new Date(this.wallNow()))}catch(t){return{state:"paused",reason:"activity-evidence",until:this.wallNow()+this.watchConfig.resourceBudget.windowMs,rebuilt:0,estimatedWriteBytes:0,detail:`reindex activity evidence could not be read: ${t instanceof Error?t.message:String(t)}`}}}reindexRequest(t){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:t}}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}clearBudgetTimer(){this.budgetTimer&&(this.clock.clearTimeout(this.budgetTimer),this.budgetTimer=null)}startGitStatePolling(){if(this.lastGitState=this.readGitState(),!this.lastGitState)return;let t=b(this);t.gitSignalPaths=this.resolveGitSignalPaths(),t.lastGitSignal=this.gitActivitySignal(),t.stagedIndexEntries=ut(this.projectRoot,t.gitReader),this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.()}resolveGitSignalPaths(){let t=b(this).gitReader,n=P(this.projectRoot,["rev-parse","--git-dir"],t),i=P(this.projectRoot,["rev-parse","--git-common-dir"],t);if(!n)return null;let r=L(this.projectRoot,n),s=i?L(this.projectRoot,i):r,o=this.lastGitState?.indexPath;return[j(r,"HEAD"),j(s,"packed-refs"),j(s,"refs","heads"),...o?[o]:[]]}gitActivitySignal(){let t=b(this).gitSignalPaths;if(!t)return null;let n="";for(let i of t)try{let r=ot(i);n+=`${i}:${r.mtimeMs}:${r.size};`}catch{n+=`${i}:absent;`}return n}pollGitState(){let t=this.gitActivitySignal();if(t!==null){if(t===b(this).lastGitSignal)return;b(this).lastGitSignal=t}let n=this.lastGitState,i=this.readGitState();if(!n||!i||this.stopped){this.lastGitState=i;return}this.lastGitState=i;let r=n.head!==i.head,s=n.indexPath!==i.indexPath||n.indexMtimeMs!==i.indexMtimeMs||n.indexSize!==i.indexSize;if(!r&&!s)return;let o=b(this),c=o.stagedIndexEntries,a=ut(this.projectRoot,o.gitReader);o.stagedIndexEntries=a;let d=Vn(this.projectRoot,o.gitReader,n,i,c,a,r,s),p=null;d!==null&&(d.includes(".codebaseiq.json")&&dt(this,this.projectRoot),p=d.filter(u=>lt(this,u)),p.length===0)||(r&&s?this.scheduleReindex({kind:"watch-git-state",detail:ce("HEAD and index changed",p)}):r?this.scheduleReindex({kind:"watch-git-head",detail:ce("HEAD changed",p)}):s&&this.scheduleReindex({kind:"watch-git-index",detail:ce(i.indexPath??"index changed",p)}))}readGitState(){let t=b(this).gitReader,n=P(this.projectRoot,["rev-parse","--git-path","index"],t);if(!n)return null;let i=L(this.projectRoot,n),r={head:P(this.projectRoot,["rev-parse","--verify","HEAD"],t),indexPath:i};try{let s=ot(i);r.indexMtimeMs=s.mtimeMs,r.indexSize=s.size}catch{r.indexMtimeMs=void 0,r.indexSize=void 0}return r}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function On(e,t,n){if(e.length===0)return!0;let i=Promise.all(e).then(()=>!0),r=Math.max(0,t-n.now()),s=null,o=new Promise(a=>{s=n.setTimeout(()=>a(!1),r)}),c=await Promise.race([i,o]);return c&&s&&n.clearTimeout(s),c}var st=new WeakMap,ft=new WeakMap,ht=new WeakMap;function Y(e){let t=st.get(e);if(t)return t;let n={closures:new Set,errors:[]};return st.set(e,n),n}function xn(e){return ft.get(e)??pt}function b(e){let t=ht.get(e);if(!t)throw new Error("Watcher input state was not initialized.");return t}function In(e,t,n){let i=Promise.resolve().then(()=>t.close()).catch(r=>{let s=`watch subscription close failed during polling fallback: ${String(r)}`;e.errors.push(s),n(new Error(s))});e.closures.add(i),i.then(()=>e.closures.delete(i))}function mt(e,t=Se){let{projectRoot:n,config:i,languages:r,pnpmWorkspaces:s,typescriptProjectMode:o,typescriptProjects:c,clojureConfigPath:a,indexerConcurrency:d,trigger:p}=e,u=q(n),f=Object.keys(u).length>0?u:i,D=z(n,f),Q=f.indexer?.typescript,jt=f.indexer?.clojure,ge=t(process.pid);if(!ge)throw new Error(`Could not establish watcher process identity for reindex worker ownership (pid ${process.pid}).`);return{workerPath:Cn(new URL("./reindex-worker.js",import.meta.url)),env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:n,SCIP_REINDEX_OUTPUT_SCIP:D.indexPath,SCIP_REINDEX_OUTPUT_DB:D.dbPath,SCIP_REINDEX_LANGUAGES:(f.languages??r)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(f.indexerConcurrency??d??""),SCIP_REINDEX_PNPM_WORKSPACES:Q?.pnpmWorkspaces??s?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:Q?.projectMode??o,projects:Q?.projects??c??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:jt?.configPath??a??"",SCIP_REINDEX_TRIGGER_KIND:p.kind,SCIP_REINDEX_TRIGGER_DETAIL:p.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1",SCIP_REINDEX_PARENT_IDENTITY:JSON.stringify(ge)}}}var En={now:F,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},wn=(e,t)=>Rn(e,t),kn=120,Tn=200,_n=15*6e4,Pn=1e3,An=64*1024;function Nn(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function at(e,t){let n=e instanceof Error?e.message:String(e),i=t.stderrTail.trim()||t.stdoutTail.trim();return i?`${n}
|
|
3
3
|
${i}`:n}function gt(e={}){let t=e.timeoutMs??_n,n=e.terminationGraceMs??Pn,i=e.maxOutputBytes??An,r=e.resolveLaunch??mt;return{start(s){let o=r(s),c=new AbortController,a=Nn(),d=!1,p=Ne({command:process.execPath,args:[...process.execArgv,o.workerPath],label:"watch reindex worker",env:o.env,timeoutMs:t,terminationGraceMs:n,maxStdoutBytes:i,maxStderrBytes:i,outputLimitBehavior:"truncate-tail",signal:c.signal,detached:!0}).then(u=>{if(a={stdoutTail:u.stdout,stderrTail:u.stderr,stdoutTruncated:u.stdoutTruncated,stderrTruncated:u.stderrTruncated},u.status!==0)throw new Error(at(new Error(`Reindex worker exited with ${u.signal?`signal ${u.signal}`:`code ${u.status}`}`),a));return u.durationMs}).catch(u=>{throw u instanceof Ae&&(a={stdoutTail:u.stdout,stderrTail:u.stderr,stdoutTruncated:u.stdoutTruncated,stderrTruncated:u.stderrTruncated}),new Error(at(u,a),{cause:u})}).finally(()=>{d=!0});return{completion:p,async cancel(){d||c.abort();try{await p}catch{}return{state:"exited",diagnostics:a}},diagnostics:()=>a}}}}function ct(e,t){return e?e.kind===t.kind?e.detail===t.detail?e:{kind:e.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${e.kind}, ${t.kind}`}:t}function Mn(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}function jn(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}function yt(e){return e&&e.length>0?[...e]:_}function dt(e,t){try{b(e).languages=yt(q(t).languages)}catch{b(e).languages=_}}function lt(e,t){return ye(t,b(e).languages)!=="other"}function Vn(e,t,n,i,r,s,o,c){let a=new Set;if(o){if(!n.head||!i.head)return null;let d=t.runResult(e,["diff","--name-only","-z","--no-renames","--relative",n.head,i.head,"--"]);if(d.kind!=="success")return null;for(let p of Dn(d.output))a.add(p)}if(c){if(r===null||s===null)return null;for(let d of Ln(r,s))a.add(d)}return[...a].sort()}function ut(e,t){let n=t.runResult(e,["diff","--cached","--raw","-z","--no-renames","--relative","--"]);return n.kind==="success"?Fn(n.output):null}function Dn(e){return e.split("\0").filter(t=>t.length>0)}function Fn(e){let t=e.split("\0");if(t.at(-1)===""&&t.pop(),t.length%2!==0)return null;let n=new Map;for(let i=0;i<t.length;i+=2){let r=t[i],s=t[i+1];if(!r.startsWith(":")||!s)return null;n.set(s,r)}return n}function Ln(e,t){return[...new Set([...e.keys(),...t.keys()])].filter(i=>e.get(i)!==t.get(i))}function ce(e,t){return t===null?`${e}; changed paths unavailable`:t.length===0?e:t.length===1?t[0]:`${t.length} compiler inputs changed`}import{existsSync as le,mkdirSync as $n,symlinkSync as Wn,readlinkSync as bt,unlinkSync as vt,readdirSync as Bn}from"fs";import{join as E,dirname as pe,resolve as w,relative as Gn,isAbsolute as Un}from"path";import{homedir as ue,platform as Jn}from"os";import{fileURLToPath as qn}from"url";var Yn=Jn()==="win32",Ct=["codebaseiq","codebaseiq-explore","concrete-plan"];function Kn(e={}){let t=e.quiet?()=>{}:console.log,n=qn(import.meta.url),i=w(pe(n),"..","skills"),r=[E(ue(),".claude","skills"),E(ue(),".codex","skills"),E(ue(),".agents","skills")],s={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let o of r){let c=pe(o);if(!le(c))continue;$n(o,{recursive:!0});let a=zn(o);Hn(o,i,a,s,t);for(let d of Ct){let p=E(i,d),u=E(o,d);if(!le(p)){s.skipped.push(`${a}/${d}`);continue}if(le(u)){try{let f=bt(u);if(w(f)===w(p)){s.alreadyLinked.push(`${a}/${d}`),t(` ok: ${d} \u2192 ${a} (already linked)`);continue}}catch{s.skipped.push(`${a}/${d}`),t(` skip: ${d} \u2192 ${a} (exists, not a symlink)`);continue}vt(u)}Wn(p,u,Yn?"junction":"dir"),s.installed.push(`${a}/${d}`),t(` done: ${d} \u2192 ${a}`)}}return s}function Hn(e,t,n,i,r){let s=new Set(Ct);for(let o of Bn(e)){if(s.has(o))continue;let c=E(e,o),a;try{a=w(pe(c),bt(c))}catch{continue}Qn(a,t)&&(vt(c),i.pruned.push(`${n}/${o}`),r(` prune: ${o} \u2192 ${n} (removed stale codebaseiq skill link)`))}}function Qn(e,t){let n=Gn(w(t),w(e));return n===""||!n.startsWith("..")&&!Un(n)}function zn(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var Rt=["repository-observation","repository-preview","mutation","composite","environment-observation","tool-information"];function Xn(e,t=[]){return{defaultRole:e,...t.length>0?{rules:t}:{}}}function Zn(e,t){for(let n of e.rules??[]){if(n.when.kind==="option-present"){let r=t.options[n.when.name];if(r!==void 0&&r!==!1)return n.role;continue}if((n.when.kind==="argument"?t.args[n.when.index]:t.options[n.when.name])===n.when.equals)return n.role}return e.defaultRole}function ei(e){return[...new Set([e.defaultRole,...(e.rules??[]).map(t=>t.role)])]}function K(e){return Rt.includes(e)}function ti(e){return e==="repository-observation"||e==="repository-preview"||e==="composite"}var fe=1,he=1,H=["compiler-graph","semantic-analysis","repository-source","change-history","runtime-measurement","heuristic","mixed","unknown"],St=["complete","partial","unknown"],Ot=["validated","failed","not-evaluated","not-applicable"],xt=["observe","advise","require-adjudication","block","not-established"],It={policyId:"codebaseiq:unresolved-repository-policy",policyVersion:he,permission:"not-established",reasons:["No repository action policy was supplied for this claim."]};function ni(e){return{schemaVersion:fe,origin:e.contract.origin,coverage:Et(e.coverage),producerValidation:e.contract.producerValidation,stateAuthority:G(e.receipt,e.receipt),repositoryPolicy:e.repositoryPolicy??It,...e.contract.families?{families:e.contract.families}:{}}}function Et(e){return e?e.complete===!0?{state:"complete",returned:e.returned,totalKnown:!0,total:e.total??e.returned,omitted:0}:e.totalKnown?{state:"partial",returned:e.returned,totalKnown:!0,...e.total===void 0?{}:{total:e.total},...e.omitted===void 0?{}:{omitted:e.omitted}}:{state:"unknown",returned:e.returned,totalKnown:!1}:{state:"unknown",returned:0,totalKnown:!1}}function ii(e,t){let n=[];return V(n,"origin",t.origins,e.origin),V(n,"coverage",t.coverage,e.coverage.state),V(n,"producer-validation",t.producerValidation,e.producerValidation.status),V(n,"state-authority",t.stateAuthority,e.stateAuthority.authority),V(n,"action-permission",t.actionPermission,e.repositoryPolicy.permission),{satisfied:n.every(i=>i.satisfied),predicates:n}}function V(e,t,n,i){n&&e.push({predicate:t,satisfied:n.includes(i),required:n,actual:i})}function me(e){return!l(e)||e.schemaVersion!==fe||!k(e.origin,H)||!ri(e.coverage)||!oi(e.producerValidation)||!si(e.stateAuthority)||!ai(e.repositoryPolicy)?!1:e.families===void 0||ci(e.families)}function ri(e){return!l(e)||!k(e.state,St)||!x(e.returned)||typeof e.totalKnown!="boolean"||e.total!==void 0&&!x(e.total)||e.omitted!==void 0&&!x(e.omitted)?!1:e.state==="complete"?e.totalKnown===!0&&e.total===e.returned&&e.omitted===0:e.state==="partial"?e.totalKnown===!0&&x(e.total)&&x(e.omitted)&&e.total===Number(e.returned)+Number(e.omitted):e.totalKnown===!1}function oi(e){if(!l(e)||!k(e.status,Ot))return!1;let t=e.certification;return e.status==="validated"||e.status==="failed"?l(t)&&g(t.id)&&Number.isSafeInteger(t.version)&&Number(t.version)>0&&g(t.corpus):t===void 0}function si(e){return l(e)&&Number.isSafeInteger(e.policyVersion)&&(e.authority==="completion"||e.authority==="advisory"||e.authority==="none")&&Array.isArray(e.requiredRelationships)&&e.requiredRelationships.every(g)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function ai(e){return l(e)&&g(e.policyId)&&e.policyVersion===he&&k(e.permission,xt)&&Array.isArray(e.reasons)&&e.reasons.every(g)}function ci(e){return Array.isArray(e)&&e.every(t=>l(t)&&g(t.id)&&g(t.selector)&&di(t.origin))}function di(e){return l(e)?e.kind==="fixed"?k(e.origin,H)&&e.origin!=="mixed":e.kind!=="result-field"||!g(e.field)||!l(e.values)?!1:Object.values(e.values).every(t=>k(t,H)&&t!=="mixed"):!1}function k(e,t){return typeof e=="string"&&t.includes(e)}var Tt="codebaseiq-result",_t=0,T=1,li=1,Pt=1,At=1;function Nt(e){if(!l(e))return{kind:"malformed",reason:"CLI JSON output must be an object."};let t=Object.hasOwn(e,"kind"),n=Object.hasOwn(e,"schemaVersion");if(!t&&!n){let o=wt(e);return o?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${o}`}:{kind:"legacy",schemaVersion:_t,envelope:e}}if(!t||!n)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==Tt)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${mi(e.kind)}.`};let i=e.schemaVersion;if(!Number.isSafeInteger(i)||Number(i)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(i!==T)return{kind:"unsupported",schemaVersion:Number(i),direction:Number(i)<T?"older":"future",...kt(e.producer)?{producer:e.producer}:{}};let r=wt(e);if(r)return{kind:"malformed",reason:`CLI JSON envelope v1: ${r}`};if(!kt(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify codebaseiq and its non-empty version."};if(!fi(e.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};let s=Mt(e.command);return s.includes(e.resultSchemaVersion)?e.evidenceContext!==void 0&&!hi(e.evidenceContext)?{kind:"malformed",reason:"CLI JSON envelope v1: evidenceContext must contain a supported receipt and analysis manifest."}:e.operationRole!==void 0&&!K(e.operationRole)?{kind:"malformed",reason:"CLI JSON envelope v1: operationRole must be a supported command operation role."}:l(e.evidenceContext)&&e.operationRole!==void 0&&e.evidenceContext.operationRole!==void 0&&e.operationRole!==e.evidenceContext.operationRole?{kind:"malformed",reason:"CLI JSON envelope v1: top-level and evidence-context operation roles must agree."}:{kind:"supported",schemaVersion:T,envelope:e}:{kind:"unsupported-result",schemaVersion:T,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:s}}function ui(e){let t=Nt(e);if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="unsupported"){let n=t.producer?` from ${t.producer.name}@${t.producer.version}`:"";throw new Error(`Unsupported codebaseiq CLI JSON schemaVersion ${t.schemaVersion}${n}; this consumer supports the legacy unversioned envelope and schemaVersion ${T}.`)}throw t.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${t.resultSchemaVersion} for codebaseiq command ${JSON.stringify(t.command)}; this consumer supports ${t.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed codebaseiq CLI JSON envelope: ${t.reason}`)}function Mt(e){return pi[e]??[li]}var pi={hotspots:[1,2],bottlenecks:[1,2],"complexity-hotspots":[1,2]};function wt(e){return typeof e.command!="string"||e.command.length===0?"command must be a non-empty string.":Array.isArray(e.args)?l(e.options)?Object.hasOwn(e,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function kt(e){return l(e)&&e.name==="codebaseiq"&&typeof e.version=="string"&&e.version.length>0}function fi(e){return Number.isSafeInteger(e)&&Number(e)>0}function hi(e){if(!l(e)||e.schemaVersion!==Pt||e.operationRole!==void 0&&!K(e.operationRole)||!B(e.receipt))return!1;let t=e.analysisManifest;return l(t)&&t.schemaVersion===At&&(t.evidence===void 0||t.evidence==="graph-fact"||t.evidence==="heuristic"||t.evidence==="mixed")&&(t.claimQualification===void 0||me(t.claimQualification))}function mi(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{xt as CLAIM_ACTION_PERMISSIONS,he as CLAIM_ACTION_POLICY_VERSION,St as CLAIM_COVERAGE_STATES,H as CLAIM_ORIGINS,fe as CLAIM_QUALIFICATION_SCHEMA_VERSION,At as CLI_ANALYSIS_MANIFEST_SCHEMA_VERSION,Pt as CLI_EVIDENCE_CONTEXT_SCHEMA_VERSION,Tt as CLI_JSON_ENVELOPE_KIND,Rt as COMMAND_OPERATION_ROLES,T as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,It as DEFAULT_REPOSITORY_POLICY_ACTION,_t as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,h as LEGACY_OBSERVATION_RECEIPT_SCHEMA_VERSION,N as OBSERVATION_IDENTITY_CANONICALIZATION_VERSION,A as OBSERVATION_IDENTITY_HASH_ALGORITHM,W as OBSERVATION_IDENTITY_SCHEMA_VERSION,R as OBSERVATION_RECEIPT_SCHEMA_VERSION,te as OBSERVATION_STATE_AUTHORITY_POLICY_VERSION,Ot as PRODUCER_VALIDATION_STATUSES,de as Watcher,Xn as commandOperation,ei as commandOperationRoles,ie as compareObservationReceipts,Le as createObservationIdentity,gt as createReindexRunner,Nt as decodeCliJsonEnvelope,ne as decodeObservationReceipt,Et as deriveClaimCoverage,ni as deriveClaimQualification,G as deriveObservationStateAuthority,ii as evaluateClaimQualification,hn as initProjectConfig,Kn as installSkills,me as isClaimQualificationV1,K as isCommandOperationRole,B as isObservationReceipt,q as loadProjectConfig,$e as observationReceiptGenerationIdentity,Be as observationReceiptStabilityLabel,We as observationReceiptWorkspaceIdentity,ti as operationObservesRepository,ui as requireCompatibleCliJsonEnvelope,Zn as resolveCommandOperationRole,z as resolveIndexStoragePaths,mt as resolveReindexWorkerLaunch,Mt as supportedCliResultSchemaVersions};
|
|
4
4
|
//# sourceMappingURL=runtime.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as V}from"./chunk-AAQQPKCU.js";import{e as E,f as A,g as U,h as O,n as C}from"./chunk-
|
|
1
|
+
import{a as V}from"./chunk-AAQQPKCU.js";import{e as E,f as A,g as U,h as O,n as C}from"./chunk-O5BWFNIH.js";import"./chunk-P5XHIJHI.js";import"./chunk-37K55EG3.js";import"./chunk-JGJKRTTB.js";import"./chunk-33AXWMO2.js";import"./chunk-DRENNWRG.js";import{A as N,B as P,C as g,D as k,F as B,j as D,l as h,r as x,s as T,v as _,w as q}from"./chunk-3F23W57G.js";import"./chunk-R2NOK63J.js";import{a as b,e as L}from"./chunk-OZI44VCR.js";import"./chunk-C3PPB2T5.js";import n from"process";import{randomUUID as H}from"crypto";import{rmSync as J}from"fs";import{resolve as f}from"path";import{pathToFileURL as W}from"url";var X=10*6e4,F=10,G=250,z=1e3;function Y(e,t,s={}){let M=_(e),d=s.now??(s.nowMs===void 0?Date.now:()=>s.nowMs),S=d(),y=A(e),w=N(M,{ownerId:s.ownerId??re,nowMs:S,limits:s.limits,owner:ne,liveness:ie}),p=0;for(let i of w){let o=null,c,m="handler-error";try{let a=P(i,s.limits),u;try{u=JSON.parse(a)}catch{throw m="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let r=U(u,{claimRequestId:i.requestId,sessionIdentity:y,nowMs:d()});if(!r.ok)throw m=r.code,c=r.responseIdentity,new Error(r.error);o=r.value,c={id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs};let l=$(o.request,s.monotonicNowMs??b());s.beforeRequest?.(l);let R=t.handle(l),I=d();if(o.deadlineAtMs<I)throw m="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");g(M,i,{ok:!0,protocolVersion:E,id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs,...R},{nowMs:I,limits:s.limits})}catch(a){let u=d(),r=c??(o?{id:o.id,sessionIdentity:o.sessionIdentity,deadlineAtMs:o.deadlineAtMs}:void 0),l=a instanceof Error?a.message:String(a);k(M,i,{ok:!1,protocolVersion:E,id:r?.id??i.requestId,...r?{sessionIdentity:r.sessionIdentity,deadlineAtMs:r.deadlineAtMs}:{},errorCode:m,error:l},l,{nowMs:u,limits:s.limits})}p+=1}return p}function $(e,t){let s=t+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:s}}}async function K(e,t){let s=_(e);q(s);let M=f(e,"server.lock"),d=ee(M);if(!d)return;let S=new O(()=>C({semanticWorkerPath:t,shareEnvironment:!0})),y=!1,w=b(),p=Number.NEGATIVE_INFINITY,i,o=0,c=L(n.pid),m=A(e),a=()=>{y=!0};n.once("SIGINT",a),n.once("SIGTERM",a);let u=(r=!1,l=r?"durable":"visibility")=>{let R=Date.now(),I=b();if(!r&&I-p<z)return;p=I;let v={protocolVersion:E,sessionIdentity:m,pid:n.pid,...c?{processIdentity:c}:{},heartbeatAtMs:R,...i===void 0?{}:{busyUntilMs:i},mailbox:B(s)};l==="durable"?T(f(e,"server.json"),v):x(f(e,"server.json"),v)};try{u(!0);let r=te();for(;!y&&b()-w<r;){let l=Y(e,S,{beforeRequest(R){i=Date.now()+R.timeoutMs+5e3,u(!0,"visibility")}});l>0?(o=0,w=b(),i=void 0,u(!0,"visibility")):(o+=1,u()),await se(Q(l,o))}}finally{S.shutdown(),J(f(e,"server.json"),{force:!0}),d.release()}}function Q(e,t=1){if(e>0)return F;let s=Math.max(0,Math.min(5,t-1));return Math.min(G,F*2**s)}var Z=e=>{let t=Number(e);return Number.isInteger(t)&&t>0?{pid:t}:null};function ee(e){let t=h(e,{kind:"rust-durable-session-server",parseLegacy:Z});return t.kind==="acquired"?t.lock:null}function te(){let e=Number(n.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:X}function se(e){return new Promise(t=>setTimeout(t,e))}var oe=n.argv[1]?W(f(n.argv[1])).href:null;if(oe===import.meta.url){V();let e=n.argv[2],t=n.argv[3];!e||!t?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),n.exitCode=1):await K(e,t)}var re=`rust-semantic-${n.pid}-${H()}`,j=L(n.pid),ne={pid:n.pid,...j?{processIdentity:j}:{}},ie={isProcessAlive:D,readProcessIdentity:L};export{ee as acquireDurableRustSessionServerLock,Q as durableSessionLoopDelayMs,Y as processDurableRustSessionRequests};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-server.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as te,b as ie,c as C,d as N,e as G,f as E,g as B,i as H,j as U,k as K,l as W,m as le,p as ce,q as ue,r as de,s as fe,t as S,v as me,w as pe,x as D}from"./chunk-Z6RL7XOE.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import{d as F,e as se,f as re,g as oe,h as ae}from"./chunk-2PRONPAS.js";import"./chunk-P4NVCOM7.js";import{a as j,j as d,k as M}from"./chunk-R2NOK63J.js";import"./chunk-6O3KXIDL.js";import{ca as q,da as ee}from"./chunk-UQYQBLJX.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,S(e.client,r,c)),o,s.deadlineMs):S(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>D(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>D(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,S(e.client,l,f)),u,o.deadlineMs):S(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>D(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>D(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
|
|
1
|
+
import{a as te,b as ie,c as C,d as N,e as G,f as E,g as B,i as H,j as U,k as K,l as W,m as le,p as ce,q as ue,r as de,s as fe,t as S,v as me,w as pe,x as D}from"./chunk-VEPK6M5C.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import{d as F,e as se,f as re,g as oe,h as ae}from"./chunk-JGJKRTTB.js";import"./chunk-33AXWMO2.js";import{a as j,j as d,k as M}from"./chunk-R2NOK63J.js";import"./chunk-OZI44VCR.js";import{ga as q,ha as ee}from"./chunk-C3PPB2T5.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,S(e.client,r,c)),o,s.deadlineMs):S(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>D(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>D(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,S(e.client,l,f)),u,o.deadlineMs):S(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>D(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>D(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-worker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q,x as r}from"./chunk-
|
|
1
|
+
import{h as b,i as c,j as d,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q,x as r}from"./chunk-VEPK6M5C.js";import{a}from"./chunk-ILMHV3KM.js";import"./chunk-JGJKRTTB.js";import"./chunk-33AXWMO2.js";import"./chunk-OZI44VCR.js";import"./chunk-C3PPB2T5.js";export{q as calleesForDefinition,l as cargoManifestsForDefinitions,i as hoverToRustSignature,h as hoverWithRetry,m as openDefinitionDocuments,p as referencesWithCompletion,o as referencesWithRetry,b as runRustAnalyzerReferenceBatch,a as runWithConcurrency,j as rustAnalyzerInitializationOptions,k as rustAnalyzerSessionRoot,d as rustRequestCalleeDefinitions,c as rustRequestReferenceDefinitions,f as rustRequestSessionDefinitions,e as rustRequestSignatureDefinitions,g as signatureForDefinition,r as sleep,n as waitForOpenedDocuments};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-worker.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a,b}from"./chunk-4XMZYLW5.js";import"./chunk-CABIZQXQ.js";import"./chunk-AJ5HVC5Z.js";import"./chunk-ZZ3MWF33.js";import"./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"./chunk-G3KRXNNT.js";import"./chunk-W6E6ME7G.js";import"./chunk-DRENNWRG.js";import"./chunk-E5U6N5WI.js";import"./chunk-SV2LEFVM.js";import"./chunk-ZJNV27DZ.js";import"./chunk-75VNTSO6.js";import"./chunk-XDQ6QJF5.js";import"./chunk-E7T22WET.js";import"./chunk-UUMAM5LM.js";import"./chunk-EDMG5CSO.js";import"./chunk-3F23W57G.js";import"./chunk-R2NOK63J.js";import"./chunk-OZI44VCR.js";import"./chunk-C3PPB2T5.js";export{a as ensureSentinelService,b as sentinelEnsureCommandDescriptor};
|
|
2
|
+
//# sourceMappingURL=sentinel-ensure-command-3MZCLPQY.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{d as a,e as b}from"./chunk-E4DP45YU.js";import"./chunk-JG5OWAEB.js";import"./chunk-DQZF7MP6.js";import"./chunk-B2OB55RR.js";import"./chunk-XZEE23VG.js";import"./chunk-OSZ7PW5K.js";import"./chunk-FPUJRBHL.js";import"./chunk-RS6UYNEP.js";import"./chunk-AZDY3EKD.js";import"./chunk-KPMMOAV5.js";import"./chunk-Z2L5H2HF.js";export{a as ensureSentinelService,b as sentinelEnsureCommandDescriptor};
|
|
3
|
+
//# sourceMappingURL=sentinel-ensure-command-LEWHIRLL.js.map
|
package/dist/sentinel-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as G}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-PCKIKOUA.js";import{a as he,b as ge,d as et,e as tt,f as nt,g as it,i as st,j as rt,l as me,m as ot}from"./chunk-E5U6N5WI.js";import{a as at}from"./chunk-SV2LEFVM.js";import{C as Qe,s as Ze}from"./chunk-ZJNV27DZ.js";import{B as Xe,l as Je,m as Ye,o as Ve,p as A,q as fe,r as C,s as pe}from"./chunk-75VNTSO6.js";import{C as We,K as Ke,L as Ge,n as He,s as ze,y as K}from"./chunk-XDQ6QJF5.js";import{a as Ue}from"./chunk-E7T22WET.js";import{e as W}from"./chunk-UUMAM5LM.js";import{g as qe}from"./chunk-EDMG5CSO.js";import{p as Be,r as je}from"./chunk-3F23W57G.js";import"./chunk-R2NOK63J.js";import"./chunk-OZI44VCR.js";import{T as z,U as k,a as le,b as de,f as ce,g as ue,h as P,n as Le}from"./chunk-C3PPB2T5.js";import{randomBytes as Gs}from"crypto";import{chmodSync as qs,existsSync as kn,mkdirSync as Js,realpathSync as Ys,renameSync as Vs,rmSync as Te,statSync as Xs}from"fs";import{createServer as Zs}from"net";import{dirname as Qs,join as _n,posix as xn}from"path";import{isMainThread as er,parentPort as En,workerData as Rn}from"worker_threads";import{createHash as Is}from"crypto";import{setImmediate as gn}from"timers/promises";function R(t){return`${t.container.join(".")}#${t.name}#${t.ordinal}`}function ye(t){let e={files:new Map,byExactHash:new Map};for(let[n,i]of t)I(e,n,i);return e}function I(t,e,n){let i=t.files.get(e);if(i)for(let s of i){let r=t.byExactHash.get(s.exactHash);if(!r)continue;let o=r.filter(a=>a.file!==e);o.length>0?t.byExactHash.set(s.exactHash,o):t.byExactHash.delete(s.exactHash)}if(!n){t.files.delete(e);return}t.files.set(e,[...n]);for(let s of n){let r=t.byExactHash.get(s.exactHash)??[];r.push({file:e,unit:s}),t.byExactHash.set(s.exactHash,r)}}function O(t,e){if(!t)return[...e];let n=new Map;for(let s of t){let r=`${s.name}\0${s.exactHash}`;n.set(r,(n.get(r)??0)+1)}let i=[];for(let s of e){let r=`${s.name}\0${s.exactHash}`,o=n.get(r)??0;o>0?n.set(r,o-1):i.push(s)}return i}function lt(t,e,n){let i=[];for(let s of e){if(s.unit.tokenCount<8)continue;let r=R(s.unit);for(let o of t.byExactHash.get(s.unit.exactHash)??[]){if(o.file===s.file&&R(o.unit)===r)continue;let a=o.unit.name===s.unit.name;s.unit.bodyLines<3&&!a||i.push({subject:s,counterpart:o,basis:s.unit.bodyLines<3?"exact-body-same-name":"exact-body",inFlight:n.isInFlight(o),crossBoundary:!n.allowsDependency(s.file,o.file)})}}return i.sort(Cn)}function Cn(t,e){return t.subject.file.localeCompare(e.subject.file)||t.subject.unit.startLine-e.subject.unit.startLine||Number(t.inFlight)-Number(e.inFlight)||t.counterpart.file.localeCompare(e.counterpart.file)||t.counterpart.unit.startLine-e.counterpart.unit.startLine}function dt(t,e){return`${t}#${R(e)}`}function ct(t,e,n){return e==="unknown"?new Set:new Set(O(e,n).map(i=>dt(t,i)))}var q=class{options;corpus=ye([]);constructor(e){this.options=e}buildCorpus(e){this.corpus=ye([]);for(let n of e)this.updateFile(n)}updateFile(e){I(this.corpus,e,this.currentUnits(e))}removeFile(e){I(this.corpus,e,null)}corpusSize(){return this.corpus.files.size}currentUnits(e){if(!this.options.isInputPath(e))return null;let n=this.options.readText(e);return n===null?null:G(this.options.db,e,n)?.units??null}analyzeEdit(e){let n=new Map,i=new Set,s=[],r=[];for(let d of e.files){let u=this.currentUnits(d.path);if(n.set(d.path,u),I(this.corpus,d.path,u),!!u){if(d.baselineUnits==="unknown"||d.baselineUnits===null&&!d.createdInSession){r.push(d.path);continue}d.createdInSession&&i.add(d.path);for(let c of O(d.baselineUnits,u))s.push({file:d.path,unit:c})}}let o=lt(this.corpus,s,{isInFlight:d=>e.inFlight.has(dt(d.file,d.unit)),allowsDependency:this.options.allowsDependency}),a=[],l=[];for(let d of o){let u=this.verify(d,n);u&&(i.has(u.subject.file)?l:a).push(u)}return{matches:a,held:l,skipped:r}}recheckHeld(e){let n=new Map;return e.flatMap(i=>this.verify(i,n)??[])}verify(e,n){let i=this.freshUnit(e.subject,n),s=this.freshUnit(e.counterpart,n);return i&&s?{...e,subject:i,counterpart:s}:null}freshUnit(e,n){n.has(e.file)||n.set(e.file,this.currentUnits(e.file));let i=R(e.unit),s=n.get(e.file)?.find(r=>R(r)===i&&r.exactHash===e.unit.exactHash);return s?{file:e.file,unit:s}:null}};var $n="codebaseiq sentinel (exact-body evidence):",ut="If a match is intended, ignore it or mark the copy with `// codebaseiq: ignore-similar`.",An="codebaseiq sentinel (unwired code):",In="Wire them in, remove them, or tell the user why they are intentionally unreferenced.",On="codebaseiq sentinel (earlier evidence, still unresolved):";function T(t){let e=s=>t.settings.delivery[s.family]==="shadow",n=t.findings.filter(e),i=jn(t.findings.filter(s=>!e(s)));return{...Tn(i,t),shadowed:n}}function Tn(t,e){switch(e.event){case"edit":case"prompt":return Mn(t,e);case"stop":return Ln(t,e);case"session-start":return Bn(t,e);case"session-end":return{delivered:[],blocked:[]}}}function Mn(t,e){let n=ft(t,e).slice(0,e.settings.maxPerDelivery);return n.length===0?{delivered:[],blocked:[]}:{modelText:[$n,...n.map(J),ut].join(`
|
|
2
2
|
`),delivered:n.map(i=>i.id),blocked:[]}}function Ln(t,e){let n=e.unverifiedReason||Un(e);if(n)return{userText:`codebaseiq sentinel unverified: ${n}`,delivered:[],blocked:[]};let i=t.filter(o=>o.family==="unwired"),s=i.filter(o=>(o.evidence==="exact"||o.evidence==="syntactic")&&!e.alreadyBlocked.has(o.id));if(e.settings.blockOnUnwired&&!e.stopHookActive&&s.length>0)return{block:!0,modelText:[An,...s.map(J),In].join(`
|
|
3
3
|
`),delivered:[],blocked:s.map(o=>o.id)};let r=[...i,...ft(t,e)];return r.length===0?{delivered:[],blocked:[]}:{userText:Hn(r,e.settings.maxPerDelivery),delivered:[],blocked:[]}}function Un({serviceStatus:t,settings:e}){return t.corpus==="ready"||!Object.values(e.delivery).includes("live")?null:`corpus ${t.corpus}`}function Bn(t,e){let n=t.slice(0,e.settings.maxPerDelivery);if(n.length===0)return{delivered:[],blocked:[]};let i=[On,...n.map(J)];return n.some(s=>s.family==="reuse-match")&&i.push(ut),{modelText:i.join(`
|
|
4
4
|
`),delivered:n.map(s=>s.id),blocked:[]}}function ft(t,e){return t.filter(n=>n.family==="reuse-match"&&!e.alreadyDelivered.has(n.id))}function jn(t){let e=new Set;return t.filter(n=>e.has(n.id)?!1:(e.add(n.id),!0))}function pt(t){if(t.family==="reuse-match")return t.summary;let{name:e,file:n,line:i}=t.subject;return`\`${e}\` (${n}:${i}) has no import or call outside tests`}function J(t){return`- ${pt(t)}`}function Hn(t,e){let n=t.slice(0,e),i=n.map(r=>r.family==="unwired"&&r.evidence!=="exact"?`- ${pt(r)} (${r.evidence} evidence)`:J(r)),s=t.length-n.length;return["codebaseiq sentinel:",...i,...s>0?[`- and ${s} more`]:[]].join(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as c,c as u}from"./chunk-
|
|
1
|
+
import{a as c,c as u}from"./chunk-CBOOHUK4.js";import"./chunk-JOYASZRF.js";import{f as d}from"./chunk-2ZBZRYX4.js";import"./chunk-G3KRXNNT.js";import"./chunk-W6E6ME7G.js";import"./chunk-DRENNWRG.js";import{C as l}from"./chunk-ZJNV27DZ.js";import"./chunk-75VNTSO6.js";import"./chunk-XDQ6QJF5.js";import"./chunk-E7T22WET.js";import"./chunk-UUMAM5LM.js";import"./chunk-EDMG5CSO.js";import"./chunk-3F23W57G.js";import{g as a,h as s}from"./chunk-R2NOK63J.js";import"./chunk-OZI44VCR.js";import"./chunk-C3PPB2T5.js";import{parentPort as p,workerData as S}from"worker_threads";var i=k(S);if(!p)throw new Error("TypeScript mailbox worker requires a parent port.");if(i.kind==="index"){let t=new c({projectRoot:i.projectRoot,currentGeneration:()=>d(i.dbPath)});p.on("message",e=>{let r=m(e);y(r,()=>t.handle(r.payload.baseGeneration,r.payload.request),()=>t.status())})}else{let t=new u({openDb:()=>l(i.projectRoot)});p.on("message",e=>{let r=m(e),o=a();s(r.payload.profileEnvironment??{});try{y(r,()=>t.handle(r.payload.generation,r.payload.request),()=>t.status())}finally{s(o)}})}function y(t,e,r){let o;try{if(Date.now()>t.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let n=e();if(Date.now()>t.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");o={kind:"response",requestId:t.requestId,ok:!0,result:n,status:r()}}catch(n){o={kind:"response",requestId:t.requestId,ok:!1,error:n instanceof Error?n.message:String(n),status:r()}}p.postMessage(o)}function k(t){if(!t||typeof t!="object")throw new Error("TypeScript mailbox worker data is missing.");let e=t;if(e.kind==="index"&&typeof e.projectRoot=="string"&&typeof e.dbPath=="string")return{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath};if(e.kind==="semantic"&&typeof e.projectRoot=="string")return{kind:"semantic",projectRoot:e.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function m(t){if(!t||typeof t!="object")throw new Error("TypeScript mailbox worker request is missing.");let e=t;if(e.kind!=="request"||typeof e.requestId!="string"||!Number.isSafeInteger(e.deadlineAtMs)||typeof e.payload!="object"||e.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return e}
|
|
2
2
|
//# sourceMappingURL=typescript-mailbox-worker.js.map
|
package/dist/watch-server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as sr}from"./chunk-DNRHRVKS.js";import{a as or}from"./chunk-WXUHXSLN.js";import{a as At,b as j,d as w,e as Ut,f as Ee,g as Qt,h as Gt,i as Ht,j as Re,k as zt,l as Yt,o as Pe}from"./chunk-BEKCTUPY.js";import{c as Zt,d as er,e as tr,f as rr,g as nr,h as ir}from"./chunk-ZUQ2MDFT.js";import{j as Xt,l as Jt,n as Kt}from"./chunk-5AJQCOZZ.js";import{a as Ot,b as Lt,c as Dt,d as xe,e as Wt,f as Ce,g as _t,i as qt,j as Nt,k as jt,o as $t,q as Ft,r as Vt,s as Bt}from"./chunk-CABIZQXQ.js";import"./chunk-AJ5HVC5Z.js";import{f as at,g as K}from"./chunk-26EZWQ24.js";import{a as ve,b as B}from"./chunk-ZZ3MWF33.js";import{N as pt,Q as ft}from"./chunk-PVKSZBX5.js";import"./chunk-YUKYB54I.js";import{a as ht}from"./chunk-AAQQPKCU.js";import"./chunk-O5BWFNIH.js";import"./chunk-P5XHIJHI.js";import"./chunk-37K55EG3.js";import"./chunk-JGJKRTTB.js";import"./chunk-33AXWMO2.js";import{b as gt,d as kt}from"./chunk-CBOOHUK4.js";import"./chunk-JOYASZRF.js";import{c as Z,d as ut,e as mt}from"./chunk-2ZBZRYX4.js";import"./chunk-G3KRXNNT.js";import"./chunk-W6E6ME7G.js";import"./chunk-DRENNWRG.js";import{c as It,d as Tt,j as Mt}from"./chunk-E5U6N5WI.js";import"./chunk-SV2LEFVM.js";import{A as be,C as Rt,E as we,F as Pt,a as Se,b as St,c as bt,e as U,h as ee,i as wt,j as N,k as xt,t as Ct,u as A,w as te,z as Et}from"./chunk-ZJNV27DZ.js";import{B as yt,D as vt}from"./chunk-75VNTSO6.js";import{c as st}from"./chunk-XDQ6QJF5.js";import{d as Ye}from"./chunk-E7T22WET.js";import"./chunk-UUMAM5LM.js";import"./chunk-EDMG5CSO.js";import{A as ct,B as dt,C as he,D as ge,E as ye,F as lt,j as it}from"./chunk-3F23W57G.js";import{a as Xe,b as Je,c as Ke,d as Ze,e as et}from"./chunk-R2NOK63J.js";import{a as W,e as _}from"./chunk-OZI44VCR.js";import{G as E,H as tt,I as rt,Q as nt,T as ot,X as q,aa as fe,b as Qe,h as J,m as Ge,n as He,o as ze}from"./chunk-C3PPB2T5.js";import v from"process";import{rmSync as $r}from"fs";import{resolve as Qn}from"path";import{pathToFileURL as Gn}from"url";var re=class{root;now;randomId;retryDelayMs;active;retryNotBeforeMs=0;currentStatus;constructor(t,r={}){this.root=t,this.now=r.now??Date.now,this.randomId=r.randomId,this.retryDelayMs=Math.max(1,Math.floor(r.retryDelayMs??1e3)),this.currentStatus=Ce(t)}initializeAfterOwnershipAcquired(){let t=Wt(this.root),r=_t(this.root,{now:()=>new Date(this.now())});return this.refreshStatus(),{recoveredClaims:t,prunedHistory:r}}observeLegacyRequest(t,r){Ot(this.root,r??"stale index observed by a legacy command",{idempotencyKey:`legacy-activity:${t}`,now:()=>new Date(t)}),this.refreshStatus()}poll(t,r){if(this.active||t.state!=="idle"||this.now()<this.retryNotBeforeMs)return!1;let i=Lt(this.root,{now:()=>new Date(this.now()),...this.randomId?{randomId:this.randomId}:{}});if(this.refreshStatus(),i.requests.length===0)return!1;this.active=i;try{return r(Vr(i)),!0}catch(n){throw xe(this.root,i),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),n}}completeActive(){return this.active?(Dt(this.root,this.active,()=>new Date(this.now())),this.active=void 0,this.retryNotBeforeMs=0,this.refreshStatus(),!0):!1}failActive(){return this.active?(xe(this.root,this.active),this.active=void 0,this.retryNotBeforeMs=this.now()+this.retryDelayMs,this.refreshStatus(),!0):!1}status(){return{...this.currentStatus}}refreshStatus(){this.currentStatus=Ce(this.root)}};function Vr(e){if(e.requests.length===1)return e.requests[0].detail;let r=[...new Set(e.requests.map(i=>i.detail))].slice(0,3).join("; ");return`${e.requests.length} coalesced refresh requests${r?`: ${r}`:""}`.slice(0,2048)}import{createHash as xn}from"crypto";import{readdirSync as Cn,statSync as En}from"fs";import{join as Ae}from"path";import{performance as Oe}from"perf_hooks";var ke;function Ie(e){ke=e}function ar(){return ke||{argv:process.argv.slice(2),execPath:process.execPath,...process.argv[1]!==void 0?{scriptPath:process.argv[1]}:{},cwd:process.cwd()}}import{Command as hn,Help as gn}from"commander";import{Option as Qr}from"commander";function Te(e){return e.evidence?e.evidence:Br.has(e.id)?"mixed":e.heuristic?"heuristic":"graph-fact"}var Br=new Set(["health","context","co-change"]);function cr(e){if(e.claims){if(e.claims.origin==="mixed"&&!e.claims.families?.length)throw new Error(`Mixed command ${e.id} must declare at least one claim family.`);return e.claims}let t=Te(e);if(t==="mixed")throw new Error(`Mixed command ${e.id} must declare claim families.`);let r=e.agent?er(e.agent.operation):[];return r.length>0&&r.every(n=>n==="repository-observation"||n==="repository-preview")?{origin:t==="heuristic"?"heuristic":"compiler-graph",observedSources:["index-generation"],producerValidation:{status:"not-evaluated"}}:{origin:"unknown",observedSources:["process"],producerValidation:{status:"not-evaluated"}}}var Ur=new Set(["EPERM","EACCES","ENOTDIR","EROFS"]);function dr(e){let t=e instanceof Error?e.message:String(e),{code:r,name:i}=e??{};return typeof r=="string"&&Ur.has(r)?`error: ${t} (codebaseiq cannot write here; set ${tt}=1 to query an existing index without writing, or set CODEBASEIQ_CACHE_DIR to a writable directory)`:i==="CacheOwnershipError"?`error: ${t} (CODEBASEIQ_CACHE_DIR must name a directory that only this project uses)`:`error: ${t}`}function lr(e,t){return rr(new Map(t.map(r=>[r.id,Te(r)]))),ir(new Map(t.map(r=>[r.id,cr(r)]))),nr(new Map(t.flatMap(r=>r.agent?[[r.id,{...r.agent,resultUnits:Hr(r)}]]:[]))),t.map(r=>{let i=r.hidden?e.command(r.command,{hidden:!0}):e.command(r.command);i.description(r.description),r.helpAfter&&i.addHelpText("after",`
|
|
2
2
|
${r.helpAfter.trim()}
|
|
3
|
-
`);for(let n of r.arguments??[])i.argument(n.name);for(let n of r.options??[])if(n.hidden){let o=new
|
|
4
|
-
`)}import{existsSync as
|
|
5
|
-
`)}function
|
|
6
|
-
`)}catch{}}async function
|
|
7
|
-
`).map(n=>n.trim()).filter(Boolean),[r,i]=t;if(!/^[0-9a-f]{40,64}$/.test(r??"")||!/^[0-9a-f]{40,64}$/.test(i??""))throw new Error("git did not report a resolved HEAD tree");return{headCommit:r,treeOid:i}}function hn(e){return hr("git",["-C",e,"status","--porcelain=v1","-z","--untracked-files=all","--no-renames","--","."],{...gr(),timeout:Te}).split("\0").filter(t=>t.length>=4&&t[2]===" ").map(t=>t.slice(3))}function gn(e){try{return mn(e).isFile()?Qe(e,{maxBytes:Ue,inputKind:"project-file"}):null}catch{return null}}var E=class extends Error{constructor(r,i){super(i);this.code=r}code};function xr(e){let t=!1,r,i=()=>{let d=r;if(r=void 0,!!d)try{d.db.close()}catch{}},n=()=>{let d=e.indexGeneration();if(!d)throw new E("stale-index","The resident index is not idle-fresh; run the command in-process.");return d},o=d=>{let c=e.observation();if(!c||c.published.generation!==d)throw new E("stale-index","No provable observation is bound to the published generation; run the command in-process.");let u=vr(e.projectRoot,c.published,{epoch:c.epoch,changeSequence:c.changeSequence});if(!u.continuous)throw new E("stale-index",`${u.reason}; run the command in-process.`)},a=()=>{let d=n(),c=xn(e.projectRoot);if(r&&(r.generation!==d||r.stamp!==c||N(e.dbPath)!==d)&&i(),!r){let u=xt(e.projectRoot);if(N(e.dbPath)!==d){try{u.close()}catch{}throw new E("stale-index","The published generation moved while opening the resident database.")}r={generation:d,stamp:c,db:u}}return r.db},l=d=>{if(!Se(d))throw new E("ineligible-command",`Command ${d} always executes in-process.`);n();let c=ee(e.projectRoot,_(e.projectRoot));if(c.dbPathSource!=="configured")throw new E("stale-index","The resident host does not serve fallback index locations.");A(c)};return{execute:async d=>{if(t)return U("busy","The resident host is executing another request; run the command in-process.");let c=d.argv[0];if(!c||c.startsWith("-")||!Se(c))return U("ineligible-command","Only evidence commands are served by the resident host.");let u;try{u=n(),o(u)}catch(p){return Sr(p)}t=!0;let f=Ae.now(),s=new Oe(d.tty),h=wn(d.envAllowlist),g=process.exitCode;process.exitCode=0,ke({argv:d.argv,execPath:d.clientInvocation?.execPath??process.execPath,...d.clientInvocation?.scriptPath!==void 0?{scriptPath:d.clientInvocation.scriptPath}:{},cwd:d.cwd}),be(a);try{let{program:p}=await fr({invocationCommand:c,resident:{preAction:l}});s.install();try{await p.parseAsync([...d.argv],{from:"user"})}finally{s.restore()}let b=typeof process.exitCode=="number"?process.exitCode:0;return{ok:!0,kind:"executed",protocolVersion:w,serverPid:process.pid,exitCode:b,stdout:s.stdout(),stderr:s.stderr(),generation:u,durationMs:Ae.now()-f}}catch(p){return p instanceof E?Sr(p):bn(p)?{ok:!0,kind:"executed",protocolVersion:w,serverPid:process.pid,exitCode:p.exitCode,stdout:s.stdout(),stderr:s.stderr(),generation:u,durationMs:Ae.now()-f}:U("execution-error",`Resident execution failed: ${p instanceof Error?p.message:String(p)}`)}finally{be(void 0),ke(void 0),A(void 0),process.exitCode=g,h(),t=!1}},releaseDatabase:i}}function U(e,t){return{ok:!1,protocolVersion:w,code:e,message:t}}function Sr(e){return e instanceof E?U(e.code,e.message):U("execution-error",e instanceof Error?e.message:String(e))}function bn(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&(e.code.startsWith("commander.")||e.code==="commander")&&typeof e.exitCode=="number"}function wn(e){let t=new Map;for(let r of Ft){t.set(r,process.env[r]);let i=e?.[r];i===void 0?delete process.env[r]:process.env[r]=i}return()=>{for(let[r,i]of t)i===void 0?delete process.env[r]:process.env[r]=i}}var Oe=class{constructor(t){this.tty=t}tty;stdoutChunks=[];stderrChunks=[];restorers=[];install(){this.restorers=[br(process.stdout,this.stdoutChunks),br(process.stderr,this.stderrChunks),ne(process.stdout,"isTTY",this.tty?.isTTY??!1),ne(process.stderr,"isTTY",this.tty?.isTTY??!1),ne(process.stdout,"columns",this.tty?.columns),ne(process.stderr,"columns",this.tty?.columns)]}restore(){for(let t of this.restorers.reverse())t();this.restorers=[]}stdout(){return this.stdoutChunks.join("")}stderr(){return this.stderrChunks.join("")}};function br(e,t){let r=e.write,i=(n,o,a)=>{t.push(typeof n=="string"?n:Buffer.isBuffer(n)?n.toString(typeof o=="string"?o:"utf8"):String(n));let l=typeof a=="function"?a:typeof o=="function"?o:void 0;return typeof l=="function"&&l(),!0};return e.write=i,()=>{e.write=r}}function ne(e,t,r){let i=Object.hasOwn(e,t),n=i?Object.getOwnPropertyDescriptor(e,t):void 0;return r===void 0?i&&Reflect.deleteProperty(e,t):Object.defineProperty(e,t,{value:r,configurable:!0,writable:!0}),()=>{n?Object.defineProperty(e,t,n):Reflect.deleteProperty(e,t)}}function xn(e){let t=yn("sha256");for(let i of[".codebaseiq.json",".codebaseiq-baseline.json"])t.update(i),t.update(wr(Me(e,i)));let r=Me(e,".codebaseiq","suppressions");t.update(r);try{for(let i of vn(r).sort())t.update(i),t.update(wr(Me(r,i)))}catch{t.update("absent")}return t.digest("hex")}function wr(e){try{let t=Sn(e);return`${t.size}:${t.mtimeMs}`}catch{return"absent"}}import{chmodSync as Cn,mkdirSync as Rn,rmSync as Cr}from"fs";import{createServer as En}from"net";import{dirname as Pn}from"path";var Rr=1e4,kn=5e3,In=6e5;function Er(e){let t=pe(e.projectRoot),r=0,i,n,o=new Set,a=En(c=>{o.add(c),c.setTimeout(Rr,()=>c.destroy()),c.on("error",()=>c.destroy()),c.on("close",()=>o.delete(c));let u=Qt(Vt,f=>{r+=1,i=new Date().toISOString(),e.onActivity?.(),l(f,c).then(s=>d(c,s)).catch(s=>{n=s instanceof Error?s.message:String(s),c.destroy()})},f=>{n=f.message,d(c,{ok:!1,protocolVersion:w,code:"invalid-request",message:f.message})});c.on("data",f=>{try{u.push(f)}catch(s){n=s instanceof Error?s.message:String(s),c.destroy()}})}),l=async(c,u)=>{let f=Gt(c);return f?pe(f.projectRoot)!==t?{ok:!1,protocolVersion:w,code:"wrong-project",message:"This query lane serves a different project root."}:y(f,u):{ok:!1,protocolVersion:w,code:"invalid-request",message:"The query lane received a request it could not validate."}},y=async(c,u)=>{if(c.kind==="ping"){let s=e.indexGeneration();return{ok:!0,kind:"pong",protocolVersion:w,serverPid:process.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{},cliVersion:e.cliVersion,projectRoot:t,...s?{indexGeneration:s}:{}}}if(!e.execute)return{ok:!1,protocolVersion:w,code:"unsupported",message:"Resident execution is not enabled on this service; run the command in-process."};let f=Math.max(c.deadlineMs??Bt,Rr);u.setTimeout(Math.min(f+kn,In));try{u.write(Re({ok:!0,kind:"accepted",protocolVersion:w,serverPid:process.pid},Ce))}catch(s){return n=s instanceof Error?s.message:String(s),u.destroy(),{ok:!1,protocolVersion:w,code:"execution-error",message:"The query lane could not acknowledge the request."}}try{return await e.execute(c)}catch(s){return n=s instanceof Error?s.message:String(s),{ok:!1,protocolVersion:w,code:"execution-error",message:`Resident execution failed: ${n}`}}},d=(c,u)=>{try{c.end(Re(u,Ce))}catch(f){n=f instanceof Error?f.message:String(f),c.destroy()}};return process.platform!=="win32"&&(Rn(Pn(e.socketPath),{recursive:!0,mode:448}),Cr(e.socketPath,{force:!0})),new Promise((c,u)=>{a.once("error",u),a.listen(e.socketPath,()=>{if(a.removeListener("error",u),a.on("error",f=>{n=f.message}),process.platform!=="win32")try{Cn(e.socketPath,384)}catch{}c({status:()=>({protocolVersion:w,socketPath:e.socketPath,requests:r,...i!==void 0?{lastRequestAt:i}:{},...n!==void 0?{lastError:n}:{}}),close:()=>new Promise(f=>{for(let s of o)s.destroy();a.close(()=>{process.platform!=="win32"&&Cr(e.socketPath,{force:!0}),f()})})})})})}import{randomUUID as Mn}from"crypto";import{Worker as An}from"worker_threads";var ie=class{constructor(t){this.options=t;this.now=t.now??Date.now,this.setTimer=t.setTimer??setTimeout,this.clearTimer=t.clearTimer??clearTimeout}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}start(t){if(!this.canAccept())return!1;if(t.deadlineAtMs<this.now()){try{this.options.onReject(t,`${this.options.name} request expired before processing.`)}catch(o){this.closed=!0,this.options.onFatal(Le(o))}return!0}let r=this.ensureWorker(),i=Math.max(1,Math.min(2147483647,t.deadlineAtMs-this.now())),n=this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},i);this.active={request:t,timer:n};try{r.postMessage({kind:"request",...t})}catch(o){this.failActiveAfterTermination(Pr(o))}return!0}async close(t=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.active){await this.failActiveAfterTermination(t);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let t=this.options.createWorker(),r=++this.workerGeneration;return t.on("message",i=>this.handleMessage(r,i)),t.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`)}),t.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`))}),this.worker=t,t}handleMessage(t,r){if(t!==this.workerGeneration||this.closed||!this.active)return;let i=Tn(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status)}catch(o){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(Le(o));return}this.releaseActive(n)}async failActiveAfterTermination(t){if(this.activeFailure){await this.activeFailure;return}let r=this.active;if(!r){await this.terminateWorker();return}this.clearTimer(r.timer);let i=(async()=>{if(await this.terminateWorker()){try{this.options.onReject(r.request,t)}catch(o){this.closed=!0,this.options.onFatal(Le(o));return}this.releaseActive(r)}})();this.activeFailure=i;try{await i}finally{this.activeFailure===i&&(this.activeFailure=null)}}releaseActive(t){this.active===t&&(this.active=null,this.clearTimer(t.timer))}async terminateWorker(){if(this.terminating)return this.terminating;let t=this.worker;if(!t)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await t.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Pr(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function Tn(e){if(!e||typeof e!="object")return null;let t=e;if(t.kind!=="response"||typeof t.requestId!="string"||!("status"in t))return null;if(t.ok===!0){if(!("result"in t)||"error"in t)return null}else if(t.ok===!1){if("result"in t||typeof t.error!="string")return null}else return null;return t}function Le(e){return e instanceof Error?e:new Error(String(e))}function Pr(e){return e instanceof Error?e.message:String(e)}function kr(e){let t=()=>({protocolVersion:K,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return Tr({name:"TypeScript index",paths:e.paths,now:e.now,limits:e.limits,initialStatus:t,parseEnvelope:dt,createWorker:()=>Mr(e,{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath}),complete(r,i,n,o){fe(e.paths,r,{ok:!0,protocolVersion:K,id:i.id,baseGeneration:i.baseGeneration,response:n},{nowMs:o,limits:e.limits})},reject(r,i,n,o){he(e.paths,r,{ok:!1,protocolVersion:K,id:i,error:n},n,{nowMs:o,limits:e.limits})},onBusy:e.onBusy,onFatal:e.onFatal})}function Ir(e){let t=()=>({protocolVersion:Z,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return Tr({name:"TypeScript semantic",paths:e.paths,now:e.now,limits:e.limits,initialStatus:t,parseEnvelope:St,createWorker:()=>Mr(e,{kind:"semantic",projectRoot:e.projectRoot}),complete(r,i,n,o){fe(e.paths,r,{ok:!0,protocolVersion:Z,id:i.id,generation:i.generation,response:n},{nowMs:o,limits:e.limits})},reject(r,i,n,o){he(e.paths,r,{ok:!1,protocolVersion:Z,id:i,error:n},n,{nowMs:o,limits:e.limits})},onBusy:e.onBusy,onFatal:e.onFatal})}function Tr(e){let t=e.now??Date.now,r=q(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${e.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${Mn()}`,o={...e.limits,maxBatch:1},a=null,l=e.initialStatus(),y=!1,d=s=>{y=!0,e.onFatal(s)},c=new ie({name:e.name,createWorker:e.createWorker,now:t,onComplete(s,h,g){let p=u(s.requestId);l=g,e.complete(p.claim,p.envelope,h,t()),f(p)},onReject(s,h,g){let p=u(s.requestId);g!==void 0&&(l=g),e.reject(p.claim,p.envelope.id,h,t()),f(p)},onStatus(s){l=s},onFatal:d});return{poll(){if(y||!c.canAccept())return 0;let s=ot(e.paths,{ownerId:n,nowMs:t(),limits:o,owner:i,liveness:{isProcessAlive:tt,readProcessIdentity:q}})[0];if(!s)return 0;let h=s.requestId;try{let g=e.parseEnvelope(st(s,o));if(h=g.id,g.id!==s.requestId)throw new Error(`${e.name} request identity does not match its mailbox path.`);if(g.deadlineAtMs<t())throw new Error(`${e.name} request expired before processing.`);if(a={claim:s,envelope:g},e.onBusy?.(g.deadlineAtMs),!c.start({requestId:g.id,deadlineAtMs:g.deadlineAtMs,payload:g}))throw new Error(`${e.name} worker lane closed admission after claiming a request.`)}catch(g){let p=Ln(g);try{e.reject(s,h,p,t()),a?.claim===s&&f(a)}catch(b){d(On(b))}}return 1},status(){return{...l,mailbox:at(e.paths)}},async close(s){await c.close(s)}};function u(s){let h=a;if(!h||h.envelope.id!==s)throw new Error(`${e.name} parent lost the active mailbox claim.`);return h}function f(s){a===s&&(a=null,e.onBusy?.(void 0))}}function Mr(e,t){if(e.createWorker)return e.createWorker(t);let r=e.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new An(r,{workerData:t})}function On(e){return e instanceof Error?e:new Error(String(e))}function Ln(e){return e instanceof Error?e.message:String(e)}import{existsSync as Wn}from"fs";import{fileURLToPath as Ar}from"url";import{Worker as Dn}from"worker_threads";var qn=2e3;function Wr(e){let t=e.userCacheRoot??Et(),r={kind:"sentinel-worker",projectRoot:e.projectRoot,cacheDir:e.indexPaths.cacheDir,dbPath:e.indexPaths.dbPath,cliVersion:e.cliVersion,userCacheRoot:t},i=e.createWorker??_n,n,o=0,a=!1,l=!1,y,d=()=>{let s;try{s=i(r)}catch(p){e.log(`worker could not be started: ${Lr(p)}`);return}let h,g={worker:s,exited:new Promise(p=>{h=p})};n=g,s.on("message",p=>{n===g&&c(p)}),s.on("error",p=>e.log(`worker failed: ${p.message}`)),s.on("exit",p=>{if(h(),n===g&&(n=void 0,o=0,!l)){if(e.log(`worker exited unexpectedly with code ${p}`),Or(t,e.projectRoot),a){e.log("worker will not be restarted again");return}a=!0,d()}})},c=s=>{let h=Nn(s);h?.kind==="sessions"?o=h.live:h?.kind==="log"&&e.log(h.message)},u=s=>{try{n?.worker.postMessage(s)}catch(h){e.log(`${s.kind} could not be posted: ${Lr(h)}`)}},f=async()=>{l=!0;let s=n;s&&(u({kind:"shutdown"}),await jn(s.exited,e.stopTimeoutMs??qn),n===s&&(n=void 0,await s.worker.terminate().catch(()=>{}))),o=0,Or(t,e.projectRoot)};return d(),{filesChanged:s=>u({kind:"filesChanged",paths:s}),generationPublished:()=>u({kind:"generationPublished"}),releaseDb:()=>u({kind:"releaseDb"}),liveSessionCount:()=>o,stop:()=>y??=f()}}function Dr(){let e,t=!1;return{attach(r){e=r},filesChanged:r=>e?.filesChanged(r),bulkChange:()=>e?.filesChanged([]),watcherStatus(r){r.state==="idle"?t=!1:e&&!t&&(t=!0,e.releaseDb())},generationPublished(){t=!1,e?.generationPublished()},liveSessionCount:()=>e?.liveSessionCount()??0,async stop(){await e?.stop()}}}function _n(e){let t=new URL("./sentinel-worker.js",import.meta.url);if(!Wn(Ar(t)))throw new Error(`sentinel worker was not found at ${Ar(t)}. Run npm run build first.`);let r=new Dn(t,{workerData:e});return r.unref(),r}function Nn(e){if(typeof e!="object"||e===null)return;let{kind:t,live:r,message:i}=e;if(t==="sessions"&&typeof r=="number"&&Number.isInteger(r)&&r>=0)return{kind:t,live:r};if(t==="log"&&typeof i=="string")return{kind:t,message:i}}function Or(e,t){try{kt(e,Pt(t),process.pid)}catch{}}async function jn(e,t){let r,i=new Promise(n=>{r=setTimeout(n,t)});try{await Promise.race([e,i])}finally{clearTimeout(r)}}function Lr(e){return e instanceof Error?e.message:String(e)}var Bn=1e3,Fn=250,Un=6e4,Qn=10,Gn=50,Hn=250;function zn(e,t=1){if(e>0)return Qn;let r=Math.max(0,Math.min(3,t-1));return Math.min(Hn,Gn*2**r)}async function Yn(e,t){let r=t.processIndexRequests(),i=t.processSemanticRequests(),n=r+i,o=n>0?0:e+1;if(t.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),t.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!0};let a=zn(n,o);return await t.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!1,delayMs:a}}function Xn(e,t=v.env){return e==="fresh"||t.CODEBASEIQ_SENTINEL_ENSURE==="1"?null:{kind:"watch-startup",detail:`index ${e} when watch service started`}}async function Jn(e,t,r={}){let i=qt(e,t),n=i.projectRoot;v.env.CODEBASEIQ_PROJECT_ROOT=n;let o=ft(n);o.watch={...o.watch,...r};let a=ht(o);if(!a.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let l=et(n,o),y=ut(l.cacheDir),d=q(v.pid),c=jt(y.lockPath,n,{readProcessIdentity:m=>m===v.pid?d:q(m)});if(!c.acquired)return;let u=new te(y.refreshRequestsPath,{retryDelayMs:Math.max(1e3,a.cooldownMs)});u.initializeAfterOwnershipAcquired();let f=Date.now(),s=D(),h=f,g=s,p={state:"idle"},b,Q,P,G,oe=J(l.dbPath),se=!1,We=!1,De=0,qe=Number.NEGATIVE_INFINITY,_e=Number.NEGATIVE_INFINITY,Ne=Number.NEGATIVE_INFINITY,je=Number.NEGATIVE_INFINITY,ae,ce,$e=0,de=vt(l.cacheDir),le=ct(l.cacheDir);Rt(de),pt(le);let H,$,L,Ve=o.sentinel?.enabled===!0,I=Dr(),Be=m=>{if(L=void 0,!!m)try{let x=_(n);if(!x?.headCommit||!x.treeOid)return;let S=ze(X(l.metaPath,"reindex metadata"));if(S.kind!=="legacy"&&S.kind!=="supported")return;let k=He(S.metadata.fingerprint);if(!k)return;L=yr({generation:m,...W.observation(),headCommit:x.headCommit,treeOid:x.treeOid,snapshot:k,config:o})}catch{}},C=(m=!1,x=m?"durable":"visibility")=>{if(!We)return;let S=Date.now(),k=D();!m&&k-qe<Bn||(qe=k,_t(y.statePath,{version:1,protocolVersion:lt,pid:v.pid,...d?{processIdentity:d}:{},projectRoot:n,...i.worktreeId?{worktreeId:i.worktreeId}:{},cliVersion:t,startedAt:new Date(f).toISOString(),heartbeatAt:new Date(S).toISOString(),lastActivityAt:new Date(h).toISOString(),...a.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date((I.liveSessionCount()>0?S:h)+a.idleTimeoutMs).toISOString()},watcher:p,...p.state==="idle"&&b?{indexGeneration:b}:{},...Q?{lastRefresh:Q}:{},...P?{lastError:P}:{},reindexActivity:oe,refreshRequests:u.status(),typescriptSemantic:{...ue.status(),...ae===void 0?{}:{busyUntil:new Date(ae).toISOString()}},typescriptIndex:{...me.status(),...ce===void 0?{}:{busyUntil:new Date(ce).toISOString()}},...H?{queryLane:H.status()}:{}},{durability:x}))},T=()=>{h=Date.now(),g=D()},Fe=m=>{T(),G??=m,P={at:new Date().toISOString(),message:m.message},C(!0,"visibility")},ue=Ir({paths:de,projectRoot:n,onBusy(m){ae=m===void 0?void 0:m+5e3,C(!0,"visibility")},onFatal:Fe}),me=kr({paths:le,projectRoot:n,dbPath:l.dbPath,onBusy(m){ce=m===void 0?void 0:m+5e3,C(!0,"visibility")},onFatal:Fe}),W=new It({projectRoot:n,config:{...o,watch:a},outputDb:l.dbPath,languages:o.languages,onStatus(m){p=m,I.watcherStatus(m),m.state!=="idle"&&(b=void 0,L=void 0,$?.releaseDatabase(),T()),C(!0)},...Ve?{onFileChanged:I.filesChanged,onBulkChange:I.bulkChange}:{},onReindexComplete(){T();let m=ve(n,o,l);return Q=m.lastRefresh,b=m.state==="fresh"?N(l.dbPath)??void 0:void 0,Be(b),oe=J(l.dbPath),u.completeActive(),P=void 0,C(!0),I.generationPublished(),m.state==="fresh"},onReindexError(){u.failActive()},onRefreshSuppressed(m){let x=it(l.dbPath,m);x.state==="failed"&&(P={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${x.reason}`},C(!0,"visibility")),oe=J(l.dbPath)},onError(m){T(),b=void 0,L=void 0,P={at:new Date().toISOString(),message:m.message},C(!0)}}),z=()=>{se=!0};v.once("SIGINT",z),v.once("SIGTERM",z);let V=!1,Y,B;try{try{$=v.env.CODEBASEIQ_DAEMON==="1"||o.daemon?.enabled===!0?xr({projectRoot:n,dbPath:l.dbPath,indexGeneration:()=>b,observation:()=>L?{published:L,...W.observation()}:void 0}):void 0,H=await Er({socketPath:Ut(l.cacheDir),projectRoot:n,cliVersion:t,...d?{processIdentity:d}:{},indexGeneration:()=>b,onActivity:T,...$?{execute:k=>$.execute(k)}:{}})}catch(S){P={at:new Date().toISOString(),message:`Query lane did not start: ${S instanceof Error?S.message:String(S)}`}}Ve&&I.attach(Wr({projectRoot:n,indexPaths:l,cliVersion:t,log(S){v.env.CODEBASEIQ_DEBUG&&console.error(`sentinel: ${F(S)}`)}})),W.start();let m=ve(n,o,l);Q=m.lastRefresh,b=m.state==="fresh"?N(l.dbPath)??void 0:void 0,Be(b);let x=Xn(m.state);for(x&&W.requestRefresh(x,{immediate:!0}),T(),We=!0,C(!0);!se;){let S=await Yn($e,{processIndexRequests:()=>me.poll(),processSemanticRequests:()=>ue.poll(),afterMailboxPoll:({processedRequests:k})=>{let O=D();if(O-je>=Un&&(je=O,ge(le),ge(de)),O-Ne>=6e4&&(Ne=O,j(n,t)),O-_e>=Fn){_e=O;let M=Nt(y.activityPath);M&&M.atMs>h&&(h=M.atMs,g=O),M?.refreshRequestedAtMs!==void 0&&M.refreshRequestedAtMs>De&&(De=M.refreshRequestedAtMs,u.observeLegacyRequest(M.refreshRequestedAtMs,M.refreshDetail??"stale index observed by a legacy command")),u.poll(p,_r=>{T(),W.requestRefresh({kind:"watch-demand",detail:_r},{immediate:!0})})}k>0&&(T(),C(!0,"visibility")),C()},shouldStop:()=>se||G!==void 0||$t({watcher:p,lastActivityAtMs:g,nowMs:D(),idleTimeoutMs:a.idleTimeoutMs,liveSessions:I.liveSessionCount()}),wait:Kn});if($e=S.consecutiveIdlePolls,S.stopped)break}}catch(m){V=!0,Y=m}finally{v.off("SIGINT",z),v.off("SIGTERM",z),await H?.close(),await I.stop(),$?.releaseDatabase(),await Promise.all([ue.close("TypeScript semantic service stopped before completing the request."),me.close("TypeScript index service stopped before completing the request.")]);let m=await W.stop();m.state==="stopped"?(qr(y.statePath,{force:!0}),qr(y.activityPath,{force:!0}),c.release()):(P={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${m.reasons.join("; ")}`},C(!0),B=new Error(P.message))}if(!V&&G&&(V=!0,Y=G),V&&B)throw new AggregateError([Y,B],"Watch service execution and shutdown both failed.");if(V)throw Y;if(B)throw B}function Kn(e){return new Promise(t=>setTimeout(t,e))}function Zn(e,t={report:r=>console.error(r),exit:r=>v.exit(r)}){return t.report(`watch-service: ${F(e instanceof Error?e.message:String(e))}`),t.exit(1)}var ei=v.argv[1]?Vn($n(v.argv[1])).href:null;if(ei===import.meta.url){mt();let e=v.argv[2],t=v.argv[3],r=ti(v.argv[4]);if(!e||!t)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await Jn(e,t,r)}catch(i){Zn(i)}}function ti(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}export{Yn as runWatchServiceLoopIteration,Jn as runWatchServiceServer,Xn as startupRefreshTrigger,Zn as terminateWatchServiceProcess,zn as watchServiceLoopDelayMs};
|
|
3
|
+
`);for(let n of r.arguments??[])i.argument(n.name);for(let n of r.options??[])if(n.hidden){let o=new Qr(n.flags,n.description).hideHelp();n.parser&&o.argParser(n.parser),Object.hasOwn(n,"defaultValue")&&o.default(n.defaultValue),i.addOption(o)}else n.parser&&Object.hasOwn(n,"defaultValue")?i.option(n.flags,n.description,n.parser,n.defaultValue):n.parser?i.option(n.flags,n.description,n.parser):Object.hasOwn(n,"defaultValue")?i.option(n.flags,n.description,n.defaultValue):i.option(n.flags,n.description);return i.action(async(...n)=>{try{let o=i.optsWithGlobals();Gr(o);let a=ar(),l=()=>r.id===Xt?r.handler(...n):Jt({command:r.id,producerVersion:E,invocationPrefix:a.scriptPath?[a.execPath,a.scriptPath]:["codebaseiq"],argv:[...a.argv],cwd:a.cwd,json:o.json===!0,sourceSession:o.session!==!1,reemitSource:o.reemit===!0,...typeof o.outputPageSize=="number"?{pageSize:o.outputPageSize}:{},...typeof o.outputCursor=="string"?{cursor:o.outputCursor}:{}},()=>r.handler(...n)),y=r.agent?Zt(r.agent.operation,{args:n.slice(0,-1),options:o}):void 0;await(y?tr(y,l):l())}catch(o){zr(o)}finally{A(void 0),U(void 0),bt()}}),{descriptor:r,command:i}})}function Gr(e){if(e.resultOnly===!0&&e.json!==!0)throw new Error("--result-only requires --json.");if(e.compact===!0&&e.json!==!0)throw new Error("--compact requires --json.")}function Hr(e){let t=e.agent?.resultUnits;if(t?.kind==="field"&&t.field.trim()==="")throw new Error(`Command ${e.id} declares an empty result-unit field.`);return t||(e.renderShape==="list"||e.renderShape==="table"||e.renderShape==="grouped-by-file"?{kind:"rows"}:{kind:"report"})}function zr(e){console.error(B(dr(e))),process.exitCode=1}var Yr=new Set(Pe),ur=new Map(Pe.map((e,t)=>[e,t])),Xr=new Set(["Navigation","Graph","Impact","Exploration"]),Jr=new Set(["Cleanup","Health"]),Kr=new Set(["Indexing","Core","Maintenance"]);function Zr(e){if(e.hidden||e.agent?.semantic?.compatibility==="deprecated")return"compatibility";if(Yr.has(e.id))return"primary-exploration";let t=e.docs?.category;if(t&&Xr.has(t))return"specialized-analysis";if(t&&Jr.has(t))return"quality-cleanup";if(t&&Kr.has(t))return"maintenance";if(t==="Formal Models")return"formal-modeling";throw new Error(`Visible command ${e.id} has no cockpit panel (docs category: ${t??"missing"}).`)}function en(e,t={}){return[{id:"primary-exploration",title:"Primary exploration",purpose:"Locate exact referents, project chosen relationships, and read only named implementation gaps."},{id:"specialized-analysis",title:"Specialized analysis",purpose:"Run a named graph, impact, or structural analysis when that exact analysis answers the task."},{id:"quality-cleanup",title:"Quality and cleanup",purpose:"Evaluate repository quality, cleanup candidates, and configured architecture findings."},{id:"maintenance",title:"Maintenance",purpose:"Build, inspect, configure, and maintain the project index and local integrations."},{id:"formal-modeling",title:"Formal modeling",purpose:"Create, verify, and check explicit state-machine models and traces."},{id:"compatibility",title:"Compatibility and deprecated controls",purpose:"Preserved invocation surfaces for existing consumers; do not choose these for new workflows."}].map(n=>({...n,commands:e.filter(o=>Zr(o)===n.id).sort((o,a)=>n.id==="primary-exploration"?(ur.get(o.id)??Number.MAX_SAFE_INTEGER)-(ur.get(a.id)??Number.MAX_SAFE_INTEGER):0)})).filter(n=>n.commands.length>0&&(t.includeCompatibility||n.id!=="compatibility"))}function mr(e,t,r={}){let i=[`Usage: ${e.name()} [options] [command]`,"",e.description(),"","Options:"],n=e.options.map(a=>a.flags),o=Math.max(...n.map(a=>a.length),0);for(let a of e.options)i.push(` ${a.flags.padEnd(o)} ${a.description}`);i.push(` ${"-h, --help".padEnd(o)} Display this grouped command help`);for(let a of en(t,r)){i.push("",`${a.title}:`,` ${a.purpose}`);let l=Math.max(...a.commands.map(y=>y.command.length),0);for(let y of a.commands)i.push(` ${y.command.padEnd(l)} ${y.description}`)}return r.includeCompatibility||i.push("","Run `codebaseiq --help-all` to include compatibility and deprecated controls."),i.push("Run `codebaseiq <command> --help` for one control's options and examples.",""),i.join(`
|
|
4
|
+
`)}import{existsSync as tn,mkdirSync as rn,writeFileSync as nn}from"fs";import{homedir as on}from"os";import{join as ne}from"path";var sn=1440*60*1e3,fr="update-check.json",an="https://registry.npmjs.org/codebaseiq/latest";async function hr(e={}){let t=e.env??process.env;if(t.CODEBASEIQ_UPDATE_CHECK==="0"||t.NO_UPDATE_NOTIFIER||rt(t))return;let r=e.cacheDir??ln(t),i=e.now??Date.now(),n=e.currentVersion??E,o=un(r),a=o&&i-o.checkedAt<sn?o.latestVersion:await mn(r,e.fetchLatestVersion??fn,i);if(!a||!dn(a,n))return;(e.writeNotice??(y=>console.error(y)))(cn(n,a))}function cn(e,t){return[`codebaseiq update available: ${e} -> ${t}.`,"Agent: tell your human to update with: npm install -g codebaseiq@latest",""].join(`
|
|
5
|
+
`)}function dn(e,t){let r=pr(e),i=pr(t);if(!r||!i)return e!==t;for(let n=0;n<r.length;n++){let o=r[n]-i[n];if(o>0)return!0;if(o<0)return!1}return!1}function ln(e){let t=e.XDG_CACHE_HOME||ne(on(),".cache");return ne(t,"codebaseiq")}function un(e){let t=ne(e,fr);if(!tn(t))return null;try{let r=JSON.parse(J(t,"update notice cache"));return typeof r.checkedAt=="number"&&(typeof r.latestVersion=="string"||r.latestVersion===null)?{checkedAt:r.checkedAt,latestVersion:r.latestVersion}:null}catch{return null}}async function mn(e,t,r){let i;try{i=await t()}catch{i=null}return pn(e,{checkedAt:r,latestVersion:i}),i}function pn(e,t){try{rn(e,{recursive:!0}),nn(ne(e,fr),`${JSON.stringify(t,null,2)}
|
|
6
|
+
`)}catch{}}async function fn(){let e=await fetch(an,{signal:AbortSignal.timeout(1e3)});if(!e.ok)return null;let t=await e.json();return typeof t.version=="string"?t.version:null}function pr(e){let t=/^v?(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/.exec(e);return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}async function vr(e={}){let t=new hn;e.resident&&t.exitOverride(),e.terminalOutput&&t.configureOutput({writeOut:n=>process.stdout.write(ve(n)),writeErr:n=>process.stderr.write(ve(n))}),t.name("codebaseiq").description("Language-agnostic code intelligence CLI powered by SCIP indexes").version(E).option("--output-page-size <characters>","Return bounded output pages with an exact continuation command",Kt).option("--output-cursor <cursor>","Continue a bounded output page").option("--no-session","Disable the explicit exploration evidence ledger").option("--reemit","Recovery only: render source and graph evidence again instead of citing session receipts").option("--help-all","Display every command, including compatibility and deprecated controls");let r=await sr(e.invocationCommand);lr(t,r);let i=new gn;return t.configureHelp({formatHelp:(n,o)=>n===t?mr(t,r):i.formatHelp(n,o)}),t.hook("preAction",async(n,o)=>{let a=o.name();if(e.resident){await e.resident.preAction(a);return}let l=Et(a),y=qt(a);if(!l&&!y){yr(),await gr(a);return}let d=Ct(),c=q(d);St(c);let u=te(d,c);A(u),yr(),await gr(a);let{config:h,paths:s}=u;if(l){let m=await or({commandName:a,projectRoot:d,config:h,paths:s,dbPathSource:u.dbPathSource,dbPath:u.dbPath,gitContext:c});m.freshness&&U({state:m.freshness.state,reason:m.freshness.reason,...m.freshness.updatedAt?{indexUpdatedAt:m.freshness.updatedAt}:{},...m.freshness.changedFiles?{changedFiles:m.freshness.changedFiles}:{}}),process.env.CODEBASEIQ_DEBUG&&console.error(`evidence-freshness: ${m.source}`),m.service.kind==="failed"&&console.error(`warning: codebaseiq watch service did not start: ${m.service.message}`),(m.service.kind==="failed"||m.service.kind==="skipped")&&j(d,E);return}if(!y){j(d,E);return}let g=Nt({commandName:a,projectRoot:d,cacheDir:s.cacheDir,cliVersion:E,config:h,gitContext:c});g.kind==="failed"&&console.error(`warning: codebaseiq watch service did not start: ${g.message}`),(g.kind==="failed"||g.kind==="skipped")&&j(d,E)}),t.hook("postAction",()=>{A(void 0),U(void 0)}),{program:t,descriptors:r}}async function gr(e){e.startsWith("__")||await hr({commandName:e})}function yr(){if(Ke(),!Xe()||Ze())return;let e=null;try{e=Pt(t=>st(t))}catch{}et({command:Je()??`codebaseiq ${process.argv.slice(2).join(" ")}`,toolVersion:E,projectFingerprint:e})}import{execFileSync as Sr}from"child_process";import{lstatSync as yn}from"fs";import{join as vn}from"path";var Me=3e4;function br(){return{env:ot(),encoding:"utf8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:Me,killSignal:"SIGKILL"}}function wr(e){return{generation:e.generation,epoch:e.epoch,changeSequence:e.changeSequence,headCommit:e.headCommit,treeOid:e.treeOid,fingerprintByPath:new Map(e.snapshot.files.map(t=>[t.path,t.hash])),languages:[...e.snapshot.languages],markerFiles:[...e.config.indexer?.typescript?.projects??[],...e.config.indexer?.clojure?.configPath?[e.config.indexer.clojure.configPath]:[]]}}function xr(e,t,r){if(r.epoch!==t.epoch)return{continuous:!1,reason:"the watcher observation epoch advanced since this generation was published"};if(r.changeSequence!==t.changeSequence)return{continuous:!1,reason:"the watcher observed a change after this generation was published"};let i,n;try{i=Sn(e),n=bn(e)}catch(o){return{continuous:!1,reason:`git state could not be read: ${o instanceof Error?o.message:String(o)}`}}if(i.headCommit!==t.headCommit||i.treeOid!==t.treeOid)return{continuous:!1,reason:"the git HEAD tree moved since this generation was published"};for(let o of n){if(He(o,t.languages,t.markerFiles)==="other")continue;let a=t.fingerprintByPath.get(o),l=wn(vn(e,o));if(l===null)return{continuous:!1,reason:`indexed input ${o} is no longer readable as a plain file`};if(a!==l)return{continuous:!1,reason:a===void 0?`indexed input ${o} appeared after this generation was published`:`indexed input ${o} changed after this generation was published`}}return{continuous:!0}}function Sn(e){let t=Sr("git",["-C",e,"rev-parse","HEAD","HEAD^{tree}"],{...br(),timeout:Me}).split(`
|
|
7
|
+
`).map(n=>n.trim()).filter(Boolean),[r,i]=t;if(!/^[0-9a-f]{40,64}$/.test(r??"")||!/^[0-9a-f]{40,64}$/.test(i??""))throw new Error("git did not report a resolved HEAD tree");return{headCommit:r,treeOid:i}}function bn(e){return Sr("git",["-C",e,"status","--porcelain=v1","-z","--untracked-files=all","--no-renames","--","."],{...br(),timeout:Me}).split("\0").filter(t=>t.length>=4&&t[2]===" ").map(t=>t.slice(3))}function wn(e){try{return yn(e).isFile()?Ge(e,{maxBytes:Qe,inputKind:"project-file"}):null}catch{return null}}var R=class extends Error{constructor(r,i){super(i);this.code=r}code};function Pr(e){let t=!1,r,i=()=>{let d=r;if(r=void 0,!!d)try{d.db.close()}catch{}},n=()=>{let d=e.indexGeneration();if(!d)throw new R("stale-index","The resident index is not idle-fresh; run the command in-process.");return d},o=d=>{let c=e.observation();if(!c||c.published.generation!==d)throw new R("stale-index","No provable observation is bound to the published generation; run the command in-process.");let u=xr(e.projectRoot,c.published,{epoch:c.epoch,changeSequence:c.changeSequence});if(!u.continuous)throw new R("stale-index",`${u.reason}; run the command in-process.`)},a=()=>{let d=n(),c=kn(e.projectRoot);if(r&&(r.generation!==d||r.stamp!==c||N(e.dbPath)!==d)&&i(),!r){let u=Rt(e.projectRoot);if(N(e.dbPath)!==d){try{u.close()}catch{}throw new R("stale-index","The published generation moved while opening the resident database.")}r={generation:d,stamp:c,db:u}}return r.db},l=d=>{if(!be(d))throw new R("ineligible-command",`Command ${d} always executes in-process.`);n();let c=te(e.projectRoot,q(e.projectRoot));if(c.dbPathSource!=="configured")throw new R("stale-index","The resident host does not serve fallback index locations.");A(c)};return{execute:async d=>{if(t)return Q("busy","The resident host is executing another request; run the command in-process.");let c=d.argv[0];if(!c||c.startsWith("-")||!be(c))return Q("ineligible-command","Only evidence commands are served by the resident host.");let u;try{u=n(),o(u)}catch(f){return Cr(f)}t=!0;let h=Oe.now(),s=new Le(d.tty),g=Pn(d.envAllowlist),m=process.exitCode;process.exitCode=0,Ie({argv:d.argv,execPath:d.clientInvocation?.execPath??process.execPath,...d.clientInvocation?.scriptPath!==void 0?{scriptPath:d.clientInvocation.scriptPath}:{},cwd:d.cwd}),we(a);try{let{program:f}=await vr({invocationCommand:c,resident:{preAction:l}});s.install();try{await f.parseAsync([...d.argv],{from:"user"})}finally{s.restore()}let b=typeof process.exitCode=="number"?process.exitCode:0;return{ok:!0,kind:"executed",protocolVersion:w,serverPid:process.pid,exitCode:b,stdout:s.stdout(),stderr:s.stderr(),generation:u,durationMs:Oe.now()-h}}catch(f){return f instanceof R?Cr(f):Rn(f)?{ok:!0,kind:"executed",protocolVersion:w,serverPid:process.pid,exitCode:f.exitCode,stdout:s.stdout(),stderr:s.stderr(),generation:u,durationMs:Oe.now()-h}:Q("execution-error",`Resident execution failed: ${f instanceof Error?f.message:String(f)}`)}finally{we(void 0),Ie(void 0),A(void 0),process.exitCode=m,g(),t=!1}},releaseDatabase:i}}function Q(e,t){return{ok:!1,protocolVersion:w,code:e,message:t}}function Cr(e){return e instanceof R?Q(e.code,e.message):Q("execution-error",e instanceof Error?e.message:String(e))}function Rn(e){return e instanceof Error&&"code"in e&&typeof e.code=="string"&&(e.code.startsWith("commander.")||e.code==="commander")&&typeof e.exitCode=="number"}function Pn(e){let t=new Map;for(let r of Gt){t.set(r,process.env[r]);let i=e?.[r];i===void 0?delete process.env[r]:process.env[r]=i}return()=>{for(let[r,i]of t)i===void 0?delete process.env[r]:process.env[r]=i}}var Le=class{constructor(t){this.tty=t}tty;stdoutChunks=[];stderrChunks=[];restorers=[];install(){this.restorers=[Er(process.stdout,this.stdoutChunks),Er(process.stderr,this.stderrChunks),ie(process.stdout,"isTTY",this.tty?.isTTY??!1),ie(process.stderr,"isTTY",this.tty?.isTTY??!1),ie(process.stdout,"columns",this.tty?.columns),ie(process.stderr,"columns",this.tty?.columns)]}restore(){for(let t of this.restorers.reverse())t();this.restorers=[]}stdout(){return this.stdoutChunks.join("")}stderr(){return this.stderrChunks.join("")}};function Er(e,t){let r=e.write,i=(n,o,a)=>{t.push(typeof n=="string"?n:Buffer.isBuffer(n)?n.toString(typeof o=="string"?o:"utf8"):String(n));let l=typeof a=="function"?a:typeof o=="function"?o:void 0;return typeof l=="function"&&l(),!0};return e.write=i,()=>{e.write=r}}function ie(e,t,r){let i=Object.hasOwn(e,t),n=i?Object.getOwnPropertyDescriptor(e,t):void 0;return r===void 0?i&&Reflect.deleteProperty(e,t):Object.defineProperty(e,t,{value:r,configurable:!0,writable:!0}),()=>{n?Object.defineProperty(e,t,n):Reflect.deleteProperty(e,t)}}function kn(e){let t=xn("sha256");for(let i of[".codebaseiq.json",".codebaseiq-baseline.json"])t.update(i),t.update(Rr(Ae(e,i)));let r=Ae(e,".codebaseiq","suppressions");t.update(r);try{for(let i of Cn(r).sort())t.update(i),t.update(Rr(Ae(r,i)))}catch{t.update("absent")}return t.digest("hex")}function Rr(e){try{let t=En(e);return`${t.size}:${t.mtimeMs}`}catch{return"absent"}}import{chmodSync as In,mkdirSync as Tn,rmSync as kr}from"fs";import{createServer as Mn}from"net";import{dirname as An}from"path";var Ir=1e4,On=5e3,Ln=6e5;function Tr(e){let t=fe(e.projectRoot),r=0,i,n,o=new Set,a=Mn(c=>{o.add(c),c.setTimeout(Ir,()=>c.destroy()),c.on("error",()=>c.destroy()),c.on("close",()=>o.delete(c));let u=zt(Ut,h=>{r+=1,i=new Date().toISOString(),e.onActivity?.(),l(h,c).then(s=>d(c,s)).catch(s=>{n=s instanceof Error?s.message:String(s),c.destroy()})},h=>{n=h.message,d(c,{ok:!1,protocolVersion:w,code:"invalid-request",message:h.message})});c.on("data",h=>{try{u.push(h)}catch(s){n=s instanceof Error?s.message:String(s),c.destroy()}})}),l=async(c,u)=>{let h=Yt(c);return h?fe(h.projectRoot)!==t?{ok:!1,protocolVersion:w,code:"wrong-project",message:"This query lane serves a different project root."}:y(h,u):{ok:!1,protocolVersion:w,code:"invalid-request",message:"The query lane received a request it could not validate."}},y=async(c,u)=>{if(c.kind==="ping"){let s=e.indexGeneration();return{ok:!0,kind:"pong",protocolVersion:w,serverPid:process.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{},cliVersion:e.cliVersion,projectRoot:t,...s?{indexGeneration:s}:{}}}if(!e.execute)return{ok:!1,protocolVersion:w,code:"unsupported",message:"Resident execution is not enabled on this service; run the command in-process."};let h=Math.max(c.deadlineMs??Qt,Ir);u.setTimeout(Math.min(h+On,Ln));try{u.write(Re({ok:!0,kind:"accepted",protocolVersion:w,serverPid:process.pid},Ee))}catch(s){return n=s instanceof Error?s.message:String(s),u.destroy(),{ok:!1,protocolVersion:w,code:"execution-error",message:"The query lane could not acknowledge the request."}}try{return await e.execute(c)}catch(s){return n=s instanceof Error?s.message:String(s),{ok:!1,protocolVersion:w,code:"execution-error",message:`Resident execution failed: ${n}`}}},d=(c,u)=>{try{c.end(Re(u,Ee))}catch(h){n=h instanceof Error?h.message:String(h),c.destroy()}};return process.platform!=="win32"&&(Tn(An(e.socketPath),{recursive:!0,mode:448}),kr(e.socketPath,{force:!0})),new Promise((c,u)=>{a.once("error",u),a.listen(e.socketPath,()=>{if(a.removeListener("error",u),a.on("error",h=>{n=h.message}),process.platform!=="win32")try{In(e.socketPath,384)}catch{}c({status:()=>({protocolVersion:w,socketPath:e.socketPath,requests:r,...i!==void 0?{lastRequestAt:i}:{},...n!==void 0?{lastError:n}:{}}),close:()=>new Promise(h=>{for(let s of o)s.destroy();a.close(()=>{process.platform!=="win32"&&kr(e.socketPath,{force:!0}),h()})})})})})}import{randomUUID as Wn}from"crypto";import{Worker as _n}from"worker_threads";var oe=class{constructor(t){this.options=t;this.now=t.now??Date.now,this.setTimer=t.setTimer??setTimeout,this.clearTimer=t.clearTimer??clearTimeout}options;now;setTimer;clearTimer;worker=null;active=null;activeFailure=null;terminating=null;closed=!1;workerGeneration=0;canAccept(){return!this.closed&&this.active===null&&this.terminating===null}start(t){if(!this.canAccept())return!1;if(t.deadlineAtMs<this.now()){try{this.options.onReject(t,`${this.options.name} request expired before processing.`)}catch(o){this.closed=!0,this.options.onFatal(De(o))}return!0}let r=this.ensureWorker(),i=Math.max(1,Math.min(2147483647,t.deadlineAtMs-this.now())),n=this.setTimer(()=>{this.failActiveAfterTermination(`${this.options.name} request exceeded its deadline.`)},i);this.active={request:t,timer:n};try{r.postMessage({kind:"request",...t})}catch(o){this.failActiveAfterTermination(Mr(o))}return!0}async close(t=`${this.options.name} service is shutting down.`){if(this.closed=!0,this.active){await this.failActiveAfterTermination(t);return}await this.terminateWorker()}ensureWorker(){if(this.worker)return this.worker;let t=this.options.createWorker(),r=++this.workerGeneration;return t.on("message",i=>this.handleMessage(r,i)),t.on("error",i=>{r===this.workerGeneration&&this.failActiveAfterTermination(`${this.options.name} worker failed: ${i.message}`)}),t.on("exit",i=>{r!==this.workerGeneration||this.terminating||(this.worker=null,this.active&&this.failActiveAfterTermination(`${this.options.name} worker exited unexpectedly with code ${i}.`))}),this.worker=t,t}handleMessage(t,r){if(t!==this.workerGeneration||this.closed||!this.active)return;let i=Dn(r);if(!i){this.failActiveAfterTermination(`${this.options.name} worker returned an invalid response.`);return}if(i.requestId!==this.active.request.requestId){this.failActiveAfterTermination(`${this.options.name} worker returned a mismatched request identity.`);return}if(this.now()>this.active.request.deadlineAtMs){this.failActiveAfterTermination(`${this.options.name} request expired while it was processing.`);return}let n=this.active;try{this.options.onStatus(i.status),i.ok?this.options.onComplete(n.request,i.result,i.status):this.options.onReject(n.request,i.error,i.status)}catch(o){this.closed=!0,this.clearTimer(n.timer),this.options.onFatal(De(o));return}this.releaseActive(n)}async failActiveAfterTermination(t){if(this.activeFailure){await this.activeFailure;return}let r=this.active;if(!r){await this.terminateWorker();return}this.clearTimer(r.timer);let i=(async()=>{if(await this.terminateWorker()){try{this.options.onReject(r.request,t)}catch(o){this.closed=!0,this.options.onFatal(De(o));return}this.releaseActive(r)}})();this.activeFailure=i;try{await i}finally{this.activeFailure===i&&(this.activeFailure=null)}}releaseActive(t){this.active===t&&(this.active=null,this.clearTimer(t.timer))}async terminateWorker(){if(this.terminating)return this.terminating;let t=this.worker;if(!t)return!0;this.worker=null;let r=++this.workerGeneration;return this.terminating=(async()=>{try{return await t.terminate(),!0}catch(i){return this.closed=!0,this.options.onFatal(new Error(`${this.options.name} worker termination failed: ${Mr(i)}`,{cause:i})),!1}finally{r===this.workerGeneration&&(this.terminating=null)}})(),this.terminating}};function Dn(e){if(!e||typeof e!="object")return null;let t=e;if(t.kind!=="response"||typeof t.requestId!="string"||!("status"in t))return null;if(t.ok===!0){if(!("result"in t)||"error"in t)return null}else if(t.ok===!1){if("result"in t||typeof t.error!="string")return null}else return null;return t}function De(e){return e instanceof Error?e:new Error(String(e))}function Mr(e){return e instanceof Error?e.message:String(e)}function Ar(e){let t=()=>({protocolVersion:Z,state:"idle",requests:0,sessionsCreated:0,sessionsReplaced:0,initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0});return Lr({name:"TypeScript index",paths:e.paths,now:e.now,limits:e.limits,initialStatus:t,parseEnvelope:mt,createWorker:()=>Dr(e,{kind:"index",projectRoot:e.projectRoot,dbPath:e.dbPath}),complete(r,i,n,o){he(e.paths,r,{ok:!0,protocolVersion:Z,id:i.id,baseGeneration:i.baseGeneration,response:n},{nowMs:o,limits:e.limits})},reject(r,i,n,o){ge(e.paths,r,{ok:!1,protocolVersion:Z,id:i,error:n},n,{nowMs:o,limits:e.limits})},onBusy:e.onBusy,onFatal:e.onFatal})}function Or(e){let t=()=>({protocolVersion:ee,state:"idle",requests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0});return Lr({name:"TypeScript semantic",paths:e.paths,now:e.now,limits:e.limits,initialStatus:t,parseEnvelope:xt,createWorker:()=>Dr(e,{kind:"semantic",projectRoot:e.projectRoot}),complete(r,i,n,o){he(e.paths,r,{ok:!0,protocolVersion:ee,id:i.id,generation:i.generation,response:n},{nowMs:o,limits:e.limits})},reject(r,i,n,o){ge(e.paths,r,{ok:!1,protocolVersion:ee,id:i,error:n},n,{nowMs:o,limits:e.limits})},onBusy:e.onBusy,onFatal:e.onFatal})}function Lr(e){let t=e.now??Date.now,r=_(process.pid),i={pid:process.pid,...r?{processIdentity:r}:{}},n=`${e.name.toLowerCase().replaceAll(" ","-")}-${process.pid}-${Wn()}`,o={...e.limits,maxBatch:1},a=null,l=e.initialStatus(),y=!1,d=s=>{y=!0,e.onFatal(s)},c=new oe({name:e.name,createWorker:e.createWorker,now:t,onComplete(s,g,m){let f=u(s.requestId);l=m,e.complete(f.claim,f.envelope,g,t()),h(f)},onReject(s,g,m){let f=u(s.requestId);m!==void 0&&(l=m),e.reject(f.claim,f.envelope.id,g,t()),h(f)},onStatus(s){l=s},onFatal:d});return{poll(){if(y||!c.canAccept())return 0;let s=ct(e.paths,{ownerId:n,nowMs:t(),limits:o,owner:i,liveness:{isProcessAlive:it,readProcessIdentity:_}})[0];if(!s)return 0;let g=s.requestId;try{let m=e.parseEnvelope(dt(s,o));if(g=m.id,m.id!==s.requestId)throw new Error(`${e.name} request identity does not match its mailbox path.`);if(m.deadlineAtMs<t())throw new Error(`${e.name} request expired before processing.`);if(a={claim:s,envelope:m},e.onBusy?.(m.deadlineAtMs),!c.start({requestId:m.id,deadlineAtMs:m.deadlineAtMs,payload:m}))throw new Error(`${e.name} worker lane closed admission after claiming a request.`)}catch(m){let f=Nn(m);try{e.reject(s,g,f,t()),a?.claim===s&&h(a)}catch(b){d(qn(b))}}return 1},status(){return{...l,mailbox:lt(e.paths)}},async close(s){await c.close(s)}};function u(s){let g=a;if(!g||g.envelope.id!==s)throw new Error(`${e.name} parent lost the active mailbox claim.`);return g}function h(s){a===s&&(a=null,e.onBusy?.(void 0))}}function Dr(e,t){if(e.createWorker)return e.createWorker(t);let r=e.workerUrl??new URL("./typescript-mailbox-worker.js",import.meta.url);return new _n(r,{workerData:t})}function qn(e){return e instanceof Error?e:new Error(String(e))}function Nn(e){return e instanceof Error?e.message:String(e)}import{existsSync as jn}from"fs";import{fileURLToPath as Wr}from"url";import{Worker as $n}from"worker_threads";var Fn=2e3;function Nr(e){let t=e.userCacheRoot??It(),r={kind:"sentinel-worker",projectRoot:e.projectRoot,cacheDir:e.indexPaths.cacheDir,dbPath:e.indexPaths.dbPath,cliVersion:e.cliVersion,userCacheRoot:t},i=e.createWorker??Vn,n,o=0,a=!1,l=!1,y,d=()=>{let s;try{s=i(r)}catch(f){e.log(`worker could not be started: ${qr(f)}`);return}let g,m={worker:s,exited:new Promise(f=>{g=f})};n=m,s.on("message",f=>{n===m&&c(f)}),s.on("error",f=>e.log(`worker failed: ${f.message}`)),s.on("exit",f=>{if(g(),n===m&&(n=void 0,o=0,!l)){if(e.log(`worker exited unexpectedly with code ${f}`),_r(t,e.projectRoot),a){e.log("worker will not be restarted again");return}a=!0,d()}})},c=s=>{let g=Bn(s);g?.kind==="sessions"?o=g.live:g?.kind==="log"&&e.log(g.message)},u=s=>{try{n?.worker.postMessage(s)}catch(g){e.log(`${s.kind} could not be posted: ${qr(g)}`)}},h=async()=>{l=!0;let s=n;s&&(u({kind:"shutdown"}),await Un(s.exited,e.stopTimeoutMs??Fn),n===s&&(n=void 0,await s.worker.terminate().catch(()=>{}))),o=0,_r(t,e.projectRoot)};return d(),{filesChanged:s=>u({kind:"filesChanged",paths:s}),generationPublished:()=>u({kind:"generationPublished"}),releaseDb:()=>u({kind:"releaseDb"}),liveSessionCount:()=>o,stop:()=>y??=h()}}function jr(){let e,t=!1;return{attach(r){e=r},filesChanged:r=>e?.filesChanged(r),bulkChange:()=>e?.filesChanged([]),watcherStatus(r){r.state==="idle"?t=!1:e&&!t&&(t=!0,e.releaseDb())},generationPublished(){t=!1,e?.generationPublished()},liveSessionCount:()=>e?.liveSessionCount()??0,async stop(){await e?.stop()}}}function Vn(e){let t=new URL("./sentinel-worker.js",import.meta.url);if(!jn(Wr(t)))throw new Error(`sentinel worker was not found at ${Wr(t)}. Run npm run build first.`);let r=new $n(t,{workerData:e});return r.unref(),r}function Bn(e){if(typeof e!="object"||e===null)return;let{kind:t,live:r,message:i}=e;if(t==="sessions"&&typeof r=="number"&&Number.isInteger(r)&&r>=0)return{kind:t,live:r};if(t==="log"&&typeof i=="string")return{kind:t,message:i}}function _r(e,t){try{Mt(e,Tt(t),process.pid)}catch{}}async function Un(e,t){let r,i=new Promise(n=>{r=setTimeout(n,t)});try{await Promise.race([e,i])}finally{clearTimeout(r)}}function qr(e){return e instanceof Error?e.message:String(e)}var Hn=1e3,zn=250,Yn=6e4,Xn=10,Jn=50,Kn=250;function Zn(e,t=1){if(e>0)return Xn;let r=Math.max(0,Math.min(3,t-1));return Math.min(Kn,Jn*2**r)}async function ei(e,t){let r=t.processIndexRequests(),i=t.processSemanticRequests(),n=r+i,o=n>0?0:e+1;if(t.afterMailboxPoll({indexRequests:r,semanticRequests:i,processedRequests:n}),t.shouldStop())return{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!0};let a=Zn(n,o);return await t.wait(a),{indexRequests:r,semanticRequests:i,processedRequests:n,consecutiveIdlePolls:o,stopped:!1,delayMs:a}}function ti(e,t=v.env){return e==="fresh"||t.CODEBASEIQ_SENTINEL_ENSURE==="1"?null:{kind:"watch-startup",detail:`index ${e} when watch service started`}}async function ri(e,t,r={}){let i=jt(e,t),n=i.projectRoot;v.env.CODEBASEIQ_PROJECT_ROOT=n;let o=yt(n);o.watch={...o.watch,...r};let a=vt(o);if(!a.enabled)throw new Error('watch mode is disabled; set "watch.enabled": true before starting the service');let l=nt(n,o),y=ft(l.cacheDir),d=_(v.pid),c=Vt(y.lockPath,n,{readProcessIdentity:p=>p===v.pid?d:_(p)});if(!c.acquired)return;let u=new re(y.refreshRequestsPath,{retryDelayMs:Math.max(1e3,a.cooldownMs)});u.initializeAfterOwnershipAcquired();let h=Date.now(),s=W(),g=h,m=s,f={state:"idle"},b,G,P,H,se=K(l.dbPath),ae=!1,We=!1,_e=0,qe=Number.NEGATIVE_INFINITY,Ne=Number.NEGATIVE_INFINITY,je=Number.NEGATIVE_INFINITY,$e=Number.NEGATIVE_INFINITY,ce,de,Fe=0,le=wt(l.cacheDir),ue=ut(l.cacheDir);kt(le),gt(ue);let z,$,L,Ve=o.sentinel?.enabled===!0,I=jr(),Be=p=>{if(L=void 0,!!p)try{let x=q(n);if(!x?.headCommit||!x.treeOid)return;let S=Ye(J(l.metaPath,"reindex metadata"));if(S.kind!=="legacy"&&S.kind!=="supported")return;let k=ze(S.metadata.fingerprint);if(!k)return;L=wr({generation:p,...D.observation(),headCommit:x.headCommit,treeOid:x.treeOid,snapshot:k,config:o})}catch{}},C=(p=!1,x=p?"durable":"visibility")=>{if(!We)return;let S=Date.now(),k=W();!p&&k-qe<Hn||(qe=k,$t(y.statePath,{version:1,protocolVersion:pt,pid:v.pid,...d?{processIdentity:d}:{},projectRoot:n,...i.worktreeId?{worktreeId:i.worktreeId}:{},cliVersion:t,startedAt:new Date(h).toISOString(),heartbeatAt:new Date(S).toISOString(),lastActivityAt:new Date(g).toISOString(),...a.idleTimeoutMs===0?{}:{idleDeadlineAt:new Date((I.liveSessionCount()>0?S:g)+a.idleTimeoutMs).toISOString()},watcher:f,...f.state==="idle"&&b?{indexGeneration:b}:{},...G?{lastRefresh:G}:{},...P?{lastError:P}:{},reindexActivity:se,refreshRequests:u.status(),typescriptSemantic:{...me.status(),...ce===void 0?{}:{busyUntil:new Date(ce).toISOString()}},typescriptIndex:{...pe.status(),...de===void 0?{}:{busyUntil:new Date(de).toISOString()}},...z?{queryLane:z.status()}:{}},{durability:x}))},T=()=>{g=Date.now(),m=W()},Ue=p=>{T(),H??=p,P={at:new Date().toISOString(),message:p.message},C(!0,"visibility")},me=Or({paths:le,projectRoot:n,onBusy(p){ce=p===void 0?void 0:p+5e3,C(!0,"visibility")},onFatal:Ue}),pe=Ar({paths:ue,projectRoot:n,dbPath:l.dbPath,onBusy(p){de=p===void 0?void 0:p+5e3,C(!0,"visibility")},onFatal:Ue}),D=new At({projectRoot:n,config:{...o,watch:a},outputDb:l.dbPath,languages:o.languages,onStatus(p){f=p,I.watcherStatus(p),p.state!=="idle"&&(b=void 0,L=void 0,$?.releaseDatabase(),T()),C(!0)},...Ve?{onFileChanged:I.filesChanged,onBulkChange:I.bulkChange}:{},onReindexComplete(){T();let p=Se(n,o,l);return G=p.lastRefresh,b=p.state==="fresh"?N(l.dbPath)??void 0:void 0,Be(b),se=K(l.dbPath),u.completeActive(),P=void 0,C(!0),I.generationPublished(),p.state==="fresh"},onReindexError(){u.failActive()},onRefreshSuppressed(p){let x=at(l.dbPath,p);x.state==="failed"&&(P={at:new Date().toISOString(),message:`Suppressed-refresh telemetry was not recorded: ${x.reason}`},C(!0,"visibility")),se=K(l.dbPath)},onError(p){T(),b=void 0,L=void 0,P={at:new Date().toISOString(),message:p.message},C(!0)}}),Y=()=>{ae=!0};v.once("SIGINT",Y),v.once("SIGTERM",Y);let F=!1,X,V;try{try{$=v.env.CODEBASEIQ_DAEMON==="1"||o.daemon?.enabled===!0?Pr({projectRoot:n,dbPath:l.dbPath,indexGeneration:()=>b,observation:()=>L?{published:L,...D.observation()}:void 0}):void 0,z=await Tr({socketPath:Ht(l.cacheDir),projectRoot:n,cliVersion:t,...d?{processIdentity:d}:{},indexGeneration:()=>b,onActivity:T,...$?{execute:k=>$.execute(k)}:{}})}catch(S){P={at:new Date().toISOString(),message:`Query lane did not start: ${S instanceof Error?S.message:String(S)}`}}Ve&&I.attach(Nr({projectRoot:n,indexPaths:l,cliVersion:t,log(S){v.env.CODEBASEIQ_DEBUG&&console.error(`sentinel: ${B(S)}`)}})),D.start();let p=Se(n,o,l);G=p.lastRefresh,b=p.state==="fresh"?N(l.dbPath)??void 0:void 0,Be(b);let x=ti(p.state);for(x&&D.requestRefresh(x,{immediate:!0}),T(),We=!0,C(!0);!ae;){let S=await ei(Fe,{processIndexRequests:()=>pe.poll(),processSemanticRequests:()=>me.poll(),afterMailboxPoll:({processedRequests:k})=>{let O=W();if(O-$e>=Yn&&($e=O,ye(ue),ye(le)),O-je>=6e4&&(je=O,j(n,t)),O-Ne>=zn){Ne=O;let M=Ft(y.activityPath);M&&M.atMs>g&&(g=M.atMs,m=O),M?.refreshRequestedAtMs!==void 0&&M.refreshRequestedAtMs>_e&&(_e=M.refreshRequestedAtMs,u.observeLegacyRequest(M.refreshRequestedAtMs,M.refreshDetail??"stale index observed by a legacy command")),u.poll(f,Fr=>{T(),D.requestRefresh({kind:"watch-demand",detail:Fr},{immediate:!0})})}k>0&&(T(),C(!0,"visibility")),C()},shouldStop:()=>ae||H!==void 0||Bt({watcher:f,lastActivityAtMs:m,nowMs:W(),idleTimeoutMs:a.idleTimeoutMs,liveSessions:I.liveSessionCount()}),wait:ni});if(Fe=S.consecutiveIdlePolls,S.stopped)break}}catch(p){F=!0,X=p}finally{v.off("SIGINT",Y),v.off("SIGTERM",Y),await z?.close(),await I.stop(),$?.releaseDatabase(),await Promise.all([me.close("TypeScript semantic service stopped before completing the request."),pe.close("TypeScript index service stopped before completing the request.")]);let p=await D.stop();p.state==="stopped"?($r(y.statePath,{force:!0}),$r(y.activityPath,{force:!0}),c.release()):(P={at:new Date().toISOString(),message:`Watch service shutdown is degraded: ${p.reasons.join("; ")}`},C(!0),V=new Error(P.message))}if(!F&&H&&(F=!0,X=H),F&&V)throw new AggregateError([X,V],"Watch service execution and shutdown both failed.");if(F)throw X;if(V)throw V}function ni(e){return new Promise(t=>setTimeout(t,e))}function ii(e,t={report:r=>console.error(r),exit:r=>v.exit(r)}){return t.report(`watch-service: ${B(e instanceof Error?e.message:String(e))}`),t.exit(1)}var oi=v.argv[1]?Gn(Qn(v.argv[1])).href:null;if(oi===import.meta.url){ht();let e=v.argv[2],t=v.argv[3],r=si(v.argv[4]);if(!e||!t)console.error("watch-service: expected <project-root> <cli-version>"),v.exitCode=1;else try{await ri(e,t,r)}catch(i){ii(i)}}function si(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}export{ei as runWatchServiceLoopIteration,ri as runWatchServiceServer,ti as startupRefreshTrigger,ii as terminateWatchServiceProcess,Zn as watchServiceLoopDelayMs};
|
|
8
8
|
//# sourceMappingURL=watch-server.js.map
|
|
@@ -24,7 +24,7 @@ The operator chooses the material question and deliberately selects a control. T
|
|
|
24
24
|
| locate | `search <exact-text>` | Where does this exact text occur in current project text, and which aligned compiler symbol owns each line? | One exact text literal or deliberately bounded regular expression; insert \`--\` before a literal that starts with a dash. | exact cardinality, bounded identities and source, and scope commands that recover withheld matches | Exact current-text cardinality and locations within reported text coverage; compiler ownership only where aligned. | Structural source ranking orders exact matches but does not establish task relevance. A literal co-occurrence does not establish a graph relationship. | `small` | outline: search locates exact text across files; outline enumerates compiler-owned constructs in one known file. | `evidence`, `inspect`, `code` |
|
|
25
25
|
| locate | `outline <file>` | What symbols and nesting exist in this file? | One exact current project file path. | symbol names, nesting, and line ranges | Exact compiler-owned constructs and ranges when the file is indexed; no invented semantic overlay. | File ownership and nesting do not establish execution or task relevance. | `small` | search: outline enumerates constructs in one known file; search locates exact text across current project text. code: outline returns identities and ranges; code materializes exact source for selected identities. | `evidence`, `inspect`, `code` |
|
|
26
26
|
| locate | `entrypoints [text]` | Which detected external roots or entry-surface candidates match this text? | Optional exact text to filter candidates; otherwise the current indexed repository. | entry symbols with files, confidence, evidence, and indexed caller counts | Source/compiler-grounded entry evidence and indexed caller counts; exported-only candidates remain candidates. | A package-public export or zero indexed callers is an entry candidate, not proof of runtime ingress. Entry classification does not establish that the callable executes. | `bounded` | entry-map: entrypoints locates possible external roots; entry-map traverses static calls from one selected root. search: entrypoints classifies callable roots; search only locates exact text and ownership. | `evidence`, `inspect`, `code` |
|
|
27
|
-
| project | `evidence` | Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap? | One or more exact symbol, file:line, or literal roots plus explicit family
|
|
27
|
+
| project | `evidence` | Which exact execution, runtime, data, state, temporal, contract, identity, ownership, or dependency relationships surround these referents? Which related source must be read only when graph evidence leaves a named implementation gap? | One or more exact symbol, file:line, or literal roots plus explicit family and direction; depth defaults to 2 and max-edges to 32. | batched exact selectors and typed graph relationships; compact endpoints with exact locations and follow-up commands; coverage and recoverable omissions; exact source-recovery command when source was requested with a graph projection; explicit ambiguity failure with exact rerun commands | Typed edges only to each registered provider ceiling within the explicitly selected projection and reported coverage. | The projection does not infer which relationships are relevant to the user task. Reference, dependency, data, state, temporal, contract, and identity edges do not become execution claims. | `bounded` | refs: refs enumerates direct reference sites; evidence traverses explicitly selected typed relationships. call-graph: call-graph specializes in static calls; evidence can combine execution with other selected families. value-flow: value-flow specializes in proved transfers; evidence projects bounded dataflow alongside other families. dependence-slice: dependence-slice computes a program-dependence slice; evidence performs bounded graph projection. | `inspect`, `code` |
|
|
28
28
|
| read | `inspect` | Which related source units across several known text, symbol, or location anchors should be read together? | One or more exact text, symbol, or file:line selectors naming the unresolved behavior. | one ranked, deduplicated semantic packet plus exact selector cardinality and explicit expansion coverage | Complete current source for every materialized syntax unit; bounded selector and packet coverage remain explicit. | A source packet does not choose which implementation details are relevant to the user task. A reference mention does not establish executable reachability. | `potentially-large` | code: inspect batches bounded behavior or source gaps; code materializes complete exact source. evidence: inspect reads implementation units; evidence projects typed relationships without source. | - |
|
|
29
29
|
| read | `code <selectors...>` | What exact source defines these symbols, ranges, or file surfaces? | One or more exact symbols, file:line ranges, or file paths. | per-selector resolution, complete definition source, exact ranges with statically attributed same-file call closure, file export surfaces, omitted-local ledgers, and line ranges | Exact current source bytes for every resolved selector, with omitted file-local constructs disclosed. | Source materialization does not establish callers, runtime reachability, or task relevance by itself. | `potentially-large` | inspect: code materializes complete exact source; inspect batches bounded behavior or source gaps. outline: code reads selected implementations; outline enumerates file structure without reading every body. | - |
|
|
30
30
|
|
|
@@ -153,7 +153,7 @@ An unavailable frontier is a relationship class for which no registered analyzer
|
|
|
153
153
|
|
|
154
154
|
| Command | Description | Cost | Closes disclosed gaps with | Options |
|
|
155
155
|
|---|---|---|---|---|
|
|
156
|
-
| `reindex` | Index the codebase and convert to SQLite | variable | - | `-l, --language <lang>`<br>`--pnpm-workspaces`<br>`--force`<br>`--allow-partial`<br>`--trust-project-tools`<br>`--install-missing`<br>`--indexer-concurrency <n>`<br>`--json`<br>`--result-only`<br>`--compact` |
|
|
156
|
+
| `reindex` | Index the codebase and convert to SQLite | variable | - | `-l, --language <lang>`<br>`--pnpm-workspaces`<br>`--force`<br>`--allow-partial`<br>`--trust-project-tools`<br>`--install-missing`<br>`--indexer-concurrency <n>`<br>`--base <ref>`<br>`--json`<br>`--result-only`<br>`--compact` |
|
|
157
157
|
| `augment-sources` | Add source files skipped by upstream SCIP indexers to the SQLite documents table | variable | - | - |
|
|
158
158
|
| `augment-vue` | Add compiler-resolved Vue SFC references to the SQLite index using Volar | variable | - | `--project <tsconfig>` |
|
|
159
159
|
|
package/docs/SECURITY_MODEL.md
CHANGED
|
@@ -28,6 +28,9 @@ CLI invocation:
|
|
|
28
28
|
- environment overrides such as `CODEBASEIQ_CACHE_DIR` are operator-owned
|
|
29
29
|
storage choices. Tracked `.codebaseiq.json` cannot grant destructive authority
|
|
30
30
|
over an arbitrary external cache.
|
|
31
|
+
- `CODEBASEIQ_READ_ONLY=1` opens an existing index without adopting, locking,
|
|
32
|
+
leasing, or writing any cache state, so a cache directory read in this mode
|
|
33
|
+
needs no ownership record. Nothing in this mode can delete cache content.
|
|
31
34
|
|
|
32
35
|
A managed cache is rebuildable local state rooted under a codebaseiq-owned
|
|
33
36
|
directory, distinguished from a caller-selected directory by an ownership
|