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
package/dist/runtime.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { P as ProjectConfig, a as SupportedLanguage, T as TypeScriptProjectMode } from './config-types-
|
|
1
|
+
import { P as ProjectConfig, a as SupportedLanguage, T as TypeScriptProjectMode } from './config-types-jVM3D7MA.js';
|
|
2
|
+
export { O as OBSERVATION_RECEIPT_SCHEMA_VERSION, b as ObservationAuthorityKind, c as ObservationReceipt, d as ObservationReceiptComparison, e as compareObservationReceipts, i as isObservationReceipt } from './config-types-jVM3D7MA.js';
|
|
2
3
|
import { watch } from 'chokidar';
|
|
3
|
-
import { R as RefreshTrigger, W as WatcherStatus } from './scip-cli-
|
|
4
|
-
export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-
|
|
4
|
+
import { R as RefreshTrigger, W as WatcherStatus } from './scip-cli-BnEwZRLJ.js';
|
|
5
|
+
export { g as getScipVersion, i as isScipInstalled, p as printScipInstallInstructions } from './scip-cli-BnEwZRLJ.js';
|
|
5
6
|
|
|
6
7
|
declare function resolveIndexStoragePaths(projectRoot: string, config?: ProjectConfig): {
|
|
7
8
|
cacheDir: string;
|
|
@@ -28,6 +29,7 @@ interface WatcherOptions {
|
|
|
28
29
|
reindexRunner?: ReindexRunner;
|
|
29
30
|
subscriptionFactory?: WatchSubscriptionFactory;
|
|
30
31
|
clock?: WatchClock;
|
|
32
|
+
stopTimeoutMs?: number;
|
|
31
33
|
onStatus?: (status: WatcherStatus) => void;
|
|
32
34
|
onReindexComplete?: (durationMs: number, trigger: RefreshTrigger) => boolean | void;
|
|
33
35
|
onReindexError?: (error: Error, trigger: RefreshTrigger) => void;
|
package/dist/runtime.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`}import{createHash as Y}from"crypto";import{closeSync as Ee,fstatSync as K,openSync as we,rmSync as be}from"fs";import{dirname as ke}from"path";var Pe=2e3,Te=10,_e=3,x=class extends Error{constructor(r,n,i){super(`Concurrent edit detected for ${r}; expected revision ${X(n)}, but found ${X(i)}. The latest file was left untouched.`);this.path=r;this.original=n;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function Q(t,e,r={}){let n=Ie(t,r.lockTimeoutMs??Pe,r.monotonicNow??C);try{let i=Math.max(0,Math.floor(r.maxRetries??_e));for(let s=0;;s+=1){let o=S(t),l=e(o,s);if(l.kind==="unchanged")return{changed:!1,attempts:s+1,previous:o,current:o};r.onBeforeCommit?.({attempt:s,snapshot:o,mutation:l});let c=S(t);if(!Oe(o.revision,c.revision)){if(s<i)continue;throw new x(t,o.revision,c.revision)}try{je(t,l,o.revision)}catch(u){if(u.code==="EEXIST"){let d=S(t);if(s<i)continue;throw new x(t,o.revision,d.revision)}throw u}return{changed:!0,attempts:s+1,previous:o,current:S(t)}}}finally{n.release()}}function S(t){for(let e=0;e<4;e+=1){let r;try{r=we(t,"r");let n=z(K(r)),i=$(r,{maxBytes:M,inputKind:"revisioned text file"}),s=z(K(r));if(!Z(n,s))continue;return{path:t,text:i,revision:{exists:!0,hash:Y("sha256").update(i).digest("hex"),identity:s}}}catch(n){if(n.code==="ENOENT")return{path:t,text:"",revision:{exists:!1,hash:Y("sha256").update("").digest("hex")}};throw n}finally{r!==void 0&&Ee(r)}}throw new Error(`Could not read a stable revision of ${t}; the file is changing continuously.`)}function Ie(t,e,r){let n=`${t}.scip-query-write.lock`,i=r()+Math.max(0,e);for(;;){let s=G(n,{kind:"revisioned-file-mutation",detail:{target:t}});if(s.kind==="acquired")return s.lock;if(r()>=i)throw new Error(`Timed out after ${e}ms waiting to update ${t}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Te)}}function je(t,e,r){if(e.kind==="delete"){if(!r.exists)return;be(t),W(ke(t));return}let n=e.mode??r.identity?.mode;r.exists?F(t,e.text,{durability:"durable",mode:n}):L(t,e.text,{durability:"durable",mode:n})}function Oe(t,e){return t.exists===e.exists&&t.hash===e.hash&&(t.identity===void 0?e.identity===void 0:e.identity!==void 0&&Z(t.identity,e.identity))}function z(t){return{dev:t.dev,ino:t.ino,size:t.size,mtimeMs:t.mtimeMs,mode:t.mode&511}}function Z(t,e){return t.dev===e.dev&&t.ino===e.ino&&t.size===e.size&&t.mtimeMs===e.mtimeMs&&t.mode===e.mode}function X(t){return t.exists?t.hash.slice(0,12):"<absent>"}var v=".scipquery.json",te=250,re=0,ne=10*6e4,Me={enabled:!1,debounceMs:te,cooldownMs:re,gitPollMs:2e3,idleTimeoutMs:ne,autoRefresh:!0,ignore:[]};var At=new Set(O);function P(t){let e=ee(t,v);if(!Ne(e))return{};let r;try{r=A(e,{maxBytes:N,inputKind:"scip-query project config"})}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`unable to read ${v} at ${e}: ${i}`,{cause:n})}return Fe(B(r),e,"read").config}function ie(t){return{...Me,...t.watch}}function Ae(t,e){let r=ee(t,v),n={languages:e,watch:{enabled:!0,debounceMs:te,cooldownMs:re,gitPollMs:2e3,idleTimeoutMs:ne,autoRefresh:!0}};return Q(r,i=>i.revision.exists?{kind:"unchanged"}:{kind:"write",text:$e(n)}),r}function $e(t){return H(t)}function Fe(t,e,r){if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="malformed"){let i=r==="read"?`invalid ${v} at ${e}: ${t.reason}`:`Cannot update ${e}: the latest project config is ${t.reason}.`;throw new Error(`${i} The file was left untouched.`)}let n=r==="read"?`invalid ${v} at ${e}`:`Cannot update ${e}: the latest project config is invalid`;throw new Error(`${n} (unsupported ${t.direction} schemaVersion ${t.schemaVersion}; this scip-query reads legacy v${p} and current v${f}). Upgrade scip-query before retrying; the file was left untouched.`)}import{statSync as Le}from"fs";import{basename as We,isAbsolute as Ve,join as De,relative as Ge}from"path";import{watch as qe}from"chokidar";import Je from"ignore";var T=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(e){this.projectRoot=e.projectRoot,this.config=e.config,this.watchConfig=ie(e.config),this.languages=e.languages,this.pnpmWorkspaces=e.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=e.config.indexer?.typescript?.projectMode,this.typescriptProjects=e.config.indexer?.typescript?.projects,this.clojureConfigPath=e.config.indexer?.clojure?.configPath,this.indexerConcurrency=e.config.indexerConcurrency,this.onStatus=e.onStatus??(()=>{}),this.onReindexComplete=e.onReindexComplete??(()=>{}),this.onReindexError=e.onReindexError??(()=>{}),this.onRefreshSuppressed=e.onRefreshSuppressed??(()=>{}),this.onError=e.onError??(r=>console.error(r.message)),this.clock=e.clock??Ue,this.reindexRunner=e.reindexRunner??ce(),this.subscriptionFactory=e.subscriptionFactory??Be,this.gitignoreFilter=D(e.projectRoot),this.extraIgnore=Je(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(e){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(e)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let e=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;return r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"}),this.stopPromise=this.finishStop(e,r).finally(()=>{this.stopInProgress=!1}),this.stopPromise}requestRefresh(e,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(e);return}this.pendingTrigger=se(this.pendingTrigger,e),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(e=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:e,...e?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{this.stopped||this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,e)),this.fsWatchers.push(r)}handleSourceWatcherError(e,r,n){if(n||this.sourcePollingFallbackStarted||!Xe(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==e),e.close();try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(e,r){let n=this.relativeWatchPath(e);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(e){let r=this.relativeWatchPath(e);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||We(r).startsWith(q)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(e){let r=Ve(e)?e:De(this.projectRoot,e);return Ge(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(e){if(this.pendingTrigger=se(this.pendingTrigger,e),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let e=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&e<this.watchConfig.cooldownMs){let s=this.watchConfig.cooldownMs-e;this.dirty=!0;let o=this.wallNow()+s;this.setStatus({state:"cooldown",until:o,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},s);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=this.wallNow();this.setStatus({state:"indexing",startedAt:n});let i=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=i,i.completion.then(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=!1;try{o=this.onReindexComplete(s,r)===!0}catch(l){this.onError(l instanceof Error?l:new Error(String(l)))}if(this.dirty&&!this.stopped){if(o){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let l=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:l,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(s=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let o=s instanceof Error?s:new Error(String(s));this.onReindexError(o,r),this.onError(o),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===i&&(this.activeOperation=null)})}async finishStop(e,r){let n=[],i=r?r.cancel():null,s=await Promise.allSettled(e.map(o=>Promise.resolve().then(()=>o.close())));for(let o of s)o.status==="rejected"&&n.push(`watch subscription close failed: ${String(o.reason)}`);if(i)try{let o=await i;o.state==="degraded"&&n.push(o.reason)}catch(o){n.push(`reindex cancellation failed: ${o instanceof Error?o.message:String(o)}`)}return n.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:n.join("; ")}),{state:"degraded",reasons:n}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(e){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:e}}setStatus(e){this.status=e,this.onStatus(e)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let e=this.lastGitState,r=this.readGitState();if(!e||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let n=e.head!==r.head,i=e.indexPath!==r.indexPath||e.indexMtimeMs!==r.indexMtimeMs||e.indexSize!==r.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let e=w(this.projectRoot,["rev-parse","--git-path","index"]);if(!e)return null;let r=V(this.projectRoot,e),n={head:w(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let i=Le(r);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};function ae(t){let{projectRoot:e,config:r,languages:n,pnpmWorkspaces:i,typescriptProjectMode:s,typescriptProjects:o,clojureConfigPath:l,indexerConcurrency:c,trigger:u}=t,d=P(e),a=Object.keys(d).length>0?d:r,R=b(e,a),E=a.indexer?.typescript,ve=a.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:e,SCIP_REINDEX_OUTPUT_SCIP:R.indexPath,SCIP_REINDEX_OUTPUT_DB:R.dbPath,SCIP_REINDEX_LANGUAGES:(a.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(a.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:E?.pnpmWorkspaces??i?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:E?.projectMode??s,projects:E?.projects??o??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:ve?.configPath??l??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var Ue={now:C,wallNow:()=>Date.now(),setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},Be=(t,e)=>qe(t,e),He=15*6e4,Ye=1e3,Ke=64*1024;function ze(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function oe(t,e){let r=t instanceof Error?t.message:String(t),n=e.stderrTail.trim()||e.stdoutTail.trim();return n?`${r}
|
|
3
|
-
${n}`:r}function
|
|
1
|
+
import{a as B,b as K,c as Y}from"./chunk-RXOXSKY3.js";import{e as k,i as ke,j as Pe,k as Te,o as q,s as J,t as H}from"./chunk-JN4NMBEX.js";import{a as U}from"./chunk-7PIO7NKH.js";import"./chunk-DHEQMPLW.js";import{e as C,g as F,l as D,o as L,p as V,x as w,y as G}from"./chunk-BS2NMXQZ.js";import{a as f,d as N,f as M,g as A,l as $,n as W}from"./chunk-2KAZEZ6M.js";import"./chunk-C3KV2II6.js";import{existsSync as Le}from"fs";import{isAbsolute as Lt,join as ie,relative as Vt,resolve as Gt}from"path";var h=1,g=2,_e="./node_modules/scip-query/docs/schemas/project-config.schema.json";function z(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(a){return{kind:"malformed",reason:`invalid JSON: ${a instanceof Error?a.message:String(a)}`}}if(!f(t))return{kind:"malformed",reason:"project config must be a JSON object"};let r=t.schemaVersion;if(r!==void 0&&!Number.isInteger(r))return{kind:"malformed",reason:"schemaVersion must be an integer"};let n=r===void 0?h:r;if(n!==h&&n!==g)return{kind:"unsupported",schemaVersion:n,direction:n<h?"older":"future"};let i=t.$schema;if(i!==void 0&&(typeof i!="string"||i.trim()===""))return{kind:"malformed",reason:"$schema must be a non-empty string when present"};let o=P(t),s=n!==g||typeof t.$schema!="string";return n===h?{kind:"legacy",sourceVersion:h,config:o,needsMigration:s}:{kind:"supported",sourceVersion:g,config:o,needsMigration:s}}function P(e){let t=e,{$schema:r,schemaVersion:n,...i}=t;return{$schema:typeof r=="string"&&r.trim()!==""?r:_e,schemaVersion:g,...i}}function X(e){return`${JSON.stringify(P(e),null,2)}
|
|
2
|
+
`}import{createHash as Q}from"crypto";import{closeSync as Ie,fstatSync as Z,openSync as Oe,rmSync as je}from"fs";import{dirname as Ne}from"path";var Me=2e3,Ae=10,$e=3,b=class extends Error{constructor(r,n,i){super(`Concurrent edit detected for ${r}; expected revision ${te(n)}, but found ${te(i)}. The latest file was left untouched.`);this.path=r;this.original=n;this.latest=i;this.name="FileRevisionConflictError"}path;original;latest};function re(e,t,r={}){let n=We(e,r.lockTimeoutMs??Me,r.monotonicNow??C);try{let i=Math.max(0,Math.floor(r.maxRetries??$e));for(let o=0;;o+=1){let s=x(e),a=t(s,o);if(a.kind==="unchanged")return{changed:!1,attempts:o+1,previous:s,current:s};r.onBeforeCommit?.({attempt:o,snapshot:s,mutation:a});let c=x(e);if(!De(s.revision,c.revision)){if(o<i)continue;throw new b(e,s.revision,c.revision)}try{Fe(e,a,s.revision)}catch(u){if(u.code==="EEXIST"){let p=x(e);if(o<i)continue;throw new b(e,s.revision,p.revision)}throw u}return{changed:!0,attempts:o+1,previous:s,current:x(e)}}}finally{n.release()}}function x(e){for(let t=0;t<4;t+=1){let r;try{r=Oe(e,"r");let n=ee(Z(r)),i=W(r,{maxBytes:A,inputKind:"revisioned text file"}),o=ee(Z(r));if(!ne(n,o))continue;return{path:e,text:i,revision:{exists:!0,hash:Q("sha256").update(i).digest("hex"),identity:o}}}catch(n){if(n.code==="ENOENT")return{path:e,text:"",revision:{exists:!1,hash:Q("sha256").update("").digest("hex")}};throw n}finally{r!==void 0&&Ie(r)}}throw new Error(`Could not read a stable revision of ${e}; the file is changing continuously.`)}function We(e,t,r){let n=`${e}.scip-query-write.lock`,i=r()+Math.max(0,t);for(;;){let o=F(n,{kind:"revisioned-file-mutation",detail:{target:e}});if(o.kind==="acquired")return o.lock;if(r()>=i)throw new Error(`Timed out after ${t}ms waiting to update ${e}; the file was left untouched.`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,Ae)}}function Fe(e,t,r){if(t.kind==="delete"){if(!r.exists)return;je(e),D(Ne(e));return}let n=t.mode??r.identity?.mode;r.exists?L(e,t.text,{durability:"durable",mode:n}):V(e,t.text,{durability:"durable",mode:n})}function De(e,t){return e.exists===t.exists&&e.hash===t.hash&&(e.identity===void 0?t.identity===void 0:t.identity!==void 0&&ne(e.identity,t.identity))}function ee(e){return{dev:e.dev,ino:e.ino,size:e.size,mtimeMs:e.mtimeMs,mode:e.mode&511}}function ne(e,t){return e.dev===t.dev&&e.ino===t.ino&&e.size===t.size&&e.mtimeMs===t.mtimeMs&&e.mode===t.mode}function te(e){return e.exists?e.hash.slice(0,12):"<absent>"}var S=".scipquery.json",oe=250,se=5e3,ae=10*6e4,Ve={enabled:!1,debounceMs:oe,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:ae,autoRefresh:!0,ignore:[]};var Bt=new Set(N);function T(e){let t=ie(e,S);if(!Le(t))return{};let r;try{r=$(t,{maxBytes:M,inputKind:"scip-query project config"})}catch(n){let i=n instanceof Error?n.message:String(n);throw new Error(`unable to read ${S} at ${t}: ${i}`,{cause:n})}return Je(z(r),t,"read").config}function ce(e){return{...Ve,...e.watch}}function Ge(e,t){return Ue(e,t).configPath}function Ue(e,t){let r=ie(e,S),n={languages:t,watch:{enabled:!0,debounceMs:oe,cooldownMs:se,gitPollMs:2e3,idleTimeoutMs:ae,autoRefresh:!0}},i=re(r,o=>o.revision.exists?{kind:"unchanged"}:{kind:"write",text:qe(n)});return{configPath:r,changed:i.changed}}function qe(e){return X(e)}function Je(e,t,r){if(e.kind==="legacy"||e.kind==="supported")return e;if(e.kind==="malformed"){let i=r==="read"?`invalid ${S} at ${t}: ${e.reason}`:`Cannot update ${t}: the latest project config is ${e.reason}.`;throw new Error(`${i} The file was left untouched.`)}let n=r==="read"?`invalid ${S} at ${t}`:`Cannot update ${t}: the latest project config is invalid`;throw new Error(`${n} (unsupported ${e.direction} schemaVersion ${e.schemaVersion}; this scip-query reads legacy v${h} and current v${g}). Upgrade scip-query before retrying; the file was left untouched.`)}import{statSync as He}from"fs";import{basename as Be,isAbsolute as Ke,join as Ye,relative as ze}from"path";import{watch as Xe}from"chokidar";import Qe from"ignore";var pe=5e3,_=class{projectRoot;config;watchConfig;languages;pnpmWorkspaces;typescriptProjectMode;typescriptProjects;clojureConfigPath;indexerConcurrency;onStatus;onReindexComplete;onReindexError;onRefreshSuppressed;onError;reindexRunner;subscriptionFactory;clock;activeOperation=null;stopPromise=null;stopInProgress=!1;status={state:"idle"};debounceTimer=null;cooldownTimer=null;dirty=!1;changedFiles=0;pendingTrigger=null;reindexInFlight=!1;lastReindexEnd=0;fsWatchers=[];sourcePollingFallbackStarted=!1;gitPollTimer=null;lastGitState=null;gitignoreFilter;extraIgnore;stopped=!1;constructor(t){this.projectRoot=t.projectRoot,this.config=t.config,this.watchConfig=ce(t.config),this.languages=t.languages,this.pnpmWorkspaces=t.config.indexer?.typescript?.pnpmWorkspaces??!1,this.typescriptProjectMode=t.config.indexer?.typescript?.projectMode,this.typescriptProjects=t.config.indexer?.typescript?.projects,this.clojureConfigPath=t.config.indexer?.clojure?.configPath,this.indexerConcurrency=t.config.indexerConcurrency,this.onStatus=t.onStatus??(()=>{}),this.onReindexComplete=t.onReindexComplete??(()=>{}),this.onReindexError=t.onReindexError??(()=>{}),this.onRefreshSuppressed=t.onRefreshSuppressed??(()=>{}),this.onError=t.onError??(r=>console.error(r.message)),this.clock=t.clock??rt,he.set(this,lt(t.stopTimeoutMs??pe,"watcher stop timeout")),this.reindexRunner=t.reindexRunner??ge(),this.subscriptionFactory=t.subscriptionFactory??nt,this.gitignoreFilter=U(t.projectRoot),this.extraIgnore=Qe(),this.watchConfig.ignore.length>0&&this.extraIgnore.add(this.watchConfig.ignore)}start(){if(this.stopInProgress)throw new Error("Cannot restart a watcher while its previous ownership is still draining.");this.stopped=!1,this.stopPromise=null,E(this).errors=[],this.sourcePollingFallbackStarted=!1,this.setStatus({state:"idle"}),this.startGitStatePolling();try{this.startSourceWatcher()}catch(t){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(t)}`))}}stop(){if(this.stopPromise)return this.stopPromise;this.stopped=!0,this.stopInProgress=!0;let t=this.fsWatchers;this.fsWatchers=[],this.clearDebounceTimer(),this.clearCooldownTimer(),this.clearGitPollTimer();let r=this.activeOperation;r&&this.setStatus({state:"draining",startedAt:this.wallNow(),reason:"waiting for the active reindex worker to exit"});let n=[...E(this).closures],i=et(this),o=this.clock.now()+i;return this.stopPromise=this.finishStop(t,n,r,o,i).catch(s=>{throw this.stopInProgress=!1,s}),this.stopPromise}requestRefresh(t,r={}){if(!this.stopped){if(!r.immediate||this.reindexInFlight||this.status.state==="cooldown"){this.scheduleReindex(t);return}this.pendingTrigger=de(this.pendingTrigger,t),this.changedFiles+=1,this.clearDebounceTimer(),this.triggerReindex()}}startSourceWatcher(t=!1){let r=this.subscriptionFactory(this.projectRoot,{ignoreInitial:!0,ignored:(n,i)=>this.isIgnoredWatchPath(n,i?.isDirectory()??!1),usePolling:t,...t?{interval:500,binaryInterval:1e3}:{}});r.on("all",(n,i)=>{this.stopped||this.handleFileChange(i)}),r.on("error",n=>this.handleSourceWatcherError(r,n,t)),this.fsWatchers.push(r)}handleSourceWatcherError(t,r,n){if(n||this.sourcePollingFallbackStarted||!ct(r)||this.stopped){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(r)}`));return}this.sourcePollingFallbackStarted=!0,this.fsWatchers=this.fsWatchers.filter(i=>i!==t),tt(E(this),t,i=>this.onError(i));try{this.startSourceWatcher(!0)}catch(i){this.onError(new Error(`Failed to watch ${this.projectRoot}: ${String(i)}`))}}isIgnoredWatchPath(t,r){let n=this.relativeWatchPath(t);if(!n)return!1;let i=r?`${n}/`:n;return i===".git/"||i.startsWith(".git/")?!0:this.gitignoreFilter.isIgnored(i)||this.extraIgnore.ignores(i)}handleFileChange(t){let r=this.relativeWatchPath(t);!r||r===".."||r.startsWith("../")||r===".git"||r.startsWith(".git/")||this.gitignoreFilter.isIgnored(r)||this.extraIgnore.ignores(r)||r.endsWith("index.db")||r.endsWith("index.scip")||r.endsWith("index.db.tmp")||Be(r).startsWith(q)||this.scheduleReindex({kind:"watch-source",detail:r})}relativeWatchPath(t){let r=Ke(t)?t:Ye(this.projectRoot,t);return ze(this.projectRoot,r).replaceAll("\\","/")}scheduleReindex(t){if(this.pendingTrigger=de(this.pendingTrigger,t),this.changedFiles++,this.reindexInFlight){this.dirty=!0,this.setStatus({state:"indexing",startedAt:this.status.startedAt});return}if(this.status.state==="cooldown"){this.dirty=!0,this.setStatus({state:"cooldown",until:this.status.until,dirty:!0});return}this.clearDebounceTimer();let r=this.wallNow()+this.watchConfig.debounceMs;this.setStatus({state:"waiting",changedFiles:this.changedFiles,reindexAt:r}),this.debounceTimer=this.clock.setTimeout(()=>{this.debounceTimer=null,this.triggerReindex()},this.watchConfig.debounceMs)}triggerReindex(){if(this.reindexInFlight||this.stopped)return;let t=this.clock.now()-this.lastReindexEnd;if(this.lastReindexEnd>0&&t<this.watchConfig.cooldownMs){let o=this.watchConfig.cooldownMs-t;this.dirty=!0;let s=this.wallNow()+o;this.setStatus({state:"cooldown",until:s,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped&&(this.dirty=!1,this.triggerReindex())},o);return}this.reindexInFlight=!0,this.dirty=!1,this.changedFiles=0;let r=this.pendingTrigger??{kind:"watch-source"};this.pendingTrigger=null;let n=this.wallNow();this.setStatus({state:"indexing",startedAt:n});let i=this.reindexRunner.start(this.reindexRequest(r));this.activeOperation=i,i.completion.then(o=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let s=!1;try{s=this.onReindexComplete(o,r)===!0}catch(a){this.onError(a instanceof Error?a:new Error(String(a)))}if(this.dirty&&!this.stopped){if(s){let c=this.pendingTrigger??{kind:"unknown"};this.dirty=!1,this.changedFiles=0,this.pendingTrigger=null,this.onRefreshSuppressed(c),this.setStatus({state:"idle"});return}let a=this.wallNow()+this.watchConfig.cooldownMs;this.setStatus({state:"cooldown",until:a,dirty:!0}),this.cooldownTimer=this.clock.setTimeout(()=>{this.cooldownTimer=null,this.dirty&&!this.stopped?(this.dirty=!1,this.triggerReindex()):this.setStatus({state:"idle"})},this.watchConfig.cooldownMs)}else this.setStatus({state:"idle"})}).catch(o=>{if(this.reindexInFlight=!1,this.lastReindexEnd=this.clock.now(),this.stopped)return;let s=o instanceof Error?o:new Error(String(o));this.onReindexError(s,r),this.onError(s),this.setStatus({state:"idle"})}).finally(()=>{this.activeOperation===i&&(this.activeOperation=null)})}async finishStop(t,r,n,i,o){let s=[],a=t.map(async d=>{try{await d.close()}catch(R){s.push(`watch subscription close failed: ${String(R)}`)}});a.push(...r),n&&a.push((async()=>{try{let d=await n.cancel();d.state==="degraded"&&s.push(d.reason)}catch(d){s.push(`reindex cancellation failed: ${d instanceof Error?d.message:String(d)}`)}})());let c=a.length,u=a.map(d=>d.finally(()=>{c-=1})),p=await Ze(u,i,this.clock),l=E(this);return s.push(...l.errors),l.errors=[],p?this.stopInProgress=!1:(s.push(`watch shutdown exceeded the ${o}ms deadline with ${c} operation(s) still pending`),Promise.all(u).then(()=>{this.stopInProgress=!1})),s.length>0?(this.setStatus({state:"draining",startedAt:this.wallNow(),reason:s.join("; ")}),{state:"degraded",reasons:s}):(this.setStatus({state:"idle"}),{state:"stopped"})}wallNow(){return this.clock.wallNow?.()??this.clock.now()}reindexRequest(t){return{projectRoot:this.projectRoot,config:this.config,languages:this.languages,pnpmWorkspaces:this.pnpmWorkspaces,typescriptProjectMode:this.typescriptProjectMode,typescriptProjects:this.typescriptProjects,clojureConfigPath:this.clojureConfigPath,indexerConcurrency:this.indexerConcurrency,trigger:t}}setStatus(t){this.status=t,this.onStatus(t)}clearDebounceTimer(){this.debounceTimer&&(this.clock.clearTimeout(this.debounceTimer),this.debounceTimer=null)}clearCooldownTimer(){this.cooldownTimer&&(this.clock.clearTimeout(this.cooldownTimer),this.cooldownTimer=null)}startGitStatePolling(){this.lastGitState=this.readGitState(),this.lastGitState&&(this.gitPollTimer=this.clock.setInterval(()=>this.pollGitState(),this.watchConfig.gitPollMs),this.gitPollTimer.unref?.())}pollGitState(){let t=this.lastGitState,r=this.readGitState();if(!t||!r||this.stopped){this.lastGitState=r;return}this.lastGitState=r;let n=t.head!==r.head,i=t.indexPath!==r.indexPath||t.indexMtimeMs!==r.indexMtimeMs||t.indexSize!==r.indexSize;n&&i?this.scheduleReindex({kind:"watch-git-state",detail:"HEAD and index changed"}):n?this.scheduleReindex({kind:"watch-git-head",detail:"HEAD changed"}):i&&this.scheduleReindex({kind:"watch-git-index",detail:r.indexPath??"index changed"})}readGitState(){let t=w(this.projectRoot,["rev-parse","--git-path","index"]);if(!t)return null;let r=G(this.projectRoot,t),n={head:w(this.projectRoot,["rev-parse","--verify","HEAD"]),indexPath:r};try{let i=He(r);n.indexMtimeMs=i.mtimeMs,n.indexSize=i.size}catch{n.indexMtimeMs=void 0,n.indexSize=void 0}return n}clearGitPollTimer(){this.gitPollTimer&&(this.clock.clearInterval(this.gitPollTimer),this.gitPollTimer=null)}};async function Ze(e,t,r){if(e.length===0)return!0;let n=Promise.all(e).then(()=>!0),i=Math.max(0,t-r.now()),o=null,s=new Promise(c=>{o=r.setTimeout(()=>c(!1),i)}),a=await Promise.race([n,s]);return a&&o&&r.clearTimeout(o),a}var le=new WeakMap,he=new WeakMap;function E(e){let t=le.get(e);if(t)return t;let r={closures:new Set,errors:[]};return le.set(e,r),r}function et(e){return he.get(e)??pe}function tt(e,t,r){let n=Promise.resolve().then(()=>t.close()).catch(i=>{let o=`watch subscription close failed during polling fallback: ${String(i)}`;e.errors.push(o),r(new Error(o))});e.closures.add(n),n.then(()=>e.closures.delete(n))}function fe(e){let{projectRoot:t,config:r,languages:n,pnpmWorkspaces:i,typescriptProjectMode:o,typescriptProjects:s,clojureConfigPath:a,indexerConcurrency:c,trigger:u}=e,p=T(t),l=Object.keys(p).length>0?p:r,d=k(t,l),R=l.indexer?.typescript,we=l.indexer?.clojure;return{workerPath:new URL("./reindex-worker.js",import.meta.url).pathname,env:{...process.env,SCIP_REINDEX_PROJECT_ROOT:t,SCIP_REINDEX_OUTPUT_SCIP:d.indexPath,SCIP_REINDEX_OUTPUT_DB:d.dbPath,SCIP_REINDEX_LANGUAGES:(l.languages??n)?.join(",")??"",SCIP_REINDEX_INDEXER_CONCURRENCY:String(l.indexerConcurrency??c??""),SCIP_REINDEX_PNPM_WORKSPACES:R?.pnpmWorkspaces??i?"1":"",SCIP_REINDEX_TYPESCRIPT_CONFIG:JSON.stringify({projectMode:R?.projectMode??o,projects:R?.projects??s??[]}),SCIP_REINDEX_CLOJURE_CONFIG_PATH:we?.configPath??a??"",SCIP_REINDEX_TRIGGER_KIND:u.kind,SCIP_REINDEX_TRIGGER_DETAIL:u.detail??"",SCIP_REINDEX_PROCESS_GROUP_LEADER:"1"}}}var rt={now:C,wallNow:()=>Date.now(),setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},nt=(e,t)=>Xe(e,t),it=15*6e4,ot=1e3,st=64*1024;function at(){return{stdoutTail:"",stderrTail:"",stdoutTruncated:!1,stderrTruncated:!1}}function ue(e,t){let r=e instanceof Error?e.message:String(e),n=t.stderrTail.trim()||t.stdoutTail.trim();return n?`${r}
|
|
3
|
+
${n}`:r}function ge(e={}){let t=e.timeoutMs??it,r=e.terminationGraceMs??ot,n=e.maxOutputBytes??st,i=e.resolveLaunch??fe;return{start(o){let s=i(o),a=new AbortController,c=at(),u=!1,p=H({command:process.execPath,args:[...process.execArgv,s.workerPath],label:"watch reindex worker",env:s.env,timeoutMs:t,terminationGraceMs:r,maxStdoutBytes:n,maxStderrBytes:n,outputLimitBehavior:"truncate-tail",signal:a.signal,detached:!0}).then(l=>{if(c={stdoutTail:l.stdout,stderrTail:l.stderr,stdoutTruncated:l.stdoutTruncated,stderrTruncated:l.stderrTruncated},l.status!==0)throw new Error(ue(new Error(`Reindex worker exited with ${l.signal?`signal ${l.signal}`:`code ${l.status}`}`),c));return l.durationMs}).catch(l=>{throw l instanceof J&&(c={stdoutTail:l.stdout,stderrTail:l.stderr,stdoutTruncated:l.stdoutTruncated,stderrTruncated:l.stderrTruncated}),new Error(ue(l,c),{cause:l})}).finally(()=>{u=!0});return{completion:p,async cancel(){u||a.abort();try{await p}catch{}return{state:"exited",diagnostics:c}},diagnostics:()=>c}}}}function de(e,t){return e?e.kind===t.kind?e.detail===t.detail?e:{kind:e.kind,detail:"multiple changes"}:{kind:"watch-git-state",detail:`${e.kind}, ${t.kind}`}:t}function ct(e){return e instanceof Error&&"code"in e&&e.code==="EMFILE"||String(e).includes("EMFILE: too many open files")}function lt(e,t){if(!Number.isSafeInteger(e)||e<=0)throw new Error(`${t} must be a positive integer.`);return e}import{existsSync as I,mkdirSync as ut,symlinkSync as dt,readlinkSync as me,unlinkSync as ye,readdirSync as pt}from"fs";import{join as m,dirname as j,resolve as y,relative as ht,isAbsolute as ft}from"path";import{homedir as O,platform as gt}from"os";import{fileURLToPath as mt}from"url";import{createHash as cr}from"crypto";import{resolve as ur}from"path";var yt=gt()==="win32",ve=["_shared","scip-query","scip-setup","scip-explore","scip-plan","scip-diagnose","scip-audit","scip-improve","scip-verify"];function vt(e={}){let t=e.quiet?()=>{}:console.log,r=mt(import.meta.url),n=y(j(r),"..","skills"),i=[m(O(),".claude","skills"),m(O(),".codex","skills"),m(O(),".agents","skills")],o={installed:[],skipped:[],alreadyLinked:[],pruned:[]};for(let s of i){let a=j(s);if(!I(a))continue;ut(s,{recursive:!0});let c=Ct(s);Rt(s,n,c,o,t);for(let u of ve){let p=m(n,u),l=m(s,u);if(!I(p)){o.skipped.push(`${c}/${u}`);continue}if(I(l)){try{let d=me(l);if(y(d)===y(p)){o.alreadyLinked.push(`${c}/${u}`),t(` ok: ${u} \u2192 ${c} (already linked)`);continue}}catch{o.skipped.push(`${c}/${u}`),t(` skip: ${u} \u2192 ${c} (exists, not a symlink)`);continue}ye(l)}dt(p,l,yt?"junction":"dir"),o.installed.push(`${c}/${u}`),t(` done: ${u} \u2192 ${c}`)}}return o}function Rt(e,t,r,n,i){let o=new Set(ve);for(let s of pt(e)){if(o.has(s))continue;let a=m(e,s),c;try{c=y(j(a),me(a))}catch{continue}St(c,t)&&(ye(a),n.pruned.push(`${r}/${s}`),i(` prune: ${s} \u2192 ${r} (removed stale scip-query skill link)`))}}function St(e,t){let r=ht(y(t),y(e));return r===""||!r.startsWith("..")&&!ft(r)}function Ct(e){return e.includes(".codex")?"Codex":e.includes(".agents")?"Agents":"Claude"}var Ce="scip-query-result",xe=0,v=1,xt=1;function be(e){if(!f(e))return{kind:"malformed",reason:"CLI JSON output must be an object."};let t=Object.hasOwn(e,"kind"),r=Object.hasOwn(e,"schemaVersion");if(!t&&!r){let s=Re(e);return s?{kind:"malformed",reason:`Legacy CLI JSON envelope: ${s}`}:{kind:"legacy",schemaVersion:xe,envelope:e}}if(!t||!r)return{kind:"malformed",reason:"CLI JSON envelope must contain both kind and schemaVersion."};if(e.kind!==Ce)return{kind:"malformed",reason:`Unsupported CLI JSON envelope kind: ${kt(e.kind)}.`};let n=e.schemaVersion;if(!Number.isSafeInteger(n)||Number(n)<1)return{kind:"malformed",reason:"CLI JSON envelope schemaVersion must be a positive safe integer."};if(n!==v)return{kind:"unsupported",schemaVersion:Number(n),direction:Number(n)<v?"older":"future",...Se(e.producer)?{producer:e.producer}:{}};let i=Re(e);if(i)return{kind:"malformed",reason:`CLI JSON envelope v1: ${i}`};if(!Se(e.producer))return{kind:"malformed",reason:"CLI JSON envelope v1: producer must identify scip-query and its non-empty version."};if(!wt(e.resultSchemaVersion))return{kind:"malformed",reason:"CLI JSON envelope v1: resultSchemaVersion must be a positive safe integer."};let o=Ee(e.command);return o.includes(e.resultSchemaVersion)?{kind:"supported",schemaVersion:v,envelope:e}:{kind:"unsupported-result",schemaVersion:v,command:e.command,resultSchemaVersion:e.resultSchemaVersion,supportedResultSchemaVersions:o}}function bt(e){let t=be(e);if(t.kind==="legacy"||t.kind==="supported")return t;if(t.kind==="unsupported"){let r=t.producer?` from ${t.producer.name}@${t.producer.version}`:"";throw new Error(`Unsupported scip-query CLI JSON schemaVersion ${t.schemaVersion}${r}; this consumer supports the legacy unversioned envelope and schemaVersion ${v}.`)}throw t.kind==="unsupported-result"?new Error(`Unsupported resultSchemaVersion ${t.resultSchemaVersion} for scip-query command ${JSON.stringify(t.command)}; this consumer supports ${t.supportedResultSchemaVersions.join(", ")}.`):new Error(`Malformed scip-query CLI JSON envelope: ${t.reason}`)}function Ee(e){return Et[e]??[xt]}var Et={};function Re(e){return typeof e.command!="string"||e.command.length===0?"command must be a non-empty string.":Array.isArray(e.args)?f(e.options)?Object.hasOwn(e,"result")?null:"result is required.":"options must be an object.":"args must be an array."}function Se(e){return f(e)&&e.name==="scip-query"&&typeof e.version=="string"&&e.version.length>0}function wt(e){return Number.isSafeInteger(e)&&Number(e)>0}function kt(e){return typeof e=="string"?JSON.stringify(e):String(e)}export{Ce as CLI_JSON_ENVELOPE_KIND,v as CURRENT_CLI_JSON_ENVELOPE_SCHEMA_VERSION,xe as LEGACY_CLI_JSON_ENVELOPE_SCHEMA_VERSION,B as OBSERVATION_RECEIPT_SCHEMA_VERSION,_ as Watcher,K as compareObservationReceipts,ge as createReindexRunner,be as decodeCliJsonEnvelope,Pe as getScipVersion,Ge as initProjectConfig,vt as installSkills,Y as isObservationReceipt,ke as isScipInstalled,T as loadProjectConfig,Te as printScipInstallInstructions,bt as requireCompatibleCliJsonEnvelope,k as resolveIndexStoragePaths,fe as resolveReindexWorkerLaunch,Ee as supportedCliResultSchemaVersions};
|
|
4
4
|
//# sourceMappingURL=runtime.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-P5XHIJHI.js";import{A as Z,B as ee,D as ne,a as D,c as V,d as I,e as P,f as z,i as E,j as k,l as $,q as Q,r as A,s as _,t as N,u as B,v as U,w as J,y as X,z as G}from"./chunk-X4FR5BZF.js";import{a as Y,g as H}from"./chunk-HGFDYOVB.js";import{a as g}from"./chunk-APMMR5Y2.js";import{b as C,g as v}from"./chunk-46XGSFNI.js";import p from"process";import{randomUUID as Ue}from"crypto";import{rmSync as Oe}from"fs";import{resolve as T}from"path";import{pathToFileURL as Le}from"url";import{spawn as ge}from"child_process";import{createHash as Me,randomUUID as De}from"crypto";import{existsSync as he,realpathSync as Rn,rmSync as fn}from"fs";import{tmpdir as yn}from"os";import{resolve as Sn}from"path";import{createHash as fe}from"crypto";import{resolve as me}from"path";var m=3;function q(e){return fe("sha256").update(A({kind:"scip-query-durable-rust-mailbox",protocolVersion:m,sessionDir:me(e)})).digest("hex")}function W(e,n){if(!D(e)||typeof e.id!="string"||!e.id)return w("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return w("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return w("Durable Rust semantic helper received a partially versioned request without a protocol version.");let o=te(e.request);if(!o)return w("Durable Rust semantic helper received an invalid legacy request kind or payload.");let c=n.nowMs+Math.max(1,o.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:U("rust-semantic-v2",{id:e.id,request:o}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:c,sessionIdentity:n.sessionIdentity,request:o}}}let t=ye(e,n);if(!t.ok)return t;if(e.protocolVersion!==m)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let i=te(e.request);return i?t.operationKey!==U("rust-semantic-v3",i)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==i.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:_,protocolVersion:m,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:i}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function ye(e,n){if(e.mailboxVersion!==_||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!re(e.operationKey)||e.id!==J(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!re(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==m)return w("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function te(e){return!D(e)||typeof e.identityKey!="string"||!e.identityKey||!P(e.timeoutMs)||e.workerEnvironment!==void 0&&!V(e.workerEnvironment)?null:e.kind==="semantic"&&be(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&Se(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function be(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!oe(e.definitions)?!1:O(e.referenceDefinitions)&&O(e.calleeDefinitions)&&O(e.signatureDefinitions)&&b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.referenceRetryTimeoutMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&ie(e.concurrency)&&L(e.includeReferences)&&L(e.includeCallees)&&L(e.includeSignatures)}function Se(e){return!D(e)||!h(e.projectRoot)||!h(e.rustAnalyzerBinary)||!h(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>D(n)&&h(n.id)&&h(n.file)&&I(n.line)&&I(n.column))?!1:b(e.requestTimeoutMs)&&b(e.readinessDeadlineMs)&&b(e.diagnosticsTimeoutMs)&&b(e.settleDelayMs)&&ie(e.concurrency)}function oe(e){return Array.isArray(e)&&e.every(Ie)}function O(e){return e===void 0||oe(e)}function Ie(e){return D(e)&&I(e.symbolId)&&I(e.documentId)&&I(e.startLine)&&se(e.startChar)&&I(e.endLine)&&se(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function w(e){return{ok:!1,code:"malformed-request",error:e}}function re(e){return/^[a-f0-9]{64}$/.test(e)}function h(e){return typeof e=="string"&&e.length>0}function ie(e){return e===void 0||P(e)}function se(e){return e===void 0||I(e)}function b(e){return e===void 0||z(e)}function L(e){return e===void 0||typeof e=="boolean"}var x=class{constructor(n,t=ke){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let i=Ee(n.request),o=t==="reused"&&i!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===i?this.semanticResponseCache.response:null;if(o)return ae(!0,n.request.definitions.length),{session:t,response:o};let c=this.requester.requestSemantic(n.request,n.timeoutMs);return i!==null&&we(c)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:i,response:c}),ae(!1,n.request.definitions.length),{session:t,response:c}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function Ee(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return qe(A(t))}function we(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function ae(e,n){Y()&&H({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function ke(e){for(let n of Object.keys(process.env))_e(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function Ae(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function _e(e){return Ae(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var En={now:Date.now,monotonicNow:g,randomId:De,isProcessAlive:k,readProcessIdentity:E,spawnServer(e,n,t){if(!he(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);ge(process.execPath,[e,n,t],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function qe(e){return Me("sha256").update(e).digest("hex")}import{existsSync as xe,mkdtempSync as ue,rmSync as F}from"fs";import{tmpdir as le}from"os";import{join as K}from"path";import{fileURLToPath as de,pathToFileURL as Te}from"url";import{SHARE_ENV as Ce,Worker as ve}from"worker_threads";function ce(e={}){let n=null,t=null,i=1,o=!1,c=()=>{t&&(F(t,{recursive:!0,force:!0}),t=null)},S=()=>{let r=n;n=null,r&&r.terminate(),c()},M=()=>{if(n)return n;let r=e.semanticWorkerPath?Te(e.semanticWorkerPath):Be();if(!xe(de(r)))throw new Error(`Rust semantic session worker was not found at ${de(r)}. Run npm run build before using built semantic Rust queries.`);return t=ue(K(le(),"scip-query-rust-session-")),n=new ve(r,e.shareEnvironment?{env:Ce}:void 0),n.unref(),n},y=()=>{let r=t??ue(K(le(),"scip-query-rust-session-"));return t=r,K(r,`${i++}.json`)};return{requestSemantic(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"semantic",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Pe(v(l,{maxBytes:C,inputKind:"Rust semantic worker response"}));if(!a.ok)throw new Error(a.error);return a.response}finally{F(l,{force:!0})}},requestImportDefinitions(r,s){if(o)throw new Error("Rust semantic session was already disposed.");let f=M(),l=y(),u=new SharedArrayBuffer(4),R=new Int32Array(u);if(f.postMessage({kind:"import-definitions",request:r,responsePath:l,sharedBuffer:u}),Atomics.wait(R,0,0,s)==="timed-out")throw S(),new Error(`Rust semantic import-definition session worker timed out after ${(s/1e3).toFixed(0)}s`);try{let a=Ne(v(l,{maxBytes:C,inputKind:"Rust import-definition worker response"}));if(!a.ok)throw new Error(a.error);return a.response}finally{F(l,{force:!0})}},shutdown(){if(o)return;if(o=!0,!n){c();return}let r=y(),s=new SharedArrayBuffer(4),f=new Int32Array(s);n.postMessage({kind:"shutdown",responsePath:r,sharedBuffer:s}),Atomics.wait(f,0,0,5e3),S()}}}function Pe(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Ne(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Be(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var We=10*6e4,Fe=10,Ke=1e3;function je(e,n,t={}){let i=N(e);B(i);let o=t.now??(t.nowMs===void 0?Date.now:()=>t.nowMs),c=o(),S=q(e),M=X(i,{ownerId:t.ownerId??Xe,nowMs:c,limits:t.limits,owner:Ge,liveness:Ze}),y=0;for(let r of M){let s=null,f,l="handler-error";try{let u=G(r,t.limits),R;try{R=JSON.parse(u)}catch{throw l="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let d=W(R,{claimRequestId:r.requestId,sessionIdentity:S,nowMs:o()});if(!d.ok)throw l=d.code,f=d.responseIdentity,new Error(d.error);s=d.value,f={id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs};let a=Ve(s.request,t.monotonicNowMs??g());t.beforeRequest?.(a);let Re=n.handle(a),j=o();if(s.deadlineAtMs<j)throw l="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");Z(i,r,{ok:!0,protocolVersion:m,id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs,...Re},{nowMs:j,limits:t.limits})}catch(u){let R=o(),d=f??(s?{id:s.id,sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:void 0),a=u instanceof Error?u.message:String(u);ee(i,r,{ok:!1,protocolVersion:m,id:d?.id??r.requestId,...d?{sessionIdentity:d.sessionIdentity,deadlineAtMs:d.deadlineAtMs}:{},errorCode:l,error:a},a,{nowMs:R,limits:t.limits})}y+=1}return y}function Ve(e,n){let t=n+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:t}}}async function ze(e,n){let t=N(e);B(t);let i=T(e,"server.lock"),o=He(i);if(!o)return;let c=new x(()=>ce({semanticWorkerPath:n,shareEnvironment:!0})),S=!1,M=g(),y=Number.NEGATIVE_INFINITY,r,s=E(p.pid),f=q(e),l=()=>{S=!0};p.once("SIGINT",l),p.once("SIGTERM",l);let u=(R=!1)=>{let d=Date.now(),a=g();!R&&a-y<Ke||(y=a,Q(T(e,"server.json"),{protocolVersion:m,sessionIdentity:f,pid:p.pid,...s?{processIdentity:s}:{},heartbeatAtMs:d,...r===void 0?{}:{busyUntilMs:r},mailbox:ne(t)}))};try{u(!0);let R=$e();for(;!S&&g()-M<R;)je(e,c,{beforeRequest(a){r=Date.now()+a.timeoutMs+5e3,u(!0)}})>0?(M=g(),r=void 0,u(!0)):u(),await Qe(Fe)}finally{c.shutdown(),Oe(T(e,"server.json"),{force:!0}),o.release()}}var Ye=e=>{let n=Number(e);return Number.isInteger(n)&&n>0?{pid:n}:null};function He(e){let n=$(e,{kind:"rust-durable-session-server",parseLegacy:Ye});return n.kind==="acquired"?n.lock:null}function $e(){let e=Number(p.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:We}function Qe(e){return new Promise(n=>setTimeout(n,e))}var Je=p.argv[1]?Le(T(p.argv[1])).href:null;if(Je===import.meta.url){let e=p.argv[2],n=p.argv[3];!e||!n?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),p.exitCode=1):await ze(e,n)}var Xe=`rust-semantic-${p.pid}-${Ue()}`,pe=E(p.pid),Ge={pid:p.pid,...pe?{processIdentity:pe}:{}},Ze={isProcessAlive:k,readProcessIdentity:E};export{He as acquireDurableRustSessionServerLock,je as processDurableRustSessionRequests};
|
|
1
|
+
import"./chunk-P5XHIJHI.js";import{c as ie}from"./chunk-SMNXQT5Z.js";import"./chunk-IZYYAFN5.js";import{A as ee,B as ne,C as te,D as re,F as se,a as E,c as z,d as M,e as B,f as Y,l as q,n as J,r as Q,s as X,t as x,u as T,v as U,w as G,x as L,y as Z}from"./chunk-AIE7TFJW.js";import{a as $,g as H}from"./chunk-HGFDYOVB.js";import{a as D,d as k}from"./chunk-MNE7YG56.js";import{b as P,g as N}from"./chunk-46XGSFNI.js";import m from"process";import{randomUUID as Fe}from"crypto";import{rmSync as Ke}from"fs";import{resolve as _}from"path";import{pathToFileURL as je}from"url";import{spawn as Ee}from"child_process";import{createHash as we,randomUUID as ke}from"crypto";import{existsSync as Ae,realpathSync as Sn,rmSync as In}from"fs";import{tmpdir as Mn}from"os";import{resolve as hn}from"path";import{createHash as Se}from"crypto";import{resolve as Ie}from"path";var y=3;function v(e){return Se("sha256").update(x({kind:"scip-query-durable-rust-mailbox",protocolVersion:y,sessionDir:Ie(e)})).digest("hex")}function F(e,n){if(!E(e)||typeof e.id!="string"||!e.id)return A("Durable Rust semantic helper received an invalid mailbox request.");if(e.id!==n.claimRequestId)return A("Durable Rust semantic request identity does not match its mailbox path.");if(e.protocolVersion===void 0){if(e.mailboxVersion!==void 0||e.operationKey!==void 0||e.clientId!==void 0||e.enqueuedAtMs!==void 0||e.deadlineAtMs!==void 0||e.sessionIdentity!==void 0)return A("Durable Rust semantic helper received a partially versioned request without a protocol version.");let o=oe(e.request);if(!o)return A("Durable Rust semantic helper received an invalid legacy request kind or payload.");let c=n.nowMs+Math.max(1,o.timeoutMs);return{ok:!0,compatibility:"legacy-v2",value:{mailboxVersion:T,protocolVersion:y,id:e.id,operationKey:L("rust-semantic-v2",{id:e.id,request:o}),clientId:"legacy-v2",enqueuedAtMs:n.nowMs,deadlineAtMs:c,sessionIdentity:n.sessionIdentity,request:o}}}let t=ge(e,n);if(!t.ok)return t;if(e.protocolVersion!==y)return{ok:!1,code:"unsupported-protocol",error:`Durable Rust semantic helper does not support mailbox protocol ${String(e.protocolVersion)}.`,responseIdentity:t.responseIdentity};let l=oe(e.request);return l?t.operationKey!==L("rust-semantic-v3",l)?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a mismatched mailbox operation identity.",responseIdentity:t.responseIdentity}:t.deadlineAtMs-t.enqueuedAtMs!==l.timeoutMs?{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received a deadline that does not match the request timeout.",responseIdentity:t.responseIdentity}:t.deadlineAtMs<n.nowMs?{ok:!1,code:"expired-request",error:"Durable Rust semantic request expired before processing.",responseIdentity:t.responseIdentity}:{ok:!0,compatibility:t.priorSessionIdentity?"prior-v3":"current-v3",value:{mailboxVersion:T,protocolVersion:y,id:e.id,operationKey:t.operationKey,clientId:t.clientId,enqueuedAtMs:t.enqueuedAtMs,deadlineAtMs:t.deadlineAtMs,sessionIdentity:n.sessionIdentity,request:l}}:{ok:!1,code:"malformed-request",error:"Durable Rust semantic helper received an invalid request kind or payload.",responseIdentity:t.responseIdentity}}function ge(e,n){if(e.mailboxVersion!==T||typeof e.protocolVersion!="number"||!Number.isInteger(e.protocolVersion)||typeof e.operationKey!="string"||!ae(e.operationKey)||e.id!==Z(e.operationKey)||typeof e.clientId!="string"||!e.clientId||typeof e.enqueuedAtMs!="number"||!Number.isFinite(e.enqueuedAtMs)||typeof e.deadlineAtMs!="number"||!Number.isFinite(e.deadlineAtMs)||e.deadlineAtMs<e.enqueuedAtMs||e.sessionIdentity!==void 0&&(typeof e.sessionIdentity!="string"||!ae(e.sessionIdentity))||e.sessionIdentity===void 0&&e.protocolVersion!==y)return A("Durable Rust semantic helper received an invalid mailbox lifecycle.");let t={id:n.claimRequestId,sessionIdentity:n.sessionIdentity,deadlineAtMs:e.deadlineAtMs};return e.sessionIdentity!==void 0&&e.sessionIdentity!==n.sessionIdentity?{ok:!1,code:"malformed-request",error:"Durable Rust semantic request belongs to a different mailbox session.",responseIdentity:t}:{ok:!0,responseIdentity:t,operationKey:e.operationKey,clientId:e.clientId,enqueuedAtMs:e.enqueuedAtMs,deadlineAtMs:e.deadlineAtMs,priorSessionIdentity:e.sessionIdentity===void 0}}function oe(e){return!E(e)||typeof e.identityKey!="string"||!e.identityKey||!B(e.timeoutMs)||e.workerEnvironment!==void 0&&!z(e.workerEnvironment)?null:e.kind==="semantic"&&Me(e.request)?{kind:"semantic",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:e.kind==="import-definitions"&&De(e.request)?{kind:"import-definitions",identityKey:e.identityKey,...e.workerEnvironment===void 0?{}:{workerEnvironment:e.workerEnvironment},request:e.request,timeoutMs:e.timeoutMs}:null}function Me(e){return!E(e)||!w(e.projectRoot)||!w(e.rustAnalyzerBinary)||!le(e.definitions)?!1:O(e.referenceDefinitions)&&O(e.calleeDefinitions)&&O(e.signatureDefinitions)&&I(e.requestTimeoutMs)&&I(e.readinessDeadlineMs)&&I(e.referenceRetryTimeoutMs)&&I(e.diagnosticsTimeoutMs)&&I(e.settleDelayMs)&&de(e.concurrency)&&W(e.includeReferences)&&W(e.includeCallees)&&W(e.includeSignatures)}function De(e){return!E(e)||!w(e.projectRoot)||!w(e.rustAnalyzerBinary)||!w(e.file)||!Array.isArray(e.positions)||!e.positions.every(n=>E(n)&&w(n.id)&&w(n.file)&&M(n.line)&&M(n.column))?!1:I(e.requestTimeoutMs)&&I(e.readinessDeadlineMs)&&I(e.diagnosticsTimeoutMs)&&I(e.settleDelayMs)&&de(e.concurrency)}function le(e){return Array.isArray(e)&&e.every(he)}function O(e){return e===void 0||le(e)}function he(e){return E(e)&&M(e.symbolId)&&M(e.documentId)&&M(e.startLine)&&ue(e.startChar)&&M(e.endLine)&&ue(e.endChar)&&typeof e.symbol=="string"&&typeof e.relativePath=="string"&&typeof e.leaf=="string"&&(e.parentTypeName===null||typeof e.parentTypeName=="string")&&typeof e.isFunctionLike=="boolean"&&typeof e.isTypeLike=="boolean"&&(e.kind===null||Number.isSafeInteger(e.kind))&&(e.documentation===null||typeof e.documentation=="string")&&(e.enclosingSymbol===null||typeof e.enclosingSymbol=="string")}function A(e){return{ok:!1,code:"malformed-request",error:e}}function ae(e){return/^[a-f0-9]{64}$/.test(e)}function w(e){return typeof e=="string"&&e.length>0}function de(e){return e===void 0||B(e)}function ue(e){return e===void 0||M(e)}function I(e){return e===void 0||Y(e)}function W(e){return e===void 0||typeof e=="boolean"}var C=class{constructor(n,t=xe){this.createRequester=n;this.applyEnvironment=t}createRequester;applyEnvironment;requester=null;identityKey=null;semanticResponseCache=null;handle(n){this.applyEnvironment(n.workerEnvironment??{});let t;if(this.requester?this.identityKey!==n.identityKey?(this.semanticResponseCache=null,this.requester.shutdown(),this.requester=this.createRequester(),this.identityKey=n.identityKey,t="invalidated"):t="reused":(this.requester=this.createRequester(),this.identityKey=n.identityKey,t="created"),n.kind==="semantic"){let l=_e(n.request),o=t==="reused"&&l!==null&&this.semanticResponseCache?.identityKey===n.identityKey&&this.semanticResponseCache.requestKey===l?this.semanticResponseCache.response:null;if(o)return ce(!0,n.request.definitions.length),{session:t,response:o};let c=this.requester.requestSemantic(n.request,n.timeoutMs);return l!==null&&qe(c)&&(this.semanticResponseCache={identityKey:n.identityKey,requestKey:l,response:c}),ce(!1,n.request.definitions.length),{session:t,response:c}}return{session:t,response:this.requester.requestImportDefinitions(n.request,n.timeoutMs)}}shutdown(){this.requester?.shutdown(),this.requester=null,this.identityKey=null,this.semanticResponseCache=null}};function _e(e){if(e.includeReferences===!1||e.includeCallees!==!0||e.includeSignatures===!0||(e.referenceDefinitions?.length??0)===0||(e.calleeDefinitions?.length??0)===0)return null;let{readinessDeadlineMs:n,...t}=e;return Ce(x(t))}function qe(e){return e.available&&Array.isArray(e.callees)&&(e.incompleteReferenceSymbolIds?.length??0)===0}function ce(e,n){$()&&H({type:"span",name:"rust.semantic.durable-session.response-cache",durationMs:0,ok:!0,hit:e,definitions:n})}function xe(e){for(let n of Object.keys(process.env))ve(n)&&delete process.env[n];for(let[n,t]of Object.entries(e))t!==null&&(process.env[n]=t)}function Te(e){return e==="HOME"||e==="PATH"||e.startsWith("CARGO_")||e.startsWith("RA_")||e.startsWith("RUST")}function ve(e){return Te(e)||e.startsWith("SCIP_RUST_")||e==="SCIP_QUERY_PROFILE"||e==="SCIP_QUERY_PROFILE_CACHE_STATE"||e==="SCIP_QUERY_PROFILE_COMMAND"||e==="SCIP_QUERY_PROFILE_OUT"||e==="SCIP_QUERY_PROFILE_RUN_ID"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY"||e==="SCIP_QUERY_PROFILE_WORKLOAD_IDENTITY_KIND"||e==="SCIP_QUERY_PROFILE_MIN_MS"}var qn={now:Date.now,monotonicNow:D,randomId:ke,isProcessAlive:q,readProcessIdentity:k,spawnServer(e,n,t){if(!Ae(e))throw new Error(`Durable Rust semantic session helper was not found at ${e}. Run npm run build first.`);Ee(process.execPath,[e,n,t],{detached:!0,stdio:"ignore"}).unref()},sleep(e){let n=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(n,0,0,e)}};function Ce(e){return we("sha256").update(e).digest("hex")}import{existsSync as Pe,mkdtempSync as pe,rmSync as K}from"fs";import{tmpdir as Re}from"os";import{join as j}from"path";import{fileURLToPath as fe,pathToFileURL as Ne}from"url";import{SHARE_ENV as Be,Worker as Ue}from"worker_threads";function me(e={}){let n=null,t=null,l=1,o=!1,c=null,g=null,h=r=>{r&&K(r,{recursive:!0,force:!0})},b=()=>{if(c)return;let r=n,a=t;n=null,t=null;let d=r?r.terminate():Promise.resolve(0);c=Promise.allSettled([d,ie(a,{gracefulMs:1e3,forceMs:1e3})]).then(([u,s])=>{let S=(s.status==="fulfilled"?s.value:[{reaped:!1,detail:String(s.reason)}]).filter(R=>!R.reaped);if(u.status==="rejected"||S.length>0){g=new Error(`Rust semantic worker cleanup did not complete; ownership evidence remains at ${a??"unknown"}.`);return}h(a)}).finally(()=>{c=null})},f=()=>{if(n)return n;if(c)throw new Error("The previous Rust semantic session worker is still terminating; retry the request.");if(g)throw g;let r=e.semanticWorkerPath?Ne(e.semanticWorkerPath):We();if(!Pe(fe(r)))throw new Error(`Rust semantic session worker was not found at ${fe(r)}. Run npm run build before using built semantic Rust queries.`);return t=pe(j(Re(),"scip-query-rust-session-")),n=new Ue(r,e.shareEnvironment?{env:Be}:void 0),n.unref(),n},i=()=>{let r=t??pe(j(Re(),"scip-query-rust-session-"));return t=r,j(r,`${l++}.json`)};return{requestSemantic(r,a){if(o)throw new Error("Rust semantic session was already disposed.");let d=f(),u=i(),s=new SharedArrayBuffer(4),p=new Int32Array(s);if(d.postMessage({kind:"semantic",request:r,responsePath:u,sharedBuffer:s}),Atomics.wait(p,0,0,a)==="timed-out")throw b(),new Error(`Rust semantic session worker timed out after ${(a/1e3).toFixed(0)}s`);try{let R=Le(N(u,{maxBytes:P,inputKind:"Rust semantic worker response"}));if(!R.ok)throw new Error(R.error);return R.response}finally{K(u,{force:!0})}},requestImportDefinitions(r,a){if(o)throw new Error("Rust semantic session was already disposed.");let d=f(),u=i(),s=new SharedArrayBuffer(4),p=new Int32Array(s);if(d.postMessage({kind:"import-definitions",request:r,responsePath:u,sharedBuffer:s}),Atomics.wait(p,0,0,a)==="timed-out")throw b(),new Error(`Rust semantic import-definition session worker timed out after ${(a/1e3).toFixed(0)}s`);try{let R=Oe(N(u,{maxBytes:P,inputKind:"Rust import-definition worker response"}));if(!R.ok)throw new Error(R.error);return R.response}finally{K(u,{force:!0})}},shutdown(){if(o)return;if(o=!0,!n){h(t),t=null;return}let r=i(),a=new SharedArrayBuffer(4),d=new Int32Array(a);n.postMessage({kind:"shutdown",responsePath:r,sharedBuffer:a}),Atomics.wait(d,0,0,5e3),b()}}}function Le(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function Oe(e){let n=JSON.parse(e);if(!n||typeof n!="object")return{ok:!1,error:"Rust semantic session worker wrote a non-object response."};let t=n;return t.ok===!0&&"response"in t?{ok:!0,response:t.response}:{ok:!1,error:typeof n.error=="string"?n.error:"Rust semantic session worker failed."}}function We(){return new URL("./rust-semantic-session-worker.js",import.meta.url)}var Ve=10*6e4,ye=10,ze=250,Ye=1e3;function $e(e,n,t={}){let l=U(e),o=t.now??(t.nowMs===void 0?Date.now:()=>t.nowMs),c=o(),g=v(e),h=ee(l,{ownerId:t.ownerId??tn,nowMs:c,limits:t.limits,owner:rn,liveness:sn}),b=0;for(let f of h){let i=null,r,a="handler-error";try{let d=ne(f,t.limits),u;try{u=JSON.parse(d)}catch{throw a="malformed-request",new Error("Durable Rust semantic helper received malformed request JSON.")}let s=F(u,{claimRequestId:f.requestId,sessionIdentity:g,nowMs:o()});if(!s.ok)throw a=s.code,r=s.responseIdentity,new Error(s.error);i=s.value,r={id:i.id,sessionIdentity:i.sessionIdentity,deadlineAtMs:i.deadlineAtMs};let p=He(i.request,t.monotonicNowMs??D());t.beforeRequest?.(p);let S=n.handle(p),R=o();if(i.deadlineAtMs<R)throw a="expired-request",new Error("Durable Rust semantic request expired while the helper was processing it.");te(l,f,{ok:!0,protocolVersion:y,id:i.id,sessionIdentity:i.sessionIdentity,deadlineAtMs:i.deadlineAtMs,...S},{nowMs:R,limits:t.limits})}catch(d){let u=o(),s=r??(i?{id:i.id,sessionIdentity:i.sessionIdentity,deadlineAtMs:i.deadlineAtMs}:void 0),p=d instanceof Error?d.message:String(d);re(l,f,{ok:!1,protocolVersion:y,id:s?.id??f.requestId,...s?{sessionIdentity:s.sessionIdentity,deadlineAtMs:s.deadlineAtMs}:{},errorCode:a,error:p},p,{nowMs:u,limits:t.limits})}b+=1}return b}function He(e,n){let t=n+Math.max(1,e.timeoutMs-1e3);return{...e,request:{...e.request,readinessDeadlineMs:t}}}async function Je(e,n){let t=U(e);G(t);let l=_(e,"server.lock"),o=Ge(l);if(!o)return;let c=new C(()=>me({semanticWorkerPath:n,shareEnvironment:!0})),g=!1,h=D(),b=Number.NEGATIVE_INFINITY,f,i=0,r=k(m.pid),a=v(e),d=()=>{g=!0};m.once("SIGINT",d),m.once("SIGTERM",d);let u=(s=!1,p=s?"durable":"visibility")=>{let S=Date.now(),R=D();if(!s&&R-b<Ye)return;b=R;let V={protocolVersion:y,sessionIdentity:a,pid:m.pid,...r?{processIdentity:r}:{},heartbeatAtMs:S,...f===void 0?{}:{busyUntilMs:f},mailbox:se(t)};p==="durable"?X(_(e,"server.json"),V):Q(_(e,"server.json"),V)};try{u(!0);let s=Ze();for(;!g&&D()-h<s;){let p=$e(e,c,{beforeRequest(S){f=Date.now()+S.timeoutMs+5e3,u(!0,"visibility")}});p>0?(i=0,h=D(),f=void 0,u(!0,"visibility")):(i+=1,u()),await en(Qe(p,i))}}finally{c.shutdown(),Ke(_(e,"server.json"),{force:!0}),o.release()}}function Qe(e,n=1){if(e>0)return ye;let t=Math.max(0,Math.min(5,n-1));return Math.min(ze,ye*2**t)}var Xe=e=>{let n=Number(e);return Number.isInteger(n)&&n>0?{pid:n}:null};function Ge(e){let n=J(e,{kind:"rust-durable-session-server",parseLegacy:Xe});return n.kind==="acquired"?n.lock:null}function Ze(){let e=Number(m.env.SCIP_RUST_SEMANTIC_DURABLE_IDLE_MS);return Number.isInteger(e)&&e>=0?e:Ve}function en(e){return new Promise(n=>setTimeout(n,e))}var nn=m.argv[1]?je(_(m.argv[1])).href:null;if(nn===import.meta.url){let e=m.argv[2],n=m.argv[3];!e||!n?(console.error("durable-rust-session: expected <session-dir> <semantic-worker-path>"),m.exitCode=1):await Je(e,n)}var tn=`rust-semantic-${m.pid}-${Fe()}`,be=k(m.pid),rn={pid:m.pid,...be?{processIdentity:be}:{}},sn={isProcessAlive:q,readProcessIdentity:k};export{Ge as acquireDurableRustSessionServerLock,Qe as durableSessionLoopDelayMs,$e as processDurableRustSessionRequests};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-server.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as de,B as fe,C as b,D as S,a as ee,b as ne,c as A,d as j,e as G,f as F,g as N,h as E,i as te,j as ie,k as se,l as re,n as B,o as H,p as U,q as W,r as ae,u as oe,v as le,w as ce,x as ue,y as k}from"./chunk-A2TNXAXO.js";import{l as $,m as q}from"./chunk-C5Q44Q5D.js";import{a as O,f as u,g as D}from"./chunk-HGFDYOVB.js";import"./chunk-APMMR5Y2.js";import"./chunk-46XGSFNI.js";import _ from"process";import{existsSync as we,writeFileSync as Pe}from"fs";import{isAbsolute as De,resolve as ke}from"path";import{performance as L}from"perf_hooks";import{parentPort as be}from"worker_threads";var Se="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",Te="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",P=new Map,me=Promise.resolve();be?.on("message",e=>{me=me.then(()=>ze(e)).catch(()=>{})});async function ze(e){if(e.kind==="shutdown"){await Le(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let t=await ve(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=N(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n={available:!1,reason:t instanceof Error?t.message:String(t),sourcePaths:e.request.positions.map(r=>[r.id,null])};g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}return}try{let t=await Ie(e.request);g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}catch(t){let i=N(t);if(i){g(e.responsePath,i,e.sharedBuffer);return}let n=ye(e.request,t instanceof Error?t.message:String(t));g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}}async function ve(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await u("rust.semantic.worker.session",()=>Re(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let n=0;await F(()=>u("rust.semantic.worker.open-source-documents",async()=>{n=await Fe(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:n,positions:e.positions.length})),()=>ge(P,i,e.readinessDeadlineMs));let r=0;return{available:!0,sourcePaths:await u("rust.semantic.worker.import-definitions",()=>S(e.positions,e.concurrency??8,async o=>{let c=await i.client.definition({textDocument:{uri:E(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},t),f=Ee(e.projectRoot,c);return f&&(r+=1),[o.id,f]}),()=>({positions:e.positions.length,resolvedPositions:r,concurrency:e.concurrency??8}))}}async function Ie(e){let t={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,n=e.includeCallees===!0,r=e.includeSignatures===!0,a=B(e),o=H(e),c=U(e),f=W(e),l=await u("rust.semantic.worker.session",()=>Ce(e),()=>({kind:"semantic",definitions:f.length,referenceDefinitions:a.length,calleeDefinitions:o.length,signatureDefinitions:c.length,references:i,callees:n,signatures:r})),p=We(l.capabilities,{references:i,callees:n,signatures:r});if(p)return ye(e,p);let d=0;await F(()=>u("rust.semantic.worker.open-definition-documents",async()=>{d=await Ae(l,e)},()=>({definitions:f.length,openedDocuments:d})),()=>ge(P,l,e.readinessDeadlineMs));let m=0,M=0,y=O(),K=y?new Map:null,T=y?pe(_.env[Se]):null,J=()=>i?u("rust.semantic.worker.references",()=>S(a,e.concurrency??8,async s=>{let w=y?L.now():0,h=await de(l.client,ie(e.projectRoot,s,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),R=re(se(e.projectRoot,h.locations)),C=y?Math.round(L.now()-w):0;return xe(K,s.relativePath,{durationMs:C,references:R.length,hasReferences:R.length>0,slow:T!==null&&C>=T}),T!==null&&C>=T&&D({type:"span",name:"rust.semantic.worker.reference-task",durationMs:C,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,references:R.length,complete:h.complete}),R.length>0&&(M+=1),m+=R.length,{symbolId:s.symbolId,references:R,complete:h.complete}}),()=>({definitions:a.length,concurrency:e.concurrency??8,definitionsWithReferences:M,references:m})):Promise.resolve(a.map(s=>({symbolId:s.symbolId,references:[],complete:!0}))),V=0,Q=0,z=O(),X=z?new Map:null,v=z?pe(_.env[Te]):null,Y=()=>n?u("rust.semantic.worker.callees",()=>S(o,e.concurrency??8,async s=>{let w=z?L.now():0,h=await fe(l.client,e.projectRoot,s,t),R=z?Math.round(L.now()-w):0;return Ge(X,s.relativePath,{durationMs:R,callees:h.length,hasCallees:h.length>0,slow:v!==null&&R>=v}),v!==null&&R>=v&&D({type:"span",name:"rust.semantic.worker.callee-task",durationMs:R,ok:!0,symbolId:s.symbolId,relativePath:s.relativePath,leaf:s.leaf,kind:s.kind,startLine:s.startLine,endLine:s.endLine,callees:h.length}),h.length>0&&(Q+=1),V+=h.length,{symbolId:s.symbolId,callees:h}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Q,callees:V})):Promise.resolve([]),I,x;i&&n&&a.length>0&&o.length>0&&He()?[I,x]=await Promise.all([J(),Y()]):(I=await J(),x=await Y()),Oe(K),Ne(X);let Z=0,Me=r?await u("rust.semantic.worker.signatures",()=>S(c,e.concurrency??8,async s=>{let w=await ae(l.client,e.projectRoot,s,t);return w&&(Z+=1),{symbolId:s.symbolId,signature:w}}),()=>({definitions:c.length,concurrency:e.concurrency??8,signaturesFound:Z})):[];return{available:!0,references:I.filter(s=>s.complete).map(s=>[s.symbolId,s.references]),incompleteReferenceSymbolIds:I.filter(s=>!s.complete).map(s=>s.symbolId),...n?{callees:x.map(s=>[s.symbolId,s.callees])}:{},...r?{signatures:Me.map(s=>[s.symbolId,s.signature])}:{}}}async function Ce(e){return Re(e.projectRoot,e.rustAnalyzerBinary,W(e).map(t=>t.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Re(e,t,i,n){let r=ce(e,i.map(M=>({relativePath:M}))),a=le(e,r),o=_e(t,a,r),c=P.get(o);if(c)return c;let f=oe(r),l=new ee(ne(t,a),{requestTimeoutMs:n.requestTimeoutMs,configuration:f}),p=n.readinessDeadlineMs===void 0?null:{afterGeneration:l.serverStatusGeneration(),deadlineMs:n.readinessDeadlineMs},d=await F(()=>u("rust.semantic.worker.initialize",()=>l.initialize({processId:_.pid,rootUri:E(a,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:f},{timeoutMs:n.requestTimeoutMs,deadlineMs:n.readinessDeadlineMs}),()=>({linkedProjects:r.length,relativePaths:i.length})),()=>l.shutdown({deadlineMs:n.readinessDeadlineMs}).catch(()=>{})),m={key:o,client:l,capabilities:d.capabilities,openedPaths:new Set,initializationReadiness:p};return P.set(o,m),m}async function Ae(e,t){let i=W(t).filter(l=>e.openedPaths.has(l.relativePath)?!1:we(ke(t.projectRoot,l.relativePath)));if(i.length===0)return await he(e),0;let n=e.initializationReadiness,r=t.readinessDeadlineMs===void 0?null:{statusSnapshot:n?null:e.client.serverStatusSnapshot(),initializationGeneration:n?.afterGeneration,deadlineMs:t.readinessDeadlineMs},a=ue(e.client,t.projectRoot,i);for(let l of i)e.openedPaths.add(l.relativePath);let o=t.diagnosticsTimeoutMs??1e4,c=o;await u("rust.semantic.worker.diagnostics",()=>r?G(l=>(c=l,k(e.client,a,l)),o,r.deadlineMs):k(e.client,a,o),()=>({openedDocuments:a.length,timeoutMs:c}));let f=t.settleDelayMs??5e3;if(!r)await u("rust.semantic.worker.settle",()=>b(f),()=>({openedDocuments:a.length,settleDelayMs:f}));else{let l;await u("rust.semantic.worker.readiness",async()=>{let p=m=>u("rust.semantic.worker.settle",()=>b(m),()=>({openedDocuments:a.length,settleDelayMs:m})),d=r.initializationGeneration===void 0?await j(e.client,r.statusSnapshot,a.length,r.deadlineMs,f,Date.now,p):await A(e.client,r.initializationGeneration,a.length,r.deadlineMs,f,Date.now,p);r.initializationGeneration!==void 0&&(e.initializationReadiness=null),l=d?.health},()=>({phase:r.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:a.length,health:l}))}return a.length}async function Fe(e,t,i,n){let r=i.filter(d=>!e.openedPaths.has(d));if(r.length===0)return await he(e),0;let a=e.initializationReadiness,o=n.readinessDeadlineMs===void 0?null:{statusSnapshot:a?null:e.client.serverStatusSnapshot(),initializationGeneration:a?.afterGeneration,deadlineMs:n.readinessDeadlineMs},c=[];for(let d of r)try{let m=E(t,d);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:$(t,d,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(d),c.push(m)}catch(m){if(!q(m))throw m}let f=n.diagnosticsTimeoutMs??1e4,l=f;await u("rust.semantic.worker.diagnostics",()=>o?G(d=>(l=d,k(e.client,c,d)),f,o.deadlineMs):k(e.client,c,f),()=>({openedDocuments:c.length,timeoutMs:l}));let p=n.settleDelayMs??5e3;if(!o)await u("rust.semantic.worker.settle",()=>b(p),()=>({openedDocuments:c.length,settleDelayMs:p}));else{let d;await u("rust.semantic.worker.readiness",async()=>{let m=y=>u("rust.semantic.worker.settle",()=>b(y),()=>({openedDocuments:c.length,settleDelayMs:y})),M=o.initializationGeneration===void 0?await j(e.client,o.statusSnapshot,c.length,o.deadlineMs,p,Date.now,m):await A(e.client,o.initializationGeneration,c.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),d=M?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:c.length,health:d}))}return c.length}async function he(e){let t=e.initializationReadiness;if(!t)return;let i;await u("rust.semantic.worker.readiness",async()=>{i=(await A(e.client,t.afterGeneration,0,t.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ee(e,t){for(let i of t){let n=te(e,i.uri);if(!(!n||n===".."||n.startsWith("../")||De(n)))return n}return null}function We(e,t){return t.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":t.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":t.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function ye(e,t){let i=B(e),n=H(e),r=U(e);return{available:!1,reason:t,references:i.map(a=>[a.symbolId,[]]),...e.includeCallees?{callees:n.map(a=>[a.symbolId,[]])}:{},...e.includeSignatures?{signatures:r.map(a=>[a.symbolId,null])}:{}}}async function Le(){let e=[...P.values()];P.clear(),await Promise.all(e.map(t=>t.client.shutdown().catch(()=>{})))}async function ge(e,t,i){e.get(t.key)===t&&e.delete(t.key),await t.client.shutdown({deadlineMs:i}).catch(()=>{})}function _e(e,t,i){return JSON.stringify({binary:e,sessionRoot:t,linkedProjects:i})}function xe(e,t,i){if(!e)return;let n=je(e,t);n.definitions+=1,i.hasReferences&&(n.definitionsWithReferences+=1),n.references+=i.references,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Oe(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithReferences:n.definitionsWithReferences,references:n.references,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function je(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function Ge(e,t,i){if(!e)return;let n=Be(e,t);n.definitions+=1,i.hasCallees&&(n.definitionsWithCallees+=1),n.callees+=i.callees,n.durationMs+=i.durationMs,n.maxDurationMs=Math.max(n.maxDurationMs,i.durationMs),i.slow&&(n.slowTasks+=1)}function Ne(e){if(!e)return;let t=[...e.entries()].sort(([i,n],[r,a])=>a.durationMs-n.durationMs||i.localeCompare(r));for(let[i,n]of t)D({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:n.durationMs,ok:!0,relativePath:i,definitions:n.definitions,definitionsWithCallees:n.definitionsWithCallees,callees:n.callees,maxDurationMs:n.maxDurationMs,slowTasks:n.slowTasks,aggregate:"sum-task-duration"})}function Be(e,t){let i=e.get(t);if(i)return i;let n={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(t,n),n}function pe(e){if(e===void 0||e==="")return null;let t=Number(e);return Number.isInteger(t)&&t>=0?t:null}function He(){let e=_.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,t,i){Pe(e,JSON.stringify(t));let n=new Int32Array(i);Atomics.store(n,0,1),Atomics.notify(n,0)}export{ge as discardRustAnalyzerSession};
|
|
1
|
+
import{A as me,B as pe,C as D,a as te,b as ie,c as C,d as N,e as G,f as E,g as B,h as F,i as se,j as re,k as oe,l as ae,n as H,o as U,p as K,q as W,r as le,u as ce,v as ue,w as de,x as fe,y as S}from"./chunk-DQLPXMH6.js";import{a as P,b as ne}from"./chunk-ILMHV3KM.js";import"./chunk-SMNXQT5Z.js";import"./chunk-IZYYAFN5.js";import{l as q,m as ee}from"./chunk-WUPW3UN3.js";import{a as j,f as d,g as M}from"./chunk-HGFDYOVB.js";import"./chunk-MNE7YG56.js";import"./chunk-46XGSFNI.js";import k from"process";import{existsSync as Te,writeFileSync as ve}from"fs";import{dirname as Ae,isAbsolute as Ie,resolve as Ce}from"path";import{performance as L}from"perf_hooks";import{parentPort as Ee}from"worker_threads";import{resolve as he}from"path";var ze=4,x=class{constructor(n=ze){this.capacity=n;if(!Number.isSafeInteger(n)||n<=0)throw new Error("Rust analyzer session capacity must be a positive safe integer.")}capacity;entries=new Map;get(n){let i=this.entries.get(n);if(i)return this.entries.delete(n),this.entries.set(n,i),i}async acquire(n,i,t){let s=this.get(n);if(s)return s;if(this.entries.size>=this.capacity){let o=this.entries.entries().next().value;if(!o)throw new Error("Rust analyzer session registry capacity accounting is inconsistent.");this.entries.delete(o[0]);try{await t(o[1])}catch(l){throw this.restoreOldest(o),l}}let r=await i();if(r.key!==n){try{await t(r)}catch(o){throw new AggregateError([o],`Rust analyzer session factory returned '${r.key}' for reserved key '${n}', and the mismatched session could not be reaped.`,{cause:o})}throw new Error(`Rust analyzer session factory returned '${r.key}' for reserved key '${n}'.`)}return this.entries.set(n,r),r}deleteIfSame(n){return this.entries.get(n.key)!==n?!1:this.entries.delete(n.key)}async shutdownAll(n){let i=[...this.entries.values()];this.entries.clear();let t=await Promise.allSettled(i.map(n)),s=[];for(let r=0;r<t.length;r+=1){let o=t[r];if(o.status==="fulfilled")continue;let l=i[r];s.push({session:l,reason:o.reason}),this.entries.set(l.key,l)}if(s.length>0)throw new AggregateError(s.map(r=>r.reason),`Failed to shut down ${s.length} retained rust-analyzer session(s).`)}get size(){return this.entries.size}restoreOldest(n){let i=[...this.entries.entries()];this.entries.clear(),this.entries.set(n[0],n[1]);for(let[t,s]of i)this.entries.set(t,s)}};function Re(e,n){let i=he(e);return[...new Set(n.map(t=>he(i,t)))].sort((t,s)=>t<s?-1:t>s?1:0)}function ye(e,n,i){return JSON.stringify({binary:e,sessionRoot:n,linkedProjects:i})}var Fe="SCIP_RUST_SEMANTIC_REFERENCE_TASK_PROFILE_MS",We="SCIP_RUST_SEMANTIC_CALLEE_TASK_PROFILE_MS",_=new x,ge=Promise.resolve(),Me;Ee?.on("message",e=>{ge=ge.then(()=>xe(e)).catch(()=>{})});async function xe(e){if(Me??=Ae(e.responsePath),e.kind==="shutdown"){await He(),g(e.responsePath,{ok:!0},e.sharedBuffer);return}if(e.kind==="import-definitions"){try{let n=await Le(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t={available:!1,reason:n instanceof Error?n.message:String(n),sourcePaths:e.request.positions.map(s=>[s.id,null])};g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}return}try{let n=await _e(e.request);g(e.responsePath,{ok:!0,response:n},e.sharedBuffer)}catch(n){let i=B(n);if(i){g(e.responsePath,i,e.sharedBuffer);return}let t=De(e.request,n instanceof Error?n.message:String(n));g(e.responsePath,{ok:!0,response:t},e.sharedBuffer)}}async function Le(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=await d("rust.semantic.worker.session",()=>Pe(e.projectRoot,e.rustAnalyzerBinary,[e.file],{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs}),()=>({kind:"import-definitions",files:1,positions:e.positions.length}));if(!i.capabilities.definitionProvider)return{available:!1,reason:"rust-analyzer initialized without textDocument/definition support.",sourcePaths:e.positions.map(o=>[o.id,null])};let t=0;await E(()=>d("rust.semantic.worker.open-source-documents",async()=>{t=await Ne(i,e.projectRoot,[e.file],{diagnosticsTimeoutMs:e.diagnosticsTimeoutMs,settleDelayMs:e.settleDelayMs,readinessDeadlineMs:e.readinessDeadlineMs})},()=>({files:1,openedDocuments:t,positions:e.positions.length})),()=>ke(_,i,e.readinessDeadlineMs));let s=0;return{available:!0,sourcePaths:await d("rust.semantic.worker.import-definitions",()=>P(e.positions,e.concurrency??8,async o=>{let l=await i.client.definition({textDocument:{uri:F(e.projectRoot,o.file)},position:{line:o.line,character:o.column}},n),u=Ge(e.projectRoot,l);return u&&(s+=1),[o.id,u]}),()=>({positions:e.positions.length,resolvedPositions:s,concurrency:e.concurrency??8}))}}async function _e(e){let n={timeoutMs:e.requestTimeoutMs,deadlineMs:e.readinessDeadlineMs},i=e.includeReferences!==!1,t=e.includeCallees===!0,s=e.includeSignatures===!0,r=H(e),o=U(e),l=K(e),u=W(e),c=await d("rust.semantic.worker.session",()=>Oe(e),()=>({kind:"semantic",definitions:u.length,referenceDefinitions:r.length,calleeDefinitions:o.length,signatureDefinitions:l.length,references:i,callees:t,signatures:s})),p=Be(c.capabilities,{references:i,callees:t,signatures:s});if(p)return De(e,p);let f=0;await E(()=>d("rust.semantic.worker.open-definition-documents",async()=>{f=await je(c,e)},()=>({definitions:u.length,openedDocuments:f})),()=>ke(_,c,e.readinessDeadlineMs));let m=0,b=0,y=j(),$=y?new Map:null,z=y?we(k.env[Fe]):null,J=()=>i?d("rust.semantic.worker.references",()=>P(r,e.concurrency??8,async a=>{let w=y?L.now():0,R=await me(c.client,re(e.projectRoot,a,!1),{requestTimeoutMs:e.requestTimeoutMs,retryTimeoutMs:e.referenceRetryTimeoutMs,deadlineMs:e.readinessDeadlineMs}),h=ae(oe(e.projectRoot,R.locations)),I=y?Math.round(L.now()-w):0;return Ue($,a.relativePath,{durationMs:I,references:h.length,hasReferences:h.length>0,slow:z!==null&&I>=z}),z!==null&&I>=z&&M({type:"span",name:"rust.semantic.worker.reference-task",durationMs:I,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,references:h.length,complete:R.complete}),h.length>0&&(b+=1),m+=h.length,{symbolId:a.symbolId,references:h,complete:R.complete}}),()=>({definitions:r.length,concurrency:e.concurrency??8,definitionsWithReferences:b,references:m})):Promise.resolve(r.map(a=>({symbolId:a.symbolId,references:[],complete:!0}))),V=0,Y=0,T=j(),Z=T?new Map:null,v=T?we(k.env[We]):null,Q=()=>t?d("rust.semantic.worker.callees",()=>P(o,e.concurrency??8,async a=>{let w=T?L.now():0,R=await pe(c.client,e.projectRoot,a,n),h=T?Math.round(L.now()-w):0;return Je(Z,a.relativePath,{durationMs:h,callees:R.length,hasCallees:R.length>0,slow:v!==null&&h>=v}),v!==null&&h>=v&&M({type:"span",name:"rust.semantic.worker.callee-task",durationMs:h,ok:!0,symbolId:a.symbolId,relativePath:a.relativePath,leaf:a.leaf,kind:a.kind,startLine:a.startLine,endLine:a.endLine,callees:R.length}),R.length>0&&(Y+=1),V+=R.length,{symbolId:a.symbolId,callees:R}}),()=>({definitions:o.length,concurrency:e.concurrency??8,definitionsWithCallees:Y,callees:V})):Promise.resolve([]),A,O;i&&t&&r.length>0&&o.length>0&&Ze()?[A,O]=await ne([J(),Q()]):(A=await J(),O=await Q()),Ke($),Ve(Z);let X=0,be=s?await d("rust.semantic.worker.signatures",()=>P(l,e.concurrency??8,async a=>{let w=await le(c.client,e.projectRoot,a,n);return w&&(X+=1),{symbolId:a.symbolId,signature:w}}),()=>({definitions:l.length,concurrency:e.concurrency??8,signaturesFound:X})):[];return{available:!0,references:A.filter(a=>a.complete).map(a=>[a.symbolId,a.references]),incompleteReferenceSymbolIds:A.filter(a=>!a.complete).map(a=>a.symbolId),...t?{callees:O.map(a=>[a.symbolId,a.callees])}:{},...s?{signatures:be.map(a=>[a.symbolId,a.signature])}:{}}}async function Oe(e){return Pe(e.projectRoot,e.rustAnalyzerBinary,W(e).map(n=>n.relativePath),{requestTimeoutMs:e.requestTimeoutMs,readinessDeadlineMs:e.readinessDeadlineMs})}async function Pe(e,n,i,t){let s=Re(e,de(e,i.map(l=>({relativePath:l})))),r=ue(e,s),o=ye(n,r,s);return _.acquire(o,async()=>{let l=ce(s),u=new te(ie(n,r,k.env,Me),{requestTimeoutMs:t.requestTimeoutMs,configuration:l}),c=t.readinessDeadlineMs===void 0?null:{afterGeneration:u.serverStatusGeneration(),deadlineMs:t.readinessDeadlineMs},p=await E(()=>d("rust.semantic.worker.initialize",()=>u.initialize({processId:k.pid,rootUri:F(r,"."),capabilities:{textDocument:{references:{dynamicRegistration:!1},definition:{dynamicRegistration:!1},callHierarchy:{dynamicRegistration:!1},hover:{dynamicRegistration:!1}}},initializationOptions:l},{timeoutMs:t.requestTimeoutMs,deadlineMs:t.readinessDeadlineMs}),()=>({linkedProjects:s.length,relativePaths:i.length})),()=>u.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}));return{key:o,client:u,capabilities:p.capabilities,openedPaths:new Set,initializationReadiness:c}},l=>l.client.shutdownAndReap({deadlineMs:t.readinessDeadlineMs}))}async function je(e,n){let i=W(n).filter(c=>e.openedPaths.has(c.relativePath)?!1:Te(Ce(n.projectRoot,c.relativePath)));if(i.length===0)return await Se(e),0;let t=e.initializationReadiness,s=n.readinessDeadlineMs===void 0?null:{statusSnapshot:t?null:e.client.serverStatusSnapshot(),initializationGeneration:t?.afterGeneration,deadlineMs:n.readinessDeadlineMs},r=fe(e.client,n.projectRoot,i);for(let c of i)e.openedPaths.add(c.relativePath);let o=n.diagnosticsTimeoutMs??1e4,l=o;await d("rust.semantic.worker.diagnostics",()=>s?G(c=>(l=c,S(e.client,r,c)),o,s.deadlineMs):S(e.client,r,o),()=>({openedDocuments:r.length,timeoutMs:l}));let u=n.settleDelayMs??5e3;if(!s)await d("rust.semantic.worker.settle",()=>D(u),()=>({openedDocuments:r.length,settleDelayMs:u}));else{let c;await d("rust.semantic.worker.readiness",async()=>{let p=m=>d("rust.semantic.worker.settle",()=>D(m),()=>({openedDocuments:r.length,settleDelayMs:m})),f=s.initializationGeneration===void 0?await N(e.client,s.statusSnapshot,r.length,s.deadlineMs,u,Date.now,p):await C(e.client,s.initializationGeneration,r.length,s.deadlineMs,u,Date.now,p);s.initializationGeneration!==void 0&&(e.initializationReadiness=null),c=f?.health},()=>({phase:s.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:r.length,health:c}))}return r.length}async function Ne(e,n,i,t){let s=i.filter(f=>!e.openedPaths.has(f));if(s.length===0)return await Se(e),0;let r=e.initializationReadiness,o=t.readinessDeadlineMs===void 0?null:{statusSnapshot:r?null:e.client.serverStatusSnapshot(),initializationGeneration:r?.afterGeneration,deadlineMs:t.readinessDeadlineMs},l=[];for(let f of s)try{let m=F(n,f);e.client.didOpenTextDocument({uri:m,languageId:"rust",version:1,text:q(n,f,{inputKind:"indexed Rust source file"})}),e.openedPaths.add(f),l.push(m)}catch(m){if(!ee(m))throw m}let u=t.diagnosticsTimeoutMs??1e4,c=u;await d("rust.semantic.worker.diagnostics",()=>o?G(f=>(c=f,S(e.client,l,f)),u,o.deadlineMs):S(e.client,l,u),()=>({openedDocuments:l.length,timeoutMs:c}));let p=t.settleDelayMs??5e3;if(!o)await d("rust.semantic.worker.settle",()=>D(p),()=>({openedDocuments:l.length,settleDelayMs:p}));else{let f;await d("rust.semantic.worker.readiness",async()=>{let m=y=>d("rust.semantic.worker.settle",()=>D(y),()=>({openedDocuments:l.length,settleDelayMs:y})),b=o.initializationGeneration===void 0?await N(e.client,o.statusSnapshot,l.length,o.deadlineMs,p,Date.now,m):await C(e.client,o.initializationGeneration,l.length,o.deadlineMs,p,Date.now,m);o.initializationGeneration!==void 0&&(e.initializationReadiness=null),f=b?.health},()=>({phase:o.initializationGeneration===void 0?"didOpen":"initialize+didOpen",openedDocuments:l.length,health:f}))}return l.length}async function Se(e){let n=e.initializationReadiness;if(!n)return;let i;await d("rust.semantic.worker.readiness",async()=>{i=(await C(e.client,n.afterGeneration,0,n.deadlineMs,0)).health,e.initializationReadiness=null},()=>({phase:"initialize",openedDocuments:0,health:i}))}function Ge(e,n){for(let i of n){let t=se(e,i.uri);if(!(!t||t===".."||t.startsWith("../")||Ie(t)))return t}return null}function Be(e,n){return n.references&&!e.referencesProvider?"rust-analyzer initialized without textDocument/references support.":n.callees&&!e.callHierarchyProvider?"rust-analyzer initialized without call hierarchy support.":n.signatures&&!e.hoverProvider?"rust-analyzer initialized without hover support.":null}function De(e,n){let i=H(e),t=U(e),s=K(e);return{available:!1,reason:n,references:i.map(r=>[r.symbolId,[]]),...e.includeCallees?{callees:t.map(r=>[r.symbolId,[]])}:{},...e.includeSignatures?{signatures:s.map(r=>[r.symbolId,null])}:{}}}async function He(){await _.shutdownAll(e=>e.client.shutdownAndReap())}async function ke(e,n,i){e.deleteIfSame(n),await n.client.shutdownAndReap({deadlineMs:i})}function Ue(e,n,i){if(!e)return;let t=$e(e,n);t.definitions+=1,i.hasReferences&&(t.definitionsWithReferences+=1),t.references+=i.references,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ke(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.references.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithReferences:t.definitionsWithReferences,references:t.references,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function $e(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithReferences:0,references:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function Je(e,n,i){if(!e)return;let t=Ye(e,n);t.definitions+=1,i.hasCallees&&(t.definitionsWithCallees+=1),t.callees+=i.callees,t.durationMs+=i.durationMs,t.maxDurationMs=Math.max(t.maxDurationMs,i.durationMs),i.slow&&(t.slowTasks+=1)}function Ve(e){if(!e)return;let n=[...e.entries()].sort(([i,t],[s,r])=>r.durationMs-t.durationMs||i.localeCompare(s));for(let[i,t]of n)M({type:"span",name:"rust.semantic.worker.callees.by-file",durationMs:t.durationMs,ok:!0,relativePath:i,definitions:t.definitions,definitionsWithCallees:t.definitionsWithCallees,callees:t.callees,maxDurationMs:t.maxDurationMs,slowTasks:t.slowTasks,aggregate:"sum-task-duration"})}function Ye(e,n){let i=e.get(n);if(i)return i;let t={definitions:0,definitionsWithCallees:0,callees:0,durationMs:0,maxDurationMs:0,slowTasks:0};return e.set(n,t),t}function we(e){if(e===void 0||e==="")return null;let n=Number(e);return Number.isInteger(n)&&n>=0?n:null}function Ze(){let e=k.env.SCIP_RUST_SEMANTIC_PARALLEL_OPERATIONS;return e!=="0"&&e!=="false"}function g(e,n,i){ve(e,JSON.stringify(n));let t=new Int32Array(i);Atomics.store(t,0,1),Atomics.notify(t,0)}export{ke as discardRustAnalyzerSession};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-session-worker.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as
|
|
1
|
+
import{A as p,B as q,C as r,m as b,n as c,o as d,p as e,q as f,r as g,s as h,t as i,u as j,v as k,w as l,x as m,y as n,z as o}from"./chunk-DQLPXMH6.js";import{a}from"./chunk-ILMHV3KM.js";import"./chunk-SMNXQT5Z.js";import"./chunk-IZYYAFN5.js";import"./chunk-WUPW3UN3.js";import"./chunk-MNE7YG56.js";import"./chunk-46XGSFNI.js";export{q as calleesForDefinition,l as cargoManifestsForDefinitions,i as hoverToRustSignature,h as hoverWithRetry,m as openDefinitionDocuments,p as referencesWithCompletion,o as referencesWithRetry,b as runRustAnalyzerReferenceBatch,a as runWithConcurrency,j as rustAnalyzerInitializationOptions,k as rustAnalyzerSessionRoot,d as rustRequestCalleeDefinitions,c as rustRequestReferenceDefinitions,f as rustRequestSessionDefinitions,e as rustRequestSignatureDefinitions,g as signatureForDefinition,r as sleep,n as waitForOpenedDocuments};
|
|
2
2
|
//# sourceMappingURL=rust-semantic-worker.js.map
|
|
@@ -22,6 +22,12 @@ interface SymbolMatch extends SymbolLocation {
|
|
|
22
22
|
symbol: string;
|
|
23
23
|
relativePath: string;
|
|
24
24
|
}
|
|
25
|
+
interface SymbolResolutionCandidate {
|
|
26
|
+
symbol: string;
|
|
27
|
+
shortName: string;
|
|
28
|
+
relativePath: string;
|
|
29
|
+
startLine: number;
|
|
30
|
+
}
|
|
25
31
|
/**
|
|
26
32
|
* A full definition record: SymbolMatch plus per-symbol metadata
|
|
27
33
|
* (leaf name, parent type, kind, documentation, enclosing symbol).
|
|
@@ -65,4 +71,4 @@ interface ScipLocalSymbol {
|
|
|
65
71
|
raw: string;
|
|
66
72
|
}
|
|
67
73
|
|
|
68
|
-
export type { IndexedDefinition as I, SymbolMatch as S, ScipSymbol as a, ScipLocalSymbol as b };
|
|
74
|
+
export type { IndexedDefinition as I, SymbolMatch as S, ScipSymbol as a, ScipLocalSymbol as b, SymbolResolutionCandidate as c };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as l}from"./chunk-XKWKXZKW.js";import{a as x,c as b,j as S}from"./chunk-DAFAHMNB.js";import{Ba as h,j as u,pa as g}from"./chunk-HZ72SESS.js";import{g as f}from"./chunk-FJH2NW7J.js";import"./chunk-WUPW3UN3.js";import"./chunk-AIE7TFJW.js";import{c as p,d as c}from"./chunk-HGFDYOVB.js";import"./chunk-MNE7YG56.js";import"./chunk-46XGSFNI.js";import{parentPort as s,workerData as j}from"worker_threads";import{existsSync as y,statSync as E}from"fs";import{join as T}from"path";function I(){return process.env.SCIP_QUERY_PROJECT_ROOT??process.cwd()}var m;function q(e=I(),t=void 0){if(t===void 0&&m?.projectRoot===e)return m;let r=b(e),n=u(e,r),o=process.env.SCIP_QUERY_INDEX_DB;if(o)return{projectRoot:e,config:r,paths:n,dbPath:o,dbPathSource:"env",gitContext:t};if(y(n.dbPath))return{projectRoot:e,config:r,paths:n,dbPath:n.dbPath,dbPathSource:"configured",gitContext:t};let i=T(e,"index.db");return{projectRoot:e,config:r,paths:n,dbPath:i,dbPathSource:"root-fallback",rootFallbackWarning:R(i,n.dbPath),gitContext:t}}function k(e,t={}){let{config:r,paths:n,dbPath:o,dbPathSource:i,rootFallbackWarning:d,gitContext:C}=q(e);if(!y(o))throw new Error("No index.db found. Run: scip-query reindex");t.warnOnRootFallback&&i==="root-fallback"&&d&&console.error(d);let v={dbPath:o,indexPath:process.env.SCIP_QUERY_INDEX_SCIP??n.indexPath,projectRoot:e,sharedEvidenceDbPath:g(e,r,C),entryRoots:r.entryRoots,semantic:r.semantic,suppressions:r.suppressions,declaredCouplings:r.declaredCouplings,locality:r.locality,architecture:r.architecture,coverageContracts:r.coverageContracts,docs:r.docs},D=f(e);return new l(v,D)}function R(e,t){let r="unknown time";try{r=E(e).mtime.toISOString()}catch{}return`warning: using legacy project-root index.db (${e}, modified ${r}) because the configured index was not found at ${t}. This fallback may be stale; run 'scip-query reindex' to refresh the configured index.`}var a=M(j);if(!s)throw new Error("TypeScript mailbox worker requires a parent port.");if(a.kind==="index"){let e=new x({projectRoot:a.projectRoot,currentGeneration:()=>h(a.dbPath)});s.on("message",t=>{let r=w(t);P(r,()=>e.handle(r.payload.baseGeneration,r.payload.request),()=>e.status())})}else{let e=new S({openDb:()=>k(a.projectRoot)});s.on("message",t=>{let r=w(t),n=p();c(r.payload.profileEnvironment??{});try{P(r,()=>e.handle(r.payload.generation,r.payload.request),()=>e.status())}finally{c(n)}})}function P(e,t,r){let n;try{if(Date.now()>e.deadlineAtMs)throw new Error("TypeScript mailbox request expired before processing.");let o=t();if(Date.now()>e.deadlineAtMs)throw new Error("TypeScript mailbox request expired while the worker was processing it.");n={kind:"response",requestId:e.requestId,ok:!0,result:o,status:r()}}catch(o){n={kind:"response",requestId:e.requestId,ok:!1,error:o instanceof Error?o.message:String(o),status:r()}}s.postMessage(n)}function M(e){if(!e||typeof e!="object")throw new Error("TypeScript mailbox worker data is missing.");let t=e;if(t.kind==="index"&&typeof t.projectRoot=="string"&&typeof t.dbPath=="string")return{kind:"index",projectRoot:t.projectRoot,dbPath:t.dbPath};if(t.kind==="semantic"&&typeof t.projectRoot=="string")return{kind:"semantic",projectRoot:t.projectRoot};throw new Error("TypeScript mailbox worker data is invalid.")}function w(e){if(!e||typeof e!="object")throw new Error("TypeScript mailbox worker request is missing.");let t=e;if(t.kind!=="request"||typeof t.requestId!="string"||!Number.isSafeInteger(t.deadlineAtMs)||typeof t.payload!="object"||t.payload===null)throw new Error("TypeScript mailbox worker request is invalid.");return t}
|
|
2
|
+
//# sourceMappingURL=typescript-mailbox-worker.js.map
|