scip-query 0.24.0 → 0.26.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 +247 -1
- package/README.md +111 -124
- package/dist/augment-vue-worker.js +1 -1
- package/dist/by-kind-PRVFAGTQ.js +2 -0
- package/dist/call-graph-DVPAQV2F.js +2 -0
- package/dist/{call-graph-evidence-BociKRpF.d.ts → call-graph-evidence-CUtj8V2I.d.ts} +1 -1
- package/dist/chunk-2FSBGL5P.js +2 -0
- package/dist/chunk-2HLAFUCY.js +2 -0
- package/dist/chunk-2IWUT6CJ.js +3 -0
- package/dist/chunk-2KNN7GTQ.js +2 -0
- package/dist/chunk-2LHXRE2B.js +8 -0
- package/dist/{chunk-E65ELFKU.js → chunk-2YXE77TJ.js} +2 -2
- package/dist/chunk-36SGVCGX.js +2 -0
- package/dist/chunk-3ABBFPTP.js +2 -0
- package/dist/chunk-3IVFU4FD.js +3 -0
- package/dist/chunk-3JIQS44J.js +7 -0
- package/dist/chunk-3ZRB6DNK.js +7 -0
- package/dist/{chunk-6YTSKJJ3.js → chunk-42EOW5VI.js} +1 -1
- package/dist/{chunk-BHKK5RJY.js → chunk-4BHGBMNO.js} +2 -2
- package/dist/chunk-4BP3UBDG.js +2 -0
- package/dist/chunk-4D6RO7G4.js +2 -0
- package/dist/chunk-4FEWQ6RH.js +2 -0
- package/dist/chunk-4IGEOBG7.js +2 -0
- package/dist/chunk-4QZXBUKC.js +2 -0
- package/dist/chunk-4WBDEVX2.js +4 -0
- package/dist/chunk-4WCUBZU3.js +8 -0
- package/dist/chunk-4WTUBQ36.js +40 -0
- package/dist/chunk-4XQ4O6IM.js +3 -0
- package/dist/chunk-55UQAMZO.js +4 -0
- package/dist/chunk-5D2LVK7O.js +125 -0
- package/dist/chunk-5IYJ56TT.js +2 -0
- package/dist/chunk-5PLMJC7Q.js +2 -0
- package/dist/chunk-5TNQJUR2.js +5 -0
- package/dist/chunk-62BDNPMI.js +2 -0
- package/dist/chunk-64DZ5TXR.js +7 -0
- package/dist/chunk-65245JCM.js +2 -0
- package/dist/chunk-6FFVZZL4.js +2 -0
- package/dist/chunk-6KO5JHAR.js +2 -0
- package/dist/chunk-6LRXOOSX.js +2 -0
- package/dist/chunk-6LSEIIF7.js +2 -0
- package/dist/chunk-6YMNWD3H.js +6 -0
- package/dist/chunk-72AD6ZRR.js +5 -0
- package/dist/chunk-73AAKPUC.js +4 -0
- package/dist/chunk-76CZ77DF.js +2 -0
- package/dist/chunk-7VPEEAAG.js +2 -0
- package/dist/chunk-7WTPQ4NX.js +14 -0
- package/dist/chunk-7Y5T6XDP.js +2 -0
- package/dist/chunk-A2IIGFMJ.js +5 -0
- package/dist/chunk-AB5KCTEV.js +2 -0
- package/dist/chunk-AC566WBP.js +6 -0
- package/dist/chunk-AGWFSTXC.js +3 -0
- package/dist/chunk-AOSIYPTA.js +2 -0
- package/dist/chunk-AUVEWPIF.js +2 -0
- package/dist/chunk-B56T42J3.js +25 -0
- package/dist/chunk-BIQEF5NE.js +2 -0
- package/dist/chunk-BL6XJKTA.js +3 -0
- package/dist/chunk-BMKOQJRI.js +2 -0
- package/dist/chunk-BOZ4EXBB.js +3 -0
- package/dist/chunk-BUTWYEPH.js +2 -0
- package/dist/chunk-BZB4QPIP.js +2 -0
- package/dist/{chunk-6ILKOOGH.js → chunk-CE357GEE.js} +4 -4
- package/dist/chunk-CFN45HFP.js +2 -0
- package/dist/chunk-CFYMZFXT.js +368 -0
- package/dist/chunk-CN5EH7O3.js +2 -0
- package/dist/chunk-D254DNNQ.js +4 -0
- package/dist/chunk-D3FDISIC.js +2 -0
- package/dist/chunk-D3NX5XIE.js +3 -0
- package/dist/chunk-DA7RPPDF.js +3 -0
- package/dist/chunk-DDMC3FON.js +3 -0
- package/dist/chunk-DIO3FUSG.js +2 -0
- package/dist/chunk-DJ2NNSUK.js +3 -0
- package/dist/chunk-DKYQIM3C.js +18 -0
- package/dist/{chunk-OHIV323X.js → chunk-DOOEL2IV.js} +2 -2
- package/dist/chunk-DVFP6PZI.js +2 -0
- package/dist/chunk-E3FDPXZK.js +2 -0
- package/dist/chunk-E7YNJLCB.js +2 -0
- package/dist/chunk-EFGW5JPH.js +2 -0
- package/dist/chunk-EJVTR244.js +13 -0
- package/dist/chunk-EOV7RTRZ.js +2 -0
- package/dist/chunk-ETOIKRHO.js +2 -0
- package/dist/chunk-EYK3ZAO2.js +3 -0
- package/dist/chunk-F2V2LPET.js +52 -0
- package/dist/chunk-F4LUHJTF.js +2 -0
- package/dist/chunk-F4PUT6IT.js +2 -0
- package/dist/chunk-F56GCXXS.js +5 -0
- package/dist/chunk-FC2EVQRM.js +2 -0
- package/dist/chunk-FL7NBMHP.js +3 -0
- package/dist/chunk-FMRN2TRL.js +3 -0
- package/dist/chunk-FVULPZDF.js +20 -0
- package/dist/chunk-GCKCF5FL.js +43 -0
- package/dist/chunk-GH2PYF46.js +2 -0
- package/dist/chunk-GHJAGXIP.js +2 -0
- package/dist/{chunk-2GJSD5GY.js → chunk-GMVSHUKZ.js} +2 -2
- package/dist/chunk-GS6KDO4R.js +2 -0
- package/dist/chunk-GUUBXNN7.js +2 -0
- package/dist/chunk-GVWX5T43.js +80 -0
- package/dist/chunk-GZKFETP5.js +2 -0
- package/dist/chunk-H4EQHO6J.js +9 -0
- package/dist/chunk-H73WY2RM.js +2 -0
- package/dist/chunk-H75GSPRV.js +60 -0
- package/dist/chunk-HDR3AHSV.js +61 -0
- package/dist/chunk-HQBSL74Y.js +2 -0
- package/dist/chunk-HRRFKWPZ.js +2 -0
- package/dist/chunk-HXENDJC6.js +2 -0
- package/dist/chunk-IIBAZNSW.js +21 -0
- package/dist/chunk-INLMWEUU.js +12 -0
- package/dist/chunk-IWQPAF4F.js +2 -0
- package/dist/chunk-IZJ6YUKP.js +35 -0
- package/dist/chunk-J2TMAIN5.js +60 -0
- package/dist/chunk-J5FJMODQ.js +142 -0
- package/dist/chunk-J7HZPIO3.js +2 -0
- package/dist/chunk-JEVRKFRL.js +2 -0
- package/dist/chunk-JFXSGAEB.js +30 -0
- package/dist/chunk-JVRTHGFS.js +3 -0
- package/dist/chunk-JYWEX7RR.js +360 -0
- package/dist/chunk-K3YL22N6.js +2 -0
- package/dist/chunk-K4CN7GXK.js +12 -0
- package/dist/chunk-K5TBVXU4.js +30 -0
- package/dist/chunk-KDDIE2DP.js +9 -0
- package/dist/chunk-KHWRRPV4.js +2 -0
- package/dist/chunk-KI6NBKDY.js +14 -0
- package/dist/chunk-KU3QRSTH.js +2 -0
- package/dist/chunk-KZBJWZJB.js +2 -0
- package/dist/chunk-L7GFM3NP.js +3 -0
- package/dist/chunk-LMO6PK3V.js +35 -0
- package/dist/chunk-LN4YXJJU.js +2 -0
- package/dist/chunk-LOVIZBJ4.js +43 -0
- package/dist/chunk-LPCRK4A2.js +11 -0
- package/dist/chunk-MMHZKBFA.js +2 -0
- package/dist/{chunk-A4WEAK35.js → chunk-MOQQBQRD.js} +2 -2
- package/dist/chunk-N2WN6I3L.js +2 -0
- package/dist/chunk-N3ORQT7L.js +2 -0
- package/dist/chunk-NAZ3RAIW.js +2 -0
- package/dist/chunk-NDUNO5JQ.js +2 -0
- package/dist/chunk-NEIWRNAZ.js +4 -0
- package/dist/chunk-NJJMVD65.js +2 -0
- package/dist/chunk-NLOQOBXI.js +20 -0
- package/dist/chunk-NOLZOVCU.js +2 -0
- package/dist/chunk-NOWINRRN.js +2 -0
- package/dist/chunk-NZAXKGRL.js +16 -0
- package/dist/chunk-O2C4UILI.js +2 -0
- package/dist/chunk-O3RHA6ZT.js +3 -0
- package/dist/chunk-O4UZSPPI.js +3 -0
- package/dist/chunk-OGFV2BUX.js +2 -0
- package/dist/chunk-OZCJXZK6.js +499 -0
- package/dist/chunk-P6ODM7BY.js +2 -0
- package/dist/{chunk-GHNPACNP.js → chunk-PAVGPRHJ.js} +2 -2
- package/dist/chunk-PH52RA7D.js +2 -0
- package/dist/chunk-PKN354TH.js +3 -0
- package/dist/chunk-PWOASWEG.js +11 -0
- package/dist/chunk-QIWXRW72.js +2 -0
- package/dist/chunk-QJRMOK5N.js +2 -0
- package/dist/{chunk-YXPUP5G2.js → chunk-QOIXNWQR.js} +2 -2
- package/dist/chunk-QXEUDXBT.js +3 -0
- package/dist/chunk-QYUVVBMR.js +6 -0
- package/dist/chunk-QZ7KQZRN.js +2 -0
- package/dist/chunk-R6LQBUDH.js +2 -0
- package/dist/chunk-RBS42E55.js +20 -0
- package/dist/chunk-RSJKPCFX.js +26 -0
- package/dist/chunk-S6CZA3MV.js +2 -0
- package/dist/chunk-STMVAHJP.js +2 -0
- package/dist/chunk-SYVPTTVW.js +2 -0
- package/dist/chunk-T6DK3ZP7.js +2 -0
- package/dist/chunk-TKD34PHN.js +4 -0
- package/dist/chunk-TNNQFH7W.js +2 -0
- package/dist/chunk-TNV7SSUF.js +2 -0
- package/dist/chunk-TO7ZR3EH.js +8 -0
- package/dist/chunk-TOU3CHK4.js +2 -0
- package/dist/chunk-TRBI4UKT.js +2 -0
- package/dist/chunk-TZCVNCAN.js +4 -0
- package/dist/chunk-U4LZA5LL.js +3 -0
- package/dist/chunk-U5RIG3JP.js +3 -0
- package/dist/chunk-UP5KXN2I.js +2 -0
- package/dist/chunk-UQFR3NDH.js +5 -0
- package/dist/chunk-UXYXF7GV.js +2 -0
- package/dist/chunk-VB3GOKOS.js +2 -0
- package/dist/{chunk-4FR6GQIT.js → chunk-VF5JZICY.js} +2 -2
- package/dist/chunk-VTY3VK6E.js +2 -0
- package/dist/chunk-VX2O4RIS.js +2 -0
- package/dist/chunk-WKPV2TDZ.js +2 -0
- package/dist/chunk-WOFQ5DTB.js +2 -0
- package/dist/chunk-WS4C6TCK.js +2 -0
- package/dist/chunk-WXU3DGPU.js +2 -0
- package/dist/{chunk-ATXPTSEI.js → chunk-X6RMKHJQ.js} +7 -7
- package/dist/{chunk-44IETFOU.js → chunk-XHMN6ZX7.js} +2 -2
- package/dist/chunk-XHTVFLWW.js +2 -0
- package/dist/chunk-XKIDJCIK.js +2 -0
- package/dist/chunk-XTYTYZPT.js +2 -0
- package/dist/chunk-Y2JHHTTA.js +2 -0
- package/dist/chunk-YGVRMGYN.js +4 -0
- package/dist/chunk-YNQCGEQE.js +2 -0
- package/dist/chunk-YOQVEXVE.js +14 -0
- package/dist/chunk-YRT2WLYY.js +2 -0
- package/dist/chunk-YTAP5Y2G.js +2 -0
- package/dist/chunk-YTYWI7VB.js +2 -0
- package/dist/chunk-YULZRALL.js +2 -0
- package/dist/chunk-Z33WQG4Q.js +2 -0
- package/dist/chunk-ZGTYGDMF.js +16 -0
- package/dist/chunk-ZHMRSZFD.js +43 -0
- package/dist/chunk-ZHSP366W.js +10 -0
- package/dist/chunk-ZIBYCYKK.js +7 -0
- package/dist/chunk-ZLADLUE6.js +3 -0
- package/dist/chunk-ZO4YXUT6.js +4 -0
- package/dist/{chunk-MZPXPSUJ.js → chunk-ZR4HBC2H.js} +2 -2
- package/dist/cli-main.js +6 -6
- package/dist/cli.js +1 -1
- package/dist/{code-B17qEMbt.d.ts → code-BNyrCF3_.d.ts} +3 -2
- package/dist/code-IL5WH3NZ.js +2 -0
- package/dist/code-result-json-ANTBEDFP.js +4 -0
- package/dist/command-descriptors-HEEMDHTU.js +222 -0
- package/dist/deps-EOWFC6FD.js +2 -0
- package/dist/direct-navigation-Y5B6OSIQ.js +3 -0
- package/dist/{exploration-topology-BG4v30HZ.d.ts → exploration-topology-CSgEyAz-.d.ts} +3 -1
- package/dist/files-K4AI3JUM.js +2 -0
- package/dist/{health-BI2a9WPy.d.ts → health-BtfmNrfa.d.ts} +5 -79
- package/dist/hierarchy-6W5NDIFI.js +2 -0
- package/dist/imports-WH365QY4.js +2 -0
- package/dist/index.d.ts +13 -1
- package/dist/index.js +1 -1
- package/dist/members-K3PHMF5S.js +2 -0
- package/dist/methods-E7KVMBX4.js +2 -0
- package/dist/output-continuation-command-BJSY67SN.js +3 -0
- package/dist/output-pagination-UZJ5ACIX.js +24 -0
- package/dist/postinstall.js +1 -1
- package/dist/project-reindex-EP24WT4X.js +3 -0
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.d.ts +15 -4
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +1 -1
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +1 -0
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +3 -3
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +1 -1
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity.d.ts +6 -3
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/context.d.ts +1 -7
- package/dist/queries/context.js +1 -1
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/dependence-slice.d.ts +46 -22
- package/dist/queries/dependence-slice.js +1 -1
- package/dist/queries/dependency-depth.d.ts +1 -7
- package/dist/queries/dependency-depth.js +1 -1
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-impact.d.ts +3 -1
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +1 -1
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +1 -1
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/entry-map.d.ts +2 -4
- package/dist/queries/entry-map.js +1 -1
- package/dist/queries/evidence.d.ts +121 -61
- package/dist/queries/evidence.js +1 -1
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +1 -1
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +1 -1
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +1 -0
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +3 -3
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +15 -64
- package/dist/queries/index.js +1 -1
- package/dist/queries/locality-candidates.d.ts +4 -4
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -6
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +4 -14
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +4 -1
- package/dist/queries/refs.js +1 -1
- package/dist/queries/review.d.ts +188 -0
- package/dist/queries/review.js +2 -0
- package/dist/queries/similar-files.d.ts +7 -10
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +19 -1
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice-cohesion.d.ts +205 -0
- package/dist/queries/slice-cohesion.js +2 -0
- package/dist/queries/source-inspection.d.ts +6 -202
- package/dist/queries/source-inspection.js +1 -1
- package/dist/queries/source-search.d.ts +2 -3
- package/dist/queries/source-search.js +1 -1
- package/dist/queries/stats.d.ts +1 -0
- package/dist/queries/stats.js +1 -1
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +4 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +1 -1
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/twin-drift.d.ts +1 -1
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +3 -15
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/query-service-fastpath.js +5 -5
- package/dist/query-service-server.js +4 -4
- package/dist/refs-CCBJG7WK.js +2 -0
- package/dist/refs-pagination-DRNLVU4S.js +2 -0
- package/dist/reindex-worker.js +79 -29
- package/dist/reindex.js +45 -45
- package/dist/repository-cache-worker.js +2 -0
- package/dist/runtime.d.ts +8 -8
- package/dist/runtime.js +3 -4
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/service-queries-2WAJI7R6.js +6 -0
- package/dist/source-inspection-91U9zdO3.d.ts +341 -0
- package/dist/{source-search-types-Dwz8KeuW.d.ts → source-search-types-DWGYNg8M.d.ts} +15 -2
- package/dist/stats-G7DIV6VU.js +2 -0
- package/dist/surface-IO55UALI.js +2 -0
- package/dist/system-ZBMSHJXU.js +2 -0
- package/dist/{queries/trace.d.ts → trace-BMjw3prn.d.ts} +1 -18
- package/dist/typescript-indexer.js +2 -0
- package/dist/typescript-mailbox-worker.js +1 -1
- package/dist/watch-server.js +3 -3
- package/docs/AGENT_GUIDE.md +19 -128
- package/docs/CLI_JSON_OUTPUT.md +21 -17
- package/docs/COMMAND_REFERENCE.md +34 -49
- package/docs/CURRENT_COMMANDS.md +123 -0
- package/docs/DETECTOR_EVIDENCE_CONTRACTS.md +0 -40
- package/docs/DETECTOR_GUIDE.md +27 -23
- package/docs/PRODUCT_VISION.md +135 -0
- package/docs/PROPERTY_TESTING.md +73 -0
- package/docs/REVIEW.md +76 -0
- package/docs/SKILLS.md +51 -0
- package/docs/WINDOWS_SIDECAR_RELEASE.md +12 -3
- package/docs/accuracy-audit-checklist.md +34 -0
- package/docs/analyzer-inventory.md +2 -2
- package/package.json +18 -80
- package/scripts/evidence-product-contract.mjs +7 -3
- package/scripts/record-review-coverage.mjs +118 -0
- package/scripts/scip-windows-provenance.mjs +29 -19
- package/skills/scip-architecture-review/SKILL.md +57 -0
- package/skills/scip-architecture-review/agents/openai.yaml +4 -0
- package/skills/scip-architecture-review/references/design-checks.md +17 -0
- package/skills/scip-explore/SKILL.md +15 -59
- package/skills/scip-explore/agents/openai.yaml +3 -3
- package/skills/scip-explore/references/external-evidence.md +2 -2
- package/skills/scip-explore/references/information-model.md +26 -29
- package/skills/scip-explore/scripts/capture-evidence.mjs +68 -34
- package/skills/scip-integrity-audit/SKILL.md +53 -181
- package/skills/scip-integrity-audit/agents/openai.yaml +3 -3
- package/skills/scip-integrity-audit/references/integrity-probes.md +27 -0
- package/skills/scip-plan/SKILL.md +39 -65
- package/skills/scip-plan/agents/openai.yaml +2 -2
- package/skills/scip-query/SKILL.md +28 -81
- package/skills/scip-query/agents/openai.yaml +2 -2
- package/skills/scip-query/references/command-guide.md +169 -0
- package/skills/scip-setup/SKILL.md +4 -2
- package/skills/scip-setup/agents/openai.yaml +3 -3
- package/dist/by-kind-H3P6BR5G.js +0 -2
- package/dist/call-graph-VTG2CUOQ.js +0 -2
- package/dist/chunk-26CT72HM.js +0 -2
- package/dist/chunk-2BMSSRBH.js +0 -2
- package/dist/chunk-2M2LSIMY.js +0 -7
- package/dist/chunk-2N6WBNDC.js +0 -29
- package/dist/chunk-2OOY75BW.js +0 -2
- package/dist/chunk-2USA3S3P.js +0 -3
- package/dist/chunk-2VAHDDLM.js +0 -133
- package/dist/chunk-2XWIUW5Z.js +0 -455
- package/dist/chunk-35NLDRZC.js +0 -2
- package/dist/chunk-3AF4TUFK.js +0 -3
- package/dist/chunk-3D4BOXW6.js +0 -20
- package/dist/chunk-3LO4FST5.js +0 -16
- package/dist/chunk-3WTY4LP2.js +0 -3
- package/dist/chunk-3Z5AMSK6.js +0 -29
- package/dist/chunk-4KBTHJLP.js +0 -2
- package/dist/chunk-5BIKR67W.js +0 -2
- package/dist/chunk-5PROPLHI.js +0 -2
- package/dist/chunk-5V7EPTII.js +0 -2
- package/dist/chunk-62LPZCBQ.js +0 -3
- package/dist/chunk-64O2JHQA.js +0 -2
- package/dist/chunk-6D4F5VWG.js +0 -10
- package/dist/chunk-6ERFBC3X.js +0 -3
- package/dist/chunk-6MFXCMZC.js +0 -2
- package/dist/chunk-6O7FACKB.js +0 -2
- package/dist/chunk-6TS3KOXR.js +0 -2
- package/dist/chunk-76QOU4PK.js +0 -3
- package/dist/chunk-7DUI77BN.js +0 -2
- package/dist/chunk-7F45LJKI.js +0 -2
- package/dist/chunk-7F7T6DCR.js +0 -2
- package/dist/chunk-7H6VHWWJ.js +0 -2
- package/dist/chunk-7HXT6YLU.js +0 -5
- package/dist/chunk-7KCZELVM.js +0 -2
- package/dist/chunk-7R4V5ES6.js +0 -6
- package/dist/chunk-7RIRIADH.js +0 -7
- package/dist/chunk-7ZLWLOGT.js +0 -2
- package/dist/chunk-AADQLOQ4.js +0 -38
- package/dist/chunk-AN76MGUE.js +0 -2
- package/dist/chunk-ANLNLY66.js +0 -2
- package/dist/chunk-AX7IDVFT.js +0 -2
- package/dist/chunk-B3X6KU75.js +0 -2
- package/dist/chunk-B7MPDEAK.js +0 -3
- package/dist/chunk-BBB5FBX4.js +0 -2
- package/dist/chunk-BJT7LSPK.js +0 -3
- package/dist/chunk-BJWFVAA5.js +0 -2
- package/dist/chunk-BKVWUP7Y.js +0 -2
- package/dist/chunk-BKZYTLGE.js +0 -35
- package/dist/chunk-BL6DCHQP.js +0 -2
- package/dist/chunk-BOW7SSQH.js +0 -43
- package/dist/chunk-C4RHHCKL.js +0 -7
- package/dist/chunk-C7C6AKAT.js +0 -117
- package/dist/chunk-CD6M6LS2.js +0 -16
- package/dist/chunk-CFE6PSG6.js +0 -2
- package/dist/chunk-CFNIGQMT.js +0 -2
- package/dist/chunk-CKBUBRYD.js +0 -2
- package/dist/chunk-CZW5MZ5B.js +0 -2
- package/dist/chunk-DBBZ63ZX.js +0 -2
- package/dist/chunk-DBN7DMJB.js +0 -18
- package/dist/chunk-DUULLZHZ.js +0 -3
- package/dist/chunk-DV5Y5NOS.js +0 -2
- package/dist/chunk-DZOIKCTM.js +0 -3
- package/dist/chunk-E4PKTOL3.js +0 -2
- package/dist/chunk-E7QR35ST.js +0 -2
- package/dist/chunk-EFSXAINW.js +0 -2
- package/dist/chunk-EHVEIEQN.js +0 -18
- package/dist/chunk-EHYDXE3Z.js +0 -2
- package/dist/chunk-EP63Y6LD.js +0 -2
- package/dist/chunk-EPX6NQN6.js +0 -4
- package/dist/chunk-ETC674NS.js +0 -5
- package/dist/chunk-F5GSBHC6.js +0 -3
- package/dist/chunk-FH3DGXC6.js +0 -2
- package/dist/chunk-FI7VGOR4.js +0 -16
- package/dist/chunk-FJF6VO2P.js +0 -2
- package/dist/chunk-FLMTCX5R.js +0 -2
- package/dist/chunk-FVFDOIM3.js +0 -2
- package/dist/chunk-G2HU5WRN.js +0 -2
- package/dist/chunk-G4ALYS4J.js +0 -2
- package/dist/chunk-G56I7K4W.js +0 -26
- package/dist/chunk-GC4DG2V5.js +0 -2
- package/dist/chunk-GG45PK4S.js +0 -4
- package/dist/chunk-GINH3YQU.js +0 -20
- package/dist/chunk-GTZZVLKJ.js +0 -2
- package/dist/chunk-GXXW5ZHH.js +0 -2
- package/dist/chunk-H5EXS3HM.js +0 -2
- package/dist/chunk-HAXXKRTD.js +0 -4
- package/dist/chunk-HEZWBAZY.js +0 -2
- package/dist/chunk-HMEWLMML.js +0 -2
- package/dist/chunk-HOBOVYPO.js +0 -11
- package/dist/chunk-HRFQ6GW5.js +0 -8
- package/dist/chunk-HX4X7KG3.js +0 -2
- package/dist/chunk-HYT2R7LX.js +0 -4
- package/dist/chunk-IKQVBVQL.js +0 -40
- package/dist/chunk-IW5XQG5G.js +0 -2
- package/dist/chunk-J6GLBBRK.js +0 -4
- package/dist/chunk-J7A4PWFX.js +0 -3
- package/dist/chunk-JCSAZ35V.js +0 -2
- package/dist/chunk-JDU2IV3A.js +0 -2
- package/dist/chunk-JFMEXGFE.js +0 -2
- package/dist/chunk-JFMI5SGB.js +0 -4
- package/dist/chunk-JJP37RGX.js +0 -57
- package/dist/chunk-JZ2A7LDM.js +0 -5
- package/dist/chunk-KMVGRIO2.js +0 -2
- package/dist/chunk-KNLQGXVH.js +0 -80
- package/dist/chunk-KVQCECPR.js +0 -2
- package/dist/chunk-KXXORBZ2.js +0 -4
- package/dist/chunk-L5KYH6U3.js +0 -35
- package/dist/chunk-L6XHYJPZ.js +0 -21
- package/dist/chunk-L7KTFEAV.js +0 -43
- package/dist/chunk-LDXHR5EL.js +0 -23
- package/dist/chunk-LEECKFCJ.js +0 -2
- package/dist/chunk-MHGDSBFX.js +0 -2
- package/dist/chunk-MLQVVDG3.js +0 -74
- package/dist/chunk-MOKUWRHO.js +0 -3
- package/dist/chunk-MPYAPMNE.js +0 -2
- package/dist/chunk-MTDBHTSF.js +0 -2
- package/dist/chunk-MV6SPXCR.js +0 -7
- package/dist/chunk-MWN53KRN.js +0 -60
- package/dist/chunk-MXNGIEPU.js +0 -3
- package/dist/chunk-N55KIE46.js +0 -2
- package/dist/chunk-NB4D3BNM.js +0 -2
- package/dist/chunk-NGKBOT6G.js +0 -23
- package/dist/chunk-NJGKXKQF.js +0 -2
- package/dist/chunk-NJQISBL4.js +0 -8
- package/dist/chunk-NJT3ZEKY.js +0 -16
- package/dist/chunk-NKMKZP6A.js +0 -2
- package/dist/chunk-NODFZ6ED.js +0 -2
- package/dist/chunk-NSM5IEVW.js +0 -2
- package/dist/chunk-NTGUVNR2.js +0 -3
- package/dist/chunk-NU3KFF2O.js +0 -57
- package/dist/chunk-NWLVNU66.js +0 -557
- package/dist/chunk-NYKZMCRC.js +0 -4
- package/dist/chunk-O6BUXZEH.js +0 -6
- package/dist/chunk-ODPDP7A4.js +0 -3
- package/dist/chunk-OIAPEKMT.js +0 -3
- package/dist/chunk-OIOC5EHF.js +0 -3
- package/dist/chunk-ONPPQM4G.js +0 -2
- package/dist/chunk-OUHEZBYI.js +0 -2
- package/dist/chunk-OVGYW7UD.js +0 -29
- package/dist/chunk-OYKU4B3Y.js +0 -2
- package/dist/chunk-POBJ6FR2.js +0 -5
- package/dist/chunk-PSZPMMWN.js +0 -2
- package/dist/chunk-PXTRBKRK.js +0 -3
- package/dist/chunk-Q5JRIHT3.js +0 -4
- package/dist/chunk-Q7ATHARX.js +0 -2
- package/dist/chunk-Q7CSKIDM.js +0 -5
- package/dist/chunk-QBQE7ZJ5.js +0 -3
- package/dist/chunk-QH22UIXP.js +0 -5
- package/dist/chunk-QXCKQTKR.js +0 -60
- package/dist/chunk-RBAD4GJ2.js +0 -13
- package/dist/chunk-RMDPFPNW.js +0 -2
- package/dist/chunk-ROPJDEJZ.js +0 -4
- package/dist/chunk-RVZC6TJE.js +0 -2
- package/dist/chunk-S4QZBKSR.js +0 -3
- package/dist/chunk-SCPMZ73U.js +0 -2
- package/dist/chunk-SIAP5RGI.js +0 -73
- package/dist/chunk-SIX4RFR3.js +0 -3
- package/dist/chunk-SKKXTABJ.js +0 -16
- package/dist/chunk-SSRFUQBD.js +0 -2
- package/dist/chunk-SYVJEEUJ.js +0 -3
- package/dist/chunk-T3CZAZSI.js +0 -8
- package/dist/chunk-T6DWDI5E.js +0 -3
- package/dist/chunk-T6HRIROJ.js +0 -7
- package/dist/chunk-TAA7HXHE.js +0 -2
- package/dist/chunk-TJ2JQYT3.js +0 -2
- package/dist/chunk-TULNMD5T.js +0 -368
- package/dist/chunk-U2FPY5XA.js +0 -3
- package/dist/chunk-U3SXIMII.js +0 -38
- package/dist/chunk-U6KCHXJ4.js +0 -2
- package/dist/chunk-UH3XSKS5.js +0 -9
- package/dist/chunk-UIFUZVCC.js +0 -2
- package/dist/chunk-UXKURIVI.js +0 -2
- package/dist/chunk-V2RBODHL.js +0 -2
- package/dist/chunk-VBKUWB6N.js +0 -2
- package/dist/chunk-VBV6ALJE.js +0 -2
- package/dist/chunk-VDGFWCQV.js +0 -2
- package/dist/chunk-VDSDOEWF.js +0 -2
- package/dist/chunk-VZPWVCLN.js +0 -20
- package/dist/chunk-WDSFQDPN.js +0 -2
- package/dist/chunk-WFA35BGR.js +0 -7
- package/dist/chunk-WLMP3OCW.js +0 -2
- package/dist/chunk-WSA52GOR.js +0 -2
- package/dist/chunk-WYPL7GF7.js +0 -2
- package/dist/chunk-X3YVZAKZ.js +0 -5
- package/dist/chunk-X6OGVFIT.js +0 -2
- package/dist/chunk-XDAUYDFT.js +0 -2
- package/dist/chunk-XKXTR6ZI.js +0 -9
- package/dist/chunk-Y5DFAW5W.js +0 -4
- package/dist/chunk-YSYPDRD5.js +0 -3
- package/dist/chunk-ZFVPWH62.js +0 -5
- package/dist/chunk-ZGIHTH27.js +0 -2
- package/dist/chunk-ZGIQN2SX.js +0 -2
- package/dist/chunk-ZHG4WAHR.js +0 -12
- package/dist/chunk-ZKB2XUEN.js +0 -4
- package/dist/chunk-ZLMXIQLC.js +0 -21
- package/dist/chunk-ZMCQIHI4.js +0 -2
- package/dist/code-TAVIKWJI.js +0 -2
- package/dist/code-result-json-5FEFQCAQ.js +0 -2
- package/dist/command-descriptors-7BKH53Y3.js +0 -343
- package/dist/dataflow-GFBTVDH3.js +0 -2
- package/dist/dependence-slice-GWGQCODG.js +0 -2
- package/dist/deps-4QHVDPYA.js +0 -2
- package/dist/direct-navigation-4UBC6HNW.js +0 -3
- package/dist/entry-map-QCTF4RVY.js +0 -2
- package/dist/files-M2UBF5HJ.js +0 -2
- package/dist/graph-evidence-Bjyky2V4.d.ts +0 -126
- package/dist/hierarchy-2UIHRLW4.js +0 -2
- package/dist/imports-WIE3YZOB.js +0 -2
- package/dist/members-YKD636DA.js +0 -2
- package/dist/methods-VDF4IMYG.js +0 -2
- package/dist/next-anchor-candidates-BwMczMvX.d.ts +0 -90
- package/dist/output-continuation-command-4UMDOOLO.js +0 -3
- package/dist/output-pagination-2GME6OPY.js +0 -19
- package/dist/project-reindex-XEQTRCV5.js +0 -3
- package/dist/queries/anchors.d.ts +0 -123
- package/dist/queries/anchors.js +0 -2
- package/dist/queries/complexity-hotspots.d.ts +0 -40
- package/dist/queries/complexity-hotspots.js +0 -2
- package/dist/queries/convergence.d.ts +0 -33
- package/dist/queries/convergence.js +0 -2
- package/dist/queries/dataflow.d.ts +0 -77
- package/dist/queries/dataflow.js +0 -2
- package/dist/queries/deep-chains.d.ts +0 -5
- package/dist/queries/deep-chains.js +0 -2
- package/dist/queries/extract-candidates.d.ts +0 -79
- package/dist/queries/extract-candidates.js +0 -2
- package/dist/queries/isolated.d.ts +0 -24
- package/dist/queries/isolated.js +0 -2
- package/dist/queries/plan-context.d.ts +0 -33
- package/dist/queries/plan-context.js +0 -2
- package/dist/queries/reference-neighborhood.d.ts +0 -4
- package/dist/queries/reference-neighborhood.js +0 -2
- package/dist/queries/reference-reachability.d.ts +0 -48
- package/dist/queries/reference-reachability.js +0 -2
- package/dist/queries/self-audit.d.ts +0 -69
- package/dist/queries/self-audit.js +0 -2
- package/dist/queries/similar-chains.d.ts +0 -48
- package/dist/queries/similar-chains.js +0 -2
- package/dist/queries/slice.d.ts +0 -4
- package/dist/queries/slice.js +0 -2
- package/dist/queries/stale-abstractions.d.ts +0 -72
- package/dist/queries/stale-abstractions.js +0 -2
- package/dist/queries/system-map.d.ts +0 -449
- package/dist/queries/system-map.js +0 -2
- package/dist/queries/trace.js +0 -2
- package/dist/queries/twin-ab.d.ts +0 -66
- package/dist/queries/twin-ab.js +0 -2
- package/dist/queries/value-flow.d.ts +0 -43
- package/dist/queries/value-flow.js +0 -2
- package/dist/queries/wrapper-candidates.d.ts +0 -49
- package/dist/queries/wrapper-candidates.js +0 -2
- package/dist/refs-JNK5CLM7.js +0 -2
- package/dist/refs-pagination-6BLRYGMV.js +0 -2
- package/dist/slice-PHPVNCWX.js +0 -2
- package/dist/source-snippet-_wrcgmZc.d.ts +0 -15
- package/dist/stats-OOJ74B32.js +0 -2
- package/dist/surface-MQX5MPIV.js +0 -2
- package/dist/symbol-resolution-DBLVXLBC.js +0 -2
- package/dist/system-JOPKV4OG.js +0 -2
- package/dist/trace-I2P2YFH4.js +0 -2
- package/dist/value-flow-JJVMF7NP.js +0 -2
- package/skills/concrete-plan/SKILL.md +0 -8
- package/skills/concrete-plan/agents/openai.yaml +0 -4
- package/skills/conductor/SKILL.md +0 -110
- package/skills/conductor/agents/openai.yaml +0 -4
- package/skills/principal-maintainability-review/SKILL.md +0 -273
- package/skills/principal-maintainability-review/agents/openai.yaml +0 -4
- package/skills/scip-calibrate/SKILL.md +0 -102
- package/skills/scip-calibrate/agents/openai.yaml +0 -4
- package/skills/scip-claim-audit/SKILL.md +0 -113
- package/skills/scip-claim-audit/agents/openai.yaml +0 -4
- package/skills/scip-probe-reachability/SKILL.md +0 -93
- package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
- package/skills/scip-root-cause/SKILL.md +0 -160
- package/skills/scip-root-cause/agents/openai.yaml +0 -4
- package/skills/scip-system-compression/SKILL.md +0 -252
- package/skills/scip-system-compression/agents/openai.yaml +0 -4
- package/skills/scip-system-compression/references/compression-atlas.md +0 -116
- package/skills/scip-system-compression/references/compression-patterns.md +0 -87
- package/skills/scip-twin-drift/SKILL.md +0 -109
- package/skills/scip-twin-drift/agents/openai.yaml +0 -4
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as ne}from"./chunk-P5XHIJHI.js";import{a as Dt,i as vt,j as ge,k as $,l as Oe,m as te,n as re,o as Ue,q as mn,r as qe,s as Pt,t as yn,v as Sn,w as gn,x as kt}from"./chunk-73AAKPUC.js";import{a as Be,b as ie,c as Ct,e as Tt,f as wt,g as je,h as We}from"./chunk-KZBJWZJB.js";import{d as Mt}from"./chunk-KK7GPALL.js";import{a as Te,b as we,c as Ee,d as Fe,e as O,o as xt}from"./chunk-DA7RPPDF.js";import{b as ht,e as V,h as Le,j as It,l as Se,x as B,y as ee}from"./chunk-5D2LVK7O.js";import{a as ye,g as _e,q as Rt,s as bt}from"./chunk-7WTPQ4NX.js";import{A as St,O as gt,a as Ae,c as pt,d as mt,q as dn}from"./chunk-FVULPZDF.js";import{g as pn,h as me,i as K}from"./chunk-D3FDISIC.js";import{c as fn,e as Z,n as ft,p as dt,q as A,s as yt,t as C,v as Ne}from"./chunk-GVWX5T43.js";import{a as de,d as F}from"./chunk-T6DK3ZP7.js";import{Ca as ut,Da as un,Q as ln,ma as st,o as it,p as z,q as Pe,qa as at,ra as pe,t as ke,u as L,ua as ct,v as ot,z as cn,za as lt}from"./chunk-5TNQJUR2.js";import{randomUUID as Yi}from"crypto";import{existsSync as Ji}from"fs";import{dirname as rr}from"path";function li(n){return(n.tsconfigPath===void 0||typeof n.tsconfigPath=="string")&&(n.tsconfigPaths===void 0||Array.isArray(n.tsconfigPaths)&&n.tsconfigPaths.every(e=>typeof e=="string"))}function ui(n){return typeof n.available=="boolean"&&(n.dependencyAvailable===void 0||typeof n.dependencyAvailable=="boolean")&&li(n)&&(n.resolvedBinary===void 0||typeof n.resolvedBinary=="string")&&(n.note===void 0||typeof n.note=="string")}function Et(n){if(!n||typeof n!="object"||Array.isArray(n))return null;let e=n;if(!ui(e))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 E(n,e,t){if(n.has(e))return n.get(e);let r=t();return n.set(e,r),r}import Nt from"path";import{realpathSync as Ft}from"fs";function fi(n,e){return n.getReferences().map(t=>{let r=t.getNode();return He(r,e)})}function di(n){let e=n;return typeof e.findReferences=="function"?e.findReferences():[]}function _t(n,e,t,r){let i=[];for(let o of di(n))for(let s of fi(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 oe(i)}function Lt(n,e,t,r){let i=[],o=t?.getStart();for(let s of n.getReferences()){let a=s.getNode();se(r,a.getSourceFile().getFilePath())===e&&(o!==void 0&&a.getStart()===o||i.push({location:He(a,r),node:a}))}return i}function He(n,e){let t=n.getSourceFile(),r=t.getLineAndColumnAtPos(n.getStart());return{file:se(e,t.getFilePath())??t.getBaseName(),line:r.line-1,column:r.column-1}}function Ot(n,e,t){let r=n.getSourceFile(),i=bn(r,n),o=n.getText(),s=new RegExp(`\\b${ye(o)}\\b`,"g"),a=r.getFullText().split(`
|
|
2
|
+
`),c=[];for(let u=0;u<a.length;u++){if(u===i)continue;let l=a[u]??"";s.lastIndex=0;let f;for(;(f=s.exec(l))!==null;)c.push({file:e,line:u,column:f.index})}return oe(c.filter(u=>se(t,Nt.join(t,u.file))===e))}function Rn(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 oe(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 se(n,e){let t=n||process.cwd(),r=At(t,e);if(r)return r;try{return At(Ft(t),Ft(e))}catch{return null}}function At(n,e){let t=Nt.relative(n,e).replace(/\\/g,"/");return!t||t===".."||t.startsWith("../")?null:t}function Ut(n,e,t,r){let i=pi(e,r);return i.size===0?new Map:mi(n,t,i)}function pi(n,e){let t=new Map;for(let r of B(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 mi(n,e,t){let r=new Map,i=new Map;return e.forEachDescendant(o=>{for(let s of yi(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 l=Math.abs(c-u.startLine),f=i.get(u.symbolId);f!==void 0&&f<=l||(i.set(u.symbolId,l),r.set(u.symbolId,o))}}}),r}function yi(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}function hn(n,e,t){let r=new Map,i=new Set,o=s=>{if(n.isFunctionLike(s)){let a=Si(n,s),u=a.name?.getText(e)??(n.isConstructorDeclaration(s)?"constructor":void 0),l=e.getLineAndCharacterOfPosition(a.getStart(e)),f=t.filter(d=>!i.has(d.symbolId)&&d.leaf===u&&Ri(d,l));f.length===1&&(r.set(s,f[0]),i.add(f[0].symbolId))}n.forEachChild(s,o)};return o(e),s=>{for(let a=s.parent;a;a=a.parent)if(n.isFunctionLike(a))return r.get(a)}}function Si(n,e){if(!n.isArrowFunction(e)&&!n.isFunctionExpression(e))return e;let t=e;for(;t.parent&&gi(n,t.parent);)t=t.parent;let r=t.parent;return r&&(n.isVariableDeclaration(r)||n.isPropertyDeclaration(r)||n.isPropertyAssignment(r))&&r.initializer===t?r:e}function gi(n,e){return n.isParenthesizedExpression(e)||n.isAsExpression(e)||n.isSatisfiesExpression(e)}function Ri(n,e){return e.line<n.startLine||e.line>n.endLine||e.line===n.startLine&&e.character<(n.startChar??0)?!1:e.line!==n.endLine||e.character<=(n.endChar??1/0)}var bi=ut("ts-definition-leaf-candidates",{clearGroups:["definition-catalog"]});function qt(n,e,t,r){let i=Dn(n,e),o=In(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 In(s,t)}function Mn(n,e,t,r){return In(Dn(n,e).get(r)??[],t)}function Bt(n,e){let t=new Map;for(let[r,i]of Dn(n,e)){let o=i[0];o&&t.set(r,o)}return t}function Dn(n,e){return bi.get(n,e,()=>{let t=new Map;for(let r of B(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 In(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 hi from"path";import{realpathSync as Ii}from"fs";function Wt(n,e){let t=new Map,r=new Map,i=null,o=()=>(i??=Ae(n,{extensions:Be}),i),s=u=>E(r,u,()=>C("typescript.source-file-index",()=>{let l=new Map;for(let f of u.project.getSourceFiles())jt(l,f);return{project:u.project,sourceFiles:l}},()=>({tsconfigPath:u.tsconfigPath,indexedDocuments:o().length}))),a=(u,l)=>{let f=s(u),d=f.sourceFiles.get(l)??null;return d||(d=u.project.addSourceFileAtPathIfExists(l)??null,d&&jt(f.sourceFiles,d)),d?{project:f.project,sourceFile:d}:null},c=u=>ie(u)?E(t,u,()=>{let l=Mi(n.config.projectRoot,u);if(!l)return null;for(let m of e){if(!m.loaded)continue;let p=s(m).sourceFiles.get(l);if(p)return{project:m.project,sourceFile:p}}let f=e.find(m=>m.fileNames?.has(l));if(f)return a(f,l);for(let m of e){if(!m.loaded)continue;let p=a(m,l);if(p)return p}let d=e[0];return d?a(d,l):null}):null;return{sourceFile:u=>c(u)?.sourceFile??null,sourceFileMatch:c,indexedTypeScriptLikeDocuments:o}}function jt(n,e){let t=vn(e.getFilePath());n.set(t,e);try{n.set(vn(Ii(t)),e)}catch(r){if(!pe(r))throw r}}function Mi(n,e){try{return vn(st(n,e,{inputKind:"indexed TypeScript source file"}).absolutePath)}catch(t){if(!pe(t))throw t;return null}}function vn(n){return hi.resolve(n)}function xn(n,e){for(let t of n)if(e===t.name||e.startsWith(`${t.name}/`))return t.name;return null}function Ht(n){let e=`${n.relativeDir}/src`;return[`${e}/index.ts`,`${e}/index.tsx`,`${e}/index.mts`,`${e}/index.cts`]}import{existsSync as Re}from"fs";import k from"path";var Cn=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"];function Tn(n,e){let r=e?k.dirname(k.join(n,e)):n,i=k.resolve(n);for(;r.startsWith(i);){for(let s of Cn){let a=k.join(r,s);if(Re(a))return a}let o=k.dirname(r);if(o===r)break;r=o}for(let o of Cn){let s=k.join(n,o);if(Re(s))return s}return null}function zt(n){let e=n.config.projectRoot,t=new Set(Di(e,n.config.semantic?.typescript?.tsconfigs)),r=Ae(n,{includeIgnored:!1,extensions:Be});for(let i of r){let o=Tn(e,i);o&&t.add(k.resolve(o))}if(t.size===0){let i=Tn(e);i&&t.add(k.resolve(i))}return[...t].filter(i=>!Kt(e,i)).sort((i,o)=>i.localeCompare(o))}function Di(n,e=[]){let t=new Set;for(let r of e){let i=k.isAbsolute(r)?r:k.join(n,r);Re(i)&&t.add(k.resolve(i))}for(let r of vi(n))for(let i of Cn){let o=k.join(r,i);Re(o)&&t.add(k.resolve(o))}if(t.size===0){let r=Tn(n);r&&t.add(k.resolve(r))}return[...t].filter(r=>!Kt(n,r)).sort((r,i)=>r.localeCompare(i))}function vi(n){let e=k.join(n,"package.json");if(!Re(e))return[];let t;try{t=JSON.parse(ot(e,"project package manifest"))}catch{return[]}return(Array.isArray(t.workspaces)?t.workspaces:t.workspaces?.packages??[]).flatMap(i=>mt(n,i))}function Kt(n,e){let t=k.relative(n,e).replace(/\\/g,"/");return t.startsWith("..")||t.includes("/node_modules/")||t.startsWith("node_modules/")||t.includes("/dist/")||t.startsWith("dist/")}var xi=32;function Xt(n,e){let t=C("typescript.provider.load",()=>Ct());if(!t)return We("ts-morph is not installed");let r=C("typescript.provider.tsconfig-discovery",()=>zt(n));if(r.length===0)return We("no tsconfig found");try{let i=C("typescript.provider.project-bundles",()=>Tt(t,r),()=>({tsconfigs:r.length}));return Ci(n,t,i)}catch(i){return We(i instanceof Error?i.message:String(i),r[0],r)}}function Ci(n,e,t,r={}){return C("typescript.provider.construct",()=>new wn(n,e,t),()=>({tsconfigs:t.length,reusedProjects:r.reusedProjects===!0}))}var wn=class{constructor(e,t,r){this.db=e;this.tsMorph=t;this.projects=r;this.workspacePackages=pt(e.config.projectRoot),this.sourceFiles=Wt(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;packageImportReferenceIndex=null;packageExportIndex=null;workspacePackages;sourceFiles;availability(){let e=je(this.projects);return{available:!0,tsconfigPath:this.projects[0]?.tsconfigPath,tsconfigPaths:this.projects.map(t=>t.tsconfigPath),projectScope:e?"file-closure":"project",...e?{note:"compiler projects are file-scoped: callees, signatures, and import usage are served per file; references and hierarchies are unavailable"}:{}}}attachBatchFiles(e){if(je(this.projects))for(let t of new Set(e.map(r=>r.relativePath)))this.sourceFiles.sourceFile(t)}assertProjectWide(){if(je(this.projects))throw new Error(wt)}importUsage(e){return E(this.importUsageCache,e,()=>{let t=this.sourceFiles.sourceFile(e);if(!t)return[];let r=wi();return C("typescript.import-usage.file",()=>this.importUsageForSourceFile(e,t,r),()=>({file:e,...r}))})}referencesFor(e){return E(this.referencesCache,e.symbolId,()=>{let t=this.nodeForDefinition(e);return this.referencesForDefinitionNode(e,t)})}referencesForDefinitions(e,t={}){this.assertProjectWide();let r=new Map,i=A(),o=[];for(let l of e){let f=this.referencesCache.get(l.symbolId);f?r.set(l.symbolId,f):o.push(l)}if(o.length===0)return r;let s=o,a=t.exact?[]:o.filter(l=>!$t(l));if(a.length>=xi){let l=this.referencesForDefinitionsBySymbolScan(a);if(this.cacheScannedReferenceResults(a,l,r),s=o.filter(f=>$t(f)),s.length===0)return r}let c=qi(s),u=[];for(let[l,f]of c){let d=Yt();C("typescript.references-map.file",()=>{let m=this.definitionNodesForFile(l);for(let p of f){i&&(d.cacheMisses+=1);let y=m.get(p.symbolId)??null;i&&(y?d.nodeHits+=1:d.nodeMisses+=1);try{let b=this.referencesForDefinitionNode(p,y,i?d:void 0);this.referencesCache.set(p.symbolId,b),r.set(p.symbolId,b)}catch{d.preciseSearchFailures+=1,u.push(p)}}},()=>({relativePath:l,definitions:f.length,...Gt(d)}))}if(u.length>0){let l=this.referencesForDefinitionsBySymbolScan(u);this.cacheScannedReferenceResults(u,l,r)}return r}cacheScannedReferenceResults(e,t,r){for(let i of e){let o=t.get(i.symbolId)??[];this.referencesCache.set(i.symbolId,o),r.set(i.symbolId,o)}}referenceFragmentsForFiles(e){this.assertProjectWide();let t=ee(this.db).filter(o=>ie(o.relativePath)),r=e.filter(o=>this.sourceFiles.sourceFile(o)!==null),i=this.referencesForDefinitionsBySymbolScan(t,r);return Pt(t,i,r)}referencesForDefinitionsBySymbolScan(e,t){let r=A(),i=Yt(),o=new Map,s=new Set(e.map(l=>l.symbolId)),a=new Map(e.map(l=>[l.symbolId,l]));for(let l of e)o.set(l.symbolId,[]);let c=()=>{let l=r?x.now():0,f=t?this.packageImportReferencesForFiles(t):this.packageImportReferences();for(let d of e){let m=f.get(d.symbolId)??[];if(m.length>0){let p=o.get(d.symbolId)??[];p.push(...m),o.set(d.symbolId,p)}r&&(i.packageReferenceCount+=m.length)}r&&(i.packageRefsMs+=x.now()-l)},u=()=>{let l=new Map,f=new Map,d=this.hierarchyTargetsForDefinitions(e),m=new Set(e.map(y=>y.leaf).filter(Boolean)),p=r?x.now():0;for(let y of t??this.sourceFiles.indexedTypeScriptLikeDocuments()){if(this.db.isIgnored(y))continue;let b=this.sourceFiles.sourceFile(y);b&&(r&&(i.scanFiles+=1),this.addReferencesFromSourceFileScan(b,y,s,a,d,m,l,f,o,r?i:void 0))}r&&(i.scanMs+=x.now()-p)};return C("typescript.references-map.inverted-scan",()=>{c(),u();let l=r?x.now():0;this.addHierarchyMemberReferences(e,o,r?i:void 0),r&&(i.hierarchyMs+=x.now()-l);for(let[f,d]of o){let m=oe(d);o.set(f,m),r&&(i.referenceCount+=m.length)}},()=>({definitions:e.length,...Gt(i)})),o}addReferencesFromSourceFileScan(e,t,r,i,o,s,a,c,u,l){let f=this.compilerCheckerForSourceFile(e),d=e.compilerNode,m=Ei(e),p=S=>{let g;return a.has(S)?g=a.get(S)??null:(g=this.referenceDefinitionFromCompilerSymbol(S),a.set(S,g)),l&&(g?l.targetHits+=1:l.targetMisses+=1),g},y=S=>{if(l&&(l.identifiers+=1),!s.has(S.text)&&!m.has(S.text))return;let g=this.compilerReferenceSymbol(f,S,l);if(!g)return;let D=p(g),P=E(c,g,()=>this.compilerSymbolKeys(g)),M=null,T=null,v=I=>{if(M??=Vt(d,S),Fi(I,t,M))return;if(!T){let w=d.getLineAndCharacterOfPosition(S.getStart(d));T={file:t,line:w.line,column:w.character}}let R=u.get(I.symbolId)??[];R.push(T),u.set(I.symbolId,R),l&&(l.requestedHits+=1)},h=Wi(D,r,i);h&&v(h);for(let I of P)for(let R of o.get(I)?.values()??[])v(R)},b=S=>{this.tsMorph.ts.isIdentifier(S)&&y(S),this.tsMorph.ts.forEachChild(S,b)};b(d)}hierarchyTargetsMemo=null;hierarchyTargetsForDefinitions(e){let t=Li(e);if(this.hierarchyTargetsMemo?.key===t)return this.hierarchyTargetsMemo.targets;let r=Z(this.db),i=`definitions:${t}`,o=!1,s=C("typescript.references-map.hierarchy-targets",()=>{if(r){let c=Jt.read(this.db,i,r);if(c&&c.projectRoot===this.db.config.projectRoot)return o=!0,_i(c,e)}let a=this.computeHierarchyTargets(e);return r&&Jt.write(this.db,i,r,{version:Zt,projectRoot:this.db.config.projectRoot,entries:[...a].map(([c,u])=>[c,[...u.values()].map(l=>l.symbol)])}),a},()=>({definitions:e.length,hit:o}));return this.hierarchyTargetsMemo={key:t,targets:s},s}computeHierarchyTargets(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 l of this.compilerSymbolKeys(u)){let f=t.get(l)??new Map;f.set(r.symbolId,r),t.set(l,f)}}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 l of u){let f=l.getProperty(r.name);f&&s(l,f,this.hierarchyAncestorTypesForType(e,l))}}};return s(e.getTypeAtLocation(t),r,this.hierarchyAncestorTypes(e,t)),i}addHierarchyMemberReferences(e,t,r){let i=new Map,o=(c,u,l,f)=>{for(let d of this.hierarchyMemberSymbols(u,l,f))if(d!==f)for(let m of this.compilerSymbolLocations(d))c.push(m),r&&(r.hierarchyReferences+=1)},s=c=>{let u=this.nodeForDefinition(c),l=u?.compilerNode;if(!l||!this.isHierarchyMethod(l))return;let f=l.parent;if(!this.isHierarchyContainer(f))return;let d=this.compilerCheckerForSourceFile(u.getSourceFile()),m=d.getSymbolAtLocation(l.name);if(!m)return;let p=l.getSourceFile(),y=p.getLineAndCharacterOfPosition(l.name.getStart(p)),b={definition:c,location:{file:c.relativePath,line:y.line,column:y.character}},S=t.get(c.symbolId)??[];o(S,d,f,m),t.set(c.symbolId,S);let g=this.hierarchyRootMemberSymbols(d,f,m);for(let D of g){let P=i.get(D)??new Map;P.set(c.symbolId,b),i.set(D,P)}r&&(r.hierarchyDefinitions+=1)},a=c=>{for(let{definition:u}of c.values()){let l=t.get(u.symbolId)??[];for(let f of c.values())f.definition.symbolId!==u.symbolId&&(l.push(f.location),r&&(r.hierarchyReferences+=1));t.set(u.symbolId,l)}};for(let c of e)s(c);for(let c of i.values())c.size<2||(r&&(r.hierarchyFamilies+=1),a(c))}hierarchyRootMemberSymbols(e,t,r){let i=new Set,o=new Set,s=(a,c,u)=>{if(o.has(a))return;o.add(a);let l=!1;for(let f of u){let d=f.getProperty(r.name);d&&(l=!0,s(f,d,this.hierarchyAncestorTypesForType(e,f)))}if(!l)for(let f of this.compilerSymbolKeys(c))i.add(f)};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=se(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){r&&(r.symbolLookups+=1);let i=e.getSymbolAtLocation(t);if(i){if((i.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return i;try{return r&&(r.aliasResolutions+=1),e.getAliasedSymbol(i)}catch{return i}}}calleesFor(e){return E(this.calleesCache,e.symbolId,()=>E(this.fileCalleesCache,e.relativePath,()=>this.calleeMapForFile(e.relativePath)).get(e.symbolId)??[])}calleesForDefinitions(e){let t=new Map;this.attachBatchFiles(e);let r=new Map;for(let i of e){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){let l=c.get(u.symbolId)??[];this.calleesCache.set(u.symbolId,l),t.set(u.symbolId,l)}}return t}calleeCoverageForDefinitions(e){this.attachBatchFiles(e);let t=new Map,r=new Map;for(let i of e){let o=r.get(i.relativePath);o?o.push(i):r.set(i.relativePath,[i]),t.set(i.symbolId,{callSites:0,resolvedInRepository:0,resolvedExternal:0,unresolved:0})}for(let[i,o]of r){let s=this.sourceFiles.sourceFile(i);if(!s)continue;let a=this.compilerCheckerForSourceFile(s),c=s.compilerNode,u=new Map,l=hn(this.tsMorph.ts,c,o),f=d=>{if(this.tsMorph.ts.isCallExpression(d)||this.tsMorph.ts.isNewExpression(d)||Qt(this.tsMorph.ts,d)){let m=l(d),p=m?t.get(m.symbolId):void 0;p&&this.recordCallSiteCoverage(d,a,p,u)}this.tsMorph.ts.forEachChild(d,f)};f(c)}return t}callNodeExpression(e){return this.tsMorph.ts.isJsxOpeningElement(e)||this.tsMorph.ts.isJsxSelfClosingElement(e)?this.tsMorph.ts.isJsxNamespacedName(e.tagName)?null:e.tagName:e.expression}recordCallSiteCoverage(e,t,r,i){r.callSites+=1;let o=this.callNodeExpression(e),s=o?this.compilerSymbolForExpression(t,o):void 0;if(!s){r.unresolved+=1;return}let a=i.get(s);a===void 0&&(a=this.definitionFromCompilerSymbol(s),i.set(s,a)),a?r.resolvedInRepository+=1:r.resolvedExternal+=1}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=_t(t,e,o,this.db.config.projectRoot);return r&&(r.semanticRefsMs+=x.now()-s,r.referenceCount+=a.length),a}signatureFor(e){return E(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];return(a?s.getTypeAtLocation(a).getText(a):s.getValueDeclaration()?.getType().getText()??"unknown").trim()}),o=r.getReturnType().getText(t);return`(${i.join(",")})=>${o.trim()}`})}importUsageForSourceFile(e,t,r){let i=[],o=new Map;for(let s of t.getImportDeclarations()){r.declarations+=1;let a=dn(this.db,e,s.getModuleSpecifierValue()),c=s.getImportClause()?.isTypeOnly()??!1;for(let u of Pn(s)){let l=Bi(a,u,c,r),{bindingSymbol:f}=l;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||Pi(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:He(s,this.db.config.projectRoot),node:s}),r.matchedReferences+=1;break}}}),i.map(s=>s.typeOnlyDeclaration?Ti(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=r.identifier?r.identifier.findReferences():[],o=[];for(let s of i)for(let a of Lt(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=>!Rn(c.node)),s=i.some(c=>Rn(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=xn(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,oe(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,oe(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=xn(this.workspacePackages,i.getModuleSpecifierValue());if(!o)return;let s=t.get(o);if(s)for(let a of Pn(i)){if(a.kind!=="named"||!a.identifier)continue;let c=s.get(a.importedName);if(!c||c.size===0)continue;let u=Ot(a.identifier,r,this.db.config.projectRoot);u.length>0&&Oi(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 Ht(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?dn(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}ji(u,r,l=>this.indexedDefinitionByLeaf(c,l))}}indexedDefinitionByLeaf(e,t){return E(this.indexedDefinitionLeafCache,e,()=>Bt(this.db,e)).get(t)??null}nodeForDefinition(e){return E(this.definitionNodeCache,e.symbolId,()=>this.definitionNodesForFile(e.relativePath).get(e.symbolId)??null)}definitionNodesForFile(e){return E(this.fileDefinitionNodeCache,e,()=>{let t=this.sourceFiles.sourceFile(e);return t?Ut(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(),l=se(this.db.config.projectRoot,u.fileName),f=u.getLineAndCharacterOfPosition(a.getStart(u)).line;if(t&&(t.declarationLocationMs+=x.now()-c),!l||this.db.isIgnored(l))continue;let d=this.indexedMatchForCompilerDeclaration(a,l,f,i,t,r);if(d)return{symbolId:d.symbolId,symbol:d.symbol,file:d.relativePath,line:d.startLine}}return null}indexedMatchForCompilerDeclaration(e,t,r,i,o,s){let a=o?x.now():0,c=this.compilerDeclarationName(e),u=s?Mn(this.db,t,r,i)??(c&&c!==i?Mn(this.db,t,r,c):null):qt(this.db,t,r,i);return o&&(o.indexedLookupMs+=x.now()-a),u}compilerDeclarationName(e){let t=e.name;return t&&this.tsMorph.ts.isIdentifier(t)?t.text:null}calleeMapForFile(e,t){let r=A(),i=0,o=0,s=0,a=0,c=0,u=0,l=0,f=0,d=r?Ai():void 0;return C("typescript.callee-map.file",()=>{let m=r?x.now():0,p=this.sourceFiles.sourceFile(e);if(r&&(c=Math.round(x.now()-m)),!p)return new Map;let y=zi(this.db,e,r),b=y.definitions;if(r&&(u=y.durationMs),i=b.length,b.length===0)return new Map;let S=new Map,g=r?x.now():0,D=this.compilerCheckerForSourceFile(p),P=p.compilerNode,M=hn(this.tsMorph.ts,P,b);r&&(l=Math.round(x.now()-g));let T=new Map,v=I=>{if(this.tsMorph.ts.isCallExpression(I)||this.tsMorph.ts.isNewExpression(I)||Qt(this.tsMorph.ts,I)){r&&(o+=1);let R=this.semanticCalleeForCallNode(D,P,M,I,T,t,d);R&&(r&&(s+=1),ki(S,R.callerId,R.target))}this.tsMorph.ts.forEachChild(I,v)},h=r?x.now():0;return v(P),r&&(f=Math.round(x.now()-h)),Ki(S),a=S.size,S},()=>({relativePath:e,definitions:i,callNodes:o,resolvedCallees:s,outputRows:a,requestedDefinitions:t?.size??i,sourceFileLookupMs:c,definitionsLoadMs:u,checkerLookupMs:l,traversalMs:f,...d?Ni(d):{}}))}semanticCalleeForCallNode(e,t,r,i,o,s,a){let c=this.requestedCallSiteOwner(r,i,s,a);if(!c)return null;let u=this.tsMorph.ts.isJsxOpeningElement(i)||this.tsMorph.ts.isJsxSelfClosingElement(i);if(u&&this.tsMorph.ts.isJsxNamespacedName(i.tagName))return null;let l=u?i.tagName:i.expression,f=this.compilerSymbolForExpression(e,l,a),d=this.profiledCalleeTarget(f,o,a);return d?{callerId:c.symbolId,target:{symbol:d.symbol,file:d.file,line:d.line,callsiteLine:Vt(t,i),...u?{kind:"jsx-render"}:{}}}:null}requestedCallSiteOwner(e,t,r,i){let o=i?x.now():0,s=e(t);return i&&(i.callerLookupMs+=x.now()-o),s?r&&!r.has(s.symbolId)?(i&&(i.skippedUnrequestedCallers+=1),null):s:null}profiledCalleeTarget(e,t,r){if(!e)return r&&(r.targetMisses+=1),null;if(r&&(r.targetSymbolHits+=1),t.has(e))return r&&(r.compilerSymbolCacheHits+=1),t.get(e)??null;r&&(r.compilerSymbolCacheMisses+=1);let i=r?x.now():0,o=this.definitionFromCompilerSymbol(e,r);return r&&(r.targetLookupMs+=x.now()-i),t.set(e,o),o}compilerSymbolForExpression(e,t,r){let i=r?x.now():0,o=e.getSymbolAtLocation(t);if(r&&(r.expressionSymbolMs+=x.now()-i),o){if((o.flags&this.tsMorph.ts.SymbolFlags.Alias)===0)return o;try{return e.getAliasedSymbol(o)}catch{return o}}r&&(r.typeFallbacks+=1);let s=r?x.now():0,a=e.getTypeAtLocation(t).getSymbol();return r&&(r.typeSymbolMs+=x.now()-s),a}compilerCheckerForSourceFile(e){return e.getProject().getTypeChecker().compilerObject}};function Pn(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())e.push(Hi(i,n));return e.length===0&&e.push({identifier:null,importedName:"*",localName:null,kind:"side-effect",isTypeOnly:!1}),e}function Ti(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 wi(){return{declarations:0,entries:0,bindingSymbols:0,missingBindingSymbols:0,scannedIdentifiers:0,symbolLookups:0,matchedReferences:0,fallbackEntries:0}}function Pi(n){for(let e=n;e;e=e.getParent())if(e.getKindName()==="ImportDeclaration")return!0;return!1}function ki(n,e,t){let r=n.get(e);r||(r=[],n.set(e,r)),r.push(t)}function Ei(n){let e=new Set;for(let t of n.getImportDeclarations())for(let r of Pn(t))r.localName&&e.add(r.localName);return e}function Vt(n,e){return n.getLineAndCharacterOfPosition(e.getStart(n)).line}function Fi(n,e,t){return e===n.relativePath&&t>=n.startLine&&t<=n.endLine}function $t(n){return n.symbol.includes("#")?Le(n.symbol)==="type"&&n.relativePath.endsWith(".d.ts"):!1}function Ai(){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 Ni(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 Yt(){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}}var Zt=1,Jt=me({kind:"typescript-hierarchy-targets",invalidation:K("typescript-hierarchy-targets"),serialize:n=>JSON.stringify(n),deserialize:n=>{try{let e=JSON.parse(n);return e.version!==Zt||typeof e.projectRoot!="string"||!Array.isArray(e.entries)?null:e}catch{return null}}});function _i(n,e){let t=new Map(e.map(i=>[i.symbol,i])),r=new Map;for(let[i,o]of n.entries){let s=new Map;for(let a of o){let c=t.get(a);c&&s.set(c.symbolId,c)}s.size>0&&r.set(i,s)}return r}function Li(n){let e=2166136261;for(let t of n)e^=t.symbolId,e=Math.imul(e,16777619)>>>0;return`${n.length}:${e.toString(16)}`}function Gt(n){return{...n,scanMs:Math.round(n.scanMs),packageRefsMs:Math.round(n.packageRefsMs),semanticRefsMs:Math.round(n.semanticRefsMs),hierarchyMs:Math.round(n.hierarchyMs)}}function Oi(n,e,t){for(let r of e){let i=n.get(r)??[];i.push(...t),n.set(r,i)}}function Qt(n,e){if(!n.isJsxOpeningElement(e)&&!n.isJsxSelfClosingElement(e))return!1;let t=e.tagName;return n.isPropertyAccessExpression(t)?!0:n.isIdentifier(t)?/^[A-Z]/.test(t.text):!1}function Ui(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 qi(n){let e=new Map;for(let t of n){let r=e.get(t.relativePath);r?r.push(t):e.set(t.relativePath,[t])}return e}function Bi(n,e,t,r){r.entries+=1;let i=t?null:e.identifier?.getSymbol()?.compilerSymbol??null;return!t&&e.identifier&&(i?r.bindingSymbols+=1:r.missingBindingSymbols+=1),{sourcePath:n,entry:e,typeOnlyDeclaration:t,bindingSymbol:i,references:[]}}function ji(n,e,t){for(let r of n){let i=r.getNameNode().getText(),o=r.getAliasNode()?.getText()??i,s=t(i);if(!s)continue;let a=e.get(o);a||(a=new Set,e.set(o,a)),a.add(s.symbolId)}}function Wi(n,e,t){return n&&e.has(n.symbolId)?t.get(n.symbolId):void 0}function Hi(n,e){let t=n.getNameNode(),i=n.getAliasNode()??(t.getKindName()==="Identifier"?t:null);return{identifier:i,importedName:t.getText(),localName:i?.getText()??t.getText(),kind:"named",isTypeOnly:n.isTypeOnly()||(e.getImportClause()?.isTypeOnly()??!1)}}function zi(n,e,t){let r=t?x.now():0,i=B(n,e).sort((s,a)=>s.startLine-a.startLine||a.endLine-s.endLine),o=t?Math.round(x.now()-r):0;return{definitions:i,durationMs:o}}function Ki(n){for(let[e,t]of n)n.set(e,Ui(t))}import{join as Vi}from"path";var ze=3;var $i="typescript-semantic";function er(n){let e=Vi(n,$i),t=Oe(e);return{...t,requestDir:t.legacyRequestDir}}var Gi=12e4,Qi=5;function ir(n,e,t={}){let r=t.requester??new En(n,t),i=null,o=null,s=process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1",a=null,c=()=>(i??=Xt(n,e),i),u=(p,y,b)=>(s=!0,to(n)?y():(a=p instanceof Error?p.message:String(p),console.error(`TypeScript semantic service request failed (${a}); semantic enrichment is disabled for the rest of this run because the index is too large for an in-process compiler.`),b())),l=(p,y,b,S=b)=>{if(a!==null)return S();if(s)return b();try{return y(r.request(p))}catch(g){return nr(g)?S():u(g,b,S)}},f=(p,y,b,S)=>{if(a!==null)return new Map;if(s)return S();let g=D=>{try{return b(r.request(y(D)))}catch(P){if(!Xi(P))throw P;let M=Zi(D);if(!M)throw P;return new Map([...g(M[0]),...g(M[1])])}};try{return g(p)}catch(D){return nr(D)?new Map:u(D,S,()=>new Map)}},d=(p,y)=>f(p,b=>({kind:"references",definitions:[...b],...y?.exact?{exact:!0}:{}}),b=>kn(b),()=>c().referencesForDefinitions?.(p,y)??new Map(p.map(b=>[b.symbolId,c().referencesFor(b)]))),m=p=>f(p,y=>({kind:"callees",definitions:[...y]}),y=>kn(y),()=>c().calleesForDefinitions?.(p)??new Map(p.map(y=>[y.symbolId,c().calleesFor(y)])));return{language:"typescript",availability:()=>(o??=l({kind:"availability"},so,()=>c().availability(),()=>({available:!1,reason:`TypeScript semantic service declined: ${a??"unknown"}`})),o),importUsage:p=>l({kind:"import-usage",file:p},y=>y,()=>c().importUsage(p),()=>[]),referencesFor:p=>d([p]).get(p.symbolId)??[],referencesForDefinitions:d,referenceFragmentsForFiles:p=>l({kind:"reference-fragments",files:[...p]},y=>oo(y),()=>c().referenceFragmentsForFiles?.(p)??new Map,()=>new Map),calleesFor:p=>m([p]).get(p.symbolId)??[],calleesForDefinitions:m,calleeCoverageForDefinitions:p=>f(p,y=>({kind:"callee-coverage",definitions:[...y]}),y=>kn(y),()=>c().calleeCoverageForDefinitions?.(p)??new Map),signatureFor:p=>l({kind:"signature",definition:p},ao,()=>c().signatureFor(p),()=>null),dispose:()=>i?.dispose?.()}}function Xi(n){let e=n instanceof Error?n.message:String(n);return/memory limit|heap out of memory|worker terminated|worker failed/iu.test(e)}function Zi(n){let e=[...new Set(n.map(r=>r.relativePath))].sort();if(e.length<2)return null;let t=new Set(e.slice(0,Math.ceil(e.length/2)));return[n.filter(r=>t.has(r.relativePath)),n.filter(r=>!t.has(r.relativePath))]}function nr(n){let e=n instanceof Error?n.message:String(n);return e.includes("invalid mailbox request")||e.includes("Unhandled TypeScript semantic request")||e.includes("compiler project is file-scoped")}var eo=2500,no=25e3,tr=new WeakMap;function to(n){let e=tr.get(n);if(e!==void 0)return e;let t=ro(n);return tr.set(n,t),t}function ro(n){try{let e=n.get("SELECT (SELECT count(*) FROM documents) AS documents, (SELECT count(*) FROM global_symbols) AS symbols");return!e||e.documents<eo&&e.symbols<no}catch{return!0}}var En=class{constructor(e,t={}){this.db=e;this.runtime=t.runtime??sr,this.timeoutMs=t.timeoutMs??co(),this.mailboxLimits=t.mailboxLimits??{},this.cacheDir=rr(e.config.dbPath),this.projectRoot=ln(e.config.projectRoot)}db;runtime;timeoutMs;cacheDir;projectRoot;mailboxLimits;request(e){let t=mn(this.cacheDir),r=er(this.cacheDir),i=qe(t.statePath);if(!Fn(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??O)()+this.timeoutMs,u=yt(),l=te("typescript-semantic-v3",{generation:o,profileEnvironment:u,request:e}),f=re(l),d=Ue(r,{mailboxVersion:$,operationKey:l,clientId:this.runtime.randomId(),enqueuedAtMs:s,deadlineAtMs:a,protocolVersion:ze,id:f,generation:o,profileEnvironment:u,request:e},{nowMs:s,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??O)()<=c;){if(Ji(d.responsePath))return io(L(d.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript semantic mailbox response"}),f,o,l);let m=qe(t.statePath);if(!Fn(m,this.projectRoot,this.runtime))throw new Error("TypeScript semantic service stopped while processing a request.");this.runtime.sleep(Qi)}throw new Error(`TypeScript semantic service timed out after ${this.timeoutMs}ms.`)}};function or(n){if(process.env.SCIP_QUERY_SKIP_WATCH_SERVICE==="1")return!1;try{let e=qe(mn(rr(n.config.dbPath)).statePath);return Fn(e,ln(n.config.projectRoot),sr)}catch{return!1}}function Fn(n,e,t){let r=n?.processIdentity?t.readProcessIdentity?.(n.pid):null;return n!==null&&n.projectRoot===e&&n.typescriptSemantic?.protocolVersion===ze&&t.isProcessAlive(n.pid)&&(!n.processIdentity||r!=null&&we(n.processIdentity,r))}function io(n,e,t,r){let i=JSON.parse(n);if(i.protocolVersion!==ze||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 kn(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid numeric map.");return new Map(n)}function oo(n){if(!Array.isArray(n))throw new Error("TypeScript semantic service wrote an invalid string map.");return new Map(n)}function so(n){let e=Et(n);if(!e)throw new Error("TypeScript semantic service wrote invalid availability.");return e}function ao(n){if(n!==null&&typeof n!="string")throw new Error("TypeScript semantic service wrote an invalid signature.");return n}function co(){let n=Number(process.env.SCIP_TYPESCRIPT_SEMANTIC_TIMEOUT_MS);return Number.isInteger(n)&&n>0?n:Gi}var sr={now:Date.now,monotonicNow:O,randomId:Yi,sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)},isProcessAlive:Fe,readProcessIdentity:Ee};function ar(n){let e=new Map,t=uo(n),r=new Map;return i=>{let o=lo(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=fo(B(n,i.file)),e.set(i.file,a));let c=po(a,i);return r.set(o,c),c}}function lo(n){return`${n.file}\0${n.symbol}\0${n.line}`}function uo(n){return new Set(n.all("SELECT relative_path FROM documents").map(e=>e.relative_path))}function fo(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 po(n,e){if(n.definitions.length===0)return e.symbol;let t=So(e.symbol),r=mo(n.byLeaf,t),i=yo(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 mo(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 yo(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 So(n){let e=new Set([n]),r=n.split(/::|\.|#/).filter(Boolean).at(-1);return r&&e.add(r),e}function cr(n,e){let r=bt(n,e).map(i=>Ro(e,i));return{usage:r,positions:bo(n,e,r)}}function lr(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?go(r.usage,i.sourcePaths):r.usage}}}function go(n,e){return n.map((t,r)=>{let i=e.get(String(r));return i?{...t,sourcePath:i}:t})}function Ro(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 bo(n,e,t){let r=gt(n,e);if(!r)return[];let i=ho(r.rootNode),o=new Map;for(let a of i){let c=o.get(An(a.importedName,a.localName));c?c.push(a.position):o.set(An(a.importedName,a.localName),[a.position])}let s=[];return t.forEach((a,c)=>{let u=o.get(An(a.importedName,a.localName??a.importedName))?.shift();u&&s.push({...u,id:String(c),file:e})}),s}function ho(n){let e=[];for(let t of n.descendantsOfType("use_declaration")){let r=t.namedChildren.find(i=>i.type!=="visibility_modifier");r&&e.push(...Ke(r,""))}return e.filter(t=>t.importedName!=="*")}function Ke(n,e){switch(n.type){case"identifier":case"super":case"self":case"crate":return[{importedName:n.text,localName:n.text,position:Nn(n,n.text)}];case"scoped_identifier":return Io(n);case"scoped_use_list":return Mo(n,e);case"use_list":return n.namedChildren.flatMap(t=>Ke(t,e));case"use_as_clause":return Do(n,e);case"use_wildcard":return vo(n);default:return[]}}function Io(n){let e=n.text.split("::").pop()??n.text;return[{importedName:e,localName:e,position:Nn(n,e)}]}function Mo(n,e){let t=n.namedChild(0),r=n.namedChild(1);if(!t||!r)return[];let i=Rt(e,t.text);return r.namedChildren.flatMap(o=>Ke(o,i))}function Do(n,e){let t=n.namedChild(0),r=n.namedChild(1);return!t||!r?[]:Ke(t,e).map(i=>({...i,localName:r.text}))}function vo(n){let e=n.namedChild(0),t="*";return[{importedName:t,localName:t,position:Nn(e??n,t)}]}function Nn(n,e){let t=Math.max(0,n.text.lastIndexOf(e));return{id:"",file:"",line:n.startPosition.row,column:n.startPosition.column+t+xo(e)}}function xo(n){return Math.max(0,Math.min(n.length-1,1))}function An(n,e){return`${n}\0${e}`}import{spawnSync as Kn}from"child_process";import{existsSync as Vn}from"fs";import{fileURLToPath as Bs}from"url";function Ve(n){let e=vt(Dt,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 Ms,mkdtempSync as Ar,rmSync as Bn}from"fs";import{tmpdir as Nr}from"os";import{join as jn}from"path";import{fileURLToPath as Ze,pathToFileURL as Ds}from"url";import{SHARE_ENV as vs,Worker as xs}from"worker_threads";function j(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=ne(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 Go}from"child_process";import{createHash as Qo,randomUUID as Xo}from"crypto";import{existsSync as vr,realpathSync as Zo,rmSync as es}from"fs";import{tmpdir as ns}from"os";import{resolve as ce}from"path";import{execFileSync as No}from"child_process";import{existsSync as Co}from"fs";import{deserializeSCIP as To,SymbolRole as wo}from"@c4312/scip";import{realpathSync as Dl}from"fs";import{basename as xl,dirname as Cl,join as Tl,relative as wl,sep as Pl}from"path";import{fileURLToPath as El,pathToFileURL as Fl}from"url";function $e(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 _n=new WeakMap,Po="SCIP_RUST_SCIP_OCCURRENCE_REFERENCE_MODE";function ur(n,e){let t=new Map,r=Ye(),i=e.filter(s=>pr(s,r));if(i.length===0)return t;let o=mr(n);if(!o)return t;for(let s of i){let a=dr(o,s);a!==null&&t.set(s.symbolId,a)}return t}function fr(n,e){if(!pr(e,Ye()))return null;let t=mr(n);return t?dr(t,e):null}function dr(n,e){return n.referencesBySymbol.get(e.symbol)??[]}function pr(n,e="safe"){if(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||Se(n.symbol)||/impl#\[[^\]]+\]\[Default\]default\(\)\.$/.test(n.symbol))return!1;if(e==="all")return!0;let t=Le(n.symbol);if(t==="method")return!0;if(t!=="term")return!1;let r=ht(n.symbol);return"kind"in r?!1:!ko(r)}function ko(n){for(let e=0;e<n.descriptors.length-1;e+=1)if(n.descriptors[e]?.suffix==="type")return!0;return!1}function mr(n){if(_n.has(n))return _n.get(n)??null;let e=Eo(n);return _n.set(n,e),e}function Eo(n){if(!n.generation.indexPath||!Co(n.generation.indexPath))return null;try{let e=To(ke(n.generation.indexPath,{inputKind:"SCIP occurrence-reference index",maxBytes:Pe})),t=new Map;for(let r of e.documents??[]){let i=r.relativePath;!i||n.isIgnored(i)||Ao(r,i,t)}for(let[r,i]of t)t.set(r,$e(i));return{referencesBySymbol:t}}catch{return null}}function Fo(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 Ye(){return process.env[Po]==="all"?"all":"safe"}function Ao(n,e,t){for(let r of n.occurrences??[]){if(!r.symbol||(r.symbolRoles&wo.Definition)!==0)continue;let i=Fo(e,r.range);if(!i)continue;let o=t.get(r.symbol)??[];o.push(i),t.set(r.symbol,o)}}var yr=new Map;function Ln(n){let t=Ve(n).resolvedBinary??null;return{engine:"rust-analyzer",resolvedBinary:t,version:t?_o(n,t):"unavailable"}}function On(n){return{...Ln(n),scipOccurrenceReferenceMode:Ye()}}function _o(n,e){let t=`${n}\0${e}`,r=yr.get(t);if(r)return r;let i;try{i=No(e,["--version"],{cwd:n,encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:2e3}).trim()}catch{i="unknown"}return yr.set(t,i),i}import{createHash as Lo}from"crypto";var Oo=new Set(["Cargo.lock","Cargo.toml","rust-project.json","rust-toolchain","rust-toolchain.toml"]);function Sr(n){let e=ct(n,{includePath:Uo});return Lo("sha256").update(JSON.stringify(e)).digest("hex")}function Uo(n){let e=n.replaceAll("\\","/"),t=e.split("/").at(-1)??e;return e.endsWith(".rs")||Oo.has(t)?!0:e===".cargo/config"||e===".cargo/config.toml"||e.endsWith("/.cargo/config")||e.endsWith("/.cargo/config.toml")}import{createHash as qo}from"crypto";import{resolve as Bo}from"path";var ae=3;function qn(n){return qo("sha256").update(ge({kind:"scip-query-durable-rust-mailbox",protocolVersion:ae,sessionDir:Bo(n)})).digest("hex")}function jo(n,e){return n.mailboxVersion===$&&n.id===e.requestId&&n.operationKey===e.operationKey&&n.sessionIdentity===e.sessionIdentity&&n.deadlineAtMs===e.deadlineAtMs}function Wo(n,e){return typeof n.completedAtMs=="number"&&Number.isFinite(n.completedAtMs)&&!(n.completedAtMs>e.deadlineAtMs)&&!(e.nowMs>e.deadlineAtMs)}function Ho(n,e){return n.ok===!1?typeof n.error!="string"||!Jo(n.errorCode)?Un("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"||!zo(n.response,e)?Un("helper wrote an invalid success response"):{ok:!0,session:n.session,response:n.response}}function br(n,e){return de(n)?n.protocolVersion!==ae?Rr(n.protocolVersion===void 0?"helper wrote a prior uncorrelated response protocol":`helper wrote unsupported response protocol ${String(n.protocolVersion)}`):jo(n,e)?Wo(n,e)?Ho(n,e.requestKind):{ok:!1,code:"expired-request",error:"helper response arrived after the durable request deadline"}:Rr("helper wrote an incompatible response identity"):Un("helper wrote an invalid response object")}function zo(n,e){return!de(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"?Ko(n):Vo(n)}function Ko(n){return Array.isArray(n.sourcePaths)&&n.sourcePaths.every(e=>Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&(e[1]===null||typeof e[1]=="string"))}function Vo(n){return gr(n.references,$o)&&(n.incompleteReferenceSymbolIds===void 0||Array.isArray(n.incompleteReferenceSymbolIds)&&n.incompleteReferenceSymbolIds.every(e=>Number.isSafeInteger(e)))&&(n.callees===void 0||gr(n.callees,Yo))&&(n.signatures===void 0||Array.isArray(n.signatures)&&n.signatures.every(e=>Array.isArray(e)&&e.length===2&&Number.isSafeInteger(e[0])&&(e[1]===null||typeof e[1]=="string")))}function gr(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 $o(n){return de(n)&&typeof n.file=="string"&&F(n.line)&&F(n.column)}function Yo(n){return de(n)&&typeof n.symbol=="string"&&typeof n.file=="string"&&F(n.line)&&(n.callsiteLine===void 0||F(n.callsiteLine))}function Jo(n){return n==="unsupported-protocol"||n==="malformed-request"||n==="expired-request"||n==="handler-error"}function Un(n){return{ok:!1,code:"malformed-response",error:n}}function Rr(n){return{ok:!1,code:"incompatible-response",error:n}}var ts=5e3,xr=10,rs=3e4;function hr(n,e,t,r=kr){let i=r.engineIdentity(n),o={protocolVersion:ae,projectRoot:r.canonicalProjectRoot(n),projectFingerprint:r.projectFingerprint(n),engine:{engine:i.engine,resolvedBinary:i.resolvedBinary,version:i.version},workerFingerprint:r.fileFingerprint(e),environment:Tr(r.environment())};return{key:Er(ge(o)),...o}}function Je(n,e,t,r){if(n.protocolVersion!==ae||!t(n.pid))return!1;if(!n.processIdentity)return!0;let i=r?.(n.pid);return i!=null&&we(n.processIdentity,i)}function Cr(n,e,t){let r;try{r=cn(e,{maxBytes:z,inputKind:"Rust semantic engine artifact"})}catch{r="missing"}let i=Er(ge({projectRoot:ce(n),serverPath:ce(e),serverFingerprint:r})).slice(0,20);return ce(t,`scip-query-rust-session-${i}`)}function Ir(n){let e=n===void 0?Number.NaN:Number(n);return Number.isInteger(e)&&e>=0?e:0}function Tr(n){return Object.fromEntries(Object.entries(n).filter(([e])=>Pr(e)).sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>[e,t??null]))}function wr(n,e){let t=e.runtime??ps,r=e.identityRuntime??kr,i=Cr(n,e.serverPath,e.tempRoot??ns()),o=!1,s=(a,c)=>{if(o)throw new Error("Durable Rust semantic session was already disposed.");return os(i,e.serverPath,e.semanticWorkerPath,a,c,t,e.mailboxLimits)};return{requestSemantic(a,c){let u=hr(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:l,...f}=a;return s({kind:"semantic",identityKey:u.key,workerEnvironment:Dr(),request:{...f,referenceRetryTimeoutMs:is(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,a.referenceRetryTimeoutMs),settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Ir(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},requestImportDefinitions(a,c){let u=hr(n,e.semanticWorkerPath,a,r),{readinessDeadlineMs:l,...f}=a;return s({kind:"import-definitions",identityKey:u.key,workerEnvironment:Dr(),request:{...f,settleDelayMs:process.env.SCIP_RUST_SEMANTIC_SETTLE_MS===void 0?a.settleDelayMs:Ir(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS)},timeoutMs:c},c)},shutdown(){o=!0}}}function is(n,e){return e!==void 0?e:n===void 0?rs:void 0}function os(n,e,t,r,i,o,s={}){let a=o.now(),c=a+i,u=(o.monotonicNow??O)(),l=u+i,f=te("rust-semantic-v3",r),d=re(f),m=Oe(n),p=qn(n),y=Ue(m,{mailboxVersion:$,protocolVersion:ae,id:d,operationKey:f,clientId:o.randomId(),enqueuedAtMs:a,deadlineAtMs:c,sessionIdentity:p,request:r},{nowMs:a,limits:s});for(Mr(n,e,t,l,o);(o.monotonicNow??O)()<=l;){if(vr(y.responsePath)){let S=us(L(y.responsePath,{maxBytes:s.maxItemBytes??z,inputKind:"durable Rust semantic mailbox response"}),{requestId:d,operationKey:f,sessionIdentity:p,deadlineAtMs:y.authoritativeDeadlineAtMs,requestKind:r.kind,nowMs:o.now()});if(!S.ok)throw new Error(S.error);return ys(o,u,S.session,r.kind),S.response}let b=Ge(n);(!b||!Je(b,o.now(),o.isProcessAlive,o.readProcessIdentity))&&Mr(n,e,t,l,o),o.sleep(xr)}throw new Error(`Durable Rust semantic session timed out after ${(i/1e3).toFixed(0)}s.`)}function Mr(n,e,t,r,i){let o=Ge(n);if(o&&Je(o,i.now(),i.isProcessAlive,i.readProcessIdentity))return;es(ce(n,"server.json"),{force:!0}),i.spawnServer(e,n,t);let s=i.monotonicNow??O,a=Math.min(r,s()+ts);for(;s()<=a;){let c=Ge(n);if(c&&Je(c,i.now(),i.isProcessAlive,i.readProcessIdentity))return;i.sleep(xr)}throw new Error("Durable Rust semantic session helper did not become ready within 5s.")}function ss(n,e){return typeof n.protocolVersion=="number"&&as(n,e)&&typeof n.pid=="number"&&typeof n.heartbeatAtMs=="number"}function as(n,e){return n.sessionIdentity===void 0||typeof n.sessionIdentity=="string"&&n.sessionIdentity===qn(e)}function cs(n){return(n.busyUntilMs===void 0||typeof n.busyUntilMs=="number")&&(n.mailbox===void 0||fs(n.mailbox))}function ls(n,e){return{protocolVersion:n.protocolVersion,...n.sessionIdentity===void 0?{}:{sessionIdentity:n.sessionIdentity},pid:n.pid,...e?{processIdentity:e}:{},heartbeatAtMs:n.heartbeatAtMs,...n.busyUntilMs===void 0?{}:{busyUntilMs:n.busyUntilMs},...n.mailbox===void 0?{}:{mailbox:n.mailbox}}}function Ge(n){try{let e=JSON.parse(L(ce(n,"server.json"),{maxBytes:it,inputKind:"durable Rust session state"}));if(!ss(e,n)||!cs(e))return null;let t=e.processIdentity===void 0?null:Te(e.processIdentity);return e.processIdentity!==void 0&&(!t||t.pid!==e.pid)?null:ls(e,t)}catch{return null}}function us(n,e){try{return br(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 fs(n){if(!n||typeof n!="object")return!1;let e=n;return ms(e)&&typeof e.totalBytes=="number"&&Number.isFinite(e.totalBytes)&&e.totalBytes>=0&&(e.oldestPendingAt===void 0||Number.isFinite(Date.parse(e.oldestPendingAt)))}function Dr(){return Object.fromEntries(Object.entries(process.env).filter(([n])=>ds(n)).sort(([n],[e])=>n.localeCompare(e)).map(([n,e])=>[n,e??null]))}function Pr(n){return n==="HOME"||n==="PATH"||n.startsWith("CARGO_")||n.startsWith("RA_")||n.startsWith("RUST")}function ds(n){return Pr(n)||n.startsWith("SCIP_RUST_")||n==="SCIP_QUERY_PROFILE"||n==="SCIP_QUERY_PROFILE_CACHE_STATE"||n==="SCIP_QUERY_PROFILE_COMMAND"||n==="SCIP_QUERY_PROFILE_OUT"||n==="SCIP_QUERY_PROFILE_RUN_ID"||n==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||n==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||n==="SCIP_QUERY_PROFILE_MIN_MS"}var kr={canonicalProjectRoot(n){try{return Zo(n)}catch{return ce(n)}},projectFingerprint(n){return Sr(n)},engineIdentity:Ln,fileFingerprint(n){return cn(n,{maxBytes:z,inputKind:"Rust semantic engine artifact"})},environment(){return Tr(process.env)}},ps={now:Date.now,monotonicNow:O,randomId:Xo,isProcessAlive:Fe,readProcessIdentity:Ee,spawnServer(n,e,t){if(!vr(n))throw new Error(`Durable Rust semantic session helper was not found at ${n}. Run npm run build first.`);Go(process.execPath,[n,e,t],{detached:!0,stdio:"ignore"}).unref()},sleep(n){let e=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(e,0,0,n)}};function Er(n){return Qo("sha256").update(n).digest("hex")}function ms(n){return F(n.pending)&&F(n.inflight)&&F(n.responses)&&F(n.deadLetters)&&F(n.invalid)&&F(n.totalItems)}function ys(n,e,t,r){A()&&Ne({type:"span",name:"rust.semantic.durable-session.request",durationMs:(n.monotonicNow??O)()-e,ok:!0,session:t,kind:r})}import{randomUUID as Mu}from"crypto";import{readdirSync as Ss,rmSync as vu,writeFileSync as xu}from"fs";import{join as gs}from"path";var Rs="rust-analyzer-owner-",bs=".json",hs=16*1024;async function Fr(n,e){if(!n)return[];let t;try{t=Ss(n)}catch{return[]}let r=t.filter(s=>s.startsWith(Rs)&&s.endsWith(bs)).map(s=>gs(n,s)),i=[],o=[];for(let s of r){let a=Is(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=>xt(s,e)))),i}function Is(n){try{let e=L(n,{maxBytes:hs,inputKind:"rust-analyzer process ownership record"}),t=JSON.parse(e),r=Te(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 _r=15e3,Lr=8,Ur=5e3,Cs=64,Ts=96,Wn=class{constructor(e,t,r={}){this.projectRoot=e;this.status=t;this.opts=r;this.requester=r.requester??Es(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:he(t),references:Ie(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!0});return{...be(r),resolvedBinary:t.resolvedBinary,references:j(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:Ie(e)}}}calleesForDefinitions(e){let t=this.status(this.projectRoot);if(!t.available||!t.resolvedBinary)return{available:!1,resolvedBinary:t.resolvedBinary,reason:he(t),callees:Me(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!0});return{...be(r),resolvedBinary:t.resolvedBinary,callees:Hn(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:Me(e)}}}referencesAndCalleesForDefinitions(e,t){let r=this.status(this.projectRoot);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:he(r),references:Ie(e),callees:Me(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{...be(o),resolvedBinary:r.resolvedBinary,references:j(e,new Map(o.references),new Set(o.incompleteReferenceSymbolIds??[])),callees:Hn(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:he(t),signatures:Or(e)};try{let r=this.requestSession(t.resolvedBinary,e,{includeReferences:!1,includeCallees:!1,includeSignatures:!0});return{...be(r),resolvedBinary:t.resolvedBinary,signatures:Ls(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:Or(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:he(r),sourcePaths:new Map(t.map(i=>[i.id,null]))};try{let i=this.requestImportDefinitions(r.resolvedBinary,e,t);return{...be(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=Qe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,_r),o=Xe(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),s=Qe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Lr),a=Xe(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,l=r.signatureDefinitions?[...r.signatureDefinitions]:void 0,f=De(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}:{},...l?{signatureDefinitions:l}:{},requestTimeoutMs:i,...r.includeReferences!==!1&&o>0?{referenceRetryTimeoutMs:o}:{},diagnosticsTimeoutMs:a,settleDelayMs:f,concurrency:s,includeReferences:r.includeReferences,includeCallees:r.includeCallees,includeSignatures:r.includeSignatures},m=Os(d);return C("rust.semantic.session.request",()=>this.requester.requestSemantic(d,Y(m,zn(i,d.referenceRetryTimeoutMs),s)),()=>({definitions:t.length,operationDefinitions:m,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:Ie(t)}:this.opts.fallbackReferenceResolver?.referencesForDefinitions(t),s=r.length===0?{available:!0,resolvedBinary:e.resolvedBinary,callees:Me(r)}:this.opts.fallbackCalleeResolver?.calleesForDefinitions(r);return o&&s?qs(e,t,r,o,s):{available:!1,resolvedBinary:e.resolvedBinary,reason:i instanceof Error?i.message:String(i),references:Ie(t),callees:Me(r)}}requestImportDefinitions(e,t,r){let i=Qe(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,_r),o=Qe(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Lr),s=Xe(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(i,1e4)),a=Xe(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,Ur),c={projectRoot:this.projectRoot,rustAnalyzerBinary:e,file:t,positions:[...r],requestTimeoutMs:i,diagnosticsTimeoutMs:s,settleDelayMs:a,concurrency:o};return C("rust.semantic.import-definitions.session.request",()=>this.requester.requestImportDefinitions(c,Y(r.length,i,o)),()=>({file:t,positions:r.length}))}};function be(n){return n.available?{available:!0}:{available:!1,reason:n.reason}}function he(n){return n.available?"rust-analyzer binary path is unavailable.":n.reason}function qr(n,e,t={}){return new Wn(n,e,t)}function De(n,e){let t=jr(n);if(t!==null)return t;let r=e.includeReferences!==!1;return r&&e.includeCallees!==!0&&e.includeSignatures!==!0&&e.definitionCount<=Cs||r&&e.includeCallees===!0&&e.includeSignatures!==!0&&e.definitionCount<=Ts?0:Ur}function ws(n){let e=n?.trim().toLowerCase(),t=["0","false","off","worker"].includes(e??""),r=["1","true","on","durable"].includes(e??""),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 Ps(n){return ws(n).transport}function ks(n,e){let t=null,r=!1,i=!1,o=!1,s=()=>t??=e(),a=()=>{i||(n.shutdown(),i=!0)},c=(l,f,d)=>{let m=_s(l);r=!0;try{a()}catch{}A()&&Ne({type:"span",name:"rust.semantic.durable-session.request",durationMs:d,ok:!1,kind:f,session:"worker-fallback",reason:m})},u=(l,f,d)=>{if(o)throw new Error("Rust semantic failover session was already disposed.");if(r)return d(s());let m=performance.now();try{return f(n)}catch(p){c(p,l,performance.now()-m)}return d(s())};return{requestSemantic(l,f){return u("semantic",d=>d.requestSemantic(l,f),d=>d.requestSemantic(l,f))},requestImportDefinitions(l,f){return u("import-definitions",d=>d.requestImportDefinitions(l,f),d=>d.requestImportDefinitions(l,f))},shutdown(){if(o)return;o=!0;let l=[];try{a()}catch(f){l.push(f)}try{t?.shutdown()}catch(f){l.push(f)}if(l.length>0)throw l[0]}}}function Es(n,e,t={worker:()=>Fs(),durable:()=>wr(n,{serverPath:Ze(Us()),semanticWorkerPath:Ze(Br())})}){return Ps(e)==="durable"?ks(t.durable(),t.worker):t.worker()}function Fs(n={}){let e=null,t=null,r=1,i=!1,o=null,s=null,a=f=>{f&&Bn(f,{recursive:!0,force:!0})},c=()=>{if(o)return;let f=e,d=t;e=null,t=null;let m=f?f.terminate():Promise.resolve(0);o=Promise.allSettled([m,Fr(d,{gracefulMs:1e3,forceMs:1e3})]).then(([p,y])=>{let S=(y.status==="fulfilled"?y.value:[{reaped:!1,detail:String(y.reason)}]).filter(g=>!g.reaped);if(p.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 f=n.semanticWorkerPath?Ds(n.semanticWorkerPath):Br();if(!Ms(Ze(f)))throw new Error(`Rust semantic session worker was not found at ${Ze(f)}. Run npm run build before using built semantic Rust queries.`);return t=Ar(jn(Nr(),"scip-query-rust-session-")),e=new xs(f,n.shareEnvironment?{env:vs}:void 0),e.unref(),e},l=()=>{let f=t??Ar(jn(Nr(),"scip-query-rust-session-"));return t=f,jn(f,`${r++}.json`)};return{requestSemantic(f,d){if(i)throw new Error("Rust semantic session was already disposed.");let m=u(),p=l(),y=new SharedArrayBuffer(4),b=new Int32Array(y);if(m.postMessage({kind:"semantic",request:f,responsePath:p,sharedBuffer:y}),Atomics.wait(b,0,0,d)==="timed-out")throw c(),new Error(`Rust semantic session worker timed out after ${(d/1e3).toFixed(0)}s`);try{let g=As(L(p,{maxBytes:z,inputKind:"Rust semantic worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{Bn(p,{force:!0})}},requestImportDefinitions(f,d){if(i)throw new Error("Rust semantic session was already disposed.");let m=u(),p=l(),y=new SharedArrayBuffer(4),b=new Int32Array(y);if(m.postMessage({kind:"import-definitions",request:f,responsePath:p,sharedBuffer:y}),Atomics.wait(b,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 g=Ns(L(p,{maxBytes:z,inputKind:"Rust import-definition worker response"}));if(!g.ok)throw new Error(g.error);return g.response}finally{Bn(p,{force:!0})}},shutdown(){if(i)return;if(i=!0,!e){a(t),t=null;return}let f=l(),d=new SharedArrayBuffer(4),m=new Int32Array(d);e.postMessage({kind:"shutdown",responsePath:f,sharedBuffer:d}),Atomics.wait(m,0,0,5e3),c()}}}function As(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 Ns(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 _s(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 Ie(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Me(n){return new Map(n.map(e=>[e.symbolId,[]]))}function Or(n){return new Map(n.map(e=>[e.symbolId,null]))}function Hn(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??[]]))}function Ls(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Os(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 zn(n,e){return e&&e>0?Math.max(n,e):n}function Br(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}function Us(){return new URL("./rust-semantic-session-server.js",import.meta.url)}function Qe(n,e){return ne(n)??e}function Xe(n,e){return jr(n)??e}function jr(n){if(!n)return null;let e=Number(n);return Number.isInteger(e)&&e>=0?e:null}function qs(n,e,t,r,i){let o={resolvedBinary:r.resolvedBinary??i.resolvedBinary??n.resolvedBinary,references:j(e,r.references),callees:Hn(t,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 fallback was unavailable.",...o}}var $n=15e3,Yn=8;function zr(n,e={}){let t=e.status??Ve,r=Hs(n,t),i=zs(n,t),o=Ks(n,t),s=Gs(n,e,t,r,i,o),a=e.referenceResolver??s??r,c=e.calleeResolver??s??i,u=e.signatureResolver??s??o,l=Qs(e,s),f=e.calleeSymbolResolver,d=e.sourceZeroCalleeOracle,m=e.scipOccurrenceCalleeOracle,p=new Map,y=new Map,b=null,S=null,g=()=>(b??=t(n),b),D=()=>{let h=g();return h.dependencyAvailable?S??h:h},P=h=>{if(h.length===0)return new Map;let I=xe(h);try{let R=a.referencesForDefinitions(I),w=g();return S=en(w,R),R.available?new Map(R.references):j(I,R.references)}catch(R){let w=g();return S=ve(w,R),J(I)}},M=h=>{if(h.length===0)return new Map;let I=xe(h),R=I.filter(Wr);if(R.length===0)return G(I);let w=new Map,W=Hr(R,m),_=Zs(R,y,W,d,w);if(_.length===0)return le(I,w,void 0);try{let X=c.calleesForDefinitions(_),H=g();S=en(H,X);let q=le(_,X.callees,f);for(let[fe,on]of q)w.set(fe,on);return le(I,w,void 0)}catch(X){let H=g();return S=ve(H,X),G(I)}},T=(h,I)=>{let R=xe(h),w=xe(I),W=w.filter(Wr),_=new Map,X=Hr(W,m),H=ea(W,X,d,_);if(R.length===0&&H.length===0)return{references:J(R),callees:le(w,_,void 0)};try{let q=s?s.referencesAndCalleesForDefinitions(R,H):Js(a,c,{referenceDefinitions:R,calleeDefinitions:H}),fe=g();S=en(fe,q);let on=q.available?new Map(q.references):j(R,q.references);for(let[sn,an]of q.callees)_.set(sn,an);let rt=le(w,_,f);for(let[sn,an]of rt)y.set(sn,an);return{references:on,callees:rt}}catch(q){let fe=g();return S=ve(fe,q),{references:J(R),callees:G(w)}}},v=h=>{if(h.length===0)return new Map;let I=xe(h);try{let R=u.signaturesForDefinitions(I),w=g();return S=en(w,R),Vr(I,R.signatures)}catch(R){let w=g();return S=ve(w,R),nn(I)}};return{language:"rust",availability:D,dispose:()=>{s?.dispose()},importUsage:h=>{let I=p.get(h);if(I)return I;try{let R=l.importUsage(h);return p.set(h,R),R}catch(R){let w=g();return S=ve(w,R),[]}},referencesFor:h=>P([h]).get(h.symbolId)??[],referencesForDefinitions:P,referencesAndCalleesForDefinitions:T,calleesFor:h=>M([h]).get(h.symbolId)??[],calleesForDefinitions:M,signatureFor:h=>v([h]).get(h.symbolId)??null}}function en(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 ve(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 js(n){if(n.usePersistentSession!==void 0)return n.usePersistentSession;let e=process.env.SCIP_RUST_SEMANTIC_SESSION;return e!=="0"&&e!=="false"}function Ws(){return{importUsageFacts:()=>({usage:[],positions:[]})}}function xe(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:It(e.symbol),isTypeLike:t.isTypeLike??!1,kind:t.kind??null,documentation:t.documentation??null,enclosingSymbol:t.enclosingSymbol??null}})}function Wr(n){return n.isFunctionLike}function Kr(n,e){if(!e)return!1;try{return e(n)}catch{return!1}}function Hr(n,e){if(!e||n.length===0)return new Map;try{return e(n)}catch{return new Map}}function Hs(n,e){return{referencesForDefinitions:t=>Vs(n,e,t)}}function zs(n,e){return{calleesForDefinitions:t=>$s(n,e,t)}}function Ks(n,e){return{signaturesForDefinitions:t=>Ys(n,e,t)}}function Vs(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Qn(r),references:J(t)};let i=Jn();if(!Vn(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=ue(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,$n),s=tn(process.env.SCIP_RUST_SEMANTIC_REFERENCE_RETRY_TIMEOUT_MS,0),a=ue(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Yn),c=tn(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),u=De(process.env.SCIP_RUST_SEMANTIC_SETTLE_MS,{definitionCount:t.length,includeReferences:!0}),l={projectRoot:n,rustAnalyzerBinary:r.resolvedBinary,definitions:[...t],requestTimeoutMs:o,...s>0?{referenceRetryTimeoutMs:s}:{},diagnosticsTimeoutMs:c,settleDelayMs:u,concurrency:a},f=Kn(process.execPath,[i],{cwd:n,input:JSON.stringify(l),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,zn(o,l.referenceRetryTimeoutMs),a)}),d=Xn(f.stdout);if(d)return{...Gn(d),resolvedBinary:r.resolvedBinary,references:j(t,new Map(d.references),new Set(d.incompleteReferenceSymbolIds??[]))};let m=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:m,references:J(t)}}function $s(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Qn(r),callees:G(t)};let i=Jn();if(!Vn(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=ue(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,$n),s=ue(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Yn),a=tn(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=De(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},l=Kn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,o,s)}),f=Xn(l.stdout);if(f)return{...Gn(f),resolvedBinary:r.resolvedBinary,callees:le(t,new Map(f.callees??[]),void 0)};let d=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:d,callees:G(t)}}function Ys(n,e,t){let r=e(n);if(!r.available||!r.resolvedBinary)return{available:!1,resolvedBinary:r.resolvedBinary,reason:Qn(r),signatures:nn(t)};let i=Jn();if(!Vn(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:nn(t)};let o=ue(process.env.SCIP_RUST_SEMANTIC_REQUEST_TIMEOUT_MS,$n),s=ue(process.env.SCIP_RUST_SEMANTIC_CONCURRENCY,Yn),a=tn(process.env.SCIP_RUST_SEMANTIC_DIAGNOSTICS_TIMEOUT_MS,Math.min(o,1e4)),c=De(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},l=Kn(process.execPath,[i],{cwd:n,input:JSON.stringify(u),encoding:"utf8",maxBuffer:50*1024*1024,timeout:Y(t.length,o,s)}),f=Xn(l.stdout);if(f)return{...Gn(f),resolvedBinary:r.resolvedBinary,signatures:Vr(t,new Map(f.signatures??[]))};let d=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:d,signatures:nn(t)}}function Js(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 nn(n){return new Map(n.map(e=>[e.symbolId,null]))}function le(n,e,t){let r=0,i=0;return C("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 Vr(n,e){return new Map(n.map(t=>[t.symbolId,e.get(t.symbolId)??null]))}function Jn(){return Bs(new URL("./rust-semantic-worker.js",import.meta.url))}function Gn(n){return n.available?{available:!0}:{available:!1,reason:n.reason}}function Qn(n){return n.available?"rust-analyzer binary path is unavailable.":n.reason}function Xn(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)||!na(t))return null;let r=Xs(t,t.references);return t.available===!0?{available:!0,...r}:{available:!1,reason:String(t.reason),...r}}catch{return null}}function ue(n,e){return ne(n)??e}function tn(n,e){if(!n)return e;let t=Number(n);return Number.isInteger(t)&&t>=0?t:e}function Gs(n,e,t,r,i,o){return e.referenceResolver||e.calleeResolver||e.signatureResolver||!js(e)?null:qr(n,t,{fallbackReferenceResolver:r,fallbackCalleeResolver:i,fallbackSignatureResolver:o})}function Qs(n,e){return n.importUsageResolver??lr(n.sourceImportUsageResolver??Ws(),n.importDefinitionResolver??e)}function Xs(n,e){return{references:e,incompleteReferenceSymbolIds:Array.isArray(n.incompleteReferenceSymbolIds)?n.incompleteReferenceSymbolIds.filter(r=>typeof r=="number"):void 0,callees:Array.isArray(n.callees)?n.callees:void 0,signatures:Array.isArray(n.signatures)?n.signatures:void 0}}function Zs(n,e,t,r,i){let o=[];for(let s of n)e.has(s.symbolId)?i.set(s.symbolId,e.get(s.symbolId)??[]):t.has(s.symbolId)?i.set(s.symbolId,t.get(s.symbolId)??[]):Kr(s,r)?i.set(s.symbolId,[]):o.push(s);return o}function ea(n,e,t,r){let i=[];for(let o of n)e.has(o.symbolId)?r.set(o.symbolId,e.get(o.symbolId)??[]):Kr(o,t)?r.set(o.symbolId,[]):i.push(o);return i}function na(n){return!(n.available===!1&&typeof n.reason!="string"||n.available===!0&&n.reason!==void 0)}import{existsSync as ta}from"fs";import{deserializeSCIP as ra,SymbolRole as ia}from"@c4312/scip";var Zn=new WeakMap;function Yr(n,e){let t=e.filter(oa);if(t.length===0)return new Map;let r=!1,i=0,o=0;return C("rust.scip-occurrence.callees",()=>{let s=ca(n);if(r=!!s,!s)return new Map;let a=new Map;for(let c of t){let u=sa(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 oa(n){return!(!n.symbol.startsWith("rust-analyzer ")||!n.relativePath.endsWith(".rs")||!n.isFunctionLike||n.leaf==="main"||Se(n.symbol))}function sa(n,e,t){let r=_e(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)||!aa(o,s))return null;let a=[],c=new Set;for(let u of s){let l=`${u.callee.symbol}\0${u.callee.file}\0${u.callee.line}`;c.has(l)||(c.add(l),a.push(u.callee))}return a}function aa(n,e){let t=$r(n),r=$r(e);if(t.size!==r.size)return!1;for(let[i,o]of t)if(r.get(i)!==o)return!1;return!0}function $r(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 ca(n){if(Zn.has(n))return Zn.get(n)??null;let e=la(n);return Zn.set(n,e),e}function la(n){if(!n.generation.indexPath||!ta(n.generation.indexPath))return null;try{let e=ee(n).filter(o=>o.symbol.startsWith("rust-analyzer ")&&o.relativePath.endsWith(".rs")&&o.isFunctionLike),t=new Map(e.map(o=>[o.symbol,o])),r=ra(ke(n.generation.indexPath,{inputKind:"SCIP occurrence-callee index",maxBytes:Pe})),i=new Map;for(let o of r.documents??[]){let s=o.relativePath;if(!s||!s.endsWith(".rs")||n.isIgnored(s))continue;let a=ua(o,t);i.set(s,a)}return{occurrencesByFile:i}}catch{return null}}function ua(n,e){let t=[];for(let r of n.occurrences??[]){if(!r.symbol||(r.symbolRoles&ia.Definition)!==0)continue;let i=e.get(r.symbol);if(!i)continue;let o=r.range?.[0];Number.isInteger(o)&&t.push({line:o,leaf:i.leaf,traitImplMember:Se(i.symbol),callee:{symbol:i.symbol,file:i.relativePath,line:i.startLine,callsiteLine:o}})}return t}var rn=class{sessions=new WeakMap;getOrCreate(e,t,r){let i=fa(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 fa(n,e){return`${n.config.projectRoot}:${e}-workspace`}var Jr=new rn;lt({name:"semantic-provider",groups:["semantic-provider"],clearAll:n=>Jr.clear(n)});function Q(n,e){let t=N(e)??"typescript";return Jr.getOrCreate(n,t,()=>t==="rust"?zr(n.config.projectRoot,{sourceImportUsageResolver:{importUsageFacts:r=>cr(n,r)},calleeSymbolResolver:ar(n),sourceZeroCalleeOracle:r=>da(n,r),scipOccurrenceCalleeOracle:r=>Yr(n,r)}):ir(n,e))}function N(n){return n?St(n)==="rust"?"rust":ie(n)?"typescript":null:"typescript"}function da(n,e){let t=_e(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 pa=/^[A-Za-z_][A-Za-z0-9_]*$/,Gr=/\bDefault::default\b/g,ma=/^\.\.\s*Default::default\b/;function Qr(n,e){let t=new Map,r=new Map;for(let i of e){let o=et(n,i,r);o!==null&&t.set(i.symbolId,o)}return t}function et(n,e,t=new Map){let r=Ia(e.symbol);if(!r)return null;let i=Mt(n,[e.symbolId]);if(i.length===0)return null;let o=new RegExp(`(^|[^A-Za-z0-9_])${ye(r)}::default\\b`,"g"),s=new RegExp(`(^|[^A-Za-z0-9_])${ye(r)}\\s*$`),a=ha(n,e.symbolId),c={owner:r,ownerDefaultCall:o,ownerLiteralBeforeBrace:s,canUseStructUpdateDefault:a},u=[];for(let l of i){let f=Ma(n,l.relative_path,t);if(f===null)return null;let d=ya(l,f,c);if(d===null)return null;for(let m of d)u.push(m)}return $e(u)}function ya(n,e,t){let r=e.split(/\r?\n/),i={braceDepth:0,ownerLiteralDepths:[]},o=[];for(let s=n.chunk_start;s<=n.chunk_end&&s<r.length;s+=1){let a=r[s]??"";for(let l of Sa(n.relative_path,s,a,t))o.push(l);let c=ga(n.relative_path,s,a,t,i);for(let l of c)o.push(l);let u=new Set(c.map(l=>l.column));if(ba(a,u))return null}return o.length===0?null:o}function Sa(n,e,t,{owner:r,ownerDefaultCall:i}){let o=[];i.lastIndex=0;let s;for(;s=i.exec(t);)o.push({file:n,line:e,column:s.index+s[1].length+r.length+2});return o}function ga(n,e,t,r,i){let o=[];for(let s=0;s<t.length;s+=1){let a=ma.exec(t.slice(s));if(a){r.canUseStructUpdateDefault&&i.ownerLiteralDepths.includes(i.braceDepth)&&o.push({file:n,line:e,column:s+a[0].lastIndexOf("default")}),s+=a[0].length-1;continue}Ra(t,s,r.ownerLiteralBeforeBrace,i)}return o}function Ra(n,e,t,r){let i=n[e];if(i==="{"){let o=t.test(n.slice(0,e));r.braceDepth+=1,o&&r.ownerLiteralDepths.push(r.braceDepth);return}if(i==="}")for(r.braceDepth=Math.max(0,r.braceDepth-1);r.ownerLiteralDepths.length>0&&r.ownerLiteralDepths[r.ownerLiteralDepths.length-1]>r.braceDepth;)r.ownerLiteralDepths.pop()}function ba(n,e){Gr.lastIndex=0;let t;for(;t=Gr.exec(n);)if(!e.has(t.index+9))return!0;return!1}function ha(n,e){return n.get("SELECT 1 AS present FROM mentions WHERE symbol_id = ? AND role = 1 LIMIT 1",e)?.present===1}function Ia(n){let e=/impl#\[([^\]]+)\]\[Default\]default\(\)\./.exec(n)?.[1]??null;return!e||!pa.test(e)?null:e}function Ma(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:Da(n,e);return t.set(e,i),i}function Da(n,e){try{return at(n.config.projectRoot,e,{inputKind:"indexed Rust source file"})}catch(t){if(!pe(t))throw t;return null}}function Xr(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 va="typescript-import-usage-v1",xa="typescript-signatures-v2",nt=un("semantic-prefetched-callees",{clearGroups:["whole-project","source-file","semantic-provider"]}),Zr=me({kind:"semantic-import-usage",invalidation:K("semantic-import-usage"),serialize:n=>JSON.stringify(n),deserialize:ai}),ei=me({kind:"semantic-signatures",invalidation:K("semantic-signatures"),serialize:n=>JSON.stringify(n),deserialize:za}),ni=pn({kind:"typescript-import-usage",invalidation:K("typescript-import-usage"),serialize:n=>JSON.stringify(n),deserialize:ai}),ti=pn({kind:"typescript-signatures",invalidation:K("typescript-signatures"),serialize:n=>JSON.stringify(n),deserialize:Ka}),Ca=256;function Bf(n,e={}){let t=e.coldFragmentLimit??Ca,r=kt(n);return r===null||r.missing<=t?{ready:!0}:(e.serviceAvailable??or)(n)?{ready:!0}:{ready:!1,reason:`TypeScript reference fragments are cold for ${r.missing} of ${r.files} files and no watch service is running; start the service with \`scip-query watch --daemon\`, then re-run this command.`}}var Ta=un("typescript-reference-map",{clearGroups:["whole-project"]});function wa(n){return Ta.get(n,()=>{let e=Z(n);if(!e)return null;let t=ee(n).filter(i=>N(i.relativePath)==="typescript"),r=gn(n,t,i=>Q(n,i));return r?{projectFingerprint:e,references:r.references,files:r.files,cacheHits:r.cacheHits,cacheMisses:r.cacheMisses,computedFiles:r.computedFiles}:null})}function Ce(n){let e=new Map,t=new Set;return{capability:(r,i)=>ci(n,r,i),importUsage:r=>ka(n,r),references:r=>ri(n,r),materializeReferences:(r,i)=>ii(n,r,e,t,i),callerMap:r=>Ea(n,r,e,t),calleeMap:r=>qa(n,r),signature:r=>Wa(n,r)}}function Pa(n,e){if(e.size===0)return;let t=nt.get(n,()=>new Map);for(let[r,i]of e)t.set(r,[...i])}function jf(n,e){if(!nt.has(n))return{hits:[],misses:[...e]};let t=nt.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 Wf(n,e){return Ce(n).importUsage(e)}function ka(n,e){if(N(e)==="typescript"){let o="fallback",s=0,a=0,c=0,u=0;return C("typescript.import-usage.materialize",()=>{let l=yn(n,e,va);if(l?.key){s=1;let d=ni.read(n,e,l.key);if(d)return o="hit",a=1,d;c=1;let m=U(n,e);if(!m)return o="unavailable",[];let p=m.importUsage(e);return ni.write(n,e,l.key,p),o="computed",p}u=1;let f=U(n,e);return f?(o="direct-fallback",f.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=Zr.read(n,e,t);if(o)return o}let r=U(n,e);if(!r)return[];let i=r.importUsage(e);return t&&Zr.write(n,e,t,i),i}function Hf(n,e){return Ce(n).references(e)}function ri(n,e){let t=et(n,e);if(t)return t;let r=fr(n,e);if(r)return r;let i=U(n,e.relativePath);return i?i.referencesFor(e):[]}function zf(n,e){return Ce(n).callerMap(e)}function Kf(n,e){let t=new Map,r=[];for(let i of e){if(N(i.relativePath)==="typescript"){r.push(i);continue}tt(n,t,i,ri(n,i))}if(r.length>0){let i=Ja(n,r);for(let o of r)tt(n,t,o,i.get(o.symbolId)??[])}return t}function Ea(n,e,t=new Map,r=new Set){let i=new Map,o=ii(n,e,t,r),s=0;return C("semantic.callers.from-references",()=>{for(let a of e)s+=tt(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 Fa(n,e){let t=[];for(let r of n)e.materializedReferences.has(r.symbolId)?e.inMemoryHits+=1:e.incompleteReferences.has(r.symbolId)?e.incompleteInMemoryHits+=1:t.push(r);return t}function Aa(n,e,t,r,i){let o=Fa(r,i);if(o.length===0){i.fullyInMemoryFiles+=1;return}let s=_a(n,e,t);if(!s){for(let c of o)N(c.relativePath)||(i.skippedUnsupportedLanguage+=1),i.unkeyed.push(c);return}i.cacheReadFiles+=1;let a=ft(n,t,s);for(let c of o)Na(c,a.get(c.symbol)??null,s,i)}function Na(n,e,t,r){if(e!==null){let i=Ua(e);if(i){r.cacheHits+=1,r.materializedReferences.set(n.symbolId,i);return}r.parseFailures+=1}r.misses.push({definition:n,cacheFingerprint:t})}function ii(n,e,t,r,i={}){let o=Z(n),s=[],a=[],c=[],u={skippedUnsupportedLanguage:0,inMemoryHits:0,cacheHits:0,parseFailures:0,cacheReadFiles:0,fullyInMemoryFiles:0,incompleteInMemoryHits:0,materializedReferences:t,incompleteReferences:r,misses:a,unkeyed:c},l=0,f=0,d=0,m=0,p=0,y=[],b=new Map,S=e.filter(D=>N(D.relativePath)==="typescript"&&!t.has(D.symbolId)&&!r.has(D.symbolId)),g=S.length>0?wa(n):null;if(g){f=S.length,d=g.cacheHits,m=g.cacheMisses,p=g.computedFiles;for(let D of S)t.set(D.symbolId,g.references.get(D.symbolId)??[])}return C("semantic.references.cache-scan",()=>{for(let[D,P]of Xr(e))Aa(n,o,D,P,u)},()=>({definitions:e.length,skippedUnsupportedLanguage:u.skippedUnsupportedLanguage,cacheHits:u.cacheHits,parseFailures:u.parseFailures,misses:a.length,unkeyed:c.length,inMemoryHits:u.inMemoryHits,incompleteInMemoryHits:u.incompleteInMemoryHits,fullyInMemoryFiles:u.fullyInMemoryFiles,cacheReadFiles:u.cacheReadFiles})),(a.length>0||c.length>0)&&(y=[...c,...a.map(D=>D.definition)],b=C("semantic.references.compute-misses",()=>{let D=La(n,y,i);return l=D.size,D},()=>({definitions:y.length,misses:a.length,unkeyed:c.length,rows:l})),Va(n,y,b,t,r,a,s)),s.length>0&&C("semantic.references.cache-write",()=>dt(n,s),()=>({entries:s.length})),b.size>0&&Sn(n,y,b,D=>Q(n,D)),{definitions:e.length,inMemoryHits:u.inMemoryHits,incompleteInMemoryHits:u.incompleteInMemoryHits,cacheHits:u.cacheHits,misses:a.length,unkeyed:c.length,skippedUnsupportedLanguage:u.skippedUnsupportedLanguage,parseFailures:u.parseFailures,computed:l,incomplete:r.size,cacheWrites:s.length,fragmentDefinitions:f,fragmentCacheHits:d,fragmentCacheMisses:m,fragmentComputedFiles:p}}function _a(n,e,t){if(!e)return null;let r=N(t);return r==="typescript"?e:r==="rust"?fn(JSON.stringify({kind:"semantic-references",language:r,engine:On(n.config.projectRoot),projectFingerprint:e})):null}function La(n,e,t={}){let r=A(),i=new Map,o=0,s=0,a=0,c=0,u=0,l=0,f=0,d=0,m=0,p=(M,T)=>{Oa(i,M,T,r,v=>{f+=1,d+=v})},y=(M,T)=>{for(let v of T)M.has(v.symbolId)&&p(v.symbolId,M.get(v.symbolId)??[])},b=(M,T,v)=>{let h=M.get(T);h?h.push(v):M.set(T,[v])},S=(M,T,v)=>{T?.referencesAndCalleesForDefinitions&&(b(M,T,v),m+=1)},g=(M,T,v)=>{let h=T.get(M.symbolId);if(h)return a+=1,c+=h.length,p(M.symbolId,h),!0;let I=v.get(M.symbolId);return I?(u+=1,l+=I.length,p(M.symbolId,I),!0):!1},D=(M,T)=>{let v=new Map,h=t.prefetchCallees?new Map:null,I=[];for(let R of e){let w,W=()=>(w??=U(n,R.relativePath),w);if(h&&S(h,W(),R),g(R,M,T))continue;let _=W();if(!_){r&&(s+=1);continue}r&&(o+=1),Ga(_,R,v,I)}return{bulkGroups:v,prefetchCalleeGroups:h,scalarDefinitions:I}},P=M=>{let T=new Set;if(!M.prefetchCalleeGroups)return T;for(let[v,h]of M.prefetchCalleeGroups){if(!v.referencesAndCalleesForDefinitions)continue;let I=M.bulkGroups.get(v)??[],R=v.referencesAndCalleesForDefinitions(I,h);T.add(v),Pa(n,R.callees),y(R.references,I)}return T};return C("semantic.references.provider-loop",()=>{let M=Qr(n,e),T=ur(n,e),v=D(M,T),h=P(v);for(let[I,R]of v.bulkGroups)h.has(I)||y(I.referencesForDefinitions(R),R);for(let{provider:I,definition:R}of v.scalarDefinitions)p(R.symbolId,I.referencesFor(R));return i},()=>({definitions:e.length,providerHits:o,providerMisses:s,rustDefaultFastPathRows:a,rustDefaultFastPathReferences:c,rustScipOccurrenceFastPathRows:u,rustScipOccurrenceFastPathReferences:l,prefetchCalleeDefinitions:m,definitionsWithReferences:f,referenceCount:d,rows:i.size}))}function Oa(n,e,t,r,i){n.set(e,t),r&&t.length>0&&i(t.length)}function tt(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 Ua(n){try{return JSON.parse(n)}catch{return null}}function Vf(n,e){return Ce(n).calleeMap(e)}function qa(n,e){let t=A(),r=new Map,i=0,o=0,s=0,a=0;return C("semantic.callees.provider-loop",()=>{let c=new Map,u=[];for(let l of e){let f=U(n,l.relativePath);if(!f){t&&(o+=1);continue}t&&(i+=1);let d=l;f.calleesForDefinitions?Ya(c,f,d):u.push({provider:f,definition:d})}$a(c,r,t,l=>{s+=1,a+=l});for(let{provider:l,definition:f}of u){let d=l.calleesFor(f);oi(r,f.symbolId,d,t,m=>{s+=1,a+=m})}return r},()=>({definitions:e.length,providerHits:i,providerMisses:o,definitionsWithCallees:s,calleeCount:a,rows:r.size}))}var Ba=256;function ja(n){let e=new Map;for(let i of n){let o=e.get(i.relativePath);o?o.push(i):e.set(i.relativePath,[i])}let t=[],r=[];for(let i of e.values())r.length>0&&r.length+i.length>Ba&&(t.push(r),r=[]),r.push(...i);return r.length>0&&t.push(r),t}function oi(n,e,t,r,i){t.length>0&&(n.set(e,t),r&&i(t.length))}function $f(n,e){return Ce(n).signature(e)}function Wa(n,e){if(N(e.relativePath)==="typescript"){let s="fallback",a=0,c=0,u=0,l=0;return C("typescript.signature.materialize",()=>{let f=yn(n,e.relativePath,xa);if(f?.key){a=1;let m=ti.read(n,e.relativePath,f.key)??{};if(Object.prototype.hasOwnProperty.call(m,e.symbol))return s="hit",c=1,m[e.symbol]??null;u=1;let p=U(n,e.relativePath);if(!p)return s="unavailable",null;let y=p.signatureFor(e);return ti.write(n,e.relativePath,f.key,{...m,[e.symbol]:y}),s="computed",y}l=1;let d=U(n,e.relativePath);return d?(s="direct-fallback",d.signatureFor(e)):(s="unavailable",null)},()=>({state:s,eligible:a,cacheHits:c,cacheMisses:u,fallbacks:l}))}let t=si(n,"semantic-signatures",e.relativePath),r=Ha(e);if(t){let s=ei.read(n,r,t);if(s)return s.signature}let i=U(n,e.relativePath);if(!i)return null;let o=i.signatureFor(e);return t&&ei.write(n,r,t,{signature:o}),o}function si(n,e,t){let r=Z(n);if(!r)return null;let i=N(t);return i!=="rust"?null:fn(JSON.stringify({kind:e,language:i,engine:On(n.config.projectRoot),projectFingerprint:r}))}function Ha(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 za(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 Ka(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=N(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 U(n,e){if(!N(e))return null;let t=Q(n,e);return t.availability().available?t:null}function Va(n,e,t,r,i,o,s){for(let a of e)t.has(a.symbolId)?(r.set(a.symbolId,t.get(a.symbolId)??[]),i.delete(a.symbolId)):i.add(a.symbolId);for(let{definition:a,cacheFingerprint:c}of o)t.has(a.symbolId)&&ci(n,"semantic-references",a.relativePath).available&&s.push({relativePath:a.relativePath,symbol:a.symbol,projectFingerprint:c,payload:JSON.stringify(t.get(a.symbolId)??[])})}function $a(n,e,t,r){for(let[i,o]of n)for(let s of ja(o)){let a=i.calleesForDefinitions(s);for(let c of s){let u=a.get(c.symbolId)??[];oi(e,c.symbolId,u,t,l=>{r(l)})}}}function Ya(n,e,t){let r=n.get(e);r?r.push(t):n.set(e,[t])}function Ja(n,e){let r=gn(n,e,i=>Q(n,i))?.references;if(!r){let i=U(n,e[0].relativePath);r=i?i.referencesForDefinitions?i.referencesForDefinitions(e,{exact:!0}):new Map(e.map(o=>[o.symbolId,i.referencesFor(o)])):new Map,i&&A()&&Sn(n,e,r,o=>Q(n,o))}return r}function Ga(n,e,t,r){if(n.referencesForDefinitions){let i=t.get(n);i?i.push(e):t.set(n,[e])}else r.push({provider:n,definition:e})}export{Xr as a,On as b,N as c,Bf as d,Ce as e,jf as f,Wf as g,Hf as h,zf as i,Kf as j,La as k,Vf as l,$f as m};
|
|
3
|
+
//# sourceMappingURL=chunk-AGWFSTXC.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as h}from"./chunk-FMRN2TRL.js";import{a as d,b as l}from"./chunk-FVULPZDF.js";import{statSync as f}from"fs";import{isAbsolute as s,join as x,relative as m}from"path";function S(t,e){let n=p(t,e,{allowMultiple:!1})[0]?.relativePath;return n||g(t,e)}function y(t,e){return p(t,e,{allowMultiple:!0}).map(n=>n.relativePath)}function b(t,e){let n=p(t,e,{allowMultiple:!0});return n.length===1?n[0].relativePath:null}function w(t,e){let n=l(t,e,{allowMultiple:!0,requirePathMatch:!0});return n.length===1?n[0].relativePath:null}function g(t,e){if(!e)return null;let n=e.replace(/\\/g,"/").replace(/^\.\//,""),r=s(n)?m(t.config.projectRoot,n):n;if(r===".."||r.startsWith("../")||s(r))return null;let o=x(t.config.projectRoot,r);return f(o,{throwIfNoEntry:!1})?.isFile()?r:null}function p(t,e,n){if(n.allowMultiple&&e.trim()){let i=D(t,e);if(i.length)return i}let r=g(t,e);if(r)return l(t,r,n).filter(i=>i.relativePath===r);let o=e.replace(/\\/g,"/").replace(/^\.\//,""),c=s(o)||o.includes("/"),a=l(t,e,{...n,requirePathMatch:c});if(a.length||c)return a;let u=h(t,e);return!u||t.isIgnored(u.relativePath)?[]:[{relativePath:u.relativePath,score:700}]}function D(t,e){let r=(s(e)?m(t.config.projectRoot,e):e).replace(/\\/g,"/").replace(/^\.\//,"").replace(/\/+$/,""),o=r==="."||r===""?"":`${r}/`;return d(t,{includeIgnored:!1}).filter(a=>a.startsWith(o)).map(a=>({relativePath:a,score:1100}))}export{S as a,y as b,b as c,w as d};
|
|
2
|
+
//# sourceMappingURL=chunk-AOSIYPTA.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as P,b as y}from"./chunk-5PLMJC7Q.js";import{a as C,c as b,e as r,f}from"./chunk-2KNN7GTQ.js";import{a as g,b as h,c as k}from"./chunk-NOLZOVCU.js";import{$ as v}from"./chunk-FVULPZDF.js";function L(e,t={}){let{minSimilarity:o=.62,minTokens:n=8,limit:c=20,scope:l,scanLimit:u,filePattern:m,focusFiles:d}=t,s=B(e,{scope:l,minTokens:n,scanLimit:u}),p=P(s,i=>i.tokens);return y({profiles:s,limit:c,filePattern:m,focusFiles:d,candidateIndex:p,profile:{name:"vue-component-duplicates"},compare:(i,a)=>V(i,a,o),sort:(i,a)=>a.similarity-i.similarity||i.fileA.localeCompare(a.fileA)||i.fileB.localeCompare(a.fileB)})}function B(e,t){return v(e).vueProfiles({scope:t.scope,minTemplateTokens:t.minTokens,scanLimit:t.scanLimit}).map(o=>({file:o.file,tokens:o.templateTokens,loc:T(o)}))}function T(e){return e.totalLines}function V(e,t,o){let n=g(e.tokens,t.tokens);if(n.size<6||!R(n))return null;let c=k(e.tokens,t.tokens);if(c<o)return null;let l=r(n,"component:"),u=r(n,"prop:"),m=r(n,"event:"),d=r(n,"directive:"),s=r(n,"slot:"),p=r(n,"id:"),i=S({sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p});return{fileA:e.file,fileB:t.file,similarity:c,tokenCountA:e.tokens.size,tokenCountB:t.tokens.size,sharedTokens:f(n),sharedComponents:l,sharedProps:u,sharedEvents:m,sharedDirectives:d,sharedSlots:s,sharedIdentifiers:p,evidenceClass:i.evidenceClass,actionTier:i.actionTier,evidenceClassReasons:i.reasons,recommendation:i.recommendation,uniqueToA:f(h(e.tokens,t.tokens)),uniqueToB:f(h(t.tokens,e.tokens)),locA:e.loc,locB:t.loc}}function R(e){let t=0,o=0;for(let n of e)n.startsWith("component:")&&(t+=1),(n.startsWith("prop:")||n.startsWith("event:")||n.startsWith("directive:")||n.startsWith("slot:"))&&(o+=1);return b([{name:"component",count:t},{name:"behavior",count:o}],[{min:{component:1},reason:"shared custom component"},{min:{behavior:3},reason:"shared Vue template structure"}]).pass}function S(e){return C({genericWords:x,primitiveGroups:[{values:e.sharedProps,reasonPrefix:"shared props",bucket:"generic"},{values:e.sharedEvents,reasonPrefix:"shared events",bucket:"generic"},{values:e.sharedDirectives,reasonPrefix:"shared directives",bucket:"generic"},{values:e.sharedSlots,reasonPrefix:"shared slots",bucket:"generic"}],nameGroups:[{names:e.sharedComponents,label:"shared component",fallbackBucket:"generic"},{names:e.sharedIdentifiers,label:"shared identifier",fallbackBucket:"generic"}],recommendation:w})}function w(e){switch(e){case"domain-behavior":case"mixed":return"Review for a shared component or feature-specific Vue primitive around the named domain structure.";case"shared-abstraction":return"Review the existing shared component usage first; extract only if duplicated structure remains outside it.";case"generic-workflow-scaffolding":return"Generic structural overlap \u2014 verify intent before consolidating."}}var x=new Set(["actions","app","button","card","content","container","dialog","field","form","header","input","item","label","layout","list","modal","page","panel","row","section","shell","table","text","toolbar","ui","value","view","wrapper"]);export{L as a};
|
|
2
|
+
//# sourceMappingURL=chunk-AUVEWPIF.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{Ab as _,Bb as k,Cb as z,Eb as j,_b as it,ac as C,d as B,zb as $}from"./chunk-JYWEX7RR.js";import{Ba as S,Zf as st,mf as ot,oe as et,pe as nt,qe as rt,re as M,t as x,ye as H,za as b}from"./chunk-OZCJXZK6.js";import{createHash as I,randomBytes as lt}from"crypto";import{writeSync as Gt,chmodSync as Xt,closeSync as T,fstatSync as V,lstatSync as Yt,mkdirSync as mt,openSync as G,readSync as Kt,readdirSync as Ot,renameSync as yt,rmSync as X,statSync as wt}from"fs";import{tmpdir as Zt}from"os";import{dirname as Qt,join as E,resolve as te}from"path";import{StringDecoder as Y}from"string_decoder";import{InvalidArgumentError as at}from"commander";var St="scip-query-output-page",Pt=1,ee="continue",O=256,P=1e5,R=4096,f=32e6,vt=64*1024*1024,ne=256*1024*1024,re=32,bt=32768,Ct=16,oe=z*Ct,A=4096,ut=vt,It=3600*1e3,se="scip-query-json-export",ie=1,Tt=3;function Et(){return E(Zt(),`scip-query-output-pages-${typeof process.getuid=="function"?process.getuid():"user"}`)}var K=/^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/u,xt=/^[A-Za-z0-9_][A-Za-z0-9_-]{11}$/u,ae=/^4\.([A-Za-z0-9_-]{22})\.([0-9a-z]{1,10})$/u,ue=/^([A-Za-z0-9_][A-Za-z0-9_-]{11})(?:\.([0-9a-z]{1,10}))?$/u,_t=1,ce="quota.lock",pe=2e3,he=5,ct=1024*1024,de=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT)),q,ge=Object.freeze({maxSnapshotBytes:vt,maxAggregateBytes:ne,maxSnapshotCount:re});var At={writeStdout:t=>{process.stdout.write(t)},writeStderr:t=>{process.stderr.write(t)},stdoutIsRegularFile:()=>{try{return V(1).isFile()}catch{return!1}}};async function fe(t,e,n=At){return it({command:t.command,cwd:t.cwd,argv:t.argv,json:t.json,sessionEnabled:t.sourceSession,reemit:t.reemitSource},async()=>{try{await le(t,e,n)}finally{C(!1)}})}async function le(t,e,n){let o=t.pageSize??$,r=t.snapshotRoot??Et(),s=ke(t.snapshotLimits),i=me(t);switch(Oe(t,o),we(t,n)){case"json-file":await Ce(t,e,n,i);return;case"json":await Ie(t,e,n);return;case"human-file":await Te(t,e,i);return}let a=jt(t.argv),u=Dt(t.invocationPrefix),c=zt(t.command,t.cwd,u,a),p={pageSize:o,snapshotRoot:r,snapshotLimits:s,maxOutputCharacters:i,filteredArgv:a,invocationPrefix:u,invocationHash:c},d=t.cursor===void 0?void 0:en(t.cursor,c),h=d?Se(d,t,p):await Pe(t,e,p);ve(t,n,p,h)}function me(t){let e=t.maxOutputCharacters??f;if(!Number.isSafeInteger(e)||e<=0)throw new Error("Output character safety limit must be a positive integer.");return Math.min(e,f,t.agentOutput?oe:f)}function Oe(t,e){if(Ut(e),t.cursor!==void 0&&t.cursor.length>R)throw new Error(`Output cursor exceeds the ${R}-character limit. Run the command again without --output-cursor.`)}function ye(t){if(!t.json)throw new Error("--json-output requires --json.");if(t.agentOutput||t.pageSize!==void 0||t.cursor!==void 0)throw new Error("--json-output cannot be combined with --agent-output or output pagination.")}function we(t,e){if(t.jsonOutputPath!==void 0)return ye(t),"json-file";if(t.json)return!t.agentOutput&&t.pageSize===void 0&&t.cursor===void 0?"json":void 0;if(t.cursor===void 0&&t.pageSize===void 0&&e.stdoutIsRegularFile?.()===!0)return"human-file"}function Se(t,e,n){let{invocationHash:o,pageSize:r,maxOutputCharacters:s,snapshotRoot:i,invocationPrefix:a,filteredArgv:u}=n;try{return{snapshotId:t.snapshotId,completed:Ee(t,o,r,s,i,e.onSnapshotRead)}}catch(c){let p=c instanceof Error?c.message:String(c);throw new Error(`${p} Restart with: ${qt(a,u,r)}`,{cause:c})}}async function Pe(t,e,n){let{invocationHash:o,invocationPrefix:r,filteredArgv:s,pageSize:i,maxOutputCharacters:a,snapshotRoot:u,snapshotLimits:c}=n,p=new F(o,r,t.command,t.cwd,s,i,a,Rt(t)?k:Qe(t,r),u,c,t.agentOutput?Ct:bt,!t.json,U(a,t.agentOutput===!0)),d=Nt(m=>p.write(m)),h=!1;try{await e(),h=!0}finally{d(),h||p.abort()}let g;try{g=p.complete()}catch(m){throw p.abort(),m}return{snapshotId:g.snapshotId,completed:{content:g.content,offset:0,pageIndex:0,pageCount:g.pageCount,totalCharacters:g.totalCharacters,outputHash:g.outputHash}}}function Rt(t){return!t.json&&t.pageSize===void 0&&t.cursor===void 0}function ve(t,e,n,{snapshotId:o,completed:r}){let{invocationPrefix:s,snapshotRoot:i}=n,a=r.offset+r.content.length,u=r.pageIndex+1>=r.pageCount;if(!u&&Rt(t)){let d=ht(o),h=l(i,d,"output");J(i,d,wt(h).size,"saved",n.snapshotLimits);let g=$t(r.content,1800,1800,!0),m=r.content.slice(0,g).split(`
|
|
3
|
+
`).slice(0,24).join(`
|
|
4
|
+
`).trimEnd();e.writeStdout(`Full result: ${j(h)}
|
|
5
|
+
Preview (${r.totalCharacters} characters saved):
|
|
6
|
+
${m}
|
|
7
|
+
`);return}let c=u?void 0:Ze({invocationPrefix:s,nextPageIndex:r.pageIndex+1,snapshotId:ht(o)});if(be(t,e,n,{snapshotId:o,completed:r}))return;let p=pn(t,r,c,a);t.json?e.writeStdout(`${JSON.stringify(p)}
|
|
8
|
+
`):e.writeStdout(cn(p)),u&&o&&v(o,i)}function be(t,e,n,{snapshotId:o,completed:r}){let s=r.pageIndex+1>=r.pageCount;return r.offset===0&&s&&t.cursor===void 0?(e.writeStdout(r.content),C(!0),o&&v(o,n.snapshotRoot),!0):!1}async function Rn(t,e,n=Et(),o=At){if(t.length>R)throw new Error(`Output cursor exceeds the ${R}-character limit.`);let r=kt(t);if(!r)throw new Error("Invalid output cursor. Run the original command again.");let s=Bt(r.snapshotId,n);await fe({command:s.command,producerVersion:e,invocationPrefix:s.invocationPrefix,argv:[...s.argv,"--output-page-size",String(s.pageSize),"--output-cursor",t],cwd:s.cwd,json:s.argv.some(i=>i==="--json"||i.startsWith("--json=")),sourceSession:!s.argv.some(i=>i==="--no-session"),agentOutput:s.argv.some(i=>i==="--agent-output"),pageSize:s.pageSize,cursor:t,snapshotRoot:n},()=>{throw new Error("Output continuation attempted to rerun the original command.")},o)}async function Ce(t,e,n,o){let r=t.jsonOutputPath;if(r===void 0||r.length===0||Buffer.byteLength(r)>A||r.includes("\0"))throw new Error(`--json-output requires a path from 1 through ${A} UTF-8 bytes.`);let s=te(t.cwd,r);if(Buffer.byteLength(s)>A)throw new Error(`The resolved --json-output path exceeds ${A} UTF-8 bytes.`);let i=new Y("utf8"),a=I("sha256"),u=0,c=0,p=w=>{if(c+=w.length,!Number.isSafeInteger(c)||c>o)throw new Error(U(o,!1))};mt(Qt(s),{recursive:!0});let d=`${s}.tmp-${lt(12).toString("hex")}`,h=G(d,"wx",384),g=!0,m=Nt(w=>{let L=u+w.length;if(!Number.isSafeInteger(L)||L>ut)throw new Error(`JSON export exceeds the ${ut}-byte file safety limit. Narrow the query before retrying.`);if(p(i.write(w)),h===void 0)throw new Error("JSON export writer is closed.");st(h,w,"JSON export"),a.update(w),u=L});try{await e(),p(i.end()),m(),T(h),h=void 0,yt(d,s),g=!1}finally{if(m(),h!==void 0)try{T(h)}catch{}g&&X(d,{force:!0})}let Wt={kind:se,schemaVersion:ie,producer:{name:"scip-query",version:t.producerVersion},command:t.command,path:s,bytes:u,sha256:a.digest("hex")};n.writeStdout(`${JSON.stringify(Wt)}
|
|
9
|
+
`),C(!0)}function U(t,e){let n=`Command output exceeds the ${t}-character safety limit. Narrow the query before retrying.`;return e?`${n} For the complete machine result, use --json --json-output <path> and inspect the file programmatically.`:n}function Un(t){if(!/^\d+$/u.test(t))throw new at(`Output page size must be an integer from ${O} through ${P}.`);let e=Number(t);try{Ut(e)}catch{throw new at(`Output page size must be an integer from ${O} through ${P}.`)}return e}function Ut(t){if(!Number.isSafeInteger(t)||t<O||t>P)throw new Error(`Output page size must be an integer from ${O} through ${P}.`)}async function Ie(t,e,n){let o=new D(_,t.maxOutputCharacters??f),r=process.stdout.write,s=!1,i=`${j(`scip-query: JSON output exceeds the ${_}-byte client-safe budget and may be truncated by the client. Do not use possibly partial client output as evidence. Read every page with: ${qt(Dt(t.invocationPrefix),an(jt(t.argv)),$)}`)}
|
|
10
|
+
`;process.stdout.write=((a,u,c)=>{let p=o.push(a,u);return p!==void 0&&(s||(s=!0,n.writeStderr(i)),r.call(process.stdout,p)),Z(u,c),!0});try{await e();let a=o.finish();a.crossedPageBoundary&&!s&&(s=!0,n.writeStderr(i)),a.bytes.length>0&&r.call(process.stdout,a.bytes),s&&n.writeStderr(i)}finally{process.stdout.write=r}}async function Te(t,e,n){let o=process.stdout.write,r=0;process.stdout.write=((s,i,a)=>{let u=Lt(s,i);if(r+=u.length,r>n)throw new Error(U(n,!1));return o.call(process.stdout,u),Z(i,a),!0});try{await e()}finally{process.stdout.write=o}C(!0)}function Nt(t){let e=process.stdout.write;return process.stdout.write=((n,o,r)=>{let s=Lt(n,o);return t(s),Z(o,r),!0}),()=>{process.stdout.write=e}}function Lt(t,e){return typeof t=="string"?Buffer.from(t,typeof e=="string"?e:"utf8"):Buffer.from(t)}function Z(t,e){let n=typeof t=="function"?t:e;typeof n=="function"&&n()}var D=class{constructor(e,n){this.byteLimit=e;this.maxOutputCharacters=n}byteLimit;maxOutputCharacters;decoder=new Y("utf8");chunks=[];overflowed=!1;totalCharacters=0;totalBytes=0;push(e,n){let o=typeof e=="string"?Buffer.from(e,typeof n=="string"?n:"utf8"):Buffer.from(e);if(this.totalBytes+=o.length,this.addCharacters(this.decoder.write(o)),this.overflowed)return o;if(this.chunks.push(o),this.totalBytes<=this.byteLimit)return;this.overflowed=!0;let r=Buffer.concat(this.chunks);return this.chunks.length=0,r}finish(){this.addCharacters(this.decoder.end());let e=this.totalBytes>this.byteLimit,n=Buffer.concat(this.chunks);return this.chunks.length=0,{bytes:n,crossedPageBoundary:e}}addCharacters(e){if(this.totalCharacters+=e.length,!Number.isSafeInteger(this.totalCharacters)||this.totalCharacters>this.maxOutputCharacters)throw new Error(`Command output exceeds the ${this.maxOutputCharacters}-character safety limit. Narrow the query before retrying.`)}},F=class{constructor(e,n,o,r,s,i,a,u,c,p,d,h,g=U(a,!1)){this.invocationHash=e;this.invocationPrefix=n;this.command=o;this.cwd=r;this.argv=s;this.pageSize=i;this.maxOutputCharacters=a;this.pageContentByteLimit=u;this.snapshotRoot=c;this.limits=p;this.maxPages=d;this.preferLineBoundaries=h;this.overflowMessage=g;Q(c);do this.snapshotId=lt(9).toString("base64url");while(this.snapshotId.startsWith("-"));this.temporaryPath=l(c,this.snapshotId,"tmp")}invocationHash;invocationPrefix;command;cwd;argv;pageSize;maxOutputCharacters;pageContentByteLimit;snapshotRoot;limits;maxPages;preferLineBoundaries;overflowMessage;snapshotId;temporaryPath;decoder=new Y("utf8");hash=I("sha256");pages=[];descriptor=null;pending="";firstPageContent="";totalCharacters=0;pageCharacterOffset=0;byteLength=0;reservedBytes=0;opened=!1;finished=!1;write(e){if(this.finished)throw new Error("Output snapshot writer is closed.");this.appendDecoded(this.decoder.write(e))}complete(){if(this.finished)throw new Error("Output snapshot writer is closed.");if(this.appendDecoded(this.decoder.end()),this.finished=!0,!this.opened){let r=this.pending,s=Buffer.from(r);return this.assertWithinByteLimit(s.length),this.hash.update(s),this.pending="",{content:r,totalCharacters:this.totalCharacters,outputHash:this.hash.digest("hex"),pageCount:1}}if((this.pending.length>0||this.pages.length===0)&&(this.flushPage(this.pending),this.pending=""),this.descriptor===null)throw new Error("Output snapshot writer is not open.");T(this.descriptor),this.descriptor=null;let e=this.hash.digest("hex"),n=l(this.snapshotRoot,this.snapshotId,"output"),o=l(this.snapshotRoot,this.snapshotId,"json");try{yt(this.temporaryPath,n);let r={version:Tt,snapshotId:this.snapshotId,invocationHash:this.invocationHash,invocationPrefix:[...this.invocationPrefix],command:this.command,cwd:this.cwd,argv:[...this.argv],outputHash:e,pageSize:this.pageSize,pages:this.pages,totalCharacters:this.totalCharacters,byteLength:this.byteLength,createdAtMs:Date.now()};return H(o,r),J(this.snapshotRoot,this.snapshotId,this.byteLength,"complete",this.limits),this.reservedBytes=this.byteLength,{content:this.firstPageContent,totalCharacters:this.totalCharacters,outputHash:e,pageCount:this.pages.length,snapshotId:this.snapshotId}}catch(r){throw v(this.snapshotId,this.snapshotRoot),r}}abort(){this.descriptor!==null&&(T(this.descriptor),this.descriptor=null),this.finished=!0,v(this.snapshotId,this.snapshotRoot)}appendDecoded(e){if(e.length===0)return;let n=this.totalCharacters+e.length;if(!Number.isSafeInteger(n)||n>this.maxOutputCharacters)throw new Error(this.overflowMessage);for(this.totalCharacters=n,this.pending+=e,this.assertWithinByteLimit(this.byteLength+Buffer.byteLength(this.pending));this.pending.length>this.pageSize||Buffer.byteLength(this.pending)>this.pageContentByteLimit;){this.open();let o=$t(this.pending,this.pageSize,this.pageContentByteLimit,this.preferLineBoundaries),r=this.pending.slice(0,o);this.pending=this.pending.slice(o),this.flushPage(r)}}open(){if(!this.opened){ze(this.snapshotRoot,this.snapshotId,0,this.limits);try{this.descriptor=G(this.temporaryPath,"wx",384),this.opened=!0}catch(e){throw qe(this.snapshotRoot,this.snapshotId),e}}}flushPage(e){if(this.descriptor===null)throw new Error("Output snapshot writer is not open.");if(this.pages.length>=this.maxPages)throw new Error(`Command output requires more than ${this.maxPages} snapshot pages. Retry with a larger --output-page-size, narrow the query, or use --json --json-output <path>.`);let n=Buffer.from(e),o=this.byteLength+n.length;if(this.assertWithinByteLimit(o),o>this.reservedBytes){let i=Math.min(this.limits.maxSnapshotBytes,Math.ceil(o/ct)*ct);J(this.snapshotRoot,this.snapshotId,i,"active",this.limits),this.reservedBytes=i}let r=0;for(;r<n.length;){let i=Gt(this.descriptor,n,r,n.length-r);if(i<=0)throw new Error("Output snapshot write made no progress.");r+=i}let s={characterOffset:this.pageCharacterOffset,characterLength:e.length,byteOffset:this.byteLength,byteLength:n.length,hash:I("sha256").update(n).digest("hex")};this.pages.length===0&&(this.firstPageContent=e),this.pages.push(s),this.hash.update(n),this.pageCharacterOffset+=e.length,this.byteLength=o}assertWithinByteLimit(e){if(!Number.isSafeInteger(e)||e>this.limits.maxSnapshotBytes)throw new Error(`Command output exceeds the ${this.limits.maxSnapshotBytes}-byte snapshot limit. Narrow the query before retrying.`)}};function Ee(t,e,n,o,r,s){Q(r);let i=Bt(t.snapshotId,r);xe(i,t,e,n);let a=i.pages[t.pageIndex];if(!a)throw new Error("Output cursor points past the current result.");if(i.totalCharacters>o)throw new Error(`Output snapshot exceeds the ${o}-character safety limit.`);if(Date.now()-i.createdAtMs>It)throw v(t.snapshotId,r),new Error("Output snapshot expired before all pages were read.");let u=l(r,t.snapshotId,"output"),c=G(u,"r");try{return{content:_e(c,i,a,s),offset:a.characterOffset,pageIndex:t.pageIndex,pageCount:i.pages.length,totalCharacters:i.totalCharacters,outputHash:i.outputHash}}catch(p){throw v(t.snapshotId,r),p}finally{T(c)}}function xe(t,e,n,o){if(t.invocationHash!==n)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");if(t.snapshotId!==e.snapshotId||e.version===3&&(t.invocationHash!==e.invocationHash||t.outputHash!==e.outputHash))throw new Error("Output snapshot identity does not match this cursor.");if(t.pageSize!==o||e.version===3&&e.pageSize!==o)throw new Error(`Output page size changed after this cursor was issued; use ${t.pageSize}.`)}function _e(t,e,n,o){let r=V(t);if(!r.isFile()||r.size!==e.byteLength)throw new Error("Output snapshot size or type changed.");let{bytes:s,bytesRead:i}=Ae(t,n,o),a=V(t);if(a.dev!==r.dev||a.ino!==r.ino||a.size!==r.size||i!==n.byteLength)throw new Error("Output snapshot changed while it was being read.");if(I("sha256").update(s).digest("hex")!==n.hash)throw new Error("Output snapshot page no longer matches its metadata.");let u=s.toString("utf8");if(u.length!==n.characterLength)throw new Error("Output snapshot page character count changed.");return u}function Ae(t,e,n){let o=Buffer.allocUnsafe(e.byteLength),r=0;for(;r<o.length;){let s=Kt(t,o,r,o.length-r,e.byteOffset+r);if(s===0)break;r+=s,n?.(s)}return{bytes:o,bytesRead:r}}function Bt(t,e){if(!y(t))throw new Error("Output snapshot identifier is invalid.");let n;try{n=JSON.parse(x(l(e,t,"json"),"output snapshot metadata"))}catch(o){throw new Error("Output snapshot is unavailable.",{cause:o})}if(!Re(n))throw new Error("Output snapshot metadata is invalid.");return n}function Re(t){if(!t||typeof t!="object")return!1;let e=t;return e.version===Tt&&Ue(e)&&Le(e)&&b(e.createdAtMs)}function pt(t,e){return typeof t=="string"&&t.length>0&&t.length<=e}function Ue(t){return typeof t.snapshotId=="string"&&y(t.snapshotId)&&S(t.invocationHash)&&Ft(t.invocationPrefix)&&pt(t.command,256)&&pt(t.cwd,8192)&&un(t.argv)&&zt(t.command,t.cwd,t.invocationPrefix,t.argv)===t.invocationHash}function Ne(t){return Array.isArray(t)&&t.length>1&&t.length<=bt&&t.every(Be)&&$e(t)}function Le(t){return S(t.outputHash)&&b(t.pageSize)&&t.pageSize>=O&&t.pageSize<=P&&Ne(t.pages)&&b(t.totalCharacters)&&t.pages.reduce((e,n)=>e+n.characterLength,0)===t.totalCharacters&&b(t.byteLength)&&t.pages.reduce((e,n)=>e+n.byteLength,0)===t.byteLength}function Be(t){if(!t||typeof t!="object")return!1;let e=t;return Me(e)&&He(e)&&S(e.hash)}function Me(t){return Number.isSafeInteger(t.characterOffset)&&(t.characterOffset??-1)>=0&&Number.isSafeInteger(t.characterLength)&&(t.characterLength??0)>0}function He(t){return Number.isSafeInteger(t.byteOffset)&&(t.byteOffset??-1)>=0&&Number.isSafeInteger(t.byteLength)&&(t.byteLength??0)>0}function $e(t){let e=0,n=0;for(let o of t){if(o.characterOffset!==e||o.byteOffset!==n)return!1;e+=o.characterLength,n+=o.byteLength}return!0}function Q(t){mt(t,{recursive:!0,mode:448});let e=Yt(t);if(!e.isDirectory()||e.isSymbolicLink())throw new Error(`Output snapshot root is not a private directory: ${t}`);if(typeof process.getuid=="function"&&e.uid!==process.getuid())throw new Error(`Output snapshot root is not owned by the current user: ${t}`);process.platform!=="win32"&&Xt(t,448)}function ke(t){let e={...ge,...t};for(let[n,o]of Object.entries(e))if(!Number.isSafeInteger(o)||o<=0)throw new Error(`Output snapshot ${n} must be a positive integer.`);if(e.maxSnapshotBytes>e.maxAggregateBytes)throw new Error("Output snapshot maxSnapshotBytes cannot exceed maxAggregateBytes.");return e}function ze(t,e,n,o){N(t,()=>{We(t),Mt(t,e,n,"active",o)})}function J(t,e,n,o,r){if(!Number.isSafeInteger(n)||n<0||n>r.maxSnapshotBytes)throw new Error(`Command output exceeds the ${r.maxSnapshotBytes}-byte snapshot limit.`);N(t,()=>{Mt(t,e,n,o,r)})}function je(t,e,n,o,r){for(let s of t.filter(i=>i.state==="saved"&&i.snapshotId!==n).sort((i,a)=>i.updatedAtMs-a.updatedAtMs)){let i=t.filter(a=>a.snapshotId!==n);if(i.length+1<=r.maxSnapshotCount&&i.reduce((a,u)=>a+u.reservedBytes,o)<=r.maxAggregateBytes)break;tt(s.snapshotId,e),t.splice(t.indexOf(s),1)}}function Mt(t,e,n,o,r){if(!Number.isSafeInteger(n)||n<0||n>r.maxSnapshotBytes)throw new Error(`Command output exceeds the ${r.maxSnapshotBytes}-byte snapshot limit.`);let s=Ve(t);je(s,t,e,n,r);let i=s.find(d=>d.snapshotId===e),a=s.reduce((d,h)=>d+h.reservedBytes,0)-(i?.reservedBytes??0)+n,u=s.length+(i?0:1);if(u>r.maxSnapshotCount||a>r.maxAggregateBytes)throw new Error(`Output snapshot capacity is full (${u}/${r.maxSnapshotCount} snapshots, ${a}/${r.maxAggregateBytes} bytes). Redirect output to a file, narrow the query, or finish an explicit pagination sequence before retrying.`);let c=Date.now(),p={version:_t,snapshotId:e,pid:process.pid,...W()?{processIdentity:W()}:{},reservedBytes:n,state:o,createdAtMs:i?.createdAtMs??c,updatedAtMs:c};H(l(t,e,"reserve"),p)}function qe(t,e){N(t,()=>{X(l(t,e,"reserve"),{force:!0})})}function Ve(t){let e=[];for(let n of Ot(t,{withFileTypes:!0})){if(!n.isFile()||!n.name.endsWith(".reserve"))continue;let o=n.name.slice(0,-8);if(y(o))try{let r=JSON.parse(x(E(t,n.name),"output snapshot reservation"));if(!Ht(r)||r.snapshotId!==o)throw new Error("reservation identity is invalid");e.push(r)}catch(r){throw new Error(`Output snapshot reservation ${n.name} is invalid; retry after its owning process or snapshot expires.`,{cause:r})}}return e}function Ht(t){if(!t||typeof t!="object")return!1;let e=t;return De(e)&&Fe(e)&&Je(e)}function De(t){return t.version===_t&&typeof t.snapshotId=="string"&&y(t.snapshotId)}function Fe(t){return Number.isSafeInteger(t.pid)&&(t.pid??0)>0&&(t.processIdentity===void 0||nt(t.processIdentity)!==null&&t.processIdentity.pid===t.pid)}function Je(t){return Number.isSafeInteger(t.reservedBytes)&&(t.reservedBytes??-1)>=0&&(t.state==="active"||t.state==="complete"||t.state==="saved")&&Number.isSafeInteger(t.createdAtMs)&&Number.isSafeInteger(t.updatedAtMs)}function We(t){let e=Date.now();for(let n of Ot(t,{withFileTypes:!0})){if(!n.isFile()||!n.name.endsWith(".reserve"))continue;let o=n.name.slice(0,-8);if(!y(o))continue;let r=Xe(E(t,n.name)),s=Ke(l(t,o,"json"));Ge(r,s,e)||tt(o,t)}}function Ge(t,e,n){let o=Ye(t),r=t?n-t.updatedAtMs>It:!1;return o||e&&!r?!0:!e&&t!==null&&!r&&t.state==="complete"}function Xe(t){try{let e=JSON.parse(x(t,"output snapshot reservation"));return Ht(e)?e:null}catch{return null}}function Ye(t){return t?.state==="active"&&et(t.pid)&&(t.processIdentity===void 0||(()=>{let e=M(t.pid);return e!==null&&rt(t.processIdentity,e)})())}function Ke(t){try{return wt(t),!0}catch{return!1}}function N(t,e){Q(t);let n=E(t,ce),o=Date.now()+pe;for(;;){let r=ot(n,{kind:"output-snapshot-quota",processIdentity:W()});if(r.kind==="acquired")try{return e()}finally{r.lock.release()}if(Date.now()>=o)throw new Error("Output snapshot quota is busy. Retry the command.");Atomics.wait(de,0,0,he)}}function W(){return q===void 0&&(q=M(process.pid)),q}function v(t,e){y(t)&&N(e,()=>tt(t,e))}function tt(t,e){for(let n of["json","output","tmp","reserve"])X(l(e,t,n),{force:!0})}function l(t,e,n){if(!y(e))throw new Error("Output snapshot identifier is invalid.");return E(t,`${e}.${n}`)}function ht(t){if(!t)throw new Error("Incomplete output did not create a resumable snapshot.");return t}function dt(t){return t>=55296&&t<=56319}function $t(t,e,n,o){let r=Math.min(t.length,e);if(dt(t.charCodeAt(r-1))&&(r-=1),Buffer.byteLength(t.slice(0,r))>n){let s=0,i=r;for(;s<i;){let a=Math.ceil((s+i)/2);Buffer.byteLength(t.slice(0,a))<=n?s=a:i=a-1}r=s,dt(t.charCodeAt(r-1))&&(r-=1)}if(r<=0)throw new Error("Output page byte limit cannot contain one UTF-8 character.");if(o){let s=t.lastIndexOf(`
|
|
11
|
+
`,r-1);if(s>=0)return s+1}return r}function Ze(t){let e=tn({pageIndex:t.nextPageIndex,snapshotId:t.snapshotId});return{cursor:e,command:Vt(t.invocationPrefix,e)}}function Qe(t,e){let n="c".repeat(64),o={cursor:n,command:Vt(e,n)};if(!t.json){let i="9".repeat(String(f).length),a=`[scip-query output page: characters ${i}-${i} of ${i}]
|
|
12
|
+
|
|
13
|
+
[Incomplete: ${i} characters remain.]
|
|
14
|
+
Continue exactly:
|
|
15
|
+
${o.command}
|
|
16
|
+
`;return gt(k,Buffer.byteLength(a),1)}let r={kind:St,schemaVersion:Pt,producer:{name:"scip-query",version:t.producerVersion},command:t.command,contentType:"application/json",agentInstruction:"INCOMPLETE EVIDENCE: do not draw conclusions or report completion from this partial page. Run page.continuation.command exactly, then repeat until page.complete is true.",page:{offset:f,returnedCharacters:f,totalCharacters:f,omittedCharacters:f,remainingCharacters:f,complete:!1,outputHash:"f".repeat(64),continuation:o},content:""},s=Buffer.byteLength(`${JSON.stringify(r)}
|
|
17
|
+
`);return gt(z,s,2)}function gt(t,e,n){let o=Math.floor((_-e)/n);if(o<O)throw new Error(`The command invocation leaves fewer than ${O} bytes for client-safe output content. Use a shorter executable path.`);return Math.min(t,o)}function tn(t){return xt.test(t.snapshotId)?t.pageIndex===1?t.snapshotId:`${t.snapshotId}.${t.pageIndex.toString(36)}`:`4.${on(t.snapshotId)}.${t.pageIndex.toString(36)}`}function en(t,e){let n=kt(t);if(!n)throw new Error("Invalid output cursor. Run the command again without --output-cursor.");if(n.version===3&&n.invocationHash!==e)throw new Error("This output cursor belongs to a different command, working directory, or argument set. Run again without --output-cursor.");return n}function kt(t){let e=ue.exec(t);if(e){let o=e[2]??"1",r=Number.parseInt(o,36);return ft(r,o)?{version:4,pageIndex:r,snapshotId:e[1]}:null}let n=ae.exec(t);if(n){let o=sn(n[1]),r=Number.parseInt(n[2],36);return o&&ft(r,n[2])?{version:4,pageIndex:r,snapshotId:o}:null}try{let o=JSON.parse(Buffer.from(t,"base64url").toString("utf8"));return nn(o)?o:null}catch{return null}}function nn(t){if(!t||typeof t!="object")return!1;let e=t;return e.version===3&&S(e.invocationHash)&&rn(e)&&S(e.outputHash)&&typeof e.snapshotId=="string"&&y(e.snapshotId)}function rn(t){return Number.isSafeInteger(t.pageIndex)&&(t.pageIndex??-1)>=1&&Number.isSafeInteger(t.pageSize)&&(t.pageSize??0)>=O&&(t.pageSize??0)<=P}function on(t){if(!K.test(t))throw new Error("Output snapshot identifier is invalid.");return Buffer.from(t.replaceAll("-",""),"hex").toString("base64url")}function sn(t){let e=Buffer.from(t,"base64url");if(e.length!==16)return null;let n=e.toString("hex"),o=`${n.slice(0,8)}-${n.slice(8,12)}-${n.slice(12,16)}-${n.slice(16,20)}-${n.slice(20)}`;return K.test(o)?o:null}function y(t){return typeof t=="string"&&(xt.test(t)||K.test(t))}function zt(t,e,n,o){return I("sha256").update(JSON.stringify({command:t,cwd:e,invocationPrefix:n,argv:o})).digest("hex")}function jt(t){let e=[];for(let n=0;n<t.length;n+=1){let o=t[n];if(o==="--output-page-size"||o==="--output-cursor"){n+=1;continue}o.startsWith("--output-page-size=")||o.startsWith("--output-cursor=")||e.push(o)}return e}function an(t){return t.filter(e=>e!=="--raw-json"&&e!=="--raw-json=true")}function qt(t,e,n){return Jt([...t,...e,"--output-page-size",String(n)])}function Vt(t,e){return Jt([...t,ee,e])}function Dt(t){let e=t===void 0?["scip-query"]:[...t];if(!Ft(e))throw new Error("Output pagination invocation prefix must contain one to sixteen non-empty shell arguments.");return e}function Ft(t){return Array.isArray(t)&&t.length>0&&t.length<=16&&t.every(e=>typeof e=="string"&&e.length>0&&e.length<=2048&&!e.includes("\0")&&!e.includes("\r")&&!e.includes(`
|
|
18
|
+
`))}function un(t){return Array.isArray(t)&&t.length>0&&t.length<=256&&t.every(e=>typeof e=="string"&&e.length<=8192&&!e.includes("\0")&&!e.includes("\r")&&!e.includes(`
|
|
19
|
+
`))}function Jt(t){return t.map(e=>B(e,{omitSafeQuotes:!0})).join(" ")}function cn(t){let e=t.page.continuation,n=Math.max(t.page.offset,t.page.offset+t.page.returnedCharacters-1),o=`[scip-query output page: characters ${t.page.offset}-${n} of ${t.page.totalCharacters}]
|
|
20
|
+
`,r=e?`
|
|
21
|
+
[Incomplete: ${t.page.remainingCharacters} characters remain.]
|
|
22
|
+
Continue exactly:
|
|
23
|
+
${e.command}
|
|
24
|
+
`:"";return`${o}${t.content}${r}`}function pn(t,e,n,o){let r={offset:e.offset,returnedCharacters:e.content.length,totalCharacters:e.totalCharacters,omittedCharacters:e.totalCharacters-e.content.length,remainingCharacters:e.totalCharacters-o};return{kind:St,schemaVersion:Pt,producer:{name:"scip-query",version:t.producerVersion},command:t.command,contentType:t.json?"application/json":"text/plain",agentInstruction:n?"INCOMPLETE EVIDENCE: do not draw conclusions or report completion from this partial page. Run page.continuation.command exactly, then repeat until page.complete is true.":"OUTPUT COMPLETE: all rendered characters have been retrieved. Evaluate the command result's own coverage separately.",page:n?{...r,complete:!1,outputHash:e.outputHash,continuation:n}:{...r,complete:!0,outputHash:e.outputHash},content:e.content}}function ft(t,e){return Number.isSafeInteger(t)&&t>=1&&t.toString(36)===e}export{ee as a,fe as b,Rn as c,Un as d};
|
|
25
|
+
//# sourceMappingURL=chunk-B56T42J3.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as zt,d as M}from"./chunk-YTAP5Y2G.js";import{a as Ft}from"./chunk-NDUNO5JQ.js";import{c as A}from"./chunk-X6RMKHJQ.js";import{d as he,f as Ot}from"./chunk-JEVRKFRL.js";import{b as Bt,c as Wt}from"./chunk-BL6XJKTA.js";import{a as me,c as U,d as G}from"./chunk-O4UZSPPI.js";import{a as Ie}from"./chunk-B3PYOSCX.js";import{e as Z}from"./chunk-HGFDYOVB.js";import{a as _t,b as qt,c as Se,d as $t}from"./chunk-QZ7KQZRN.js";import{C as Be,b as ge,c as k,d as X,g as jt,h as Nt,i as _e,j as qe,m as $e}from"./chunk-TKD34PHN.js";import{H as Lt,N as Ct,O as Mt,a as Fe,c as Pt,d as pe,e as ye,o as je,q as Dt,r as At,t as kt}from"./chunk-U5RIG3JP.js";import{a as w,b as Ne,c as h,f as v,h as x,i as I,k as Tt,l as z}from"./chunk-62BDNPMI.js";import{createHash as yr,randomUUID as gr}from"crypto";import{existsSync as H,mkdirSync as mr,readdirSync as hr,rmSync as Vt,statSync as Yt}from"fs";import{basename as Sr,dirname as be,join as b}from"path";var F=1,Ue=1,te=".scipquery-generations",we="manifest.json",Jt="readers",Ir="gc.lock",br=128,ee=new Map,Qt={pid:process.pid,now:()=>new Date,randomToken:()=>gr(),isProcessAlive:Ie,readProcessIdentity:Se};function m(e){return b(be(e),te)}function He(e){return b(m(e),Ir)}function Da(e,t=Qt){let n=M(He(e.dbPath),{waitMs:5e3,directoryDurability:"recoverable"});if(!n)throw new Error("SQLite generation retention is busy; retry opening the index.");let r;try{let i=Er(e);if(i.source!=="immutable")return{generation:i,release(){}};let o=t.randomToken();if(!/^[A-Za-z0-9._-]+$/.test(o))throw new Error("SQLite generation reader token is unsafe.");let a=b(m(e.dbPath),Jt);mr(a,{recursive:!0}),r=b(a,`${t.pid}-${o}.json`);let s=t.readProcessIdentity(t.pid);U(r,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...s?{processIdentity:s}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!r||(c=!0,Vt(r,{force:!0}))}}}finally{n.release()}}function Kt(e,t,n=Qt,r={}){let i=b(m(e),Jt);if(!H(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,a=0,s=0,c=0;for(let d of hr(i,{withFileTypes:!0})){if(!d.isFile()||!d.name.endsWith(".json"))continue;let u=b(i,d.name),p=Mr(u);if(!p){c+=1;for(let g of t)o.add(g);continue}if(!Rr(p,n)){r.removeStale!==!1&&(Vt(u,{force:!0}),s+=1);continue}a+=1,o.add(p.generationIdentity)}return{protectedGenerations:o,activeLeases:a,staleLeasesRemoved:s,malformedLeases:c}}function wr(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,n=t.processIdentity===void 0?null:_t(t.processIdentity);return!vr(t)||!xr(t,n)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...n?{processIdentity:n}:{},acquiredAt:t.acquiredAt}}function vr(e){return e.version===1&&typeof e.token=="string"&&e.token.trim()!==""&&typeof e.generationIdentity=="string"&&/^[a-f0-9]{64}$/.test(e.generationIdentity)}function xr(e,t){return typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.acquiredAt=="string"&&Number.isFinite(Date.parse(e.acquiredAt))&&(e.processIdentity===void 0||!!(t&&t.pid===e.pid))}function Rr(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let n=t.readProcessIdentity(e.pid);return n===null||qt(e.processIdentity,n)}function j(e){try{let t=JSON.parse(I(b(m(e),"state.json"),"SQLite generation state"));return Dr(t)?t:null}catch{return null}}function V(e,t){return ne(m(e),t)}function ne(e,t){try{let n=JSON.parse(I(b(e,t,we),"SQLite generation manifest"));return Tr(n,t)?n:null}catch{return null}}function Er(e){let t=j(e.dbPath);if(t){let n=Gr(e,t.currentGeneration);if(n)return n;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(H(b(be(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return Pr(e,t?.currentGeneration)}function Aa(e){let t=j(e);if(t)return t.currentGeneration;try{let n=b(be(e),"meta.json"),r=H(n)?I(n,"reindex metadata"):void 0;return Xt(e,r)}catch{return null}}function L(e){return Ot(he(e))??e}function Gr(e,t){try{let n=b(m(e.dbPath),t),r=V(e.dbPath,t);if(!r)return null;let i=We(n,r.database),o=r.index?We(n,r.index):void 0,a=r.metadata?We(n,r.metadata):void 0;return!Zt(i,r.database)||!Ht(o,r.index)||!Ht(a,r.metadata)?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...a?{metadataPath:a,metadataRaw:I(a,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function Pr(e,t){let n=N(e.dbPath),r=b(be(e.dbPath),"meta.json"),i=H(r)?I(r,"reindex metadata"):void 0,o=H(e.indexPath)?e.indexPath:void 0;return{identity:t??Xt(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:r,metadataRaw:i},source:"legacy",databaseFileIdentity:n}}function Xt(e,t){let n=yr("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&n.update(L(t)),n.update(`\0${N(e)}`),n.digest("hex")}function N(e){let t=Yt(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function We(e,t){if(Sr(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return b(e,t.file)}function Zt(e,t){if(!H(e))return!1;let n=Ut(e);if(!n||n.size!==t.size)return!1;let r=`${e}\0${t.sha256}\0${n.identity}`;if(ee.has(r))return!0;let i=z(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=Ut(e);if(!o||o.identity!==n.identity||i!==t.sha256)return!1;for(ee.set(r,!0);ee.size>br;){let a=ee.keys().next().value;if(a===void 0)break;ee.delete(a)}return!0}function Ut(e){let t=Yt(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function Tr(e,t){return e.version===Ue&&e.identity===t&&ze(e.database)&&(e.index===void 0||ze(e.index))&&(e.metadata===void 0||ze(e.metadata))}function ze(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.file=="string"&&!!t.file&&Number.isSafeInteger(t.size)&&(t.size??-1)>=0&&typeof t.sha256=="string"&&/^[a-f0-9]{64}$/.test(t.sha256)}function Dr(e){return e.version===F&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&Ar(e.stableMirrors)&&kr(e.previousGeneration)&&Lr(e.publication)}function Ar(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.databaseFileIdentity=="string"&&!!t.databaseFileIdentity&&(t.indexFileIdentity===void 0||typeof t.indexFileIdentity=="string"&&!!t.indexFileIdentity)}function kr(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function Lr(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return Cr(t,n)&&Or(t)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}function Cr(e,t){return(e.mode==="incremental"||e.mode==="full")&&e.validation==="passed"&&e.converterDurationMs!==void 0&&t.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)}function Or(e){return(e.scipCompanion===void 0||e.scipCompanion==="current"||e.scipCompanion==="deferred")&&(e.typescriptOverlayGeneration===void 0||typeof e.typescriptOverlayGeneration=="string"&&!!e.typescriptOverlayGeneration)&&(e.scipCompanion!=="deferred"||!!e.typescriptOverlayGeneration)}function Ht(e,t){return!t||!!(e&&Zt(e,t))}function Mr(e){let t;try{t=wr(JSON.parse(I(e,"SQLite generation reader lease")))}catch{t=null}return t}import{existsSync as en,readdirSync as tn,rmSync as nn}from"fs";import{join as Y}from"path";import{create as on,fromBinary as an,toBinary as Na}from"@bufbuild/protobuf";import{deserializeSCIP as Ve,DocumentSchema as sn,IndexSchema as cn,serializeSCIP as dn}from"@c4312/scip";var Ye=1,re="typescript-scip-fragments";function Ba(e){let t=new Set,n=[];for(let o of e){let a=ve(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=an(sn,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);n.push(s)}let r=dn(on(cn,{documents:n,externalSymbols:[]})),i=Ve(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function Fr(e){let t=Y(e,re);return{rootDir:t,blobDir:Y(t,"blobs"),generationDir:Y(t,"generations")}}function ln(e){let t=jr(e);return Nr(t.baseIndex,t.completeDocuments,"assembled")}function jr(e){let t=Ve(e.baseIndexBytes);Je(t.metadata,zr(e)),Wr(t.externalSymbols);let n=Ur(e),r=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=ve(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let d=n.get(c);if(!d){i.push(s);continue}if(n.delete(c),d.bytes===null){a.push(c);continue}let u=rn(c,d.bytes);i.push(u),o.push(u)}for(let s of[...n.keys()].sort()){let c=n.get(s);if(c.bytes===null)continue;if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let d=rn(s,c.bytes);i.push(d),o.push(d)}return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function rn(e,t){let n=an(sn,t);if(n.relativePath!==e)throw new Error(`TypeScript fragment path mismatch: expected ${e}, got ${n.relativePath}`);return n}function Nr(e,t,n){let r=dn(on(cn,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Ve(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function Wa(e,t){let n=Fr(e);if(!en(n.generationDir))return;let r=new Set(t.map(a=>Br(a))),i=tn(n.generationDir).filter(a=>a.endsWith(".json")),o=new Set;for(let a of i.filter(s=>r.has(s))){let s=_r(x(Y(n.generationDir,a),{maxBytes:w,inputKind:"TypeScript fragment manifest"}));for(let c of s.documents)o.add(`${c.blobHash}.scipdoc`)}for(let a of i)r.has(a)||nn(Y(n.generationDir,a),{force:!0});if(en(n.blobDir))for(let a of tn(n.blobDir))o.has(a)||nn(Y(n.blobDir,a),{force:!0})}function _r(e){let t=JSON.parse(e);qr(t);let n=new Set;for(let r of t.documents){if($r(r),ve(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function qr(e){if(e.version!==Ye||typeof e.producerIdentity!="string"||typeof e.projectIdentity!="string"||typeof e.generationIdentity!="string"||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.documents))throw new Error("invalid TypeScript fragment generation manifest")}function $r(e){if(!e||typeof e.relativePath!="string"||typeof e.blobHash!="string"||!/^[a-f0-9]{64}$/.test(e.blobHash)||typeof e.byteLength!="number"||!Number.isInteger(e.byteLength)||e.byteLength<0||typeof e.documentIdentity!="string"||!e.documentIdentity)throw new Error("invalid TypeScript fragment record")}function Br(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${A(e)}.json`}function Wr(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Je(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==Ct(t))throw new Error("TypeScript SCIP shard producer identity changed")}function zr(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function ve(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function Ur(e){let t=new Map;for(let n of e.fragments){let r=ve(n.relativePath);if(t.has(r))throw new Error(`duplicate TypeScript fragment replacement: ${r}`);t.set(r,n)}if(t.size===0)throw new Error("TypeScript index assembly requires at least one replacement");return t}function za(e,t,n){let r=e.files.filter(i=>{let o=Fe(i.path,e.languages);return o==="ambient"||o==="config"&&(!Lt(i.path)||n.has(i.path))}).map(i=>{let a=Fe(i.path,e.languages)==="config"?i.semanticHash:void 0;return{path:i.path,size:a===void 0?i.size:0,hash:a??i.hash}}).sort((i,o)=>i.path.localeCompare(o.path));return`typescript-project-v3:${A(JSON.stringify({version:3,producerIdentity:t,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),nonSourceInputs:r}))}`}function Ua(e,t){return A(JSON.stringify({version:1,producerIdentity:t,snapshot:pe(e)}))}import{fromBinary as Kr}from"@bufbuild/protobuf";import{MetadataSchema as Xr}from"@c4312/scip";var R=class extends Error{},Hr=0,Vr=1,un=2,Yr=5;function Qe(e,t,n){let r=0,i=0;for(;t<n;){let o=e[t];if(t+=1,i<53)r+=(o&127)*2**i;else if((o&127)!==0)throw new R("varint exceeds the safe integer range");if((o&128)===0)return{value:r,pos:t};if(i+=7,i>63)throw new R("varint is longer than 64 bits")}throw new R("varint runs past the end of the buffer")}function*S(e,t=0,n=e.length){let r=t;for(;r<n;){let i=r,o=Qe(e,r,n);r=o.pos;let a=Math.floor(o.value/8),s=o.value%8;if(a===0)throw new R("field number 0 is invalid");let c=r,d=0;if(s===Hr){let u=Qe(e,r,n);d=u.value,r=u.pos}else if(s===un){let u=Qe(e,r,n);if(c=u.pos,r=u.pos+u.value,r>n)throw new R("length-delimited field runs past the end of the buffer")}else if(s===Vr)r+=8;else if(s===Yr)r+=4;else throw new R(`unsupported wire type ${s}`);if(r>n)throw new R("field value runs past the end of the buffer");yield{fieldNumber:a,wireType:s,fieldStart:i,valueStart:c,valueEnd:r,fieldEnd:r,varint:d}}}function ie(e){if(!Number.isSafeInteger(e)||e<0)throw new R(`cannot encode varint ${e}`);let t=[],n=e;do{let r=n%128;n=Math.floor(n/128),n>0&&(r|=128),t.push(r)}while(n>0);return Uint8Array.from(t)}function xe(e){return ie(e*8+un)}var Jr=1,Qr=3;function oe(e){let t=new TextDecoder,n;for(let r of S(e))if(!(r.fieldNumber!==Jr||r.wireType!==2))for(let i of S(e,r.valueStart,r.valueEnd)){if(i.fieldNumber!==Qr||i.wireType!==2)continue;let o=t.decode(e.subarray(i.valueStart,i.valueEnd));o&&(n=o)}return n}import{existsSync as Ee,readdirSync as Ke,rmSync as fn}from"fs";import{join as P}from"path";var Ge=1,ae="typescript-scip-overlays",pn="typescript-project-v3:";function Zr(e){let t=mn(e.cacheDir,e.previousGenerationIdentity);ni(e,t);let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=Pe(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);r.add(a),n.set(a,ii(e.cacheDir,o))}if(ti(e,n,r),r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Ge,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((o,a)=>o.relativePath.localeCompare(a.relativePath))};return oi(e.cacheDir,i),i}function is(e){let t=[],n=!1,r=new TextDecoder("utf-8",{fatal:!0});for(let i of S(e.indexBytes)){if(i.wireType!==2)continue;let o=e.indexBytes.subarray(i.valueStart,i.valueEnd);if(i.fieldNumber===1)Je(Kr(Xr,o),e.packageVersion),n=!0;else{if(i.fieldNumber===3)throw new Error("TypeScript overlay seed cannot contain external symbols");if(i.fieldNumber===2){let a=ei(o,r);t.push({relativePath:a,bytes:o,occurrences:0,symbols:0,referenceFragments:[]})}}}if(!n)throw new Error("TypeScript overlay seed has no producer identity");return Zr({...e,previousGenerationIdentity:e.generationIdentity,nextGenerationIdentity:e.generationIdentity,baseShardCurrent:!0,fragments:t})}function ei(e,t){let n;for(let r of S(e))r.fieldNumber===1&&r.wireType===2&&(n=t.decode(e.subarray(r.valueStart,r.valueEnd)));if(!n)throw new Error("TypeScript overlay seed document has no path");return n}function ti(e,t,n){for(let r of e.retainedDocuments??[]){hn(r);let i=Pe(r.relativePath);if(n.has(i))throw new Error(`duplicate TypeScript overlay: ${i}`);let o=t.get(i);if(!r.blobHash||!o||o.blobHash!==r.blobHash||o.byteLength!==r.byteLength)throw new Error(`retained TypeScript overlay does not match its accepted blob: ${i}`);gn(e.cacheDir,r),n.add(i)}}function ni(e,t){if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t?.producerIdentity!==void 0&&t.producerIdentity!==e.producerIdentity)throw new Error("TypeScript overlay producer identity changed");let n=ri(e,t);if(t&&t.projectIdentity!==e.projectIdentity&&!e.allowProjectIdentityChange&&!n)throw new Error("TypeScript overlay project identity changed")}function ri(e,t){return e.allowLegacyProjectIdentityMigration===!0&&t!==null&&!t.projectIdentity.startsWith(pn)&&e.projectIdentity.startsWith(pn)}function os(e){let t=mn(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=gn(e.cacheDir,r);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return ln({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function gn(e,t){let n=v(P(se(e),"blobs",`${t.blobHash}.scipdoc`),{maxBytes:Ne,inputKind:"TypeScript overlay blob"});if(n.byteLength!==t.byteLength||A(n)!==t.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${t.relativePath}`);return n}function as(e,t){let n=se(e),r=P(n,"generations");if(!Ee(r))return;let i=new Set(t.map(Ze)),o=new Set;for(let s of Ke(r).filter(c=>i.has(c))){let c=Xe(x(P(r,s),{maxBytes:w,inputKind:"TypeScript overlay manifest"}));for(let d of c.overlays)d.blobHash&&o.add(`${d.blobHash}.scipdoc`)}for(let s of Ke(r))i.has(s)||fn(P(r,s),{force:!0});let a=P(n,"blobs");if(Ee(a))for(let s of Ke(a))o.has(s)||fn(P(a,s),{force:!0})}function mn(e,t){let n=P(se(e),"generations",Ze(t));if(!Ee(n))return null;let r=Xe(x(n,{maxBytes:w,inputKind:"TypeScript overlay manifest"}));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function ii(e,t){let n=Pe(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=A(r);return Ft({blobDir:P(se(e),"blobs"),blobHash:i,bytes:r,relativePath:n,inputKind:"TypeScript overlay blob"}),{relativePath:n,blobHash:i,byteLength:r.byteLength}}function oi(e,t){let n=P(se(e),"generations",Ze(t.generationIdentity));if(Ee(n)){let r=Xe(x(n,{maxBytes:w,inputKind:"TypeScript overlay manifest"}));if(yn(r)!==yn(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}U(n,t,{spacing:2,trailingNewline:!0})}function Xe(e){let t=JSON.parse(e);ai(t);let n=new Set;for(let r of t.overlays){if(hn(r),Pe(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function ai(e){if(e.version!==Ge||!Re(e.producerIdentity)||!Re(e.projectIdentity)||!Re(e.baseGenerationIdentity)||!Re(e.generationIdentity)||typeof e.createdAt!="string"||!Number.isFinite(Date.parse(e.createdAt))||!Array.isArray(e.overlays))throw new Error("invalid TypeScript overlay manifest")}function Re(e){return typeof e=="string"&&e!==""}function hn(e){let t=e;if(!t||typeof t.relativePath!="string"||t.blobHash!==null&&(typeof t.blobHash!="string"||!/^[a-f0-9]{64}$/.test(t.blobHash))||!Number.isInteger(t.byteLength)||t.byteLength<0||t.blobHash===null&&t.byteLength!==0)throw new Error("invalid TypeScript overlay record")}function se(e){return P(e,ae)}function Ze(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${A(e)}.json`}function yn(e){return A(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Pe(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}import{execFileSync as si}from"child_process";import{existsSync as ci,readdirSync as Sn}from"fs";import{extname as In,join as bn}from"path";var wn=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),di=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function fs(e){let t=[],n=li(e),r=yi(e);for(let i of di){if(ui(e,i.files)){t.push(i.language);continue}if(fi(n,i.globs)){t.push(i.language);continue}hi(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&et(t,"javascript"),Si(t,r),t}function li(e){try{return Sn(e)}catch{return[]}}function ui(e,t){return t?.length?t.some(n=>ci(bn(e,n))):!1}function fi(e,t){return t?.length?e.some(n=>t.some(r=>pi(n,r))):!1}function pi(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function yi(e){let t=mi(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=Sn(i,{withFileTypes:!0})}catch{continue}gi(i,o,r,n)}return n}function gi(e,t,n,r){for(let i of t){if(i.name.startsWith(".")&&!i.name.endsWith("proj")&&!i.name.endsWith("sln")&&i.isDirectory())continue;let o=bn(e,i.name);if(i.isDirectory()){wn.has(i.name)||n.push(o);continue}let a=In(i.name).toLowerCase();a&&r.add(a)}}function mi(e){try{let t=Dt(e,26214400,()=>si("git",["-C",e,"ls-files","-co","-v","-z","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:52428800,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"})),n=new Set;for(let r of At(t)){if(r.split("/").some(o=>wn.has(o)))continue;let i=In(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function hi(e,t){return t?.length?t.some(n=>e.has(n)):!1}function et(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}function Si(e,t){if(e.includes("cpp")&&e.includes("c")){let n=t.has(".c"),r=[".cc",".cpp",".cxx"].some(i=>t.has(i));n&&!r?et(e,"cpp"):n||et(e,"c")}}import{writeSync as Ii}from"fs";function E(e,t,n="File"){let r=0;for(;r<t.byteLength;){let i=Ii(e,t,r,t.byteLength-r);if(i<=0)throw new Error(`${n} write made no forward progress.`);r+=i}}import{closeSync as vn,openSync as bi,renameSync as wi,rmSync as vi}from"fs";import{create as Te,fromBinary as xn,toBinary as xi}from"@bufbuild/protobuf";import{DocumentSchema as De,IndexSchema as Ri,MetadataSchema as Ei,PositionEncoding as tt,SymbolInformationSchema as Gi,SymbolRole as Rn}from"@c4312/scip";var nt=2,Pi=3,Ti=1,Di=2,Ai=3,ki=4,Li=6,Ci=1,Oi=2,Mi=3;function xs(e){let t;try{t=v(e,{inputKind:"SCIP sanitization input",maxBytes:h})}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}try{return Fi(t,e)}catch(n){if(n instanceof R)return{removedDefinitionOccurrences:0,touchedDocuments:0};throw n}}function Fi(e,t){let n=new TextDecoder,r=new Set;ji(e,n,r);let i=0,o=0,a=[],s=$i(e);for(let c of S(e)){if(c.wireType!==2||c.fieldNumber!==nt)continue;let d=_i(e,c,n,r,s);An(d)&&(i+=d.removed,o+=d.symbols.length,a.push({field:c,repair:d}))}return a.length>0&&qi(e,t,a),Pn(i,a.length,o)}function En(e,t,n,r){if((t&Rn.Definition)!==0){if(!e){r.removed++;return}e.startsWith("local ")||n.has(e)||(n.add(e),r.symbols.push(e))}}function Gn(e,t){return An(t)?Te(De,{...e,positionEncoding:t.positionEncoding??e.positionEncoding,occurrences:e.occurrences.filter(n=>n.symbol||(n.symbolRoles&Rn.Definition)===0),symbols:[...e.symbols,...t.symbols.map(n=>Te(Gi,{symbol:n}))]}):e}function Pn(e,t,n){return{removedDefinitionOccurrences:e,touchedDocuments:t,...n>0?{recoveredDefinitionSymbols:n}:{}}}function ji(e,t,n){for(let r of S(e))r.wireType===2&&(r.fieldNumber===nt?Ni(e,r,t,n):r.fieldNumber===Pi&&Tn(e,r,t,n))}function Ni(e,t,n,r){for(let i of S(e,t.valueStart,t.valueEnd))i.wireType===2&&(i.fieldNumber===Ti?je(n.decode(e.subarray(i.valueStart,i.valueEnd))):i.fieldNumber===Ai&&Tn(e,i,n,r))}function Tn(e,t,n,r){for(let i of S(e,t.valueStart,t.valueEnd)){if(i.wireType!==2||i.fieldNumber!==Ci)continue;let o=n.decode(e.subarray(i.valueStart,i.valueEnd));o&&r.add(o)}}function _i(e,t,n,r,i){let o={removed:0,symbols:[]},a="",s=tt.UnspecifiedPositionEncoding;for(let c of S(e,t.valueStart,t.valueEnd)){if(c.fieldNumber===ki&&c.wireType===2&&(a=n.decode(e.subarray(c.valueStart,c.valueEnd))),c.fieldNumber===Li&&c.wireType===0&&(s=c.varint),c.wireType!==2||c.fieldNumber!==Di)continue;let{symbol:d,symbolRoles:u}=Bi(e,c,n);En(d,u,r,o)}return o.positionEncoding=rt(a,s,i),o}function qi(e,t,n){let r=`${t}.sanitize-tmp`,i=bi(r,"w",384);try{let o=0;for(let{field:a,repair:s}of n){E(i,e.subarray(o,a.fieldStart));let c=Gn(xn(De,e.subarray(a.valueStart,a.valueEnd)),s),d=xi(De,c);E(i,xe(nt)),E(i,ie(d.byteLength)),E(i,d),o=a.fieldEnd}E(i,e.subarray(o))}catch(o){throw vn(i),vi(r,{force:!0}),o}vn(i),wi(r,t)}function Dn(e){let t=new Set;for(let a of e.documents){je(a.relativePath);for(let s of a.symbols)s.symbol&&t.add(s.symbol)}for(let a of e.externalSymbols)a.symbol&&t.add(a.symbol);let n=0,r=0,i=0,o=e.documents.map(a=>{let s={removed:0,symbols:[]};for(let d of a.occurrences)En(d.symbol,d.symbolRoles,t,s);s.positionEncoding=rt(a.language,a.positionEncoding,e.metadata);let c=Gn(a,s);return c!==a&&i++,n+=s.removed,r+=s.symbols.length,c});return{index:i===0?e:Te(Ri,{...e,documents:o}),...Pn(n,i,r)}}function An(e){return e.removed>0||e.symbols.length>0||e.positionEncoding!==void 0}function rt(e,t,n){if(t===tt.UnspecifiedPositionEncoding&&!(e!==""&&e!=="python")&&!(n?.toolInfo?.name!=="scip-python"||!["0.7.4","0.7.5"].includes(n.toolInfo.version)))return tt.UTF16CodeUnitOffsetFromLineStart}function it(e,t){let n=rt(e.language,e.positionEncoding,t);return n===void 0?e:Te(De,{...e,positionEncoding:n})}function $i(e){let t;for(let n of S(e)){if(n.fieldNumber!==1||n.wireType!==2)continue;let r=xn(Ei,e.subarray(n.valueStart,n.valueEnd));if(!r.toolInfo||t&&JSON.stringify(t.toolInfo)!==JSON.stringify(r.toolInfo))return;t=r}return t}function Bi(e,t,n){let r="",i=0;for(let o of S(e,t.valueStart,t.valueEnd))o.fieldNumber===Oi&&o.wireType===2?r=n.decode(e.subarray(o.valueStart,o.valueEnd)):o.fieldNumber===Mi&&o.wireType===0&&(i=o.varint);return{symbol:r,symbolRoles:i}}import{writeSync as Wi,closeSync as ce,openSync as ot,readSync as zi,renameSync as Ui,rmSync as On,statSync as Hi,writeFileSync as Mn}from"fs";import{create as de,fromBinary as Vi,toBinary as Yi}from"@bufbuild/protobuf";import{deserializeSCIP as Fn,serializeSCIP as jn,DocumentSchema as Ji,IndexSchema as kn,MetadataSchema as at,SymbolInformationSchema as Qi,SymbolRole as Ki}from"@c4312/scip";function Nn(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1){let i=e[0];return de(kn,{...i,documents:i.documents.map(o=>it(o,i.metadata))})}let t=Xi(e),n=Zi(e.flatMap(i=>i.documents.map(o=>it(o,i.metadata)))),r=qn(e.flatMap(i=>i.externalSymbols??[]));return de(kn,{metadata:t,documents:n,externalSymbols:r})}function Cs(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>Fn(v(i,{inputKind:"SCIP merge input",maxBytes:h}))),r=Nn(n);return Mn(t,jn(r)),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Os(e,t){if(e.length===0)throw new Error("Cannot concatenate zero SCIP files");let n=0;for(let o of e)if(n+=Hi(o).size,n>h)throw new Error(`Concatenated SCIP output exceeds the ${h}-byte artifact limit. Reduce the indexed project scope or use compatible cached generations.`);let r=Buffer.allocUnsafe(1024*1024),i=ot(t,"w",384);try{for(let o of e){let a=ot(o,"r");try{let s=0;for(;(s=zi(a,r,0,r.byteLength,null))>0;){let c=0;for(;c<s;)c+=Wi(i,r,c,s-c)}}finally{ce(a)}}}catch(o){throw ce(i),On(t,{force:!0}),o}ce(i)}function Ms(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=Z("reindex.publish.scip-output.deserialize",()=>e.map(o=>Fn(v(o,{inputKind:"SCIP merge input",maxBytes:h})))),r=Z("reindex.publish.scip-output.merge",()=>Nn(n)),i=Z("reindex.publish.scip-output.sanitize",()=>Dn(r));return Z("reindex.publish.scip-output.serialize",()=>Mn(t,jn(i.index))),{documentCount:i.index.documents.length,externalSymbolCount:i.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:i.removedDefinitionOccurrences,...i.recoveredDefinitionSymbols?{recoveredDefinitionSymbols:i.recoveredDefinitionSymbols}:{},touchedDocuments:i.touchedDocuments}}var Ln=1;function _n(e,t,n){let r=v(e,{inputKind:"SCIP normalization input",maxBytes:h}),i=oe(r),o=[];for(let c of S(r))c.fieldNumber===Ln&&c.wireType===2&&o.push(c);if(o.length===0)throw new Error("Cannot rebase a SCIP index without metadata");if((i??"")!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${i??""}`);let a=`${e}.rebase-tmp`,s=ot(a,"w",384);try{let c=0;for(let d of o){E(s,r.subarray(c,d.fieldStart));let u=Vi(at,r.subarray(d.valueStart,d.valueEnd));u.projectRoot=n;let p=Yi(at,u);E(s,xe(Ln)),E(s,ie(p.byteLength)),E(s,p),c=d.fieldEnd}E(s,r.subarray(c))}catch(c){throw ce(s),On(a,{force:!0}),c}ce(s),Ui(a,e)}function Xi(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let i of e.slice(1)){let o=i.metadata?.projectRoot;if(n&&o&&o!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${o}`)}return e.every(i=>JSON.stringify(i.metadata?.toolInfo)===JSON.stringify(t.toolInfo))?t:de(at,{...t,toolInfo:void 0})}function Zi(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}eo(r,n),t.set(n.relativePath,de(Ji,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:to([...r.occurrences,...n.occurrences]),symbols:qn([...r.symbols,...n.symbols]),text:r.text||n.text,positionEncoding:r.occurrences.length?r.positionEncoding:n.positionEncoding}))}return[...t.values()]}function eo(e,t){for(let i of["language","text"])if(e[i]&&t[i]&&e[i]!==t[i])throw new Error(`Cannot merge ${e.relativePath}: conflicting ${i}. Reindex one consistent source snapshot.`);if(e.occurrences.length&&t.occurrences.length&&e.positionEncoding!==t.positionEncoding)throw new Error(`Cannot merge ${e.relativePath}: incompatible column encodings.`);let n=Cn(e),r=Cn(t);for(let[i,o]of r){let a=n.get(i);if(a!==void 0&&(o.length===0||JSON.stringify(a)!==JSON.stringify(o)))throw new Error(`Cannot merge ${e.relativePath}: conflicting document-local identity ${i}.`)}}function Cn(e){let t=new Map;for(let n of e.occurrences){if(!n.symbol.startsWith("local "))continue;let r=t.get(n.symbol)??new Set;(n.symbolRoles&Ki.Definition)!==0&&r.add(JSON.stringify(st(n.range))),t.set(n.symbol,r)}return new Map([...t].map(([n,r])=>[n,[...r].sort()]))}function st(e){return e.length===3?[e[0],e[1],e[0],e[2]]:e}function to(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify({...r,range:st(r.range),enclosingRange:st(r.enclosingRange)});t.has(i)||(t.add(i),n.push(r))}return n}function qn(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,de(Qi,{symbol:r.symbol,documentation:ro([...r.documentation,...n.documentation]),relationships:no([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function no(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function ro(e){return[...new Set(e)]}import{createHash as pt,randomUUID as _s}from"crypto";import{closeSync as io,copyFileSync as $s,existsSync as y,mkdirSync as oo,openSync as ao,readSync as so,readdirSync as yt,renameSync as lt,rmSync as J,statSync as _}from"fs";import{basename as Bn,dirname as T,join as f,relative as $n}from"path";import co from"better-sqlite3";var lo=Object.freeze({maxGenerations:2,maxLogicalBytes:2*1024*1024*1024});function Wn(e){let t=m(e.outputDb),n=So(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Io(e,n),o=mt({generationRoot:t,databasePath:e.tempOutputDb,indexPath:y(r)?r:void 0,verifiedIndexArtifact:i,metadataPath:y(e.tempMetaPath)?e.tempMetaPath:void 0}),a=(e.now??(()=>new Date))().toISOString(),s={version:F,currentGeneration:o.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:a},c=G(f(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||ft(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),Do(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),ft(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let d=o.identity,u={...s,stableMirrors:gt(e.outputDb,e.outputScip)};G(f(t,"state.json"),u,{spacing:2,trailingNewline:!0});let p=zn(e.outputDb,{now:e.now}),g=X(o.directorySync,c.directorySync);return{currentGeneration:d,...n?{previousGeneration:n}:{},retention:p,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}function uo(e,t,n,r=()=>new Date){if(!y(e))return null;let i=j(e),o=f(m(e),"state.json");if(Lo(e,i))return i;let a=m(e),s=!i&&y(o)?wo(n,e,t):void 0;if(s&&!ne(a,s))return null;let c=mt({generationRoot:a,databasePath:e,indexPath:y(t)?t:void 0,metadataPath:y(n)?n:void 0,forcedIdentity:i?.currentGeneration??s}),d=ko(c.identity,e,t,i,r);return G(f(a,"state.json"),d,{spacing:2,trailingNewline:!0}),d}function Ks(e,t,n=()=>new Date){if(!y(e)||!y(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=j(e),i=m(e),o=mt({generationRoot:i,databasePath:e,indexPath:y(f(T(e),"index.scip"))?f(T(e),"index.scip"):void 0,metadataPath:t}),a=r&&r.currentGeneration!==o.identity?Vn(e,r.currentGeneration):void 0,s={version:F,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:gt(e,f(T(e),"index.scip")),...a?{previousGeneration:a}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return G(f(m(e),"state.json"),s,{spacing:2,trailingNewline:!0}),zn(e,{now:n}),s}function zn(e,t={}){let n=go(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=M(He(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:"another process owns local generation retention"};try{return fo(e,t,n,i)}catch(a){let s={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:n,at:i,reason:a instanceof Error?a.message:String(a)};try{Hn(e,s)}catch{}return s}finally{o.release()}}function fo(e,t,n,r){let i=j(e),o=mo(e),a=Kt(e,o.map(W=>W.identity),{isProcessAlive:t.isProcessAlive??Ie,readProcessIdentity:t.readProcessIdentity??Se}),s=new Set(a.protectedGenerations);i?.currentGeneration&&s.add(i.currentGeneration),i?.previousGeneration?.generationIdentity&&s.add(i.previousGeneration.generationIdentity);let{generationCount:c,logicalBytes:d,removedGenerations:u,removedLogicalBytes:p}=yo(o,s,n,t),g=c>n.maxGenerations||d>n.maxLogicalBytes,K={state:g?"protected":u>0?"collected":"within-bounds",generationCount:c,logicalBytes:d,protectedGenerations:s.size,activeReaderLeases:a.activeLeases,staleReaderLeasesRemoved:a.staleLeasesRemoved,malformedReaderLeases:a.malformedLeases,removedGenerations:u,removedLogicalBytes:p,limits:n,at:r,...g?{reason:po(a.malformedLeases)}:{}};return Hn(e,K),K}function po(e){return e>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}function yo(e,t,n,r){let i=e.length,o=e.reduce((c,d)=>c+d.logicalBytes,0),a=0,s=0;for(let c of e){if(i<=n.maxGenerations&&o<=n.maxLogicalBytes)break;t.has(c.identity)||(r.onBeforeRemove?.(c.identity),J(c.path,{recursive:!0,force:!0}),i-=1,o-=c.logicalBytes,a+=1,s+=c.logicalBytes)}return{generationCount:i,logicalBytes:o,removedGenerations:a,removedLogicalBytes:s}}function go(e={}){let t={...lo,...e};if(!Number.isSafeInteger(t.maxGenerations)||t.maxGenerations<2)throw new Error("Local SQLite generation retention must keep at least current and previous generations.");if(!Number.isSafeInteger(t.maxLogicalBytes)||t.maxLogicalBytes<=0)throw new Error("Local SQLite generation byte retention must be a positive safe integer.");return t}function mo(e){let t=m(e);return y(t)?yt(t,{withFileTypes:!0}).filter(n=>n.isDirectory()&&/^[a-f0-9]{64}$/.test(n.name)).map(n=>{let r=f(t,n.name),i=ne(t,n.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Un(r);return{identity:n.name,path:r,logicalBytes:o,modifiedAtMs:_(r).mtimeMs}}).sort((n,r)=>n.modifiedAtMs-r.modifiedAtMs||n.identity.localeCompare(r.identity)):[]}function Un(e){let t=0;for(let n of yt(e,{withFileTypes:!0})){let r=f(e,n.name);n.isDirectory()?t+=Un(r):n.isFile()&&(t+=_(r).size)}return t}function Hn(e,t){U(f(m(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function ke(e,t=f(T(e),"meta.json")){let n=f(m(e),"state.json");if(!y(n))return{state:"legacy",statePath:n};let r=j(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=V(e,r.currentGeneration),o=i!==null,a=i?ho(e,t,i,r):!1,s=r.previousGeneration?y(f(T(e),r.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:n,currentMatches:a,recoveryExists:s,generation:r,reason:Co(o,a)}:{state:"current",statePath:n,currentMatches:a,recoveryExists:s,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function ho(e,t,n,r){if(!Oo(e,r)||!ut(e,n.database))return!1;let i=f(T(e),"index.scip");if(n.index&&!ut(i,n.index))return!1;if(!n.metadata)return!y(t);if(!y(t))return!1;let o=f(m(e),n.identity,n.metadata.file);return y(o)&&L(I(t,"reindex metadata"))===L(I(o,"immutable reindex metadata"))}function ut(e,t){return y(e)&&_(e).isFile()&&_(e).size===t.size}function So(e){let t=uo(e.outputDb,e.outputScip,e.metaPath);return t?Vn(e.outputDb,t.currentGeneration):void 0}function Io(e,t){if(!e.preserveOutputScip)return;if(!t)throw new Error("deferred SCIP publication requires an accepted immutable generation");let n=ke(e.outputDb,e.metaPath);if(n.state!=="current"||n.generation.currentGeneration!==t.generationIdentity){let i=n.state==="current"?"generation identity changed":"reason"in n?n.reason:`generation state is ${n.state}`;throw new Error(`deferred SCIP publication requires a verified accepted companion: ${i}`)}let r=V(e.outputDb,t.generationIdentity);if(!r?.index||!ut(e.outputScip,r.index))throw new Error("deferred SCIP publication requires the verified accepted index artifact");return r.index}function gt(e,t){return{databaseFileIdentity:N(e),...y(t)?{indexFileIdentity:N(t)}:{}}}function Vn(e,t){let n=f(m(e),t),r=V(e,t);if(!r)throw new Error("Cannot retain recovery artifacts without a valid generation manifest.");let i=f(n,r.database.file),o=r.metadata?f(n,r.metadata.file):void 0;return{generationIdentity:t,databasePath:$n(T(e),i),...o?{metadataPath:$n(T(e),o)}:{}}}function bo(e){if(y(e))for(let t of yt(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&J(f(e,t.name),{recursive:!0,force:!0})}function wo(e,t,n=f(T(t),"index.scip")){let r=pt("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(Ae(t)),y(n)&&r.update(`\0${Ae(n)}`),y(e)&&r.update(`\0${L(I(e,"reindex metadata"))}`),r.digest("hex")}function mt(e){Ao(e.databasePath);let t=ct(e.databasePath),n=e.indexPath?e.verifiedIndexArtifact?Eo(e.indexPath,e.verifiedIndexArtifact):ct(e.indexPath):void 0,r=e.metadataPath?ct(e.metadataPath):void 0,i=e.forcedIdentity??Ro(t,n,e.metadataPath),o=f(e.generationRoot,i),a=f(o,we);if(y(a))return xo(e,i,o,t,n);let s=[ge(e.generationRoot)];bo(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;J(c,{recursive:!0,force:!0}),oo(c,{recursive:!0});try{vo(e,c,t,n,r,s);let d=G(f(c,we),{version:Ue,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0});d.directorySync!=="not-requested"&&s.push(d.directorySync),s.push(k(c)),lt(c,o),s.push(k(e.generationRoot))}finally{J(c,{recursive:!0,force:!0})}return{identity:i,directorySync:X(...s)}}function vo(e,t,n,r,i,o){o.push(dt(e.databasePath,f(t,n.file))),r&&e.indexPath&&o.push(dt(e.indexPath,f(t,r.file))),i&&e.metadataPath&&o.push(dt(e.metadataPath,f(t,i.file)))}function xo(e,t,n,r,i){let o=ne(e.generationRoot,t);if(o&&Yn(n,o.database,r)&&Po(n,o.index,i)&&To(n,o.metadata,e.metadataPath))return{identity:t,directorySync:k(e.generationRoot)};throw new Error(`SQLite generation ${t} already exists with different or corrupt artifacts.`)}function Ro(e,t,n){let r=pt("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${L(I(n,"reindex metadata"))}`),r.digest("hex")}function ct(e){return{file:Bn(e),size:_(e).size,sha256:Ae(e)}}function Eo(e,t){if(t.file!==Bn(e)||_(e).size!==t.size)throw new Error(`verified SQLite generation artifact changed before publication: ${e}`);return t}function Ae(e){let t=pt("sha256"),n=ao(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Go(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{io(n)}return t.digest("hex")}function Go(e,t){let n=0;for(;n<t.length;){let r=so(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function dt(e,t){return me(e,t,{mode:292})}function Yn(e,t,n){let r=f(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&y(r)&&_(r).size===t.size&&Ae(r)===t.sha256}function Po(e,t,n){return!t||!n?t===n:Yn(e,t,n)}function To(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=f(e,t.file);return y(r)&&L(I(r,"stored reindex metadata"))===L(I(n,"candidate reindex metadata"))}function Do(e,t){for(let n of["-wal","-shm","-journal"])J(`${t}${n}`,{force:!0});ft(e,t)}function Ao(e){let t=new co(e,{fileMustExist:!0});try{if(t.pragma("wal_checkpoint(TRUNCATE)").some(i=>i.busy!==0))throw new Error(`SQLite publication has an active writer or reader: ${e}`);let r=t.pragma("quick_check");if(r.length!==1||r[0]?.quick_check!=="ok")throw new Error(`SQLite publication rejected an invalid database: ${e}`)}finally{t.close()}}function ft(e,t){J(`${t}.tmp-replace`,{force:!0}),lt(e,`${t}.tmp-replace`),lt(`${t}.tmp-replace`,t)}function ko(e,t,n,r,i){return{version:F,currentGeneration:e,artifactSet:"immutable-v1",stableMirrors:gt(t,n),...r?.previousGeneration?{previousGeneration:r.previousGeneration}:{},...r?.publication?{publication:r.publication}:{},publishedAt:r?.publishedAt??i().toISOString()}}function Lo(e,t){return t?.artifactSet==="immutable-v1"&&!!V(e,t.currentGeneration)}function Co(e,t){return e?t?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}function Oo(e,t){return!(t.stableMirrors&&(t.stableMirrors.databaseFileIdentity!==N(e)||t.stableMirrors.indexFileIdentity!==void 0&&t.stableMirrors.indexFileIdentity!==N(f(T(e),"index.scip"))))}import{createHash as tr,randomUUID as $o}from"crypto";import{existsSync as O,lstatSync as bt,mkdirSync as Q,mkdtempSync as nr,readdirSync as rr,realpathSync as ir,renameSync as $,rmSync as C,statSync as Me}from"fs";import{dirname as It,join as l,resolve as q}from"path";import{setTimeout as Bo}from"timers/promises";import{pathToFileURL as Xn}from"url";import Wo from"better-sqlite3";import{lstatSync as Mo,readdirSync as Fo}from"fs";import{join as jo,relative as No,resolve as ht,sep as _o}from"path";var le=1,St="language-indexes",Jn=["index.db","index.scip","meta.json"],Qn=[St,re,ae];function Le(e){let t=[];for(let n of Jn)qo(e,n),t.push(n);for(let n of Qn)Kn(e,n,t);return{version:le,files:t.sort()}}function Ce(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!Jn.includes(e)&&!Qn.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function D(e,t){let n=Ce(t),r=ht(e),i=ht(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${_o}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Kn(e,t,n){let r=jo(e,t),i;try{i=Fo(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?Kn(e,a,n):o.isFile()&&n.push(Ce(a))}}function qo(e,t){let n=D(e,t),r;try{r=Mo(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(No(ht(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var wt=1,Zn="SCIP_QUERY_SHARED_CACHE",zo=2,Oe=JSON.stringify({cliVersion:Mt,typescriptSymbolIdentityVersion:6,artifactCatalogVersion:le,postIndexAugmentationSchemaVersion:zo,sqliteGenerationStoreVersion:F,typescriptFragmentStoreVersion:Ye,typescriptOverlayStoreVersion:Ge}),vt="manifest.json",or="shared-cache.json";var xt=[St,re,ae];function Uo(e,t){if(!e.clean||!e.treeOid)return;let n=pr(JSON.stringify({version:wt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:pe(t),producerIdentity:Oe}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Oe,generationId:n,repositoryCacheDir:_e(e.repositoryId)}}function kc(e,t,n){if(!ga(n))return!1;let r=Uo(e,n);if(!r)return!1;try{let i=la(t);if(!i||i.repositoryId!==e.repositoryId||i.worktreeId!==e.worktreeId)return!1;let o=JSON.parse(x(l(r.repositoryCacheDir,"worktrees",`${i.worktreeId}.json`),{inputKind:"worktree cache lease",maxBytes:w}));return Ho(o,i,e,t,r)?B(r,!1)!==null:!1}catch{return!1}}function Ho(e,t,n,r,i){return!(e.version!==1||e.repositoryId!==t.repositoryId||e.worktreeId!==t.worktreeId||q(e.projectRoot)!==q(n.projectRoot)||e.treeOid!==n.treeOid||q(e.localCacheDir)!==q(r)||e.ownershipChecksum!==Rt(e)||e.baseGenerationId!==i.generationId||e.activeGenerationId!==i.generationId)}function Lc(e,t,n){if(process.env[Zn]==="0")return`${Zn}=0`;if(!qe(n))return"explicit cache or database override";if($e(It(t))!==$e(Nt(e))||t!==l(It(t),"index.db"))return"index database is outside the managed worktree cache"}function Cc(e,t,n){if(!qe(t))return;let r=n??kt(e);return r?l(_e(r.repositoryId),"evidence.db"):void 0}function B(e,t=!0){let n=Et(e),r;try{r=sr(x(l(n,vt),{inputKind:"shared-generation manifest",maxBytes:w}))}catch{return null}if(!ma(r,e)||!ca(n))return null;if(!t)return r;try{for(let i of r.artifacts){let o=D(n,i.path),a=Me(o);if(!a.isFile()||a.size!==i.size||z(o,{inputKind:"shared-generation artifact",maxBytes:h})!==i.sha256)return null}}catch{return null}return r}function Oc(e,t,n,r){if(!e.treeOid)return null;let i=Be(t,n),o=l(jt(),"repositories",e.repositoryId),a;try{let d=bt(o);if(!d.isDirectory()||d.isSymbolicLink())return null;a=ir(o)}catch{return null}let s=l(a,"generations"),c=[];try{Vo(s,e,i,c)}catch{return null}c.sort((d,u)=>{let p=d.treeOid===e.treeOid?0:1,g=u.treeOid===e.treeOid?0:1;if(p!==g)return p-g;if(r){let W=er(d.fingerprint,r)-er(u.fingerprint,r);if(W!==0)return W}return Date.parse(u.createdAt)-Date.parse(d.createdAt)||d.generationId.localeCompare(u.generationId)});for(let d of c){let u={repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:d.treeOid,fingerprint:d.fingerprint,producerIdentity:d.producerIdentity,generationId:d.generationId,repositoryCacheDir:a},p=B(u);if(p)return{snapshot:u,manifest:p}}return null}function Vo(e,t,n,r){for(let i of rr(e)){if(!/^[a-f0-9]{64}$/.test(i))continue;let o=l(e,i),a;try{a=bt(o)}catch{continue}if(!(!a.isDirectory()||a.isSymbolicLink()))try{let s=sr(x(l(o,vt),{inputKind:"shared-generation baseline manifest",maxBytes:w}));Yo(s,i,t,n)&&r.push(s)}catch{continue}}}function Yo(e,t,n,r){return e.generationId===t&&e.repositoryId===n.repositoryId&&e.producerIdentity===Oe&&da(e.fingerprint,r)}function Mc(e){let t=M(l(e.snapshot.repositoryCacheDir,"locks",`${e.snapshot.generationId}.publish.lock`));if(!t)throw new Error(`shared generation publication is already in progress for ${e.snapshot.generationId}`);try{return Jo(e)}finally{t.release()}}function Jo(e){let t=B(e.snapshot);if(t)return ar(e.snapshot,t);if(!fr(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=cr(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=Le(e.sourceCacheDir),i=l(e.snapshot.repositoryCacheDir,"generations"),o=[ge(i)],a=nr(l(i,`.tmp-${process.pid}-`));try{let s=Xo(e,r.files,a,o),c=Ko(e,a,n),d={version:wt,artifactCatalogVersion:le,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:c,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:s.sort((K,W)=>K.path.localeCompare(W.path))},u=G(l(a,vt),d,{spacing:2,trailingNewline:!0});u.directorySync!=="not-requested"&&o.push(u.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(k(a)),e.onPublicationStage?.("after-staging-directory-synced");let p=Qo(e.snapshot,a);if(p)return p;e.onPublicationStage?.("after-generation-renamed"),o.push(k(i)),e.onPublicationStage?.("after-generations-directory-synced");let g=X(...o);return{kind:"published",manifest:d,achievedDurability:g==="synced"?"directory-durable":"file-flushed",directorySync:g}}finally{C(a,{recursive:!0,force:!0})}}function Qo(e,t){let n=Et(e);try{if(O(n)&&!B(e)){let r=`${n}.corrupt-${process.pid}-${Date.now()}`;$(n,r),C(r,{recursive:!0,force:!0})}$(t,n)}catch(r){let i=B(e);if(i)return ar(e,i);throw r}}function Ko(e,t,n){let r=oe(v(l(t,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:h}));if(!r)throw new Error("shared SCIP generation has no project root metadata");let i=Gt(e.sourceProjectRoot);if(r!==i)throw new Error("shared SCIP generation root does not match its source worktree");if(cr(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");return r}function Xo(e,t,n,r){let i=[];for(let o of t){let a=D(e.sourceCacheDir,o),s=D(n,o);r.push(fe(a,s,292)),e.onPublicationStage?.("after-artifact-flushed",o);let c=Me(s).size;i.push({path:o,size:c,sha256:z(s,{inputKind:"staged shared-generation artifact",maxBytes:h})})}return i}function ar(e,t){let n=k(l(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:n==="synced"?"directory-durable":"file-flushed",directorySync:n}}function Fc(e){let t=Et(e.snapshot);Q(e.targetCacheDir,{recursive:!0});let n=M(l(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:e.lockWaitMs??3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{if(r=nr(l(e.targetCacheDir,".shared-hydrate-")),ya(e.manifest,e.snapshot),ea(e.manifest,t,r),ta(e,r),!fr(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=ua(e.targetCacheDir,r),o=!0,fa(r,e.targetCacheDir,i),Wn({tempOutputScip:l(r,"index.scip"),tempOutputDb:l(r,"index.db"),tempMetaPath:l(r,"meta.json"),outputScip:l(e.targetCacheDir,"index.scip"),outputDb:l(e.targetCacheDir,"index.db"),metaPath:l(e.targetCacheDir,"meta.json"),now:e.now}),Zo(e.targetCacheDir),e.persistLease!==!1&&na(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&pa(e.targetCacheDir,i),a}finally{r&&C(r,{recursive:!0,force:!0}),n.release()}}function Zo(e){let t=ke(l(e,"index.db"),l(e,"meta.json"));if(t.state==="invalid"||t.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${t.reason}`)}function ea(e,t,n){for(let r of e.artifacts){let i=D(t,r.path),o=D(n,r.path);if(fe(i,o),Me(o).size!==r.size||z(o,{inputKind:"hydrated shared-generation artifact",maxBytes:h})!==r.sha256)throw new Error(`shared artifact is corrupt: ${r.path}`)}}function ta(e,t){let n=Gt(e.targetProjectRoot);if(n!==e.manifest.scipProjectRoot)for(let r of e.manifest.artifacts)r.path.endsWith(".scip")&&_n(D(t,r.path),e.manifest.scipProjectRoot,n)}async function jc(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??$t,o=i()+n,a=l(e.repositoryCacheDir,"locks"),s=l(a,`${e.generationId}.lock`);for(;i()<=o;){if(B(e))return{kind:"generation-ready"};let c=Wt(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:Bt});if(c.kind==="acquired")return{kind:"owner",release:()=>c.lock.release()};let d=o-i();if(d<=0)break;await Bo(Math.min(r,d))}return B(e)?{kind:"generation-ready"}:{kind:"timeout"}}function na(e,t,n,r=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:n,lastSeenAt:(r??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:Rt(i)};return lr(e.repositoryCacheDir,o,!0),o}function Nc(e,t,n=void 0){let r={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,lastAction:"overlay",lastReason:`private cache forked from shared baseline ${e.generationId}`,lastSeenAt:(n??(()=>new Date))().toISOString()},i={...r,ownershipChecksum:Rt(r)};return lr(e.repositoryCacheDir,i,!0),i}function Rt(e){return pr(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:q(e.projectRoot),localCacheDir:q(e.localCacheDir)}))}function sr(e){let t=JSON.parse(e);if(!ra(t)||!ia(t))throw new Error("invalid shared generation manifest");if(!oa(t))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(aa(r),Ce(r.path),n.has(r.path))throw new Error(`duplicate shared generation artifact: ${r.path}`);n.add(r.path)}for(let r of["index.db","index.scip","meta.json"])if(!n.has(r))throw new Error(`shared generation is missing ${r}`);return t}function ra(e){return e.version===wt&&e.artifactCatalogVersion===le&&typeof e.generationId=="string"&&/^[a-f0-9]{64}$/.test(e.generationId)&&typeof e.repositoryId=="string"&&/^[a-f0-9]{24}$/.test(e.repositoryId)}function ia(e){return typeof e.treeOid=="string"&&e.treeOid!==""&&typeof e.producerIdentity=="string"&&e.producerIdentity===Oe&&typeof e.sourceProjectRoot=="string"&&typeof e.scipProjectRoot=="string"}function oa(e){return typeof e.createdAt=="string"&&Number.isFinite(Date.parse(e.createdAt))&&!!e.fingerprint&&Array.isArray(e.artifacts)}function aa(e){if(!e||typeof e.path!="string"||typeof e.size!="number"||e.size<0||typeof e.sha256!="string"||!/^[a-f0-9]{64}$/.test(e.sha256))throw new Error("invalid shared generation artifact")}function fe(e,t,n=384){return me(e,t,{mode:n})}function sa(e,t,n){Q(e,{recursive:!0}),G(l(e,or),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function cr(e){try{let t=Le(e),n=tr("sha256");for(let r of t.files){let i=D(e,r),o=Me(i).size;n.update(r).update("\0").update(String(o)).update("\0"),Tt(i,{inputKind:"source-generation artifact",maxBytes:h},a=>n.update(a)),n.update("\0")}return n.digest("hex")}catch{return null}}function dr(e){try{let t=he(x(l(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:w}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function ca(e){return dr(e)?.scipCompanion!=="deferred"}function da(e,t){if(e.typescriptSymbolIdentityVersion!==t.typescriptSymbolIdentityVersion)return!1;let n=Be(e.languages,e);return JSON.stringify(n)===JSON.stringify(t)}function er(e,t){let n=new Map(e.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),r=new Map(t.files.map(o=>[o.path,`${o.size}\0${o.hash}`])),i=0;for(let[o,a]of n)r.get(o)!==a&&(i+=1);for(let o of r.keys())n.has(o)||(i+=1);return i}function Et(e){return l(e.repositoryCacheDir,"generations",e.generationId)}function la(e){let t=JSON.parse(x(l(e,or),{inputKind:"worktree cache pointer",maxBytes:w}));return t.version!==1||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.worktreeId!="string"||!/^[a-f0-9]{24}$/.test(t.worktreeId)?null:{version:t.version,repositoryId:t.repositoryId,worktreeId:t.worktreeId}}function lr(e,t,n){let r=zt(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId??t.baseGenerationId;if(!o||!O(l(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=l(e,"worktrees");Q(i,{recursive:!0}),G(l(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),sa(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function ua(e,t){let n=l(t,".rollback"),r=new Map,i=new Map;Q(n,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=l(e,s),d=O(c);r.set(s,d),d&&fe(c,l(n,"stable",s))}for(let s of xt){let c=l(e,s),d=O(c);if(d){let u=bt(c);if(!u.isDirectory()||u.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,d)}let o=l(e,te),a=O(o);return a&&ur(o,l(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:a}}function fa(e,t,n){for(let r of xt){let i=l(t,r);if(n.managedDirectories.get(r)){let a=l(n.root,"managed",r);Q(It(a),{recursive:!0}),$(i,a)}let o=l(e,r);O(o)&&$(o,i)}}function pa(e,t){for(let i of xt){let o=l(e,i),a=l(t.root,"managed",i);t.managedDirectories.get(i)?O(a)&&(C(o,{recursive:!0,force:!0}),$(a,o)):C(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=l(e,i);if(!o){C(a,{force:!0});continue}let s=`${a}.shared-restore-${$o()}`;fe(l(t.root,"stable",i),s),C(a,{force:!0}),$(s,a)}let n=l(e,te);C(n,{recursive:!0,force:!0});let r=l(t.root,"sqlite-generations");t.generationStoreExisted&&O(r)&&$(r,n)}function ur(e,t){Q(t,{recursive:!0});for(let n of rr(e,{withFileTypes:!0})){let r=l(e,n.name),i=l(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?ur(r,i):n.isFile()&&fe(r,i)}}function ya(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!ye(e.fingerprint,t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function fr(e,t,n,r=!0,i=!0){try{let o=dr(e);if(Sa(o,n))return ue("source validation rejected metadata"),!1;let a=Le(e),s=ke(l(e,"index.db"),l(e,"meta.json"));if(r?s.state!=="current":s.state==="invalid"||s.state==="drifted")return ue(`source validation rejected SQLite generation state ${s.state}`),!1;if(!ha(e,i))return!1;let c=Gt(t),u=(i?a.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let g=oe(v(D(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:h}));return g!==c&&ue(`source validation rejected SCIP root for ${p}: ${String(g)}`),g===c});return u||ue("source validation rejected SCIP project roots"),u}catch(o){return ue(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function ue(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function Gt(e){try{return Xn(ir(e)).href}catch{return Xn(q(e)).href}}function ga(e){if(!e||typeof e!="object")return!1;let t=e;return t.version===3&&Array.isArray(t.languages)&&typeof t.pnpmWorkspaces=="boolean"&&(t.typescriptProjectMode==="single"||t.typescriptProjectMode==="workspace")&&Array.isArray(t.typescriptProjects)&&Array.isArray(t.files)&&t.files.every(n=>n!==null&&typeof n=="object"&&typeof n.path=="string"&&typeof n.size=="number"&&typeof n.hash=="string"&&(n.semanticHash===void 0||typeof n.semanticHash=="string"))}function pr(e){return tr("sha256").update(e).digest("hex")}function ma(e,t){return!(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||!ye(e.fingerprint,t.fingerprint))}function ha(e,t){let n=new Wo(l(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(t){if(n.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else n.pragma("schema_version",{simple:!0})}finally{n.close()}return!0}function Sa(e,t){return!e||e.scipCompanion==="deferred"||!ye(Pt(e.fingerprint),t)||JSON.stringify([...e.indexedLanguages??[]].sort())!==JSON.stringify([...t.languages].sort())}export{Ba as a,Wa as b,za as c,Ua as d,Da as e,j as f,Er as g,Aa as h,N as i,S as j,ie as k,xe as l,Zr as m,is as n,os as o,gn as p,as as q,mn as r,fs as s,xs as t,Cs as u,Os as v,Ms as w,Wn as x,uo as y,Ks as z,ke as A,Uo as B,kc as C,Lc as D,Cc as E,B as F,Oc as G,Mc as H,Fc as I,jc as J,na as K,Nc as L,Rt as M};
|
|
2
|
+
//# sourceMappingURL=chunk-BIQEF5NE.js.map
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as v}from"./chunk-B3PYOSCX.js";import{a as I,b as k,c as R}from"./chunk-QZ7KQZRN.js";import{a as w,b as y}from"./chunk-2HLAFUCY.js";import{i as g}from"./chunk-62BDNPMI.js";import{randomUUID as A}from"crypto";import{closeSync as x,fsyncSync as N,linkSync as _,mkdirSync as C,openSync as T,statSync as M,unlinkSync as q,writeSync as z}from"fs";import{dirname as P}from"path";var F="scip-query-process-lock",m=1,a=Object.freeze({wallNow:()=>Date.now(),isProcessAlive:v,readProcessIdentity:R,randomToken:()=>A(),makeDirectory:e=>C(e,{recursive:!0}),openFile:(e,r,t)=>T(e,r,t),writeFile:(e,r,t,o)=>z(e,r,t,o),syncFile:e=>N(e),closeFile:e=>x(e),linkFile:(e,r)=>_(e,r),readFile:e=>g(e,"process lock record"),statFile:e=>{let r=M(e);return{dev:r.dev,ino:r.ino,size:r.size,mtimeMs:r.mtimeMs}},removeFile:e=>q(e)}),te=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e.pid;return typeof r=="number"&&Number.isSafeInteger(r)&&r>0?{pid:r}:null};function oe(e,r){let t=r.runtime??a;t.makeDirectory(P(e));let o;for(let i=0;i<2;i+=1)try{return{kind:"acquired",lock:O(e,r,t),...o?{reclaimed:o}:{}}}catch(n){if(n.code!=="EEXIST")throw n;let c=d(e,{parseLegacy:r.parseLegacy,runtime:t});if(i===0&&j(e,c,{creationGraceMs:r.creationGraceMs,parseLegacy:r.parseLegacy,runtime:t})){o=c;continue}return{kind:"contended",observation:c}}return{kind:"contended",observation:d(e,{parseLegacy:r.parseLegacy,runtime:t})}}function d(e,r={}){let t=r.runtime??a,o,i;try{o=t.statFile(e),i=t.readFile(e)}catch(l){return l.code==="ENOENT"?{state:"missing"}:{state:"malformed"}}let n;try{n=JSON.parse(i)}catch{return{state:"malformed",raw:i,identity:o}}let c=G(n);if(c)return{state:"valid",raw:i,identity:o,record:c,owner:B(c),parsed:n};let s=r.parseLegacy?.(n)??null;return s?{state:"legacy",raw:i,identity:o,owner:s,parsed:n}:{state:"malformed",raw:i,identity:o,parsed:n}}function G(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let r=e;if(!J(r)||!K(r))return null;let t=h(r);if(!t)return null;let{processIdentity:o}=t;return{protocol:F,version:m,kind:r.kind,pid:r.pid,token:r.token,...o?{processIdentity:o}:{},startedAt:r.startedAt,...r.detail?{detail:r.detail}:{}}}function h(e){let r=e.processIdentity===void 0?null:I(e.processIdentity);return e.processIdentity!==void 0&&(!r||r.pid!==e.pid)?null:{processIdentity:r}}function J(e){return e.protocol===F&&e.version===m&&typeof e.kind=="string"&&e.kind.trim()!==""&&typeof e.pid=="number"&&Number.isSafeInteger(e.pid)&&e.pid>0&&typeof e.token=="string"&&e.token.trim()!==""}function K(e){return typeof e.startedAt=="string"&&Number.isFinite(Date.parse(e.startedAt))&&(e.detail===void 0||typeof e.detail=="object"&&e.detail!==null&&!Array.isArray(e.detail))}function j(e,r,t={}){let o=t.runtime??a;if(!f(r,o))return!1;let i=$(`${e}.reclaim`,o);if(!i)return!1;try{let n=d(e,{parseLegacy:t.parseLegacy,runtime:o});return!D(r,n)||!f(n,o)?!1:p(e,o)}finally{i.release()}}function O(e,r,t){let o=r.directoryDurability??"durable",i=r.pid??process.pid,n=t.randomToken(),c=r.processIdentity===void 0?t.readProcessIdentity(i):r.processIdentity,s={protocol:F,version:m,kind:r.kind,pid:i,token:n,...c?{processIdentity:c}:{},startedAt:new Date(t.wallNow()).toISOString(),...r.detail?{detail:r.detail}:{}},l=`${e}.${n}.candidate`;V(l,s,t);try{t.linkFile(l,e)}catch(u){throw L(l,t),u}if(L(l,t),o==="durable")try{E(P(e),t)}catch(u){throw U(e,s,t),u}let b=!1;return{path:e,record:s,release:()=>b?!1:(b=!0,S(e,s,t,o))}}function U(e,r,t=a){return S(e,r,t,"durable")}function S(e,r,t,o){let i=d(e,{runtime:t});return i.state!=="valid"||!i.record||i.record.pid!==r.pid||i.record.token!==r.token||r.processIdentity&&(!i.record.processIdentity||!k(r.processIdentity,i.record.processIdentity))?!1:p(e,t,o)}function $(e,r){for(let t=0;t<2;t+=1)try{return O(e,{kind:"reclaim-guard",runtime:r},r)}catch(o){if(o.code!=="EEXIST"||!X(e,r,t))return null}return null}function f(e,r){if(e.state==="missing")return!1;if(e.owner){if(!r.isProcessAlive(e.owner.pid))return!0;if(!e.owner.processIdentity)return!1;let t=r.readProcessIdentity(e.owner.pid);return t!==null&&!k(e.owner.processIdentity,t)}return!1}function D(e,r){return e.state===r.state&&e.raw===r.raw&&e.identity!==void 0&&r.identity!==void 0&&e.identity.dev===r.identity.dev&&e.identity.ino===r.identity.ino&&e.identity.size===r.identity.size&&e.identity.mtimeMs===r.identity.mtimeMs}function B(e){return{pid:e.pid,...e.processIdentity?{processIdentity:e.processIdentity}:{}}}function E(e,r){let t;try{t=r.openFile(e,"r")}catch(o){if(y(o,process.platform))return;throw o}try{r.syncFile(t)}catch(o){if(!y(o,process.platform))throw o}finally{r.closeFile(t)}}function p(e,r,t="durable"){try{return r.removeFile(e),t==="durable"&&E(P(e),r),!0}catch{return!1}}function L(e,r){try{r.removeFile(e)}catch{}}function V(e,r,t){let o=t.openFile(e,"wx",384),i;try{w(o,Buffer.from(`${JSON.stringify(r)}
|
|
2
|
+
`),t,"process lock"),t.syncFile(o)}catch(n){i=n}try{t.closeFile(o)}catch(n){i??=n}if(i!==void 0)throw L(e,t),i}function X(e,r,t){let o=d(e,{runtime:r});if(t>0||!f(o,r))return!1;let i=d(e,{runtime:r});return D(o,i)?p(e,r):!1}export{a,te as b,oe as c,d,j as e};
|
|
3
|
+
//# sourceMappingURL=chunk-BL6XJKTA.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as m,b as g}from"./chunk-5PLMJC7Q.js";import{c as u}from"./chunk-NOLZOVCU.js";import{b as d}from"./chunk-GCKCF5FL.js";function b(n,e={}){let{minSimilarity:s=.5,limit:t=20,scope:o,filePattern:l}=e,r=e.minDeps??(l?1:4),{profiles:i,distinctiveDeps:a}=D(n,{scope:o,minDeps:r}),p=m(i,f=>f.deps);return g({profiles:i,limit:t,filePattern:l,overrunFactor:5,candidateIndex:p,profile:{name:"similar-files"},compare:(f,c)=>v(f,c,s,a,r)})}function D(n,e){let{scope:s,minDeps:t}=e,o=d(n),{universalDeps:l,distinctiveDeps:r}=P(o),i=[];for(let[a,p]of o){if(s&&!a.includes(s))continue;let f=new Set([...p].filter(c=>!l.has(c)));f.size>=t&&i.push({file:a,deps:f})}return{profiles:i,distinctiveDeps:r}}function P(n){let e=new Set,s=new Set,t=n.size;if(t===0)return{universalDeps:e,distinctiveDeps:s};let o=new Map;for(let r of n.values())for(let i of r)o.set(i,(o.get(i)??0)+1);let l=Math.max(3,Math.ceil(t*.03));for(let[r,i]of o)i>=5&&i/t>.3?e.add(r):i<=l&&s.add(r);return{universalDeps:e,distinctiveDeps:s}}function v(n,e,s,t,o){let l=new Set;for(let f of n.deps)e.deps.has(f)&&l.add(f);if(l.size<Math.min(3,o))return null;let r=0;for(let f of l)t.has(f)&&r++;if(r<Math.min(2,o))return null;let i=u(n.deps,e.deps);if(i<s)return null;let a=S(n.deps,e.deps),p=S(e.deps,n.deps);return{fileA:n.file,fileB:e.file,similarity:i,evidenceBasis:"filtered-dependency-overlap",sharedDeps:[...l],uniqueToA:a,uniqueToB:p}}function S(n,e){let s=[];for(let t of n)e.has(t)||s.push(t);return s}export{b as a};
|
|
2
|
+
//# sourceMappingURL=chunk-BMKOQJRI.js.map
|