codebaseiq 0.1.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 +481 -0
- package/LICENSE +202 -0
- package/README.md +349 -0
- package/dist/augment-vue-worker.js +2 -0
- package/dist/call-graph-evidence-gNsxjCW8.d.ts +16 -0
- package/dist/change-analysis-types-CCtoCHbC.d.ts +9 -0
- package/dist/chunk-2Q2LW5JW.js +14 -0
- package/dist/chunk-2X7V4HS4.js +88 -0
- package/dist/chunk-34WBMAYK.js +2 -0
- package/dist/chunk-35NLDRZC.js +2 -0
- package/dist/chunk-362QOSFD.js +3 -0
- package/dist/chunk-3IER7Q6H.js +12 -0
- package/dist/chunk-3JSXXYTZ.js +345 -0
- package/dist/chunk-3LCDIREB.js +4 -0
- package/dist/chunk-476NR5B7.js +2 -0
- package/dist/chunk-4FC325IF.js +30 -0
- package/dist/chunk-4WKDMDEW.js +9 -0
- package/dist/chunk-4XTAUQFD.js +2 -0
- package/dist/chunk-5PUWMSDU.js +26 -0
- package/dist/chunk-5VKBFZZU.js +3 -0
- package/dist/chunk-6BQ3DSPK.js +2 -0
- package/dist/chunk-6CS3UQTN.js +3 -0
- package/dist/chunk-6MUIJMVL.js +6 -0
- package/dist/chunk-6NW7MU72.js +40 -0
- package/dist/chunk-6OAHRI2D.js +6 -0
- package/dist/chunk-6YTSKJJ3.js +2 -0
- package/dist/chunk-7FND7D7N.js +2 -0
- package/dist/chunk-7MGU3HPH.js +2 -0
- package/dist/chunk-7NVGT435.js +2 -0
- package/dist/chunk-7XAN6GKB.js +2 -0
- package/dist/chunk-AAQQPKCU.js +2 -0
- package/dist/chunk-ADTBPVUZ.js +21 -0
- package/dist/chunk-AKB7V7TV.js +2 -0
- package/dist/chunk-ANFVSJWQ.js +11 -0
- package/dist/chunk-B2OB55RR.js +3 -0
- package/dist/chunk-B3UYV66Z.js +4 -0
- package/dist/chunk-B75HZHUP.js +2 -0
- package/dist/chunk-BFFZDZQV.js +2 -0
- package/dist/chunk-BGBBVSH4.js +2 -0
- package/dist/chunk-BH5F2Q4O.js +2 -0
- package/dist/chunk-BJ6SQAEN.js +2 -0
- package/dist/chunk-BMYOV5GP.js +77 -0
- package/dist/chunk-BVAJLC5A.js +7 -0
- package/dist/chunk-C6SBF2WH.js +4 -0
- package/dist/chunk-C74PPYLA.js +3 -0
- package/dist/chunk-C7QOQX32.js +8 -0
- package/dist/chunk-CAUCPUOF.js +7 -0
- package/dist/chunk-CO5R3UNA.js +2 -0
- package/dist/chunk-CQP3THUZ.js +7 -0
- package/dist/chunk-CVYSU6BX.js +16 -0
- package/dist/chunk-CWONGW6P.js +3 -0
- package/dist/chunk-DDZ7VHWV.js +20 -0
- package/dist/chunk-DGXRDLV5.js +2 -0
- package/dist/chunk-DO6WQD2T.js +3 -0
- package/dist/chunk-DQMDCD24.js +2 -0
- package/dist/chunk-DR2LURYU.js +3 -0
- package/dist/chunk-DRENNWRG.js +2 -0
- package/dist/chunk-ECQBG7PW.js +564 -0
- package/dist/chunk-EF2R3WNQ.js +2 -0
- package/dist/chunk-ELNRLMC5.js +29 -0
- package/dist/chunk-EMNIHCRB.js +18 -0
- package/dist/chunk-ENCCHKM6.js +5 -0
- package/dist/chunk-EZNMUY67.js +5 -0
- package/dist/chunk-FAJQ7LWY.js +3 -0
- package/dist/chunk-FDGD5AB5.js +2 -0
- package/dist/chunk-FETNQCFO.js +117 -0
- package/dist/chunk-FM5BPL4V.js +60 -0
- package/dist/chunk-FQKZWM4L.js +49 -0
- package/dist/chunk-FW53T7EB.js +2 -0
- package/dist/chunk-G6XFR4ZL.js +4 -0
- package/dist/chunk-GCHRX4YW.js +4 -0
- package/dist/chunk-GTIYTDRE.js +562 -0
- package/dist/chunk-GTXSJDCO.js +2 -0
- package/dist/chunk-GW6Z3WGY.js +2 -0
- package/dist/chunk-H3LGFZVK.js +2 -0
- package/dist/chunk-HKQUXIFO.js +2 -0
- package/dist/chunk-HOA5YGOH.js +3 -0
- package/dist/chunk-HPJRBHVT.js +3 -0
- package/dist/chunk-HRWGYWRJ.js +49 -0
- package/dist/chunk-I2T2LLK2.js +4 -0
- package/dist/chunk-ICFDQHAM.js +3 -0
- package/dist/chunk-ID63777H.js +4 -0
- package/dist/chunk-IJ4HMYBE.js +3 -0
- package/dist/chunk-ILMHV3KM.js +2 -0
- package/dist/chunk-IOP6FWIM.js +2 -0
- package/dist/chunk-IRQOAM5G.js +2 -0
- package/dist/chunk-J77SU6VA.js +38 -0
- package/dist/chunk-JE3WZ6II.js +2 -0
- package/dist/chunk-JEJLSICM.js +4 -0
- package/dist/chunk-JOIRNPPY.js +2 -0
- package/dist/chunk-JSOYNVWH.js +3 -0
- package/dist/chunk-KMITESMT.js +2 -0
- package/dist/chunk-KUW32IRO.js +2 -0
- package/dist/chunk-KWVHSKHK.js +31 -0
- package/dist/chunk-L4NRUAGJ.js +18 -0
- package/dist/chunk-L57ZKWVG.js +6 -0
- package/dist/chunk-LTA3BRZX.js +2 -0
- package/dist/chunk-LU3BMVH2.js +10 -0
- package/dist/chunk-LZYFLFEH.js +2 -0
- package/dist/chunk-MOVBWNIP.js +16 -0
- package/dist/chunk-MVB3DAEY.js +3 -0
- package/dist/chunk-N3IQCBCF.js +29 -0
- package/dist/chunk-NAUD7LCA.js +2 -0
- package/dist/chunk-NCZUNH3E.js +109 -0
- package/dist/chunk-NE6IU5ZD.js +5 -0
- package/dist/chunk-NEDP5RFQ.js +60 -0
- package/dist/chunk-NMTSZXCL.js +2 -0
- package/dist/chunk-NNJ2KZZG.js +4 -0
- package/dist/chunk-NNO6A2PO.js +2 -0
- package/dist/chunk-NNOKTMZT.js +20 -0
- package/dist/chunk-O6QTXQPJ.js +13 -0
- package/dist/chunk-OANDYLJQ.js +2 -0
- package/dist/chunk-OFBE4NGP.js +2 -0
- package/dist/chunk-OGTFJ3XD.js +2 -0
- package/dist/chunk-OL6KJP3N.js +16 -0
- package/dist/chunk-OLF4MA5W.js +8 -0
- package/dist/chunk-OTOKVOJ3.js +2 -0
- package/dist/chunk-OVTS4DKB.js +2 -0
- package/dist/chunk-OZYRSMSH.js +3 -0
- package/dist/chunk-P5XHIJHI.js +2 -0
- package/dist/chunk-PBI2LFKH.js +2 -0
- package/dist/chunk-PIOMTC27.js +2 -0
- package/dist/chunk-PTAWHLVJ.js +6 -0
- package/dist/chunk-PX4RYAAK.js +2 -0
- package/dist/chunk-PYAB5SM6.js +7 -0
- package/dist/chunk-Q5ELPRKQ.js +2 -0
- package/dist/chunk-Q65CQ4XL.js +2 -0
- package/dist/chunk-Q72QSKXC.js +308 -0
- package/dist/chunk-QCN62RTF.js +3 -0
- package/dist/chunk-QDCCHMVZ.js +2 -0
- package/dist/chunk-QHRNXP3C.js +3 -0
- package/dist/chunk-QKPLA6IC.js +2 -0
- package/dist/chunk-QOKYJ33H.js +2 -0
- package/dist/chunk-QW7EP6WI.js +21 -0
- package/dist/chunk-R2NOK63J.js +4 -0
- package/dist/chunk-RBAS5ZHI.js +2 -0
- package/dist/chunk-RDBI2RXU.js +9 -0
- package/dist/chunk-RKEJ6VTF.js +73 -0
- package/dist/chunk-RR7SX44N.js +35 -0
- package/dist/chunk-RU65DDUP.js +215 -0
- package/dist/chunk-SELM5MER.js +2 -0
- package/dist/chunk-SGX43S2L.js +2 -0
- package/dist/chunk-SMRBZ6EC.js +2 -0
- package/dist/chunk-SNNWPCN7.js +4 -0
- package/dist/chunk-ST7V3SKN.js +2 -0
- package/dist/chunk-SWHMHUKF.js +2 -0
- package/dist/chunk-SYDJMPES.js +2 -0
- package/dist/chunk-SZD2KF7Q.js +2 -0
- package/dist/chunk-T3DGWPXM.js +3 -0
- package/dist/chunk-TFZB6XTM.js +239 -0
- package/dist/chunk-TIIC3ZE7.js +2 -0
- package/dist/chunk-TRRC4ZJ7.js +2 -0
- package/dist/chunk-TXXOEMZJ.js +2 -0
- package/dist/chunk-UBGWN7I4.js +2 -0
- package/dist/chunk-UCD3H3UZ.js +5 -0
- package/dist/chunk-UDS562V4.js +5 -0
- package/dist/chunk-UNBY47BC.js +3 -0
- package/dist/chunk-UP3BUZR5.js +74 -0
- package/dist/chunk-UXM43C7T.js +3 -0
- package/dist/chunk-UZGZB3VB.js +3 -0
- package/dist/chunk-VE5AVNMP.js +2 -0
- package/dist/chunk-VEXUL62T.js +2 -0
- package/dist/chunk-VFY6Y2H6.js +61 -0
- package/dist/chunk-VUIYB2V3.js +2 -0
- package/dist/chunk-VXYS3FZD.js +23 -0
- package/dist/chunk-WE5RZHZ7.js +5 -0
- package/dist/chunk-WMPRTGH2.js +2 -0
- package/dist/chunk-WOQBZPIF.js +2 -0
- package/dist/chunk-XLQ3GLWZ.js +2 -0
- package/dist/chunk-XME3HPXZ.js +2 -0
- package/dist/chunk-XMQ23E27.js +2 -0
- package/dist/chunk-XWUOUWYI.js +2 -0
- package/dist/chunk-XZEE23VG.js +5 -0
- package/dist/chunk-Y6KHROC3.js +7 -0
- package/dist/chunk-YESXMKX3.js +3 -0
- package/dist/chunk-YMGZZEW4.js +2 -0
- package/dist/chunk-YSNONTJ2.js +2 -0
- package/dist/chunk-YUKYB54I.js +1 -0
- package/dist/chunk-YVCIMIOC.js +12 -0
- package/dist/chunk-Z54RD7VL.js +3 -0
- package/dist/chunk-ZKX2FRS6.js +15 -0
- package/dist/chunk-ZMI2JSX2.js +2 -0
- package/dist/chunk-ZV3JV5G5.js +8 -0
- package/dist/chunk-ZZ3MWF33.js +4 -0
- package/dist/chunk-ZZXSWSN6.js +2 -0
- package/dist/cli-context-3SNLDYBM.js +3 -0
- package/dist/cli-context-T3B7W6GG.js +2 -0
- package/dist/cli-program-YNOXO72B.js +7 -0
- package/dist/cli.js +3 -0
- package/dist/code-DlqpBDd0.d.ts +121 -0
- package/dist/command-descriptors-6AOUKWW7.js +346 -0
- package/dist/command-descriptors-ZFKJSRUP.js +344 -0
- package/dist/command-panels-SZONPMLJ.js +3 -0
- package/dist/config-types-BNoC96J3.d.ts +560 -0
- package/dist/db-D7sauVFH.d.ts +95 -0
- package/dist/direct-navigation-DP4LVMRX.js +3 -0
- package/dist/direct-navigation-FLUS3BT6.js +2 -0
- package/dist/exploration-topology-BG4v30HZ.d.ts +256 -0
- package/dist/file-dep-graph-Bqg3t3Px.d.ts +4 -0
- package/dist/file-kind-BKCVMNUf.d.ts +10 -0
- package/dist/frontend-behavior-evidence-EfM4_9bc.d.ts +4 -0
- package/dist/git-history-ChNHbfZQ.d.ts +13 -0
- package/dist/graph-evidence-BIFqyisO.d.ts +131 -0
- package/dist/health-DJaZXg8I.d.ts +340 -0
- package/dist/index.d.ts +183 -0
- package/dist/index.js +2 -0
- package/dist/invocation-command-descriptors-QT2JMY5J.js +3 -0
- package/dist/invocation-command-descriptors-YN4QJEAX.js +2 -0
- package/dist/next-anchor-candidates-BwMczMvX.d.ts +90 -0
- package/dist/output-continuation-command-2V2SL4TD.js +2 -0
- package/dist/output-continuation-command-65J5IP3O.js +3 -0
- package/dist/postinstall.js +3 -0
- package/dist/project-reindex-5JOKXAXT.js +2 -0
- package/dist/project-reindex-UQBIKO4M.js +3 -0
- package/dist/queries/affected.d.ts +40 -0
- package/dist/queries/affected.js +2 -0
- package/dist/queries/anchors.d.ts +123 -0
- package/dist/queries/anchors.js +2 -0
- package/dist/queries/architecture.d.ts +166 -0
- package/dist/queries/architecture.js +2 -0
- package/dist/queries/bottlenecks.d.ts +68 -0
- package/dist/queries/bottlenecks.js +2 -0
- package/dist/queries/by-kind.d.ts +27 -0
- package/dist/queries/by-kind.js +2 -0
- package/dist/queries/call-graph.d.ts +52 -0
- package/dist/queries/call-graph.js +2 -0
- package/dist/queries/change-surface.d.ts +55 -0
- package/dist/queries/change-surface.js +2 -0
- package/dist/queries/cleanup-plan.d.ts +66 -0
- package/dist/queries/cleanup-plan.js +2 -0
- package/dist/queries/co-change.d.ts +90 -0
- package/dist/queries/co-change.js +2 -0
- package/dist/queries/code.d.ts +6 -0
- package/dist/queries/code.js +2 -0
- package/dist/queries/complexity-hotspots.d.ts +61 -0
- package/dist/queries/complexity-hotspots.js +2 -0
- package/dist/queries/complexity.d.ts +74 -0
- package/dist/queries/complexity.js +2 -0
- package/dist/queries/context.d.ts +146 -0
- package/dist/queries/context.js +2 -0
- package/dist/queries/convergence.d.ts +33 -0
- package/dist/queries/convergence.js +2 -0
- package/dist/queries/coupling.d.ts +32 -0
- package/dist/queries/coupling.js +2 -0
- package/dist/queries/cycles.d.ts +66 -0
- package/dist/queries/cycles.js +2 -0
- package/dist/queries/dataflow.d.ts +77 -0
- package/dist/queries/dataflow.js +2 -0
- package/dist/queries/dead.d.ts +58 -0
- package/dist/queries/dead.js +2 -0
- package/dist/queries/decorative-checkers.d.ts +34 -0
- package/dist/queries/decorative-checkers.js +2 -0
- package/dist/queries/deep-chains.d.ts +5 -0
- package/dist/queries/deep-chains.js +2 -0
- package/dist/queries/dependence-slice.d.ts +46 -0
- package/dist/queries/dependence-slice.js +2 -0
- package/dist/queries/dependency-depth.d.ts +49 -0
- package/dist/queries/dependency-depth.js +2 -0
- package/dist/queries/deps.d.ts +15 -0
- package/dist/queries/deps.js +2 -0
- package/dist/queries/diff-impact.d.ts +165 -0
- package/dist/queries/diff-impact.js +2 -0
- package/dist/queries/doc-drift.d.ts +115 -0
- package/dist/queries/doc-drift.js +2 -0
- package/dist/queries/drift.d.ts +79 -0
- package/dist/queries/drift.js +2 -0
- package/dist/queries/duplicate-bodies.d.ts +55 -0
- package/dist/queries/duplicate-bodies.js +2 -0
- package/dist/queries/entry-map.d.ts +121 -0
- package/dist/queries/entry-map.js +2 -0
- package/dist/queries/evidence.d.ts +70 -0
- package/dist/queries/evidence.js +2 -0
- package/dist/queries/extract-candidates.d.ts +52 -0
- package/dist/queries/extract-candidates.js +2 -0
- package/dist/queries/fan.d.ts +53 -0
- package/dist/queries/fan.js +2 -0
- package/dist/queries/files.d.ts +20 -0
- package/dist/queries/files.js +2 -0
- package/dist/queries/health.d.ts +8 -0
- package/dist/queries/health.js +2 -0
- package/dist/queries/hierarchy.d.ts +21 -0
- package/dist/queries/hierarchy.js +2 -0
- package/dist/queries/hotspots.d.ts +42 -0
- package/dist/queries/hotspots.js +2 -0
- package/dist/queries/imports.d.ts +34 -0
- package/dist/queries/imports.js +2 -0
- package/dist/queries/incomplete-migration.d.ts +90 -0
- package/dist/queries/incomplete-migration.js +2 -0
- package/dist/queries/index.d.ts +180 -0
- package/dist/queries/index.js +2 -0
- package/dist/queries/isolated.d.ts +24 -0
- package/dist/queries/isolated.js +2 -0
- package/dist/queries/locality-candidates.d.ts +51 -0
- package/dist/queries/locality-candidates.js +2 -0
- package/dist/queries/members.d.ts +21 -0
- package/dist/queries/members.js +2 -0
- package/dist/queries/methods.d.ts +43 -0
- package/dist/queries/methods.js +2 -0
- package/dist/queries/not-implemented.d.ts +33 -0
- package/dist/queries/not-implemented.js +2 -0
- package/dist/queries/outline.d.ts +22 -0
- package/dist/queries/outline.js +2 -0
- package/dist/queries/passthrough-candidates.d.ts +41 -0
- package/dist/queries/passthrough-candidates.js +2 -0
- package/dist/queries/plan-context.d.ts +33 -0
- package/dist/queries/plan-context.js +2 -0
- package/dist/queries/react-component-duplicates.d.ts +39 -0
- package/dist/queries/react-component-duplicates.js +2 -0
- package/dist/queries/react-hook-candidates.d.ts +44 -0
- package/dist/queries/react-hook-candidates.js +2 -0
- package/dist/queries/react-large-component-pressure.d.ts +34 -0
- package/dist/queries/react-large-component-pressure.js +2 -0
- package/dist/queries/recent-duplicates.d.ts +79 -0
- package/dist/queries/recent-duplicates.js +2 -0
- package/dist/queries/redundant-reexports.d.ts +37 -0
- package/dist/queries/redundant-reexports.js +2 -0
- package/dist/queries/reference-neighborhood.d.ts +4 -0
- package/dist/queries/reference-neighborhood.js +2 -0
- package/dist/queries/reference-reachability.d.ts +48 -0
- package/dist/queries/reference-reachability.js +2 -0
- package/dist/queries/refs.d.ts +13 -0
- package/dist/queries/refs.js +2 -0
- package/dist/queries/self-audit.d.ts +65 -0
- package/dist/queries/self-audit.js +2 -0
- package/dist/queries/similar-chains.d.ts +48 -0
- package/dist/queries/similar-chains.js +2 -0
- package/dist/queries/similar-files.d.ts +35 -0
- package/dist/queries/similar-files.js +2 -0
- package/dist/queries/similar-signatures.d.ts +46 -0
- package/dist/queries/similar-signatures.js +2 -0
- package/dist/queries/similar.d.ts +187 -0
- package/dist/queries/similar.js +2 -0
- package/dist/queries/slice.d.ts +4 -0
- package/dist/queries/slice.js +2 -0
- package/dist/queries/source-inspection.d.ts +209 -0
- package/dist/queries/source-inspection.js +2 -0
- package/dist/queries/source-search.d.ts +85 -0
- package/dist/queries/source-search.js +2 -0
- package/dist/queries/stale-abstractions.d.ts +72 -0
- package/dist/queries/stale-abstractions.js +2 -0
- package/dist/queries/stats.d.ts +15 -0
- package/dist/queries/stats.js +2 -0
- package/dist/queries/surface.d.ts +22 -0
- package/dist/queries/surface.js +2 -0
- package/dist/queries/symbols.d.ts +14 -0
- package/dist/queries/symbols.js +2 -0
- package/dist/queries/system-map.d.ts +449 -0
- package/dist/queries/system-map.js +2 -0
- package/dist/queries/system.d.ts +21 -0
- package/dist/queries/system.js +2 -0
- package/dist/queries/test-quality.d.ts +56 -0
- package/dist/queries/test-quality.js +2 -0
- package/dist/queries/trace.d.ts +68 -0
- package/dist/queries/trace.js +2 -0
- package/dist/queries/twin-ab.d.ts +66 -0
- package/dist/queries/twin-ab.js +2 -0
- package/dist/queries/twin-drift.d.ts +119 -0
- package/dist/queries/twin-drift.js +2 -0
- package/dist/queries/unused-imports.d.ts +4 -0
- package/dist/queries/unused-imports.js +2 -0
- package/dist/queries/unused-params.d.ts +38 -0
- package/dist/queries/unused-params.js +2 -0
- package/dist/queries/value-flow.d.ts +42 -0
- package/dist/queries/value-flow.js +2 -0
- package/dist/queries/vue-component-duplicates.d.ts +43 -0
- package/dist/queries/vue-component-duplicates.js +2 -0
- package/dist/queries/vue-composable-candidates.d.ts +44 -0
- package/dist/queries/vue-composable-candidates.js +2 -0
- package/dist/queries/vue-large-view-pressure.d.ts +41 -0
- package/dist/queries/vue-large-view-pressure.js +2 -0
- package/dist/queries/wrapper-candidates.d.ts +34 -0
- package/dist/queries/wrapper-candidates.js +2 -0
- package/dist/reindex-worker.js +3 -0
- package/dist/reindex.d.ts +254 -0
- package/dist/reindex.js +298 -0
- package/dist/repository-text-C0Q8VYdN.d.ts +19 -0
- package/dist/runtime.d.ts +555 -0
- package/dist/runtime.js +4 -0
- package/dist/rust-semantic-session-server.js +2 -0
- package/dist/rust-semantic-session-worker.js +2 -0
- package/dist/rust-semantic-worker.js +2 -0
- package/dist/scip-cli-B7N3haxa.d.ts +67 -0
- package/dist/source-snippet-_wrcgmZc.d.ts +15 -0
- package/dist/symbol-types-BIQwfoAx.d.ts +74 -0
- package/dist/typescript-mailbox-worker.js +2 -0
- package/dist/watch-server.js +8 -0
- package/docs/AGENT_GUIDE.md +148 -0
- package/docs/AI_FAILURE_MODES.md +43 -0
- package/docs/API.md +40 -0
- package/docs/API_EVOLUTION.md +77 -0
- package/docs/CLI_JSON_OUTPUT.md +389 -0
- package/docs/COMMAND_REFERENCE.md +294 -0
- package/docs/CONFIGURATION_WRITE_SAFETY.md +131 -0
- package/docs/DETECTOR_GUIDE.md +46 -0
- package/docs/DURABILITY.md +159 -0
- package/docs/INDEX_GENERATIONS.md +167 -0
- package/docs/LOCK_PROTOCOL.md +133 -0
- package/docs/MAILBOX_LIFECYCLE.md +224 -0
- package/docs/REGEX_POLICY.md +36 -0
- package/docs/REINDEX_METADATA_COMPATIBILITY.md +104 -0
- package/docs/RUST_DURABLE_SESSION_PROTOCOL.md +126 -0
- package/docs/SECURITY_MODEL.md +125 -0
- package/docs/TELEMETRY_RETENTION.md +84 -0
- package/docs/TIME_SEMANTICS.md +77 -0
- package/docs/WATCH_REFRESH_REQUESTS.md +123 -0
- package/docs/WINDOWS_SIDECAR_RELEASE.md +424 -0
- package/docs/accuracy-audit-checklist.md +304 -0
- package/docs/accuracy-hardening-goal.md +500 -0
- package/docs/analyzer-inventory.md +78 -0
- package/docs/analyzer-validation-protocol.md +84 -0
- package/docs/architecture-coherence-vision.md +254 -0
- package/docs/assets/codebaseiq-logo-dark.svg +21 -0
- package/docs/assets/codebaseiq-logo.svg +24 -0
- package/docs/locality-analyzer-design.md +193 -0
- package/docs/schemas/cli-json-envelope.schema.json +237 -0
- package/docs/schemas/cli-output-page.schema.json +104 -0
- package/docs/schemas/npm-release-state.schema.json +146 -0
- package/docs/schemas/observation-receipt.schema.json +164 -0
- package/docs/schemas/project-config.schema.json +318 -0
- package/docs/schemas/suppression-record.schema.json +79 -0
- package/docs/schemas/windows-sidecar-provenance.schema.json +137 -0
- package/package.json +482 -0
- package/scripts/build-codebaseiq-windows.mjs +197 -0
- package/scripts/codebaseiq-windows-provenance.mjs +364 -0
- package/scripts/evidence-product-contract.mjs +197 -0
- package/scripts/verify-codebaseiq-windows.mjs +29 -0
- package/skills/codebaseiq/SKILL.md +75 -0
- package/skills/codebaseiq/agents/openai.yaml +4 -0
- package/skills/codebaseiq-explore/SKILL.md +34 -0
- package/skills/codebaseiq-explore/agents/openai.yaml +4 -0
- package/skills/concrete-plan/SKILL.md +79 -0
- package/skills/concrete-plan/agents/openai.yaml +4 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{appendFileSync as w,mkdirSync as D}from"fs";import{createHash as N,randomUUID as F}from"crypto";import{dirname as k}from"path";import{performance as s}from"perf_hooks";var y="CODEBASEIQ_PROFILE",_="CODEBASEIQ_PROFILE_OUT",g="CODEBASEIQ_PROFILE_COMMAND",P="CODEBASEIQ_PROFILE_CACHE_STATE",u="CODEBASEIQ_PROFILE_RUN_ID",l="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY",p="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY_KIND",m=[y,_,g,P,u,l,p],K=new Set(m),E=new Set,I=new Map,O=!1;function a(){let e=process.env[y];return e==="1"||e==="true"}function x(){return process.env[_]}function v(){return process.env[g]}function L(){return process.env[P]}function M(){let e=process.env[u];if(e)return e;if(!a())return;let n=F();return process.env[u]=n,n}function R(){return process.env[l]}function T(e){let n=R();if(n)return n;if(!a())return;let o=M();if(!o)return;let t=e.projectFingerprint?"published-project":"run-only",r=S(["profile-workload-v1",e.toolVersion,e.command,e.projectFingerprint??o]);return process.env[l]=r,process.env[p]=t,r}function S(e){return N("sha256").update(JSON.stringify(e)).digest("hex").slice(0,24)}function V(){return Object.fromEntries(m.flatMap(e=>{let n=process.env[e];return n===void 0?[]:[[e,n]]}))}function j(e,n,o){if(!a())return n();let t=s.now();try{let r=n();return d({type:"span",name:e,durationMs:Math.round(s.now()-t),ok:!0,...f(o)??{}}),r}catch(r){throw d({type:"span",name:e,durationMs:Math.round(s.now()-t),ok:!1,error:r instanceof Error?r.message:String(r),...f(o)??{}}),r}}async function B(e,n,o){if(!a())return n();let t=s.now();try{let r=await n();return d({type:"span",name:e,durationMs:Math.round(s.now()-t),ok:!0,...f(o)??{}}),r}catch(r){throw d({type:"span",name:e,durationMs:Math.round(s.now()-t),ok:!1,error:r instanceof Error?r.message:String(r),...f(o)??{}}),r}}function d(e,n=x()){let o=h(e),t={timestamp:new Date().toISOString(),pid:process.pid,runId:M(),command:v(),cacheState:L(),...o,...e},r=`${JSON.stringify(t)}
|
|
2
|
+
`;if(n)try{let i=k(n);E.has(i)||(D(i,{recursive:!0}),E.add(i)),w(n,r);return}catch(i){O||(O=!0,process.stderr.write(`[profile] failed to write ${n}: ${i instanceof Error?i.message:String(i)}
|
|
3
|
+
`));return}a()&&process.stderr.write(r)}function h(e){let n=R()??T({command:v()??"unknown",toolVersion:"unknown",projectFingerprint:null});if(!n)return{};let o=process.env[p],t=typeof e.name=="string"?e.name:void 0;if(!t)return{workloadIdentity:n,workloadIdentityKind:o};let r=t.split(/[.:]/,1)[0]??t,i=`${n}\0${t}`,c=I.get(i);return c||(c=S(["profile-subsystem-v1",n,t]),I.set(i,c)),{workloadIdentity:n,workloadIdentityKind:o,subsystem:r,subsystemWorkIdentity:c}}function f(e){return typeof e=="function"?e():e}export{a,S as b,V as c,j as d,B as e,d as f};
|
|
4
|
+
//# sourceMappingURL=chunk-3LCDIREB.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{wb as o}from"./chunk-GTIYTDRE.js";import{G as n}from"./chunk-WE5RZHZ7.js";async function i(t){if(typeof t!="string"||t.length===0)throw new Error("Output continuation requires a cursor.");await o(t,n)}var u={id:"continue",command:"continue <cursor>",hidden:!0,description:"Continue an immutable output snapshot",renderShape:"custom",handler:i};export{u as a};
|
|
2
|
+
//# sourceMappingURL=chunk-476NR5B7.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{A as G,D as P,a as y,b as ce,i as k,j as le,t as B,u as de,w as j,x as ue,y as b}from"./chunk-LTA3BRZX.js";import{$a as C,Za as g,_a as ne,bb as x,j as ee,k as te,mb as oe,nb as re,ob as ie,qb as se,r as S,sb as ae,ub as E}from"./chunk-GTIYTDRE.js";import{G as Y,H,J as Z,q as N,r as L,t as M}from"./chunk-NCZUNH3E.js";import{Q as X}from"./chunk-Z54RD7VL.js";import{i as W}from"./chunk-3IER7Q6H.js";import{c as T,g as Q}from"./chunk-DRENNWRG.js";function ge(e,n,t){if(!Number.isSafeInteger(t.limit)||t.limit<=0)throw new Error("Reference page limit must be a positive safe integer.");let o=N(e,n);if(!o)return{rows:[],hasMore:!1,producer:t.producer??"source-keyset",semanticEnrichment:!1};if(t.producer==="complete-only"||t.semantic===!0||o.relativePath.endsWith(".rb"))return F(e,n,t);let i=Y(e,o);if(!i)return F(e,n,t);let s=fe(e,o),c=Te(e,s),a=[],l=t.producer==="source-keyset";for(let u of c){if(t.after&&u<t.after.relativePath)continue;t.instrumentation?.fileScanned?.(u);let f=H(e,i,u);f.length>0&&(l=!0);let d=new Set(f);s?.relativePath===u&&d.add(s.line);for(let m of[...d].sort((p,Ae)=>p-Ae)){let p={relativePath:u,line:m};if(!(t.after&&R(p,t.after)<=0)&&(a.push(p),t.instrumentation?.rowAccepted?.(p),l&&a.length>t.limit))return me(a,t.limit)}}return l?me(a,t.limit):F(e,n,t,s)}function R(e,n){return(e.relativePath<n.relativePath?-1:e.relativePath>n.relativePath?1:0)||e.line-n.line}function me(e,n){return{rows:e.slice(0,n),hasMore:e.length>n,producer:"source-keyset",semanticEnrichment:!1}}function F(e,n,t,o){let r=N(e,n),i=t.semantic===!0||r?.relativePath.endsWith(".rb")?S(e,n,{semantic:t.semantic}):De(e,n,o),s=Me(i).filter(c=>!t.after||R(c,t.after)>0);for(let c of s.slice(0,t.limit+1))t.instrumentation?.rowAccepted?.(c);return{rows:s.slice(0,t.limit),hasMore:s.length>t.limit,producer:"complete-only",semanticEnrichment:t.semantic===!0}}function De(e,n,t){let o=N(e,n);if(!o)return[];let r=t===void 0?fe(e,o):t,i=Z(e,o).map(s=>({relativePath:s.file,line:s.line}));return r?[r,...i]:i}function fe(e,n){return!Q(n.symbol)&&!e.isIgnored(n.relativePath)?{relativePath:n.relativePath,line:n.startLine}:null}function Te(e,n){let t=W(e);return!n||t.includes(n.relativePath)?t:[...t,n.relativePath].sort((o,r)=>o<r?-1:o>r?1:0)}function Me(e){let n=new Map;for(let t of e)n.set(`${t.relativePath}\0${t.line}`,t);return[...n.values()].sort(R)}import{InvalidArgumentError as v}from"commander";var St=X,Be=/^[+-]?\d+$/u,je=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/u,xt=(e=>V(e,"an integer")),pe=(e=>{let n=V(e,"a non-negative integer");if(n<0)throw new v(`Expected a non-negative integer, got "${e}".`);return n}),he=(e=>{let n=V(e,"a positive integer");if(n<1)throw new v(`Expected a positive integer, got "${e}".`);return n}),Et=(e=>{if(!je.test(e))throw new v(`Expected a number, got "${e}".`);let n=Number(e);if(!Number.isFinite(n))throw new v(`Expected a finite number, got "${e}".`);return n});function V(e,n){if(!Be.test(e))throw new v(`Expected ${n}, got "${e}".`);let t=Number(e);if(!Number.isSafeInteger(t))throw new v(`Expected ${n}, got "${e}".`);return t}function h(e,n,t,...o){return o.length>0?{flags:e,description:n,parser:t,defaultValue:o[0]}:{flags:e,description:n,parser:t}}function Ge(){return h("--json","Output as JSON for programmatic consumption")}function Fe(){return h("--compact","Emit minified one-line JSON (use with --json)")}function Ve(){return h("--result-only","Emit only the command-owned result (use with --json)")}function Ce(e=[]){return I(e)}function I(e=[]){let n=[Ge(),Ve(),Fe()],t=new Set(n.map(o=>o.flags));return[...e.filter(o=>!t.has(o.flags)),...n]}function $(e,n=[]){return{category:e,examples:n}}function Pt(e,n){return{origin:"mixed",observedSources:e,producerValidation:{status:"not-evaluated"},families:n}}function $t(e,n){return{origin:e,observedSources:n,producerValidation:{status:"not-evaluated"}}}function wt(e,n,t){return{id:e,selector:n,origin:{kind:"fixed",origin:t}}}function Ot(e,n,t,o){return{id:e,selector:n,origin:{kind:"result-field",field:t,values:o}}}function w(e,n,t,o,r,i,s){return{answers:typeof e=="string"?[e]:e,returns:typeof n=="string"?[n]:n,inputs:t,coverage:o,operation:i,semantic:s,...r?{scope:r}:{}}}function Nt(e,n,t,o,r,i=y){let s=typeof e=="string"?[e]:e,c=typeof n=="string"?[n]:n;return w(s,c,t,o,r,i,K(s.join(" "),c.join("; "),["This command establishes only its declared result units and evidence contract."],void 0,{outputCost:o==="complete"?"bounded":"variable"}))}function ye(e,n,t,o,r,i=y){let s=typeof e=="string"?[e]:e,c=typeof n=="string"?[n]:n;return w(s,c,t,o,r,i,Ke(c.join("; "),["This command does not establish repository graph relationships unless its result says so explicitly."]))}function be(e,n,t={ranking:"identity-only"}){return{kind:"locator",locates:e,nonClaims:n,outputCost:"small",frontierClosure:["evidence","inspect","code"],...t}}function Lt(e){return{kind:"graph-projection",outputCost:"bounded",frontierClosure:["inspect","code"],...e}}function Re(e,n,t,o={}){return{kind:"source-read",reads:e,nonClaims:n,outputCost:"potentially-large",frontierClosure:[],...t?{compatibility:t}:{},...o}}function K(e,n,t,o,r={}){return{kind:"analysis",analysis:e,resultMeaning:n,nonClaims:t,outputCost:"bounded",frontierClosure:["inspect","code"],...o?{compatibility:o}:{},...r}}function Ke(e,n,t,o={}){return{kind:"maintenance",effect:e,nonClaims:n,outputCost:"variable",frontierClosure:[],...t?{compatibility:t}:{},...o}}function J(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}function A(e){return e.generation.identity}function U(e){return"after"in e?J({version:2,...e}):J({version:1,...e})}function ve(e,n){let t=_e(e);if(!Je(t)&&!Ue(t))throw new Error("Invalid result cursor. Run the command again without --cursor.");return ze(t,n),t}function Je(e){if(!e||typeof e!="object")return!1;let n=e;return n.version===1&&typeof n.command=="string"&&typeof n.target=="string"&&Number.isSafeInteger(n.offset)&&(n.offset??-1)>=0&&typeof n.indexGeneration=="string"&&n.indexGeneration.length>0}function Ue(e){if(!e||typeof e!="object")return!1;let n=e,t=n.after;return n.version===2&&typeof n.command=="string"&&typeof n.target=="string"&&!!t&&typeof t.relativePath=="string"&&t.relativePath.length>0&&Number.isSafeInteger(t.line)&&(t.line??-1)>=0&&(n.producer==="source-keyset"||n.producer==="complete-only")&&typeof n.semanticEnrichment=="boolean"&&typeof n.indexGeneration=="string"&&n.indexGeneration.length>0}function _e(e){try{return JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{throw new Error("Invalid result cursor. Run the command again without --cursor.")}}function ze(e,n){if(e.command!==n.command||e.target!==n.target)throw new Error("This cursor belongs to a different command or target. Run again without --cursor.");if(e.indexGeneration!==n.indexGeneration)throw new Error("The index changed after this cursor was issued. Run again without --cursor.")}function Se(e,n){let t=L(e,n),o=qe(t);for(let r of o)console.log(r)}function xe(e,n,t="No results found for resolved symbol."){return L(e,n).match?t:z(n,M(e,n,5))}function _(e,n,t,o){return{...D(e,n),[o]:t}}function D(e,n){let t=L(e,n);return t.match?{matched:!0,resolved:{symbol:t.match.symbol,shortName:T(t.match.symbol),relativePath:t.match.relativePath},otherMatches:t.candidates.map(o=>({shortName:o.shortName,relativePath:o.relativePath,startLine:o.startLine})),totalMatches:t.total}:{matched:!1,suggestions:M(e,n,5)}}function z(e,n){let t=`No definition matched '${e}'.`;return n.length>0?`${t} Suggestions: ${n.join(", ")}`:t}function qe(e){if(!e.match||e.total<=1)return[];let n=e.match,t=Math.max(0,e.total-1),o=[`Resolved: ${T(n.symbol)} (${n.relativePath}) -- ${t} other definition(s) share this name; qualify as <dir/leaf> to target another.`],r=e.candidates.slice(0,3);return r.length>0&&o.push(`Alternates: ${r.map(i=>`${i.shortName} (${i.relativePath}:${g(i.startLine)})`).join("; ")}`),o.push(""),o}var We=k(({db:e,args:n,opts:t})=>{let o=B(n,0),r=b(t,"signatures"),i=ee(e,o);if(b(t,"json")){P("outline",n,t,i);return}if(console.log(`\u2550\u2550\u2550 REQUEST \u2550\u2550\u2550
|
|
2
|
+
file=${JSON.stringify(o)}; signatures=${r?"shown":"hidden"}`),i.length===0){console.log(`
|
|
3
|
+
\u2550\u2550\u2550 OBSERVED FACTS \u2550\u2550\u2550
|
|
4
|
+
No compiler-owned constructs were found for ${JSON.stringify(o)}.`),console.log(`
|
|
5
|
+
\u2550\u2550\u2550 EVIDENCE CALIBRATION \u2550\u2550\u2550
|
|
6
|
+
Missing compiler constructs do not establish that the current text file is empty or irrelevant.`),console.log(`
|
|
7
|
+
\u2550\u2550\u2550 COVERAGE \u2550\u2550\u2550
|
|
8
|
+
Compiler ownership is unavailable or empty for this exact file selector.`),console.log(`
|
|
9
|
+
\u2550\u2550\u2550 RECOVERY \u2550\u2550\u2550
|
|
10
|
+
Read current source exactly with: codebaseiq code ${O(o)}`);return}function s(c,a){for(let l of c){let u=" ".repeat(a),f=r&&l.signature?` - ${Oe(l.signature)}`:"";console.log(`${u}${ne(l.startLine,l.endLine)} ${l.shortName}${f}`),s(l.children,a+1)}}console.log(`
|
|
11
|
+
\u2550\u2550\u2550 OBSERVED FACTS \u2550\u2550\u2550`),s(i,0),console.log(`
|
|
12
|
+
\u2550\u2550\u2550 EVIDENCE CALIBRATION \u2550\u2550\u2550
|
|
13
|
+
These are compiler-owned identities and source ranges. Ownership and nesting do not establish execution or task relevance.`),console.log(`
|
|
14
|
+
\u2550\u2550\u2550 COVERAGE \u2550\u2550\u2550
|
|
15
|
+
${we(i)} compiler construct(s) returned in ${i.length} top-level tree(s).`),console.log(`
|
|
16
|
+
\u2550\u2550\u2550 RECOVERY \u2550\u2550\u2550
|
|
17
|
+
Every displayed file:line is an exact evidence root. Exact top-level symbol selectors:`);for(let c of i){let a=`'${c.symbol.replaceAll("'","'\\''")}'`;console.log(` ${c.shortName}: ${a}`)}});function we(e){return e.reduce((n,t)=>n+1+we(t.children),0)}function Oe(e){return e.length>120?`${e.slice(0,117)}...`:e}var Qe=le("refs",({db:e,args:n,opts:t,budget:o})=>{let r=B(n,0),i=j(t,"cursor"),s=ue(t,"limit"),c=A(e),a=i?ve(i,{command:"refs",target:r,indexGeneration:c}):void 0,l=!a&&s===void 0,u=l?Ye(e,r,o.semantic):a?.version===1?He(e,r,a.offset,s??50,o.semantic):Ze(e,r,{limit:s??50,cursor:a,semantic:a?.semanticEnrichment??b(t,"full"),indexGeneration:c}),{rows:f,continuation:d,coverage:m}=u;if(b(t,"json")){let p={..._(e,r,f,"references"),pagination:u.pagination};P("refs",n,t,p,{analysisBudget:o.analysisBudget,coverage:m});return}if(f.length===0)return x.empty(xe(e,r,"No references found."));if(Se(e,r),x.groupedByFile(f,p=>` line ${g(p.line)}`),u.pagination.producer==="complete-only"&&!l&&console.error(`
|
|
18
|
+
This evidence provider required complete analysis; --limit bounded the returned rows, not analysis work.`),d){let p=m.totalKnown?`${m.omitted} omitted; `:"More references are available; ";console.log(`
|
|
19
|
+
${p}continue with --cursor ${d.cursor}`)}});function Ye(e,n,t){let o=S(e,n,{semantic:t}).sort(R);return{rows:o,coverage:{complete:!0,totalKnown:!0,returned:o.length,total:o.length,omitted:0},pagination:{cursorVersion:2,producer:"complete-only",semanticEnrichment:t}}}function He(e,n,t,o,r){let i=S(e,n,{semantic:r}).sort(R);if(t>i.length)throw new Error("This cursor points past the current result set. Run again without --cursor.");let s=i.slice(t,t+o),c=t+s.length,a=s[s.length-1],l=t===0&&s.length===i.length,u=c<i.length&&a?{cursor:U({command:"refs",target:n,after:a,producer:"complete-only",semanticEnrichment:r,indexGeneration:A(e)}),indexGeneration:A(e)}:void 0;return{rows:s,continuation:u,coverage:l?{complete:!0,totalKnown:!0,returned:s.length,total:s.length,omitted:0}:{complete:!1,totalKnown:!0,returned:s.length,total:i.length,omitted:i.length-s.length,...u?{continuation:u}:{}},pagination:{cursorVersion:2,producer:"complete-only",semanticEnrichment:r}}}function Ze(e,n,t){let o=ge(e,n,{limit:t.limit,after:t.cursor?.after,producer:t.cursor?.producer,semantic:t.semantic}),r=o.rows[o.rows.length-1],i=o.hasMore&&r?{cursor:U({command:"refs",target:n,after:r,producer:o.producer,semanticEnrichment:o.semanticEnrichment,indexGeneration:t.indexGeneration}),indexGeneration:t.indexGeneration}:void 0,s=!t.cursor&&!o.hasMore;return{rows:o.rows,continuation:i,coverage:s?{complete:!0,totalKnown:!0,returned:o.rows.length,total:o.rows.length,omitted:0}:{complete:!1,totalKnown:!1,returned:o.rows.length,...i?{continuation:i}:{}},pagination:{cursorVersion:2,producer:o.producer,semanticEnrichment:o.semanticEnrichment}}}var Xe=k(({db:e,args:n,opts:t})=>{ae(e.config.projectRoot,"code",t.session!==!1);let o=de(n,0),r=G(t,"context",0),i=tt(t),s=te(e,o,{context:r,members:i}),c=nt(s);if(b(t,"json")){if(c){let d=o[0];P("code",o,t,_(e,d,c,"code"),{resultOnly:dt(e,d,c)});return}P("code",o,t,s,{coverage:{complete:!0,totalKnown:!0,returned:s.entries.length,total:s.requested,omitted:0},resultOnly:ut(s)});return}let a=oe(),l=c?Ne(c,s.bindingClosure,!0):q(s,!0),u=G(t,"outputPageSize",E);if(l.length>u){re(a),console.error(at(s,o,{context:r,members:i,pageSize:u,packetCharacters:l.length})),process.exitCode=1;return}if(c){process.stdout.write(l);return}let f=s.entries[0];if(s.requested===1&&f?.status==="missing")return x.empty(z(f.selector,f.suggestions));process.stdout.write(l)}),et=k(({opts:e})=>{let n=b(e,"reset"),t=se(n);if(!t.enabled){x.empty(t.reason??"Exploration-session deduplication is unavailable.");return}console.log(n?"Exploration-session ledger reset; subsequent exploration will emit evidence again.":`Exploration session: ${t.uniqueLines.toLocaleString()} unique source line(s) and ${t.evidenceItems.toLocaleString()} graph evidence item(s) delivered across ${t.emissions.toLocaleString()} emission(s).`),!n&&t.rows.length>0&&console.log(t.rows.join(`
|
|
20
|
+
`))});function tt(e){let n=j(e,"members")??"exported";if(n==="exported"||n==="all")return n;throw new RangeError(`--members must be "exported" or "all", got "${n}".`)}function nt(e){let n=e.entries[0];return e.requested===1&&n?.status==="matched"&&n.kind==="source"&&(!n.rangeCoverage||n.rangeCoverage.referencedDefinitions===0)&&n.results.length===1?n.results[0]:null}function q(e,n=!1){let t=["\u2550\u2550\u2550 REQUEST \u2550\u2550\u2550",` ${e.entries.map(a=>a.selector).join(", ")}`,"",`\u2550\u2550\u2550 OBSERVED FACTS (${e.requested} requested: ${e.matched} matched, ${e.ambiguous} ambiguous, ${e.missing} missing) \u2550\u2550\u2550`],o=new Set;for(let a of e.entries)for(let l of a.results){let u=`${l.relativePath}:${l.startLine}:${l.endLine}`;if(o.has(u)){t.push("",` ${a.selector}: source already included at ${C(l.relativePath,l.startLine,l.endLine)}.`);continue}o.add(u),(e.requested>1||a.status==="ambiguous")&&t.push("",` selector ${a.selector}`),ke(t,l,n)}let r=e.entries.filter(a=>a.kind==="file-source");if(r.length>0){t.push("","\u2550\u2550\u2550 FILE SOURCE COVERAGE \u2550\u2550\u2550");for(let a of r)rt(t,a)}let i=e.entries.filter(a=>a.rangeCoverage);if(i.length>0){t.push("","\u2550\u2550\u2550 RANGE SOURCE COVERAGE \u2550\u2550\u2550");for(let a of i)ot(t,a)}let s=e.entries.filter(a=>a.status==="ambiguous");if(s.length>0){t.push("","\u2550\u2550\u2550 AMBIGUOUS SELECTORS \u2550\u2550\u2550");for(let a of s)it(t,a)}let c=e.entries.filter(a=>a.status==="missing");if(c.length>0){t.push("","\u2550\u2550\u2550 MISSING SELECTORS \u2550\u2550\u2550");for(let a of c){let l=a.suggestions.length>0?` Suggestions: ${a.suggestions.join(", ")}`:"";t.push(` ${a.selector}: ${a.reason==="definition-source-unreadable"?"definition source unreadable.":"no definition matched."}${l}`)}}return Ie(t,e.bindingClosure),Le(t,e.entries.flatMap(a=>a.results)),st(t,e),`${t.join(`
|
|
21
|
+
`)}
|
|
22
|
+
`}function ot(e,n){let t=n.rangeCoverage;if(t&&(e.push(` ${n.selector} \u2014 requested lines returned plus ${t.returnedBodies} same-file callable body(ies), covering ${t.returnedDefinitions}/${t.referencedDefinitions} statically attributed same-file definition(s).`,` basis: ${t.basis}; dynamic calls and references outside the requested lines are not claimed`),t.omittedLedger.length!==0)){e.push(" OMITTED REFERENCED DEFINITIONS");for(let o of t.omittedLedger)e.push(` ${C(o.relativePath,o.startLine,o.endLine)} ${o.shortName}`)}}function Ne(e,n,t=!1){let o=["\u2550\u2550\u2550 REQUEST \u2550\u2550\u2550",` resolved-selector=${e.symbol}`,"","\u2550\u2550\u2550 OBSERVED FACTS \u2550\u2550\u2550"];return ke(o,e,t),Ie(o,n),Le(o,[e]),o.push("","\u2550\u2550\u2550 COVERAGE \u2550\u2550\u2550"," One exact selector resolved to the complete source body shown. Source identity does not establish callers or runtime relationships."),`${o.join(`
|
|
23
|
+
`)}
|
|
24
|
+
`}function Le(e,n){let t=n.flatMap(r=>r.freshness?[r.freshness]:[]);if(e.push("","\u2550\u2550\u2550 EVIDENCE CALIBRATION \u2550\u2550\u2550"," Source bodies are exact current working-tree text. Compiler identity and binding closure apply only within their reported semantic coverage."),t.length===0){e.push(" No source-freshness overlay was available.");return}let o={aligned:t.filter(r=>r.semantic.state==="aligned").length,stale:t.filter(r=>r.semantic.state==="stale").length,unavailable:t.filter(r=>r.semantic.state==="unavailable").length};e.push(`Text freshness: ${t.length}/${n.length} returned source body(ies) read from current working-tree bytes; semantic overlay ${o.aligned} aligned, ${o.stale} stale, ${o.unavailable} unavailable.`)}function ke(e,n,t){if(t){e.push(ie({relativePath:n.relativePath,startLine:n.startLine,source:n.source,sessionPolicy:"exact-unit",ownerSymbol:n.shortName,headerSuffix:` ${n.shortName} [${n.language??"unknown"}]`,indent:"",sourceIndent:" ",showFocusMarker:!1,lineNumberWidth:4,blankAfterHeader:!0}));return}e.push(`${C(n.relativePath,n.startLine,n.endLine)} ${n.shortName} [${n.language??"unknown"}]`,"");let o=n.source.split(`
|
|
25
|
+
`);for(let r=0;r<o.length;r++)e.push(` ${String(g(n.startLine+r)).padStart(4)} ${o[r]}`)}function rt(e,n){let t=n.fileCoverage;if(!t||(e.push(` ${n.selector} \u2014 ${t.returnedBodies} source body(ies) cover ${t.returnedDefinitions}/${t.totalDefinitions} indexed definition(s); ${t.omittedDefinitions} omitted definition(s) disclosed below.`,` basis: ${t.basis}; members=${t.members}`),t.omittedLedger.length===0))return;e.push(" OMITTED FILE-LOCAL DEFINITIONS");for(let r of t.omittedLedger){let i=r.signature?` \u2014 ${Oe(r.signature)}`:"",s=r.nestedDefinitions>0?` (+${r.nestedDefinitions} nested definition(s))`:"";e.push(` ${" ".repeat(r.depth)}${C(r.relativePath,r.startLine,r.endLine)} ${r.shortName}${i}${s}`)}let o=t.omittedLedger.filter(r=>r.depth===0);for(let r=0;r<o.length;r+=24){let i=o.slice(r,r+24);e.push(` Read omitted units together: codebaseiq code ${i.map(s=>O(`${s.relativePath}:${g(s.startLine)}-${g(s.endLine)}`)).join(" ")}`)}}function it(e,n){e.push(` ${n.selector} \u2014 ${n.totalCandidates} candidate(s); ${n.results.length>0?"all candidate bodies returned above":"no body selected"}.`);for(let t of n.candidates)e.push(` ${C(t.relativePath,t.startLine,t.endLine)} ${t.shortName}`);n.omittedCandidates>0&&e.push(` ... ${n.omittedCandidates} additional candidate identity(ies).`),n.candidates.length>0&&e.push(` Read shown candidates together: codebaseiq code ${n.candidates.map(t=>O(`${t.relativePath}:${g(t.startLine)}-${g(t.endLine)}`)).join(" ")}`)}function Ie(e,n){if(!(!n||n.inline.length===0)){e.push("","LITERAL VALUES");for(let t of n.inline)e.push(` inline ${t.name} @ ${C(t.relativePath,t.startLine,t.endLine)}`),e.push(` ${t.source??""}`)}}function st(e,n){let t=n.entries.flatMap(d=>d.fileCoverage?[d.fileCoverage]:[]),o=n.entries.flatMap(d=>d.rangeCoverage?[d.rangeCoverage]:[]);if(t.length===0&&o.length===0){e.push("","\u2550\u2550\u2550 COVERAGE \u2550\u2550\u2550",` ${n.requested}/${n.requested} selector(s) resolved to the source bodies shown. Selector accounting does not claim that referenced definitions or runtime relationships are complete. Source lines use absolute file line numbers and are citation-ready.`);return}let r=t.reduce((d,m)=>d+m.returnedBodies,0),i=t.reduce((d,m)=>d+m.returnedDefinitions,0),s=t.reduce((d,m)=>d+m.totalDefinitions,0),c=t.reduce((d,m)=>d+m.omittedDefinitions,0),a=o.reduce((d,m)=>d+m.referencedDefinitions,0),l=o.reduce((d,m)=>d+m.returnedDefinitions,0),u=o.reduce((d,m)=>d+m.omittedDefinitions,0),f=[...t.length>0?[`${t.length} file selector(s) returned ${r} source body(ies) covering ${i}/${s} indexed definition(s); ${c} file-local definition(s) omitted and disclosed`]:[],...o.length>0?[`${o.length} range selector(s) covered ${l}/${a} statically attributed same-file definition(s); ${u} referenced definition(s) omitted and disclosed`]:[]];e.push("","\u2550\u2550\u2550 COVERAGE \u2550\u2550\u2550",` ${n.requested}/${n.requested} selectors resolved; ${f.join("; ")}. Source lines use absolute file line numbers and are citation-ready.`)}function at(e,n,t){let o=[`CODE PACKET REFUSED: the complete packet needs ${t.packetCharacters.toLocaleString()} characters; the active output page is ${t.pageSize.toLocaleString()}.`,"No partial source was emitted."],r=ct(e,n,t);return o.push(`Run these ${r.commands.length} complete packet(s):`,...r.commands.map(i=>` ${i}`)),r.ledgerCommands.length>0&&o.push("Then inspect each complete omitted-definition ledger before making file-absence claims:",...r.ledgerCommands.map(i=>` ${i}`)),o.join(`
|
|
26
|
+
`)}function ct(e,n,t){let o=[],r=[],i=[],s=[],c=()=>{s.length!==0&&(o.push($e(s,t)),i=[],s=[])};for(let a=0;a<e.entries.length;a++){let l=e.entries[a],u=n[a];if(q(Pe(e,[l])).length>E){c();let m=l.results.flatMap(p=>lt(p));for(let p of m)o.push($e([p],{...t,members:"exported"}));l.fileCoverage?.omittedDefinitions&&r.push(`codebaseiq outline ${O(l.selector)} --signatures`);continue}let d=[...i,l];i.length>0&&q(Pe(e,d)).length>E&&c(),i.push(l),s.push(u)}return c(),{commands:o,ledgerCommands:r}}var Ee=E-8e3;function lt(e){if(Ne(e).length<=Ee)return[`${e.relativePath}:${g(e.startLine)}-${g(e.endLine)}`];let n=[],t=e.source.split(`
|
|
27
|
+
`),o=0,r=0;for(let i=0;i<t.length;i++){let s=t[i].length+12;i>o&&r+s>Ee&&(n.push(`${e.relativePath}:${g(e.startLine+o)}-${g(e.startLine+i-1)}`),o=i,r=0),r+=s}return n.push(`${e.relativePath}:${g(e.startLine+o)}-${g(e.endLine)}`),n}function Pe(e,n){return{requested:n.length,matched:n.filter(t=>t.status==="matched").length,ambiguous:n.filter(t=>t.status==="ambiguous").length,missing:n.filter(t=>t.status==="missing").length,entries:[...n],bindingClosure:e.bindingClosure}}function $e(e,n){return["codebaseiq","code",...e.map(O),...n.members==="all"?["--members","all"]:[],...n.context>0?["--context",String(n.context)]:[]].join(" ")}function dt(e,n,t){if(!t)return D(e,n);let o={file:t.relativePath,symbol:t.shortName,language:t.language??"unknown",range:{startLine:g(t.startLine),endLine:g(t.endLine)},...t.freshness?{freshness:t.freshness}:{},lines:t.source.split(`
|
|
28
|
+
`).map((s,c)=>({line:g(t.startLine+c),text:s}))},r=D(e,n),i=r.totalMatches??0;return!r.matched||!r.resolved||i<=1?o:{...o,resolution:{selected:r.resolved,alternatives:r.otherMatches??[],totalMatches:i}}}function ut(e){return{requested:e.requested,matched:e.matched,ambiguous:e.ambiguous,missing:e.missing,entries:e.entries.map(n=>({selector:n.selector,status:n.status,kind:n.kind,totalCandidates:n.totalCandidates,sources:n.results.map(t=>({file:t.relativePath,symbol:t.shortName,language:t.language??"unknown",range:{startLine:g(t.startLine),endLine:g(t.endLine)},...t.freshness?{freshness:t.freshness}:{},lines:t.source.split(`
|
|
29
|
+
`).map((o,r)=>({line:g(t.startLine+r),text:o}))})),definitions:n.definitions,...n.fileCoverage?{fileCoverage:n.fileCoverage}:{},...n.rangeCoverage?{rangeCoverage:n.rangeCoverage}:{},candidates:n.candidates,omittedCandidates:n.omittedCandidates,suggestions:n.suggestions,...n.reason?{reason:n.reason}:{}})),literalValues:e.bindingClosure.inline}}function O(e){return`'${e.replaceAll("'","'\\''")}'`}var Zt=[{id:"session",command:"session",description:"Show evidence already delivered in this agent exploration session",options:[h("--reset","Clear this agent exploration-session ledger")],agent:ye("Which indexed source ranges and graph facts have already been delivered in this exploration session?","prior command ordinals, exact source ranges, and content-bound graph receipts",[],"complete","repository",ce("repository-observation",[{when:{kind:"option",name:"reset",equals:!0},role:"mutation"}])),renderShape:"custom",docs:$("Navigation"),handler:et},{id:"refs",command:"refs <symbol>",description:"Find all files referencing a symbol",options:Ce([h("--full","Run unbounded semantic analysis on large indexes"),h("-n, --limit <n>","Maximum reference sites to return",he),h("--cursor <cursor>","Continue a prior bounded result (implies --limit 50 when omitted)")]),budget:"semantic",agent:{operation:y,answers:["Which files reference this symbol?","Is this symbol used anywhere, or only defined?"],returns:["referencing file paths","reference line numbers grouped by file"],inputs:["symbol"],coverage:"bounded",semantic:K("Resolve the exact reference sites attributed to one compiler symbol identity.","Referencing file paths and reference line numbers grouped by file.",["Reference sites do not establish runtime execution, data flow, or task relevance."]),contrasts:[{command:"imported-by",distinction:"imported-by lists files importing the symbol; refs covers every reference site, imported or not."},{command:"affected",distinction:"refs is one hop out; affected is the transitive closure of what could break."}]},renderShape:"grouped-by-file",docs:$("Navigation",["codebaseiq refs login"]),handler:Qe},{id:"outline",command:"outline <file>",description:"Tree view of symbols in a file, with line ranges",agent:{...w("What symbols and nesting exist in this file?","symbol names, nesting, and line ranges",["file"],"complete",void 0,y,be(["file","symbol","construct"],["File ownership and nesting do not establish execution or task relevance."],{ranking:"identity-only",manualInput:"One exact current project file path.",evidenceCeiling:"Exact compiler-owned constructs and ranges when the file is indexed; no invented semantic overlay."})),contrasts:[{command:"search",distinction:"outline enumerates constructs in one known file; search locates exact text across current project text."},{command:"code",distinction:"outline returns identities and ranges; code materializes exact source for selected identities."}]},options:I([h("--signatures","Show trimmed symbol signatures")]),renderShape:"custom",docs:$("Navigation"),handler:We},{id:"code",command:"code <selectors...>",description:"Read exact definitions, ranges with local call closure, or file export surfaces",agent:{...w("What exact source defines these symbols, ranges, or file surfaces?","per-selector resolution, complete definition source, exact ranges with statically attributed same-file call closure, file export surfaces, omitted-local ledgers, and line ranges",[["symbol","file"]],"complete",void 0,y,Re(["construct","exact-source"],["Source materialization does not establish callers, runtime reachability, or task relevance by itself."],void 0,{manualInput:"One or more exact symbols, file:line ranges, or file paths.",evidenceCeiling:"Exact current source bytes for every resolved selector, with omitted file-local constructs disclosed."})),resultUnits:{kind:"field",field:"code"},contrasts:[{command:"inspect",distinction:"code materializes complete exact source; inspect batches bounded behavior or source gaps."},{command:"outline",distinction:"code reads selected implementations; outline enumerates file structure without reading every body."}]},options:I([h("-C, --context <n>","Extra lines of context above/below",pe,0),h("--members <exported|all>","For file selectors, return the exported surface or the complete file",void 0,"exported")]),renderShape:"custom",docs:$("Navigation",["codebaseiq code parseRequest handleRequest","codebaseiq code src/api.ts src/web.ts"]),handler:Xe}];export{St as a,xt as b,pe as c,he as d,Et as e,h as f,Fe as g,Ce as h,I as i,$ as j,Pt as k,$t as l,wt as m,Ot as n,w as o,Nt as p,ye as q,be as r,Lt as s,Re as t,K as u,Se as v,xe as w,_ as x,D as y,Zt as z};
|
|
30
|
+
//# sourceMappingURL=chunk-4FC325IF.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as O}from"./chunk-P5XHIJHI.js";import{f as H,r as v,t as M}from"./chunk-BMYOV5GP.js";import{execFileSync as U}from"child_process";var L=2e3,S=50,J=64,V=8,W=3,X=2160*60*60,Y=/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i,Z=3,Q=/#\d+|\b[A-Z][A-Z0-9]+-\d+\b/g,q=/^([a-z][a-z0-9-]+)(?:\([^)]+\))?!?:/i;function tt(t){let e=H(t,{clearGroups:["whole-project"]});return(i,n,r)=>{let o=r??P(i.config.projectRoot);if(!o)return null;let s=e.has(i)?e.get(i,()=>({head:"",value:null})):null;return s&&s.head===o?s.value:(e.invalidate(i),e.get(i,()=>({head:o,value:n(i.config.projectRoot,o)})).value)}}function F(t){let e=H(t,{clearGroups:["whole-project"]});return(i,n,r,o)=>{let s=o??P(i.config.projectRoot);if(!s)return null;let c=e.has(i)?e.get(i,()=>({head:"",values:new Map})):null;(!c||c.head!==s)&&e.invalidate(i);let l=e.get(i,()=>({head:s,values:new Map}));if(l.values.has(n))return l.values.get(n)??null;let d=r(i.config.projectRoot,s);return l.values.set(n,d),d}}var et=F("git-commit-history");function nt(t,e={}){let i=e.historyMode??"bounded",n=e.head;return{capability:r=>it(t,r,n),commitHistory:()=>x(t,i,n),fileChurn:()=>st(t,i,n),changeAmplification:()=>at(t,i,n),trackedFiles:()=>lt(t,n),fileAddRecords:()=>dt(t,i,n),coChangePairs:(r={})=>bt(t,r,i,n),coChangePairsForFiles:(r,o={})=>z(t,r,o,i,n),directionalCoChangePairsForFiles:(r,o={})=>yt(t,r,o,i,n)}}function x(t,e="bounded",i){return et(t,y(e),(n,r)=>rt(n,r,e),i)}function it(t,e,i){let n=i??P(t.config.projectRoot);return n?{slot:e,available:!0,head:n}:{slot:e,available:!1,head:null,reason:"git history is unavailable for this project"}}function P(t){try{return C(t,["rev-parse","HEAD"]).trim()||null}catch{return null}}function C(t,e){return U("git",["-C",t,...e],{encoding:"utf-8",maxBuffer:64*1024*1024,stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:3e4,killSignal:"SIGKILL"})}function rt(t,e,i){let n;try{n=C(t,["log","--no-merges","--name-only",...R(i),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}return{head:e,...w(n,S)}}function ot(t){return Y.test(t.subject)}function st(t,e,i){let n=x(t,e,i);if(!n)return null;let r=new Map;for(let o of n.commits){let s=ot(o);for(let c of o.files){let l=r.get(c)??{changes:0,fixChanges:0,lastChangedAt:0};l.changes+=1,s&&(l.fixChanges+=1),o.timestamp>l.lastChangedAt&&(l.lastChangedAt=o.timestamp),r.set(c,l)}}return r}function at(t,e,i){let n=x(t,e,i);if(!n||n.commits.length===0)return null;let r=n.commits.map(o=>o.files.length).filter(o=>o>0).sort((o,s)=>o-s);return r.length===0?null:{medianFilesPerCommit:D(r,.5),p90FilesPerCommit:D(r,.9),commitsAnalyzed:r.length}}function D(t,e){let i=Math.min(t.length-1,Math.floor(t.length*e));return t[i]}var ct=tt("git-tracked-files");function lt(t,e){return ct(t,i=>{try{let n=C(i,["ls-files"]);return new Set(n.split(`
|
|
2
|
+
`).map(r=>r.trim()).filter(r=>r!==""))}catch{return null}},e)}var ut=F("git-file-adds"),_="__git__/file-adds",k=v({kind:"git-file-adds",invalidation:M("git-file-adds"),serialize:gt,deserialize:ft});function Ot(t){return nt(t).fileAddRecords()}function dt(t,e,i){let n=y(e);return ut(t,n,(r,o)=>mt(t,r,o,e),i)}function mt(t,e,i,n){let r=k.read(t,I(n),i);if(r)return r;let o=ht(e,n);return o&&k.write(t,I(n),i,o),o}function gt(t){return JSON.stringify([...t.entries()])}function ft(t){if(!t)return null;try{let e=JSON.parse(t);if(!Array.isArray(e))return null;let i=new Map;for(let n of e){if(!Array.isArray(n)||n.length!==2||typeof n[0]!="string")return null;let r=n[1];if(!r||typeof r.commitsAgo!="number"||!Number.isFinite(r.commitsAgo)||typeof r.addedAt!="number"||!Number.isFinite(r.addedAt))return null;i.set(n[0],{commitsAgo:r.commitsAgo,addedAt:r.addedAt})}return i}catch{return null}}function ht(t,e){let i;try{i=C(t,["log","--no-merges","--find-renames","--name-status",...R(e),"--pretty=format:%x01%H%x00%ct%x00%s"])}catch{return null}let n=new Map,r=new Map,o=-1;for(let s of i.split("")){if(s.trim()==="")continue;o+=1;let c=s.indexOf(`
|
|
3
|
+
`),l=c>=0?s.slice(0,c):s,[,d]=l.split("\0"),f=Number(d)||0;if(!(c<0))for(let u of s.slice(c+1).split(`
|
|
4
|
+
`)){let a=pt(u);if(!a)continue;if(a.status==="R"&&a.from&&a.to){let p=r.get(a.to)??new Set([a.to]);r.set(a.from,p);continue}if(a.status!=="A"||!a.to)continue;let m={commitsAgo:o,addedAt:f};n.set(a.to,m);for(let p of r.get(a.to)??[])n.set(p,m)}}return n}function pt(t){let e=t.trim().split(" "),i=e[0]??"";if(!i)return null;let n=i[0]??"";if(n==="R"){let o=e[1],s=e[2];return o&&s?{status:n,from:o,to:s}:null}let r=e[1];return r?{status:n,to:r}:null}var j=F("git-co-change-pairs"),Ct=F("git-directional-co-change-pairs");function bt(t,e,i,n){let r=`all\0${y(i)}\0${T(e)}`,o=j(t,r,()=>{let s=x(t,i,n);return s?G(s,e):null},n);return o&&[...o]}function z(t,e,i,n,r){if(e.size===0)return[];let o=`files\0${y(n)}\0${B(e)}\0${T(i)}`,s=j(t,o,()=>{let c=x(t,n,r);return c?G(c,i,e):null},r);return s&&[...s]}function yt(t,e,i,n,r){if(e.size===0)return[];let o=i.maxFilesPerCommit??S;if(e.size>J)return z(t,e,i,n,r);let s=`directional\0${y(n)}\0${B(e)}\0${T({...i,maxFilesPerCommit:o})}`,c=Ct(t,s,(l,d)=>{let f=At(l,d,e,o,n);return f?G(f,i,e):null},r);return c&&[...c]}function T(t){let e=t.minTogether??4,i=t.minConfidence??.6,n=t.maxFilesPerCommit??S;return`${e}\0${i}\0${n}`}function B(t){return[...t].sort().join("\0")}function G(t,e,i){let{minTogether:n=4,minConfidence:r=.6,maxFilesPerCommit:o=S}=e,s=new Map,c=new Map,l=t.newestAnalyzedAt??0;for(let u of t.commits){let a=[...new Set(u.files)].sort();if(a.length>o)continue;t.newestAnalyzedAt===void 0&&u.timestamp>l&&(l=u.timestamp);let m=Ft(a),p=i===void 0||a.some(g=>i.has(g));for(let g of a)s.set(g,(s.get(g)??0)+1);if(p)for(let g=0;g<a.length;g++)for(let b=g+1;b<a.length;b++){if(i&&!i.has(a[g])&&!i.has(a[b]))continue;let A=`${a[g]}\0${a[b]}`,h=c.get(A)??{together:0,focusedTogether:0,broadTogether:0,lastTogetherAt:0,timestamps:[],subjects:[]};h.together+=1,m?h.broadTogether+=1:h.focusedTogether+=1,u.timestamp>h.lastTogetherAt&&(h.lastTogetherAt=u.timestamp),h.timestamps.push(u.timestamp),h.subjects.push(u.subject),c.set(A,h)}}let d=[],f=l-X;for(let[u,a]of c){let m=a.together;if(m<n)continue;let[p,g]=u.split("\0"),b=s.get(p)??m,A=s.get(g)??m,h=Math.max(m/b,m/A);if(h<r)continue;let $=a.broadTogether/m,E=a.timestamps.filter(K=>K>=f).length;d.push({fileA:p,fileB:g,together:m,confidence:h,changesA:b,changesB:A,focusedTogether:a.focusedTogether,broadTogether:a.broadTogether,broadCommitRatio:$,lastTogetherAt:a.lastTogetherAt,recentTogether:E,commitScope:Ht(a.broadTogether,m),recency:E>0?"recent":"stale",subjectContext:Pt(a.subjects)})}return d.sort((u,a)=>a.together-u.together||a.confidence-u.confidence||u.fileA.localeCompare(a.fileA)),d}function At(t,e,i,n,r){let o;try{o=xt(t,r)}catch{return null}if(o.length===0)return{head:e,commits:[],skippedBulkCommits:0,newestAnalyzedAt:0};let s;try{s=C(t,["log","--no-merges","--format=%H",...R(r),"--",...[...i].sort()])}catch{return null}let c=new Set(o.map(a=>a.hash)),l=s.split(`
|
|
5
|
+
`).map(a=>a.trim()).filter(a=>a!==""&&c.has(a)),d=St(t,o,n);if(l.length===0)return{head:e,commits:[],skippedBulkCommits:0,newestAnalyzedAt:d};let f;try{f=C(t,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...l])}catch{return null}let u=w(f,n);return{head:e,...u,newestAnalyzedAt:d}}function xt(t,e){return C(t,["log","--no-merges","--format=%H%x00%ct",...R(e)]).split(`
|
|
6
|
+
`).map(n=>n.trim()).filter(n=>n!=="").map(n=>{let[r,o]=n.split("\0");return{hash:r??"",timestamp:Number(o)||0}}).filter(n=>n.hash!=="")}function R(t){return t==="full"?[]:["-n",String(N())]}function N(){return O(process.env.CODEBASEIQ_GIT_HISTORY_MAX_COMMITS)??L}function y(t){return t==="full"?"full":`bounded:${N()}`}function I(t){let e=y(t);return e===`bounded:${L}`?_:`${_}:${e}`}function St(t,e,i){for(let r=0;r<e.length;r+=20){let o=e.slice(r,r+20),s;try{s=C(t,["show","--no-walk=unsorted","--name-only","--pretty=format:%x01%H%x00%ct%x00%s",...o.map(l=>l.hash)])}catch{return e[0]?.timestamp??0}let c=w(s,i);if(c.commits.length>0)return c.commits[0].timestamp}return 0}function w(t,e){let i=[],n=0;for(let r of t.split("")){if(r.trim()==="")continue;let o=r.indexOf(`
|
|
7
|
+
`),s=o>=0?r.slice(0,o):r,[c,l,d]=s.split("\0");if(!c||!l)continue;let f=o>=0?r.slice(o+1).split(`
|
|
8
|
+
`).map(u=>u.trim()).filter(u=>u!==""):[];if(f.length>e){n+=1;continue}i.push({hash:c,timestamp:Number(l)||0,subject:d??"",files:f})}return{commits:i,skippedBulkCommits:n}}function Ft(t){return t.length>=V?!0:Rt(t).size>=W}function Rt(t){let e=new Set;for(let i of t){let n=i.indexOf("/");e.add(n>=0?i.slice(0,n):".")}return e}function Ht(t,e){return t===0?"focused":t/e>=.5?"broad-sweep":"mixed"}function Pt(t){let e=new Set,i=[],n=[];for(let r of t){!n.includes(r)&&n.length<Z&&n.push(r);for(let o of Tt(r))e.add(o);for(let o of r.match(Q)??[])i.includes(o)||i.push(o)}return{subjectLabels:[...e].sort(),issueRefs:i,sampleSubjects:n,externalIssueLabelStatus:"unavailable"}}function Tt(t){let e=new Set,i=q.exec(t)?.[1]?.toLowerCase();return i&&e.add(Gt(i)),/\b(?:feat|feature)\b/i.test(t)&&e.add("feature"),/\b(?:fix(?:es|ed)?|bug|regression|hotfix)\b/i.test(t)&&e.add("fix"),/\b(?:docs?|documentation|guide|readme)\b/i.test(t)&&e.add("docs"),/\brefactor(?:ing|ed)?\b/i.test(t)&&e.add("refactor"),/\btests?\b/i.test(t)&&e.add("test"),/\b(?:release|version|v\d+\.\d+)\b/i.test(t)&&e.add("release"),/\bchore\b/i.test(t)&&e.add("chore"),/\bbuild\b/i.test(t)&&e.add("build"),/\bci\b/i.test(t)&&e.add("ci"),/\bperf(?:ormance)?\b/i.test(t)&&e.add("perf"),[...e]}function Gt(t){return t==="feat"?"feature":t}export{nt as a,C as b,Ot as c};
|
|
9
|
+
//# sourceMappingURL=chunk-4WKDMDEW.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as U}from"./chunk-SELM5MER.js";import{c as T}from"./chunk-7FND7D7N.js";import{a as R}from"./chunk-UZGZB3VB.js";import{d as x}from"./chunk-FETNQCFO.js";import{a as v}from"./chunk-ADTBPVUZ.js";import{b}from"./chunk-NNJ2KZZG.js";import{posix as p}from"path";var G=20,O=1,q=new Map([["app","app"],["apps","app"],["component","component"],["components","component"],["composable","composable"],["composables","composable"],["contract","contract"],["contracts","contract"],["domain","domain"],["domains","domain"],["feature","feature"],["features","feature"],["hook","hook"],["hooks","hook"],["lib","library"],["module","module"],["modules","module"],["package","package"],["packages","package"],["page","page"],["pages","page"],["route","route"],["routes","route"],["screen","screen"],["screens","screen"],["service","service"],["services","service"],["shared","shared"],["src","source-root"],["store","state"],["stores","state"],["test","test"],["tests","test"],["util","utility"],["utils","utility"],["view","view"],["views","view"]]),K=new Set(["components","contracts","hooks","lib","services","shared","stores","utils"]),Y=new Set(["access","api","auth","config","db","effect","errors","hooks","lib","middleware","permissions","routes","schemas","servicetasks","services","startup","store","stores","test-utils","repository","repositories","tests","types","ui","utils","workflow","workflows"]);function Ae(e,n={}){let t=D(n.limit,G),i=D(n.minConsumers,O),r=new T(e),s=r.fileDependencyGraph(n.scope),o=fe(v(e,{includeIgnored:!1})),a=ye(e.config.locality?.architecturalBoundarySegments,n.architecturalBoundarySegments);return(n.target?J(e,r,n.target):Q(e,n.scope,n.scanLimit)).map(l=>V(e,r,s,l,n,o,a)).filter(l=>l.consumerFiles.length>=i||n.target).sort(ge).slice(0,t)}function J(e,n,t){let i=ee(e,t);if(i)return[P(i)];let r=R(e,t);if(!r)return[];let s=n.definitionsForFile(r.relativePath).find(o=>o.symbolId===r.symbolId);return s?[ne(s)]:[{unit:{kind:"symbol",file:r.relativePath,shortName:x(r.symbol),symbol:r.symbol,startLine:r.startLine,endLine:r.endLine}}]}function Q(e,n,t){let i=v(e,{scope:n,includeIgnored:!1}),r=D(t,i.length);return i.slice(0,r).map(s=>P(s))}function V(e,n,t,i,r,s,o){let a=i.definition?X(e,n,i.definition,r.semantic):null,c=a?.files??Z(t,i.unit.file),u=i.definition?a.coverage==="complete"?c.length>0?"exact":"none":a.coverage:c.length>0?"file-level":"none",l=u==="incomplete"||u==="unavailable"||u==="incomplete-and-unavailable",y=i.unit.file,g=d(p.dirname(y)),f=ie(c),j=te(g),z=C([...F(g),...f?F(f):[]]),S=l?"repository-level-review":re(i.unit,g,f,c),h=l?{suggestedHome:null,confidence:"withheld",whyNoSuggestedHome:`Compiler-resolved consumer evidence is ${u}; no relocation destination is safe to score.`}:oe(S,i.unit,g,f,c,s,o),A=ue(i.unit,u,f,c,g,h.whyNoSuggestedHome),_=de(i.unit,g,f,c,h.suggestedHome,h.whyNoSuggestedHome);return{actionTier:"signal",sourceUnit:i.unit,candidatePath:y,currentDirectory:g,directoryAncestry:j,consumerFiles:c,consumerCoverage:u,nearestCommonOwner:f,boundaryMarkers:z,recommendedTier:S,suggestedHome:h.suggestedHome,destinationConfidence:h.confidence,whyNoSuggestedHome:h.whyNoSuggestedHome,counterevidence:l?[...A,"Known consumer files are retained, but missing compiler evidence can hide additional owners."]:A,reasons:_,recommendation:l?"Retain the current location until compiler-resolved consumer evidence is complete.":me(S,h.suggestedHome,u)}}function X(e,n,t,i){let r=U(e,n).forDefinitions([t],{semantic:i!==!1,sourceFallback:!0}).get(t.symbolId),s=r?.semanticIncomplete?r.semanticUnavailable?"incomplete-and-unavailable":"incomplete":r?.semanticUnavailable?"unavailable":"complete";return{files:W(r?.files.map(o=>o.file)??[]),coverage:s}}function Z(e,n){let t=[];for(let[i,r]of e.entries())i!==n&&r.has(n)&&t.push(i);return W(t)}function ee(e,n){let t=b(n),i=v(e,{includeIgnored:!1}),r=i.find(o=>o===t);if(r)return r;let s=i.find(o=>o.endsWith(`/${t}`));return s||(i.find(o=>o.includes(t))??null)}function ne(e){return{definition:e,unit:{kind:"symbol",file:e.relativePath,shortName:x(e.symbol),symbol:e.symbol,startLine:e.startLine,endLine:e.endLine}}}function P(e){return{unit:{kind:"file",file:e,shortName:p.basename(e)}}}function te(e){if(e===".")return[{path:".",depth:0,markers:[]}];let n=[],t=e.split("/").filter(Boolean);for(let i=0;i<t.length;i+=1){let r=t.slice(0,i+1).join("/");n.push({path:r,depth:i,markers:k(r)})}return n}function F(e){return e==="."?[]:H(e).map(({marker:n,prefix:t})=>`${n}: ${t}`)}function k(e){return C(H(e).map(({marker:n})=>n))}function H(e){let n=e.split("/").filter(Boolean),t=[];for(let i=0;i<n.length;i+=1){let r=q.get(n[i]);r&&t.push({marker:r,prefix:n.slice(0,i+1).join("/")})}return t}function ie(e){if(e.length===0)return null;let n=e.map(i=>d(p.dirname(i))),t=n[0].split("/").filter(Boolean);for(let i of n.slice(1)){let r=i.split("/").filter(Boolean),s=[],o=Math.min(t.length,r.length);for(let a=0;a<o&&t[a]===r[a];a+=1)s.push(t[a]);t=s}return t.length===0?".":t.join("/")}function re(e,n,t,i){return t?e.kind==="symbol"&&i.length===1?i[0]===e.file?"same-file":"sibling-folder":t==="."||t==="src"?"repository-level-review":I(t,"package")?"package-level-shared":I(t,"app")?"app-level-shared":$(t,["feature","domain","module"])||$(n,["feature","domain","module"])?"feature-local-shared":"sibling-folder":"no-exact-consumers"}function oe(e,n,t,i,r,s,o){let a=se(e,i);if(a)return m(a);let c=he(n.file),u=ae(e,t,c,r,o);if(u)return u;let l=i;if(d(t)===d(l))return m(`${t} is already the nearest common owner for its consumers.`);let y=ce(l,t,c,o);return y||le(l,t,c,s,o)}function se(e,n){return n?e==="no-exact-consumers"||e==="repository-level-review"?"The inferred owner is too broad or unsupported for an exact destination.":null:"No consumer owner could be inferred from the current index."}function ae(e,n,t,i,r){if(e==="same-file"){let s=i[0]??null;return s?L(s):m("No same-file consumer path was available.")}if(e==="sibling-folder"&&i.length===1){let s=d(p.dirname(i[0])),o=B(n,t,s,r);return o?m(o):L(s)}return null}function ce(e,n,t,i){return ve(e)?M(e,n,t,i,`Nearest shared owner ${e} is outside source root ${t}.`):null}function le(e,n,t,i,r){if(e===".")return m("The nearest common owner is the repository root.");let s=`${e}/shared`,o=M(s,n,t,r,`Proposed home ${s} is outside source root ${t}.`);return o.confidence==="withheld"||i.has(s)?o:m(`${s} does not exist in the indexed project.`)}function M(e,n,t,i,r){if(!E(e,t))return m(r);let s=B(n,t,e,i);return s?m(s):L(e)}function L(e){return{suggestedHome:e,confidence:"exact",whyNoSuggestedHome:null}}function m(e){return{suggestedHome:null,confidence:"withheld",whyNoSuggestedHome:e}}function ue(e,n,t,i,r,s){let o=["Report-only signal; review ownership before moving files."];return n==="none"&&o.push("No consumers were found in the current index."),n==="file-level"&&o.push("File-level import evidence can hide which exported unit is actually used."),(t==="."||t==="src")&&o.push("Nearest common owner is broad, so this is not enough evidence for automatic placement."),i.length===1&&o.push("Only one consumer was found; inlining or same-folder placement may be better than shared extraction."),e.kind==="file"&&o.push("File targets describe module locality, not symbol-level usage."),t&&r.startsWith(`${t}/`)&&o.push("Candidate already lives under the nearest common owner."),s&&o.push(`No exact suggested home: ${s}`),o}function de(e,n,t,i,r,s){let o=[];return o.push(`${e.shortName} currently lives in ${n}.`),t?o.push(`${i.length} consumer file(s) share ${t} as their nearest common owner.`):o.push("No consumer owner could be inferred from the current index."),r?o.push(`Suggested home is ${r}.`):s&&o.push(`No exact suggested home: ${s}`),o}function me(e,n,t){return e==="no-exact-consumers"?"Review references before moving; no consumers were found.":e==="repository-level-review"?"Keep this as a broad locality signal; the inferred owner is too general for automatic relocation.":n?`Review whether ${t==="exact"?"symbol usage":"module import"} supports moving or extracting toward ${n}.`:"Review ownership manually before changing structure."}function ge(e,n){return N(n)-N(e)||e.candidatePath.localeCompare(n.candidatePath)}function N(e){let n=e.consumerFiles.length*10;return e.consumerCoverage==="exact"&&(n+=5),e.suggestedHome&&(n+=3),e.recommendedTier==="repository-level-review"&&(n*=.1),e.recommendedTier==="no-exact-consumers"&&(n*=.05),n}function fe(e){let n=new Set(["."]);for(let t of e){let i=d(p.dirname(t));for(;!n.has(i)&&(n.add(i),i!==".");)i=d(p.dirname(i))}return n}function he(e){let n=w(e),t=n.indexOf("src");return t>=0?n.slice(0,t+1).join("/"):n.length<=1?".":n[0]}function E(e,n){let t=d(e),i=d(n);return i==="."||t===i||t.startsWith(`${i}/`)}function pe(e,n,t){let i=w(e),r=w(n);return(E(e,n)?i.slice(r.length):i).some(o=>t.has(o.toLowerCase()))}function B(e,n,t,i){return d(e)===d(t)||!pe(e,n,i)?null:`${e} is a named architectural boundary; an exact move to ${t} needs human design.`}function ye(...e){let n=new Set(Y);for(let t of e)for(let i of t??[]){let r=be(i);r&&n.add(r)}return n}function be(e){let n=e.trim().toLowerCase();return n===""?null:n}function I(e,n){return k(e).includes(n)}function $(e,n){let t=k(e);return n.some(i=>t.includes(i))}function ve(e){let n=e.split("/").filter(Boolean),t=n[n.length-1];return t?K.has(t):!1}function d(e){let n=b(e);return n===""?".":n}function w(e){let n=b(e);return n==="."?[]:n.split("/").filter(Boolean)}function D(e,n){return!Number.isFinite(e)||e===void 0||e<1?n:Math.floor(e)}function W(e){return C([...e]).sort((n,t)=>n.localeCompare(t))}function C(e){return[...new Set(e)]}export{Ae as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4XTAUQFD.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import{a as u}from"./chunk-JOIRNPPY.js";import{f as d}from"./chunk-J77SU6VA.js";import{d as r,u as a}from"./chunk-FETNQCFO.js";function b(e,i={}){return f(e,i).rows}function f(e,i={}){let{limit:l=30,scope:t}=i,n=t?"AND def_d.relative_path LIKE ?":"",c=t?[`%${t}%`]:[],o=e.all(`SELECT
|
|
2
|
+
gs.symbol,
|
|
3
|
+
COUNT(*) AS ref_count,
|
|
4
|
+
COUNT(DISTINCT ref_d.id) AS file_count,
|
|
5
|
+
def_d.relative_path AS defined_in
|
|
6
|
+
FROM mentions m
|
|
7
|
+
JOIN chunks c ON m.chunk_id = c.id
|
|
8
|
+
JOIN documents ref_d ON c.document_id = ref_d.id
|
|
9
|
+
JOIN global_symbols gs ON m.symbol_id = gs.id
|
|
10
|
+
JOIN (
|
|
11
|
+
SELECT m2.symbol_id, c2.document_id
|
|
12
|
+
FROM mentions m2
|
|
13
|
+
JOIN chunks c2 ON m2.chunk_id = c2.id
|
|
14
|
+
WHERE m2.role = 1
|
|
15
|
+
GROUP BY m2.symbol_id
|
|
16
|
+
) sym_def ON sym_def.symbol_id = gs.id
|
|
17
|
+
JOIN documents def_d ON sym_def.document_id = def_d.id
|
|
18
|
+
WHERE m.role != 1
|
|
19
|
+
AND def_d.id != ref_d.id
|
|
20
|
+
${e.pathExclusionsFor("def_d")}
|
|
21
|
+
${e.symbolNoiseFor("gs")}
|
|
22
|
+
${n}
|
|
23
|
+
GROUP BY gs.id
|
|
24
|
+
ORDER BY ref_count DESC
|
|
25
|
+
LIMIT ?`,...c,l).filter(s=>!e.isIgnored(s.defined_in)).map(s=>({symbol:s.symbol,shortName:r(s.symbol),refCount:s.ref_count,fileCount:s.file_count,definedIn:s.defined_in,basis:"scip-cross-file-mentions",countUnit:"reference-occurrences"}));return o.length>0?{rows:o,coverage:{semanticEvidence:{enabled:!1,status:"disabled",incompleteSymbolCount:0,unavailableSymbolCount:0}}}:p(e,t,l)}function I(e,i={}){return b(e,i)}function p(e,i,l){let t=a(e,{scope:i}).filter(o=>!e.isIgnored(o.relativePath)),n=d(e,t,{limit:500,semanticEvidence:u}),c=t.filter(o=>!n.incompleteSymbolIds.has(o.symbolId)&&!n.unavailableSymbolIds.has(o.symbolId)).map(o=>y(o,n.rows.get(o.symbolId)??[])).filter(o=>o.refCount>0).sort((o,s)=>s.refCount-o.refCount||s.fileCount-o.fileCount).slice(0,l),m=n.incompleteSymbolIds.size>0&&n.unavailableSymbolIds.size>0?"incomplete-and-unavailable":n.incompleteSymbolIds.size>0?"incomplete":n.unavailableSymbolIds.size>0?"unavailable":"complete";return{rows:c,coverage:{semanticEvidence:{enabled:!0,status:m,incompleteSymbolCount:n.incompleteSymbolIds.size,unavailableSymbolCount:n.unavailableSymbolIds.size}}}}function y(e,i){let l=i.filter(t=>t.file!==e.relativePath);return{symbol:e.symbol,shortName:r(e.symbol),refCount:l.length,fileCount:new Set(l.map(t=>t.file)).size,definedIn:e.relativePath,basis:"source-backed-incoming-evidence",countUnit:"distinct-incoming-evidence-rows"}}export{b as a,f as b,I as c};
|
|
26
|
+
//# sourceMappingURL=chunk-5PUWMSDU.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{b as m}from"./chunk-7MGU3HPH.js";import{a as p}from"./chunk-EF2R3WNQ.js";import{$ as d,ba as P,ca as h,g as f}from"./chunk-WE5RZHZ7.js";import{realpathSync as c}from"fs";import{basename as x,dirname as L,join as T,relative as I,sep as O}from"path";import{fileURLToPath as S,pathToFileURL as y}from"url";function F(n,e){return e==="."||e==="./"?y(c(n)).href:y(d(n,e).absolutePath).href}function b(n,e){let r=S(e);return I(c(n),v(r)).split(O).join("/")}function v(n){try{return c(n)}catch{try{return T(c(L(n)),x(n))}catch{return n}}}function H(n,e,r){return{textDocument:{uri:F(n,e.relativePath)},position:z(n,e),context:{includeDeclaration:r}}}function z(n,e){let r={line:e.startLine,character:e.startChar??0};try{return M(P(n,e.relativePath,{inputKind:"indexed Rust source file"}),e,r)}catch(t){if(!h(t))throw t;return r}}function M(n,e,r={line:e.startLine,character:e.startChar??0}){let t=n.split(/\r?\n/),o=t[e.startLine];if(o===void 0||e.leaf.length===0)return r;let i=Math.max(0,Math.min(r.character,o.length)),s=o.indexOf(e.leaf,i);if(s>=0)return{line:e.startLine,character:u(s,e.leaf)};let a=o.indexOf(e.leaf);if(a>=0)return{line:e.startLine,character:u(a,e.leaf)};let l=D(t,e.startLine,e.leaf);return l||r}function u(n,e){return n+Math.max(0,e.length-2)}function D(n,e,r){for(let t of[-1,1,-2,2]){let o=e+t;if(o<0||o>=n.length)continue;let i=n[o].indexOf(r);if(i>=0)return{line:o,character:u(i,r)}}return null}function K(n,e){return e.map(r=>({file:b(n,r.uri),line:r.range.start.line,column:r.range.start.character}))}function X(n){let e=new Map;for(let r of n)e.set(`${r.file}\0${r.line}\0${r.column}`,r);return[...e.values()].sort((r,t)=>{let o=r.file.localeCompare(t.file);return o!==0?o:r.line!==t.line?r.line-t.line:r.column-t.column})}import{randomUUID as E}from"crypto";import{readdirSync as $,rmSync as j,writeFileSync as A}from"fs";import{join as g}from"path";var R="rust-analyzer-owner-",w=".json",U=16*1024;function Z(n,e){if(!n||!e.rootIdentity)return null;let r=g(n,`${R}${e.rootPid}-${E()}${w}`),t={version:1,rootIdentity:e.rootIdentity,ownsProcessGroup:e.ownsProcessGroup};return A(r,`${JSON.stringify(t)}
|
|
2
|
+
`,{encoding:"utf8",mode:384,flag:"wx"}),r}function ee(n){n&&j(n,{force:!0})}async function re(n,e){if(!n)return[];let r;try{r=$(n)}catch{return[]}let t=r.filter(s=>s.startsWith(R)&&s.endsWith(w)).map(s=>g(n,s)),o=[],i=[];for(let s of t){let a=C(s);a?i.push(a):o.push({reaped:!1,reason:"identity-unavailable",detail:`Rust analyzer ownership record ${s} could not be validated.`})}return o.push(...await Promise.all(i.map(s=>m(s,e)))),o}function C(n){try{let e=f(n,{maxBytes:U,inputKind:"rust-analyzer process ownership record"}),r=JSON.parse(e),t=p(r.rootIdentity);return r.version!==1||!t||typeof r.ownsProcessGroup!="boolean"?null:{rootPid:t.pid,rootIdentity:t,ownsProcessGroup:r.ownsProcessGroup,knownMembers:new Map([[t.pid,t]])}}catch{return null}}export{Z as a,ee as b,re as c,F as d,b as e,H as f,K as g,X as h};
|
|
3
|
+
//# sourceMappingURL=chunk-5VKBFZZU.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as P,d as w}from"./chunk-FAJQ7LWY.js";import{s as M}from"./chunk-Z54RD7VL.js";import{b as g,c as T}from"./chunk-FDGD5AB5.js";import{U as v,W as b,X as d}from"./chunk-RU65DDUP.js";import{d as f}from"./chunk-QW7EP6WI.js";import{w as l}from"./chunk-RDBI2RXU.js";import{c,d as y}from"./chunk-EF2R3WNQ.js";import{o as h,p as S}from"./chunk-WE5RZHZ7.js";import{randomUUID as A}from"crypto";import{resolve as q}from"path";var E=class{projectRoot;currentGeneration;createEmitter;wallNow;monotonicNow;active=new Map;requests=0;sessionsCreated=0;sessionsReplaced=0;lastRequestAtMs=null;lastDurationMs=null;lastError=null;unavailable=!1;constructor(e){this.projectRoot=q(e.projectRoot),this.currentGeneration=e.currentGeneration,this.createEmitter=e.createEmitter??g,this.wallNow=e.wallNow??e.now??Date.now,this.monotonicNow=e.monotonicNow??e.now??y}handle(e,t){let r=this.monotonicNow();try{if(this.currentGeneration()!==e)throw new Error("TypeScript index request does not match the currently published generation.");let s=this.emitterFor(t);if(s.emitter.producerIdentity!==t.producerIdentity)throw new Error("TypeScript index producer identity changed.");let o=s.emitter.snapshotStats(),a=s.emitter.advance({modifiedFiles:t.modifiedFiles,affectedFiles:t.affectedFiles}),m=this.monotonicNow()-r;return this.requests+=1,this.lastRequestAtMs=this.wallNow(),this.lastDurationMs=m,this.lastError=null,this.unavailable=!1,{producerIdentity:a.producerIdentity,cold:a.stats.initializations>o.initializations,durationMs:m,fragments:a.fragments.map(n=>({relativePath:n.relativePath,bytesBase64:n.bytes===null?null:Buffer.from(n.bytes).toString("base64"),occurrences:n.occurrences,symbols:n.symbols,referenceFragments:n.referenceFragments}))}}catch(s){throw this.lastError=s instanceof Error?s.message:String(s),s}}status(e){let t=[...this.active.values()].map(s=>s.emitter.snapshotStats()),r=s=>t.reduce((o,a)=>o+a[s],0);return{protocolVersion:T,state:this.unavailable?"unavailable":this.lastError?"error":this.active.size>0?"ready":"idle",requests:this.requests,sessionsCreated:this.sessionsCreated,sessionsReplaced:this.sessionsReplaced,initializations:r("initializations"),programUpdates:r("programUpdates"),documentsEmitted:r("documentsEmitted"),documentsRemoved:r("documentsRemoved"),...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastDurationMs===null?{}:{lastDurationMs:this.lastDurationMs},...this.lastError?{lastError:this.lastError}:{},...e?{mailbox:e}:{}}}close(){this.active.clear()}emitterFor(e){let t=`${e.tsconfigPath}\0${e.projectArgument}`,r=this.active.get(t);if(r?.projectIdentity===e.projectIdentity)return r;let s=this.createEmitter({workspaceRoot:this.projectRoot,tsconfigPath:e.tsconfigPath,projectRoot:e.projectArgument});if(!s.available)throw this.unavailable=!0,new Error(s.reason);r&&(this.sessionsReplaced+=1);let o={projectIdentity:e.projectIdentity,emitter:s.emitter};return this.active.set(t,o),this.sessionsCreated+=1,o}};function Q(i){l(i)}var Z=`typescript-index-${process.pid}-${A()}`,I=c(process.pid),ee={pid:process.pid,...I?{processIdentity:I}:{}};import{randomUUID as _}from"crypto";import{resolve as R}from"path";var p=class{loadModule;discoverTsconfigs;createProjects;createProvider;db;module=null;projects=null;provider=null;stats={providerRequests:0,sessionsCreated:0,sessionsReused:0,sessionsRefreshed:0,sessionsReplaced:0,projectsCreated:0};constructor(e,t={}){this.db=e,this.loadModule=t.loadModule??v,this.discoverTsconfigs=t.discoverTsconfigs??P,this.createProjects=t.createProjects??b,this.createProvider=t.createProvider??((r,s,o)=>w(r,s,o,{reusedProjects:!0}))}semanticProvider(){return this.stats.providerRequests+=1,this.provider?(this.stats.sessionsReused+=1,this.provider):this.createSession()}advanceGeneration(e,t){let r=O(t);return this.provider?.dispose?.(),this.provider=null,this.db=e,this.projects?r.mode==="replace"?(this.projects=null,this.module=null,this.stats.sessionsReplaced+=1,r):(r.mode==="refresh"&&(B(this.projects,e.config.projectRoot,r),this.stats.sessionsRefreshed+=1),r):r}snapshotStats(){return{...this.stats}}dispose(){this.provider?.dispose?.(),this.provider=null,this.projects=null,this.module=null}createSession(){let e=this.module??this.loadModule();if(!e)return this.provider=d("ts-morph is not installed"),this.provider;if(this.module=e,!this.projects){let t=this.discoverTsconfigs(this.db);if(t.length===0)return this.provider=d("no tsconfig found"),this.provider;this.projects=this.createProjects(e,t),this.stats.projectsCreated+=this.projects.length}return this.provider=this.createProvider(this.db,e,this.projects),this.stats.sessionsCreated+=1,this.provider}};function O(i){let e=new Set;i.projectIdentityChanged&&e.add("project-identity-changed");for(let o of i.uncertainty)e.add(o);for(let o of i.changes)o.inputKind!=="source"&&e.add(`${o.inputKind}-input-changed`);if(e.size>0)return{mode:"replace",addedFiles:[],modifiedFiles:[],deletedFiles:[],reasons:[...e].sort()};let t=u(i.changes,"added"),r=u(i.changes,"modified"),s=u(i.changes,"deleted");return{mode:t.length+r.length+s.length===0?"reuse":"refresh",addedFiles:t,modifiedFiles:r,deletedFiles:s,reasons:[]}}function u(i,e){return i.filter(t=>t.kind===e).map(t=>t.path).sort()}function B(i,e,t){for(let r of i){for(let s of t.deletedFiles)r.project.getSourceFile(R(e,s))?.forget();for(let s of t.modifiedFiles){let o=r.project.getSourceFile(R(e,s));o&&o.refreshFromFileSystemSync()}t.addedFiles.length>0&&r.project.addSourceFilesFromTsConfig(r.tsconfigPath)}}var j=class{openDb;createHost;generationIdentity;readSnapshot;now;db=null;host=null;generation=null;snapshot=null;requests=0;lastRequestAtMs=null;lastError=null;available=null;constructor(e){this.openDb=e.openDb,this.createHost=e.createHost??(t=>new p(t)),this.generationIdentity=e.generationIdentity?t=>e.generationIdentity(t.config.dbPath):t=>t.generation.identity,this.readSnapshot=e.readSnapshot?t=>e.readSnapshot(t.config.dbPath):k,this.now=e.now??Date.now}handle(e,t){try{this.syncGeneration(e);let r=this.host.semanticProvider();switch(this.available=r.availability().available,this.requests+=1,this.lastRequestAtMs=this.now(),this.lastError=null,t.kind){case"availability":return r.availability();case"import-usage":return r.importUsage(t.file);case"references":return[...H(r,t.definitions,{exact:t.exact===!0})];case"reference-fragments":if(!r.referenceFragmentsForFiles)throw new Error("TypeScript provider does not support reference fragments.");return[...r.referenceFragmentsForFiles(t.files)];case"callees":return[...L(r,t.definitions)];case"signature":return r.signatureFor(t.definition);default:return Y(t)}}catch(r){throw this.lastError=r instanceof Error?r.message:String(r),r}}status(e){let t=this.host?.snapshotStats();return{protocolVersion:M,state:this.lastError?"error":this.host?this.available?"ready":"unavailable":"idle",requests:this.requests,...this.lastRequestAtMs===null?{}:{lastRequestAt:new Date(this.lastRequestAtMs).toISOString()},...this.lastError?{lastError:this.lastError}:{},sessionsCreated:t?.sessionsCreated??0,sessionsReused:t?.sessionsReused??0,sessionsRefreshed:t?.sessionsRefreshed??0,sessionsReplaced:t?.sessionsReplaced??0,projectsCreated:t?.projectsCreated??0,...e?{mailbox:e}:{}}}closeTypeScriptService(){this.host?.dispose(),this.db?.close(),this.host=null,this.db=null,this.generation=null,this.snapshot=null,this.available=null}syncGeneration(e){if(this.generation===e&&this.host&&this.db)return;let t=this.openDb(),r=this.generationIdentity(t);if(!r||r!==e)throw t.close(),new Error("TypeScript semantic request does not match the currently published index generation.");let s=this.readSnapshot(t);if(!this.host||!this.db)this.db=t,this.host=this.createHost(t);else{let o=this.db;this.host.advanceGeneration(t,G(this.snapshot,s)),this.db=t,o.close()}this.generation=r,this.snapshot=s,this.available=null}};function Se(i){l(i)}function H(i,e,t){return i.referencesForDefinitions?.(e,t)??new Map(e.map(r=>[r.symbolId,i.referencesFor(r)]))}function L(i,e){return i.calleesForDefinitions?.(e)??new Map(e.map(t=>[t.symbolId,i.calleesFor(t)]))}function k(i){if(!i.generation.metadataRaw)return null;let e=f(i.generation.metadataRaw);return e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.usableForEvidenceCache?null:h(e.metadata.fingerprint)}function G(i,e){return e?S(i,e):{version:1,changes:[],projectIdentityChanged:!0,uncertainty:["prior-snapshot-unavailable"]}}function Y(i){throw new Error(`Unhandled TypeScript semantic request: ${JSON.stringify(i)}`)}var fe=`typescript-semantic-${process.pid}-${_()}`,x=c(process.pid),ye={pid:process.pid,...x?{processIdentity:x}:{}};export{E as a,Q as b,j as c,Se as d};
|
|
2
|
+
//# sourceMappingURL=chunk-6BQ3DSPK.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as X}from"./chunk-P5XHIJHI.js";import{C as wt,D as me,E as $,F as Le,G as Z,H as ee,I as Oe,J as Pt,K as dn,L as Ue,M as ne,N as Et,O as At,P as Be,Q as Ft,S as pn,U as mn,V as yn,u as Tt}from"./chunk-UCD3H3UZ.js";import{d as Ct}from"./chunk-ELNRLMC5.js";import{a as De,b as xe,c as we,d as ke,e as q,q as kt}from"./chunk-ZKX2FRS6.js";import{b as Dt,e as V,f as Ne,h as xt,j as pe,t as z,u as _e}from"./chunk-FETNQCFO.js";import{a as de,f as Fe,n as Mt,p as vt}from"./chunk-O6QTXQPJ.js";import{C as It,a as Ee,c as pt,d as mt,q as ln,z as ht}from"./chunk-ADTBPVUZ.js";import{a as ot,b as st,e as lt,f as ut,i as Pe,k as cn,m as ft,o as dt,r as un,s as fn,t as ue}from"./chunk-BMYOV5GP.js";import{d as gt,f as bt,g as fe,j as Rt}from"./chunk-CWONGW6P.js";import{a as _,c as yt,d as k,f as Ae}from"./chunk-3LCDIREB.js";import{A as at,B as H,C as Ce,F as Te,G as B,H as ct,L as an,ea as St,n as le,q as N}from"./chunk-NNJ2KZZG.js";function Nt(n){let e=new Map,t=ui(n),r=new Map;return i=>{let o=li(i),s=r.get(o);if(s!==void 0)return s;if(!t.has(i.file))return r.set(o,i.symbol),i.symbol;let a=e.get(i.file);a||(a=fi(z(n,i.file)),e.set(i.file,a));let c=di(a,i);return r.set(o,c),c}}function li(n){return`${n.file}\0${n.symbol}\0${n.line}`}function ui(n){return new Set(n.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function fi(n){let e=new Map,t=new Map;for(let r of n){let i=e.get(r.leaf);i?i.push(r):e.set(r.leaf,[r]);let o=t.get(r.startLine);o?o.push(r):t.set(r.startLine,[r])}return{definitions:n,byLeaf:e,byStartLine:t}}function di(n,e){if(n.definitions.length===0)return e.symbol;let t=yi(e.symbol),r=pi(n.byLeaf,t),i=mi(r,e.line);if(i)return i.symbol;let o=n.byStartLine.get(e.line)??[];return o.length===1?o[0].symbol:e.symbol}function pi(n,e){let t=[],r=new Set;for(let i of e)for(let o of n.get(i)??[])r.has(o.symbolId)||(r.add(o.symbolId),t.push(o));return t}function mi(n,e){let t=null;for(let r of n)if(!(r.startLine>e||r.endLine<e)){if(r.startLine===e)return r;(!t||r.endLine-r.startLine<t.endLine-t.startLine)&&(t=r)}return t}function yi(n){let e=new Set([n]),r=n.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function _t(n,e){let r=vt(n,e).map(i=>gi(e,i));return{usage:r,positions:bi(n,e,r)}}function Lt(n,e){return{importUsage(t){let r=n.importUsageFacts(t);if(!e||r.positions.length===0)return r.usage;let i=e.importDefinitionsForFile(t,r.positions);return i.available?Si(r.usage,i.sourcePaths):r.usage}}}function Si(n,e){return n.map((t,r)=>{let i=e.get(String(r));return i?{...t,sourcePath:i}:t})}function gi(n,e){let t=e.isTypeOnly===!0,r=e.kind==="side-effect"||t||e.used;return{importer:n,sourcePath:e.sourcePath,importedName:e.importedName,localName:e.localName,kind:e.kind,isTypeOnly:t,isUsed:r,isTypeUsed:t,isValueUsed:e.kind==="side-effect"||!t&&e.used,references:[]}}function bi(n,e,t){let r=It(n,e);if(!r)return[];let i=Ri(r.rootNode),o=new Map;for(let a of i){let c=o.get(gn(a.importedName,a.localName));c?c.push(a.position):o.set(gn(a.importedName,a.localName),[a.position])}let s=[];return t.forEach((a,c)=>{let u=o.get(gn(a.importedName,a.localName??a.importedName))?.shift();u&&s.push({...u,id:String(c),file:e})}),s}function Ri(n){let e=[];for(let t of n.descendantsOfType("use_declaration")){let r=t.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...qe(r,""))}return e.filter(t=>t.importedName!=="*")}function qe(n,e){switch(n.type){case"identifier":case"super":case"self":case"crate":return[{importedName:n.text,localName:n.text,position:Sn(n,n.text)}];case"scoped_identifier":{let t=n.text.split("::").pop()??n.text;return[{importedName:t,localName:t,position:Sn(n,t)}]}case"scoped_use_list":{let t=n.namedChild(0),r=n.namedChild(1);if(!t||!r)return[];let i=Mt(e,t.text);return r.namedChildren.flatMap(o=>qe(o,i))}case"use_list":return n.namedChildren.flatMap(t=>qe(t,e));case"use_as_clause":{let t=n.namedChild(0),r=n.namedChild(1);return!t||!r?[]:qe(t,e).map(i=>({...i,localName:r.text}))}case"use_wildcard":{let t=n.namedChild(0),r="*";return[{importedName:r,localName:r,position:Sn(t??n,r)}]}default:return[]}}function Sn(n,e){let t=Math.max(0,n.text.lastIndexOf(e));return{id:"",file:"",line:n.startPosition.row,column:n.startPosition.column+t+hi(e)}}function hi(n){return Math.max(0,Math.min(n.length-1,1))}function gn(n,e){return`${n}\0${e}`}import{spawnSync as wn}from"child_process";import{existsSync as kn}from"fs";import{fileURLToPath as vo}from"url";function je(n){let e=wt(Tt,n),t=e.runnable;return t?{available:!0,dependencyAvailable:t,resolvedBinary:e.resolvedBinary??void 0,note:"rust-analyzer semantic reference queries are enabled."}:{available:!1,dependencyAvailable:t,resolvedBinary:e.resolvedBinary??void 0,reason:"rust-analyzer is not runnable; Rust semantic checks will use SCIP/source evidence only."}}import{existsSync as oo,mkdtempSync as sr,rmSync as vn}from"fs";import{tmpdir as ar}from"os";import{join as Dn}from"path";import{fileURLToPath as Ye,pathToFileURL as so}from"url";import{SHARE_ENV as ao,Worker as co}from"worker_threads";function K(n,e,t=new Set){let r=new Map;for(let i of n)t.has(i.symbolId)||r.set(i.symbolId,e.get(i.symbolId)??[]);return r}function Y(n,e,t){let r=X(process.env.SCIP_RUST_SEMANTIC_BATCH_TIMEOUT_MS)??0;if(r>0)return r;let i=Math.max(1,Math.ceil(n/Math.max(1,t)));return Math.max(12e4,3e4+i*e)}import{spawn as Bi}from"child_process";import{createHash as qi,randomUUID as ji}from"crypto";import{existsSync as Qt,realpathSync as Wi,rmSync as zi}from"fs";import{tmpdir as Ki}from"os";import{resolve as re}from"path";import{execFileSync as wi}from"child_process";import{existsSync as Ii}from"fs";import{deserializeSCIP as Mi,SymbolRole as vi}from"@c4312/scip";import{realpathSync as ea}from"fs";import{basename as ta,dirname as ra,join as ia,relative as oa,sep as sa}from"path";import{fileURLToPath as ca,pathToFileURL as la}from"url";function We(n){let e=new Map;for(let t of n)e.set(`${t.file}\0${t.line}\0${t.column}`,t);return[...e.values()].sort((t,r)=>{let i=t.file.localeCompare(r.file);return i!==0?i:t.line!==r.line?t.line-r.line:t.column-r.column})}var bn=new WeakMap,Di="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function Ot(n,e){let t=new Map,r=ze(),i=e.filter(s=>qt(s,r));if(i.length===0)return t;let o=jt(n);if(!o)return t;for(let s of i){let a=Bt(o,s);a!==null&&t.set(s.symbolId,a)}return t}function Ut(n,e){if(!qt(e,ze()))return null;let t=jt(n);return t?Bt(t,e):null}function Bt(n,e){return n.referencesBySymbol.get(e.symbol)??[]}function qt(n,e="safe"){if(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||pe(n.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(n.symbol))return!1;if(e==="all")return!0;let t=Ne(n.symbol);if(t==="method")return!0;if(t!=="term")return!1;let r=Dt(n.symbol);return"kind"in r?!1:!xi(r)}function xi(n){for(let e=0;e<n.descriptors.length-1;e+=1)if(n.descriptors[e]?.suffix==="type")return!0;return!1}function jt(n){if(bn.has(n))return bn.get(n)??null;let e=Ci(n);return bn.set(n,e),e}function Ci(n){if(!n.generation.indexPath||!Ii(n.generation.indexPath))return null;try{let e=Mi(Te(n.generation.indexPath,{inputKind:"SCIP occurrence-reference index",maxBytes:Ce})),t=new Map;for(let r of e.documents??[]){let i=r.relativePath;if(!(!i||n.isIgnored(i)))for(let o of r.occurrences??[]){if(!o.symbol||(o.symbolRoles&vi.Definition)!==0)continue;let s=Ti(i,o.range);if(!s)continue;let a=t.get(o.symbol)??[];a.push(s),t.set(o.symbol,a)}}for(let[r,i]of t)t.set(r,We(i));return{referencesBySymbol:t}}catch{return null}}function Ti(n,e){if(e.length<3)return null;let t=e[0],r=e[1];return!Number.isInteger(t)||!Number.isInteger(r)?null:{file:n,line:t,column:r}}function ze(){return process.env[Di]==="all"?"all":"safe"}var Wt=new Map;function Rn(n){let t=je(n).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:t,version:t?ki(n,t):"unavailable"}}function hn(n){return{...Rn(n),scipOccurrenceReferenceMode:ze()}}function ki(n,e){let t=`${n}\0${e}`,r=Wt.get(t);if(r)return r;let i;try{i=wi(e,["--version"],{cwd:n,encoding:"utf8",stdio:["ignore","pipe","ignore"],windowsHide:!0,timeout:2e3}).trim()}catch{i="unknown"}return Wt.set(t,i),i}import{createHash as Pi}from"crypto";var Ei=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function zt(n){let e=Rt(n,{includePath:Ai});return Pi("sha256").update(JSON.stringify(e)).digest("hex")}function Ai(n){let e=n.replaceAll("\\","/"),t=e.split("/").at(-1)??e;return e.endsWith(".rs")||Ei.has(t)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}import{createHash as Fi}from"crypto";import{resolve as Ni}from"path";var te=3;function Mn(n){return Fi("sha256").update(me({kind:"codebaseiq-durable-rust-mailbox",protocolVersion:te,sessionDir:Ni(n)})).digest("hex")}function Vt(n,e){return le(n)?n.protocolVersion!==te?Ht(n.protocolVersion===void 0?"helper wrote a prior uncorrelated response protocol":`helper wrote unsupported response protocol ${String(n.protocolVersion)}`):n.mailboxVersion!==$||n.id!==e.requestId||n.operationKey!==e.operationKey||n.sessionIdentity!==e.sessionIdentity||n.deadlineAtMs!==e.deadlineAtMs?Ht("helper wrote an incompatible response identity"):typeof n.completedAtMs!="number"||!Number.isFinite(n.completedAtMs)||n.completedAtMs>e.deadlineAtMs||e.nowMs>e.deadlineAtMs?{ok:!1,code:"expired-request",error:"helper response arrived after the durable request deadline"}:n.ok===!1?typeof n.error!="string"||!Ui(n.errorCode)?In("helper wrote an invalid rejection response"):{ok:!1,code:n.errorCode,error:n.error}:n.ok!==!0||n.session!=="created"&&n.session!=="reused"&&n.session!=="invalidated"||!_i(n.response,e.requestKind)?In("helper wrote an invalid success response"):{ok:!0,session:n.session,response:n.response}:In("helper wrote an invalid response object")}function _i(n,e){return!le(n)||typeof n.available!="boolean"||n.available===!1&&(typeof n.reason!="string"||n.reason.length===0)||n.available===!0&&n.reason!==void 0?!1:e==="import-definitions"?Array.isArray(n.sourcePaths)&&n.sourcePaths.every(t=>Array.isArray(t)&&t.length===2&&typeof t[0]=="string"&&(t[1]===null||typeof t[1]=="string")):Kt(n.references,Li)&&(n.incompleteReferenceSymbolIds===void 0||Array.isArray(n.incompleteReferenceSymbolIds)&&n.incompleteReferenceSymbolIds.every(t=>Number.isSafeInteger(t)))&&(n.callees===void 0||Kt(n.callees,Oi))&&(n.signatures===void 0||Array.isArray(n.signatures)&&n.signatures.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&(t[1]===null||typeof t[1]=="string")))}function Kt(n,e){return Array.isArray(n)&&n.every(t=>Array.isArray(t)&&t.length===2&&Number.isSafeInteger(t[0])&&Array.isArray(t[1])&&t[1].every(e))}function Li(n){return le(n)&&typeof n.file=="string"&&N(n.line)&&N(n.column)}function Oi(n){return le(n)&&typeof n.symbol=="string"&&typeof n.file=="string"&&N(n.line)&&(n.callsiteLine===void 0||N(n.callsiteLine))}function Ui(n){return n==="unsupported-protocol"||n==="malformed-request"||n==="expired-request"||n==="handler-error"}function In(n){return{ok:!1,code:"malformed-response",error:n}}function Ht(n){return{ok:!1,code:"incompatible-response",error:n}}var Hi=5e3,Xt=10,Vi=3e4;function $t(n,e,t,r=rr){let i=r.engineIdentity(n),o={protocolVersion:te,projectRoot:r.canonicalProjectRoot(n),projectFingerprint:r.projectFingerprint(n),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:er(r.environment())};return{key:ir(me(o)),...o}}function Ke(n,e,t,r){if(n.protocolVersion!==te||!t(n.pid))return!1;if(!n.processIdentity)return!0;let i=r?.(n.pid);return i!=null&&xe(n.processIdentity,i)}function Zt(n,e,t){let r;try{r=an(e,{maxBytes:H,inputKind:"Rust semantic engine artifact"})}catch{r="missing"}let i=ir(me({projectRoot:re(n),serverPath:re(e),serverFingerprint:r})).slice(0,20);return re(t,`codebaseiq-rust-session-${i}`)}function Yt(n){let e=n===void 0?Number.NaN:Number(n);return Number.isInteger(e)&&e>=0?e:0}function er(n){return Object.fromEntries(Object.entries(n).filter(([e])=>tr(e)).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t??null]))}function nr(n,e){let t=e.runtime??Xi,r=e.identityRuntime??rr,i=Zt(n,e.serverPath,e.tempRoot??Ki()),o=!1,s=(a,c)=>{if(o)throw new Error("Durable Rust semantic session was already disposed.");return Yi(i,e.serverPath,e.semanticWorkerPath,a,c,t,e.mailboxLimits)};return{requestSemantic(a,c){let u=$t(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...l}=a;return s({kind:"semantic",identityKey:u.key,workerEnvironment:Gt(),request:{...l,referenceRetryTimeoutMs:$i(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Yt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let u=$t(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:f,...l}=a;return s({kind:"import-definitions",identityKey:u.key,workerEnvironment:Gt(),request:{...l,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Yt(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){o=!0}}}function $i(n,e){return e!==void 0?e:n===void 0?Vi:void 0}function Yi(n,e,t,r,i,o,s={}){let a=o.now(),c=a+i,u=(o.monotonicNow??q)(),f=u+i,l=Z("rust-semantic-v3",r),d=ee(l),p=Le(n),m=Mn(n),R=Oe(p,{mailboxVersion:$,protocolVersion:te,id:d,operationKey:l,clientId:o.randomId(),enqueuedAtMs:a,deadlineAtMs:c,sessionIdentity:m,request:r},{nowMs:a,limits:s});for(Jt(n,e,t,f,o);(o.monotonicNow??q)()<=f;){if(Qt(R.responsePath)){let S=Ji(B(R.responsePath,{maxBytes:s.maxItemBytes??H,inputKind:"durable Rust semantic mailbox response"}),{requestId:d,operationKey:l,sessionIdentity:m,deadlineAtMs:R.authoritativeDeadlineAtMs,requestKind:r.kind,nowMs:o.now()});if(!S.ok)throw new Error(S.error);return _()&&Ae({type:"span",name:"rust.semantic.durable-session.request",durationMs:(o.monotonicNow??q)()-u,ok:!0,session:S.session,kind:r.kind}),S.response}let I=He(n);(!I||!Ke(I,o.now(),o.isProcessAlive,o.readProcessIdentity))&&Jt(n,e,t,f,o),o.sleep(Xt)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}function Jt(n,e,t,r,i){let o=He(n);if(o&&Ke(o,i.now(),i.isProcessAlive,i.readProcessIdentity))return;zi(re(n,"server.json"),{force:!0}),i.spawnServer(e,n,t);let s=i.monotonicNow??q,a=Math.min(r,s()+Hi);for(;s()<=a;){let c=He(n);if(c&&Ke(c,i.now(),i.isProcessAlive,i.readProcessIdentity))return;i.sleep(Xt)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function He(n){try{let e=JSON.parse(B(re(n,"server.json"),{maxBytes:at,inputKind:"durable Rust session state"}));if(typeof e.protocolVersion!="number"||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||e.sessionIdentity!==Mn(n))||typeof e.pid!="number"||typeof e.heartbeatAtMs!="number"||e.busyUntilMs!==void 0&&typeof e.busyUntilMs!="number"||e.mailbox!==void 0&&!Gi(e.mailbox))return null;let t=e.processIdentity===void 0?null:De(e.processIdentity);return e.processIdentity!==void 0&&(!t||t.pid!==e.pid)?null:{protocolVersion:e.protocolVersion,...e.sessionIdentity===void 0?{}:{sessionIdentity:e.sessionIdentity},pid:e.pid,...t?{processIdentity:t}:{},heartbeatAtMs:e.heartbeatAtMs,...e.busyUntilMs===void 0?{}:{busyUntilMs:e.busyUntilMs},...e.mailbox===void 0?{}:{mailbox:e.mailbox}}}catch{return null}}function Ji(n,e){try{return Vt(JSON.parse(n),e)}catch(t){return{ok:!1,code:"malformed-response",error:`helper wrote malformed JSON: ${t instanceof Error?t.message:String(t)}`}}}function Gi(n){if(!n||typeof n!="object")return!1;let e=n;return N(e.pending)&&N(e.inflight)&&N(e.responses)&&N(e.deadLetters)&&N(e.invalid)&&N(e.totalItems)&&typeof e.totalBytes=="number"&&Number.isFinite(e.totalBytes)&&e.totalBytes>=0&&(e.oldestPendingAt===void 0||Number.isFinite(Date.parse(e.oldestPendingAt)))}function Gt(){return Object.fromEntries(Object.entries(process.env).filter(([n])=>Qi(n)).sort(([n],[e])=>n.localeCompare(e)).map(([n,e])=>[n,e??null]))}function tr(n){return n==="HOME"||n==="PATH"||n.startsWith("CARGO_")||n.startsWith("RA_")||n.startsWith("RUST")}function Qi(n){return tr(n)||n.startsWith("SCIP_RUST_")||n==="CODEBASEIQ_PROFILE"||n==="CODEBASEIQ_PROFILE_CACHE_STATE"||n==="CODEBASEIQ_PROFILE_COMMAND"||n==="CODEBASEIQ_PROFILE_OUT"||n==="CODEBASEIQ_PROFILE_RUN_ID"||n==="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY"||n==="CODEBASEIQ_PROFILE_WORKLOAD_IDENTITY_KIND"||n==="CODEBASEIQ_PROFILE_MIN_MS"}var rr={canonicalProjectRoot(n){try{return Wi(n)}catch{return re(n)}},projectFingerprint(n){return zt(n)},engineIdentity:Rn,fileFingerprint(n){return an(n,{maxBytes:H,inputKind:"Rust semantic engine artifact"})},environment(){return er(process.env)}},Xi={now:Date.now,monotonicNow:q,randomId:ji,isProcessAlive:ke,readProcessIdentity:we,spawnServer(n,e,t){if(!Qt(n))throw new Error(`Durable Rust semantic session helper was not found at ${n}. Run npm run build first.`);Bi(process.execPath,[n,e,t],{detached:!0,stdio:"ignore",windowsHide:!0}).unref()},sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)}};function ir(n){return qi("sha256").update(n).digest("hex")}import{randomUUID as Xa}from"crypto";import{readdirSync as Zi,rmSync as ec,writeFileSync as nc}from"fs";import{join as eo}from"path";var no="rust-analyzer-owner-",to=".json",ro=16*1024;async function or(n,e){if(!n)return[];let t;try{t=Zi(n)}catch{return[]}let r=t.filter(s=>s.startsWith(no)&&s.endsWith(to)).map(s=>eo(n,s)),i=[],o=[];for(let s of r){let a=io(s);a?o.push(a):i.push({reaped:!1,reason:"identity-unavailable",detail:`Rust analyzer ownership record ${s} could not be validated.`})}return i.push(...await Promise.all(o.map(s=>kt(s,e)))),i}function io(n){try{let e=B(n,{maxBytes:ro,inputKind:"rust-analyzer process ownership record"}),t=JSON.parse(e),r=De(t.rootIdentity);return t.version!==1||!r||typeof t.ownsProcessGroup!="boolean"?null:{rootPid:r.pid,rootIdentity:r,ownsProcessGroup:t.ownsProcessGroup,knownMembers:new Map([[r.pid,r]])}}catch{return null}}var cr=15e3,lr=8,fr=5e3,lo=64,uo=96,Cn=class{constructor(e,t,r={}){this.projectRoot=e;this.status=t;this.opts=r;this.requester=r.requester??yo(e,process.env.SCIP_RUST_SEMANTIC_DURABLE_SESSION)}projectRoot;status;opts;requester;referencesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:Se(t),references:ge(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!0});return{...ye(r),resolvedBinary:t.resolvedBinary,references:K(e,new Map(r.references),new Set(r.incompleteReferenceSymbolIds??[]))}}catch(r){return this.opts.fallbackReferenceResolver?.referencesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),references:ge(e)}}}calleesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:Se(t),callees:be(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{...ye(r),resolvedBinary:t.resolvedBinary,callees:xn(e,new Map(r.callees??[]))}}catch(r){return this.opts.fallbackCalleeResolver?.calleesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),callees:be(e)}}}referencesAndCalleesForDefinitions(e,t){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Se(r),references:ge(e),callees:be(t)};let i=[...e,...t];try{let o=this.requestSession(r.resolvedBinary,i,{includeReferences:e.length>0,includeCallees:t.length>0,referenceDefinitions:e,calleeDefinitions:t});return{...ye(o),resolvedBinary:r.resolvedBinary,references:K(e,new Map(o.references),new Set(o.incompleteReferenceSymbolIds??[])),callees:xn(t,new Map(o.callees??[]))}}catch(o){return this.fallbackReferencesAndCallees(r,e,t,o)}}signaturesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:Se(t),signatures:ur(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{...ye(r),resolvedBinary:t.resolvedBinary,signatures:ho(e,new Map(r.signatures??[]))}}catch(r){return this.opts.fallbackSignatureResolver?.signaturesForDefinitions(e)??{available:!1,resolvedBinary:t.resolvedBinary,reason:r instanceof Error?r.message:String(r),signatures:ur(e)}}}importDefinitionsForFile(e,t){let r=this.status(this.projectRoot);if(t.length===0)return r.available?{available:!0,resolvedBinary:r.resolvedBinary,sourcePaths:new Map}:{available:!1,reason:r.reason,resolvedBinary:r.resolvedBinary,sourcePaths:new Map};if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Se(r),sourcePaths:new Map(t.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,t);return{...ye(i),resolvedBinary:r.resolvedBinary,sourcePaths:new Map(i.sourcePaths)}}catch(i){return{available:!1,resolvedBinary:r.resolvedBinary,reason:i instanceof Error?i.message:String(i),sourcePaths:new Map(t.map(o=>[o.id,null]))}}}dispose(){this.requester.shutdown()}requestSession(e,t,r){let i=Ve(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,cr),o=$e(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),s=Ve(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,lr),a=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),c=r.referenceDefinitions?[...r.referenceDefinitions]:void 0,u=r.calleeDefinitions?[...r.calleeDefinitions]:void 0,f=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,l=Re(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,...r}),d={projectRoot:this.projectRoot,rustAnalyzerBinary:e,definitions:[...t],...c?{referenceDefinitions:c}:{},...u?{calleeDefinitions:u}:{},...f?{signatureDefinitions:f}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:a,settleDelayMs:l,concurrency:s,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},p=Io(d);return k("rust.semantic.session.request",()=>this.requester.requestSemantic(d,Y(p,Tn(i,d.referenceRetryTimeoutMs),s)),()=>({definitions:t.length,operationDefinitions:p,referenceDefinitions:d.referenceDefinitions?.length,calleeDefinitions:d.calleeDefinitions?.length,signatureDefinitions:d.signatureDefinitions?.length,references:d.includeReferences!==!1,callees:d.includeCallees===!0,signatures:d.includeSignatures===!0,referenceRetryTimeoutMs:d.referenceRetryTimeoutMs}))}fallbackReferencesAndCallees(e,t,r,i){let o=t.length===0?{available:!0,resolvedBinary:e.resolvedBinary,references:ge(t)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(t),s=r.length===0?{available:!0,resolvedBinary:e.resolvedBinary,callees:be(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);if(o&&s){let a={resolvedBinary:o.resolvedBinary??s.resolvedBinary??e.resolvedBinary,references:K(t,o.references),callees:xn(r,s.callees)};return o.available&&s.available?{available:!0,...a}:{available:!1,reason:(o.available?void 0:o.reason)??(s.available?void 0:s.reason)??"Rust semantic fallback was unavailable.",...a}}return{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:ge(t),callees:be(r)}}requestImportDefinitions(e,t,r){let i=Ve(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,cr),o=Ve(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,lr),s=$e(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=$e(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,fr),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:t,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:s,settleDelayMs:a,concurrency:o};return k("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,Y(r.length,i,o)),()=>({file:t,positions:r.length}))}};function ye(n){return n.available?{available:!0}:{available:!1,reason:n.reason}}function Se(n){return n.available?"rust-analyzer binary path is unavailable.":n.reason}function dr(n,e,t={}){return new Cn(n,e,t)}function Re(n,e){let t=mr(n);if(t!==null)return t;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=lo||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=uo?0:fr}function fo(n){let e=n?.trim().toLowerCase(),t=e==="0"||e==="false"||e==="off"||e==="worker",r=e==="1"||e==="true"||e==="on"||e==="durable",i=e===void 0||e==="";return{transport:t||!i&&!r?"worker":"durable",source:i?"default":"environment",fallback:"worker",valid:i||t||r,optOut:"SCIP_RUST_SEMANTIC_DURABLE_SESSION=0"}}function po(n){return fo(n).transport}function mo(n,e){let t=null,r=!1,i=!1,o=!1,s=()=>t??=e(),a=()=>{i||(n.shutdown(),i=!0)},c=(f,l,d)=>{let p=Ro(f);r=!0;try{a()}catch{}_()&&Ae({type:"span",name:"rust.semantic.durable-session.request",durationMs:d,ok:!1,kind:l,session:"worker-fallback",reason:p})},u=(f,l,d)=>{if(o)throw new Error("Rust semantic failover session was already disposed.");if(r)return d(s());let p=performance.now();try{return l(n)}catch(m){c(m,f,performance.now()-p)}return d(s())};return{requestSemantic(f,l){return u("semantic",d=>d.requestSemantic(f,l),d=>d.requestSemantic(f,l))},requestImportDefinitions(f,l){return u("import-definitions",d=>d.requestImportDefinitions(f,l),d=>d.requestImportDefinitions(f,l))},shutdown(){if(o)return;o=!0;let f=[];try{a()}catch(l){f.push(l)}try{t?.shutdown()}catch(l){f.push(l)}if(f.length>0)throw f[0]}}}function yo(n,e,t={worker:()=>So(),durable:()=>nr(n,{serverPath:Ye(Mo()),semanticWorkerPath:Ye(pr())})}){return po(e)==="durable"?mo(t.durable(),t.worker):t.worker()}function So(n={}){let e=null,t=null,r=1,i=!1,o=null,s=null,a=l=>{l&&vn(l,{recursive:!0,force:!0})},c=()=>{if(o)return;let l=e,d=t;e=null,t=null;let p=l?l.terminate():Promise.resolve(0);o=Promise.allSettled([p,or(d,{gracefulMs:1e3,forceMs:1e3})]).then(([m,R])=>{let S=(R.status==="fulfilled"?R.value:[{reaped:!1,detail:String(R.reason)}]).filter(h=>!h.reaped);if(m.status==="rejected"||S.length>0){s=new Error(`Rust semantic worker cleanup did not complete; ownership evidence remains at ${d??"unknown"}.`);return}a(d)}).finally(()=>{o=null})},u=()=>{if(e)return e;if(o)throw new Error("The previous Rust semantic session worker is still terminating; retry the request.");if(s)throw s;let l=n.semanticWorkerPath?so(n.semanticWorkerPath):pr();if(!oo(Ye(l)))throw new Error(`Rust semantic session worker was not found at ${Ye(l)}. Run npm run build before using built semantic Rust queries.`);return t=sr(Dn(ar(),"codebaseiq-rust-session-")),e=new co(l,n.shareEnvironment?{env:ao}:void 0),e.unref(),e},f=()=>{let l=t??sr(Dn(ar(),"codebaseiq-rust-session-"));return t=l,Dn(l,`${r++}.json`)};return{requestSemantic(l,d){if(i)throw new Error("Rust semantic session was already disposed.");let p=u(),m=f(),R=new SharedArrayBuffer(4),I=new Int32Array(R);if(p.postMessage({kind:"semantic",request:l,responsePath:m,sharedBuffer:R}),Atomics.wait(I,0,0,d)==="timed-out")throw c(),new Error(`Rust semantic session worker timed out after ${(d/1e3).toFixed(0)}s`);try{let h=go(B(m,{maxBytes:H,inputKind:"Rust semantic worker response"}));if(!h.ok)throw new Error(h.error);return h.response}finally{vn(m,{force:!0})}},requestImportDefinitions(l,d){if(i)throw new Error("Rust semantic session was already disposed.");let p=u(),m=f(),R=new SharedArrayBuffer(4),I=new Int32Array(R);if(p.postMessage({kind:"import-definitions",request:l,responsePath:m,sharedBuffer:R}),Atomics.wait(I,0,0,d)==="timed-out")throw c(),new Error(`Rust semantic import-definition session worker timed out after ${(d/1e3).toFixed(0)}s`);try{let h=bo(B(m,{maxBytes:H,inputKind:"Rust import-definition worker response"}));if(!h.ok)throw new Error(h.error);return h.response}finally{vn(m,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){a(t),t=null;return}let l=f(),d=new SharedArrayBuffer(4),p=new Int32Array(d);e.postMessage({kind:"shutdown",responsePath:l,sharedBuffer:d}),Atomics.wait(p,0,0,5e3),c()}}}function go(n){let e=JSON.parse(n);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=e;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function bo(n){let e=JSON.parse(n);if(!e||typeof e!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=e;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof e.error=="string"?e.error:"Rust semantic session worker failed."}}function Ro(n){let e=n instanceof Error?`${n.name} ${n.message}`.toLowerCase():String(n).toLowerCase();return e.includes("readiness")?"readiness":e.includes("timeout")||e.includes("timed out")?"timeout":e.includes("helper")?"helper":"request"}function ge(n){return new Map(n.map(e=>[e.symbolId,[]]))}function be(n){return new Map(n.map(e=>[e.symbolId,[]]))}function ur(n){return new Map(n.map(e=>[e.symbolId,null]))}function xn(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??[]]))}function ho(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Io(n){let e=0;return n.includeReferences!==!1&&(e+=(n.referenceDefinitions??n.definitions).length),n.includeCallees===!0&&(e+=(n.calleeDefinitions??n.definitions).length),n.includeSignatures===!0&&(e+=(n.signatureDefinitions??n.definitions).length),Math.max(1,e)}function Tn(n,e){return e&&e>0?Math.max(n,e):n}function pr(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Mo(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function Ve(n,e){return X(n)??e}function $e(n,e){return mr(n)??e}function mr(n){if(!n)return null;let e=Number(n);return Number.isInteger(e)&&e>=0?e:null}var Pn=15e3,En=8;function br(n,e={}){let t=e.status??je,r=Co(n,t),i=To(n,t),o=wo(n,t),s=e.referenceResolver||e.calleeResolver||e.signatureResolver||!Do(e)?null:dr(n,t,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:o}),a=e.referenceResolver??s??r,c=e.calleeResolver??s??i,u=e.signatureResolver??s??o,f=e.importUsageResolver??Lt(e.sourceImportUsageResolver??xo(),e.importDefinitionResolver??s),l=e.calleeSymbolResolver,d=e.sourceZeroCalleeOracle,p=e.scipOccurrenceCalleeOracle,m=new Map,R=new Map,I=null,S=null,h=()=>(I??=t(n),I),P=()=>{let b=h();return b.dependencyAvailable?S??b:b},M=b=>{if(b.length===0)return new Map;let y=Ie(b);try{let g=a.referencesForDefinitions(y),T=h();return S=Je(T,g),g.available?new Map(g.references):K(y,g.references)}catch(g){let T=h();return S=he(T,g),J(y)}},v=b=>{if(b.length===0)return new Map;let y=Ie(b),g=y.filter(yr);if(g.length===0)return G(y);let T=new Map,j=gr(g,p),F=[];for(let w of g)R.has(w.symbolId)?T.set(w.symbolId,R.get(w.symbolId)??[]):j.has(w.symbolId)?T.set(w.symbolId,j.get(w.symbolId)??[]):Sr(w,d)?T.set(w.symbolId,[]):F.push(w);if(F.length===0)return ie(y,T,void 0);try{let w=c.calleesForDefinitions(F),O=h();S=Je(O,w);let E=ie(F,w.callees,l);for(let[ce,rn]of E)T.set(ce,rn);return ie(y,T,void 0)}catch(w){let O=h();return S=he(O,w),G(y)}},C=(b,y)=>{let g=Ie(b),T=Ie(y),j=T.filter(yr),F=new Map,w=gr(j,p),O=[];for(let E of j)w.has(E.symbolId)?F.set(E.symbolId,w.get(E.symbolId)??[]):Sr(E,d)?F.set(E.symbolId,[]):O.push(E);if(g.length===0&&O.length===0)return{references:J(g),callees:ie(T,F,void 0)};try{let E=s?s.referencesAndCalleesForDefinitions(g,O):Ao(a,c,{referenceDefinitions:g,calleeDefinitions:O}),ce=h();S=Je(ce,E);let rn=E.available?new Map(E.references):K(g,E.references);for(let[on,sn]of E.callees)F.set(on,sn);let it=ie(T,F,l);for(let[on,sn]of it)R.set(on,sn);return{references:rn,callees:it}}catch(E){let ce=h();return S=he(ce,E),{references:J(g),callees:G(T)}}},D=b=>{if(b.length===0)return new Map;let y=Ie(b);try{let g=u.signaturesForDefinitions(y),T=h();return S=Je(T,g),Rr(y,g.signatures)}catch(g){let T=h();return S=he(T,g),Ge(y)}};return{language:"rust",availability:P,dispose:()=>{s?.dispose()},importUsage:b=>{let y=m.get(b);if(y)return y;try{let g=f.importUsage(b);return m.set(b,g),g}catch(g){let T=h();return S=he(T,g),[]}},referencesFor:b=>M([b]).get(b.symbolId)??[],referencesForDefinitions:M,referencesAndCalleesForDefinitions:C,calleesFor:b=>v([b]).get(b.symbolId)??[],calleesForDefinitions:v,signatureFor:b=>D([b]).get(b.symbolId)??null}}function Je(n,e){let t={dependencyAvailable:n.dependencyAvailable,resolvedBinary:e.resolvedBinary??n.resolvedBinary,...n.note?{note:n.note}:{}};return e.available?{available:!0,...t}:{available:!1,reason:e.reason,...t}}function he(n,e){return{available:!1,dependencyAvailable:n.dependencyAvailable,resolvedBinary:n.resolvedBinary,...n.note?{note:n.note}:{},reason:e instanceof Error?e.message:String(e)}}function Do(n){if(n.usePersistentSession!==void 0)return n.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function xo(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function Ie(n){return n.map(e=>{let t=e;return{...e,leaf:typeof t.leaf=="string"?t.leaf:V(e.symbol),parentTypeName:t.parentTypeName??null,isFunctionLike:typeof t.isFunctionLike=="boolean"?t.isFunctionLike:xt(e.symbol),isTypeLike:t.isTypeLike??!1,kind:t.kind??null,documentation:t.documentation??null,enclosingSymbol:t.enclosingSymbol??null}})}function yr(n){return n.isFunctionLike}function Sr(n,e){if(!e)return!1;try{return e(n)}catch{return!1}}function gr(n,e){if(!e||n.length===0)return new Map;try{return e(n)}catch{return new Map}}function Co(n,e){return{referencesForDefinitions:t=>ko(n,e,t)}}function To(n,e){return{calleesForDefinitions:t=>Po(n,e,t)}}function wo(n,e){return{signaturesForDefinitions:t=>Eo(n,e,t)}}function ko(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Nn(r),references:J(t)};let i=An();if(!kn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,references:J(t)};let o=oe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Pn),s=Qe(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=oe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,En),c=Qe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),u=Re(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!0}),f={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,...s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:c,settleDelayMs:u,concurrency:a},l=wn(process.execPath,[i],{cwd:n,input:JSON.stringify(f),encoding:"utf8",maxBuffer:50*1024*1024,windowsHide:!0,timeout:Y(t.length,Tn(o,f.referenceRetryTimeoutMs),a)}),d=_n(l.stdout);if(d)return{...Fn(d),resolvedBinary:r.resolvedBinary,references:K(t,new Map(d.references),new Set(d.incompleteReferenceSymbolIds??[]))};let p=l.error instanceof Error?l.error.message:l.stderr.trim()||`Rust semantic worker exited with status ${l.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:p,references:J(t)}}function Po(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Nn(r),callees:G(t)};let i=An();if(!kn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,callees:G(t)};let o=oe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Pn),s=oe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,En),a=Qe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=Re(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!1,includeCallees:!0}),u={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:s,includeReferences:!1,includeCallees:!0},f=wn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,windowsHide:!0,timeout:Y(t.length,o,s)}),l=_n(f.stdout);if(l)return{...Fn(l),resolvedBinary:r.resolvedBinary,callees:ie(t,new Map(l.callees??[]),void 0)};let d=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,callees:G(t)}}function Eo(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Nn(r),signatures:Ge(t)};let i=An();if(!kn(i))return{available:!1,resolvedBinary:r.resolvedBinary,reason:`Rust semantic worker was not found at ${i}. Run npm run build before using built semantic Rust queries.`,signatures:Ge(t)};let o=oe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,Pn),s=oe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,En),a=Qe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=Re(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!1,includeCallees:!1,includeSignatures:!0}),u={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,diagnosticsTimeoutMs:a,settleDelayMs:c,concurrency:s,includeReferences:!1,includeCallees:!1,includeSignatures:!0},f=wn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,windowsHide:!0,timeout:Y(t.length,o,s)}),l=_n(f.stdout);if(l)return{...Fn(l),resolvedBinary:r.resolvedBinary,signatures:Rr(t,new Map(l.signatures??[]))};let d=f.error instanceof Error?f.error.message:f.stderr.trim()||`Rust semantic worker exited with status ${f.status??"unknown"}.`;return{available:!1,resolvedBinary:r.resolvedBinary,reason:d,signatures:Ge(t)}}function Ao(n,e,t){let r=t.referenceDefinitions.length>0?n.referencesForDefinitions(t.referenceDefinitions):{available:!0,references:J(t.referenceDefinitions)},i=t.calleeDefinitions.length>0?e.calleesForDefinitions(t.calleeDefinitions):{available:!0,callees:G(t.calleeDefinitions)},o={resolvedBinary:r.resolvedBinary??i.resolvedBinary,references:r.references,callees:i.callees};return r.available&&i.available?{available:!0,...o}:{available:!1,reason:(r.available?void 0:r.reason)??(i.available?void 0:i.reason)??"Rust semantic resolution was unavailable.",...o}}function J(n){return new Map(n.map(e=>[e.symbolId,[]]))}function G(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Ge(n){return new Map(n.map(e=>[e.symbolId,null]))}function ie(n,e,t){let r=0,i=0;return k("rust.semantic.callees.complete-map",()=>{let o=new Map;for(let s of n){let a=e.get(s.symbolId)??[];a.length>0&&(r+=1),i+=a.length,o.set(s.symbolId,a.map(c=>({...c,symbol:t?t(c):c.symbol})))}return o},()=>({definitions:n.length,rows:r,callees:i,resolveSymbols:!!t}))}function Rr(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function An(){return vo(new URL("./rust-semantic-worker.js",import.meta.url))}function Fn(n){return n.available?{available:!0}:{available:!1,reason:n.reason}}function Nn(n){return n.available?"rust-analyzer binary path is unavailable.":n.reason}function _n(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e;if(typeof t.available!="boolean"||!Array.isArray(t.references)||t.available===!1&&typeof t.reason!="string"||t.available===!0&&t.reason!==void 0)return null;let r={references:t.references,incompleteReferenceSymbolIds:Array.isArray(t.incompleteReferenceSymbolIds)?t.incompleteReferenceSymbolIds.filter(i=>typeof i=="number"):void 0,callees:Array.isArray(t.callees)?t.callees:void 0,signatures:Array.isArray(t.signatures)?t.signatures:void 0};return t.available===!0?{available:!0,...r}:{available:!1,reason:String(t.reason),...r}}catch{return null}}function oe(n,e){return X(n)??e}function Qe(n,e){if(!n)return e;let t=Number(n);return Number.isInteger(t)&&t>=0?t:e}import{existsSync as Fo}from"fs";import{deserializeSCIP as No,SymbolRole as _o}from"@c4312/scip";var Ln=new WeakMap;function Ir(n,e){let t=e.filter(Lo);if(t.length===0)return new Map;let r=!1,i=0,o=0;return k("rust.scip-occurrence.callees",()=>{let s=Bo(n);if(r=!!s,!s)return new Map;let a=new Map;for(let c of t){let u=Oo(n,s,c);u!==null&&(a.set(c.symbolId,u),i+=1,o+=u.length)}return a},()=>({definitions:e.length,candidates:t.length,indexAvailable:r,resolvedDefinitions:i,resolvedCallees:o}))}function Lo(n){return!(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||!n.isFunctionLike||n.leaf==="main"||pe(n.symbol))}function Oo(n,e,t){let r=Fe(n,t.relativePath);if(!r||r.language!=="rust")return null;let i=r.callables.find(u=>u.startLine!==t.startLine||u.endLine!==t.endLine?!1:u.name===t.leaf||t.leaf.endsWith(u.name)||u.name.endsWith(t.leaf));if(!i)return null;let o=r.callSites.filter(u=>u.line>=i.startLine&&u.line<=i.endLine);if(o.length===0)return null;let s=(e.occurrencesByFile.get(t.relativePath)??[]).filter(u=>u.line>=i.startLine&&u.line<=i.endLine&&u.callee.symbol!==t.symbol);if(s.some(u=>u.traitImplMember)||!Uo(o,s))return null;let a=[],c=new Set;for(let u of s){let f=`${u.callee.symbol}\0${u.callee.file}\0${u.callee.line}`;c.has(f)||(c.add(f),a.push(u.callee))}return a}function Uo(n,e){let t=hr(n),r=hr(e);if(t.size!==r.size)return!1;for(let[i,o]of t)if(r.get(i)!==o)return!1;return!0}function hr(n){let e=new Map;for(let t of n){let r=t.calleeLeaf??t.leaf;if(!r)continue;let i=`${t.line}\0${r}`;e.set(i,(e.get(i)??0)+1)}return e}function Bo(n){if(Ln.has(n))return Ln.get(n)??null;let e=qo(n);return Ln.set(n,e),e}function qo(n){if(!n.generation.indexPath||!Fo(n.generation.indexPath))return null;try{let e=_e(n).filter(o=>o.symbol.startsWith("rust-analyzer ")&&o.relativePath.endsWith(".rs")&&o.isFunctionLike),t=new Map(e.map(o=>[o.symbol,o])),r=No(Te(n.generation.indexPath,{inputKind:"SCIP occurrence-callee index",maxBytes:Ce})),i=new Map;for(let o of r.documents??[]){let s=o.relativePath;if(!s||!s.endsWith(".rs")||n.isIgnored(s))continue;let a=[];for(let c of o.occurrences??[]){if(!c.symbol||(c.symbolRoles&_o.Definition)!==0)continue;let u=t.get(c.symbol);if(!u)continue;let f=c.range?.[0];Number.isInteger(f)&&a.push({line:f,leaf:u.leaf,traitImplMember:pe(u.symbol),callee:{symbol:u.symbol,file:u.relativePath,line:u.startLine,callsiteLine:f}})}i.set(s,a)}return{occurrencesByFile:i}}catch{return null}}var Xe=class{sessions=new WeakMap;getOrCreate(e,t,r){let i=jo(e,t),o=this.sessions.get(e);o||(o=new Map,this.sessions.set(e,o));let s=o.get(i);if(s)return s.hits+=1,s.lastUsedAtMs=Date.now(),s.provider;let a=Date.now(),c=r();return o.set(i,{key:i,language:t,projectRoot:e.config.projectRoot,provider:c,createdAtMs:a,lastUsedAtMs:a,hits:1}),c}sessionsFor(e){return[...this.sessions.get(e)?.values()??[]]}clear(e){let t=this.sessions.get(e);if(t)for(let r of t.values())r.provider.dispose?.();this.sessions.delete(e)}};function jo(n,e){return`${n.config.projectRoot}:${e}-workspace`}import{randomUUID as ps}from"crypto";import{existsSync as ms}from"fs";import{dirname as ys}from"path";function Mr(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n;if(typeof e.available!="boolean"||e.dependencyAvailable!==void 0&&typeof e.dependencyAvailable!="boolean"||e.tsconfigPath!==void 0&&typeof e.tsconfigPath!="string"||e.tsconfigPaths!==void 0&&(!Array.isArray(e.tsconfigPaths)||!e.tsconfigPaths.every(t=>typeof t=="string"))||e.resolvedBinary!==void 0&&typeof e.resolvedBinary!="string"||e.note!==void 0&&typeof e.note!="string")return null;if(e.available===!0){if(e.reason!==void 0)return null}else if(typeof e.reason!="string"||e.reason.length===0)return null;return e}import{performance as x}from"perf_hooks";function U(n,e,t){if(n.has(e))return n.get(e);let r=t();return n.set(e,r),r}import xr from"path";import{realpathSync as vr}from"fs";function Wo(n,e){return n.getReferences().map(t=>{let r=t.getNode();return Ze(r,e)})}function zo(n){let e=n;return typeof e.findReferences=="function"?e.findReferences():[]}function Cr(n,e,t,r){let i=[];for(let o of zo(n))for(let s of Wo(o,r))s.file===e.relativePath&&s.line>=e.startLine&&s.line<=e.endLine||i.push(s);for(let o of t)i.push(o);return se(i)}function Tr(n,e,t,r){let i=[],o=t?.getStart();for(let s of n.getReferences()){let a=s.getNode();ae(r,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||i.push({location:Ze(a,r),node:a}))}return i}function Ze(n,e){let t=n.getSourceFile(),r=t.getLineAndColumnAtPos(n.getStart());return{file:ae(e,t.getFilePath())??t.getBaseName(),line:r.line-1,column:r.column-1}}function On(n,e,t){let r=n.getSourceFile(),i=Bn(r,n),o=n.getText(),s=new RegExp(`\\b${de(o)}\\b`,"g"),a=r.getFullText().split(`
|
|
2
|
+
`),c=[];for(let u=0;u<a.length;u++){if(u===i)continue;let f=a[u]??"";s.lastIndex=0;let l;for(;(l=s.exec(f))!==null;)c.push({file:e,line:u,column:l.index})}return se(c.filter(u=>ae(t,xr.join(t,u.file))===e))}function Un(n){for(let e=n;e;e=e.getParent()){let t=e.getKindName();if(t.includes("Type")||t==="InterfaceDeclaration"||t==="TypeAliasDeclaration")return!0;if(t==="CallExpression"||t==="NewExpression"||t==="ExpressionStatement")return!1}return!1}function Bn(n,e){return n.getLineAndColumnAtPos(e.getStart()).line-1}function se(n){let e=new Set,t=[];for(let r of n){let i=`${r.file}:${r.line}:${r.column}`;e.has(i)||(e.add(i),t.push(r))}return t}function ae(n,e){let t=n||process.cwd(),r=Dr(t,e);if(r)return r;try{return Dr(vr(t),vr(e))}catch{return null}}function Dr(n,e){let t=xr.relative(n,e).replace(/\\/g,"/");return!t||t===".."||t.startsWith("../")?null:t}function wr(n,e,t,r){let i=Ko(e,r);return i.size===0?new Map:Ho(n,t,i)}function Ko(n,e){let t=new Map;for(let r of z(n,e)){let i=V(r.symbol)??r.leaf;if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push(r)}return t}function Ho(n,e,t){let r=new Map,i=new Map;return e.forEachDescendant(o=>{for(let s of Vo(n,o)){let a=t.get(s);if(!a)continue;let c=Bn(e,o);for(let u of a){if(c<u.startLine-1||c>u.endLine+1)continue;let f=Math.abs(c-u.startLine),l=i.get(u.symbolId);l!==void 0&&l<=f||(i.set(u.symbolId,f),r.set(u.symbolId,o))}}}),r}function Vo(n,e){let t=[],r=i=>{i&&!t.includes(i)&&t.push(i)};if("getNameNode"in e&&typeof e.getNameNode=="function"){let i=e.getNameNode();r(i?.getText())}if("getName"in e&&typeof e.getName=="function"){let i=e.getName();r(i)}return n.Node.isIdentifier(e)&&r(e.getText()),t}var $o=lt("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function kr(n,e,t,r){let i=Wn(n,e),o=qn(i.get(r)??[],t);if(o)return o;let s=[];for(let a of i.values())for(let c of a)((c.leaf||V(c.symbol)||"").includes(r)||c.symbol.includes(r))&&s.push(c);return qn(s,t)}function jn(n,e,t,r){return qn(Wn(n,e).get(r)??[],t)}function Pr(n,e){let t=new Map;for(let[r,i]of Wn(n,e)){let o=i[0];o&&t.set(r,o)}return t}function Wn(n,e){return $o.get(n,e,()=>{let t=new Map;for(let r of z(n,e)){let i=r.leaf||V(r.symbol);if(!i)continue;let o=t.get(i);o||(o=[],t.set(i,o)),o.push({...r,leaf:i})}for(let r of t.values())r.sort((i,o)=>i.startLine-o.startLine||i.endLine-o.endLine||i.symbolId-o.symbolId);return t})}function qn(n,e){let t=null,r=Number.POSITIVE_INFINITY;for(let i of n){let o=Math.abs(i.startLine-e);(o<r||o===r&&t&&i.startLine<t.startLine)&&(t=i,r=o)}return t}import Yo from"path";import{realpathSync as Jo}from"fs";function Er(n,e){let t=new Map,r=null,i=null,o=()=>(i??=Ee(n,{extensions:Ue}),i),s=()=>(r??=k("typescript.source-file-index",()=>Go(n.config.projectRoot,e,o()),()=>({projects:e.length,indexedDocuments:o().length})),r),a=c=>ne(c)?U(t,c,()=>{let u=Ar(n.config.projectRoot,c);if(!u)return null;for(let{project:f,sourceFiles:l}of s()){let d=l.get(u)??null;if(d||(d=f.addSourceFileAtPathIfExists(u)??null,d&&zn(l,d)),d)return{project:f,sourceFile:d}}return null}):null;return{sourceFile:c=>a(c)?.sourceFile??null,sourceFileMatch:a,indexedTypeScriptLikeDocuments:o}}function Go(n,e,t){let r=e.map(({project:i})=>{let o=new Map;for(let s of i.getSourceFiles())zn(o,s);return{project:i,sourceFiles:o}});for(let i of t){let o=Ar(n,i);if(o)for(let s of r){if(s.sourceFiles.has(o))break;let a=s.project.addSourceFileAtPathIfExists(o)??null;if(a){zn(s.sourceFiles,a);break}}}return r}function zn(n,e){let t=Kn(e.getFilePath());n.set(t,e);try{n.set(Kn(Jo(t)),e)}catch(r){if(!fe(r))throw r}}function Ar(n,e){try{return Kn(gt(n,e,{inputKind:"indexed TypeScript source file"}).absolutePath)}catch(t){if(!fe(t))throw t;return null}}function Kn(n){return Yo.resolve(n)}function Hn(n,e){for(let t of n)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function Fr(n){let e=`${n.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as Me}from"fs";import A from"path";var Vn=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function $n(n,e){let r=e?A.dirname(A.join(n,e)):n,i=A.resolve(n);for(;r.startsWith(i);){for(let s of Vn){let a=A.join(r,s);if(Me(a))return a}let o=A.dirname(r);if(o===r)break;r=o}for(let o of Vn){let s=A.join(n,o);if(Me(s))return s}return null}function Nr(n){let e=n.config.projectRoot,t=new Set(Qo(e,n.config.semantic?.typescript?.tsconfigs)),r=Ee(n,{includeIgnored:!1,extensions:Ue});for(let i of r){let o=$n(e,i);o&&t.add(A.resolve(o))}if(t.size===0){let i=$n(e);i&&t.add(A.resolve(i))}return[...t].filter(i=>!_r(e,i)).sort((i,o)=>i.localeCompare(o))}function Qo(n,e=[]){let t=new Set;for(let r of e){let i=A.isAbsolute(r)?r:A.join(n,r);Me(i)&&t.add(A.resolve(i))}for(let r of Xo(n))for(let i of Vn){let o=A.join(r,i);Me(o)&&t.add(A.resolve(o))}if(t.size===0){let r=$n(n);r&&t.add(A.resolve(r))}return[...t].filter(r=>!_r(n,r)).sort((r,i)=>r.localeCompare(i))}function Xo(n){let e=A.join(n,"package.json");if(!Me(e))return[];let t;try{t=JSON.parse(ct(e,"project package manifest"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>mt(n,i))}function _r(n,e){let t=A.relative(n,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}function Yn(n,e){try{return n()}catch{e?.();return}}var Zo=32;function jr(n,e){let t=k("typescript.provider.load",()=>Et());if(!t)return Be("ts-morph is not installed");let r=k("typescript.provider.tsconfig-discovery",()=>Nr(n));if(r.length===0)return Be("no tsconfig found");try{let i=k("typescript.provider.project-bundles",()=>At(t,r),()=>({tsconfigs:r.length}));return es(n,t,i)}catch(i){return Be(i instanceof Error?i.message:String(i),r[0],r)}}function es(n,e,t,r={}){return k("typescript.provider.construct",()=>new Jn(n,e,t),()=>({tsconfigs:t.length,reusedProjects:r.reusedProjects===!0}))}var Jn=class{constructor(e,t,r){this.db=e;this.tsMorph=t;this.projects=r;this.workspacePackages=pt(e.config.projectRoot),this.sourceFiles=Er(e,r)}db;tsMorph;projects;language="typescript";importUsageCache=new Map;referencesCache=new Map;calleesCache=new Map;fileCalleesCache=new Map;signatureCache=new Map;definitionNodeCache=new Map;fileDefinitionNodeCache=new Map;indexedDefinitionLeafCache=new Map;compilerCheckerCache=new WeakMap;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(e=>e.tsconfigPath)}}importUsage(e){return U(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let r=ts();return k("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,t,r),()=>({file:e,...r}))})}referencesFor(e){return U(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,t)})}referencesForDefinitions(e,t={}){let r=new Map,i=_(),o=[];for(let f of e){let l=this.referencesCache.get(f.symbolId);l?r.set(f.symbolId,l):o.push(f)}if(o.length===0)return r;let s=o,a=t.exact?[]:o.filter(f=>!Or(f));if(a.length>=Zo){let f=this.referencesForDefinitionsBySymbolScan(a);if(f.incompleteFiles.size===0)for(let l of a){let d=f.references.get(l.symbolId)??[];this.referencesCache.set(l.symbolId,d),r.set(l.symbolId,d)}if(s=o.filter(l=>Or(l)),s.length===0)return r}let c=new Map;for(let f of s){let l=c.get(f.relativePath);l?l.push(f):c.set(f.relativePath,[f])}let u=[];for(let[f,l]of c){let d=Ur();k("typescript.references-map.file",()=>{let p=this.definitionNodesForFile(f);for(let m of l){i&&(d.cacheMisses+=1);let R=p.get(m.symbolId)??null;i&&(R?d.nodeHits+=1:d.nodeMisses+=1);try{let I=this.referencesForDefinitionNode(m,R,i?d:void 0);this.referencesCache.set(m.symbolId,I),r.set(m.symbolId,I)}catch{d.preciseSearchFailures+=1,u.push(m)}}},()=>({relativePath:f,definitions:l.length,...Br(d)}))}if(u.length>0){let f=this.referencesForDefinitionsBySymbolScan(u);if(f.incompleteFiles.size===0)for(let l of u){let d=f.references.get(l.symbolId)??[];this.referencesCache.set(l.symbolId,d),r.set(l.symbolId,d)}}return r}referenceFragmentsForFiles(e){let t=_e(this.db).filter(s=>ne(s.relativePath)),r=e.filter(s=>this.sourceFiles.sourceFile(s)!==null),i=this.referencesForDefinitionsBySymbolScan(t,r),o=r.filter(s=>!i.incompleteFiles.has(s));return Ft(t,i.references,o)}referencesForDefinitionsBySymbolScan(e,t){let r=_(),i=Ur(),o=new Map,s=new Set,a=new Set(e.map(u=>u.symbolId)),c=new Map(e.map(u=>[u.symbolId,u]));for(let u of e)o.set(u.symbolId,[]);return k("typescript.references-map.inverted-scan",()=>{let u=r?x.now():0,f=t?this.packageImportReferencesForFiles(t):this.packageImportReferences();for(let S of e){let h=f.get(S.symbolId)??[];if(h.length>0){let P=o.get(S.symbolId)??[];P.push(...h),o.set(S.symbolId,P)}r&&(i.packageReferenceCount+=h.length)}r&&(i.packageRefsMs+=x.now()-u);let l=new Map,d=new Map,p=this.hierarchyTargetsForDefinitions(e),m=new Set(e.map(S=>S.leaf).filter(Boolean)),R=r?x.now():0;for(let S of t??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(S))continue;let h=this.sourceFiles.sourceFile(S);if(!h)continue;r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(h,S,a,c,p,m,l,d,o,r?i:void 0)||s.add(S)}r&&(i.scanMs+=x.now()-R);let I=r?x.now():0;this.addHierarchyMemberReferences(e,o,r?i:void 0),r&&(i.hierarchyMs+=x.now()-I);for(let[S,h]of o){let P=se(h);o.set(S,P),r&&(i.referenceCount+=P.length)}},()=>({definitions:e.length,...Br(i)})),{references:o,incompleteFiles:s}}addReferencesFromSourceFileScan(e,t,r,i,o,s,a,c,u,f){let l=this.compilerCheckerForSourceFile(e),d=e.compilerNode,p=os(e),m=!0,R=I=>{if(this.tsMorph.ts.isIdentifier(I)){if(f&&(f.identifiers+=1),!s.has(I.text)&&!p.has(I.text)){this.tsMorph.ts.forEachChild(I,R);return}let S=this.compilerReferenceSymbol(l,I,f,()=>{m=!1});if(S){let h;a.has(S)?h=a.get(S)??null:(h=this.referenceDefinitionFromCompilerSymbol(S),a.set(S,h)),f&&(h?f.targetHits+=1:f.targetMisses+=1);let P=U(c,S,()=>this.compilerSymbolKeys(S)),M=null,v=null,C=h&&r.has(h.symbolId)?i.get(h.symbolId):void 0;if(C&&(M=en(d,I),!Lr(C,t,M))){let D=d.getLineAndCharacterOfPosition(I.getStart(d));v={file:t,line:D.line,column:D.character};let b=u.get(C.symbolId)??[];b.push(v),u.set(C.symbolId,b),f&&(f.requestedHits+=1)}for(let D of P)for(let b of o.get(D)?.values()??[]){if(M??=en(d,I),Lr(b,t,M))continue;if(!v){let g=d.getLineAndCharacterOfPosition(I.getStart(d));v={file:t,line:g.line,column:g.character}}let y=u.get(b.symbolId)??[];y.push(v),u.set(b.symbolId,y),f&&(f.requestedHits+=1)}}}this.tsMorph.ts.forEachChild(I,R)};return R(d),m}hierarchyTargetsForDefinitions(e){let t=new Map;for(let r of e){let i=this.nodeForDefinition(r),o=i?.compilerNode;if(!o||!this.isHierarchyMethod(o))continue;let s=o.parent;if(!this.isHierarchyContainer(s))continue;let a=this.compilerCheckerForSourceFile(i.getSourceFile()),c=a.getSymbolAtLocation(o.name);if(c)for(let u of this.hierarchyMemberSymbols(a,s,c))for(let f of this.compilerSymbolKeys(u)){let l=t.get(f)??new Map;l.set(r.symbolId,r),t.set(f,l)}}return t}hierarchyMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(!o.has(a)){o.add(a),i.add(c);for(let f of u){let l=f.getProperty(r.name);l&&s(f,l,this.hierarchyAncestorTypesForType(e,f))}}};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}addHierarchyMemberReferences(e,t,r){let i=new Map;for(let o of e){let s=this.nodeForDefinition(o),a=s?.compilerNode;if(!a||!this.isHierarchyMethod(a))continue;let c=a.parent;if(!this.isHierarchyContainer(c))continue;let u=this.compilerCheckerForSourceFile(s.getSourceFile()),f=u.getSymbolAtLocation(a.name);if(!f)continue;let l=a.getSourceFile(),d=l.getLineAndCharacterOfPosition(a.name.getStart(l)),p={definition:o,location:{file:o.relativePath,line:d.line,column:d.character}},m=t.get(o.symbolId)??[];for(let I of this.hierarchyMemberSymbols(u,c,f))if(I!==f)for(let S of this.compilerSymbolLocations(I))m.push(S),r&&(r.hierarchyReferences+=1);t.set(o.symbolId,m);let R=this.hierarchyRootMemberSymbols(u,c,f);for(let I of R){let S=i.get(I)??new Map;S.set(o.symbolId,p),i.set(I,S)}r&&(r.hierarchyDefinitions+=1)}for(let o of i.values())if(!(o.size<2)){r&&(r.hierarchyFamilies+=1);for(let{definition:s}of o.values()){let a=t.get(s.symbolId)??[];for(let c of o.values())c.definition.symbolId!==s.symbolId&&(a.push(c.location),r&&(r.hierarchyReferences+=1));t.set(s.symbolId,a)}}}hierarchyRootMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(o.has(a))return;o.add(a);let f=!1;for(let l of u){let d=l.getProperty(r.name);d&&(f=!0,s(l,d,this.hierarchyAncestorTypesForType(e,l)))}if(!f)for(let l of this.compilerSymbolKeys(c))i.add(l)};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}compilerSymbolKeys(e){return(e.declarations??[]).map(t=>{let r=t.getSourceFile();return`${r.fileName}\0${t.getStart(r)}\0${e.name}`})}compilerSymbolLocations(e){let t=[];for(let r of e.declarations??[]){let i=r.getSourceFile(),o=ae(this.db.config.projectRoot,i.fileName);if(!o)continue;let s=r.name,a=i.getLineAndCharacterOfPosition((s??r).getStart(i));t.push({file:o,line:a.line,column:a.character})}return t}baseTypes(e,t){try{return e.getBaseTypes(t)??[]}catch{return[]}}hierarchyAncestorTypes(e,t){let r=new Set(this.hierarchyAncestorTypesForType(e,e.getTypeAtLocation(t)));for(let i of t.heritageClauses??[])for(let o of i.types)r.add(e.getTypeAtLocation(o));return[...r]}hierarchyAncestorTypesForType(e,t){let r=new Set(this.baseTypes(e,t));for(let i of t.getSymbol()?.declarations??[])if(this.isHierarchyContainer(i))for(let o of i.heritageClauses??[])for(let s of o.types)r.add(e.getTypeAtLocation(s));return[...r]}isHierarchyMethod(e){return this.tsMorph.ts.isMethodDeclaration(e)||this.tsMorph.ts.isMethodSignature(e)}isHierarchyContainer(e){return this.tsMorph.ts.isClassDeclaration(e)||this.tsMorph.ts.isClassExpression(e)||this.tsMorph.ts.isInterfaceDeclaration(e)}compilerReferenceSymbol(e,t,r,i){r&&(r.symbolLookups+=1);let o=Yn(()=>e.getSymbolAtLocation(t),i);if(o){if((o.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return o;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(o)}catch{return i?.(),o}}}calleesFor(e){if(this.calleesCache.has(e.symbolId))return this.calleesCache.get(e.symbolId)??[];let t=U(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath));if(t.incompleteSymbolIds.has(e.symbolId))throw new Error(`TypeScript callee evidence is incomplete for ${e.symbol}.`);let r=t.callees.get(e.symbolId)??[];return this.calleesCache.set(e.symbolId,r),r}calleesForDefinitions(e){let t=new Map,r=new Map;for(let i of e){if(this.calleesCache.has(i.symbolId)){t.set(i.symbolId,this.calleesCache.get(i.symbolId)??[]);continue}let o=r.get(i.relativePath);o?o.push(i):r.set(i.relativePath,[i])}for(let[i,o]of r){let s=this.fileCalleesCache.get(i),a=new Set(o.map(u=>u.symbolId)),c=s??this.calleeMapForFile(i,a);for(let u of o){if(c.incompleteSymbolIds.has(u.symbolId))continue;let f=c.callees.get(u.symbolId)??[];this.calleesCache.set(u.symbolId,f),t.set(u.symbolId,f)}}return t}referencesForDefinitionNode(e,t,r){let i=r?x.now():0,o=this.packageImportReferencesForDefinition(e);if(r&&(r.packageRefsMs+=x.now()-i,r.packageReferenceCount+=o.length),!t)return o;let s=r?x.now():0,a=Cr(t,e,o,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=x.now()-s,r.referenceCount+=a.length),a}signatureFor(e){return U(this.signatureCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);if(!t||!this.tsMorph.Node.isFunctionDeclaration(t)&&!this.tsMorph.Node.isMethodDeclaration(t)&&!this.tsMorph.Node.isArrowFunction(t)&&!this.tsMorph.Node.isFunctionExpression(t)&&!this.tsMorph.Node.isConstructorDeclaration(t))return null;let r=t.getType().getCallSignatures()[0];if(!r)return null;let i=r.getParameters().map(s=>{let a=s.getDeclarations()[0],c=a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown";return qr(c)}),o=r.getReturnType().getText(t);return`(${i.join(",")})=>${qr(o)}`})}importUsageForSourceFile(e,t,r){let i=[],o=new Map;for(let s of t.getImportDeclarations()){r.declarations+=1;let a=ln(this.db,e,s.getModuleSpecifierValue()),c=s.getImportClause()?.isTypeOnly()??!1;for(let u of Gn(s)){r.entries+=1;let f=c?null:u.identifier?.getSymbol()?.compilerSymbol??null;!c&&u.identifier&&(f?r.bindingSymbols+=1:r.missingBindingSymbols+=1);let l={sourcePath:a,entry:u,typeOnlyDeclaration:c,bindingSymbol:f,references:[]};if(i.push(l),c||!u.localName||!f)continue;let d=o.get(u.localName);d?d.push(l):o.set(u.localName,[l])}}return o.size>0&&t.forEachDescendant(s=>{if(s.getKindName()!=="Identifier")return;let a=o.get(s.getText());if(!a||rs(s))return;r.scannedIdentifiers+=1;let c=s.getSymbol()?.compilerSymbol;if(r.symbolLookups+=1,!!c){for(let u of a)if(u.bindingSymbol===c){u.references.push({location:Ze(s,this.db.config.projectRoot),node:s}),r.matchedReferences+=1;break}}}),i.map(s=>s.typeOnlyDeclaration?ns(e,s.sourcePath,s.entry):s.entry.identifier&&!s.bindingSymbol?(r.fallbackEntries+=1,this.valueImportUsageForEntry(e,s.sourcePath,s.entry)):this.valueImportUsageFromLocations(e,s.sourcePath,s.entry,s.references))}valueImportUsageForEntry(e,t,r){let i;try{i=r.identifier?r.identifier.findReferences():[]}catch{let s=r.identifier?On(r.identifier,e,this.db.config.projectRoot):[];return{importer:e,sourcePath:t,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:r.isTypeOnly,isUsed:r.isTypeOnly||s.length>0,isTypeUsed:r.isTypeOnly,isValueUsed:!r.isTypeOnly&&s.length>0,references:s}}let o=[];for(let s of i)for(let a of Tr(s,e,r.identifier,this.db.config.projectRoot))o.push(a);return this.valueImportUsageFromLocations(e,t,r,o)}valueImportUsageFromLocations(e,t,r,i){let o=i.some(c=>!Un(c.node)),s=i.some(c=>Un(c.node)),a=r.isTypeOnly;return{importer:e,sourcePath:t,importedName:r.importedName,localName:r.localName,kind:r.kind,isTypeOnly:a,isUsed:a||i.length>0,isTypeUsed:a||s,isValueUsed:o,references:i.map(c=>c.location)}}packageImportReferencesForDefinition(e){return this.packageImportReferences().get(e.symbolId)??[]}packageImportReferencesForFiles(e){let t=new Map,r=new Set;for(let o of e){let s=this.sourceFiles.sourceFile(o);if(s)for(let a of s.getImportDeclarations()){let c=Hn(this.workspacePackages,a.getModuleSpecifierValue());c&&r.add(c)}}if(r.size===0)return t;let i=this.packageExportsForNames(r);for(let o of e)this.addPackageImportReferencesForDocument(t,i,o);for(let[o,s]of t)t.set(o,se(s));return t}packageImportReferences(){if(this.packageImportReferenceIndex)return this.packageImportReferenceIndex;let e=new Map,t=this.packageExports();for(let r of this.sourceFiles.indexedTypeScriptLikeDocuments())this.addPackageImportReferencesForDocument(e,t,r);for(let[r,i]of e)e.set(r,se(i));return this.packageImportReferenceIndex=e,e}addPackageImportReferencesForDocument(e,t,r){if(this.db.isIgnored(r))return;let i=this.sourceFiles.sourceFileMatch(r);if(i)for(let o of i.sourceFile.getImportDeclarations())this.addPackageImportReferencesForDeclaration(e,t,r,o)}addPackageImportReferencesForDeclaration(e,t,r,i){let o=Hn(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of Gn(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let u=On(a.identifier,r,this.db.config.projectRoot);u.length>0&&ls(e,c,u)}}packageExports(){return this.packageExportIndex?this.packageExportIndex:(this.packageExportIndex=this.packageExportsForNames(new Set(this.workspacePackages.map(e=>e.name))),this.packageExportIndex)}packageExportsForNames(e){let t=new Map;for(let r of this.workspacePackages){if(!e.has(r.name))continue;let i=new Map;for(let o of Fr(r))this.collectPackageExports(r,o,i,new Set);i.size>0&&t.set(r.name,i)}return t}collectPackageExports(e,t,r,i){if(i.has(t))return;i.add(t);let o=this.sourceFiles.sourceFile(t);if(o)for(let s of o.getExportDeclarations()){let a=s.getModuleSpecifierValue(),c=a?ln(this.db,t,a):t;if(!c||!c.startsWith(`${e.relativeDir}/src/`))continue;let u=s.getNamedExports();if(u.length===0){if(s.isNamespaceExport())continue;this.collectPackageExports(e,c,r,i);continue}for(let f of u){let l=f.getNameNode().getText(),d=f.getAliasNode()?.getText()??l,p=this.indexedDefinitionByLeaf(c,l);if(!p)continue;let m=r.get(d);m||(m=new Set,r.set(d,m)),m.add(p.symbolId)}}}indexedDefinitionByLeaf(e,t){return U(this.indexedDefinitionLeafCache,e,()=>Pr(this.db,e)).get(t)??null}nodeForDefinition(e){return U(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return U(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?wr(this.tsMorph,this.db,t,e):new Map})}referenceDefinitionFromCompilerSymbol(e){return this.definitionFromCompilerSymbol(e,void 0,!0)}definitionFromCompilerSymbol(e,t,r=!1){let i=e.name,o=t?x.now():0,s=e.declarations??[];t&&(t.declarationsMs+=x.now()-o,t.declarationChecks+=s.length);for(let a of s){let c=t?x.now():0,u=a.getSourceFile(),f=ae(this.db.config.projectRoot,u.fileName),l=u.getLineAndCharacterOfPosition(a.getStart(u)).line;if(t&&(t.declarationLocationMs+=x.now()-c),!f||this.db.isIgnored(f))continue;let d=t?x.now():0,p=this.compilerDeclarationName(a),m=r?jn(this.db,f,l,i)??(p&&p!==i?jn(this.db,f,l,p):null):kr(this.db,f,l,i);if(t&&(t.indexedLookupMs+=x.now()-d),m)return{symbolId:m.symbolId,symbol:m.symbol,file:m.relativePath,line:m.startLine}}return null}compilerDeclarationName(e){let t=e.name;return t&&this.tsMorph.ts.isIdentifier(t)?t.text:null}calleeMapForFile(e,t){let r=_(),i=0,o=0,s=0,a=0,c=0,u=0,f=0,l=0,d=r?as():void 0;return k("typescript.callee-map.file",()=>{let p=r?x.now():0,m=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(x.now()-p)),!m)return{callees:new Map,incompleteSymbolIds:new Set};let R=r?x.now():0,I=z(this.db,e).sort((y,g)=>y.startLine-g.startLine||g.endLine-y.endLine);if(r&&(u=Math.round(x.now()-R)),i=I.length,I.length===0)return{callees:new Map,incompleteSymbolIds:new Set};let S=new Map,h=new Set,P=r?x.now():0,M=this.compilerCheckerForSourceFile(m),v=m.compilerNode;r&&(f=Math.round(x.now()-P));let C=new Map,D=y=>{if(this.tsMorph.ts.isCallExpression(y)||this.tsMorph.ts.isNewExpression(y)){r&&(o+=1);let g=this.semanticCalleeForCallNode(M,v,I,y,C,t,h,d);g&&(r&&(s+=1),is(S,g.callerId,g.target))}this.tsMorph.ts.forEachChild(y,D)},b=r?x.now():0;D(v),r&&(l=Math.round(x.now()-b));for(let[y,g]of S)S.set(y,us(g));return a=S.size,{callees:S,incompleteSymbolIds:h}},()=>({relativePath:e,definitions:i,callNodes:o,resolvedCallees:s,outputRows:a,requestedDefinitions:t?.size??i,sourceFileLookupMs:c,definitionsLoadMs:u,checkerLookupMs:f,traversalMs:l,...d?cs(d):{}}))}semanticCalleeForCallNode(e,t,r,i,o,s,a,c){let u=c?x.now():0,f=ss(r,en(t,i));if(c&&(c.callerLookupMs+=x.now()-u),!f)return null;if(s&&!s.has(f.symbolId))return c&&(c.skippedUnrequestedCallers+=1),null;let l=i.expression,d=this.compilerSymbolForExpression(e,l,c);d.incomplete&&a?.add(f.symbolId);let p=d.symbol,m=null;if(p)if(c&&(c.targetSymbolHits+=1),o.has(p))c&&(c.compilerSymbolCacheHits+=1),m=o.get(p)??null;else{c&&(c.compilerSymbolCacheMisses+=1);let R=c?x.now():0;m=this.definitionFromCompilerSymbol(p,c),c&&(c.targetLookupMs+=x.now()-R),o.set(p,m)}else c&&(c.targetMisses+=1);return m?{callerId:f.symbolId,target:{symbol:m.symbol,file:m.file,line:m.line,callsiteLine:en(t,i)}}:null}compilerSymbolForExpression(e,t,r){let i=!1,o=r?x.now():0,s=Yn(()=>e.getSymbolAtLocation(t),()=>{i=!0});if(r&&(r.expressionSymbolMs+=x.now()-o),s)return{symbol:s,incomplete:!1};r&&(r.typeFallbacks+=1);let a=!1,c=r?x.now():0,u=Yn(()=>e.getTypeAtLocation(t).getSymbol(),()=>{a=!0});return r&&(r.typeSymbolMs+=x.now()-c),{symbol:u,incomplete:!u&&(i||a)}}compilerCheckerForSourceFile(e){let t=e.getProject(),r=this.compilerCheckerCache.get(t);return r||(r=t.getTypeChecker().compilerObject,this.compilerCheckerCache.set(t,r)),r}};function Gn(n){let e=[],t=n.getDefaultImport();t&&e.push({identifier:t,importedName:"default",localName:t.getText(),kind:"default",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});let r=n.getNamespaceImport();r&&e.push({identifier:r,importedName:"*",localName:r.getText(),kind:"namespace",isTypeOnly:n.getImportClause()?.isTypeOnly()??!1});for(let i of n.getNamedImports()){let o=i.getNameNode(),a=i.getAliasNode()??(o.getKindName()==="Identifier"?o:null);e.push({identifier:a,importedName:o.getText(),localName:a?.getText()??o.getText(),kind:"named",isTypeOnly:i.isTypeOnly()||(n.getImportClause()?.isTypeOnly()??!1)})}return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function ns(n,e,t){return{importer:n,sourcePath:e,importedName:t.importedName,localName:t.localName,kind:t.kind,isTypeOnly:!0,isUsed:!0,isTypeUsed:!0,isValueUsed:!1,references:[]}}function ts(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function rs(n){for(let e=n;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function is(n,e,t){let r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}function os(n){let e=new Set;for(let t of n.getImportDeclarations())for(let r of Gn(t))r.localName&&e.add(r.localName);return e}function ss(n,e){let t=null;for(let r of n)e<r.startLine||e>r.endLine||(!t||r.startLine>=t.startLine)&&(t=r);return t}function en(n,e){return n.getLineAndCharacterOfPosition(e.getStart(n)).line}function Lr(n,e,t){return e===n.relativePath&&t>=n.startLine&&t<=n.endLine}function Or(n){return n.symbol.includes("#")?Ne(n.symbol)==="type"&&n.relativePath.endsWith(".d.ts"):!1}function as(){return{callerLookupMs:0,expressionSymbolMs:0,typeSymbolMs:0,targetLookupMs:0,declarationsMs:0,declarationLocationMs:0,indexedLookupMs:0,compilerSymbolCacheHits:0,compilerSymbolCacheMisses:0,targetSymbolHits:0,targetMisses:0,typeFallbacks:0,declarationChecks:0,skippedUnrequestedCallers:0}}function cs(n){return{...n,callerLookupMs:Math.round(n.callerLookupMs),expressionSymbolMs:Math.round(n.expressionSymbolMs),typeSymbolMs:Math.round(n.typeSymbolMs),targetLookupMs:Math.round(n.targetLookupMs),declarationsMs:Math.round(n.declarationsMs),declarationLocationMs:Math.round(n.declarationLocationMs),indexedLookupMs:Math.round(n.indexedLookupMs)}}function Ur(){return{cacheHits:0,cacheMisses:0,nodeHits:0,nodeMisses:0,scanFiles:0,identifiers:0,symbolLookups:0,aliasResolutions:0,targetHits:0,targetMisses:0,requestedHits:0,scanMs:0,packageRefsMs:0,semanticRefsMs:0,packageReferenceCount:0,referenceCount:0,preciseSearchFailures:0,hierarchyDefinitions:0,hierarchyFamilies:0,hierarchyReferences:0,hierarchyMs:0}}function Br(n){return{...n,scanMs:Math.round(n.scanMs),packageRefsMs:Math.round(n.packageRefsMs),semanticRefsMs:Math.round(n.semanticRefsMs),hierarchyMs:Math.round(n.hierarchyMs)}}function ls(n,e,t){for(let r of e){let i=n.get(r)??[];i.push(...t),n.set(r,i)}}function us(n){let e=new Set,t=[];for(let r of n){let i=`${r.symbol}|${r.file}|${r.line}|${r.callsiteLine??""}`;e.has(i)||(e.add(i),t.push(r))}return t}function qr(n){return n.replace(/\s+/g," ").replace(/\bimport\("[^"]+"\)\./g,"").trim()}import{join as fs}from"path";var nn=4;var ds="typescript-semantic";function Wr(n){let e=fs(n,ds),t=Le(e);return{...t,requestDir:t.legacyRequestDir}}var Ss=12e4,gs=5;function Vr(n,e,t={}){let r=new Qn(n,t),i=null,o=null,s=process.env.CODEBASEIQ_SKIP_WATCH_SERVICE==="1",a=()=>(i??=jr(n,e),i),c=(l,d,p)=>{if(s)return p();try{return d(r.request(l))}catch{return s=!0,p()}},u=(l,d)=>c({kind:"references",definitions:[...l],...d?.exact?{exact:!0}:{}},p=>Hr(p),()=>a().referencesForDefinitions?.(l,d)??new Map(l.map(p=>[p.symbolId,a().referencesFor(p)]))),f=l=>c({kind:"callees",definitions:[...l]},d=>Hr(d),()=>a().calleesForDefinitions?.(l)??new Map(l.map(d=>[d.symbolId,a().calleesFor(d)])));return{language:"typescript",availability:()=>(o??=c({kind:"availability"},hs,()=>a().availability()),o),importUsage:l=>c({kind:"import-usage",file:l},d=>d,()=>a().importUsage(l)),referencesFor:l=>zr(u([l]),l,"reference"),referencesForDefinitions:u,referenceFragmentsForFiles:l=>c({kind:"reference-fragments",files:[...l]},d=>Rs(d),()=>a().referenceFragmentsForFiles?.(l)??new Map),calleesFor:l=>zr(f([l]),l,"callee"),calleesForDefinitions:f,signatureFor:l=>c({kind:"signature",definition:l},Is,()=>a().signatureFor(l)),dispose:()=>i?.dispose?.()}}function zr(n,e,t){if(!n.has(e.symbolId))throw new Error(`TypeScript ${t} evidence is incomplete for ${e.symbol}.`);return n.get(e.symbolId)}var Qn=class{constructor(e,t={}){this.db=e;this.runtime=t.runtime??vs,this.timeoutMs=t.timeoutMs??Ms(),this.mailboxLimits=t.mailboxLimits??{},this.cacheDir=ys(e.config.dbPath),this.projectRoot=St(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;mailboxLimits;request(e){let t=Pt(this.cacheDir),r=Wr(this.cacheDir),i=dn(t.statePath);if(!Kr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript semantic service is not running.");let o=this.db.generation.identity;if(!o)throw new Error("Published TypeScript generation identity is unavailable.");let s=this.runtime.now(),a=s+this.timeoutMs,c=(this.runtime.monotonicNow??q)()+this.timeoutMs,u=yt(),f=Z("typescript-semantic-v4",{generation:o,profileEnvironment:u,request:e}),l=ee(f),d=Oe(r,{mailboxVersion:$,operationKey:f,clientId:this.runtime.randomId(),enqueuedAtMs:s,deadlineAtMs:a,protocolVersion:nn,id:l,generation:o,profileEnvironment:u,request:e},{nowMs:s,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??q)()<=c;){if(ms(d.responsePath))return bs(B(d.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript semantic mailbox response"}),l,o,f);let p=dn(t.statePath);if(!Kr(p,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(gs)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}};function Kr(n,e,t){let r=n?.processIdentity?t.readProcessIdentity?.(n.pid):null;return n!==null&&n.projectRoot===e&&n.typescriptSemantic?.protocolVersion===nn&&t.isProcessAlive(n.pid)&&(!n.processIdentity||r!=null&&xe(n.processIdentity,r))}function bs(n,e,t,r){let i=JSON.parse(n);if(i.protocolVersion!==nn||i.id!==e||i.operationKey!==r||i.ok===!0&&i.generation!==t)throw new Error("TypeScript semantic service wrote an incompatible response.");if(i.ok===!0)return i.response;throw new Error(typeof i.error=="string"?i.error:"TypeScript semantic service request failed.")}function Hr(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(n)}function Rs(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(n)}function hs(n){let e=Mr(n);if(!e)throw new Error("TypeScript semantic service wrote invalid availability.");return e}function Is(n){if(n!==null&&typeof n!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return n}function Ms(){let n=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(n)&&n>0?n:Ss}var vs={now:Date.now,monotonicNow:q,randomId:ps,sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)},isProcessAlive:ke,readProcessIdentity:we};var Xn=new Xe;ot({name:"semantic-provider",groups:["semantic-provider"],clearAll:n=>Xn.clear(n)});st({name:"semantic-provider",close:n=>Xn.clear(n)});function Q(n,e){let t=L(e)??"typescript";return Xn.getOrCreate(n,t,()=>t==="rust"?br(n.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>_t(n,r)},calleeSymbolResolver:Nt(n),sourceZeroCalleeOracle:r=>Ds(n,r),scipOccurrenceCalleeOracle:r=>Ir(n,r)}):Vr(n,e))}function L(n){return n?ht(n)==="rust"?"rust":ne(n)?"typescript":null:"typescript"}function Ds(n,e){let t=Fe(n,e.relativePath);if(!t||t.language!=="rust")return!1;let r=t.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine&&i.name===e.leaf)??t.callables.find(i=>i.startLine===e.startLine&&i.endLine===e.endLine);return r?!t.callSites.some(i=>i.line>=r.startLine&&i.line<=r.endLine):!1}var xs=/^[A-Za-z_][A-Za-z0-9_]*$/,$r=/\bDefault::default\b/g,Cs=/^\.\.\s*Default::default\b/;function Yr(n,e){let t=new Map,r=new Map;for(let i of e){let o=Zn(n,i,r);o!==null&&t.set(i.symbolId,o)}return t}function Zn(n,e,t=new Map){let r=ws(e.symbol);if(!r)return null;let i=Ct(n,[e.symbolId]);if(i.length===0)return null;let o=new RegExp(`(^|[^A-Za-z0-9_])${de(r)}::default\\b`,"g"),s=new RegExp(`(^|[^A-Za-z0-9_])${de(r)}\\s*$`),a=Ts(n,e.symbolId),c=[];for(let u of i){let f=ks(n,u.relative_path,t);if(f===null)return null;let l=f.split(/\r?\n/),d=0,p=[],m=0;for(let R=u.chunk_start;R<=u.chunk_end&&R<l.length;R+=1){let S=l[R]??"",h=new Set;o.lastIndex=0;let P;for(;P=o.exec(S);)c.push({file:u.relative_path,line:R,column:P.index+P[1].length+r.length+2}),m+=1;for(let M=0;M<S.length;M+=1){let v=Cs.exec(S.slice(M));if(v){if(a&&p.includes(d)){let D=M+v[0].lastIndexOf("default");c.push({file:u.relative_path,line:R,column:D}),h.add(D),m+=1}M+=v[0].length-1;continue}let C=S[M];if(C==="{"){let D=s.test(S.slice(0,M));d+=1,D&&p.push(d);continue}if(C==="}")for(d=Math.max(0,d-1);p.length>0&&p[p.length-1]>d;)p.pop()}for($r.lastIndex=0;P=$r.exec(S);){let M=P.index+9;if(!h.has(M))return null}}if(m===0)return null}return We(c)}function Ts(n,e){return n.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function ws(n){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(n)?.[1]??null;return!e||!xs.test(e)?null:e}function ks(n,e,t){if(t.has(e))return t.get(e)??null;let r=n.get("SELECT text FROM documents WHERE relative_path = ?",e),i=typeof r?.text=="string"?r.text:Ps(n,e);return t.set(e,i),i}function Ps(n,e){try{return bt(n.config.projectRoot,e,{inputKind:"indexed Rust source file"})}catch(t){if(!fe(t))throw t;return null}}function Jr(n){let e=new Map;for(let t of n){let r=e.get(t.relativePath)??[];r.push(t),e.set(t.relativePath,r)}return e}var tn=new WeakMap;function Du(n){tn.delete(n)}function xu(n){let e=tn.get(n);return{incompleteSymbolIds:new Set(e?.incompleteSymbolIds),unavailableSymbolIds:new Set(e?.unavailableSymbolIds)}}function tt(n,e){if(e.incompleteSymbolIds.size===0&&e.unavailableSymbolIds.size===0)return;let t=tn.get(n)??{incompleteSymbolIds:new Set,unavailableSymbolIds:new Set};for(let r of e.incompleteSymbolIds)t.incompleteSymbolIds.add(r);for(let r of e.unavailableSymbolIds)t.unavailableSymbolIds.add(r);tn.set(n,t)}var Es="typescript-import-usage-v1",As="typescript-signatures-v1",et=ut("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),Gr=fn({kind:"semantic-import-usage",invalidation:ue("semantic-import-usage"),serialize:n=>JSON.stringify(n),deserialize:ai}),Qr=fn({kind:"semantic-signatures",invalidation:ue("semantic-signatures"),serialize:n=>JSON.stringify(n),deserialize:js}),Xr=un({kind:"typescript-import-usage",invalidation:ue("typescript-import-usage"),serialize:n=>JSON.stringify(n),deserialize:ai}),Zr=un({kind:"typescript-signatures",invalidation:ue("typescript-signatures"),serialize:n=>JSON.stringify(n),deserialize:Ws});function rt(n){let e=new Map,t=new Set;return{capability:(r,i)=>ci(n,r,i),importUsage:r=>Ns(n,r),references:r=>ni(n,r),materializeReferences:(r,i)=>ti(n,r,e,t,i),callerMap:r=>Ls(n,r,e,t),calleeMap:r=>oi(n,r),signature:r=>Bs(n,r)}}function Fs(n,e){if(e.size===0)return;let t=et.get(n,()=>new Map);for(let[r,i]of e)t.set(r,[...i])}function Cu(n,e){if(!et.has(n))return{hits:[],misses:[...e]};let t=et.get(n,()=>new Map),r=[],i=[];for(let o of e)t.has(o.symbolId)?r.push({definition:o,callees:t.get(o.symbolId)??[]}):i.push(o);return{hits:r,misses:i}}function Tu(n,e){return rt(n).importUsage(e)}function Ns(n,e){if(L(e)==="typescript"){let o="fallback",s=0,a=0,c=0,u=0;return k("typescript.import-usage.materialize",()=>{let f=pn(n,e,Es);if(f?.key){s=1;let d=Xr.read(n,e,f.key);if(d)return o="hit",a=1,d;c=1;let p=W(n,e);if(!p)return o="unavailable",[];let m=p.importUsage(e);return Xr.write(n,e,f.key,m),o="computed",m}u=1;let l=W(n,e);return l?(o="direct-fallback",l.importUsage(e)):(o="unavailable",[])},()=>({state:o,eligible:s,cacheHits:a,cacheMisses:c,fallbacks:u}))}let t=si(n,"semantic-import-usage",e);if(t){let o=Gr.read(n,e,t);if(o)return o}let r=W(n,e);if(!r)return[];let i=r.importUsage(e);return t&&Gr.write(n,e,t,i),i}function wu(n,e){return rt(n).references(e)}function ni(n,e){let t=Zn(n,e);if(t)return t;let r=Ut(n,e);if(r)return r;let i=W(n,e.relativePath);return i?i.referencesFor(e):[]}function ku(n,e){let t=_s(n,e),r=t.incompleteSymbolIds.size+t.unavailableSymbolIds.size;if(r>0)throw new Error(`Exact semantic caller evidence is incomplete for ${r} definition(s).`);return t.callers}function _s(n,e,t=r=>Q(n,r)){let r=new Map,i=new Set,o=new Set,s=new Map;for(let c of e){let u=L(c.relativePath);if(!u)continue;let f;try{f=t(c.relativePath)}catch{o.add(c.symbolId);continue}if(!f.availability().available){o.add(c.symbolId);continue}if(u==="typescript"){let l=s.get(f)??[];l.push(c),s.set(f,l);continue}nt(n,r,c,ni(n,c))}for(let[c,u]of s){let f=yn(n,u,t),l=f?.references??(c.referencesForDefinitions?c.referencesForDefinitions(u,{exact:!0}):new Map(u.map(d=>[d.symbolId,c.referencesFor(d)])));!f&&_()&&mn(n,u,l,t);for(let d of u){if(!l.has(d.symbolId)){i.add(d.symbolId);continue}nt(n,r,d,l.get(d.symbolId)??[])}}let a={callers:r,incompleteSymbolIds:i,unavailableSymbolIds:o};return tt(n,a),a}function Ls(n,e,t=new Map,r=new Set){let i=new Map,o=ti(n,e,t,r),s=0;return k("semantic.callers.from-references",()=>{for(let a of e)s+=nt(n,i,a,t.get(a.symbolId)??[])},()=>({definitions:e.length,materialized:o.definitions,inMemoryHits:o.inMemoryHits,incompleteInMemoryHits:o.incompleteInMemoryHits,resultRows:i.size,callerFiles:s})),i}function ti(n,e,t,r,i={}){let o=cn(n),s=[],a=[],c=[],u=0,f=0,l=0,d=0,p=0,m=0,R=0,I=0,S=0,h=0,P=0,M=0,v=[],C=new Map,D=e.filter(y=>L(y.relativePath)==="typescript"&&!t.has(y.symbolId)&&!r.has(y.symbolId)),b=yn(n,D,y=>Q(n,y));if(b){S=D.length,h=b.cacheHits,P=b.cacheMisses,M=b.computedFiles;for(let y of D)t.set(y.symbolId,b.references.get(y.symbolId)??[])}if(k("semantic.references.cache-scan",()=>{for(let[y,g]of Jr(e)){let T=[];for(let w of g)t.has(w.symbolId)?f+=1:r.has(w.symbolId)?I+=1:T.push(w);if(T.length===0){R+=1;continue}let j=Os(n,o,y);if(!j){for(let w of T)L(w.relativePath)||(u+=1),c.push(w);continue}m+=1;let F=ft(n,y,j);for(let w of T){let O=F.get(w.symbol)??null;if(O!==null){let E=Us(O);if(E){l+=1,t.set(w.symbolId,E);continue}d+=1}a.push({definition:w,cacheFingerprint:j})}}},()=>({definitions:e.length,skippedUnsupportedLanguage:u,cacheHits:l,parseFailures:d,misses:a.length,unkeyed:c.length,inMemoryHits:f,incompleteInMemoryHits:I,fullyInMemoryFiles:R,cacheReadFiles:m})),a.length>0||c.length>0){v=[...c,...a.map(y=>y.definition)],C=k("semantic.references.compute-misses",()=>{let y=ri(n,v,i);return p=y.size,y},()=>({definitions:v.length,misses:a.length,unkeyed:c.length,rows:p}));for(let y of v)C.has(y.symbolId)?(t.set(y.symbolId,C.get(y.symbolId)??[]),r.delete(y.symbolId)):r.add(y.symbolId);for(let{definition:y,cacheFingerprint:g}of a)C.has(y.symbolId)&&ci(n,"semantic-references",y.relativePath).available&&s.push({relativePath:y.relativePath,symbol:y.symbol,projectFingerprint:g,payload:JSON.stringify(C.get(y.symbolId)??[])})}return s.length>0&&k("semantic.references.cache-write",()=>dt(n,s),()=>({entries:s.length})),C.size>0&&mn(n,v,C,y=>Q(n,y)),{definitions:e.length,inMemoryHits:f,incompleteInMemoryHits:I,cacheHits:l,misses:a.length,unkeyed:c.length,skippedUnsupportedLanguage:u,parseFailures:d,computed:p,incomplete:r.size,cacheWrites:s.length,fragmentDefinitions:S,fragmentCacheHits:h,fragmentCacheMisses:P,fragmentComputedFiles:M}}function Os(n,e,t){if(!e)return null;let r=L(t);return r==="typescript"?Pe(JSON.stringify({kind:"semantic-references",language:r,schema:"typescript-references-v2-incomplete-scan",projectFingerprint:e})):r==="rust"?Pe(JSON.stringify({kind:"semantic-references",language:r,engine:hn(n.config.projectRoot),projectFingerprint:e})):null}function ri(n,e,t={}){let r=_(),i=new Map,o=0,s=0,a=0,c=0,u=0,f=0,l=0,d=0,p=0;return k("semantic.references.provider-loop",()=>{let m=Yr(n,e),R=Ot(n,e),I=new Map,S=t.prefetchCallees?new Map:null,h=[];for(let M of e){let v,C=()=>(v??=W(n,M.relativePath),v);if(S){let g=C();if(g?.referencesAndCalleesForDefinitions){let T=S.get(g);T?T.push(M):S.set(g,[M]),p+=1}}let D=m.get(M.symbolId);if(D){a+=1,c+=D.length,ve(i,M.symbolId,D,r,g=>{l+=1,d+=g});continue}let b=R.get(M.symbolId);if(b){u+=1,f+=b.length,ve(i,M.symbolId,b,r,g=>{l+=1,d+=g});continue}let y=C();if(!y){r&&(s+=1);continue}if(r&&(o+=1),y.referencesForDefinitions){let g=I.get(y);g?g.push(M):I.set(y,[M])}else h.push({provider:y,definition:M})}let P=new Set;if(S)for(let[M,v]of S){if(!M.referencesAndCalleesForDefinitions)continue;let C=I.get(M)??[],D=M.referencesAndCalleesForDefinitions(C,v);P.add(M),Fs(n,D.callees);for(let b of C){if(!D.references.has(b.symbolId))continue;let y=D.references.get(b.symbolId)??[];ve(i,b.symbolId,y,r,g=>{l+=1,d+=g})}}for(let[M,v]of I){if(P.has(M))continue;let C=M.referencesForDefinitions(v);for(let D of v){if(!C.has(D.symbolId))continue;let b=C.get(D.symbolId)??[];ve(i,D.symbolId,b,r,y=>{l+=1,d+=y})}}for(let{provider:M,definition:v}of h){let C=M.referencesFor(v);ve(i,v.symbolId,C,r,D=>{l+=1,d+=D})}return i},()=>({definitions:e.length,providerHits:o,providerMisses:s,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:c,rustScipOccurrenceFastPathRows:u,rustScipOccurrenceFastPathReferences:f,prefetchCalleeDefinitions:p,definitionsWithReferences:l,referenceCount:d,rows:i.size}))}function Pu(n,e,t={}){let r=ri(n,e,t),i=ii(n,e,r);return tt(n,i),{rows:r,...i}}function ve(n,e,t,r,i){n.set(e,t),r&&t.length>0&&i(t.length)}function nt(n,e,t,r){let i=0;for(let o of r){if(o.file===t.relativePath||n.isIgnored(o.file))continue;let s=e.get(t.symbolId);s||(s=new Set,e.set(t.symbolId,s));let a=s.size;s.add(o.file),s.size!==a&&(i+=1)}return i}function Us(n){try{return JSON.parse(n)}catch{return null}}function Eu(n,e,t){let r=oi(n,e,t),i=ii(n,e,r,t);return tt(n,i),{rows:r,...i}}function ii(n,e,t,r){let i=new Set,o=new Set;for(let s of e)if(!(t.has(s.symbolId)||!L(s.relativePath)))try{(r?r(s.relativePath):Q(n,s.relativePath)).availability().available?i.add(s.symbolId):o.add(s.symbolId)}catch{o.add(s.symbolId)}return{incompleteSymbolIds:i,unavailableSymbolIds:o}}function oi(n,e,t){let r=_(),i=new Map,o=0,s=0,a=0,c=0;return k("semantic.callees.provider-loop",()=>{let u=new Map,f=[];for(let l of e){let d=t?t(l.relativePath):W(n,l.relativePath);if(d&&!d.availability().available){r&&(s+=1);continue}if(!d){r&&(s+=1);continue}r&&(o+=1);let p=l;if(d.calleesForDefinitions){let m=u.get(d);m?m.push(p):u.set(d,[p])}else f.push({provider:d,definition:p})}for(let[l,d]of u){let p=l.calleesForDefinitions(d);for(let m of d){if(!p.has(m.symbolId))continue;let R=p.get(m.symbolId)??[];ei(i,m.symbolId,R,r,I=>{a+=1,c+=I})}}for(let{provider:l,definition:d}of f){let p=l.calleesFor(d);ei(i,d.symbolId,p,r,m=>{a+=1,c+=m})}return i},()=>({definitions:e.length,providerHits:o,providerMisses:s,definitionsWithCallees:a,calleeCount:c,rows:i.size}))}function ei(n,e,t,r,i){n.set(e,t),r&&t.length>0&&i(t.length)}function Au(n,e){return rt(n).signature(e)}function Bs(n,e){if(L(e.relativePath)==="typescript"){let s="fallback",a=0,c=0,u=0,f=0;return k("typescript.signature.materialize",()=>{let l=pn(n,e.relativePath,As);if(l?.key){a=1;let p=Zr.read(n,e.relativePath,l.key)??{};if(Object.prototype.hasOwnProperty.call(p,e.symbol))return s="hit",c=1,p[e.symbol]??null;u=1;let m=W(n,e.relativePath);if(!m)return s="unavailable",null;let R=m.signatureFor(e);return Zr.write(n,e.relativePath,l.key,{...p,[e.symbol]:R}),s="computed",R}f=1;let d=W(n,e.relativePath);return d?(s="direct-fallback",d.signatureFor(e)):(s="unavailable",null)},()=>({state:s,eligible:a,cacheHits:c,cacheMisses:u,fallbacks:f}))}let t=si(n,"semantic-signatures",e.relativePath),r=qs(e);if(t){let s=Qr.read(n,r,t);if(s)return s.signature}let i=W(n,e.relativePath);if(!i)return null;let o=i.signatureFor(e);return t&&Qr.write(n,r,t,{signature:o}),o}function si(n,e,t){let r=cn(n);if(!r)return null;let i=L(t);return i!=="rust"?null:Pe(JSON.stringify({kind:e,language:i,engine:hn(n.config.projectRoot),projectFingerprint:r}))}function qs(n){return`${n.relativePath}\0${n.symbol}`}function ai(n){try{let e=JSON.parse(n);return Array.isArray(e)?e:null}catch{return null}}function js(n){try{let e=JSON.parse(n);if(!e||typeof e!="object")return null;let t=e.signature;return t!==null&&typeof t!="string"?null:{signature:t}}catch{return null}}function Ws(n){try{let e=JSON.parse(n);if(!e||typeof e!="object"||Array.isArray(e))return null;for(let t of Object.values(e))if(t!==null&&typeof t!="string")return null;return e}catch{return null}}function ci(n,e,t){let r=L(t);if(!r)return{slot:e,language:"typescript",available:!1,reason:"semantic evidence is only available for TypeScript or Rust files"};try{return{slot:e,language:r,...Q(n,t).availability()}}catch(i){return{slot:e,language:r,available:!1,reason:i instanceof Error?i.message:String(i)}}}function W(n,e){if(!L(e))return null;let t=Q(n,e);return t.availability().available?t:null}export{Jr as a,hn as b,L as c,Du as d,xu as e,rt as f,Cu as g,Tu as h,wu as i,ku as j,_s as k,ri as l,Pu as m,Eu as n,Au as o};
|
|
3
|
+
//# sourceMappingURL=chunk-6CS3UQTN.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as le}from"./chunk-N3IQCBCF.js";import{a as re}from"./chunk-GCHRX4YW.js";import{b as _}from"./chunk-XME3HPXZ.js";import{a as se}from"./chunk-BFFZDZQV.js";import{b as ie}from"./chunk-ID63777H.js";import{a as ne,b as oe}from"./chunk-AKB7V7TV.js";import{b as ee}from"./chunk-LZYFLFEH.js";import{f as te}from"./chunk-T3DGWPXM.js";import{a as X}from"./chunk-KMITESMT.js";import{a as Z}from"./chunk-ANFVSJWQ.js";import{b as Q}from"./chunk-SWHMHUKF.js";import{a as J}from"./chunk-4WKDMDEW.js";import{d as V}from"./chunk-PTAWHLVJ.js";import{b as Y}from"./chunk-GTXSJDCO.js";import{a as W}from"./chunk-OL6KJP3N.js";import{a as D}from"./chunk-UDS562V4.js";import{b as q}from"./chunk-LU3BMVH2.js";import{a as H,c as K}from"./chunk-UZGZB3VB.js";import{a as G}from"./chunk-TIIC3ZE7.js";import{e as P,t as w}from"./chunk-FETNQCFO.js";import{d as z}from"./chunk-3LCDIREB.js";function ae(e){let t=new Set(e.filter(o=>o.definition?.isFunctionLike).map(o=>`${o.role}:${o.definition.relativePath}`));return e.flatMap(o=>o.definition?!o.definition.isFunctionLike&&t.has(`${o.role}:${o.definition.relativePath}`)?[]:[{definition:o.definition,role:o.role}]:[])}var pe=6,I=10,B=3,N=8,he=.7,ce=24,M=200,ye=12,ue=80,me=600;function Ve(e,t,o={}){let l=o.impactDepth??3,m=o.sliceDepth??3,u=o.semantic,c=Ee(t)?be(e,t):null,a=c?c.primary?.symbol??null:t,s=a!==null,d=s?f("trace",a,()=>ie(e,a,{semantic:u,referenceContext:ye}),i=>({definitions:i.definitions.length,references:i.referencedBy.length})):{definitions:[],referencedBy:[],claimSupport:null},g=s?f("call-graph",a,()=>X(e,a,{semantic:u}),i=>({callers:i?.callers.length??0,callees:i?.callees.length??0})):null,n=s?f("complexity",a,()=>W(e,a,{semantic:u}),i=>({callees:i?.calleeCount??0})):null,y=s?f("dataflow",a,()=>ee(e,a,{semantic:u}),i=>({references:i?.usageSites.length??0,producers:i?.producers.length??0,consumers:i?.consumers.length??0})):null,r=s?f("backward-slice",a,()=>_(e,a,{direction:"backward",maxDepth:m,semantic:u}),i=>({maxDepth:m,connectedSymbols:i?.connectedSymbols.length??0})):null,C=s?f("forward-slice",a,()=>_(e,a,{direction:"forward",maxDepth:m,semantic:u}),i=>({maxDepth:m,connectedSymbols:i?.connectedSymbols.length??0})):null,h=s?f("affected",a,()=>q(e,a,{maxDepth:l,scope:o.scope}),i=>({maxDepth:l,affectedSymbols:i.rows.length,coverage:i.coverage.status})):null,b=h?.rows??[],p=h?.coverage??null,S=s?f("reuse-candidates",a,()=>D(e,a,{minSimilarity:.4,limit:5,semantic:u,sourceCandidateMode:"target-pruned"}),i=>({candidates:i.length,direct:i.filter(Ce=>Ce.actionTier==="direct").length})):[],L=s?H(e,a)?.symbol??null:null,k=s?f("affected-consumer-reuse",a,()=>Re(d,L,i=>D(e,i,{minSimilarity:.4,limit:I,semantic:u,sourceCandidateMode:"target-pruned"}),{consumerLimit:pe,perConsumerSearchLimit:I,perConsumerCandidateLimit:B,candidateLimit:N}),i=>({totalConsumers:i.coverage.totalConsumers,analyzedConsumers:i.coverage.analyzedConsumers,candidates:i.candidates.length})):ve(),A=f("change-surface",t,()=>Z(e,t,{semantic:u}),i=>({symbols:i?.symbols.length??0,externalConsumers:i?.totalExternalConsumers??0})),R=f("system",t,()=>re(e,t),i=>({files:i.files.length,symbols:i.symbols.length})),T=R.files.length===1,F=f("deps",t,()=>T?R.dependsOn.map(i=>({relativePath:i,edgeBasis:"symbol-references",evidence:"cross-file SCIP references plus resolved source imports"})):ne(e,t),i=>({files:i.length,reusedSystem:T})),O=f("rdeps",t,()=>T?R.dependedOnBy.map(i=>({relativePath:i,edgeBasis:"symbol-references",evidence:"cross-file SCIP references plus resolved source imports"})):oe(e,t),i=>({files:i.length,reusedSystem:T})),U=f("surface",t,()=>le(e,t),i=>({consumers:i.length})),v={symbol:d.definitions.length>0||d.referencedBy.length>0||g!==null||n!==null||y!==null||r!==null||C!==null||b.length>0,file:A!==null||F.length>0||O.length>0,module:R.files.length>0||R.symbols.length>0||U.length>0},x=[];c&&!c.primary&&c.callableCount>1&&x.push(`File target has ${c.callableCount} callable symbols; use one callable name for compiler-resolved flow.`);let $=[...new Set(d.referencedBy.map(i=>i.relativePath))];$.length>0&&$.every(i=>G(i)==="test")&&x.push("Only test references were found for this target. For replacement or retirement work, map the currently wired owner or one production entry point before planning; this target does not describe the live affected surface."),!v.symbol&&!v.file&&!v.module&&x.push("No symbol, file, or module matched target."),p&&p.status!=="accounted"&&x.push(`Possible-impact coverage is ${p.status}: ${p.reasons.join(" ")}`);let j=A?.file??d.definitions[0]?.relativePath??null;return{target:t,...c?.primary?{primaryCallable:{symbol:c.primary.symbol,shortName:P(c.primary.symbol),file:c.primary.relativePath}}:{},matched:v,history:f("history",j??t,()=>Pe(e,j,o.gitHead)),trace:ge(d),callGraph:g,complexity:n,dataflow:y,backwardSlice:r,forwardSlice:C,affected:b,affectedCoverage:p,changeSurface:A,deps:F,rdeps:O,system:R,surface:U,reuseCandidates:S,affectedConsumerReuse:k,sourcePacket:Se(e,L,d,k,S),warnings:x}}function ge(e){return{definitions:e.definitions,referencedBy:e.referencedBy.map(t=>({relativePath:t.relativePath,line:t.line,enclosingSymbol:t.enclosingSymbol,enclosingShort:t.enclosingShort}))}}function be(e,t){let o=Y(e,t);if(o.length!==1)return{primary:null,callableCount:0};let l=w(e,o[0]).filter(c=>c.isFunctionLike),m=l.filter(c=>c.enclosingSymbol===null),u=m.length>0?m:l;return{primary:u.length===1?u[0]:null,callableCount:u.length}}function Se(e,t,o,l,m){let u=[...t?[{definition:fe(e,t),role:"target"}]:[],...[...l.candidates.map(n=>n.candidate),...m].map(n=>({definition:fe(e,n.symbolB),role:"reuse-candidate"}))],c=new Map;for(let n of ae(u)){if(c.has(n.definition.symbol))continue;let y=n.role==="target"?M:ue,r=n.definition.endLine<=n.definition.startLine?V(e,n.definition.relativePath,n.definition.startLine,y):null,C=r?.unitType?r.source:te(e,n.definition);if(!C)continue;let h=C.split(`
|
|
2
|
+
`),b=Math.min(h.length,y),p=r?.unitType?r.startLine:n.definition.startLine;c.set(n.definition.symbol,{role:n.role,symbol:n.definition.symbol,shortName:P(n.definition.symbol),file:n.definition.relativePath,startLine:p,endLine:p+b-1,source:h.slice(0,b).join(`
|
|
3
|
+
`),omittedLines:(r?.unitType?r.omittedLines:0)+Math.max(0,h.length-b)})}let a=new Map;for(let n of o.referencedBy){if(n.source===void 0||n.source===null||n.sourceStartLine===void 0||n.sourceStartLine===null||n.sourceEndLine===void 0||n.sourceEndLine===null)continue;let y=`${n.relativePath}:${n.sourceStartLine}-${n.sourceEndLine}`,r=a.get(y);if(r){r.focusLines=[...new Set([...r.focusLines??[],n.line])].sort((C,h)=>C-h);continue}a.set(y,{role:"consumer",symbol:n.enclosingSymbol??`${n.relativePath}:${n.line}`,shortName:n.enclosingShort,file:n.relativePath,startLine:n.sourceStartLine,endLine:n.sourceEndLine,source:n.source,omittedLines:0,focusLines:[n.line]})}let s=[...[...c.values()].filter(n=>n.role==="target"),...a.values(),...[...c.values()].filter(n=>n.role==="reuse-candidate")],d=[],g=me;for(let n of s){if(d.length>=ce||g<=0)break;let y=n.source.split(`
|
|
4
|
+
`),r=Math.min(y.length,g);d.push({...n,endLine:n.startLine+r-1,source:y.slice(0,r).join(`
|
|
5
|
+
`),omittedLines:n.omittedLines+Math.max(0,y.length-r),...n.focusLines?{focusLines:n.focusLines.filter(C=>C<=n.startLine+r-1)}:{}}),g-=r}return{slices:d,candidateSlices:s.length,omittedSlices:Math.max(0,s.length-d.length),maxSlices:ce,maxLinesPerSlice:M,maxTotalLines:me,targetLineLimit:M,consumerContextLines:ye,reuseLineLimit:ue}}function fe(e,t){let o=K(e,t);return o?w(e,o.relativePath).find(l=>l.symbol===t)??null:null}function Re(e,t,o,l={}){let m=E(l.consumerLimit,pe),u=E(l.perConsumerSearchLimit,I),c=E(l.perConsumerCandidateLimit,B),a=E(l.candidateLimit,N),s=xe(e),d=s.slice(0,m),g=new Set(s.map(r=>r.symbol));t&&g.add(t);let n=new Map;for(let r of d){let C=o(r.symbol).slice(0,u),h=0;for(let b of C){let p=Le(b,r.symbol);if(!p||g.has(p.symbolB))continue;let S=n.get(p.symbolB);if(S?(S.consumers.some(L=>L.symbol===r.symbol)||S.consumers.push(r),p.similarity>S.candidate.similarity&&(S.candidate=p)):n.set(p.symbolB,{candidate:p,consumers:[r]}),h+=1,h>=c)break}}let y=[...n.values()].filter(r=>r.candidate.actionTier==="direct"||r.candidate.similarity>=he||r.consumers.length>1).sort(Te).slice(0,a);return{candidates:y,coverage:{totalConsumers:s.length,analyzedConsumers:d.length,omittedConsumers:Math.max(0,s.length-d.length),perConsumerSearchLimit:u,perConsumerCandidateLimit:c,candidateLimit:a,returnedCandidates:y.length}}}function xe(e){let t=new Map;for(let o of e.referencedBy){if(!o.enclosingSymbol)continue;let l=t.get(o.enclosingSymbol);if(l){l.referenceCount+=1;continue}t.set(o.enclosingSymbol,{symbol:o.enclosingSymbol,shortName:P(o.enclosingSymbol)||o.enclosingShort,file:o.relativePath,referenceCount:1})}return[...t.values()].sort((o,l)=>l.referenceCount-o.referenceCount||o.symbol.localeCompare(l.symbol))}function Le(e,t){return e.symbolA===t?e:e.symbolB!==t?null:{...e,symbolA:e.symbolB,shortNameA:e.shortNameB,fileA:e.fileB,symbolB:e.symbolA,shortNameB:e.shortNameA,fileB:e.fileA,uniqueToA:e.uniqueToB,uniqueToB:e.uniqueToA}}function Te(e,t){let o=de(t.candidate.actionTier)-de(e.candidate.actionTier);if(o!==0)return o;let l=t.consumers.length-e.consumers.length;if(l!==0)return l;let m=t.candidate.similarity-e.candidate.similarity;return m!==0?m:e.candidate.symbolB.localeCompare(t.candidate.symbolB)}function de(e){return e==="direct"?1:0}function E(e,t){return typeof e=="number"&&Number.isFinite(e)?Math.max(1,Math.floor(e)):t}function ve(){return{candidates:[],coverage:{totalConsumers:0,analyzedConsumers:0,omittedConsumers:0,perConsumerSearchLimit:I,perConsumerCandidateLimit:B,candidateLimit:N,returnedCandidates:0}}}function f(e,t,o,l=()=>({})){let m;return z(`context.${e}`,()=>(m=o(),m),()=>({target:t,...l(m)}))}function Pe(e,t,o){let l={available:!1,file:t,churn:null,coChangePartners:[],suppressionsInFile:0};if(!t)return l;let m=J(e,o?{head:o}:{}),u=f("history.churn",t,()=>m.fileChurn(),s=>({files:s?.size??0}));if(!u)return l;let c=f("history.co-change",t,()=>Q(e,t,{limit:5,...o?{head:o}:{}}),s=>({commits:s.commitsAnalyzed,partners:s.findings.length})),a=f("history.suppressions",t,()=>se(e).byFile.get(t)??0,s=>({suppressions:s}));return{available:!0,file:t,churn:u.get(t)??{changes:0,fixChanges:0,lastChangedAt:0},coChangePartners:c.findings.map(s=>({file:s.fileA===t?s.fileB:s.fileA,together:s.together,confidence:s.confidence,subjectContext:s.subjectContext})),suppressionsInFile:a}}function Ee(e){return e.includes("/")||e.includes("\\")||/\.[A-Za-z0-9]+(?::\d+(?:-\d+)?)?$/.test(e)}export{Ve as a,Re as b};
|
|
6
|
+
//# sourceMappingURL=chunk-6MUIJMVL.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import{a as y}from"./chunk-QHRNXP3C.js";import{b as f}from"./chunk-UZGZB3VB.js";import{c as h,d as w}from"./chunk-SGX43S2L.js";import{d as u,e as m,h as b,p,q as g}from"./chunk-FETNQCFO.js";import{dirname as $,isAbsolute as k,relative as x,resolve as v}from"path";var C=new Set(w());function R(t,e){return`tests/generated/twin-ab/${d(t)}-vs-${d(e)}.test.ts`}function d(t){return(t.split(/[/#]/).pop()||t).replace(/[^A-Za-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"symbol"}function P(t,e,a,n){let{refA:l,refB:s,outFile:r}=typeof e=="string"?{refA:e,refB:a,outFile:n}:e;if(typeof l!="string"||typeof s!="string"||typeof r!="string")throw new TypeError("twinAb requires refA, refB, and outFile.");if(!k(r))throw new TypeError("twinAb outFile must be an absolute path.");let i=A(t,l);if(!i.ok)return i;let o=A(t,s);if(!o.ok)return o;let c=i.symbol.paramCount===null||o.symbol.paramCount===null?null:i.symbol.paramCount===o.symbol.paramCount,S=N(i.symbol,o.symbol,t.config.projectRoot,r,c);return{ok:!0,a:i.symbol,b:o.symbol,signatureCompatible:c,testSource:S}}function A(t,e){let n=f(t,e).match;if(!n)return{ok:!1,reason:`${e} does not resolve to an indexed symbol.`};let s=t.get("SELECT kind FROM global_symbols WHERE id = ?",n.symbolId)?.kind??null;if(!(s!==null?C.has(s):b(n.symbol)))return{ok:!1,reason:`${e} resolves to ${u(n.symbol)}${s!==null?` with SCIP kind ${h(s)}`:""} \u2014 twin-ab compares call outputs, so both referents must be functions or methods.`};if(!y(t,n))return{ok:!1,reason:`${e} (${u(n.symbol)} at ${n.relativePath}:${n.startLine+1}) is not exported \u2014 twin-ab needs an importable named binding for both twins.`};let i=t.get("SELECT documentation FROM global_symbols WHERE id = ?",n.symbolId),o=p(g(i?.documentation??null));return{ok:!0,symbol:{ref:e,symbol:n.symbol,shortName:m(n.symbol)||u(n.symbol),file:n.relativePath,startLine:n.startLine,signature:o,paramCount:o?E(o):null}}}function E(t){let e=t.indexOf("(");if(e===-1)return null;let a=0,n=-1;for(let i=e;i<t.length;i+=1){let o=t[i];if(o==="(")a+=1;else if(o===")"&&(a-=1,a===0)){n=i;break}}if(n===-1)return null;let l=t.slice(e+1,n).trim();if(!l)return 0;let s=1,r=0;for(let i of l)i==="("||i==="["||i==="{"?r+=1:i===")"||i==="]"||i==="}"?r=Math.max(0,r-1):i===","&&r===0&&(s+=1);return s}function T(t,e,a){let n=$(e),l=v(t,a),r=x(n,l).replace(/\\/g,"/").replace(/\.tsx?$/,".js");return r.startsWith(".")?r:`./${r}`}function N(t,e,a,n,l){let s=T(a,n,t.file),r=T(a,n,e.file),i=l===null?"Signature comparison: unknown (one or both signatures unavailable in the index) \u2014 check by hand.":l?"Signature comparison: param counts match.":"Signature comparison: param counts DIFFER \u2014 twins may not be directly comparable; check by hand.";return`/**
|
|
2
|
+
* Generated by 'codebaseiq twin-ab'. Cleanup integrity scenario.
|
|
3
|
+
* ("cross-examine same-concept twins"): where one concept is computed in
|
|
4
|
+
* more than one place, feed both the same input and require the same
|
|
5
|
+
* answer. Disagreement between twins means at least one is wrong \u2014
|
|
6
|
+
* determine which before consolidating.
|
|
7
|
+
*
|
|
8
|
+
* Twin A: ${t.shortName} (${t.file}:${t.startLine+1})
|
|
9
|
+
* ${t.signature??"(signature unavailable)"}
|
|
10
|
+
* Twin B: ${e.shortName} (${e.file}:${e.startLine+1})
|
|
11
|
+
* ${e.signature??"(signature unavailable)"}
|
|
12
|
+
* ${i}
|
|
13
|
+
*
|
|
14
|
+
* Fill in the TODO input table below with inputs both twins should agree
|
|
15
|
+
* on, then run this file with vitest.
|
|
16
|
+
*/
|
|
17
|
+
import { describe, expect, it } from 'vitest';
|
|
18
|
+
import { ${t.shortName} as twinA } from '${s}';
|
|
19
|
+
import { ${e.shortName} as twinB } from '${r}';
|
|
20
|
+
|
|
21
|
+
// TODO: fill in shared inputs both twins should agree on \u2014 one arg array per call.
|
|
22
|
+
const inputs: any[][] = [
|
|
23
|
+
// [/* arg1, arg2, ... */],
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
// Cast to a variadic signature so the input table can hold any arg shape \u2014
|
|
27
|
+
// the real twins have fixed, non-rest parameter lists, and TS rejects
|
|
28
|
+
// spreading a generic args array into those (TS2556) even when the array
|
|
29
|
+
// itself is 'any'; casting the callee's signature, not the args, satisfies
|
|
30
|
+
// the checker without weakening the twins' real exported types elsewhere.
|
|
31
|
+
const callA = twinA as (...callArgs: any[]) => any;
|
|
32
|
+
const callB = twinB as (...callArgs: any[]) => any;
|
|
33
|
+
|
|
34
|
+
describe.skipIf(inputs.length === 0)('twin-ab: ${t.shortName} vs ${e.shortName}', () => {
|
|
35
|
+
it.each(inputs)('agrees on input %#', (...args) => {
|
|
36
|
+
expect(callA(...args)).toEqual(callB(...args));
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
`}export{R as a,P as b};
|
|
40
|
+
//# sourceMappingURL=chunk-6NW7MU72.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{b as t,d}from"./chunk-2Q2LW5JW.js";import{execFileSync as g}from"child_process";import{createRequire as v}from"module";import{existsSync as w}from"fs";import{platform as i,arch as f}from"os";var r="v0.8.1",c="https://github.com/sourcegraph/scip",s=`github.com/sourcegraph/scip/cmd/scip@${r}`,m=v(import.meta.url),h="CODEBASEIQ_SCIP_BIN";function x(e){if(e.isOnPath("scip"))return{source:"path",path:"scip"};let n=e.env[h];if(n&&e.fileExists(n))return{source:"env",path:n};if(e.platform==="win32"){let o=e.resolveSidecar(e.arch);if(o&&e.fileExists(o))return{source:"sidecar",path:o}}return null}function S(e){for(let n of e==="arm64"?["arm64","x64"]:[e])try{return m.resolve(`codebaseiq-windows/scip-win32-${n}.exe`)}catch{}return null}function u(e=process.env){let n=x({platform:i(),arch:f(),env:e,isOnPath:t,fileExists:w,resolveSidecar:S});return n?.source==="path"?d("scip")??n.path:n?.path??null}function C(){return u()!==null}function b(){let e=u();if(!e)return null;try{return g(e,["--version"],{stdio:"pipe",windowsHide:!0,timeout:1e4,killSignal:"SIGKILL"}).toString().trim()}catch{return null}}function y(){let e=i(),n=f(),o,l,a;switch(e){case"darwin":o="darwin",a="tar.gz";break;case"linux":o="linux",a="tar.gz";break;default:return null}switch(n){case"arm64":l="arm64";break;case"x64":l="amd64";break;default:return null}let p=`scip-${o}-${l}.${a}`;return{url:`${c}/releases/download/${r}/${p}`,filename:p}}function O(){let e=y();if(console.log("\nThe `scip` CLI is required but not found on PATH.\n"),i()==="darwin"||i()==="linux")console.log("Install the reviewed version with Go:"),console.log(` go install ${s}
|
|
2
|
+
`),console.log("Or download that exact release manually:");else if(i()==="win32"){let n=$();console.log("On Windows the scip binary ships via the npm sidecar package codebaseiq-windows,"),console.log("installed automatically with codebaseiq. If it is missing:"),console.log(` npm install -g ${n}`),console.log(`Or set ${h} to a local scip.exe path.
|
|
3
|
+
`),console.log("Upstream release page:")}else console.log("Download from:");console.log(e?` ${e.url}
|
|
4
|
+
`:` ${c}/releases/tag/${r}
|
|
5
|
+
`),console.log("After installing, ensure `scip` is on your PATH and run `codebaseiq reindex`.")}function $(){let n=m("../../package.json").optionalDependencies?.["codebaseiq-windows"];if(!n||!/^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?$/.test(n))throw new Error("codebaseiq package metadata does not declare an exact Windows sidecar version.");return`codebaseiq-windows@${n}`}function k(e){if(t("go")){e(`Installing immutable ${s} via go install into the Go bin directory (GOBIN or GOPATH/bin); expected executable: scip.`);try{if(g("go",["install",s],{stdio:"inherit",windowsHide:!0,timeout:3e5,env:process.env}),t("scip")){let n=u(),o=b();if(n&&o&&o.includes(r))return e(`Successfully installed ${s}; resolved executable: ${n}; reported version: ${o}.`),!0;e(`go install completed, but the resolved scip executable did not report ${r} (executable: ${n??"unresolved"}; version: ${o??"unavailable"}).`)}}catch(n){let o=n instanceof Error?n.message:String(n);e(`go install failed: ${o}`)}}return e("Could not auto-install scip CLI."),e(`Install manually from: ${c}/releases`),!1}export{u as a,C as b,O as c,k as d};
|
|
6
|
+
//# sourceMappingURL=chunk-6OAHRI2D.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{statSync as r}from"fs";function o(t){let e=t.get("SELECT COUNT(*) as c FROM documents").c,s=t.get("SELECT COUNT(*) as c FROM global_symbols").c,n=t.get("SELECT COUNT(*) as c FROM mentions WHERE role = 1").c,i=t.get("SELECT COUNT(*) as c FROM mentions WHERE role != 1").c;return{documents:e,symbols:s,definitions:n,references:i,...a(t.generation.databasePath)}}function a(t){try{let e=r(t);return{indexSizeBytes:e.size,lastBuilt:e.mtime}}catch{return{indexSizeBytes:0,lastBuilt:null}}}export{o as a};
|
|
2
|
+
//# sourceMappingURL=chunk-6YTSKJJ3.js.map
|