scip-query 0.19.8 → 0.20.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 +97 -0
- package/README.md +158 -48
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-26QA6FAI.js +8 -0
- package/dist/{chunk-KJ2IIBZN.js → chunk-2HPVVXM5.js} +2 -2
- package/dist/chunk-2KAZEZ6M.js +2 -0
- package/dist/chunk-32LVLCLN.js +40 -0
- package/dist/{chunk-24GTWJ3N.js → chunk-3CLX5EOX.js} +2 -2
- package/dist/{chunk-QGGLL3UH.js → chunk-3G66UZBH.js} +2 -2
- package/dist/{chunk-AA4UWRNL.js → chunk-3ORVDL3H.js} +2 -2
- package/dist/chunk-4MAK2HOY.js +6 -0
- package/dist/{chunk-QIQ63BHW.js → chunk-4TURLRL5.js} +2 -2
- package/dist/chunk-4UQVNCQE.js +2 -0
- package/dist/chunk-55Q3WLZX.js +2 -0
- package/dist/{chunk-CTF2GDEX.js → chunk-5E4WNAVD.js} +2 -2
- package/dist/{chunk-ZCEJ63SP.js → chunk-5I5G2QOX.js} +2 -2
- package/dist/chunk-6LDJQXAH.js +2 -0
- package/dist/{chunk-3EDFLQ6A.js → chunk-6O5TICIZ.js} +2 -2
- package/dist/{chunk-ACAM6O5R.js → chunk-6SHPK5ZE.js} +2 -2
- package/dist/chunk-7BAVHKMJ.js +49 -0
- package/dist/chunk-7O5IKBTZ.js +16 -0
- package/dist/{chunk-WJL2L6MV.js → chunk-7PIO7NKH.js} +2 -2
- package/dist/chunk-7S5E7KWT.js +2 -0
- package/dist/{chunk-YLFORA5G.js → chunk-7SQQWSY3.js} +2 -2
- package/dist/chunk-7WPLAODU.js +5 -0
- package/dist/chunk-A73XVBCR.js +20 -0
- package/dist/chunk-AFHORGLH.js +42 -0
- package/dist/chunk-AIE7TFJW.js +9 -0
- package/dist/{chunk-TWMJ3Y3G.js → chunk-AZJQQKDD.js} +2 -2
- package/dist/{chunk-BDOIKGDI.js → chunk-B2PX5I6M.js} +2 -2
- package/dist/{chunk-DQBCO2UY.js → chunk-B7PBSLZN.js} +2 -2
- package/dist/chunk-BBW6JFHN.js +2 -0
- package/dist/{chunk-YTVWB7YJ.js → chunk-BDCC2NPY.js} +2 -2
- package/dist/{chunk-O23I56NA.js → chunk-BNXCIFVY.js} +2 -2
- package/dist/{chunk-MLFZP76A.js → chunk-BPAPWKP6.js} +2 -2
- package/dist/chunk-BS2NMXQZ.js +4 -0
- package/dist/chunk-C3KV2II6.js +2 -0
- package/dist/chunk-C43RDDP4.js +20 -0
- package/dist/{chunk-K2WO7XY7.js → chunk-CJST5ETY.js} +2 -2
- package/dist/chunk-DAFAHMNB.js +42 -0
- package/dist/{chunk-KKME5ZAI.js → chunk-DQGFVPUV.js} +2 -2
- package/dist/chunk-DQLPXMH6.js +8 -0
- package/dist/chunk-EKZTZXHZ.js +117 -0
- package/dist/{chunk-FJ5UDTQF.js → chunk-EN3O7VJA.js} +2 -2
- package/dist/{chunk-HZYDQPNY.js → chunk-EW2NTSFA.js} +2 -2
- package/dist/chunk-F3Z4OUDS.js +8 -0
- package/dist/chunk-FJH2NW7J.js +66 -0
- package/dist/{chunk-MSBDMFER.js → chunk-FKSELJQF.js} +2 -2
- package/dist/chunk-FTFP6O3L.js +11 -0
- package/dist/chunk-FYLK2DEJ.js +2 -0
- package/dist/{chunk-WUW7YUAH.js → chunk-GH74ASD6.js} +2 -2
- package/dist/{chunk-464PLI5O.js → chunk-GMXWZP2B.js} +2 -2
- package/dist/chunk-GOUBFH5O.js +3 -0
- package/dist/{chunk-FIJCV235.js → chunk-HLF2TX6R.js} +2 -2
- package/dist/{chunk-WWKWUPSU.js → chunk-HX4GQPZP.js} +2 -2
- package/dist/chunk-HX7M4BDI.js +30 -0
- package/dist/chunk-HZ72SESS.js +128 -0
- package/dist/{chunk-SERUIGV5.js → chunk-IB2N4FIY.js} +2 -2
- package/dist/chunk-ILMHV3KM.js +2 -0
- package/dist/chunk-IZYYAFN5.js +2 -0
- package/dist/{chunk-GNC4JVAN.js → chunk-JAYYFEQY.js} +2 -2
- package/dist/{chunk-QJIVBYEK.js → chunk-JDOEX4E6.js} +2 -2
- package/dist/chunk-JFGGXWQF.js +947 -0
- package/dist/chunk-JN4NMBEX.js +8 -0
- package/dist/{chunk-6M7RONVB.js → chunk-JVYA47YU.js} +2 -2
- package/dist/{chunk-7KYNAMMH.js → chunk-JW56N3KI.js} +2 -2
- package/dist/{chunk-OUBAF226.js → chunk-JZ2OXNWB.js} +2 -2
- package/dist/chunk-KMKTIO2G.js +8 -0
- package/dist/chunk-L5GJNV2T.js +8 -0
- package/dist/{chunk-MNSTUIDD.js → chunk-L7AW2QB5.js} +2 -2
- package/dist/chunk-L7JDSCDF.js +4 -0
- package/dist/chunk-LU47HG23.js +14 -0
- package/dist/chunk-LVY7NPF7.js +2 -0
- package/dist/chunk-LY4WC4AD.js +74 -0
- package/dist/{chunk-7FT5Y65S.js → chunk-MKCDWWGV.js} +2 -2
- package/dist/chunk-MNE7YG56.js +2 -0
- package/dist/{chunk-7QHY3H7P.js → chunk-MRXBEXSY.js} +2 -2
- package/dist/chunk-MV7OWDUX.js +2 -0
- package/dist/{chunk-ZJ5CBXK3.js → chunk-N5W4YZMK.js} +2 -2
- package/dist/chunk-NGEXCJJW.js +11 -0
- package/dist/{chunk-7SWJEWJF.js → chunk-NIW6JDC5.js} +2 -2
- package/dist/{chunk-O3O4XXO6.js → chunk-O64IZ6UX.js} +2 -2
- package/dist/{chunk-3ZSJ3PWF.js → chunk-PBUQFCNB.js} +2 -2
- package/dist/{chunk-7RAG65VK.js → chunk-POAVPHH7.js} +2 -2
- package/dist/{chunk-A3QXWFBK.js → chunk-PQCI4SQX.js} +2 -2
- package/dist/{chunk-4BV4QAZJ.js → chunk-PXY7F6Y4.js} +2 -2
- package/dist/chunk-RDO52JGY.js +2 -0
- package/dist/chunk-RJT3TUUZ.js +2 -0
- package/dist/{chunk-S4S2WOIX.js → chunk-RUJURYSV.js} +2 -2
- package/dist/{chunk-JAY7YWS3.js → chunk-RVLDN63O.js} +2 -2
- package/dist/chunk-RXOXSKY3.js +2 -0
- package/dist/chunk-S7OYBOCK.js +2 -0
- package/dist/chunk-SMNXQT5Z.js +3 -0
- package/dist/{chunk-NE3TZUCI.js → chunk-SRAFT254.js} +2 -2
- package/dist/{chunk-ELLMY7XJ.js → chunk-SXP2MBJH.js} +2 -2
- package/dist/chunk-T7YQSHPQ.js +3 -0
- package/dist/{chunk-WY45BHKQ.js → chunk-TFRAYKN6.js} +2 -2
- package/dist/{chunk-2SNGN6U4.js → chunk-UJCOIXDY.js} +2 -2
- package/dist/{chunk-MZZBAITE.js → chunk-UJPRPGCO.js} +2 -2
- package/dist/chunk-W4ETQAXM.js +2 -0
- package/dist/chunk-WCCFZ7V7.js +113 -0
- package/dist/chunk-WUPW3UN3.js +3 -0
- package/dist/{chunk-7LSVMFX7.js → chunk-WXZLAAWK.js} +2 -2
- package/dist/{chunk-5ML2BNRH.js → chunk-X54AGLVX.js} +2 -2
- package/dist/chunk-XKWKXZKW.js +20 -0
- package/dist/{chunk-5YLUDDAF.js → chunk-XSRF6Q77.js} +2 -2
- package/dist/chunk-Y2MVPNKY.js +5 -0
- package/dist/{chunk-JHF3E4YM.js → chunk-YKUU5AIC.js} +2 -2
- package/dist/{chunk-E3HYEQO7.js → chunk-YLCJLTPL.js} +2 -2
- package/dist/{chunk-7VCOXZH3.js → chunk-YTQVETEO.js} +2 -2
- package/dist/chunk-Z4N3MZYA.js +38 -0
- package/dist/chunk-ZHXX42OH.js +18 -0
- package/dist/chunk-ZJOOT3BG.js +2 -0
- package/dist/{chunk-P3UO3EH3.js → chunk-ZK26BAQL.js} +2 -2
- package/dist/{chunk-33KUO7CG.js → chunk-ZTETIQ35.js} +2 -2
- package/dist/cli.js +3 -8
- package/dist/command-descriptors-DSS46KXI.js +642 -0
- package/dist/{config-types-B6MEoRNy.d.ts → config-types-jVM3D7MA.d.ts} +68 -2
- package/dist/{db-DYLKr9Wn.d.ts → db-B5PM5yNk.d.ts} +20 -2
- package/dist/{diff-gate-types-C9BoYwYD.d.ts → diff-gate-types-B0QYpDv1.d.ts} +2 -1
- package/dist/direct-navigation-6YHV6IB5.js +3 -0
- package/dist/{health-DgxIDXJC.d.ts → health-Do5TKSJI.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/postinstall.js +1 -1
- package/dist/queries/affected.d.ts +2 -2
- package/dist/queries/affected.js +1 -1
- package/dist/queries/architecture.d.ts +2 -2
- package/dist/queries/architecture.js +1 -1
- package/dist/queries/bottlenecks.d.ts +2 -2
- package/dist/queries/bottlenecks.js +1 -1
- package/dist/queries/by-kind.d.ts +2 -2
- package/dist/queries/by-kind.js +1 -1
- package/dist/queries/call-graph.d.ts +2 -2
- package/dist/queries/call-graph.js +1 -1
- package/dist/queries/change-surface.d.ts +22 -3
- package/dist/queries/change-surface.js +1 -1
- package/dist/queries/cleanup-plan.d.ts +2 -2
- package/dist/queries/cleanup-plan.js +1 -1
- package/dist/queries/co-change.d.ts +2 -2
- package/dist/queries/co-change.js +1 -1
- package/dist/queries/code.d.ts +2 -2
- package/dist/queries/code.js +1 -1
- package/dist/queries/complexity-hotspots.d.ts +3 -3
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +3 -3
- package/dist/queries/complexity.js +1 -1
- package/dist/queries/convergence.d.ts +2 -2
- package/dist/queries/convergence.js +1 -1
- package/dist/queries/coupling.d.ts +2 -2
- package/dist/queries/coupling.js +1 -1
- package/dist/queries/cycles.d.ts +2 -2
- package/dist/queries/cycles.js +1 -1
- package/dist/queries/dataflow.d.ts +2 -2
- package/dist/queries/dataflow.js +1 -1
- package/dist/queries/dead.d.ts +2 -2
- package/dist/queries/dead.js +1 -1
- package/dist/queries/decorative-checkers.d.ts +2 -2
- package/dist/queries/decorative-checkers.js +1 -1
- package/dist/queries/deep-chains.d.ts +2 -2
- package/dist/queries/deep-chains.js +1 -1
- package/dist/queries/deps.d.ts +2 -2
- package/dist/queries/deps.js +1 -1
- package/dist/queries/diff-gate.d.ts +40 -7
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +84 -6
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +3 -3
- package/dist/queries/doc-drift.js +1 -1
- package/dist/queries/drift.d.ts +2 -2
- package/dist/queries/drift.js +1 -1
- package/dist/queries/duplicate-bodies.d.ts +3 -3
- package/dist/queries/duplicate-bodies.js +1 -1
- package/dist/queries/extract-candidates.d.ts +2 -2
- package/dist/queries/extract-candidates.js +1 -1
- package/dist/queries/fan.d.ts +2 -2
- package/dist/queries/fan.js +1 -1
- package/dist/queries/files.d.ts +12 -3
- package/dist/queries/files.js +1 -1
- package/dist/queries/health.d.ts +3 -3
- package/dist/queries/health.js +1 -1
- package/dist/queries/hierarchy.d.ts +2 -2
- package/dist/queries/hierarchy.js +1 -1
- package/dist/queries/hotspots.d.ts +2 -2
- package/dist/queries/hotspots.js +1 -1
- package/dist/queries/imports.d.ts +2 -2
- package/dist/queries/imports.js +1 -1
- package/dist/queries/incomplete-migration.d.ts +8 -6
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +141 -10
- package/dist/queries/index.js +1 -1
- package/dist/queries/isolated.d.ts +2 -2
- package/dist/queries/isolated.js +1 -1
- package/dist/queries/locality-candidates.d.ts +2 -2
- package/dist/queries/locality-candidates.js +1 -1
- package/dist/queries/members.d.ts +2 -2
- package/dist/queries/members.js +1 -1
- package/dist/queries/methods.d.ts +34 -3
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +2 -2
- package/dist/queries/not-implemented.js +1 -1
- package/dist/queries/outline.d.ts +2 -2
- package/dist/queries/outline.js +1 -1
- package/dist/queries/passthrough-candidates.d.ts +3 -3
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +3 -3
- package/dist/queries/plan-context.js +1 -1
- package/dist/queries/react-component-duplicates.d.ts +2 -2
- package/dist/queries/react-component-duplicates.js +1 -1
- package/dist/queries/react-hook-candidates.d.ts +2 -2
- package/dist/queries/react-hook-candidates.js +1 -1
- package/dist/queries/react-large-component-pressure.d.ts +2 -2
- package/dist/queries/react-large-component-pressure.js +1 -1
- package/dist/queries/recent-duplicates.d.ts +2 -2
- package/dist/queries/recent-duplicates.js +1 -1
- package/dist/queries/redundant-reexports.d.ts +2 -2
- package/dist/queries/redundant-reexports.js +1 -1
- package/dist/queries/refs.d.ts +2 -2
- package/dist/queries/refs.js +1 -1
- package/dist/queries/self-audit.d.ts +2 -2
- package/dist/queries/self-audit.js +1 -1
- package/dist/queries/similar-chains.d.ts +2 -2
- package/dist/queries/similar-chains.js +1 -1
- package/dist/queries/similar-files.d.ts +2 -2
- package/dist/queries/similar-files.js +1 -1
- package/dist/queries/similar-signatures.d.ts +2 -2
- package/dist/queries/similar-signatures.js +1 -1
- package/dist/queries/similar.d.ts +2 -2
- package/dist/queries/similar.js +1 -1
- package/dist/queries/slice.d.ts +2 -2
- package/dist/queries/slice.js +1 -1
- package/dist/queries/stale-abstractions.d.ts +2 -2
- package/dist/queries/stale-abstractions.js +1 -1
- package/dist/queries/stats.d.ts +2 -2
- package/dist/queries/surface.d.ts +2 -2
- package/dist/queries/surface.js +1 -1
- package/dist/queries/symbols.d.ts +2 -2
- package/dist/queries/symbols.js +1 -1
- package/dist/queries/system.d.ts +2 -2
- package/dist/queries/system.js +1 -1
- package/dist/queries/test-quality.d.ts +2 -2
- package/dist/queries/test-quality.js +1 -1
- package/dist/queries/trace.d.ts +2 -2
- package/dist/queries/trace.js +1 -1
- package/dist/queries/twin-ab.d.ts +14 -3
- package/dist/queries/twin-ab.js +1 -1
- package/dist/queries/twin-drift.d.ts +2 -2
- package/dist/queries/twin-drift.js +1 -1
- package/dist/queries/unused-imports.d.ts +2 -2
- package/dist/queries/unused-imports.js +1 -1
- package/dist/queries/unused-params.d.ts +2 -2
- package/dist/queries/unused-params.js +1 -1
- package/dist/queries/vue-component-duplicates.d.ts +2 -2
- package/dist/queries/vue-component-duplicates.js +1 -1
- package/dist/queries/vue-composable-candidates.d.ts +2 -2
- package/dist/queries/vue-composable-candidates.js +1 -1
- package/dist/queries/vue-large-view-pressure.d.ts +2 -2
- package/dist/queries/vue-large-view-pressure.js +1 -1
- package/dist/queries/wrapper-candidates.d.ts +2 -2
- package/dist/queries/wrapper-candidates.js +1 -1
- package/dist/reindex-worker.js +21 -21
- package/dist/reindex.d.ts +3 -3
- package/dist/reindex.js +33 -33
- package/dist/runtime.d.ts +5 -3
- package/dist/runtime.js +3 -3
- package/dist/rust-semantic-session-server.js +1 -1
- package/dist/rust-semantic-session-worker.js +1 -1
- package/dist/rust-semantic-worker.js +1 -1
- package/dist/{scip-cli-Cc6c00-a.d.ts → scip-cli-BnEwZRLJ.d.ts} +1 -1
- package/dist/{symbol-types-BgWU6lhL.d.ts → symbol-types-BIQwfoAx.d.ts} +7 -1
- package/dist/typescript-mailbox-worker.js +2 -0
- package/dist/watch-server.js +2 -42
- package/docs/AGENT_GUIDE.md +13 -6
- package/docs/CLI_JSON_OUTPUT.md +110 -22
- package/docs/COMMAND_REFERENCE.md +88 -88
- package/docs/COMMITTED_RECORD_COMPATIBILITY.md +55 -18
- package/docs/DURABILITY.md +88 -38
- package/docs/INDEX_GENERATIONS.md +65 -19
- package/docs/MAILBOX_LIFECYCLE.md +28 -1
- package/docs/REINDEX_METADATA_COMPATIBILITY.md +18 -8
- package/docs/SECURITY_MODEL.md +31 -14
- package/docs/TELEMETRY_RETENTION.md +11 -4
- package/docs/WATCH_REFRESH_REQUESTS.md +34 -21
- package/docs/WINDOWS_SIDECAR_RELEASE.md +9 -4
- package/docs/analyzer-inventory.md +31 -22
- package/docs/analyzer-validation-ledger.md +8 -0
- package/docs/schemas/outcome-event-record.schema.json +57 -1
- package/docs/schemas/project-config.schema.json +82 -1
- package/docs/schemas/suppression-record.schema.json +84 -3
- package/package.json +5 -5
- package/skills/_shared/SKILL.md +2 -2
- package/skills/_shared/references/agent-contract-catalog.md +1 -1
- package/skills/_shared/references/detector-precision-and-diffgate.md +1 -1
- package/skills/scip-audit/SKILL.md +6 -6
- package/skills/scip-audit/references/claims.md +1 -1
- package/skills/scip-audit/references/cleanup.md +19 -20
- package/skills/scip-audit/references/directory.md +4 -4
- package/skills/scip-audit/references/frontend.md +10 -10
- package/skills/scip-audit/references/twin-drift.md +2 -2
- package/skills/scip-diagnose/references/debug.md +8 -8
- package/skills/scip-diagnose/references/root-cause.md +3 -3
- package/skills/scip-diagnose/references/triage.md +10 -10
- package/skills/scip-explore/SKILL.md +3 -3
- package/skills/scip-improve/SKILL.md +10 -10
- package/skills/scip-improve/references/cleanup-batches.md +3 -3
- package/skills/scip-improve/references/directory-moves.md +3 -3
- package/skills/scip-improve/references/doc-reconcile.md +1 -1
- package/skills/scip-improve/references/frontend-extraction.md +2 -2
- package/skills/scip-improve/references/twin-drift.md +3 -3
- package/skills/scip-plan/SKILL.md +2 -2
- package/skills/scip-plan/references/api-impact.md +5 -5
- package/skills/scip-plan/references/conductor.md +2 -2
- package/skills/scip-plan/references/hyper-optimization.md +1 -1
- package/skills/scip-query/SKILL.md +15 -5
- package/skills/scip-setup/references/bootstrap-workflow.md +7 -8
- package/skills/scip-setup/references/language-verification.md +2 -2
- package/skills/scip-setup/references/per-repo-triage.md +1 -1
- package/skills/scip-verify/SKILL.md +10 -10
- package/skills/scip-verify/references/calibrate-detectors.md +7 -7
- package/dist/chunk-2465DLHK.js +0 -3
- package/dist/chunk-2U3OLUNJ.js +0 -61
- package/dist/chunk-33XTHFKR.js +0 -2
- package/dist/chunk-43KC6EQZ.js +0 -2
- package/dist/chunk-47BU5Z4T.js +0 -8
- package/dist/chunk-4YTUWQ6M.js +0 -18
- package/dist/chunk-64MNV6AB.js +0 -8
- package/dist/chunk-67QRR5YC.js +0 -6
- package/dist/chunk-6GXYN7YA.js +0 -40
- package/dist/chunk-A2TNXAXO.js +0 -8
- package/dist/chunk-APMMR5Y2.js +0 -2
- package/dist/chunk-AZFUMCQB.js +0 -2
- package/dist/chunk-BNXICU42.js +0 -33
- package/dist/chunk-C5Q44Q5D.js +0 -3
- package/dist/chunk-DQGSM7RZ.js +0 -20
- package/dist/chunk-E2LAW7SL.js +0 -30
- package/dist/chunk-E4NFOAD4.js +0 -6
- package/dist/chunk-E5HNT4X2.js +0 -3
- package/dist/chunk-FD3HFKXR.js +0 -5
- package/dist/chunk-GHKEJTCE.js +0 -35
- package/dist/chunk-GLZTVKAB.js +0 -16
- package/dist/chunk-HIB452NU.js +0 -949
- package/dist/chunk-IF6FP6B2.js +0 -66
- package/dist/chunk-JORHF5AL.js +0 -108
- package/dist/chunk-KSGTULOS.js +0 -9
- package/dist/chunk-KXDJAG4N.js +0 -38
- package/dist/chunk-L4S2A7BV.js +0 -2
- package/dist/chunk-LP3ARJKF.js +0 -8
- package/dist/chunk-LSOR3LQG.js +0 -3
- package/dist/chunk-NTUMF2X3.js +0 -56
- package/dist/chunk-QOXBSI6G.js +0 -20
- package/dist/chunk-QXK6UUSM.js +0 -2
- package/dist/chunk-RA3AYNWP.js +0 -112
- package/dist/chunk-RJMDJR3A.js +0 -2
- package/dist/chunk-RLH5VUMG.js +0 -2
- package/dist/chunk-SMQWE25B.js +0 -3
- package/dist/chunk-TAVELHYR.js +0 -2
- package/dist/chunk-VAXNI5NE.js +0 -146
- package/dist/chunk-VVY2G5ET.js +0 -2
- package/dist/chunk-W3DBTGL4.js +0 -11
- package/dist/chunk-WANA4KAQ.js +0 -5
- package/dist/chunk-X4FR5BZF.js +0 -9
- package/dist/chunk-X6RKPDY7.js +0 -2
- package/dist/chunk-YCPASUCX.js +0 -2
- package/dist/chunk-ZL2OGDCD.js +0 -2
- package/dist/command-descriptors-ZW5J4ZEM.js +0 -631
- package/dist/direct-navigation-42YHQPOI.js +0 -3
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import{a as Ci,b as C,c as $t,d as Pi,e as We,f as ki}from"./chunk-FJH2NW7J.js";import{d as bi,e as Ei,f as k,g as jr,h as Ft,l as Ti,m as wi}from"./chunk-WUPW3UN3.js";import{a as ce,b as xi,g as Ii,h as Or,i as Ue,j as W,k as le,l as jt,n as Mt,q as Gt,r as de,s as Y,u as Mr,v as Ni,x as Gr,y as _i}from"./chunk-AIE7TFJW.js";import{a as Ar,b as Lr,e as Fr}from"./chunk-HGFDYOVB.js";import{a as Lt,b as vi,c as Ri,d as Ot}from"./chunk-MNE7YG56.js";import{a as K,b as Be,c as A,f as w,g as X,h,j as Si,k as Ve}from"./chunk-46XGSFNI.js";import{createHash as Li,randomUUID as xa}from"crypto";import{chmodSync as Fi,existsSync as He,linkSync as Ia,lstatSync as Vt,readdirSync as Br,realpathSync as Q,unlinkSync as Ea,writeSync as va}from"fs";import{homedir as Ra}from"os";import{basename as Ta,dirname as Ut,isAbsolute as Di,join as L,resolve as Wt}from"path";import{createRequire as ha}from"module";var Sa=ha(import.meta.url),qt=ba().version;function ba(){for(let e of["../package.json","../../package.json"])try{return Sa(e)}catch{}return{version:"0.0.0"}}var Oi=1,st=".scip-query-cache-owner.json",wa=16*1024,ji=Object.freeze({...Or,randomToken:()=>xa(),linkFile:(e,t)=>Ia(e,t),removeFile:e=>Ea(e),writeFile:(e,t,r,n)=>va(e,t,r,n)});function Bt(e,t){return Object.assign(new Error(`refusing unsafe project dbPath ${JSON.stringify(e)} (${t}); use a repository-relative directory that remains inside the checkout`),{name:"UnsafeCachePathError",code:"SCIP_QUERY_UNSAFE_CACHE_PATH",configuredPath:e,reason:t})}function J(e,t){return Object.assign(new Error(`refusing unowned cache directory ${JSON.stringify(e)} (${t}); move unrelated data elsewhere or choose a new empty dbPath`),{name:"CacheOwnershipError",code:"SCIP_QUERY_CACHE_OWNERSHIP",cacheDir:e,reason:t})}function Ca(e,t){let r=Q(e),n=process.env.SCIP_QUERY_CACHE_DIR;return n?$r(r,Wt(n)):t?.dbPath?$r(r,ka(r,t.dbPath)):$r(r,Vr(r))}function Mi(){let e=process.env.XDG_CACHE_HOME;return L(e||L(Ra(),".cache"),"scip-query")}function Vr(e){let t=Wt(e);try{t=Q(t)}catch{}let r=Li("sha256").update(t).digest("hex").slice(0,12);return L(Mi(),"projects",r)}function Ur(e){if(!/^[a-f0-9]{24}$/.test(e))throw new Error(`invalid repository cache identity: ${e}`);let t=L(Mi(),"repositories",e);return $i(t),Q(t)}function Wr(e){return process.env.SCIP_QUERY_SHARED_CACHE!=="0"&&!process.env.SCIP_QUERY_CACHE_DIR&&!process.env.SCIP_QUERY_INDEX_DB&&!e?.dbPath}function om(e,t){let r=Ca(e,t);return{cacheDir:r,dbPath:L(r,"index.db"),indexPath:L(r,"index.scip"),metaPath:L(r,"meta.json")}}function $r(e,t,r=ji){return Pa(e,t,r).cacheDir}function Pa(e,t,r=ji){let n=Q(e),i=He(t)?"synced":$i(t,r),o=Q(t),s=L(o,st);if(He(s))return qr(n,o),Hr(s),ot(o),{kind:"existing",cacheDir:o};Ai(o),La(o),Ai(o);let c=`${JSON.stringify({schemaVersion:Oi,canonicalProjectRoot:n,canonicalCacheDir:o,creatorVersion:qt},null,2)}
|
|
2
|
+
`;try{let l=Fa(s,c,r),d=le(i,l);return{kind:"published",cacheDir:o,achievedDurability:d==="synced"?"directory-durable":"file-flushed",directorySync:d}}catch(l){if(ja(l))return qr(n,o),{kind:"existing",cacheDir:o};throw l}}function qr(e,t){let r=Q(e),n=Q(t);return _a(n,r,n)}function sm(e,t){return He(L(t,st))?(qr(e,t),Gi(t),!0):!1}function ka(e,t){let r;try{r=Ft(t)}catch(s){throw s instanceof Ei?Bt(t,s.reason):s}let n=Wt(e,...r.split("/"));if(n===e||!jr(e,n))throw Bt(t,"outside-project");let i=Na(n),o=Q(i);if(!jr(e,o)&&o!==e)throw Bt(t,"symlink-escape");return n}function Na(e){let t=e;for(;!He(t);){let r=Ut(t);if(r===t)throw Bt(e,"no-existing-ancestor");t=r}return t}function _a(e,t,r){let n=L(e,st);if(!He(n)||Vt(n).isSymbolicLink())throw J(e,"missing regular ownership record");let i=Vt(n);if(!i.isFile()||i.size>wa)throw J(e,"invalid ownership record file");let o=h(n,"cache ownership record"),s=Da(o,e);if(s.canonicalProjectRoot!==t)throw J(e,"ownership record belongs to a different project");if(s.canonicalCacheDir!==r)throw J(e,"ownership record names a different cache directory");return{record:s,ownerSha256:Li("sha256").update(o).digest("hex"),physicalCacheDir:e}}function Da(e,t){try{let r=JSON.parse(e);if(r.schemaVersion!==Oi||typeof r.canonicalProjectRoot!="string"||typeof r.canonicalCacheDir!="string"||typeof r.creatorVersion!="string"||!Di(r.canonicalProjectRoot)||!Di(r.canonicalCacheDir))throw new Error("invalid fields");return r}catch(r){throw J(t,`malformed ownership record: ${r instanceof Error?r.message:String(r)}`)}}function Ai(e){let t=Br(e).filter(r=>r!==st&&!Aa(r));if(t.length>0)throw J(e,`unrecognized existing entries: ${t.slice(0,3).join(", ")}`)}function Aa(e){return e.startsWith(`${st}.tmp-`)||[".scipquery-generations","affected-shadow-latest.json","affected-shadow.jsonl","agent-hooks","augment-vue-meta.json","cache-lifecycle.lock","evidence.db","evidence.db-shm","evidence.db-wal","health-report-cache.json","index.db","index.db-shm","index.db-wal","index.lock","index.scip","language-indexes","meta.json","reindex-activity.jsonl","shared-cache.json","typescript-index","typescript-scip-fragments","typescript-scip-overlays","typescript-semantic","watch-activity.json","watch-refresh-requests","watch-state.json","watch.lock"].includes(e)?!0:/^(?:reindex-|rust-|typescript-)/.test(e)}function La(e){for(let t of Br(e)){let r=L(e,t),n=Vt(r);if(n.isSymbolicLink())throw J(e,`legacy cache entry ${t} is a symlink`);if(n.isDirectory())ot(r);else if(n.isFile())Hr(r);else throw J(e,`legacy cache entry ${t} is not a file or directory`)}ot(e)}function Gi(e){let t=Vt(e);if(t.isSymbolicLink())throw J(e,"managed cache tree contains a symlink");if(t.isFile()){Hr(e);return}if(!t.isDirectory())throw J(e,"managed cache tree contains a special file");ot(e);for(let r of Br(e))Gi(L(e,r))}function $i(e,t=Or){let r=Ue(e,t);return ot(e),r}function Fa(e,t,r){let n=`${e}.tmp-${process.pid}-${r.randomToken()}`,i,o=!1;try{i=r.openFile(n,"wx",384),o=!0,Ii(i,Buffer.from(t),r,"cache ownership record"),r.syncFile(i),r.closeFile(i),i=void 0,r.linkFile(n,e);let s=W(Ut(e),r);return r.removeFile(n),o=!1,le(s,W(Ut(e),r))}finally{if(i!==void 0)try{r.closeFile(i)}catch{}if(o)try{r.removeFile(n)}catch{}}}function ot(e){process.platform!=="win32"&&Fi(e,448)}function Hr(e){process.platform!=="win32"&&Fi(e,384)}function Oa(e){if(He(e))return Q(e);let t=Q(Ut(e));return L(t,Ta(e))}function zr(e){return Oa(Wt(e))}function ja(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="EEXIST"}import{createHash as Wa}from"crypto";import{dirname as Ha,join as Ui}from"path";var qi=["typescript","javascript","java","scala","kotlin","rust","python","ruby","go","cpp","c","csharp","vb","dart","php","clojure"];var Kr=2,Ee=3;var Xr=new Set(qi);function ue(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){return{kind:"malformed",reason:`invalid JSON: ${Ua(s)}`}}if(!ce(t))return{kind:"malformed",reason:"metadata must be a JSON object"};let r=t.version;if(!Number.isInteger(r))return{kind:"malformed",reason:"version must be an integer"};if(r!==Kr&&r!==Ee)return{kind:"unsupported",version:r,direction:r<Kr?"older":"future"};let n=Ga(t,r);if(n)return{kind:"malformed",reason:n};let i=t,o={metadata:i,capabilities:Ma(i)};return r===Kr?{kind:"legacy",...o,metadata:i}:{kind:"supported",...o,metadata:i}}function fm(e){return e.kind==="legacy"||e.kind==="supported"?e.metadata:null}function Ht(e){if(e.kind!=="legacy"&&e.kind!=="supported"||!e.capabilities.stableGenerationIdentity)return null;let t=e.metadata;return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion,sqliteLayoutVersion:t.version===Ee?t.sqliteLayoutVersion:void 0})}function Ma(e){let t=e.fingerprint!==void 0,r=ce(e.fingerprint),n=e.indexedLanguages!==void 0,i=e.status==="complete",o=e.version===Ee?e:null;return{usableForQuery:n,usableForEvidenceCache:t,publishableGeneration:i&&r&&n,stableGenerationIdentity:i&&t&&typeof e.updatedAt=="string",languageShardReuse:!!o?.languageFingerprints,typescriptProjectShardReuse:!!o?.typescriptProjectShards}}function Ga(e,t){if(e.status!=="complete"&&e.status!=="partial")return"status must be complete or partial";if(e.updatedAt!==void 0&&!xi(e.updatedAt))return"updatedAt must be a valid timestamp";for(let r of["requestedLanguages","indexedLanguages"])if(e[r]!==void 0&&!$a(e[r]))return`${r} must contain unique supported languages`;return e.skipped!==void 0&&!qa(e.skipped)?"skipped must contain supported language/reason pairs":e.scipCompanion!==void 0&&e.scipCompanion!=="current"&&e.scipCompanion!=="deferred"?"scipCompanion must be current or deferred":t===Ee&&e.sqliteLayoutVersion!==void 0&&(!Number.isSafeInteger(e.sqliteLayoutVersion)||e.sqliteLayoutVersion<1)?"sqliteLayoutVersion must be a positive safe integer":t===Ee&&e.languageFingerprints!==void 0&&!Ba(e.languageFingerprints)?"languageFingerprints must map supported languages to fingerprint objects":t===Ee&&e.typescriptProjectShards!==void 0&&!Va(e.typescriptProjectShards)?"typescriptProjectShards must map project names to file fingerprints":null}function mm(e){return e.version===Ee&&e.sqliteLayoutVersion===1}function $a(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string"&&Xr.has(t))?!1:new Set(e).size===e.length}function qa(e){return Array.isArray(e)&&e.every(t=>ce(t)&&typeof t.language=="string"&&Xr.has(t.language)&&typeof t.reason=="string")}function Ba(e){return ce(e)&&Object.entries(e).every(([t,r])=>Xr.has(t)&&ce(r))}function Va(e){return ce(e)&&Object.values(e).every(t=>ce(t)&&Array.isArray(t.files)&&t.files.every(bi))}function Ua(e){return e instanceof Error?e.message:String(e)}var Bi=3,za=2,Ka="typescript-index";function Im(e){let t=Ui(e,Ka),r=Ni(t);return{...r,requestDir:r.legacyRequestDir}}function Em(e){let t=JSON.parse(e),r=t.protocolVersion,n=r===za;if(!n&&r!==Bi||typeof t.id!="string"||!t.id||typeof t.baseGeneration!="string"||!t.baseGeneration||typeof t.deadlineAtMs!="number"||!Number.isFinite(t.deadlineAtMs)||!Xa(t.request)||!n&&(t.mailboxVersion!==Mr||typeof t.operationKey!="string"||!/^[a-f0-9]{64}$/.test(t.operationKey)||t.id!==_i(t.operationKey)||typeof t.clientId!="string"||!t.clientId||typeof t.enqueuedAtMs!="number"||!Number.isFinite(t.enqueuedAtMs)||t.deadlineAtMs<t.enqueuedAtMs))throw new Error("TypeScript index service received an invalid mailbox request.");if(!n){let o=t,s=Gr("typescript-index-v3",{baseGeneration:o.baseGeneration,request:o.request});if(o.operationKey!==s)throw new Error("TypeScript index service received a mismatched mailbox operation identity.");return o}let i=Gr("typescript-index-v2",{id:t.id,baseGeneration:t.baseGeneration,request:t.request});return{protocolVersion:Bi,mailboxVersion:Mr,id:t.id,operationKey:i,clientId:"legacy-v2",enqueuedAtMs:t.deadlineAtMs,deadlineAtMs:t.deadlineAtMs,baseGeneration:t.baseGeneration,request:t.request}}function vm(e){try{let t=Ht(ue(h(Ui(Ha(e),"meta.json"),"reindex metadata")));return t?Wa("sha256").update(t).digest("hex"):null}catch{return null}}function Xa(e){if(!e||typeof e!="object")return!1;let t=e,r=Vi(t.modifiedFiles)?t.modifiedFiles:null,n=Vi(t.affectedFiles)?t.affectedFiles:null;return t.kind==="emit-documents"&&typeof t.tsconfigPath=="string"&&!!t.tsconfigPath&&typeof t.projectArgument=="string"&&!!t.projectArgument&&typeof t.projectIdentity=="string"&&!!t.projectIdentity&&typeof t.producerIdentity=="string"&&!!t.producerIdentity&&r!==null&&r.length>0&&new Set(r).size===r.length&&n!==null&&n.length>0&&new Set(n).size===n.length&&r.every(i=>n.includes(i))}function Vi(e){return Array.isArray(e)&&e.every(t=>typeof t=="string"&&t.length>0)}import{spawnSync as Ya}from"child_process";import{createHash as Ja}from"crypto";import{existsSync as Qa,lstatSync as Za,realpathSync as ec}from"fs";import{dirname as tc,isAbsolute as rc,join as nc,resolve as Kt}from"path";var Xt={run(e,t){let r=Hi(e,t);return r.kind==="success"?r.output:void 0},runResult:Hi},ic=["rev-parse","--show-toplevel","--absolute-git-dir","--git-common-dir","HEAD","HEAD^{tree}"],Wi=/^[0-9a-f]{40,64}$/;function zi(e,t=Xt){let r=t.runResult(e,ic);if(r.kind==="success"){let n=oc(r.output);if(n)return sc(n,t)}return ac(e,t)}function oc(e){let t=e.split(`
|
|
3
|
+
`).map(c=>c.trim());if(t.length!==5)return;let[r,n,i,o,s]=t;if(!r||!n||!i||!o||!s||!Wi.test(o)||!Wi.test(s))return;let a=ve(r);return{root:a,gitDir:ve(zt(a,n)),commonDir:ve(zt(a,i)),headCommit:o,treeOid:s}}function sc(e,t){let r=t.run(e.root,["status","--porcelain=v1","-z","--untracked-files=all"]);return r===void 0?void 0:{...Ki(e.root,e.gitDir),commonDir:e.commonDir,repositoryId:Jr("repository",e.commonDir),headCommit:e.headCommit,treeOid:e.treeOid,clean:r.length===0}}function ac(e,t){let r=cc(e,t);if(r.kind!=="worktree")return;let n=r.identity,i=n.projectRoot,o=t.run(i,["rev-parse","--git-common-dir"])?.trim();if(!o)return;let s=ve(zt(i,o)),a=Yr(t.run(i,["rev-parse","--verify","HEAD"])),c=Yr(t.run(i,["rev-parse","--verify","HEAD^{tree}"])),l=t.run(i,["status","--porcelain=v1","-z","--untracked-files=all"]);if(l!==void 0)return{...n,commonDir:s,repositoryId:Jr("repository",s),headCommit:a,treeOid:c,clean:l.length===0}}function cc(e,t=Xt){let r=t.runResult(e,["rev-parse","--show-toplevel"]);if(r.kind==="not-repository")return{kind:"non-git"};if(r.kind==="error")return r;let n=r.output.trim();if(!n)return{kind:"error",message:"Git returned an empty worktree root."};let i=ve(n),o=t.run(i,["rev-parse","--absolute-git-dir"])?.trim();if(!o)return{kind:"error",message:"Git did not return an absolute worktree directory."};let s=ve(zt(i,o));return{kind:"worktree",identity:Ki(i,s)}}function Ki(e,t){return{projectRoot:e,gitDir:t,worktreeId:Jr("worktree",`${e}\0${t}`)}}function lc(e,t=Xt){let r=t.run(e,["worktree","list","--porcelain","-z"]);return r===void 0?[]:dc(r)}function dc(e){let t=[],r;for(let n of e.split("\0")){if(n===""){r&&t.push(r),r=void 0;continue}let i=n.indexOf(" "),o=i<0?n:n.slice(0,i),s=i<0?"":n.slice(i+1);if(o==="worktree"){r&&t.push(r),r={path:ve(s),detached:!1,bare:!1,prunable:!1,locked:!1};continue}r&&(o==="HEAD"?r.head=s:o==="branch"?r.branch=s:o==="detached"?r.detached=!0:o==="bare"?r.bare=!0:o==="prunable"?r.prunable=!0:o==="locked"&&(r.locked=!0))}return r&&t.push(r),t}function km(e,t,r=Xt){return Yr(r.run(e,t))}function zt(e,t){return rc(t)?t:Kt(e,t)}function ve(e){try{return ec(e)}catch{return Kt(e)}}function Jr(e,t){return Ja("sha256").update(`${e}\0${t}`).digest("hex").slice(0,24)}function Yr(e){return e?.trim()||void 0}function Hi(e,t){let r=Ya("git",["-C",e,...t],{encoding:"utf-8",env:{...process.env,LC_ALL:"C"},maxBuffer:52428800,stdio:["ignore","pipe","pipe"],timeout:3e4,killSignal:"SIGKILL"});if(r.status===0)return{kind:"success",output:r.stdout.trimEnd()};let i=(typeof r.stderr=="string"?r.stderr.trim():"")||r.error?.message||`git exited with status ${r.status??"unknown"}`,o=r.error?.code;return(/not a git repository/i.test(i)||o==="ENOENT"&&Qa(Kt(e)))&&!uc(e)?{kind:"not-repository"}:{kind:"error",message:i}}function uc(e){if(process.env.GIT_DIR||process.env.GIT_COMMON_DIR)return!0;let t=Kt(e);for(;;){try{return Za(nc(t,".git")),!0}catch(n){let i=n.code;if(i!=="ENOENT"&&i!=="ENOTDIR")return!0}let r=tc(t);if(r===t)return!1;t=r}}import{join as pc}from"path";var fc=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function Xi(e,t={}){return Re(pc(e,"gc.lock"),t)}function Re(e,t={}){let r=t.waitMs??0,n=t.pollMs??10,i=t.now??Lt,o=i()+r;do{let s=mc(e);if(s)return gc(s);let a=o-i();if(a<=0)return null;yc(Math.min(n,a))}while(i()<=o);return null}function mc(e){let t=Mt(e,{kind:"generic",parseLegacy:fc});return t.kind==="acquired"?t.lock:null}function gc(e){return{release:()=>{e.release()}}}function yc(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import{createHash as hc,randomUUID as Sc}from"crypto";import{existsSync as ze,mkdirSync as bc,readdirSync as xc,rmSync as Ji,statSync as Qi}from"fs";import{basename as Ic,dirname as Yt,join as F}from"path";var Te=1,tn=1,ct=".scipquery-generations",Jt="manifest.json",Zi="readers",Ec="gc.lock",vc=128,at=new Map,eo={pid:process.pid,now:()=>new Date,randomToken:()=>Sc(),isProcessAlive:jt,readProcessIdentity:Ot};function v(e){return F(Yt(e),ct)}function rn(e){return F(v(e),Ec)}function Wm(e,t=eo){let r=Re(rn(e.dbPath),{waitMs:5e3});if(!r)throw new Error("SQLite generation retention is busy; retry opening the index.");let n;try{let i=wc(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 s=F(v(e.dbPath),Zi);bc(s,{recursive:!0}),n=F(s,`${t.pid}-${o}.json`);let a=t.readProcessIdentity(t.pid);de(n,{version:1,token:o,generationIdentity:i.identity,pid:t.pid,...a?{processIdentity:a}:{},acquiredAt:t.now().toISOString()},{spacing:2,trailingNewline:!0});let c=!1;return{generation:i,release(){c||!n||(c=!0,Ji(n,{force:!0}))}}}finally{r.release()}}function to(e,t,r=eo,n={}){let i=F(v(e),Zi);if(!ze(i))return{protectedGenerations:new Set,activeLeases:0,staleLeasesRemoved:0,malformedLeases:0};let o=new Set,s=0,a=0,c=0;for(let l of xc(i,{withFileTypes:!0})){if(!l.isFile()||!l.name.endsWith(".json"))continue;let d=F(i,l.name),u;try{u=Rc(JSON.parse(h(d,"SQLite generation reader lease")))}catch{u=null}if(!u){c+=1;for(let p of t)o.add(p);continue}if(!Tc(u,r)){n.removeStale!==!1&&(Ji(d,{force:!0}),a+=1);continue}s+=1,o.add(u.generationIdentity)}return{protectedGenerations:o,activeLeases:s,staleLeasesRemoved:a,malformedLeases:c}}function Rc(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e,r=t.processIdentity===void 0?null:vi(t.processIdentity);return t.version!==1||typeof t.token!="string"||t.token.trim()===""||typeof t.generationIdentity!="string"||!/^[a-f0-9]{64}$/.test(t.generationIdentity)||typeof t.pid!="number"||!Number.isSafeInteger(t.pid)||t.pid<=0||typeof t.acquiredAt!="string"||!Number.isFinite(Date.parse(t.acquiredAt))||t.processIdentity!==void 0&&(!r||r.pid!==t.pid)?null:{version:1,token:t.token,generationIdentity:t.generationIdentity,pid:t.pid,...r?{processIdentity:r}:{},acquiredAt:t.acquiredAt}}function Tc(e,t){if(!t.isProcessAlive(e.pid))return!1;if(!e.processIdentity)return!0;let r=t.readProcessIdentity(e.pid);return r===null||Ri(e.processIdentity,r)}function we(e){try{let t=JSON.parse(h(F(v(e),"state.json"),"SQLite generation state"));return Nc(t)?t:null}catch{return null}}function Qt(e,t){return lt(v(e),t)}function lt(e,t){try{let r=JSON.parse(h(F(e,t,Jt),"SQLite generation manifest"));return kc(r,t)?r:null}catch{return null}}function wc(e){let t=we(e.dbPath);if(t){let r=Cc(e,t.currentGeneration);if(r)return r;if(t.artifactSet==="immutable-v1")throw new Error(`Published SQLite generation ${t.currentGeneration} is missing or invalid.`)}if(ze(F(Yt(e.dbPath),"index.lock")))throw new Error("Legacy SQLite publication is in progress; retry after the reindex lock is released.");return Pc(e,t?.currentGeneration)}function Hm(e){let t=we(e);if(t)return t.currentGeneration;try{let r=F(Yt(e),"meta.json"),n=ze(r)?h(r,"reindex metadata"):void 0;return ro(e,n)}catch{return null}}function pe(e){return Ht(ue(e))??e}function Cc(e,t){try{let r=F(v(e.dbPath),t),n=Qt(e.dbPath,t);if(!n)return null;let i=Qr(r,n.database),o=n.index?Qr(r,n.index):void 0,s=n.metadata?Qr(r,n.metadata):void 0;return!Zr(i,n.database)||n.index&&(!o||!Zr(o,n.index))||n.metadata&&(!s||!Zr(s,n.metadata))?null:{identity:t,databasePath:i,...o?{indexPath:o}:{},...s?{metadataPath:s,metadataRaw:h(s,"reindex metadata")}:{},source:"immutable"}}catch{return null}}function Pc(e,t){let r=Ce(e.dbPath),n=F(Yt(e.dbPath),"meta.json"),i=ze(n)?h(n,"reindex metadata"):void 0,o=ze(e.indexPath)?e.indexPath:void 0;return{identity:t??ro(e.dbPath,i),databasePath:e.dbPath,...o?{indexPath:o}:{},...i===void 0?{}:{metadataPath:n,metadataRaw:i},source:"legacy",databaseFileIdentity:r}}function ro(e,t){let r=hc("sha256").update("sqlite-generation-legacy-v1\0");return t!==void 0&&r.update(pe(t)),r.update(`\0${Ce(e)}`),r.digest("hex")}function Ce(e){let t=Qi(e);return`${t.dev}:${t.ino}:${t.size}:${t.mtimeMs}`}function Qr(e,t){if(Ic(t.file)!==t.file||t.file==="."||t.file==="..")throw new Error("SQLite generation manifest contains an unsafe artifact path");return F(e,t.file)}function Zr(e,t){if(!ze(e))return!1;let r=Yi(e);if(!r||r.size!==t.size)return!1;let n=`${e}\0${t.sha256}\0${r.identity}`;if(at.has(n))return!0;let i=Ve(e,{inputKind:"immutable SQLite generation artifact",maxBytes:t.size}),o=Yi(e);if(!o||o.identity!==r.identity||i!==t.sha256)return!1;for(at.set(n,!0);at.size>vc;){let s=at.keys().next().value;if(s===void 0)break;at.delete(s)}return!0}function Yi(e){let t=Qi(e,{bigint:!0});return t.isFile()?{identity:`${t.dev}:${t.ino}:${t.size}:${t.mtimeNs}:${t.ctimeNs}`,size:Number(t.size)}:null}function kc(e,t){return e.version===tn&&e.identity===t&&en(e.database)&&(e.index===void 0||en(e.index))&&(e.metadata===void 0||en(e.metadata))}function en(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 Nc(e){return e.version===Te&&typeof e.currentGeneration=="string"&&!!e.currentGeneration&&typeof e.publishedAt=="string"&&Number.isFinite(Date.parse(e.publishedAt))&&(e.artifactSet===void 0||e.artifactSet==="immutable-v1")&&_c(e.stableMirrors)&&Dc(e.previousGeneration)&&Ac(e.publication)}function _c(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 Dc(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 Ac(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,r=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(n=>n!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&r.every(n=>typeof n=="number"&&Number.isFinite(n)&&n>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}import{createHash as Lc}from"crypto";import{existsSync as Fc,mkdirSync as Oc}from"fs";import{dirname as no,join as jc}from"path";import nn from"better-sqlite3";var Mc="evidence.db";var Gc=["source-facts","definition-exclusions","doc-path-tokens","react-component-behavior-profiles"],on=new Set(Gc),$c=25e4,qc=512*1024*1024,Bc=6e4;var Zt=new WeakMap,Vc=C("evidence-content-hash",{clearGroups:["whole-project","source-file"]}),Uc=C("evidence-project-fingerprint",{clearGroups:["whole-project"]}),re="evidence-v1",Ke="version NOT LIKE 'evidence-%'";function er(e){return Lc("sha256").update(e).digest("hex")}function dt(e,t,r){return Vc.get(e,t,()=>er(r))}function io(e){return Uc.get(e,"current",()=>{try{if(!e.generation.metadataRaw)return null;let t=ue(e.generation.metadataRaw);if(t.kind!=="legacy"&&t.kind!=="supported"||!t.capabilities.usableForEvidenceCache)return null;let r=t.metadata,n=[...r.indexedLanguages??[]].sort();return er(JSON.stringify({fingerprint:r.fingerprint,indexedLanguages:n,status:r.status}))}catch(t){return Pe("project fingerprint unavailable",t),null}})}function Pe(e,t){process.env.SCIP_QUERY_DEBUG&&console.error(`evidence-cache: ${e}: ${t instanceof Error?t.message:String(t)}`)}function ut(e){if(Zt.has(e))return Zt.get(e)??null;let t=null;try{let r=new nn(jc(no(e.config.dbPath),Mc));r.pragma("journal_mode = WAL"),r.pragma("busy_timeout = 5000"),r.pragma("synchronous = NORMAL"),r.exec(`
|
|
4
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
5
|
+
kind TEXT NOT NULL,
|
|
6
|
+
relative_path TEXT NOT NULL,
|
|
7
|
+
content_hash TEXT NOT NULL,
|
|
8
|
+
version TEXT NOT NULL,
|
|
9
|
+
payload TEXT NOT NULL,
|
|
10
|
+
PRIMARY KEY (kind, relative_path)
|
|
11
|
+
);
|
|
12
|
+
CREATE TABLE IF NOT EXISTS project_evidence (
|
|
13
|
+
kind TEXT NOT NULL,
|
|
14
|
+
cache_key TEXT NOT NULL,
|
|
15
|
+
project_fingerprint TEXT NOT NULL,
|
|
16
|
+
version TEXT NOT NULL,
|
|
17
|
+
payload TEXT NOT NULL,
|
|
18
|
+
PRIMARY KEY (kind, cache_key)
|
|
19
|
+
);
|
|
20
|
+
CREATE TABLE IF NOT EXISTS semantic_callees (
|
|
21
|
+
relative_path TEXT NOT NULL,
|
|
22
|
+
symbol TEXT NOT NULL,
|
|
23
|
+
content_hash TEXT NOT NULL,
|
|
24
|
+
deps_digest TEXT NOT NULL,
|
|
25
|
+
version TEXT NOT NULL,
|
|
26
|
+
payload TEXT NOT NULL,
|
|
27
|
+
PRIMARY KEY (relative_path, symbol)
|
|
28
|
+
);
|
|
29
|
+
CREATE TABLE IF NOT EXISTS semantic_references (
|
|
30
|
+
relative_path TEXT NOT NULL,
|
|
31
|
+
symbol TEXT NOT NULL,
|
|
32
|
+
project_fingerprint TEXT NOT NULL,
|
|
33
|
+
version TEXT NOT NULL,
|
|
34
|
+
payload TEXT NOT NULL,
|
|
35
|
+
PRIMARY KEY (relative_path, symbol)
|
|
36
|
+
);
|
|
37
|
+
CREATE TABLE IF NOT EXISTS finding_outcome_ledger (
|
|
38
|
+
check_name TEXT NOT NULL,
|
|
39
|
+
finding_id TEXT NOT NULL,
|
|
40
|
+
first_seen INTEGER NOT NULL,
|
|
41
|
+
last_seen INTEGER NOT NULL,
|
|
42
|
+
times_shown INTEGER NOT NULL,
|
|
43
|
+
outcome TEXT NOT NULL,
|
|
44
|
+
PRIMARY KEY (check_name, finding_id)
|
|
45
|
+
);
|
|
46
|
+
CREATE TABLE IF NOT EXISTS finding_outcome_observations (
|
|
47
|
+
observation_id TEXT PRIMARY KEY,
|
|
48
|
+
fingerprint TEXT NOT NULL,
|
|
49
|
+
observed_at INTEGER NOT NULL
|
|
50
|
+
);
|
|
51
|
+
`),t={evidence:r,shared:Wc(e.config.sharedEvidenceDbPath),readFileEvidence:r.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),readLegacyFileEvidence:r.prepare(`SELECT payload FROM file_evidence
|
|
52
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND ${Ke}
|
|
53
|
+
ORDER BY version DESC
|
|
54
|
+
LIMIT 1`),writeFileEvidence:r.prepare("INSERT OR REPLACE INTO file_evidence (kind, relative_path, content_hash, version, payload) VALUES (?, ?, ?, ?, ?)"),readProjectEvidence:r.prepare("SELECT payload FROM project_evidence WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND version = ?"),readLegacyProjectEvidence:r.prepare(`SELECT payload FROM project_evidence
|
|
55
|
+
WHERE kind = ? AND cache_key = ? AND project_fingerprint = ? AND ${Ke}
|
|
56
|
+
ORDER BY version DESC
|
|
57
|
+
LIMIT 1`),writeProjectEvidence:r.prepare("INSERT OR REPLACE INTO project_evidence (kind, cache_key, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)"),readCallees:r.prepare(`SELECT payload FROM semantic_callees
|
|
58
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCallees:r.prepare(`SELECT payload FROM semantic_callees
|
|
59
|
+
WHERE relative_path = ? AND symbol = ? AND content_hash = ? AND deps_digest = ? AND ${Ke}
|
|
60
|
+
ORDER BY version DESC
|
|
61
|
+
LIMIT 1`),readCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
62
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND version = ?`),readLegacyCalleesForFile:r.prepare(`SELECT symbol, payload FROM semantic_callees
|
|
63
|
+
WHERE relative_path = ? AND content_hash = ? AND deps_digest = ? AND ${Ke}
|
|
64
|
+
ORDER BY symbol, version DESC`),writeCallees:r.prepare(`INSERT OR REPLACE INTO semantic_callees
|
|
65
|
+
(relative_path, symbol, content_hash, deps_digest, version, payload) VALUES (?, ?, ?, ?, ?, ?)`),dropStaleCallees:r.prepare("DELETE FROM semantic_callees WHERE relative_path = ? AND content_hash != ?"),readReferences:r.prepare(`SELECT payload FROM semantic_references
|
|
66
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferences:r.prepare(`SELECT payload FROM semantic_references
|
|
67
|
+
WHERE relative_path = ? AND symbol = ? AND project_fingerprint = ? AND ${Ke}
|
|
68
|
+
ORDER BY version DESC
|
|
69
|
+
LIMIT 1`),readReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
|
|
70
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND version = ?`),readLegacyReferencesForFile:r.prepare(`SELECT symbol, payload FROM semantic_references
|
|
71
|
+
WHERE relative_path = ? AND project_fingerprint = ? AND ${Ke}
|
|
72
|
+
ORDER BY symbol, version DESC`),writeReferences:r.prepare(`INSERT OR REPLACE INTO semantic_references
|
|
73
|
+
(relative_path, symbol, project_fingerprint, version, payload) VALUES (?, ?, ?, ?, ?)`),dropStaleReferences:r.prepare("DELETE FROM semantic_references WHERE relative_path = ? AND project_fingerprint != ?"),readFindingOutcomeLedger:r.prepare("SELECT check_name, finding_id, first_seen, last_seen, times_shown, outcome FROM finding_outcome_ledger"),claimFindingOutcomeObservation:r.prepare(`INSERT OR IGNORE INTO finding_outcome_observations
|
|
74
|
+
(observation_id, fingerprint, observed_at) VALUES (?, ?, ?)`),readFindingOutcomeObservation:r.prepare("SELECT fingerprint FROM finding_outcome_observations WHERE observation_id = ?"),upsertFindingOutcomeLedgerRow:r.prepare(`INSERT INTO finding_outcome_ledger
|
|
75
|
+
(check_name, finding_id, first_seen, last_seen, times_shown, outcome)
|
|
76
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
77
|
+
ON CONFLICT(check_name, finding_id) DO UPDATE SET
|
|
78
|
+
first_seen = MIN(finding_outcome_ledger.first_seen, excluded.first_seen),
|
|
79
|
+
last_seen = MAX(finding_outcome_ledger.last_seen, excluded.last_seen),
|
|
80
|
+
times_shown = finding_outcome_ledger.times_shown + excluded.times_shown,
|
|
81
|
+
outcome = excluded.outcome`),updateFindingOutcomeLedgerRow:r.prepare(`UPDATE finding_outcome_ledger
|
|
82
|
+
SET first_seen = MIN(first_seen, ?),
|
|
83
|
+
last_seen = MAX(last_seen, ?),
|
|
84
|
+
outcome = ?
|
|
85
|
+
WHERE check_name = ? AND finding_id = ?`),trimFindingOutcomeLedgerCheck:r.prepare(`DELETE FROM finding_outcome_ledger
|
|
86
|
+
WHERE rowid IN (
|
|
87
|
+
SELECT rowid
|
|
88
|
+
FROM finding_outcome_ledger
|
|
89
|
+
WHERE check_name = ?
|
|
90
|
+
ORDER BY last_seen DESC, first_seen DESC, finding_id DESC
|
|
91
|
+
LIMIT -1 OFFSET ?
|
|
92
|
+
)`)}}catch(r){Pe("disabled (open failed)",r)}return Zt.set(e,t),t}function pt(e,t,r){Pe(`disabled (${t})`,r),Zt.set(e,null)}function Wc(e){if(!e)return null;try{Oc(no(e),{recursive:!0});let t=new nn(e);return t.pragma("journal_mode = WAL"),t.pragma("busy_timeout = 250"),t.pragma("synchronous = NORMAL"),t.exec(`
|
|
93
|
+
CREATE TABLE IF NOT EXISTS file_evidence (
|
|
94
|
+
kind TEXT NOT NULL,
|
|
95
|
+
relative_path TEXT NOT NULL,
|
|
96
|
+
content_hash TEXT NOT NULL,
|
|
97
|
+
version TEXT NOT NULL,
|
|
98
|
+
payload TEXT NOT NULL,
|
|
99
|
+
last_accessed_at INTEGER NOT NULL,
|
|
100
|
+
PRIMARY KEY (kind, relative_path, content_hash, version)
|
|
101
|
+
);
|
|
102
|
+
CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
|
|
103
|
+
ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version);
|
|
104
|
+
`),{evidence:t,readFileEvidence:t.prepare("SELECT payload FROM file_evidence WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?"),writeFileEvidence:t.prepare(`INSERT INTO file_evidence (kind, relative_path, content_hash, version, payload, last_accessed_at)
|
|
105
|
+
VALUES (?, ?, ?, ?, ?, ?)
|
|
106
|
+
ON CONFLICT(kind, relative_path, content_hash, version)
|
|
107
|
+
DO UPDATE SET payload = excluded.payload, last_accessed_at = excluded.last_accessed_at`),touchFileEvidence:t.prepare(`UPDATE file_evidence
|
|
108
|
+
SET last_accessed_at = ?
|
|
109
|
+
WHERE kind = ? AND relative_path = ? AND content_hash = ? AND version = ?
|
|
110
|
+
AND last_accessed_at < ?`)}}catch(t){return Pe("shared cache disabled (open failed)",t),null}}function sn(e,t,r){Pe(`shared cache disabled (${t})`,r);try{e.shared?.evidence.close()}catch{}e.shared=null}function eg(e,t={}){if(!Fc(e))return null;let r;try{r=new nn(e),r.pragma("busy_timeout = 50"),r.exec(`CREATE INDEX IF NOT EXISTS idx_file_evidence_lru
|
|
111
|
+
ON file_evidence(last_accessed_at, kind, relative_path, content_hash, version)`),r.pragma("wal_checkpoint(TRUNCATE)");let n=r.prepare("SELECT COUNT(*) AS count FROM file_evidence").get().count,i=t.maxRows??$c,o=t.budgetBytes??qc,s=Number(r.pragma("page_size",{simple:!0})),a=Number(r.pragma("page_count",{simple:!0})),c=Number(r.pragma("freelist_count",{simple:!0})),l=Math.max(0,a-c)*s,d=n>0&&l>o?Math.min(n,Math.ceil((l-o)/Math.max(1,l/n))):0,u=Math.max(n-i,d);return u>0&&(r.prepare(`DELETE FROM file_evidence WHERE rowid IN (
|
|
112
|
+
SELECT rowid FROM file_evidence ORDER BY last_accessed_at ASC, rowid ASC LIMIT ?
|
|
113
|
+
)`).run(u),r.pragma("wal_checkpoint(TRUNCATE)")),{deletedRows:u,remainingRows:n-u}}catch(n){return Pe("shared cache maintenance skipped",n),null}finally{try{r?.close()}catch{}}}function oo(e,t,r,n){let i=ut(e);if(!i)return null;try{let o=i.readFileEvidence.get(t,r,n,re)??i.readLegacyFileEvidence.get(t,r,n);if(o?.payload!==void 0)return o.payload;if(!on.has(t)||!i.shared)return null;try{let s=i.shared.readFileEvidence.get(t,r,n,re);return s?.payload!==void 0&&Hc(i.shared,t,r,n),s?.payload??null}catch(s){return sn(i,"file_evidence read",s),null}}catch(o){return pt(e,"file_evidence read",o),null}}function Hc(e,t,r,n){let i=Date.now();try{e.touchFileEvidence.run(i,t,r,n,re,i-Bc)}catch(o){Pe("shared file_evidence recency touch skipped",o)}}function so(e,t,r,n,i){let o=ut(e);if(o)try{if(o.writeFileEvidence.run(t,r,n,re,i),on.has(t)&&o.shared)try{o.shared.writeFileEvidence.run(t,r,n,re,i,Date.now())}catch(s){sn(o,"file_evidence write",s)}}catch(s){pt(e,"file_evidence write",s)}}function ao(e,t){if(t.length===0)return;let r=ut(e);if(r)try{r.evidence.transaction(()=>{for(let i of t)r.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,re,i.payload)})();let n=t.filter(i=>on.has(i.kind));if(n.length>0&&r.shared)try{r.shared.evidence.transaction(()=>{for(let i of n)r.shared.writeFileEvidence.run(i.kind,i.relativePath,i.contentHash,re,i.payload,Date.now())})()}catch(i){sn(r,"file_evidence batch write",i)}}catch(n){pt(e,"file_evidence batch write",n)}}function co(e,t,r,n){let i=ut(e);if(!i)return null;try{return(i.readProjectEvidence.get(t,r,n,re)??i.readLegacyProjectEvidence.get(t,r,n))?.payload??null}catch(o){return pt(e,"project_evidence read",o),null}}function lo(e,t,r,n,i){let o=ut(e);if(o)try{o.writeProjectEvidence.run(t,r,n,re,i)}catch(s){pt(e,"project_evidence write",s)}}function an(e){return typeof e=="object"&&e!==null}function rg(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")?e:null}import{execFileSync as zc}from"child_process";import{existsSync as Kc,readdirSync as po}from"fs";import{extname as fo,join as mo}from"path";var go=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Xc=[{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 ag(e){let t=[],r=Yc(e),n=el(e);for(let i of Xc){if(Jc(e,i.files)){t.push(i.language);continue}if(Qc(r,i.globs)){t.push(i.language);continue}rl(n,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&uo(t,"javascript"),t.includes("cpp")&&!n.has(".c")&&uo(t,"c"),t}function Yc(e){try{return po(e)}catch{return[]}}function Jc(e,t){return t?.length?t.some(r=>Kc(mo(e,r))):!1}function Qc(e,t){return t?.length?e.some(r=>t.some(n=>Zc(r,n))):!1}function Zc(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[r,n]=t.split("*");return e.startsWith(r??"")&&e.endsWith(n??"")}function el(e){let t=tl(e);if(t)return t;let r=new Set,n=[e];for(;n.length>0;){let i=n.pop();if(!i)continue;let o;try{o=po(i,{withFileTypes:!0})}catch{continue}for(let s of o){if(s.name.startsWith(".")&&!s.name.endsWith("proj")&&!s.name.endsWith("sln")&&s.isDirectory())continue;let a=mo(i,s.name);if(s.isDirectory()){go.has(s.name)||n.push(a);continue}let c=fo(s.name).toLowerCase();c&&r.add(c)}}return r}function tl(e){try{let t=zc("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}),r=new Set;for(let n of t.split(`
|
|
114
|
+
`)){if(!n||n.split("/").some(o=>go.has(o)))continue;let i=fo(n).toLowerCase();i&&r.add(i)}return r}catch{return null}}function rl(e,t){return t?.length?t.some(r=>e.has(r)):!1}function uo(e,t){let r=e.indexOf(t);r!==-1&&e.splice(r,1)}import{writeFileSync as nl}from"fs";import{create as yo}from"@bufbuild/protobuf";import{deserializeSCIP as il,DocumentSchema as ol,IndexSchema as sl,serializeSCIP as al,SymbolRole as cl}from"@c4312/scip";function mg(e){let t;try{t=il(w(e,{inputKind:"SCIP sanitization input",maxBytes:A}))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let r=cn(t);return r.removedDefinitionOccurrences>0&&nl(e,Buffer.from(al(r.index))),{removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function cn(e){let t=new Set;for(let o of e.documents){Ft(o.relativePath);for(let s of o.symbols)s.symbol&&t.add(s.symbol)}for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let r=0,n=0,i=[];for(let o of e.documents){let s=o.occurrences.filter(a=>(a.symbolRoles&cl.Definition)===0||t.has(a.symbol)?!0:(r+=1,!1));if(s.length===o.occurrences.length){i.push(o);continue}n+=1,i.push(yo(ol,{language:o.language,relativePath:o.relativePath,occurrences:s,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:r===0?e:yo(sl,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:r,touchedDocuments:n}}import{writeFileSync as ln}from"fs";import{create as ft}from"@bufbuild/protobuf";import{deserializeSCIP as dn,serializeSCIP as un,DocumentSchema as ll,IndexSchema as ho,MetadataSchema as dl,SymbolInformationSchema as ul}from"@c4312/scip";function So(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=fl(e),r=ml(e.flatMap(i=>i.documents??[])),n=xo(e.flatMap(i=>i.externalSymbols??[]));return ft(ho,{metadata:t,documents:r,externalSymbols:n})}function Ig(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>dn(w(i,{inputKind:"SCIP merge input",maxBytes:A}))),n=So(r);return ln(t,Buffer.from(un(n))),{documentCount:n.documents.length,externalSymbolCount:n.externalSymbols.length,inputCount:e.length}}function Eg(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let r=e.map(i=>dn(w(i,{inputKind:"SCIP merge input",maxBytes:A}))),n=cn(So(r));return ln(t,Buffer.from(un(n.index))),{documentCount:n.index.documents.length,externalSymbolCount:n.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function pl(e,t,r){let n=e.metadata;if(!n)throw new Error("Cannot rebase a SCIP index without metadata");if(n.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${n.projectRoot}`);return ft(ho,{metadata:ft(dl,{...n,projectRoot:r}),documents:e.documents,externalSymbols:e.externalSymbols})}function bo(e,t,r){let n=dn(w(e,{inputKind:"SCIP normalization input",maxBytes:A})),i=pl(n,t,r);ln(e,Buffer.from(un(i)))}function fl(e){let t=e[0]?.metadata;if(!t)return;let r=t.projectRoot;for(let n of e.slice(1)){let i=n.metadata?.projectRoot;if(r&&i&&i!==r)throw new Error(`Cannot merge SCIP indexes with different project roots: ${r} vs ${i}`)}return t}function ml(e){let t=new Map;for(let r of e){let n=t.get(r.relativePath);if(!n){t.set(r.relativePath,r);continue}t.set(r.relativePath,ft(ll,{language:n.language||r.language,relativePath:n.relativePath||r.relativePath,occurrences:gl([...n.occurrences,...r.occurrences]),symbols:xo([...n.symbols,...r.symbols]),text:hl(n.text,r.text),positionEncoding:n.positionEncoding||r.positionEncoding}))}return[...t.values()]}function gl(e){let t=new Set,r=[];for(let n of e){let i=JSON.stringify(n);t.has(i)||(t.add(i),r.push(n))}return r}function xo(e){let t=new Map;for(let r of e){let n=t.get(r.symbol);if(!n){t.set(r.symbol,r);continue}t.set(r.symbol,ft(ul,{symbol:n.symbol,documentation:Sl([...n.documentation,...r.documentation]),relationships:yl([...n.relationships,...r.relationships]),kind:n.kind||r.kind,displayName:n.displayName||r.displayName,enclosingSymbol:n.enclosingSymbol||r.enclosingSymbol,signatureDocumentation:n.signatureDocumentation??r.signatureDocumentation}))}return[...t.values()]}function yl(e){let t=new Set,r=[];for(let n of e){let i=[n.symbol,n.isReference?"1":"0",n.isImplementation?"1":"0",n.isTypeDefinition?"1":"0",n.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),r.push(n))}return r}function hl(e,t){return e?t?e.length>=t.length?e:t:e:t}function Sl(e){return[...new Set(e)]}import{createHash as Cl}from"crypto";import{existsSync as gt,mkdirSync as Pl,readdirSync as yn,renameSync as kl,rmSync as Oo,writeFileSync as Nl}from"fs";import{join as H}from"path";import{createHash as bl}from"crypto";import{existsSync as fn,mkdirSync as xl,readdirSync as wg,renameSync as Il,rmSync as Cg,writeFileSync as El}from"fs";import{join as Xe}from"path";import{create as Eo,fromBinary as vo,toBinary as vl}from"@bufbuild/protobuf";import{deserializeSCIP as tr,DocumentSchema as mn,IndexSchema as Ro,serializeSCIP as To}from"@c4312/scip";var rr=1,mt="typescript-scip-fragments";function Ag(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,r=[];for(let o of e){let s=ke(o.relativePath);if(t.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(t.add(s),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${s}`);let a=vo(mn,o.bytes);if(a.relativePath!==s)throw new Error(`TypeScript fragment path mismatch: expected ${s}, got ${a.relativePath}`);r.push(a)}let n=To(Eo(Ro,{documents:r,externalSymbols:[]})),i=tr(n);if(i.documents.length!==r.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return n}function nr(e){let t=Xe(e,mt);return{rootDir:t,blobDir:Xe(t,"blobs"),generationDir:Xe(t,"generations")}}function Rl(e){let t=tr(e.indexBytes);Lo(t.metadata,Fo(e)),Ao(t.externalSymbols);let r=new Set,n=[];for(let o of t.documents){let s=ke(o.relativePath);if(r.has(s))throw new Error(`duplicate TypeScript SCIP document path: ${s}`);r.add(s);let a=vl(mn,o),c=e.documentIdentities.get(s)??(e.allowUntrackedDocuments?Ne(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:s,contentHash:Ne(a)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${s}`);n.push(ko(e.cacheDir,{relativePath:s,bytes:a,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=No(e,n);return _o(e.cacheDir,i),i}function Lg(e){let t=nr(e.cacheDir);if(!fn(gn(t,e.generationIdentity)))return Rl(e);let r=wo({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&r.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let n of r.manifest.documents){let i=e.documentIdentities.get(n.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==n.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${n.relativePath}`)}return r.manifest}function Fg(e){let t=wo({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,r=new Map(t.documents.map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=ke(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript fragment replacement: ${s}`);if(n.add(s),!r.has(s))throw new Error(`TypeScript fragment replacement has no prior document: ${s}`);let a=e.documentIdentities.get(s);if(!a)throw new Error(`missing TypeScript document identity: ${s}`);o.bytes===null?r.delete(s):r.set(s,ko(e.cacheDir,o,a))}if(n.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=No(e,[...r.values()]);return _o(e.cacheDir,i),i}function wo(e){let t=nr(e.cacheDir),r=gn(t,e.generationIdentity),n;try{n=Do(X(r,{maxBytes:K,inputKind:"TypeScript fragment manifest"}))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(n.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&n.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&n.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of n.documents){let s=Xe(t.blobDir,`${o.blobHash}.scipdoc`),a=w(s,{maxBytes:Be,inputKind:"TypeScript fragment blob"});if(a.byteLength!==o.byteLength||Ne(a)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,a)}return{manifest:n,fragments:i}}function Co(e){let t=Po(e);return pn(t.baseIndex,t.completeDocuments,"assembled")}function Og(e){let t=Po(e);return Tl(t.deletedAffectedPaths),{completeIndexBytes:pn(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:pn(t.baseIndex,t.affectedDocuments,"affected")}}function Po(e){let t=tr(e.baseIndexBytes);Lo(t.metadata,Fo(e)),Ao(t.externalSymbols);let r=new Map;for(let a of e.fragments){let c=ke(a.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);r.set(c,a)}if(r.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let n=new Set,i=[],o=[],s=[];for(let a of t.documents){let c=ke(a.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);n.add(c);let l=r.get(c);if(!l){i.push(a);continue}if(r.delete(c),l.bytes===null){s.push(c);continue}let d=vo(mn,l.bytes);if(d.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${d.relativePath}`);i.push(d),o.push(d)}if(r.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...r.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:s}}function pn(e,t,r){let n=To(Eo(Ro,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=tr(n);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${r} TypeScript SCIP index failed structural verification`);return n}function Tl(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function ko(e,t,r){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let n=ke(t.relativePath),i=Buffer.from(t.bytes),o=Ne(i),s=nr(e);xl(s.blobDir,{recursive:!0});let a=Xe(s.blobDir,`${o}.scipdoc`);if(fn(a)){let c=w(a,{maxBytes:Be,inputKind:"TypeScript fragment blob"});if(c.byteLength!==i.byteLength||Ne(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${n}`)}else{let c=`${a}.${process.pid}.${Date.now()}.tmp`;El(c,i),Il(c,a)}return{relativePath:n,blobHash:o,byteLength:i.byteLength,documentIdentity:r}}function No(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let r=[...t].sort((n,i)=>n.relativePath.localeCompare(i.relativePath));if(new Set(r.map(n=>n.relativePath)).size!==r.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:rr,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:r}}function _o(e,t){let r=nr(e),n=gn(r,t.generationIdentity);if(fn(n)){let i=Do(X(n,{maxBytes:K,inputKind:"TypeScript fragment manifest"}));if(Io(i)!==Io(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}de(n,t,{spacing:2,trailingNewline:!0})}function Io(e){return Ne(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function Do(e){let t=JSON.parse(e);if(t.version!==rr||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let r=new Set;for(let n of t.documents){if(!n||typeof n.relativePath!="string"||typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash)||typeof n.byteLength!="number"||!Number.isInteger(n.byteLength)||n.byteLength<0||typeof n.documentIdentity!="string"||!n.documentIdentity)throw new Error("invalid TypeScript fragment record");if(ke(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript fragment record");r.add(n.relativePath)}return t}function gn(e,t){return Xe(e.generationDir,wl(t))}function wl(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${Ne(e)}.json`}function Ao(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Lo(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let r=e,n=r.toolInfo??r.tool_info;if(!n||typeof n!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=n;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Fo(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function ke(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 Ne(e){return bl("sha256").update(e).digest("hex")}var ir=1,Ug=64*1024*1024,ht="typescript-scip-overlays";function Wg(e){let t=Mo(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let r=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),n=new Set;for(let o of e.fragments){let s=bn(o.relativePath);if(n.has(s))throw new Error(`duplicate TypeScript overlay: ${s}`);n.add(s),r.set(s,_l(e.cacheDir,o))}if(n.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:ir,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...r.values()].sort((o,s)=>o.relativePath.localeCompare(s.relativePath))};return Dl(e.cacheDir,i),i}function Hg(e){let t=Mo(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let r=t.overlays.map(n=>{if(n.blobHash===null)return{relativePath:n.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=w(H(St(e.cacheDir),"blobs",`${n.blobHash}.scipdoc`),{maxBytes:Be,inputKind:"TypeScript overlay blob"});if(i.byteLength!==n.byteLength||yt(i)!==n.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${n.relativePath}`);return{relativePath:n.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Co({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:r})}function zg(e,t){let r=St(e),n=H(r,"generations");if(!gt(n))return;let i=new Set(t.map(Sn)),o=new Set;for(let a of yn(n).filter(c=>i.has(c))){let c=hn(X(H(n,a),{maxBytes:K,inputKind:"TypeScript overlay manifest"}));for(let l of c.overlays)l.blobHash&&o.add(`${l.blobHash}.scipdoc`)}for(let a of yn(n))i.has(a)||Oo(H(n,a),{force:!0});let s=H(r,"blobs");if(gt(s))for(let a of yn(s))o.has(a)||Oo(H(s,a),{force:!0})}function Mo(e,t){let r=H(St(e),"generations",Sn(t));if(!gt(r))return null;let n=hn(X(r,{maxBytes:K,inputKind:"TypeScript overlay manifest"}));if(n.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return n}function _l(e,t){let r=bn(t.relativePath);if(t.bytes===null)return{relativePath:r,blobHash:null,byteLength:0};let n=Buffer.from(t.bytes),i=yt(n),o=H(St(e),"blobs");Pl(o,{recursive:!0});let s=H(o,`${i}.scipdoc`);if(gt(s)){let a=w(s,{maxBytes:Be,inputKind:"TypeScript overlay blob"});if(a.byteLength!==n.byteLength||yt(a)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${r}`)}else{let a=`${s}.${process.pid}.${Date.now()}.tmp`;Nl(a,n),kl(a,s)}return{relativePath:r,blobHash:i,byteLength:n.byteLength}}function Dl(e,t){let r=H(St(e),"generations",Sn(t.generationIdentity));if(gt(r)){let n=hn(X(r,{maxBytes:K,inputKind:"TypeScript overlay manifest"}));if(jo(n)!==jo(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}de(r,t,{spacing:2,trailingNewline:!0})}function hn(e){let t=JSON.parse(e);if(t.version!==ir||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let r=new Set;for(let n of t.overlays){if(!n||typeof n.relativePath!="string"||n.blobHash!==null&&(typeof n.blobHash!="string"||!/^[a-f0-9]{64}$/.test(n.blobHash))||!Number.isInteger(n.byteLength)||n.byteLength<0||n.blobHash===null&&n.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(bn(n.relativePath),r.has(n.relativePath))throw new Error("duplicate TypeScript overlay record");r.add(n.relativePath)}return t}function St(e){return H(e,ht)}function Sn(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${yt(e)}.json`}function jo(e){return yt(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function bn(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function yt(e){return Cl("sha256").update(e).digest("hex")}import{createHash as Rn}from"crypto";import{closeSync as Al,existsSync as S,mkdirSync as Ll,openSync as Fl,readSync as Ol,readdirSync as Tn,renameSync as vn,rmSync as bt,statSync as Ye}from"fs";import{basename as Bo,dirname as Z,join as y,relative as Go}from"path";var jl=Object.freeze({maxGenerations:8,maxLogicalBytes:2*1024*1024*1024});function Vo(e){let t=v(e.outputDb),r=Bl(e);e.onStage?.("after-recovery-retained");let n=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Pn({generationRoot:t,databasePath:e.tempOutputDb,indexPath:S(n)?n:void 0,metadataPath:S(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),s={version:Te,currentGeneration:i.identity,artifactSet:"immutable-v1",...r?{previousGeneration:r}:{},...e.publication?{publication:e.publication}:{},publishedAt:o},a=Y(y(t,"state.json"),s,{spacing:2,trailingNewline:!0});e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||En(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),En(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),En(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let c=i.identity,l={...s,stableMirrors:Cn(e.outputDb,e.outputScip)};Y(y(t,"state.json"),l,{spacing:2,trailingNewline:!0});let d=Uo(e.outputDb,{now:e.now}),u=le(i.directorySync,a.directorySync);return{currentGeneration:c,...r?{previousGeneration:r}:{},retention:d,achievedDurability:u==="synced"?"directory-durable":"file-flushed",directorySync:u}}function Ml(e,t,r,n=()=>new Date){if(!S(e))return null;let i=we(e),o=y(v(e),"state.json");if(i?.artifactSet==="immutable-v1"&&Qt(e,i.currentGeneration))return i;let s=v(e),a=!i&&S(o)?Ul(r,e,t):void 0;if(a&&!lt(s,a))return null;let c=Pn({generationRoot:s,databasePath:e,indexPath:S(t)?t:void 0,metadataPath:S(r)?r:void 0,forcedIdentity:i?.currentGeneration??a}),l={version:Te,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:Cn(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??n().toISOString()};return Y(y(s,"state.json"),l,{spacing:2,trailingNewline:!0}),l}function oy(e,t,r=()=>new Date){if(!S(e)||!S(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let n=we(e),i=v(e),o=Pn({generationRoot:i,databasePath:e,indexPath:S(y(Z(e),"index.scip"))?y(Z(e),"index.scip"):void 0,metadataPath:t}),s=n&&n.currentGeneration!==o.identity?Ho(e,n.currentGeneration):void 0,a={version:Te,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:Cn(e,y(Z(e),"index.scip")),...s?{previousGeneration:s}:{},...n?.publication?{publication:n.publication}:{},publishedAt:r().toISOString()};return Y(y(v(e),"state.json"),a,{spacing:2,trailingNewline:!0}),Uo(e,{now:r}),a}function Uo(e,t={}){let r=Gl(t.limits),i=(t.now??(()=>new Date))().toISOString(),o=Re(rn(e),{waitMs:0});if(!o)return{state:"deferred",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:"another process owns local generation retention"};try{let s=we(e),a=$l(e),c=to(e,a.map(b=>b.identity),{isProcessAlive:t.isProcessAlive??jt,readProcessIdentity:t.readProcessIdentity??Ot}),l=new Set(c.protectedGenerations);s?.currentGeneration&&l.add(s.currentGeneration),s?.previousGeneration?.generationIdentity&&l.add(s.previousGeneration.generationIdentity);let d=a.length,u=a.reduce((b,it)=>b+it.logicalBytes,0),p=0,m=0;for(let b of a){if(d<=r.maxGenerations&&u<=r.maxLogicalBytes)break;l.has(b.identity)||(t.onBeforeRemove?.(b.identity),bt(b.path,{recursive:!0,force:!0}),d-=1,u-=b.logicalBytes,p+=1,m+=b.logicalBytes)}let g=d>r.maxGenerations||u>r.maxLogicalBytes,T={state:g?"protected":p>0?"collected":"within-bounds",generationCount:d,logicalBytes:u,protectedGenerations:l.size,activeReaderLeases:c.activeLeases,staleReaderLeasesRemoved:c.staleLeasesRemoved,malformedReaderLeases:c.malformedLeases,removedGenerations:p,removedLogicalBytes:m,limits:r,at:i,...g?{reason:c.malformedLeases>0?"malformed reader ownership evidence fails closed":"retention bounds cannot be met without deleting a protected generation"}:{}};return $o(e,T),T}catch(s){let a={state:"error",generationCount:0,logicalBytes:0,protectedGenerations:0,activeReaderLeases:0,staleReaderLeasesRemoved:0,malformedReaderLeases:0,removedGenerations:0,removedLogicalBytes:0,limits:r,at:i,reason:s instanceof Error?s.message:String(s)};try{$o(e,a)}catch{}return a}finally{o.release()}}function Gl(e={}){let t={...jl,...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 $l(e){let t=v(e);return S(t)?Tn(t,{withFileTypes:!0}).filter(r=>r.isDirectory()&&/^[a-f0-9]{64}$/.test(r.name)).map(r=>{let n=y(t,r.name),i=lt(t,r.name),o=i?i.database.size+(i.index?.size??0)+(i.metadata?.size??0):Wo(n);return{identity:r.name,path:n,logicalBytes:o,modifiedAtMs:Ye(n).mtimeMs}}).sort((r,n)=>r.modifiedAtMs-n.modifiedAtMs||r.identity.localeCompare(n.identity)):[]}function Wo(e){let t=0;for(let r of Tn(e,{withFileTypes:!0})){let n=y(e,r.name);r.isDirectory()?t+=Wo(n):r.isFile()&&(t+=Ye(n).size)}return t}function $o(e,t){de(y(v(e),"gc.json"),t,{spacing:2,trailingNewline:!0})}function wn(e,t=y(Z(e),"meta.json")){let r=y(v(e),"state.json");if(!S(r))return{state:"legacy",statePath:r};let n=we(e);if(!n)return{state:"invalid",statePath:r,reason:"generation state is malformed"};try{let i=Qt(e,n.currentGeneration),o=i!==null,s=i?ql(e,t,i,n):!1,a=n.previousGeneration?S(y(Z(e),n.previousGeneration.databasePath)):!0;return!s||!o||!a?{state:"drifted",statePath:r,currentMatches:s,recoveryExists:a,generation:n,reason:o?s?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:r,currentMatches:s,recoveryExists:a,generation:n}}catch(i){return{state:"drifted",statePath:r,currentMatches:!1,recoveryExists:!1,generation:n,reason:i instanceof Error?i.message:String(i)}}}function ql(e,t,r,n){if(n.stableMirrors&&(n.stableMirrors.databaseFileIdentity!==Ce(e)||n.stableMirrors.indexFileIdentity!==void 0&&n.stableMirrors.indexFileIdentity!==Ce(y(Z(e),"index.scip")))||!qo(e,r.database))return!1;let i=y(Z(e),"index.scip");if(r.index&&!qo(i,r.index))return!1;if(!r.metadata)return!S(t);if(!S(t))return!1;let o=y(v(e),r.identity,r.metadata.file);return S(o)&&pe(h(t,"reindex metadata"))===pe(h(o,"immutable reindex metadata"))}function qo(e,t){return S(e)&&Ye(e).isFile()&&Ye(e).size===t.size}function Bl(e){let t=Ml(e.outputDb,e.outputScip,e.metaPath);return t?Ho(e.outputDb,t.currentGeneration):void 0}function Cn(e,t){return{databaseFileIdentity:Ce(e),...S(t)?{indexFileIdentity:Ce(t)}:{}}}function Ho(e,t){let r=y(v(e),t),n=y(r,Bo(e)),i=y(r,"meta.json");return{generationIdentity:t,databasePath:Go(Z(e),n),...S(i)?{metadataPath:Go(Z(e),i)}:{}}}function Vl(e){if(S(e))for(let t of Tn(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&bt(y(e,t.name),{recursive:!0,force:!0})}function Ul(e,t,r=y(Z(t),"index.scip")){let n=Rn("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(or(t)),S(r)&&n.update(`\0${or(r)}`),S(e)&&n.update(`\0${pe(h(e,"reindex metadata"))}`),n.digest("hex")}function Pn(e){let t=xn(e.databasePath),r=e.indexPath?xn(e.indexPath):void 0,n=e.metadataPath?xn(e.metadataPath):void 0,i=e.forcedIdentity??Wl(t,r,e.metadataPath),o=y(e.generationRoot,i),s=y(o,Jt);if(S(s)){let l=lt(e.generationRoot,i);if(l&&zo(o,l.database,t)&&zl(o,l.index,r)&&Kl(o,l.metadata,e.metadataPath))return{identity:i,directorySync:W(e.generationRoot)};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}let a=[Ue(e.generationRoot)];Vl(e.generationRoot);let c=`${o}.${process.pid}.${Date.now()}.tmp`;bt(c,{recursive:!0,force:!0}),Ll(c,{recursive:!0});try{a.push(In(e.databasePath,y(c,t.file))),r&&e.indexPath&&a.push(In(e.indexPath,y(c,r.file))),n&&e.metadataPath&&a.push(In(e.metadataPath,y(c,n.file)));let l=Y(y(c,Jt),{version:tn,identity:i,database:t,...r?{index:r}:{},...n?{metadata:n}:{}},{spacing:2,trailingNewline:!0});l.directorySync!=="not-requested"&&a.push(l.directorySync),a.push(W(c)),vn(c,o),a.push(W(e.generationRoot))}finally{bt(c,{recursive:!0,force:!0})}return{identity:i,directorySync:le(...a)}}function Wl(e,t,r){let n=Rn("sha256").update("sqlite-generation-artifacts-v1\0");return n.update(e.sha256),t&&n.update(`\0${t.sha256}`),r&&n.update(`\0${pe(h(r,"reindex metadata"))}`),n.digest("hex")}function xn(e){return{file:Bo(e),size:Ye(e).size,sha256:or(e)}}function or(e){let t=Rn("sha256"),r=Fl(e,"r"),n=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Hl(r,n);if(i===0)break;t.update(n.subarray(0,i))}}finally{Al(r)}return t.digest("hex")}function Hl(e,t){let r=0;for(;r<t.length;){let n=Ol(e,t,r,t.length-r,null);if(r+=n,n===0)break}return r}function In(e,t){return Gt(e,t,{mode:292})}function zo(e,t,r){let n=y(e,t.file);return t.file===r.file&&t.size===r.size&&t.sha256===r.sha256&&S(n)&&Ye(n).size===t.size&&or(n)===t.sha256}function zl(e,t,r){return!t||!r?t===r:zo(e,t,r)}function Kl(e,t,r){if(!t||!r)return t===void 0&&r===void 0;let n=y(e,t.file);return S(n)&&pe(h(n,"stored reindex metadata"))===pe(h(r,"candidate reindex metadata"))}function En(e,t){bt(`${t}.tmp-replace`,{force:!0}),vn(e,`${t}.tmp-replace`),vn(`${t}.tmp-replace`,t)}import{createHash as ts,randomUUID as td}from"crypto";import{existsSync as me,lstatSync as rd,mkdirSync as Je,mkdtempSync as rs,readdirSync as nd,realpathSync as id,renameSync as _e,rmSync as fe,statSync as cr}from"fs";import{dirname as _n,join as f,resolve as Dn}from"path";import{setTimeout as od}from"timers/promises";import{pathToFileURL as Jo}from"url";import{deserializeSCIP as ns}from"@c4312/scip";import sd from"better-sqlite3";import{lstatSync as Xl,readdirSync as Yl}from"fs";import{join as Jl,relative as Ql,resolve as kn,sep as Zl}from"path";var xt=1,Nn="language-indexes",Ko=["index.db","index.scip","meta.json"],Xo=[Nn,mt,ht];function sr(e){let t=[];for(let r of Ko)ed(e,r),t.push(r);for(let r of Xo)Yo(e,r,t);return{version:xt,files:t.sort()}}function ar(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(n=>!n||n==="."||n===".."))throw new Error(`invalid index artifact path: ${e}`);let r=t[0];if(!Ko.includes(e)&&!Xo.includes(r))throw new Error(`index artifact path is not shareable: ${e}`);return e}function ee(e,t){let r=ar(t),n=kn(e),i=kn(n,...r.split("/"));if(i!==n&&!i.startsWith(`${n}${Zl}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Yo(e,t,r){let n=Jl(e,t),i;try{i=Yl(n,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let s=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${s}`);o.isDirectory()?Yo(e,s,r):o.isFile()&&r.push(ar(s))}}function ed(e,t){let r=ee(e,t),n;try{n=Xl(r)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!n.isFile()||n.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(Ql(kn(e),r).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}var Ln=1,Qo="SCIP_QUERY_SHARED_CACHE",An=JSON.stringify({cliVersion:qt,artifactCatalogVersion:xt,sqliteGenerationStoreVersion:Te,typescriptFragmentStoreVersion:rr,typescriptOverlayStoreVersion:ir}),is="manifest.json",ad="shared-cache.json",Fn=[Nn,mt,ht];function Ly(e,t){if(!e.clean||!e.treeOid)return;let r=as(JSON.stringify({version:Ln,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:An}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:An,generationId:r,repositoryCacheDir:Ur(e.repositoryId)}}function Fy(e,t,r){if(process.env[Qo]==="0")return`${Qo}=0`;if(!Wr(r))return"explicit cache or database override";if(zr(_n(t))!==zr(Vr(e))||t!==f(_n(t),"index.db"))return"index database is outside the managed worktree cache"}function Oy(e,t,r){if(!Wr(t))return;let n=r??zi(e);return n?f(Ur(n.repositoryId),"evidence.db"):void 0}function Et(e,t=!0){let r=On(e),n;try{n=dd(X(f(r,is),{inputKind:"shared-generation manifest",maxBytes:K}))}catch{return null}if(n.generationId!==e.generationId||n.repositoryId!==e.repositoryId||n.treeOid!==e.treeOid||n.producerIdentity!==e.producerIdentity||JSON.stringify(n.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return n;try{for(let i of n.artifacts){let o=ee(r,i.path),s=cr(o);if(!s.isFile()||s.size!==i.size||Ve(o,{inputKind:"shared-generation artifact",maxBytes:A})!==i.sha256)return null}}catch{return null}return n}function jy(e){let t=Et(e.snapshot);if(t)return Zo(e.snapshot,t);if(!ss(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let r=es(e.sourceCacheDir);if(!r)throw new Error("source index artifacts are incomplete");let n=sr(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations"),o=[Ue(i)],s=rs(f(i,`.tmp-${process.pid}-`));try{let a=[];for(let g of n.files){let T=ee(e.sourceCacheDir,g),b=ee(s,g);o.push(vt(T,b,292)),e.onPublicationStage?.("after-artifact-flushed",g);let it=cr(b).size;a.push({path:g,size:it,sha256:Ve(b,{inputKind:"staged shared-generation artifact",maxBytes:A})})}let c=ns(w(f(s,"index.scip"),{inputKind:"staged shared SCIP index",maxBytes:A})).metadata?.projectRoot;if(!c)throw new Error("shared SCIP generation has no project root metadata");let l=jn(e.sourceProjectRoot);if(c!==l)throw new Error("shared SCIP generation root does not match its source worktree");if(es(e.sourceCacheDir)!==r||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let d={version:Ln,artifactCatalogVersion:xt,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:a.sort((g,T)=>g.path.localeCompare(T.path))},u=Y(f(s,is),d,{spacing:2,trailingNewline:!0});u.directorySync!=="not-requested"&&o.push(u.directorySync),e.onPublicationStage?.("after-manifest-flushed"),o.push(W(s)),e.onPublicationStage?.("after-staging-directory-synced");let p=On(e.snapshot);try{if(me(p)&&!Et(e.snapshot)){let g=`${p}.corrupt-${process.pid}-${Date.now()}`;_e(p,g),fe(g,{recursive:!0,force:!0})}_e(s,p)}catch(g){let T=Et(e.snapshot);if(T)return Zo(e.snapshot,T);throw g}e.onPublicationStage?.("after-generation-renamed"),o.push(W(i)),e.onPublicationStage?.("after-generations-directory-synced");let m=le(...o);return{kind:"published",manifest:d,achievedDurability:m==="synced"?"directory-durable":"file-flushed",directorySync:m}}finally{fe(s,{recursive:!0,force:!0})}}function Zo(e,t){let r=W(f(e.repositoryCacheDir,"generations"));return{kind:"existing",manifest:t,achievedDurability:r==="synced"?"directory-durable":"file-flushed",directorySync:r}}function My(e){let t=On(e.snapshot);Je(e.targetCacheDir,{recursive:!0});let r=Re(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!r)throw new Error("timed out waiting for another cache hydration");let n,i,o=!1;try{n=rs(f(e.targetCacheDir,".shared-hydrate-")),hd(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let l=ee(t,c.path),d=ee(n,c.path);if(vt(l,d),cr(d).size!==c.size||Ve(d,{inputKind:"hydrated shared-generation artifact",maxBytes:A})!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let s=jn(e.targetProjectRoot);if(s!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&bo(ee(n,c.path),e.manifest.scipProjectRoot,s);if(!ss(n,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=md(e.targetCacheDir,n),o=!0,gd(n,e.targetCacheDir,i),Vo({tempOutputScip:f(n,"index.scip"),tempOutputDb:f(n,"index.db"),tempMetaPath:f(n,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let a=wn(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(a.state==="invalid"||a.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${a.reason}`);cd(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(s){throw o&&i&&yd(e.targetCacheDir,i),s}finally{n&&fe(n,{recursive:!0,force:!0}),r.release()}}async function Gy(e,t={}){let r=t.timeoutMs??3e4,n=t.pollMs??100,i=t.now??Lt,o=i()+r,s=f(e.repositoryCacheDir,"locks"),a=f(s,`${e.generationId}.lock`),c=l=>{if(!l||typeof l!="object"||Array.isArray(l))return null;let d=l.pid;return typeof d=="number"&&Number.isSafeInteger(d)&&d>0?{pid:d}:null};for(;i()<=o;){if(Et(e))return{kind:"generation-ready"};let l=Mt(a,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(l.kind==="acquired")return{kind:"owner",release:()=>l.lock.release()};let d=o-i();if(d<=0)break;await od(Math.min(n,d))}return Et(e)?{kind:"generation-ready"}:{kind:"timeout"}}function cd(e,t,r,n=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:r,lastSeenAt:(n??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:ld(i)};return fd(e.repositoryCacheDir,o,!0),o}function ld(e){return as(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Dn(e.projectRoot),localCacheDir:Dn(e.localCacheDir)}))}function dd(e){let t=JSON.parse(e);if(t.version!==Ln||t.artifactCatalogVersion!==xt||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==An||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let r=new Set;for(let n of t.artifacts){if(!n||typeof n.path!="string"||typeof n.size!="number"||n.size<0||typeof n.sha256!="string"||!/^[a-f0-9]{64}$/.test(n.sha256))throw new Error("invalid shared generation artifact");if(ar(n.path),r.has(n.path))throw new Error(`duplicate shared generation artifact: ${n.path}`);r.add(n.path)}for(let n of["index.db","index.scip","meta.json"])if(!r.has(n))throw new Error(`shared generation is missing ${n}`);return t}function vt(e,t,r=384){return Gt(e,t,{mode:r})}function ud(e,t,r){Je(e,{recursive:!0}),Y(f(e,ad),{version:1,repositoryId:t,worktreeId:r},{spacing:2,trailingNewline:!0})}function es(e){try{let t=sr(e),r=ts("sha256");for(let n of t.files){let i=ee(e,n),o=cr(i).size;r.update(n).update("\0").update(String(o)).update("\0"),Si(i,{inputKind:"source-generation artifact",maxBytes:A},s=>r.update(s)),r.update("\0")}return r.digest("hex")}catch{return null}}function pd(e){try{let t=ue(X(f(e,"meta.json"),{inputKind:"reindex metadata",maxBytes:K}));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function On(e){return f(e.repositoryCacheDir,"generations",e.generationId)}function fd(e,t,r){let n=Xi(e,{waitMs:5e3});if(!n)throw new Error("repository cache cleanup is busy");try{if(r){let o=t.activeGenerationId;if(!o||!me(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");Je(i,{recursive:!0}),Y(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),ud(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{n.release()}}function md(e,t){let r=f(t,".rollback"),n=new Map,i=new Map;Je(r,{recursive:!0});for(let a of["index.scip","index.db","meta.json"]){let c=f(e,a),l=me(c);n.set(a,l),l&&vt(c,f(r,"stable",a))}for(let a of Fn){let c=f(e,a),l=me(c);if(l){let d=rd(c);if(!d.isDirectory()||d.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${a}`)}i.set(a,l)}let o=f(e,ct),s=me(o);return s&&os(o,f(r,"sqlite-generations")),{root:r,stableFiles:n,managedDirectories:i,generationStoreExisted:s}}function gd(e,t,r){for(let n of Fn){let i=f(t,n);if(r.managedDirectories.get(n)){let s=f(r.root,"managed",n);Je(_n(s),{recursive:!0}),_e(i,s)}let o=f(e,n);me(o)&&_e(o,i)}}function yd(e,t){for(let i of Fn){let o=f(e,i),s=f(t.root,"managed",i);t.managedDirectories.get(i)?me(s)&&(fe(o,{recursive:!0,force:!0}),_e(s,o)):fe(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let s=f(e,i);if(!o){fe(s,{force:!0});continue}let a=`${s}.shared-restore-${td()}`;vt(f(t.root,"stable",i),a),fe(s,{force:!0}),_e(a,s)}let r=f(e,ct);fe(r,{recursive:!0,force:!0});let n=f(t.root,"sqlite-generations");t.generationStoreExisted&&me(n)&&_e(n,r)}function os(e,t){Je(t,{recursive:!0});for(let r of nd(e,{withFileTypes:!0})){let n=f(e,r.name),i=f(t,r.name);if(r.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${n}`);r.isDirectory()?os(n,i):r.isFile()&&vt(n,i)}}function hd(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function ss(e,t,r,n=!0,i=!0){try{let o=pd(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(r)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...r.languages].sort()))return It("source validation rejected metadata"),!1;let s=sr(e),a=wn(f(e,"index.db"),f(e,"meta.json"));if(n?a.state!=="current":a.state==="invalid"||a.state==="drifted")return It(`source validation rejected SQLite generation state ${a.state}`),!1;let c=new sd(f(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let l=jn(t),u=(i?s.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let m=ns(w(ee(e,p),{inputKind:"shared SCIP validation artifact",maxBytes:A})).metadata?.projectRoot;return m!==l&&It(`source validation rejected SCIP root for ${p}: ${String(m)}`),m===l});return u||It("source validation rejected SCIP project roots"),u}catch(o){return It(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function It(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function jn(e){try{return Jo(id(e)).href}catch{return Jo(Dn(e)).href}}function as(e){return ts("sha256").update(e).digest("hex")}import{createRequire as Sd}from"module";import{dirname as qn,isAbsolute as bd,relative as us,resolve as ye,sep as Mn}from"path";var ge=Sd(import.meta.url),xd=1,cs="0.4.0";function Id(){try{let e=ps();if(!e.available)return e;let{packageRoot:t}=e,r=ge.resolve("typescript",{paths:[t]}),n=ge(r),{FileIndexer:i}=ge(ye(t,"dist/src/FileIndexer.js")),{Input:o}=ge(ye(t,"dist/src/Input.js")),{Packages:s}=ge(ye(t,"dist/src/Packages.js")),a=ge(ye(t,"dist/src/scip.js"));if(!i||!o||!s||!a.scip?.Document||!a.scip.Index)return{available:!1,reason:"scip-typescript document runtime has an unsupported module shape"};let c={packageVersion:e.packageVersion,typescript:n,Document:a.scip.Document,Index:a.scip.Index,FileIndexer:i,Input:o,Packages:s};return{available:!0,runtime:c,producerIdentity:Bn(c)}}catch(e){return{available:!1,reason:`scip-typescript document runtime unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Uy(){let e=ps();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function ps(){try{let e=ge.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(h(e,"scip-typescript package manifest"));if(t.version!==cs)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${cs}`};let r=qn(e),n=ge.resolve("typescript/package.json",{paths:[r]}),i=JSON.parse(h(n,"TypeScript package manifest"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:r,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:fs(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Wy(e){let t=e.runtime===void 0?Id():e.runtime===null?{available:!1,reason:"scip-typescript document runtime unavailable"}:{available:!0,runtime:e.runtime,producerIdentity:Bn(e.runtime)};return t.available?{available:!0,emitter:new Gn(e,t.runtime)}:t}var Gn=class{producerIdentity;workspaceRoot;tsconfigPath;projectRoot;maxFileByteSize;runtime;host;config=null;includedFiles=new Set;program=null;checker=null;symbolTable=new Map;constructorTable=new Map;packages;fragments=new Map;stats={initializations:0,programUpdates:0,documentsEmitted:0,documentsRemoved:0,sourceNodesReused:0,sourceNodesReplaced:0,symbolEntriesPruned:0};constructor(t,r){this.workspaceRoot=ye(t.workspaceRoot),this.tsconfigPath=ye(this.workspaceRoot,t.tsconfigPath),this.projectRoot=t.projectRoot??vd(this.workspaceRoot,qn(this.tsconfigPath)),this.maxFileByteSize=t.maxFileByteSize??1024*1024,this.runtime=r,this.producerIdentity=Bn(r);let n=ls(r.typescript,this.tsconfigPath);this.config=n,this.host=new $n(r.typescript,n.options,this.workspaceRoot),this.packages=new r.Packages(this.projectRoot)}initialize(){let t=performance.now(),r=this.config??ls(this.runtime.typescript,this.tsconfigPath);this.includedFiles=new Set(r.fileNames.map(Qe)),this.program=this.runtime.typescript.createProgram(r.fileNames,r.options,this.host.compilerHost),this.checker=this.program.getTypeChecker(),this.stats.initializations+=1;let n=[];for(let i of this.program.getSourceFiles())this.includedFiles.has(Qe(i.fileName))&&n.push(this.emitSourceFile(i));return this.result(n,t)}advance(t){if(!this.program||!this.checker||!this.config)return this.initializeAndAdvance(t);let r=performance.now(),n=lr(t.modifiedFiles),i=lr(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=this.program,s=new Map;for(let c of n){let l=Rt(this.workspaceRoot,c),d=o.getSourceFile(l);if(!d)throw new Error(`modified TypeScript source is unavailable: ${c}`);s.set(c,d),this.stats.symbolEntriesPruned+=ds(this.symbolTable,d),this.stats.symbolEntriesPruned+=ds(this.constructorTable,d),this.host.invalidate(l)}this.program=this.runtime.typescript.createProgram(this.config.fileNames,this.config.options,this.host.compilerHost,o),this.checker=this.program.getTypeChecker(),this.stats.programUpdates+=1;for(let[c,l]of s)this.program.getSourceFile(Rt(this.workspaceRoot,c))===l?this.stats.sourceNodesReused+=1:this.stats.sourceNodesReplaced+=1;let a=i.map(c=>{let l=Rt(this.workspaceRoot,c),d=this.program.getSourceFile(l);if(!d)throw new Error(`affected TypeScript source is unavailable: ${c}`);return this.emitSourceFile(d)});return this.result(a,r)}fragment(t){return this.fragments.get(dr(t))??null}snapshotStats(){return{...this.stats}}initializeAndAdvance(t){let r=this.initialize(),n=lr(t.modifiedFiles),i=lr(t.affectedFiles);this.validateIncrementalPaths(n,i);let o=new Set(i);return{...r,fragments:r.fragments.filter(s=>o.has(s.relativePath))}}validateIncrementalPaths(t,r){if(t.length===0)throw new Error("incremental TypeScript document update requires a modified file");if(r.length===0)throw new Error("incremental TypeScript document update requires an affected file");for(let n of t){let i=Rt(this.workspaceRoot,n);if(!this.includedFiles.has(Qe(i)))throw new Error(`modified TypeScript file is outside the configured project: ${n}`)}for(let n of r){let i=Rt(this.workspaceRoot,n);if(!this.includedFiles.has(Qe(i)))throw new Error(`affected TypeScript file is outside the configured project: ${n}`)}}emitSourceFile(t){if(!this.checker)throw new Error("TypeScript document emitter is not initialized");let r=dr(us(this.workspaceRoot,t.fileName)),n=new this.runtime.Document({relative_path:r,occurrences:[]});if(new this.runtime.FileIndexer(this.checker,{cwd:this.workspaceRoot,projectRoot:this.projectRoot,projectDisplayName:this.projectRoot,maxFileByteSizeNumber:this.maxFileByteSize},new this.runtime.Input(t.fileName,t.getText()),n,this.symbolTable,this.constructorTable,this.packages,t).index(),this.stats.documentsEmitted+=1,n.occurrences.length===0)return this.fragments.delete(r),this.stats.documentsRemoved+=1,{relativePath:r,bytes:null,occurrences:0,symbols:n.symbols.length,referenceFragments:[]};let o=n.serializeBinary();return this.fragments.set(r,o),{relativePath:r,bytes:o,occurrences:n.occurrences.length,symbols:n.symbols.length,referenceFragments:Ed(r,n)}}result(t,r){return{producerIdentity:this.producerIdentity,fragments:t,durationMs:performance.now()-r,stats:this.snapshotStats()}}};function Ed(e,t){let r=new Map;for(let n of t.occurrences){if(!n.symbol||(n.symbol_roles&1)!==0||n.range.length<3)continue;let i=n.range[0],o=n.range[1];if(!Number.isInteger(i)||!Number.isInteger(o))continue;let s={targetSymbol:n.symbol,location:{file:e,line:i,column:o}};r.set(`${n.symbol}\0${i}\0${o}`,s)}return[...r.values()].sort((n,i)=>n.targetSymbol.localeCompare(i.targetSymbol)||n.location.line-i.location.line||n.location.column-i.location.column)}var $n=class{compilerHost;sourceFiles=new Map;constructor(t,r,n){let i=t.createCompilerHost(r),o=i.getSourceFile.bind(i);this.compilerHost={...i,getCurrentDirectory:()=>n,getSourceFile:(s,a,c,l)=>{let d=Qe(s);if(this.sourceFiles.has(d))return this.sourceFiles.get(d);let u=o(s,a,c,l);return this.sourceFiles.set(d,u),u}}}invalidate(t){this.sourceFiles.delete(Qe(t))}};function ls(e,t){let r=e.readConfigFile(t,e.sys.readFile);if(r.error)throw new Error(e.formatDiagnostics([r.error],e.createCompilerHost({})));let n=e.parseJsonConfigFileContent(r.config,e.sys,qn(t)),i=n.errors.filter(o=>o.code!==18003);if(i.length>0)throw new Error(e.formatDiagnostics(i,e.createCompilerHost({})));return n}function Bn(e){return fs(e.packageVersion,e.typescript.version)}function fs(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${xd}`}function vd(e,t){return dr(us(e,t))||"."}function Rt(e,t){if(bd(t))throw new Error(`expected a project-relative path: ${t}`);let r=ye(e,t),n=e.endsWith(Mn)?e:`${e}${Mn}`;if(r!==e&&!r.startsWith(n))throw new Error(`path escapes the project root: ${t}`);return r}function lr(e){return[...new Set(e.map(dr))].sort()}function dr(e){return e.split(Mn).join("/").replace(/^\.\//,"")}function Qe(e){return ye(e)}function ds(e,t){let r=0;for(let n of e.keys())if(Rd(n)){try{if(n.getSourceFile()!==t)continue}catch{continue}e.delete(n),r+=1}return r}function Rd(e){return!!(e&&typeof e=="object"&&"kind"in e&&"getSourceFile"in e)}var Td=[N("source-facts",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/source-facts.ts"}),N("file-definitions",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/symbols/definition-catalog.ts"}),N("definition-exclusions",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/framework-patterns.ts"}),N("doc-path-tokens",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-products.test.ts",owner:"tests/storage/evidence-cache.test.ts"}),N("doc-path-evidence",{dependsOn:["content-hash","git-history","git-head","tool-version"],keyParts:["kind","relativePath","contentHash","trackedFiles","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/cleanup/doc-drift.ts"}),N("source-imports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),N("source-reexports",{dependsOn:["content-hash","import-resolution-fingerprint","config","tool-version"],keyParts:["kind","relativePath","contentHash","importResolutionFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/language-parsers/index.ts"}),N("source-fingerprints",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/definition-catalog.test.ts",owner:"src/queries/cleanup/similar.ts"}),N("consumer-file-usage",{dependsOn:["content-hash","project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","contentHash","projectFingerprint","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/queries/internal/consumer-evidence.ts"}),N("react-component-behavior-profiles",{dependsOn:["content-hash","tool-version"],keyParts:["kind","relativePath","contentHash","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/source/react-profile.ts"}),N("git-file-adds",{dependsOn:["git-head","git-history","tool-version"],keyParts:["kind","cacheKey","head","historyWindow","payloadVersion"],stalenessTest:"tests/storage/evidence-cache.test.ts",owner:"src/analysis/git-history.ts"}),N("typescript-reference-fragments",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-reference-fragments.test.ts",owner:"src/semantic/typescript/reference-fragment-shadow.ts"}),N("typescript-import-usage",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),N("typescript-signatures",{dependsOn:["content-hash","transitive-deps-digest","config","tool-version"],keyParts:["kind","relativePath","semanticIdentity","payloadVersion"],stalenessTest:"tests/semantic/typescript/typescript-semantic-provider.test.ts",owner:"src/semantic/shared-primitives.ts"}),ur("file-dependency-graph",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","scope","projectFingerprint","payloadVersion"],stalenessTest:"tests/symbols/file-dep-graph.test.ts",owner:"src/symbols/graph/file-dep-graph.ts"}),ur("semantic-import-usage",{dependsOn:["project-fingerprint","indexed-language-set","import-resolution-fingerprint","tool-version"],keyParts:["kind","relativePath","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),ur("semantic-signatures",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","relativePath","symbol","projectFingerprint","language","semanticEngine","payloadVersion"],stalenessTest:"tests/semantic/rust/rust-semantic-cache-gate.test.ts",owner:"src/semantic/shared-primitives.ts"}),ur("health-semantic-prewarm",{dependsOn:["project-fingerprint","indexed-language-set","tool-version"],keyParts:["kind","scope","cliVersion","projectFingerprint","payloadVersion"],stalenessTest:"tests/runtime/cli-support.test.ts",owner:"src/runtime/cli-support.ts"})];function Tt(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(Ar()){let c=io(r);if(c){let l=`${c}\0${n}\0${i}`;a=t.get(l),a||(a=Lr(["evidence-product-file-read-v1",e.kind,c,n,i]),t.set(l,a))}}return Fr("evidence-product.file.read",()=>{let c=oo(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"file",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){so(r,e.kind,n,i,e.serialize(o))},writeBatch(r,n){ao(r,n.map(i=>({kind:e.kind,relativePath:i.relativePath,contentHash:i.contentHash,payload:e.serialize(i.value)})))}}}function Jy(e){let t=new Map;return{kind:e.kind,read(r,n,i){let o=!1,s=0,a;if(Ar()){let c=`${i}\0${n}`;a=t.get(c),a||(a=Lr(["evidence-product-project-read-v1",e.kind,i,n]),t.set(c,a))}return Fr("evidence-product.project.read",()=>{let c=co(r,e.kind,n,i);if(c===null)return null;s=c.length;try{let l=e.deserialize(c);return o=l!==null,l}catch{return null}},()=>({...a?{workIdentity:a,workOutcome:"computed"}:{},scope:"project",kind:e.kind,available:!0,hit:o,payloadBytes:s}))},write(r,n,i,o){lo(r,e.kind,n,i,e.serialize(o))}}}function wt(e){let t=Td.find(r=>r.kind===e);if(!t)throw new Error(`missing evidence product manifest entry for ${e}`);return t.invalidation}function N(e,t){return{scope:"file",kind:e,invalidation:{scope:"file",...t}}}function ur(e,t){return{scope:"project",kind:e,invalidation:{scope:"project",...t}}}var wd=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs"];function Zy(e){let t=e.toLowerCase();return wd.some(r=>t.endsWith(r))}import{createRequire as Cd}from"module";var ms=Cd(import.meta.url),Ct,pr;function Pd(){if(Ct!==void 0)return Ct;try{Ct=ms("ts-morph")}catch{Ct=null}return Ct}function rh(){if(pr)return pr;let e=Pd();if(!e)return"ts-morph:unavailable";let t="unknown";try{t=ms("ts-morph/package.json").version??"unknown"}catch{}return pr=`ts-morph:${t}:typescript:${e.ts.version}`,pr}function nh(e,t){return t.map(r=>({tsconfigPath:r,project:new e.Project({tsConfigFilePath:r,skipFileDependencyResolution:!0})}))}function ih(e,t,r){return{language:"typescript",availability:()=>({available:!1,reason:e,tsconfigPath:t,tsconfigPaths:r}),importUsage:()=>[],referencesFor:()=>[],calleesFor:()=>[],signatureFor:()=>null}}function sh(e,t,r){let n=new Set(r),i=new Map(r.map(o=>[o,[]]));for(let o of e)for(let s of t.get(o.symbolId)??[])n.has(s.file)&&i.get(s.file).push({targetSymbol:o.symbol,location:s});for(let[o,s]of i)i.set(o,kd(s));return i}function kd(e){let t=new Map;for(let r of e){let{location:n}=r;t.set(`${r.targetSymbol}\0${n.file}\0${n.line}\0${n.column}`,r)}return[...t.values()].sort((r,n)=>r.targetSymbol.localeCompare(n.targetSymbol)||Nd(r.location,n.location))}function Nd(e,t){return e.file.localeCompare(t.file)||e.line-t.line||e.column-t.column}import{existsSync as Un,readdirSync as _d,statSync as Dd}from"fs";import{join as Ze,relative as Ad}from"path";function gs(e){let t=Ld(e)??Md(e);if(!t||t.length===0)return[];let r=[],n=new Set;for(let i of t)for(let o of Gd(e,i)){if(n.has(o))continue;n.add(o);let s=$d(e,o);s&&r.push(s)}return r}function Ld(e){let t=Ze(e,"pnpm-workspace.yaml");if(!Un(t))return null;try{return Fd(h(t,"pnpm workspace manifest"))}catch{return null}}function Fd(e){let t=[],r=!1;for(let n of e.split(/\r?\n/)){let i=Od(n);if(!r){/^packages\s*:\s*$/.test(i.trim())&&(r=!0);continue}let o=/^\s+-\s*(.+)$/.exec(i);if(o){let s=jd(o[1].trim());s&&t.push(s);continue}if(i.trim()!=="")break}return t}function Od(e){let t=e.indexOf("#");return t===-1?e:e.slice(0,t)}function jd(e){return e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function Md(e){let t=Ze(e,"package.json");if(!Un(t))return null;try{let r=JSON.parse(h(t,"workspace package manifest"));return r.workspaces?Array.isArray(r.workspaces)?r.workspaces:r.workspaces.packages??[]:null}catch{return null}}function Gd(e,t){if(!t||t.startsWith("!")||t.includes("node_modules"))return[];if(!t.includes("*")){let s=Ze(e,t);return Vn(s)?[s]:[]}let r=t.indexOf("*"),n=t.slice(0,r).replace(/\/$/,""),i=t.slice(r+1).replace(/^\//,""),o=Ze(e,n||".");return Vn(o)?_d(o).map(s=>Ze(o,s,i)).filter(Vn):[]}function Vn(e){try{return Dd(e).isDirectory()}catch{return!1}}function $d(e,t){let r=Ze(t,"package.json");if(!Un(r))return null;try{let n=JSON.parse(h(r,"workspace package manifest"));return typeof n.name!="string"||n.name.length===0?null:{name:n.name,relativeDir:Ad(e,t).replace(/\\/g,"/"),exports:n.exports}}catch{return null}}import{createRequire as qd}from"module";import{existsSync as Le}from"fs";import{basename as ys,dirname as O,extname as ne,join as $,relative as De,resolve as R,sep as Bd}from"path";var Vd=$t("indexed-paths",{clearGroups:[]}),Ud=$t("indexed-path-digest",{clearGroups:[]}),Wd=C("tsconfig-alias-config",{clearGroups:["whole-project"]}),Hd=C("tsconfig-alias-config-for-dir",{clearGroups:["whole-project"]}),zd=qd(import.meta.url),Pt;function Kd(){if(Pt!==void 0)return Pt;try{Pt=zd("typescript")}catch{Pt=null}return Pt}var Xd=["tsconfig.json","tsconfig.app.json","tsconfig.node.json","tsconfig.base.json"],Yd=$t("workspace-packages",{clearGroups:["whole-project"]}),Ae=[".ts",".tsx",".mts",".cts",".js",".jsx",".mjs",".cjs",".vue"],fr=[".py",".pyi"],j=[".java",".scala",".kt",".kts"],mr=[".rs"],gr=[".rb"],yr=[".c",".h",".cc",".cpp",".cxx",".hpp",".hh",".hxx"],he=[".cs",".vb"],hr=[".dart"],Fe=[".php"],et=[".clj",".cljs",".cljc"],Jd=new Set(Ae),Wn=new Set(fr),hs=new Set(j),Hn=new Set(mr),zn=new Set(gr),Ss=new Set(yr),bs=new Set(he),Kn=new Set(hr),xs=new Set(Fe),Is=new Set(et),Qd=[{extensions:Ae,lookup:Jd},{extensions:fr,lookup:Wn},{extensions:j,lookup:hs},{extensions:mr,lookup:Hn},{extensions:gr,lookup:zn},{extensions:yr,lookup:Ss},{extensions:he,lookup:bs},{extensions:hr,lookup:Kn},{extensions:Fe,lookup:xs},{extensions:et,lookup:Is}];function ie(e,t){return t.has(ne(e).toLowerCase())}function Zd(e){return ie(e,Wn)}function eu(e){return ie(e,hs)}function tu(e){return ie(e,Hn)}function ru(e){return ie(e,zn)}function nu(e){return ie(e,Ss)}function iu(e){return ie(e,bs)}function Es(e){return ne(e).toLowerCase()===".vb"}function ou(e){return ie(e,Kn)}function su(e){return ie(e,xs)}function au(e){return ie(e,Is)}function Xn(e){let t=ne(e).toLowerCase();for(let r of Qd)if(r.lookup.has(t))return r.extensions;return Ae}function cu(e){return eu(e)||iu(e)||su(e)}function Se(e,t,r){return Zd(t)?tt(e,t,r):tu(t)?oe(e,t,r):ru(t)?Sr(e,t,r):nu(t)?br(e,t,r):cu(t)?I(e,r.replace(/\\/g,"."),Xn(t)):ou(t)?xr(e,t,r):au(t)?Yn(e,r):lu(e,t,r)}function lu(e,t,r){if(!r.startsWith(".")&&!r.startsWith("/"))return du(e,t,r)??pu(e,r);let n=O($(e.config.projectRoot,t)),i=R(n,r),o=se(e);for(let s of Qn(i)){let a=k(De(e.config.projectRoot,s));if(o.has(a)||Le(s))return a}return k(De(e.config.projectRoot,i))}function du(e,t,r){let n=Su(e,t);if(!n)return null;let i=se(e);for(let o of uu(n,r)){let s=R(n.baseUrl,o);for(let a of Qn(s)){let c=k(De(e.config.projectRoot,a));if(i.has(c)||Le(a))return c}}return null}function uu(e,t){let r=[];for(let[n,i]of Object.entries(e.paths)){let o=n.indexOf("*");if(o===-1){if(t!==n)continue;r.push(...i);continue}let s=n.slice(0,o),a=n.slice(o+1);if(!t.startsWith(s)||!t.endsWith(a)||t.length<s.length+a.length)continue;let c=t.slice(s.length,t.length-a.length);for(let l of i)r.push(l.includes("*")?l.replace("*",c):l)}return r}function pu(e,t){let r=mu(fu(e),t);if(!r)return null;let n=se(e);for(let i of gu(r)){let o=R(e.config.projectRoot,r.pkg.relativeDir,i);for(let s of Qn(o)){let a=k(De(e.config.projectRoot,s));if(n.has(a)||Le(s))return a}}return null}function fu(e){return Yd.get(e,()=>gs(e.config.projectRoot))}function mu(e,t){let r=null;for(let n of e){let i=null;t===n.name?i="":t.startsWith(`${n.name}/`)&&(i=t.slice(n.name.length+1)),i!==null&&(!r||n.name.length>r.pkg.name.length)&&(r={pkg:n,subpath:i})}return r}function gu(e){let t=[],r=yu(e.pkg.exports,e.subpath);if(r){let n=hu(r);n&&t.push(n)}return t.push(e.subpath?`src/${e.subpath}`:"src/index"),t}function yu(e,t){if(!e||typeof e!="object")return null;let r=t===""?".":`./${t}`;return vs(e[r])}function vs(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;let t=e;for(let r of["types","import","default","require","node"]){let n=vs(t[r]);if(n)return n}return null}function hu(e){let t=e.replace(/^\.\//,"");return t.startsWith("dist/")?`src/${t.slice(5)}`:null}function Su(e,t){let r=k(O(t));return Hd.get(e,r,()=>bu(e,r))}function bu(e,t){let r=Kd();if(!r)return null;let n=R(e.config.projectRoot),i=R(n,t);for(;i===n||i.startsWith(n+Bd);){for(let s of Xd){let a=$(i,s);if(!Le(a))continue;let c=Wd.get(e,a,()=>xu(r,a));if(c)return c}let o=O(i);if(o===i)break;i=o}return null}function xu(e,t){try{let r=e.readConfigFile(t,e.sys.readFile);if(r.error||!r.config)return null;let n=e.parseJsonConfigFileContent(r.config,e.sys,O(t)),i=n.options.paths;return!i||Object.keys(i).length===0?null:{baseUrl:n.options.baseUrl?R(O(t),n.options.baseUrl):O(t),paths:i}}catch{return null}}function tt(e,t,r){let n=se(e),i;if(r.startsWith(".")){let o=r.match(/^(\.+)(.*)$/);if(!o)return null;let s=o[1].length,a=o[2].replace(/^\./,""),c=O($(e.config.projectRoot,t));for(let l=1;l<s;l++)c=O(c);i=a?R(c,a.replace(/\./g,"/")):c}else i=R(e.config.projectRoot,r.replace(/\./g,"/"));for(let o of Iu(i)){let s=k(De(e.config.projectRoot,o));if(n.has(s)||Le(o))return s}return null}function oe(e,t,r){if(!r)return null;let n=r.replace(/\s+as\s+.+$/,"").trim();if(!n.startsWith("crate::")&&!n.startsWith("self::")&&!n.startsWith("super::"))return null;let i=O($(e.config.projectRoot,t)),o;return n.startsWith("crate::")?o=R(e.config.projectRoot,"src",n.slice(7).replace(/::/g,"/")):n.startsWith("self::")?o=R(i,n.slice(6).replace(/::/g,"/")):o=R(O(i),n.slice(7).replace(/::/g,"/")),Jn(e,Eu(o))}function Sr(e,t,r){let n=O($(e.config.projectRoot,t)),i=R(n,r);return Jn(e,vu(i))}function br(e,t,r){let n=O($(e.config.projectRoot,t)),i=[R(n,r),R(e.config.projectRoot,r),R(e.config.projectRoot,"include",r),R(e.config.projectRoot,"src",r)];return Jn(e,i)}function I(e,t,r){let n=se(e),i=t.replace(/\\/g,".").replace(/::/g,".").replace(/^global::/,""),o=i.replace(/\./g,"/"),s=i.split(".").pop()??i;for(let c of r){let l=`${o}${c}`,d=[...n].find(u=>u.endsWith(l));if(d)return d}for(let c of r){let l=[...n].find(d=>ys(d)===`${s}${c}`);if(l)return l}let a=[...n].filter(c=>r.includes(ne(c).toLowerCase())).filter(c=>c.includes(`/${o}/`)||c.includes(`/${s}/`)).sort((c,l)=>c.localeCompare(l));return a.length===1?a[0]:null}function xr(e,t,r){let n=se(e);if(r.startsWith("package:")){let s=r.slice(8),a=s.indexOf("/");if(a<0)return null;let c=s.slice(a+1),l=k(c.startsWith("lib/")?c:`lib/${c}`);return n.has(l)?l:null}let i=O($(e.config.projectRoot,t)),o=R(i,r);for(let s of Ru(o)){let a=k(De(e.config.projectRoot,s));if(n.has(a)||Le(s))return a}return null}function Yn(e,t){let r=t.replace(/-/g,"_").replace(/\./g,"/"),n=se(e);for(let i of et){let o=`${r}${i}`,s=[...n].find(a=>a.endsWith(o));if(s)return s}for(let i of et){let o=[...n].find(s=>ys(s)===`${r.split("/").pop()}${i}`);if(o)return o}return null}function Iu(e){let t=ne(e);return Wn.has(t)?[e]:[`${e}.py`,`${e}.pyi`,$(e,"__init__.py"),$(e,"__init__.pyi")]}function Jn(e,t){let r=se(e);for(let n of t){let i=k(De(e.config.projectRoot,n));if(r.has(i)||Le(n))return i}return null}function Eu(e){let t=ne(e);return Hn.has(t)?[e]:[`${e}.rs`,$(e,"mod.rs")]}function vu(e){let t=ne(e);return zn.has(t)?[e]:[`${e}.rb`,$(e,"index.rb")]}function Ru(e){let t=ne(e);return Kn.has(t)?[e]:[`${e}.dart`,e]}function Qn(e){let t=ne(e),r=new Set;if(t){r.add(e);for(let n of Ae)r.add(e.slice(0,-t.length)+n)}else for(let n of Ae)r.add(`${e}${n}`),r.add($(e,`index${n}`));return[...r]}function se(e){return Vd.get(e,()=>new Set(ki(e,{includeIgnored:!1}).map(k)))}function Zn(e){return Ud.get(e,()=>er([...se(e)].sort().join(`
|
|
115
|
+
`)))}var Tu=C("source-text",{clearGroups:["whole-project","source-file"]}),wu=C("source-lines",{clearGroups:["whole-project","source-file"]});function M(e,t){let r=t.replace(/\\/g,"/");return Tu.get(e,r,()=>{try{return Ti(e.config.projectRoot,r,{inputKind:"indexed source file"})}catch(n){if(wi(n))return"";throw n}})}function vh(e,t){let r=t.replace(/\\/g,"/");return wu.get(e,r,()=>{let n=M(e,r);return n?n.split(`
|
|
116
|
+
`):[]})}import{basename as Xs}from"path";function Oe(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Cu(e){return e.replace(/'''[\s\S]*?'''/g,be).replace(/"""[\s\S]*?"""/g,be).replace(/#.*$/gm,be).replace(/\/\/.*$/gm,be).replace(/\/\*[\s\S]*?\*\//g,be).replace(/`(?:\\[\s\S]|[^`])*`/g,be).replace(/'(?:\\.|[^'\\\r\n])*'/g,be).replace(/"(?:\\.|[^"\\\r\n])*"/g,be)}function be(e){return e.replace(/[^\r\n]/g," ")}var kh=We("stripped-lines",{clearGroups:["whole-project","source-file"]});Ci({name:"stripped-source-singleton",groups:["whole-project","source-file"],clearAll:()=>{Ir=null,kt=""},clearFile:()=>{Ir=null,kt=""}});var Ir=null,kt="";function Pu(e){return Ir===e||(Ir=e,kt=Cu(e)),kt}function xe(e,t,r){let n=Pu(e);return`${n.slice(0,t)}${" ".repeat(r-t)}${n.slice(r)}`}function _(e,t){return new RegExp(`\\b${Oe(t)}\\b`,"m").test(e)}function rt(e,t){let r=new Set,n=new RegExp(`\\b${Oe(t)}\\s*\\.\\s*([A-Za-z_$][\\w$]*)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function ei(e){let t=0;for(let r of e)r==="("&&(t+=1),r===")"&&(t-=1);return t}import{extname as Rs}from"path";var ku={".rs":"rust",".ts":"typescript",".mts":"typescript",".cts":"typescript",".tsx":"tsx",".js":"javascript",".jsx":"javascript",".mjs":"javascript",".cjs":"javascript",".py":"python",".pyi":"python",".java":"java",".kt":"kotlin",".kts":"kotlin",".scala":"scala",".sc":"scala",".rb":"ruby",".c":"c",".h":"c",".cc":"cpp",".cpp":"cpp",".cxx":"cpp",".hpp":"cpp",".hh":"cpp",".hxx":"cpp",".cs":"csharp",".php":"php",".vb":"vb",".clj":"clojure",".cljs":"clojure",".cljc":"clojure"};function je(e){return ku[Rs(e).toLowerCase()]??null}function Me(e){return Rs(e).toLowerCase()===".vue"}import{createRequire as Nu}from"module";var P=Nu(import.meta.url),Er=null,Ts=!1;function _u(){if(Ts)return null;if(Er)return Er;try{return Er=P("tree-sitter"),Er}catch{return Ts=!0,null}}var ws=new Map,vr=new Set;function Du(e){if(vr.has(e))return null;let t=ws.get(e);if(t)return t;let r;try{switch(e){case"rust":r=P("tree-sitter-rust");break;case"typescript":r=P("tree-sitter-typescript").typescript;break;case"tsx":r=P("tree-sitter-typescript").tsx;break;case"javascript":r=P("tree-sitter-javascript");break;case"python":r=P("tree-sitter-python");break;case"java":r=P("tree-sitter-java");break;case"kotlin":r=P("tree-sitter-kotlin");break;case"scala":r=P("tree-sitter-scala");break;case"ruby":r=P("tree-sitter-ruby");break;case"c":r=P("tree-sitter-c");break;case"cpp":r=P("tree-sitter-cpp");break;case"csharp":r=P("tree-sitter-c-sharp");break;case"php":r=P("tree-sitter-php").php;break;case"vb":{let n=P("tree-sitter-vb-dotnet");r=n.language??n;break}case"clojure":return vr.add(e),null}}catch{return vr.add(e),null}return ws.set(e,r),r}var Cs=new Map;function Au(e){let t=Cs.get(e);if(t)return t;let r=Du(e);if(!r)return null;let n=_u();if(!n)return null;let i=new n;try{i.setLanguage(r)}catch{return vr.add(e),null}return Cs.set(e,i),i}function Lu(e,t){return e.parse(n=>n>=t.length?null:t.slice(n,Math.min(t.length,n+16384)))}function ti(e,t){let r=Au(e);if(!r)return null;try{return Lu(r,t)}catch{return null}}import{posix as ri}from"path";import{parse as Fu}from"@vue/compiler-sfc";var Gh=Pi("vue-sfc-units");function Ou(e){return e.replace(/\\/g,"/").replace(/^\.\//,"")}function ju(e){let t=e?.toLowerCase();return!t||t==="js"||t==="javascript"||t==="jsx"?"javascript":t==="ts"||t==="typescript"?"typescript":t==="tsx"?"tsx":null}function Ns(e,t,r){let n={relativePath:t,template:null,scripts:[],styles:[],customBlocks:[],errors:[]};if(!r)return n;let i;try{i=Fu(r,{filename:t})}catch(s){return n.errors.push(ks(s)),n}n.errors.push(...i.errors.map(ks));let{descriptor:o}=i;return o.template&&(n.template=Rr(e,t,"template",o.template)),o.script&&n.scripts.push(Ps(e,t,o.script,!1)),o.scriptSetup&&n.scripts.push(Ps(e,t,o.scriptSetup,!0)),n.styles=o.styles.map(s=>Rr(e,t,"style",s)),n.customBlocks=o.customBlocks.map(s=>Rr(e,t,"custom",s)),n.errors.push(...[n.template,...n.scripts,...n.styles,...n.customBlocks].flatMap(s=>s?.errors??[])),n}function Ps(e,t,r,n){let i=Rr(e,t,"script",r);return{...i,kind:"script",setup:n,astLanguage:ju(i.lang)}}function Rr(e,t,r,n){let i=Gu(n.attrs),o=typeof i.lang=="string"?i.lang:null,s=typeof i.src=="string"?i.src:typeof n.src=="string"?n.src:void 0;if(s){let c=Mu(t,s);if(!c)return{kind:r,ownerPath:t,sourcePath:t,external:!0,src:s,attrs:i,lang:o,body:"",startLine:0,endLine:0,errors:[`Could not resolve Vue ${r} block source: ${s}`]};let l=M(e,c),d=l?Math.max(0,l.split(`
|
|
117
|
+
`).length-1):0;return{kind:r,ownerPath:t,sourcePath:c,external:!0,src:s,attrs:i,lang:o,body:l,startLine:0,endLine:d,errors:l?[]:[`Vue ${r} block source not found: ${c}`]}}let a=Math.max(0,n.loc.start.line-1);return{kind:r,ownerPath:t,sourcePath:t,external:!1,attrs:i,lang:o,body:n.content,startLine:a,endLine:Math.max(a,n.loc.end.line-1),errors:[]}}function Mu(e,t){let r=t.split(/[?#]/,1)[0];if(!r||r.startsWith("/")||r.includes("://"))return null;let n=Ou(ri.normalize(ri.join(ri.dirname(e),r)));return n===".."||n.startsWith("../")?null:n}function Gu(e){return{...e}}function ks(e){return e instanceof Error?e.message:String(e)}function Tr(e,t,r){let i=Ns(e,t,r).scripts.filter(s=>s.astLanguage&&s.body.length>0),o=i[0]?.astLanguage;return o?{body:i.map(s=>`${`
|
|
118
|
+
`.repeat(s.startLine)}${s.body}`).join(`
|
|
119
|
+
`),startLine:0,language:o}:null}var _s=We("ast-trees",{clearGroups:["whole-project","source-file"]});function te(e,t){if(Me(t))return $u(e,t);let r=je(t);if(!r)return null;let n=M(e,t);return n?_s.get(e,t,n,()=>ti(r,n)):null}function $u(e,t){let r=M(e,t);return r?_s.get(e,t,r,()=>{let n=Tr(e,t,r);if(!n)return null;let i=`
|
|
120
|
+
`.repeat(n.startLine)+n.body;return ti(n.language,i)}):null}function Ds(e,t){let r=qu(e,t);if(!r)return null;let n=Ge(r);return n?{calleeLeaf:n,memberAccess:Bu(r),line:e.startPosition.row}:null}function qu(e,t){if(t==="rust")return e.type==="call_expression"?e.childForFieldName("function")??e.namedChild(0):e.type==="macro_invocation"?e.childForFieldName("macro")??e.namedChild(0):null;if(t==="python")return e.type!=="call"?null:e.childForFieldName("function")??e.namedChild(0);if(t==="typescript"||t==="tsx"||t==="javascript"){if(e.type==="call_expression")return e.childForFieldName("function")??e.namedChild(0);if(e.type==="new_expression")return e.childForFieldName("constructor")??e.namedChild(0)}return null}function Bu(e){switch(e.type){case"field_expression":case"member_expression":case"attribute":return!0;default:return!1}}function Ge(e){switch(e.type){case"identifier":case"type_identifier":case"field_identifier":case"property_identifier":case"shorthand_property_identifier":return e.text;case"field_expression":case"member_expression":case"attribute":{let t=e.namedChild(e.namedChildCount-1);return t?Ge(t):null}case"generic_function":{let t=e.childForFieldName("function")??e.namedChild(0);return t?Ge(t):null}case"scoped_identifier":{let t=e.childForFieldName("name")??e.namedChild(e.namedChildCount-1);return t?Ge(t):null}case"super":case"self":case"this":return null;default:return null}}function Nt(e){return e.type==="comment"||e.type==="line_comment"||e.type==="block_comment"}var Vu=new Set(["function_declaration","method_definition","method_signature","function_signature"]);function js(e,t){let r=Wu(e,t);if(r)return{name:r.name,startLine:r.definitionNode.startPosition.row,endLine:r.definitionNode.endPosition.row,paramCount:Fs(r.functionNode),params:As(r.functionNode),paramsEndLine:Ls(r.functionNode),isLiteralPassthrough:Os(r.functionNode,t)};if(!Uu(e.type,t))return null;let n=e.childForFieldName("name")??e.namedChildren.find(i=>i.type==="identifier"||i.type==="property_identifier");return n?{name:n.text,startLine:e.startPosition.row,endLine:e.endPosition.row,paramCount:Fs(e),params:As(e),paramsEndLine:Ls(e),isLiteralPassthrough:Os(e,t)}:null}function Ms(e){return e.namedChildren.find(t=>t.type==="parameters"||t.type==="formal_parameters")}function As(e){let t=Ms(e);if(!t)return[];let r=[];for(let n of t.namedChildren){if(Nt(n))continue;if(n.type==="identifier"){r.push({name:n.text,simple:!0});continue}let i=n.namedChildren.some(a=>a.type.endsWith("_modifier"))||/^\s*(?:public|private|protected|readonly|override)\b/.test(n.text),o=n.childForFieldName("pattern");if(!i&&o&&o.type==="identifier"){r.push({name:o.text,simple:!0});continue}let s=n.namedChildren.find(a=>a.type==="identifier");r.push({name:o?.type==="identifier"?o.text:s?.text??"",simple:!1})}return r}function Ls(e){let t=Ms(e);return t?t.endPosition.row:e.startPosition.row}function Uu(e,t){return t==="rust"?e==="function_item"||e==="function_signature_item":t==="python"?e==="function_definition":t==="typescript"||t==="tsx"||t==="javascript"?Vu.has(e):!1}function Wu(e,t){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript")return null;if(e.type==="variable_declarator"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}if(e.type==="public_field_definition"){let r=e.childForFieldName("name")??e.namedChild(0),n=e.childForFieldName("value")??e.namedChild(1);return!r||!n||n.type!=="arrow_function"&&n.type!=="function_expression"?null:{name:r.text,definitionNode:e,functionNode:n}}return null}function Fs(e){let t=e.namedChildren.find(n=>n.type==="parameters"||n.type==="formal_parameters");if(!t)return 0;let r=0;for(let n of t.namedChildren)Nt(n)||(r+=1);return r}function Os(e,t){let r=e.namedChildren.find(u=>u.type==="block"||u.type==="statement_block");if(!r)return!1;let n=r.namedChildren.filter(u=>!Nt(u));if(n.length!==1)return!1;let i=n[0],o=null;if(i.type==="return_statement"||i.type==="expression_statement"?o=i.namedChild(0)??null:t==="rust"&&(i.type==="call_expression"||i.type==="macro_invocation")&&(o=i),!o)return!1;let s=t==="python"?"call":"call_expression";if(o.type!==s)return!1;let a=o.namedChildren.find(u=>u.type==="arguments"||u.type==="argument_list");if(!a)return!1;let c=a.namedChildren.filter(u=>!Nt(u)),l=e.namedChildren.find(u=>u.type==="parameters"||u.type==="formal_parameters");if(!l)return!1;let d=[];for(let u of l.namedChildren){if(u.type==="identifier"){d.push(u.text);continue}let p=u.namedChildren.find(m=>m.type==="identifier");p&&d.push(p.text)}if(c.length!==d.length)return!1;for(let u=0;u<d.length;u+=1){let p=c[u];if(p.type!=="identifier"||p.text!==d[u])return!1}return!0}var Hu=new Set(["identifier","type_identifier","field_identifier"]),zu=new Set(["identifier"]),Ku=new Set(["identifier","property_identifier","type_identifier","shorthand_property_identifier","shorthand_property_identifier_pattern"]),Xu=new Set(["rust","python"]),Yu=/\{([^{}]*)\}/g,Ju=/\b([A-Za-z_][\w]*)\b/g;function Gs(e,t){return Qu(t).has(e.type)}function $s(e,t){return Xu.has(t)&&e.type==="string_content"}function ni(e){let t=0;for(let n of e.values()){let i=n[n.length-1];i!==void 0&&i>t&&(t=i)}let r=new Array(t+1);for(let n=0;n<=t;n+=1)r[n]=new Set;for(let[n,i]of e)for(let o of i)r[o].add(n);return r}function Qu(e){return e==="rust"?Hu:e==="python"?zu:Ku}function qs(e,t){let r=e.startPosition.row;for(let n of e.text.matchAll(Yu)){let i=n[1]??"";for(let o of i.matchAll(Ju))o[1]&&t(o[1],r)}}var Zu=[/\bdefault\s*=\s*"([^"]+)"/g,/\bwith\s*=\s*"([^"]+)"/g,/\bserialize_with\s*=\s*"([^"]+)"/g,/\bdeserialize_with\s*=\s*"([^"]+)"/g,/\bskip_serializing_if\s*=\s*"([^"]+)"/g,/\bgetter\s*=\s*"([^"]+)"/g,/\brename_all_with\s*=\s*"([^"]+)"/g,/\bschema_with\s*=\s*"([^"]+)"/g],ep=/^#!?\[\s*serde\s*\(/,tp=/^#!?\[\s*schemars\s*\(/,rp=/^#!?\[\s*validate\s*\(/,np=new Set(["invoke","invokeTauriCommand","listen","once","emit","subscribe","dispatch","sendCommand","callRust"]);function Bs(e,t,r){if(t!=="typescript"&&t!=="tsx"&&t!=="javascript"||e.type!=="call_expression")return;let n=e.childForFieldName("function")??e.namedChild(0);if(!n)return;let i=Ge(n);if(!i||!np.has(i))return;let o=e.namedChildren.find(c=>c.type==="arguments");if(!o)return;let s=o.namedChild(0);if(!s||s.type!=="string")return;let a=s.namedChildren.find(c=>c.type==="string_fragment");a&&r.add(a.text)}function Vs(e,t){let r=ep.test(e),n=tp.test(e),i=rp.test(e);if(!(!r&&!n&&!i))for(let o of Zu){o.lastIndex=0;let s;for(;(s=o.exec(e))!==null;){let a=s[1],c=a.split("::").pop()??a;c==="is_none"&&/\bOption\b/.test(a)||c==="is_empty"&&/\b(String|Vec|HashMap|BTreeMap|HashSet|BTreeSet)\b/.test(a)||c&&t.add(c)}}}function Us(e,t){let r=new Map,n=(s,a)=>{if(s===a)return;let c=r.get(s);c||(c=new Set,r.set(s,c)),c.add(a)},i=t==="python"?new Set(["identifier"]):new Set(["type_identifier"]),o=(s,a)=>{let c=l=>{i.has(l.type)&&l.text!==a&&n(l.text,a);for(let d of l.children)c(d)};for(let l of s.children)c(l)};if(t==="rust")for(let s of e.rootNode.descendantsOfType(["struct_item","enum_item","union_item","type_item"])){let a=s.namedChildren.find(l=>l.type==="type_identifier")?.text;if(!a)continue;let c=s.namedChildren.find(l=>l.type==="field_declaration_list"||l.type==="enum_variant_list"||l.type==="ordered_field_declaration_list");c&&o(c,a),s.type==="type_item"&&o(s,a)}else if(t==="python")for(let s of e.rootNode.descendantsOfType("class_definition")){let a=s.namedChildren.find(d=>d.type==="identifier")?.text;if(!a)continue;let c=s.childForFieldName("superclasses");c&&o(c,a);let l=s.namedChildren.find(d=>d.type==="block");if(l)for(let d of l.descendantsOfType("type"))for(let u of d.descendantsOfType("identifier"))u.text!==a&&n(u.text,a)}else for(let s of e.rootNode.descendantsOfType(["interface_declaration","type_alias_declaration","class_declaration"])){let a=s.namedChildren.find(c=>c.type==="type_identifier")?.text;a&&o(s,a)}return r}var ip=new Map([["defn","function"],["defn-","function"],["defmacro","macro"],["defmacro-","macro"],["defmethod","method"]]),ii=new Set(["catch","comment","def","defprotocol","defrecord","deftype","defmethod","defmacro","defmacro-","defn","defn-","do","doseq","dotimes","fn","for","if","let","loop","ns","quote","recur","throw","try","extend-protocol","extend-type","when","when-let","when-not"]);function Ws(e){let t=[],r=[],n=[],i=new Map,o=[],s=0,a=0,c=(l,d)=>{let u=i.get(l);if(!u){i.set(l,[d]);return}u[u.length-1]!==d&&u.push(d)};for(;a<e.length;){let l=e[a];if(l===`
|
|
121
|
+
`){s+=1,a+=1;continue}if(/\s|,/.test(l)){a+=1;continue}if(l===";"){a=Cr(e,a);continue}if(l==='"'){let g=Dt(e,a,s);s=g.line,a=g.index;continue}if(l==="("||l==="["||l==="{"){o.push({kind:l,startLine:s,endLine:s,headTokens:[],tokens:[],children:[]}),a+=1;continue}if(l===")"||l==="]"||l==="}"){let g=o.pop();g&&(g.endLine=s,op(g,{callables:t,callSites:r,clojureMembers:n,recordIdentifier:c}),o[o.length-1]?.children.push(g)),a+=1;continue}if(oi(l)){a+=1;continue}let d=s,u=a;for(;a<e.length&&!si(e[a]);)a+=1;let p=e.slice(u,a);if(!p)continue;let m={text:p,line:d};sp(o[o.length-1],m),c(q(p),d)}return{language:"clojure",callables:t,callSites:r,clojureMembers:n,typeContainerMap:new Map,identifierLineMap:i,identifiersByLine:up(i),fileIdentifiers:new Set(i.keys()),rustAttrReferencedNames:new Set,crossLanguageDispatchNames:new Set}}function op(e,t){if(e.kind!=="("||e.headTokens.length===0)return;let r=e.headTokens[0],n=q(r.text),i=ip.get(r.text);if(i){let s=e.headTokens[1];if(s){let a=q(s.text);t.recordIdentifier(a,s.line),t.callables.push({name:a,startLine:e.startLine,endLine:e.endLine,paramCount:0,params:[],paramsEndLine:s.line,isLiteralPassthrough:!1,clojureKind:i})}}if(ap(e,t),!n||ii.has(r.text)||ii.has(n)||n.startsWith(":"))return;let o=dp(r.text);t.callSites.push({calleeLeaf:o.leaf,calleeQualifier:o.qualifier,calleeText:o.text,memberAccess:!1,line:r.line})}function sp(e,t){e&&(e.headTokens.length<2&&e.headTokens.push(t),e.tokens.length<200&&e.tokens.push(t))}function ap(e,t){let r=q(e.tokens[0]?.text??"");if(r==="defprotocol"){let n=q(e.tokens[1]?.text??"");if(!n)return;for(let i of wr(e))_t(t,n,"protocol",i,"protocol-method");return}if(r==="defrecord"||r==="deftype"){let n=q(e.tokens[1]?.text??"");if(!n)return;let i=r==="defrecord"?"record":"type",o=r==="defrecord"?"record-method":"type-method";for(let s of wr(e))_t(t,n,i,s,o);return}if(r==="extend-type"){let n=q(e.tokens[1]?.text??"");if(!n)return;for(let i of wr(e))_t(t,n,"extension",i,"extension-method");return}if(r==="extend-protocol"){let n=q(e.tokens[1]?.text??"");for(let i of wr(e)){n&&_t(t,n,"extension",i,"extension-method");let o=lp(e,i.startLine);o&&o!==n&&_t(t,o,"extension",i,"extension-method")}}}function wr(e){return e.children.filter(cp)}function cp(e){if(e.kind!=="(")return!1;let t=q(e.tokens[0]?.text??"");return!!(t&&!ii.has(t)&&!t.startsWith(":"))}function _t(e,t,r,n,i){let o=n.tokens[0],s=q(o?.text??"");!o||!s||(e.recordIdentifier(s,o.line),e.clojureMembers.push({ownerName:t,ownerKind:r,memberName:s,memberKind:i,startLine:n.startLine,endLine:n.endLine}))}function lp(e,t){let r=null;for(let n=2;n<e.tokens.length;n+=1){let i=e.tokens[n];if(i.line>t)break;let o=q(i.text);o&&!o.startsWith(":")&&(r=o)}return r}function q(e){return e.replace(/^#?['`~@]+/,"").split("/").pop()?.replace(/^\./,"")??""}function dp(e){let t=e.replace(/^#?['`~@]+/,""),r=t.lastIndexOf("/"),n=q(t);if(r<=0)return{leaf:n,text:t};let i=t.slice(0,r);return{leaf:n,qualifier:i,text:t}}function Cr(e,t){let r=t;for(;r<e.length&&e[r]!==`
|
|
122
|
+
`;)r+=1;return r}function Dt(e,t,r){let n=t+1,i=r;for(;n<e.length;){let o=e[n];if(o==="\\"){n+=2;continue}if(o===`
|
|
123
|
+
`&&(i+=1),n+=1,o==='"')break}return{index:n,line:i}}function oi(e){return e==="'"||e==="`"||e==="~"||e==="@"||e==="^"||e==="#"}function si(e){return/\s|,/.test(e)||e==="("||e===")"||e==="["||e==="]"||e==="{"||e==="}"||e==='"'||e===";"}function up(e){let t=[];for(let[r,n]of e)for(let i of n)t[i]??=new Set,t[i].add(r);return t}var Hs=3,pp=We("source-facts",{clearGroups:["whole-project","source-file"]}),ai=Tt({kind:"source-facts",invalidation:wt("source-facts"),serialize:yp,deserialize:hp});function zs(e,t){return fp(e,t).facts}function fp(e,t){let r=M(e,t);if(!r)return{facts:null};let n=mp(e,t,r);return n?pp.get(e,t,r,()=>gp(e,t,n,r)):{facts:null}}function mp(e,t,r){return Me(t)?Tr(e,t,r)?.language??null:je(t)}function gp(e,t,r,n){let i=dt(e,t,n),o=ai.read(e,t,i);if(o&&o.language===r)return{facts:o};if(r==="clojure"){let c=Ws(n);return ai.write(e,t,i,c),{facts:c}}let s=te(e,t);if(!s)return{facts:null,unavailable:{language:r,reason:"parser-unavailable"}};let a=Sp(s,r);return ai.write(e,t,i,a),{facts:a}}function yp(e){let t={version:Hs,language:e.language,callables:e.callables,callSites:e.callSites,clojureMembers:e.clojureMembers,typeContainerMap:[...e.typeContainerMap.entries()].map(([r,n])=>[r,[...n]]),identifierLineMap:[...e.identifierLineMap.entries()],rustAttrReferencedNames:[...e.rustAttrReferencedNames],crossLanguageDispatchNames:[...e.crossLanguageDispatchNames]};return JSON.stringify(t)}function hp(e){try{let t=JSON.parse(e);if(t.version!==Hs||t.language==="clojure"&&(t.clojureMembers===void 0||t.callSites.some(n=>n.calleeText===void 0)))return null;let r=new Map(t.identifierLineMap);return{language:t.language,callables:t.callables,callSites:t.callSites,clojureMembers:t.clojureMembers??[],typeContainerMap:new Map(t.typeContainerMap.map(([n,i])=>[n,new Set(i)])),identifierLineMap:r,identifiersByLine:ni(r),fileIdentifiers:new Set(r.keys()),rustAttrReferencedNames:new Set(t.rustAttrReferencedNames),crossLanguageDispatchNames:new Set(t.crossLanguageDispatchNames)}}catch{return null}}function Sp(e,t){let r=[],n=[],i=new Set,o=new Set,s=new Map,a=(l,d)=>{let u=s.get(l);if(!u){s.set(l,[d]);return}u[u.length-1]!==d&&u.push(d)},c=l=>{let d=js(l,t);d&&r.push(d);let u=Ds(l,t);u&&n.push(u),Bs(l,t,o),t==="rust"&&(l.type==="attribute_item"||l.type==="inner_attribute_item")&&Vs(l.text,i),Gs(l,t)&&a(l.text,l.startPosition.row),$s(l,t)&&qs(l,a);for(let p of l.children)c(p)};return c(e.rootNode),{language:t,callables:r,callSites:n,clojureMembers:[],typeContainerMap:Us(e,t),identifierLineMap:s,identifiersByLine:ni(s),fileIdentifiers:new Set(s.keys()),rustAttrReferencedNames:i,crossLanguageDispatchNames:o}}var bp=new Set(["rust","typescript","tsx","javascript","python","clojure"]);function xp(e,t){let r=zs(e,t);return!r||!bp.has(r.language)?null:r.callables.map(n=>({name:n.name,startLine:n.startLine,endLine:n.endLine}))}function Ks(e,t){return e.split(t).filter(Boolean).map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("")}var Ip=new Set(["identifier","type_identifier","property_identifier","shorthand_property_identifier","field_identifier"]);function D(e){let t=[],r=0,n=0;for(let i=0;i<e.length;i++){let o=e[i];(o==="{"||o==="["||o==="(")&&r++,(o==="}"||o==="]"||o===")")&&r--,o===","&&r===0&&(t.push(e.slice(n,i)),n=i+1)}return t.push(e.slice(n)),t}function G(e,t){for(let r of e.namedChildren)if(r.type===t)return r;return null}function E(e,t){let r=new Set,n=(i,o)=>{let s=o||t.has(i.type);!s&&Ip.has(i.type)&&r.add(i.text);for(let a of i.children)n(a,s)};return n(e.rootNode,!1),r}function z(e,t,r,n,i,o,s){return{importedName:i,localName:o,sourcePath:s??I(e,n,Xn(t)),kind:"named",used:_(r,o),usedMembers:[]}}function x(e,t,r,n,i="named",o={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n.has(t),usedMembers:[],isTypeOnly:o.isTypeOnly}}function ae(e,t,r,n,i="named",o=[],s={}){return{importedName:e,localName:t,sourcePath:r,kind:i,used:n,usedMembers:o,isTypeOnly:s.isTypeOnly}}function $e(e,t){return{importedName:e,localName:null,sourcePath:t,kind:"side-effect",used:!0,usedMembers:[]}}function qe(e,t,r={}){return{importedName:e,localName:r.localName??null,sourcePath:t,kind:"namespace",used:r.used??!0,usedMembers:r.usedMembers??[],isTypeOnly:r.isTypeOnly}}function B(e,t,r){let n=[];for(let i of e.matchAll(t)){let o=i[0];if(!o||typeof i.index!="number")continue;let s=xe(e,i.index,i.index+o.length);for(let a of r(i,s))n.push(a)}return n}function V(e,t,r,n){let i=te(e,t);if(i){let o=r(i);if(o)return o}return n()}function Pr(e,t,r,n){let i=te(e,t),o=je(t),s=o?r[o]:void 0;return i&&s?s(i):n()}function Ys(e,t,r){return V(e,t,n=>vp(e,t,n),()=>Ep(e,t,r))}function Ep(e,t,r){return B(r,/^[ \t]*#include\s+[<"]([^">]+)[">]\s*$/gm,(n,i)=>{let o=n[1]?.trim();if(!o)return[];let s=Xs(o).replace(/\.[^.]+$/,"");return[ae(o,s,br(e,t,o),_(i,s))]})}function vp(e,t,r){let n=E(r,new Set(["preproc_include"])),i=[];for(let o of r.rootNode.descendantsOfType("preproc_include")){let s=null;for(let c of o.namedChildren){if(c.type==="system_lib_string"){s=c.text.replace(/^<|>$/g,"");break}if(c.type==="string_literal"){s=c.namedChildren.find(d=>d.type==="string_content")?.text??c.text.replace(/^"|"$/g,"");break}}if(!s)continue;let a=Xs(s).replace(/\.[^.]+$/,"");i.push(x(s,a,br(e,t,s),n))}return i}var Rp=new Set([":require",":require-macros",":use"]),di=String.raw`A-Za-z0-9_$*+!?.<>=-`;function Qs(e,t,r){let n=Fp(r);if(!n)return[];let i=Lp(r,n.start,n.end),o=[];for(let s of n.children.slice(2)){if(s.type!=="list"||s.children.length===0)continue;let a=U(s.children[0]);if(a){if(Rp.has(a)){for(let c of Cp(s.children.slice(1)))o.push(...wp(e,c,i));continue}if(a===":import")for(let c of kp(s.children.slice(1)))o.push(c)}}return o}function Tp(e){return e.type==="list"&&U(e.children[0])==="ns"}function wp(e,t,r){let n=Yn(e,t.namespace),i=t.alias??t.namespace,o=_p(r,i),s=[{importedName:t.namespace,localName:i,sourcePath:n,kind:"namespace",used:t.refers.length>0||t.referAll||o.length>0||Dp(r,t.namespace),usedMembers:o}];t.referAll&&s.push({importedName:"*",localName:null,sourcePath:n,kind:"side-effect",used:!0,usedMembers:[]});for(let a of t.refers)s.push({importedName:a,localName:a,sourcePath:n,kind:"named",used:Ap(r,a),usedMembers:[]});return s}function Cp(e){return e.flatMap(t=>kr(t,null))}function kr(e,t){if(e.type==="atom")return e.text.startsWith(":")?[]:[{namespace:li(t,e.text),alias:null,refers:[],referAll:!1}];if(e.type==="vector")return e.children.length>0&&U(e.children[0])===null?e.children.flatMap(r=>kr(r,t)):Pp(e,t);if(e.type==="list"&&e.children.length>0){let r=U(e.children[0]);return r?!r||r.startsWith(":")?[]:e.children.slice(1).flatMap(n=>kr(n,li(t,r))):e.children.flatMap(n=>kr(n,t))}return[]}function Pp(e,t){let r=U(e.children[0]);if(!r||r.startsWith(":"))return[];let n={namespace:li(t,r),alias:null,refers:[],referAll:!1};for(let i=1;i<e.children.length;i+=1){let o=U(e.children[i]);if(!o?.startsWith(":"))continue;let s=e.children[i+1];if((o===":as"||o===":as-alias")&&s){n.alias=U(s),i+=1;continue}o===":refer"&&s&&(U(s)===":all"?n.referAll=!0:(s.type==="vector"||s.type==="list")&&n.refers.push(...s.children.map(U).filter(Np)),i+=1)}return[n]}function kp(e){let t=[];for(let r of e){if(r.type==="atom"){let i=r.text.split(".").pop()??r.text;t.push(ae(i,i,null,!0));continue}if(r.type!=="vector")continue;let n=U(r.children[0]);if(n)for(let i of r.children.slice(1)){let o=U(i);o&&t.push(ae(`${n}.${o}`,o,null,!0))}}return t}function li(e,t){return e?`${e}.${t}`:t}function U(e){return e?.type==="atom"?e.text:null}function Np(e){return!!(e&&!e.startsWith(":"))}function _p(e,t){let r=new Set,n=new RegExp(`${ui()}${Oe(t)}\\s*/\\s*([${di}]+)`,"g");for(let i of e.matchAll(n)){let o=i[1];o&&r.add(o)}return[...r]}function Dp(e,t){return new RegExp(`${ui()}${Oe(t)}\\s*/`,"m").test(e)}function Ap(e,t){return new RegExp(`${ui()}${Oe(t)}(?![${di}])`,"m").test(e)}function ui(){return`(?<![${di}])`}function Lp(e,t,r){let n="",i=0;for(;i<e.length;){if(i>=t&&i<r){n+=e[i]===`
|
|
124
|
+
`?`
|
|
125
|
+
`:" ",i+=1;continue}let o=e[i];if(o===";"){let s=Cr(e,i);n+=Js(e.slice(i,s)),i=s;continue}if(o==='"'){let s=Dt(e,i,0).index;n+=Js(e.slice(i,s)),i=s;continue}n+=o,i+=1}return n}function Fp(e){let t=0;for(;t<e.length&&(t=pi(e,t),!(t>=e.length));){let r=Nr(e,t);if(!r){t+=1;continue}if(Tp(r.form))return r.form;t=r.index}return null}function Nr(e,t){let r=pi(e,t);if(e.startsWith("#?@",r)||e.startsWith("#?",r))return Op(e,r);if(e.startsWith("#_",r)){let i=Nr(e,r+2);return i?{form:{type:"atom",text:"",start:r,end:i.index},index:i.index}:null}for(;oi(e[r]);)r+=1;let n=e[r];return n?n==="("?ci(e,r,"list",")"):n==="["?ci(e,r,"vector","]"):n==="{"?ci(e,r,"map","}"):n==='"'?{form:{type:"atom",text:"",start:r,end:Dt(e,r,0).index},index:Dt(e,r,0).index}:Mp(e,r):null}function Op(e,t){let r=e.startsWith("#?@",t)?3:2,n=Nr(e,t+r);return n?{form:{type:"list",children:n.form.type==="list"||n.form.type==="vector"||n.form.type==="map"?jp(n.form.children):[],start:t,end:n.index},index:n.index}:null}function jp(e){let t=[];for(let r=0;r<e.length;r+=2){let n=U(e[r]),i=e[r+1];n?.startsWith(":")&&i&&t.push(i)}return t}function ci(e,t,r,n){let i=[],o=t+1;for(;o<e.length;){if(o=pi(e,o),e[o]===n)return{form:{type:r,children:i,start:t,end:o+1},index:o+1};let s=Nr(e,o);if(!s){o+=1;continue}s.form.type==="atom"&&s.form.text===""||i.push(s.form),o=s.index}return{form:{type:r,children:i,start:t,end:e.length},index:e.length}}function Mp(e,t){let r=t;for(;r<e.length&&!si(e[r]);)r+=1;return{form:{type:"atom",text:e.slice(t,r),start:t,end:r},index:r}}function pi(e,t){let r=t;for(;r<e.length;){let n=e[r];if(/\s|,/.test(n)){r+=1;continue}if(n===";"){r=Cr(e,r);continue}break}return r}function Js(e){return e.replace(/[^\r\n]/g," ")}function Zs(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*import\s+['"]([^'"]+)['"](?:\s+as\s+([A-Za-z_]\w*))?[\s\S]*?;$/gm)){let o=i[1]?.trim(),s=i[2]?.trim()??null,a=i[0];if(!o||!a||typeof i.index!="number")continue;let c=xe(r,i.index,i.index+a.length);n.push({importedName:o,localName:s,sourcePath:xr(e,t,o),kind:s?"namespace":"side-effect",used:s?_(c,s):!0,usedMembers:s?rt(c,s):[]})}return n}function ea(e,t,r){let n=[];for(let i of r.matchAll(/^[ \t]*export\s+['"]([^'"]+)['"][\s\S]*?;$/gm)){let o=i[1]?.trim();o&&n.push({specifier:o,sourcePath:xr(e,t,o)})}return n}function ta(e,t,r){return Pr(e,t,{csharp:n=>$p(e,t,n),vb:n=>Gp(e,t,n)},()=>{let n=Es(t)?/^[ \t]*Imports\s+(.+?)\s*$/gm:/^[ \t]*using\s+(.+?)\s*;$/gm;return B(r,n,(i,o)=>{let s=i[1]?.trim();if(!s)return[];let[a,c]=s.split(/\s*=\s*/),l=!!c,d=(l?c:a)?.trim()??s,u=d.split(".").pop()??d,p=l?a?.trim()??u:u;return[z(e,t,o,d,u,p,I(e,d,he))]})})}function Gp(e,t,r){let n=E(r,new Set(["imports_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("imports_statement")){let s=o.namedChildren.filter(p=>p.type==="namespace_name");if(s.length===0)continue;let a=s[s.length-1],c=s.length>1?s[0]:null,l=a.text,d=l.split(".").pop()??l,u=c?.text??d;i.push(x(d,u,I(e,l,he),n,c?"namespace":"named"))}return i}function $p(e,t,r){let n=E(r,new Set(["using_directive"])),i=[];for(let o of r.rootNode.descendantsOfType("using_directive")){let s=o.namedChildren;if(s.length===0)continue;let a=null,c;s.length>=2&&s[0].type==="identifier"&&(s[1].type==="qualified_name"||s[1].type==="identifier")?(a=s[0],c=s[1]):c=s[s.length-1];let l=c.text,d=l.split(".").pop()??l,u=a?.text??d;i.push(x(d,u,I(e,l,he),n,a?"namespace":"named"))}return i}var qp=C("vue-non-script-identifiers",{clearGroups:["whole-project","source-file"]});function ra(e,t){return qp.get(e,t,()=>{let r=new Set,n=M(e,t);if(!n)return r;let o=n.replace(/<script\b[^>]*>[\s\S]*?<\/script>/g,s=>s.replace(/[^\r\n]/g," ")).replace(/<!--[\s\S]*?-->/g,s=>s.replace(/[^\r\n]/g," ")).replace(/\/\*[\s\S]*?\*\//g,s=>s.replace(/[^\r\n]/g," "));for(let s of o.matchAll(/[A-Za-z_$][\w$]*/g))r.add(s[0]);return r})}function fi(e,t,r){return V(e,t,n=>Vp(e,t,n),()=>Bp(e,t,r))}function Bp(e,t,r){return ef(r).flatMap(n=>tf(e,t,n.clause,n.specifier,n.start,n.end,r))}function Vp(e,t,r){let n=Up(e,t,r),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))i.push(...Wp(e,t,r,o,n));return i}function Up(e,t,r){let n=E(r,new Set(["import_statement"]));if(Me(t))for(let i of ra(e,t))n.add(i);return n}function Wp(e,t,r,n,i){let o=Yp(n);if(!o)return[];let s=Se(e,t,o),a=G(n,"import_clause");return a?Hp(r,a,s,i,Jp(n.text)):[$e("*",s)]}function Hp(e,t,r,n,i){let o=[];for(let s of t.namedChildren)if(s.type==="identifier")o.push(zp(s.text,r,n,i));else if(s.type==="namespace_import"){let a=Kp(e,s,r,n,i);a&&o.push(a)}else s.type==="named_imports"&&o.push(...Xp(s,r,n,i));return o}function zp(e,t,r,n){return x("default",e,t,r,"default",{isTypeOnly:n})}function Kp(e,t,r,n,i){let s=G(t,"identifier")?.text??"";if(!s)return null;let a=Zp(e,s);return qe("*",r,{localName:s,usedMembers:a,isTypeOnly:i,used:a.length>0||n.has(s)})}function Xp(e,t,r,n){let i=[];for(let o of e.namedChildren){if(o.type!=="import_specifier")continue;let s=o.namedChild(0),a=o.namedChild(1);if(!s)continue;let c=s.text,l=a?.text??c;i.push(x(c,l,t,r,"named",{isTypeOnly:n||Qp(o.text)}))}return i}function Yp(e){let t=G(e,"string");if(!t)return null;let r=G(t,"string_fragment");return r?r.text:null}function Jp(e){return/^\s*import\s+type\b/.test(e)}function Qp(e){return/^\s*type\b/.test(e.trim())}function Zp(e,t){let r=new Set;for(let n of e.rootNode.descendantsOfType("member_expression")){let i=n.namedChild(0),o=n.namedChild(1);!i||!o||i.type!=="identifier"||i.text!==t||(o.type==="property_identifier"||o.type==="identifier")&&r.add(o.text)}return[...r]}function ef(e){let t=[],r=/^[ \t]*import\s+([\s\S]*?)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(r)){let o=i[0],s=i[1],a=i[2];!o||!a||typeof i.index!="number"||t.push({clause:s,specifier:a,start:i.index,end:i.index+o.length})}let n=/^[ \t]*import\s+['"]([^'"]+)['"]\s*;?/gm;for(let i of e.matchAll(n)){let o=i[0],s=i[1];!o||!s||typeof i.index!="number"||t.push({clause:null,specifier:s,start:i.index,end:i.index+o.length})}return t.sort((i,o)=>i.start-o.start)}function tf(e,t,r,n,i,o,s){let a=Se(e,t,n),c=xe(s,i,o);return r?rf(r).map(d=>({...d,sourcePath:a})).map(d=>{if(d.kind==="namespace"){let u=rt(c,d.localName);return qe(d.importedName,d.sourcePath,{localName:d.localName,usedMembers:u,used:u.length>0||_(c,d.localName),isTypeOnly:d.isTypeOnly})}return d.kind==="side-effect"?$e(d.importedName,d.sourcePath):ae(d.importedName,d.localName??"",d.sourcePath,d.localName?_(c,d.localName):!1,d.kind,[],{isTypeOnly:d.isTypeOnly})}):[$e("*",a)]}function rf(e){let t=e.trim(),r=/^type\b/.test(t),n=t.replace(/^type\s+/,""),[i,o]=nf(n),s=[];return i&&s.push(...na(i,r)),o&&s.push(...na(o,r)),s}function na(e,t){let r=e.trim();if(!r)return[];if(r.startsWith("{")){let n=r.slice(1,-1).trim();return n?D(n).map(i=>{let o=i.trim(),s=t||/^type\b/.test(o),a=o.replace(/^type\s+/,""),[c,l]=a.split(/\s+as\s+/);return{importedName:c.trim(),localName:(l??c).trim(),kind:"named",isTypeOnly:s}}):[]}return r.startsWith("* as ")?[{importedName:"*",localName:r.slice(5).trim(),kind:"namespace",isTypeOnly:t}]:[{importedName:"default",localName:r,kind:"default",isTypeOnly:t}]}function nf(e){let t=0;for(let r=0;r<e.length;r++){let n=e[r];if(n==="{"&&t++,n==="}"&&t--,n===","&&t===0)return[e.slice(0,r).trim(),e.slice(r+1).trim()]}return[e.trim(),null]}function mi(e,t,r){let n=te(e,t);return n?df(e,t,n):of(e,t,r)}function of(e,t,r){return[...sf(e,t,r),...af(e,t,r),...cf(e,t,r)]}function sf(e,t,r){let n=[],i=/^[ \t]*export\s+(?:type\s+)?\{([\s\S]*?)\}\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=o[2]??"",c=D(s).map(u=>lf(u.trim())).filter(u=>!!u),l=nt(r,o.index),d=nt(r,o.index+o[0].length-1);n.push({kind:"named",sourcePath:Se(e,t,a),names:c,startLine:l,endLine:d})}return n}function af(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+as\s+(\w+)\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[2]??"",a=nt(r,o.index),c=nt(r,o.index+o[0].length-1);n.push({kind:"star-as",sourcePath:Se(e,t,s),names:[],startLine:a,endLine:c})}return n}function cf(e,t,r){let n=[],i=/^[ \t]*export\s+\*\s+from\s+['"]([^'"]+)['"]\s*;?/gm;for(let o of r.matchAll(i)){if(typeof o.index!="number")continue;let s=o[1]??"",a=nt(r,o.index),c=nt(r,o.index+o[0].length-1);n.push({kind:"star",sourcePath:Se(e,t,s),names:[],startLine:a,endLine:c})}return n}function lf(e){if(!e)return null;let t=e.replace(/^type\s+/,"").trim();if(!t)return null;let r=t.match(/^(\w+)\s+as\s+(\w+)$/);if(r)return r[2]??null;let n=t.match(/^(\w+)$/);return n?n[1]??null:null}function nt(e,t){let r=0;for(let n=0;n<t&&n<e.length;n++)e.charCodeAt(n)===10&&r++;return r}function df(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("export_statement")){let o=uf(e,t,i);if(o===void 0)continue;let s=i.startPosition.row,a=i.endPosition.row,c=pf(i,o,s,a);n.push(c)}return n}function uf(e,t,r){let n=G(r,"string");if(!n)return;let i=G(n,"string_fragment");if(i)return Se(e,t,i.text)}function pf(e,t,r,n){let i=G(e,"export_clause");if(i){let s=[];for(let a of i.namedChildren){if(a.type!=="export_specifier")continue;let c=a.namedChild(0),l=a.namedChild(1);c&&s.push((l??c).text)}return{kind:"named",sourcePath:t,names:s,startLine:r,endLine:n}}return G(e,"namespace_export")?{kind:"star-as",sourcePath:t,names:[],startLine:r,endLine:n}:{kind:"star",sourcePath:t,names:[],startLine:r,endLine:n}}function ia(e,t,r){return Pr(e,t,{java:n=>ff(e,t,n),kotlin:n=>mf(e,t,n),scala:n=>gf(e,t,n)},()=>B(r,/^[ \t]*import\s+(?:static\s+)?(.+?)\s*;?$/gm,(n,i)=>{let o=n[1]?.trim();return o?yf(e,t,o,i):[]}))}function ff(e,t,r){let n=E(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.children.some(u=>u.type==="asterisk"),c=o.namedChildren.find(u=>u.type==="scoped_identifier")??o.namedChildren.find(u=>u.type==="identifier");if(!c)continue;let l=c.text;if(s){i.push(qe("*",I(e,l,j)));continue}let d=l.split(".").pop()??l;i.push(x(d,d,I(e,l,j),n))}return i}function mf(e,t,r){let n=E(r,new Set(["import_header","import_list"])),i=[];for(let o of r.rootNode.descendantsOfType("import_header")){let s=o.namedChildren.find(m=>m.type==="identifier");if(!s)continue;let a=o.namedChildren.some(m=>m.type==="wildcard_import"),c=o.namedChildren.find(m=>m.type==="import_alias");if(a){i.push(qe("*",I(e,s.text,j)));continue}let l=s.text,d=l.split(".").pop()??l,p=c?.namedChild(0)?.text??d;i.push(x(d,p,I(e,l,j),n))}return i}function gf(e,t,r){let n=E(r,new Set(["import_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("import_declaration")){let s=o.namedChildren.find(u=>u.type==="namespace_selectors"||u.type==="namespace_wildcard"),a=o.namedChildren.filter(u=>u!==s&&(u.type==="identifier"||u.type==="stable_identifier")),c=a.map(u=>u.text).join(".");if(!c)continue;if(s?.type==="namespace_wildcard"){i.push(qe("*",I(e,c,j)));continue}if(s?.type==="namespace_selectors"){for(let u of s.namedChildren)if(u.type==="arrow_renamed_identifier"){let[p,m]=u.namedChildren;if(!p)continue;let g=p.text,T=m?.text??g;if(g==="_")continue;i.push(x(g,T,I(e,`${c}.${g}`,j),n))}else if(u.type==="identifier"){let p=u.text;i.push(x(p,p,I(e,`${c}.${p}`,j),n))}continue}let l=a[a.length-1]?.text??c,d=a.slice(0,-1).map(u=>u.text).join(".")||c;i.push(x(l,l,I(e,d&&a.length>1?`${d}.${l}`:c,j),n))}return i}function yf(e,t,r,n){if(r.includes("{")&&r.includes("}")){let i=r.slice(0,r.indexOf("{")).replace(/\.$/,"").trim(),o=r.slice(r.indexOf("{")+1,r.lastIndexOf("}")).trim();return D(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.includes("=>")?a.split(/\s*=>\s*/):a.split(/\s+as\s+/),d=c?.trim();if(!d||d==="_")return[];let u=(l??d.split(".").pop()??d).trim(),p=d==="_"?i:`${i}.${d}`.replace(/\.\./g,".");return[z(e,t,n,p,d,u)]})}return[z(e,t,n,r,r.split(".").pop()??r,r.split(".").pop()??r)]}function sa(e,t,r){return V(e,t,n=>hf(e,t,n),()=>B(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?D(o).flatMap(s=>{let a=s.trim();if(!a)return[];let[c,l]=a.split(/\s+as\s+/i),d=c?.trim()??a,u=d.split("\\").pop()??d,p=(l??u).trim();return[z(e,t,i,d,u,p,I(e,d.replace(/\\/g,"."),Fe))]}):[]}))}function hf(e,t,r){let n=E(r,new Set(["namespace_use_declaration"])),i=[],o=(s,a,c)=>{i.push(x(a,c,I(e,s.replace(/\\/g,"."),Fe),n))};for(let s of r.rootNode.descendantsOfType("namespace_use_declaration")){let a=s.namedChildren.find(c=>c.type==="namespace_use_group");if(a){let c=s.namedChildren.find(l=>l.type==="namespace_name")?.text??"";for(let l of a.namedChildren){if(l.type!=="namespace_use_clause")continue;let{importedName:d,localName:u,qualified:p}=oa(l,c);d&&o(p,d,u)}continue}for(let c of s.namedChildren){if(c.type!=="namespace_use_clause")continue;let{importedName:l,localName:d,qualified:u}=oa(c,"");l&&o(u,l,d)}}return i}function oa(e,t){let r=e.namedChildren.find(l=>l.type==="qualified_name"),n=e.namedChildren.filter(l=>l.type==="name"),i="";r?i=r.text:n.length>=1&&(i=n[0].text);let o=r&&n.length>0?n[n.length-1]:null,s=i.split("\\").pop()??i,a=o?.text??s,c=t?`${t}\\${i}`:i;return{importedName:s,localName:a,qualified:c}}function ca(e,t,r){return V(e,t,n=>Sf(e,t,n),()=>xf(r).flatMap(n=>Ef(e,t,n,r)))}function Sf(e,t,r){let n=E(r,new Set(["import_statement","import_from_statement"])),i=[];for(let o of r.rootNode.descendantsOfType("import_statement"))for(let s of o.namedChildren){let a=aa(s);if(!a)continue;let c=tt(e,t,a.qualifiedName);i.push({importedName:a.qualifiedName,localName:a.localName,sourcePath:c,kind:"namespace",used:n.has(a.localName),usedMembers:[]})}for(let o of r.rootNode.descendantsOfType("import_from_statement")){let s=o.namedChild(0);if(!s)continue;let a=bf(s);if(a===null)continue;let c=tt(e,t,a);for(let l=1;l<o.namedChildCount;l+=1){let d=o.namedChild(l);if(d.type==="wildcard_import"){i.push({importedName:"*",localName:null,sourcePath:c,kind:"side-effect",used:!0,usedMembers:[]});continue}let u=aa(d);u&&i.push({importedName:u.qualifiedName,localName:u.localName,sourcePath:c,kind:"named",used:n.has(u.localName),usedMembers:[]})}}return i}function aa(e){if(e.type==="aliased_import"){let t=e.namedChild(0),r=e.namedChild(1);return!t||!r?null:{qualifiedName:t.text,localName:r.text}}if(e.type==="dotted_name"){let t=e.text;return{qualifiedName:t,localName:t.split(".")[0]??t}}return e.type==="identifier"?{qualifiedName:e.text,localName:e.text}:null}function bf(e){if(e.type==="dotted_name")return e.text;if(e.type==="relative_import"){let t=G(e,"import_prefix")?.text??"",r=G(e,"dotted_name")?.text??"";return`${t}${r}`}return null}function xf(e){let t=e.split(`
|
|
126
|
+
`),r=[],n=0;for(let i=0;i<t.length;i++){let o=t[i],s=o.trimStart(),a=n;if(n+=o.length+1,!s.startsWith("import ")&&!s.startsWith("from "))continue;let c=o,l=a+o.length,d=ei(o);for(;i+1<t.length&&(d>0||c.trimEnd().endsWith("\\"));){i++;let p=t[i];c+=`
|
|
127
|
+
${p}`,l+=1+p.length,d+=ei(p),n+=p.length+1}let u=If(c);u&&r.push({...u,start:a,end:l})}return r}function If(e){let t=e.replace(/\\\s*\n/g," ").trim();if(t.startsWith("import "))return{kind:"import",module:null,clause:t.slice(7).trim()};let r=t.match(/^from\s+([.\w]+)\s+import\s+([\s\S]+)$/);if(!r)return null;let n=r[2].trim();return n.startsWith("(")&&n.endsWith(")")&&(n=n.slice(1,-1).trim()),{kind:"from",module:r[1],clause:n}}function Ef(e,t,r,n){let i=xe(n,r.start,r.end),o=r.clause.replace(/\n/g," ").trim();if(r.kind==="import")return D(o).flatMap(c=>{let l=c.trim().replace(/,$/,"");if(!l)return[];let[d,u]=l.split(/\s+as\s+/),p=d.trim(),m=(u??p.split(".")[0]??p).trim(),g=tt(e,t,p),T=rt(i,m);return[{importedName:p,localName:m,sourcePath:g,kind:"namespace",used:_(i,m)||T.length>0,usedMembers:T}]});let s=r.module?tt(e,t,r.module):null,a=[];for(let c of D(o)){let l=c.trim().replace(/,$/,"");if(!l)continue;if(l==="*"){a.push({importedName:"*",localName:null,sourcePath:s,kind:"side-effect",used:!0,usedMembers:[]});continue}let[d,u]=l.split(/\s+as\s+/),p=(u??d).trim();a.push({importedName:d.trim(),localName:p,sourcePath:s,kind:"named",used:_(i,p),usedMembers:[]})}return a}import{basename as vf}from"path";function la(e,t,r){return V(e,t,n=>Tf(e,t,n),()=>Rf(e,t,r))}function Rf(e,t,r){return B(r,/^[ \t]*(require_relative|require)\s+["']([^"']+)["']\s*$/gm,(n,i)=>{let o=n[1],s=n[2];if(!o||!s)return[];let a=o==="require_relative"?Sr(e,t,s):null;if(a){let c=da(s);return[ae(c,c,a,_(i,c))]}return[$e(s,a)]})}function Tf(e,t,r){let n=E(r,new Set([])),i=[],o=new Set(["require","require_relative","load"]);for(let s of r.rootNode.descendantsOfType("call")){let a=s.namedChild(0);if(!a||a.type!=="identifier"||!o.has(a.text))continue;let l=s.namedChildren.find(m=>m.type==="argument_list")?.namedChild(0);if(!l||l.type!=="string")continue;let u=l.namedChildren.find(m=>m.type==="string_content")?.text;if(!u)continue;let p=a.text==="require_relative"?Sr(e,t,u):null;if(p){let m=da(u);i.push(x(m,m,p,n))}else i.push($e(u,p))}return i}function da(e){return Ks(vf(e).replace(/\.[^.]+$/,""),/_/)}function ua(e,t,r){return V(e,t,n=>wf(e,t,n),()=>B(r,/^[ \t]*use\s+(.+?)\s*;$/gm,(n,i)=>{let o=n[1]?.trim();return o?Cf(e,t,o,i):[]}))}function wf(e,t,r){let n=E(r,new Set(["use_declaration"])),i=[];for(let o of r.rootNode.descendantsOfType("use_declaration")){let s=o.namedChild(0);if(s)for(let a of At(s,"")){if(!a.importedName||a.importedName==="*")continue;let c=oe(e,t,a.qualifiedName)??oe(e,t,a.qualifiedName.split("::").slice(0,-1).join("::"));i.push(x(a.importedName,a.localName,c,n))}}return i}function At(e,t){switch(e.type){case"identifier":case"super":case"crate":{let r=e.text;return[{qualifiedName:_r(t,r),importedName:r,localName:r}]}case"self":{let r=t.split("::").filter(Boolean).pop()??"self";return[{qualifiedName:t||"self",importedName:r,localName:r}]}case"scoped_identifier":{let r=e.text,n=r.split("::").pop()??r;return[{qualifiedName:_r(t,r),importedName:n,localName:n}]}case"scoped_use_list":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=_r(t,r.text),o=[];for(let s of n.namedChildren)o.push(...At(s,i));return o}case"use_list":{let r=[];for(let n of e.namedChildren)r.push(...At(n,t));return r}case"use_as_clause":{let r=e.namedChild(0),n=e.namedChild(1);if(!r||!n)return[];let i=At(r,t),o=n.text;return i.map(s=>({...s,localName:o}))}case"use_wildcard":{let r=e.namedChild(0),n=r?r.text:"";return[{qualifiedName:_r(t,`${n}::*`),importedName:"*",localName:"*"}]}default:return[]}}function _r(e,t){return e?t?`${e}::${t}`:e:t}function Cf(e,t,r,n){let i=r.trim();if(i.includes("{")&&i.includes("}")){let d=i.slice(0,i.indexOf("{")).replace(/::$/,"").trim(),u=i.slice(i.indexOf("{")+1,i.lastIndexOf("}")).trim();return D(u).flatMap(p=>{let m=p.trim();if(!m)return[];if(m==="self"){let Dr=d.split("::").filter(Boolean).pop();return Dr?[z(e,t,n,d,Dr,Dr)]:[]}let[g,T]=m.split(/\s+as\s+/),b=g?.trim();if(!b)return[];let it=(T??b.split("::").pop()??b).trim(),ya=`${d}::${b}`.replace(/::::/g,"::");return[z(e,t,n,ya,b.split("::").pop()??b,it,oe(e,t,d))]})}let[o,s]=i.split(/\s+as\s+/),a=o?.trim()??i,c=(s??a.split("::").pop()??a).trim(),l=oe(e,t,a)??oe(e,t,a.split("::").slice(0,-1).join("::"));return[z(e,t,n,a,a.split("::").pop()??a,c,l)]}function pa(e,t,r){let n=te(e,t);if(n)return Pf(e,t,n);let i=[];for(let o of r.matchAll(/^[ \t]*pub\s+use\s+(.+?)\s*;$/gm)){let s=o[1]?.trim();s&&i.push(...Nf(e,t,s))}return i}function Pf(e,t,r){let n=[];for(let i of r.rootNode.descendantsOfType("use_declaration")){if(!kf(i))continue;let o=i.namedChildren.find(s=>s.type!=="visibility_modifier");if(o)for(let s of At(o,""))s.importedName&&n.push(gi(e,t,s.qualifiedName))}return n}function kf(e){for(let t of e.children)if(t.type==="visibility_modifier"&&t.text.startsWith("pub"))return!0;return!1}function Nf(e,t,r){let n=r.trim();if(n.includes("{")&&n.includes("}")){let i=n.slice(0,n.indexOf("{")).replace(/::$/,"").trim(),o=n.slice(n.indexOf("{")+1,n.lastIndexOf("}")).trim();return D(o).flatMap(s=>{let a=s.trim();if(!a||a==="self")return[];let[c]=a.split(/\s+as\s+/),l=`${i}::${c?.trim()??a}`.replace(/::::/g,"::");return[gi(e,t,l)]})}return[gi(e,t,n)]}function gi(e,t,r){return{specifier:r,sourcePath:oe(e,t,r)??oe(e,t,r.split("::").slice(0,-1).join("::"))}}function Ie({language:e,extensions:t,imports:r,parseImports:n}){return{language:e,extensions:t,capabilities:{imports:r},parseImports:n}}function fa(e,t){let r=t.toLowerCase();for(let n of e)for(let i of n.extensions)if(r.endsWith(i))return n;return null}var _f={language:"javascript",extensions:Ae,capabilities:{imports:"ast-with-regex-fallback",reExports:"ast-with-regex-fallback"},parseImports:fi,parseReExports:mi},Df=Ie({language:"python",extensions:fr,imports:"ast-with-regex-fallback",parseImports:ca}),Af=Ie({language:"jvm",extensions:j,imports:"ast-dispatch-with-regex-fallback",parseImports:ia}),Lf={language:"rust",extensions:mr,capabilities:{imports:"ast-with-regex-fallback",exports:"ast-with-regex-fallback"},parseImports:ua,parseExports:pa},Ff=Ie({language:"ruby",extensions:gr,imports:"ast-with-regex-fallback",parseImports:la}),Of=Ie({language:"c/cpp",extensions:yr,imports:"ast-with-regex-fallback",parseImports:Ys}),jf=Ie({language:"dotnet",extensions:he,imports:"ast-dispatch-with-regex-fallback",parseImports:ta}),Mf={language:"dart",extensions:hr,capabilities:{imports:"regex-only",exports:"regex-only"},parseImports:Zs,parseExports:ea},Gf=Ie({language:"php",extensions:Fe,imports:"ast-with-regex-fallback",parseImports:sa}),$f=Ie({language:"clojure",extensions:et,imports:"regex-only",parseImports:Qs}),qf=[_f,Df,Af,Lf,Ff,Of,jf,Mf,Gf,$f];function yi(e){return fa(qf,e)}var hi={clearGroups:["whole-project","source-file"]},Bf=C("source-imports",hi),Jb=C("source-exports",hi),Vf=C("source-reexports",hi),ma=Tt({kind:"source-imports",invalidation:wt("source-imports"),serialize:Uf,deserialize:Wf}),ga=Tt({kind:"source-reexports",invalidation:wt("source-reexports"),serialize:Hf,deserialize:zf});function Qb(e,t){let r=k(t);return Vf.get(e,r,()=>{let n=yi(r);if(!n?.parseReExports)return[];let i=M(e,r);if(!i)return[];let o=dt(e,r,i),s=Zn(e),a=ga.read(e,r,o);if(a?.resolutionFingerprint===s)return a.reExports;let c=n.parseReExports(e,r,i);return ga.write(e,r,o,{resolutionFingerprint:s,reExports:c}),c})}function Zb(e,t){let r=k(t);return Bf.get(e,r,()=>{let n=yi(r);if(!n)return[];let i=M(e,r);if(!i)return[];let o=dt(e,r,i),s=Zn(e),a=ma.read(e,r,o);if(a?.resolutionFingerprint===s)return a.imports;let c=n.parseImports(e,r,i);return ma.write(e,r,o,{resolutionFingerprint:s,imports:c}),c})}function Uf(e){return JSON.stringify(e)}function Wf(e){try{let t=JSON.parse(e);return!an(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.imports)?null:{resolutionFingerprint:t.resolutionFingerprint,imports:t.imports}}catch{return null}}function Hf(e){return JSON.stringify(e)}function zf(e){try{let t=JSON.parse(e);return!an(t)||typeof t.resolutionFingerprint!="string"||!Array.isArray(t.reExports)?null:{resolutionFingerprint:t.resolutionFingerprint,reExports:t.reExports}}catch{return null}}export{qi as a,Ee as b,ue as c,fm as d,Ma as e,mm as f,Mi as g,Vr as h,Wr as i,om as j,sm as k,zr as l,zi as m,cc as n,lc as o,km as p,zt as q,ve as r,Xi as s,Re as t,Wm as u,wc as v,Hm as w,Ce as x,er as y,dt as z,io as A,eg as B,Tt as C,Jy as D,wt as E,gs as F,Gd as G,Se as H,an as I,rg as J,M as K,vh as L,Oe as M,te as N,fp as O,xp as P,Qb as Q,Zb as R,wd as S,Zy as T,Pd as U,rh as V,nh as W,ih as X,sh as Y,ag as Z,mg as _,Ig as $,Eg as aa,Ag as ba,Lg as ca,Fg as da,Og as ea,Ug as fa,Wg as ga,Hg as ha,zg as ia,Vo as ja,Ml as ka,oy as la,wn as ma,Ly as na,Fy as oa,Oy as pa,Et as qa,jy as ra,My as sa,Gy as ta,cd as ua,ld as va,Uy as wa,Wy as xa,Bi as ya,Im as za,Em as Aa,vm as Ba};
|
|
128
|
+
//# sourceMappingURL=chunk-HZ72SESS.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{c as D}from"./chunk-
|
|
1
|
+
import{c as D}from"./chunk-Z4N3MZYA.js";import{o as R}from"./chunk-7O5IKBTZ.js";import{a as M,c as N}from"./chunk-T7YQSHPQ.js";import{d as b,f as g,s as S,z as I}from"./chunk-EKZTZXHZ.js";import{x as p}from"./chunk-GH74ASD6.js";function C(o,n,l={}){let{maxDepth:u=5,scope:m}=l,i=M(o,n);if(!i)return[];let c=[],d=new Set([i.symbolId]),a=new Set,r=[i];for(let e=1;e<=u&&r.length!==0;e++){let t=[],f=D(o,r,{limit:500,semanticEvidence:R});for(let y of r)for(let s of w(o,y,m,f.get(y.symbolId)??[])){let h=`${s.file}|${s.shortName}`;if(s.symbolId!==null){if(d.has(s.symbolId))continue;d.add(s.symbolId)}else if(a.has(h))continue;a.add(h),c.push({symbol:s.symbol,shortName:s.shortName,file:s.file,depth:e}),s.symbolId!==null&&s.symbolMatch&&t.push(s.symbolMatch)}r=t}return c.sort((e,t)=>e.depth-t.depth||e.file.localeCompare(t.file)),c}function w(o,n,l,u){let m=u.filter(e=>!o.isIgnored(e.file)).filter(e=>!l||e.file.includes(l)),i=new Set(m.map(e=>e.file)),c=[];for(let e of A(o,n,l)){if(i.has(e))continue;let t=S(o,e),f=t.length>0?I(t,t[0].startLine):null;c.push({symbol:f?.symbol??e,file:e})}let d=[...m,...c],a=[],r=new Set;for(let e of d){let t=N(o,e.symbol);if(!t){let y=`${e.file}|${e.symbol}`;if(r.has(y))continue;r.add(y),a.push({symbolId:null,symbol:e.symbol,shortName:b(e.symbol),file:e.file,symbolMatch:null});continue}if(t.symbolId===n.symbolId||o.isIgnored(t.relativePath)||!_(t))continue;let f=`${t.symbolId}|${t.relativePath}`;r.has(f)||(r.add(f),a.push({symbolId:t.symbolId,symbol:t.symbol,shortName:b(t.symbol),file:t.relativePath,symbolMatch:t}))}return a}function A(o,n,l){let u=l?"AND consumer_d.relative_path LIKE ?":"",m=[n.symbolId,n.documentId];return l&&m.push(`%${l}%`),new Set(o.all(`SELECT DISTINCT consumer_d.relative_path
|
|
2
2
|
FROM mentions m
|
|
3
3
|
JOIN chunks c ON m.chunk_id = c.id
|
|
4
4
|
JOIN documents consumer_d ON consumer_d.id = c.document_id
|
|
@@ -7,4 +7,4 @@ import{c as D}from"./chunk-KXDJAG4N.js";import{n as R}from"./chunk-GLZTVKAB.js";
|
|
|
7
7
|
AND c.document_id != ?
|
|
8
8
|
${o.pathExclusionsFor("consumer_d")}
|
|
9
9
|
${u}`,...m).map(i=>i.relative_path).filter(i=>!o.isIgnored(i)))}function _(o){if(o.symbol.startsWith("scip-clojure ")||p(o.relativePath)==="clojure")return!0;let n=g(o.symbol);return n==="method"||n==="type"||o.symbol.endsWith("().")}export{C as a};
|
|
10
|
-
//# sourceMappingURL=chunk-
|
|
10
|
+
//# sourceMappingURL=chunk-IB2N4FIY.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e=Symbol("no-error");async function h(n,r,i){if(n.length===0)return[];let t=new Array(n.length),o=Number.isFinite(r)?Math.max(1,Math.floor(r)):1,a=Math.min(n.length,o),l=0,s=e,u=!0,f=Array.from({length:a},async()=>{for(;u&&l<n.length;){let c=l++;try{t[c]=await i(n[c])}catch(w){s===e&&(s=w),u=!1}}});if(await Promise.all(f),s!==e)throw s;return t}async function m(n){let r=e,i=n.map(o=>o.catch(a=>{throw r===e&&(r=a),a})),t=await Promise.allSettled(i);if(r!==e)throw r;return t.map(o=>o.value)}export{h as a,m as b};
|
|
2
|
+
//# sourceMappingURL=chunk-ILMHV3KM.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{c as f,d as p}from"./chunk-MNE7YG56.js";import{execFileSync as w}from"child_process";import{platform as I}from"os";var b=1e3,T=2*1024*1024,M=25;function v(e,n,r=S){let t=r.readIdentity(e),o=new Map;return t&&o.set(e,t),{rootPid:e,rootIdentity:t,ownsProcessGroup:n,knownMembers:o}}async function k(e,n,r=S){if(!e.rootIdentity){let a=await l(e,n.gracefulMs+n.forceMs,r);return{reaped:a,reason:a?"terminated":"identity-unavailable",detail:a?void 0:`Could not establish the birth identity of process ${e.rootPid}.`}}let t=g(e,r);if(t==="mismatch")return{reaped:!1,reason:"identity-mismatch",detail:`Process ${e.rootPid} no longer has the identity owned by this runner.`};if(t==="exited"&&!h(e,r))return{reaped:!0,reason:"terminated"};if(r.platform==="win32"){try{r.terminateWindowsTree(e.rootPid)}catch(u){let c=await l(e,n.forceMs,r);return{reaped:c,reason:c?"terminated":"signal-failed",detail:c?void 0:m(u)}}let a=await l(e,n.forceMs,r);return{reaped:a,reason:a?"terminated":"deadline"}}let o=P(e,"SIGTERM",r);if(await l(e,n.gracefulMs,r))return{reaped:!0,reason:"terminated"};let s=P(e,"SIGKILL",r);return await l(e,n.forceMs,r)?{reaped:!0,reason:"terminated"}:s?{reaped:!1,reason:s.reason,detail:s.detail}:o?{reaped:!1,reason:o.reason,detail:o.detail}:{reaped:!1,reason:"deadline",detail:`Process tree ${e.rootPid} did not exit before its termination deadline.`}}function g(e,n){let r=n.readIdentity(e.rootPid);if(!r)return"exited";if(!e.rootIdentity||!f(e.rootIdentity,r))return"mismatch";e.knownMembers.set(e.rootPid,r);for(let t of n.listDescendantPids(e.rootPid)){let o=n.readIdentity(t);o&&e.knownMembers.set(t,o)}return"owned"}function P(e,n,r){let t=g(e,r);if(t==="mismatch")return{reason:"identity-mismatch",detail:`Process ${e.rootPid} changed identity before ${n}.`};if(t==="owned"&&e.ownsProcessGroup)try{return r.signal(-e.rootPid,n),null}catch(i){if(!y(i))return{reason:"signal-failed",detail:m(i)}}let o=null;for(let i of e.knownMembers.values()){let s=r.readIdentity(i.pid);if(!(!s||!f(i,s)))try{r.signal(i.pid,n)}catch(d){!y(d)&&o===null&&(o=m(d))}}return o===null?null:{reason:"signal-failed",detail:o}}async function l(e,n,r){let t=r.now()+n;for(;h(e,r);){if(r.now()>=t)return!1;await r.sleep(Math.min(M,Math.max(1,t-r.now())))}return!0}function h(e,n){if(!e.rootIdentity&&n.isProcessAlive(e.rootPid))return!0;for(let r of e.knownMembers.values()){let t=n.readIdentity(r.pid);if(t&&f(r,t))return!0}return!!(e.ownsProcessGroup&&n.isProcessGroupAlive(e.rootPid))}function R(e){let n=w("ps",["-axo","pid=,ppid="],{encoding:"utf8",timeout:b,maxBuffer:T,env:{...process.env,LC_ALL:"C",LANG:"C"},stdio:["ignore","pipe","ignore"]}),r=new Map;for(let s of n.split(/\r?\n/)){let d=/^\s*(\d+)\s+(\d+)\s*$/.exec(s);if(!d)continue;let a=Number(d[1]),u=Number(d[2]),c=r.get(u)??[];c.push(a),r.set(u,c)}let t=[],o=[...r.get(e)??[]],i=new Set;for(;o.length>0;){let s=o.pop();i.has(s)||(i.add(s),t.push(s),o.push(...r.get(s)??[]))}return t}function y(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ESRCH"}function m(e){return e instanceof Error?e.message:String(e)}var S={platform:I(),now:Date.now,readIdentity:p,isProcessAlive(e){try{return process.kill(e,0),!0}catch(n){return typeof n=="object"&&n!==null&&"code"in n&&n.code==="EPERM"}},isProcessGroupAlive(e){if(this.platform==="win32")return!1;try{return process.kill(-e,0),!0}catch(n){return typeof n=="object"&&n!==null&&"code"in n&&n.code==="EPERM"}},listDescendantPids(e){if(this.platform==="win32")return[];try{return R(e)}catch{return[]}},signal(e,n){process.kill(e,n)},terminateWindowsTree(e){w("taskkill.exe",["/PID",String(e),"/T","/F"],{timeout:b,maxBuffer:T,stdio:"ignore",windowsHide:!0})},async sleep(e){await new Promise(n=>setTimeout(n,e))}};export{v as a,k as b};
|
|
2
|
+
//# sourceMappingURL=chunk-IZYYAFN5.js.map
|