scip-query 0.19.6 → 0.19.10
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 +116 -0
- package/README.md +156 -44
- package/dist/augment-vue-worker.js +1 -1
- package/dist/chunk-26QA6FAI.js +8 -0
- package/dist/{chunk-J7VT2CRB.js → chunk-2HPVVXM5.js} +2 -2
- package/dist/chunk-2KAZEZ6M.js +2 -0
- package/dist/chunk-32LVLCLN.js +40 -0
- package/dist/{chunk-2CVXCGL4.js → chunk-3CLX5EOX.js} +2 -2
- package/dist/{chunk-5OC3HWP5.js → chunk-3G66UZBH.js} +2 -2
- package/dist/{chunk-S2GP3CU3.js → chunk-3ORVDL3H.js} +2 -2
- package/dist/chunk-46XGSFNI.js +2 -0
- package/dist/chunk-4MAK2HOY.js +6 -0
- package/dist/chunk-4TURLRL5.js +16 -0
- package/dist/chunk-4UQVNCQE.js +2 -0
- package/dist/chunk-55Q3WLZX.js +2 -0
- package/dist/{chunk-OQ2A4G2G.js → chunk-5E4WNAVD.js} +2 -2
- package/dist/{chunk-YGQN3XGZ.js → chunk-5I5G2QOX.js} +2 -2
- package/dist/chunk-6LDJQXAH.js +2 -0
- package/dist/{chunk-WXAAURU7.js → chunk-6O5TICIZ.js} +2 -2
- package/dist/{chunk-OBKDTVZ3.js → chunk-6SHPK5ZE.js} +2 -2
- package/dist/chunk-7BAVHKMJ.js +49 -0
- package/dist/chunk-7O5IKBTZ.js +16 -0
- package/dist/chunk-7PIO7NKH.js +60 -0
- package/dist/chunk-7S5E7KWT.js +2 -0
- package/dist/{chunk-GK3GRUJX.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-AQOFWNQJ.js +1 -0
- package/dist/{chunk-MGBJHRFB.js → chunk-AZJQQKDD.js} +2 -2
- package/dist/{chunk-IYAOX36F.js → chunk-B2PX5I6M.js} +2 -2
- package/dist/{chunk-EVOC5I5I.js → chunk-B7PBSLZN.js} +2 -2
- package/dist/{chunk-ZLJLE6LK.js → chunk-BBW6JFHN.js} +2 -2
- package/dist/{chunk-NBRUH7OE.js → chunk-BDCC2NPY.js} +2 -2
- package/dist/{chunk-DD5BOU5I.js → chunk-BNXCIFVY.js} +2 -2
- package/dist/{chunk-FHCTEANE.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-QBYYWGAT.js → chunk-CJST5ETY.js} +2 -2
- package/dist/chunk-DAFAHMNB.js +42 -0
- package/dist/chunk-DHEQMPLW.js +2 -0
- package/dist/{chunk-336DC5NJ.js → chunk-DQGFVPUV.js} +2 -2
- package/dist/chunk-DQLPXMH6.js +8 -0
- package/dist/chunk-EKZTZXHZ.js +117 -0
- package/dist/{chunk-KLVJABXA.js → chunk-EN3O7VJA.js} +2 -2
- package/dist/{chunk-U5CNPPTZ.js → chunk-EW2NTSFA.js} +2 -2
- package/dist/chunk-F3Z4OUDS.js +8 -0
- package/dist/chunk-FJH2NW7J.js +66 -0
- package/dist/{chunk-3OIKRYU5.js → chunk-FKSELJQF.js} +2 -2
- package/dist/chunk-FTFP6O3L.js +11 -0
- package/dist/chunk-FYLK2DEJ.js +2 -0
- package/dist/chunk-GH74ASD6.js +11 -0
- package/dist/{chunk-NQLSSVOB.js → chunk-GMXWZP2B.js} +2 -2
- package/dist/chunk-GOUBFH5O.js +3 -0
- package/dist/{chunk-RJHCPSZ7.js → chunk-HLF2TX6R.js} +2 -2
- package/dist/{chunk-PC44K7RF.js → chunk-HX4GQPZP.js} +2 -2
- package/dist/chunk-HX7M4BDI.js +30 -0
- package/dist/chunk-HZ72SESS.js +128 -0
- package/dist/{chunk-YTUD45PU.js → chunk-IB2N4FIY.js} +2 -2
- package/dist/chunk-ILMHV3KM.js +2 -0
- package/dist/chunk-IZYYAFN5.js +2 -0
- package/dist/{chunk-A43URCQ3.js → chunk-JAYYFEQY.js} +2 -2
- package/dist/{chunk-RWRLUZ6U.js → chunk-JDOEX4E6.js} +2 -2
- package/dist/chunk-JFGGXWQF.js +947 -0
- package/dist/chunk-JN4NMBEX.js +8 -0
- package/dist/{chunk-JELJLXEE.js → chunk-JVYA47YU.js} +2 -2
- package/dist/{chunk-F42A3AKG.js → chunk-JW56N3KI.js} +2 -2
- package/dist/{chunk-FQTPPXNA.js → chunk-JZ2OXNWB.js} +2 -2
- package/dist/chunk-KFZNKUNT.js +2 -0
- package/dist/chunk-KMKTIO2G.js +8 -0
- package/dist/chunk-L5GJNV2T.js +8 -0
- package/dist/{chunk-RBFFD4V2.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-MLGTCX56.js → chunk-MKCDWWGV.js} +2 -2
- package/dist/chunk-MNE7YG56.js +2 -0
- package/dist/{chunk-YWB2EBNB.js → chunk-MRXBEXSY.js} +2 -2
- package/dist/chunk-MV7OWDUX.js +2 -0
- package/dist/{chunk-2GSQR6YA.js → chunk-N5W4YZMK.js} +2 -2
- package/dist/chunk-NGEXCJJW.js +11 -0
- package/dist/{chunk-CYJM7CYF.js → chunk-NIW6JDC5.js} +2 -2
- package/dist/{chunk-YHXBD52M.js → chunk-O64IZ6UX.js} +2 -2
- package/dist/chunk-PBUQFCNB.js +16 -0
- package/dist/{chunk-UQK5CRUK.js → chunk-POAVPHH7.js} +2 -2
- package/dist/{chunk-TYQ76QHQ.js → chunk-PQCI4SQX.js} +2 -2
- package/dist/chunk-PXY7F6Y4.js +5 -0
- package/dist/chunk-RDO52JGY.js +2 -0
- package/dist/chunk-RJT3TUUZ.js +2 -0
- package/dist/{chunk-OHWZKLVA.js → chunk-RUJURYSV.js} +2 -2
- package/dist/{chunk-CSTYYXKC.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-QQWOFXNW.js → chunk-SRAFT254.js} +2 -2
- package/dist/{chunk-6XHTISLI.js → chunk-SXP2MBJH.js} +2 -2
- package/dist/chunk-T7YQSHPQ.js +3 -0
- package/dist/{chunk-2EZSOTSY.js → chunk-TFRAYKN6.js} +2 -2
- package/dist/{chunk-XVJ3V7LM.js → chunk-UJCOIXDY.js} +2 -2
- package/dist/{chunk-7LABSJSR.js → chunk-UJPRPGCO.js} +5 -5
- package/dist/chunk-W4ETQAXM.js +2 -0
- package/dist/chunk-WCCFZ7V7.js +113 -0
- package/dist/chunk-WUPW3UN3.js +3 -0
- package/dist/{chunk-VP542C25.js → chunk-WXZLAAWK.js} +2 -2
- package/dist/{chunk-LMFVTUW2.js → chunk-X54AGLVX.js} +2 -2
- package/dist/chunk-XKWKXZKW.js +20 -0
- package/dist/{chunk-OP3MTFJR.js → chunk-XSRF6Q77.js} +2 -2
- package/dist/chunk-Y2MVPNKY.js +5 -0
- package/dist/{chunk-6XFC7PQ5.js → chunk-YKUU5AIC.js} +2 -2
- package/dist/chunk-YLCJLTPL.js +2 -0
- package/dist/{chunk-47X75ZKH.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-ZK26BAQL.js +2 -0
- package/dist/{chunk-UUJBLG6J.js → chunk-ZTETIQ35.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/command-descriptors-4A4HWV4F.js +642 -0
- package/dist/{config-types-BWQ5xPGI.d.ts → config-types-jVM3D7MA.d.ts} +72 -2
- package/dist/{db-B0r1o7Vt.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-CFnlCiTz.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 +26 -25
- package/dist/reindex.d.ts +7 -3
- package/dist/reindex.js +34 -33
- package/dist/runtime.d.ts +5 -10
- 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-DCvnlZCu.d.ts → scip-cli-BnEwZRLJ.d.ts} +2 -2
- 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 +28 -5
- package/docs/CLI_JSON_OUTPUT.md +176 -3
- package/docs/COMMAND_REFERENCE.md +89 -87
- 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 +146 -0
- package/docs/TELEMETRY_RETENTION.md +16 -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/cli-output-page.schema.json +104 -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 +9 -8
- package/skills/_shared/SKILL.md +5 -3
- 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 +9 -8
- 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 +4 -4
- 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 +3 -3
- 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 +16 -11
- package/skills/scip-verify/references/calibrate-detectors.md +7 -7
- package/dist/chunk-24QNP7MN.js +0 -2
- package/dist/chunk-26X7KCJR.js +0 -5
- package/dist/chunk-273W2U4Y.js +0 -40
- package/dist/chunk-2OXVAGGT.js +0 -3
- package/dist/chunk-2ZOCHAL2.js +0 -8
- package/dist/chunk-35SQLYCQ.js +0 -2
- package/dist/chunk-4CGVLUDP.js +0 -18
- package/dist/chunk-4RI4BJGT.js +0 -8
- package/dist/chunk-52HQTTPB.js +0 -2
- package/dist/chunk-64MNV6AB.js +0 -8
- package/dist/chunk-7E3TH5ZN.js +0 -33
- package/dist/chunk-7Q6VYYCH.js +0 -2
- package/dist/chunk-A63U2W3P.js +0 -3
- package/dist/chunk-ADFSIJP2.js +0 -16
- package/dist/chunk-AOLE4DYM.js +0 -6
- package/dist/chunk-APMMR5Y2.js +0 -2
- package/dist/chunk-B5MHCHP3.js +0 -107
- package/dist/chunk-DGAGY7RJ.js +0 -60
- package/dist/chunk-DGMCFMPG.js +0 -11
- package/dist/chunk-E2ZXPB7J.js +0 -38
- package/dist/chunk-FKGN4A4E.js +0 -61
- package/dist/chunk-G4UQL4CP.js +0 -2
- package/dist/chunk-GA64UPMI.js +0 -6
- package/dist/chunk-HEBAY673.js +0 -2
- package/dist/chunk-HELS7KFF.js +0 -2
- package/dist/chunk-IPDCSB6N.js +0 -6
- package/dist/chunk-JERWGHQT.js +0 -16
- package/dist/chunk-JJJCO4QC.js +0 -945
- package/dist/chunk-JZNLMHWY.js +0 -56
- package/dist/chunk-K42M2KWT.js +0 -2
- package/dist/chunk-KP4KBDVF.js +0 -3
- package/dist/chunk-LRTP3DKL.js +0 -3
- package/dist/chunk-N3SE646F.js +0 -2
- package/dist/chunk-NN4ZIRPK.js +0 -8
- package/dist/chunk-P6HBYNBE.js +0 -5
- package/dist/chunk-QHKUY4FW.js +0 -2
- package/dist/chunk-QHRL4LKM.js +0 -2
- package/dist/chunk-SHKZ7OVJ.js +0 -35
- package/dist/chunk-TFUU5MQQ.js +0 -2
- package/dist/chunk-UXP636P5.js +0 -144
- package/dist/chunk-VEVBIAOJ.js +0 -16
- package/dist/chunk-VKRQDBW5.js +0 -9
- package/dist/chunk-VOQFGC2W.js +0 -67
- package/dist/chunk-WMXRRBII.js +0 -8
- package/dist/chunk-X3NLZHPA.js +0 -20
- package/dist/chunk-XF3KLXN3.js +0 -11
- package/dist/chunk-YCPASUCX.js +0 -2
- package/dist/chunk-YLVE3SXZ.js +0 -20
- package/dist/chunk-Z2LHPIOM.js +0 -2
- package/dist/chunk-Z5QQPJ3U.js +0 -30
- package/dist/chunk-ZTTISZ7J.js +0 -112
- package/dist/command-descriptors-SJDZ7QGR.js +0 -617
- package/dist/direct-navigation-HTKOZEOM.js +0 -3
package/dist/reindex-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as de,b as le}from"./chunk-PBUQFCNB.js";import{a as Rn}from"./chunk-ILMHV3KM.js";import{a as In}from"./chunk-P5XHIJHI.js";import{a as O}from"./chunk-XKWKXZKW.js";import{a as qt,b as Wt,d as Ce,e as Qt,i as Sn,j as Ue,l as bn,m as Pn,n as xn,o as qe}from"./chunk-L5GJNV2T.js";import"./chunk-IZYYAFN5.js";import{$ as zt,A as Nt,Ba as yn,C as Ct,D as $t,E as ce,Q as Gt,R as Bt,T as X,V as Ut,Z as Ht,_ as Jt,aa as Xt,b as q,ba as Vt,c as ae,ca as Yt,d as Me,da as Kt,e as Oe,ea as Zt,f as bt,fa as en,ga as tn,ha as nn,ia as rn,ja as an,k as Ae,ka as on,la as sn,m as se,ma as Q,na as ue,oa as cn,qa as $e,r as vt,ra as dn,sa as Ge,t as Ft,ta as ln,ua as un,wa as Be,y as z,ya as pe,za as hn}from"./chunk-HZ72SESS.js";import{b as At,c as Lt,f as k}from"./chunk-FJH2NW7J.js";import{a as re,b as St,c as ie,g as H,i as jt,j as Tt,k as wt,n as Dt,o as kt}from"./chunk-WUPW3UN3.js";import{l as L,n as Et,o as Ne,p as _t,r as Mt,s as Ot,u as pn,x as gn,y as fn,z as mn}from"./chunk-AIE7TFJW.js";import{e as T,f as W}from"./chunk-HGFDYOVB.js";import{a as b,b as It,c as J,d as A}from"./chunk-MNE7YG56.js";import{a as yt,c as De,f as ke,g as ne,h as D}from"./chunk-46XGSFNI.js";import{a as oe,b as Pt,c as xt,d as Le,e as Rt}from"./chunk-KFZNKUNT.js";import{execFileSync as yo}from"child_process";import{createHash as So}from"crypto";import{copyFileSync as je,existsSync as j,mkdirSync as _e,mkdtempSync as bo,readdirSync as Lr,renameSync as Nr,rmSync as B,statSync as Po}from"fs";import{basename as Ee,dirname as y,extname as xo,join as R,resolve as jr}from"path";import{platform as Ro}from"os";import{execFileSync as En}from"child_process";import{createHash as oi}from"crypto";import{existsSync as ge,statSync as si}from"fs";import{createRequire as ci}from"module";import{platform as di}from"os";import{dirname as vn,join as V}from"path";var li=ci(import.meta.url),N={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function We(e){return[e.indexerBinary,...e.binaryAliases??[]]}function fe(e){let t=We(e);return t.length===1?t[0]:t.join(" or ")}function C(e){for(let t of We(e)){let n=xt(t);if(n)return n}return pi(e)}function _n(e){return C(e)!==null||ui(e)}function ui(e){return Fn(e)!==null}function pi(e){let t=Fn(e);if(!t)return null;let r=JSON.parse(D(t,"indexer package manifest")).bin;if(!r)return null;if(typeof r=="string")return V(vn(t),r);for(let i of We(e)){let a=r[i];if(a)return V(vn(t),a)}return null}function Fn(e){if(!e.bundledNpmPackage)return null;try{return li.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function jn(e,t){for(let n of e.projectLocalBinaries??[]){let r=V(t,n);if(ge(r))return r}return null}function Tn(e,t){for(let n of e.projectLocalBinaries??[]){let r=V(t,n);if(ge(r))return Dn(t,n,r)}return null}function wn(e,t){let n=gi(e,t);if(!n||n.canonicalPath!==t.canonicalPath||n.sha256!==t.sha256||n.size!==t.size||n.mtimeMs!==t.mtimeMs||n.device!==t.device||n.inode!==t.inode||n.executable!==t.executable)throw new Error(`refusing changed project-local indexer ${t.relativePath}; review the current file and rerun with --trust-project-tools`)}function gi(e,t){try{return Dn(e,t.relativePath,t.configuredPath)}catch{return null}}function Dn(e,t,n){let r={maxBytes:268435456,inputKind:"project-local indexer"},i=Tt(e,t,r),a=wt(e,t,r),o=si(i.absolutePath);return{configuredPath:n,canonicalPath:i.absolutePath,relativePath:t,sha256:oi("sha256").update(a).digest("hex"),size:i.size,mtimeMs:i.mtimeMs,device:i.device,inode:i.inode,executable:(o.mode&73)!==0}}function kn(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||Mn(n,t))return t;let r=fi(n,t);return r?{...t,DOTNET_ROOT:r}:t}function fi(e,t){for(let n of mi(t))if(Mn(e,{...t,DOTNET_ROOT:n}))return n;return null}function mi(e){let t=[],n=e.DOTNET_ROOT;if(n&&ge(n)&&t.push(n),di()==="darwin"&&oe("brew"))try{let r=En("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=V(r,"libexec");ge(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function Mn(e,t){try{return En(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var On=$t({kind:"file-dependency-graph",invalidation:ce("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:Ri}),hi=At("file-dep-graph",{clearGroups:["whole-project"]});function $(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",a=bi(t,r,i);return hi.get(e,a,()=>{let o=new Set(k(e,{includeIgnored:!1})),s=Nt(e),d=0,c=0,l=null,u=!1,p=0,h=0;return T("file-dep-graph.product",()=>{if(s){let f=On.read(e,a,s);if(f){u=!0;let P=xi(f);return d=f.sourceFileCount,c=f.sourceEdgeCount,p=f.scipEdgeCount,h=P.size,l=f.sourceDependencyFingerprint,P}}let g=T("file-dep-graph.source-imports",()=>{let f=yi(e,o,t,i);return d=f.files.length,c=f.edges.length,l=f.fingerprint,f},()=>({scope:t??null,sourceEdges:i,files:d,edges:c})),m=new Map,S=(f,P)=>_i(e,m,o,f,P);T("file-dep-graph.scip-edges",()=>{for(let f of Ei(e,t,r))p+=1,S(f.from_file,f.to_file)},()=>({scope:t??null,edges:p}));for(let f of g.edges)S(f.fromFile,f.toFile);return h=m.size,s&&On.write(e,a,s,{sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:p,graph:Pi(m)}),m},()=>({scope:t??null,available:s!==null,hit:u,files:d,sourceEdges:c,sourceEdgeMode:i,scipEdges:p,graphFiles:h,sourceDependencyFingerprint:l}))})}function yi(e,t,n,r){let i=[],a=[];for(let o of t)if(!(n&&!o.includes(n))){i.push(o);for(let s of Bt(e,o))s.sourcePath&&a.push({fromFile:o,toFile:s.sourcePath});if(r==="imports-and-reexports")for(let s of Gt(e,o))s.sourcePath&&a.push({fromFile:o,toFile:s.sourcePath})}return{files:i,edges:a,fingerprint:Si(i,a)}}function Si(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return z(JSON.stringify({files:e,edges:n}))}function bi(e,t,n){return`edge-mode-v3:${t}:${n}:${e??"<all>"}`}function Pi(e){return[...e].map(([t,n])=>[t,[...n]])}function xi(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function Ri(e){let t=JSON.parse(e);return Ii(t)?t:null}function Ii(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.sourceDependencyFingerprint=="string"&&typeof t.sourceFileCount=="number"&&typeof t.sourceEdgeCount=="number"&&typeof t.scipEdgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(vi)}function vi(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Ei(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],a=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
|
|
2
2
|
d1.relative_path AS from_file,
|
|
3
3
|
d2.relative_path AS to_file
|
|
4
4
|
FROM mentions m
|
|
@@ -16,7 +16,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
16
16
|
WHERE d1.id != d2.id
|
|
17
17
|
${a}
|
|
18
18
|
${e.pathExclusionsFor("d1","d2")}
|
|
19
|
-
${r}`,...i)}function
|
|
19
|
+
${r}`,...i)}function _i(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function he(e){let t=me(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let p=re(u.path,["typescript"]);return p==="config"||p==="ambient"}).map(u=>u.path),a=me([...t,...i]),o=a.find(u=>!r.has(u)),s=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,d=!o&&a.some(u=>An(r.get(u))),c=z(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:me(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,p){if(!n.has(u))return G("target-outside-project");if(s)return G("duplicate-input-path");if(o)return G("missing-input-fingerprint");if(d)return G("unreadable-input");let h=[],g,m;if(e.graph===null)h.push("dependency-graph-unavailable"),m="whole-project",g=a;else{let P=ji(u,e.graph,l);if(P.find(x=>!r.has(x)))return G("missing-input-fingerprint");if(g=me([...P,...i]),g.some(x=>An(r.get(x))))return G("unreadable-input");m="dependency-closure"}let S=g.map(P=>Ti(r.get(P)));return{version:1,key:z(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:c,inputs:S})),mode:m,inputFiles:g,reasons:h}}}}function Fi(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let o of[...t.get(a)??[]].sort())n.has(o)||r.push(o)}}return[...n].sort()}function ji(e,t,n){let r=n.get(e);if(r)return r;let i=Fi(e,t);return n.set(e,i),i}function Ti(e){return{path:e.path,size:e.size,hash:e.hash}}function An(e){return e.size<0||e.hash==="unreadable"}function G(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function me(e){return[...new Set(e)].sort()}var As=Lt("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function Ln(e){return k(e,{includeIgnored:!1}).filter(X).sort()}var wi="typescript-reference-fragment-v2",Di=Ct({kind:"typescript-reference-fragments",invalidation:ce("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:ki});function Nn(e,t,n,r=e){let i=Ln(e),a=he({projectFiles:i,snapshot:t,graph:$(e),engineIdentity:Ut()}),o=[...n].map(([s,d])=>({relativePath:s,contentHash:a.identityFor(s,wi).key,value:[...d]}));if(o.some(s=>s.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return Di.writeBatch(r,o.map(s=>({...s,contentHash:s.contentHash}))),o.length}function ki(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(Mi)?null:t}catch{return null}}function Mi(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as Ai}from"crypto";import{existsSync as Li}from"fs";import{dirname as Ni,join as $n}from"path";function He(e){let t=new Set;for(let n of e.uncertainty)t.add(n);e.projectIdentityChanged&&t.add("project-identity-changed");for(let n of e.changes)n.kind==="added"&&t.add("file-added"),n.kind==="deleted"&&t.add("file-deleted"),n.inputKind==="config"&&t.add("configuration-changed"),n.inputKind==="ambient"&&t.add("ambient-declaration-changed"),n.inputKind==="other"&&t.add("unclassified-input");return{fullProject:t.size>0,reasons:[...t].sort()}}function ye(e,t,n){let r=e.changes.map(s=>s.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=He(e),o=new Set(a.reasons);return r.some(s=>!i.has(s))&&o.add("changed-file-outside-project"),t===null?(o.add("dependency-graph-unavailable"),Cn(r,i,o)):o.size>0?Cn(r,i,o):{mode:"closure",changedFiles:r,affectedFiles:Oi(r,t,i),reasons:[]}}function Cn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Oi(e,t,n){let r=new Map;for(let[o,s]of t)if(n.has(o))for(let d of s){if(!n.has(d))continue;let c=r.get(d)??new Set;c.add(o),r.set(d,c)}let i=new Set(e),a=[...e];for(let o=0;o<a.length;o+=1){let s=a[o];if(s!==void 0)for(let d of r.get(s)??[])i.has(d)||(i.add(d),a.push(d))}return[...i].sort()}var Ci="<global-symbols>";function $i(e){let t=[];for(let n of e.all(`
|
|
20
20
|
SELECT relative_path, language, position_encoding, text
|
|
21
21
|
FROM documents
|
|
22
22
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -43,7 +43,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
43
43
|
FROM defn_enclosing_ranges r
|
|
44
44
|
JOIN documents d ON d.id = r.document_id
|
|
45
45
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
46
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
46
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:Je(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
47
47
|
SELECT d.relative_path,
|
|
48
48
|
c.chunk_index,
|
|
49
49
|
m.role,
|
|
@@ -58,7 +58,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
58
58
|
JOIN chunks c ON c.id = m.chunk_id
|
|
59
59
|
JOIN documents d ON d.id = c.document_id
|
|
60
60
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
61
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
61
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:Je(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
62
62
|
SELECT g.symbol,
|
|
63
63
|
g.display_name,
|
|
64
64
|
g.kind,
|
|
@@ -72,8 +72,8 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
72
72
|
) AND NOT EXISTS (
|
|
73
73
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
74
74
|
)
|
|
75
|
-
`))t.push({relativePath:
|
|
76
|
-
`);n.set(r,a.digest("hex"))}return n}function mi(e,t){let n=[],r=[],i=[],a=[],s=new Set([...e.keys(),...t.keys()]);for(let o of[...s].sort()){let c=e.get(o),d=t.get(o);c===void 0?n.push(o):d===void 0?i.push(o):c!==d?r.push(o):a.push(o)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function Ne(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),s=e.affectedFiles.filter(c=>!i.has(c)).sort(),o=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:o/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:s}}function Ce(e,t=xi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),s=(d,l)=>{let u=r();return Fn(e.refreshResult,d,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return s("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return s("candidate-index-unavailable");let o=null,c=null;try{o=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let d=[...new Set([...t.indexedPaths(o),...t.indexedPaths(c)])].sort(),l=te(e.previousSnapshot,e.currentSnapshot),u=new Set(d),p=l.changes.length>0&&!Ae(l).fullProject&&l.changes.every(b=>u.has(b.path)),h=fe(l,p?t.dependencyGraph(o):new Map,d),g=mi(t.factDigests(o),t.factDigests(c)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:Ne(h,g,d.length)}}catch(d){return s("oracle-error",d instanceof Error?d.message:String(d))}finally{In(o),In(c)}}function vn(e,t,n,r=Date.now()){return Fn(e,t,r,0,n)}function hi(e){let t=ui(e);return{latestPath:Rn(t,"affected-shadow-latest.json"),historyPath:Rn(t,"affected-shadow.jsonl")}}function En(e,t,n=Ri){let r=hi(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var yi=8*1024*1024,Si=Dt;function bi(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function Pi(e,t,n=yi){kt(e,bi(t),{maxSegmentBytes:n,previousSuffix:Si})}function Le(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var xi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>li(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>j(e),dependencyGraph:e=>L(e),factDigests:e=>gi(e)},Ri={appendHistory:Pi,writeLatest:(e,t)=>Pt(e,t,{spacing:2,trailingNewline:!0})};function Fn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function In(e){try{e?.close()}catch{}}import{existsSync as wn,readdirSync as Ii}from"fs";import{isAbsolute as vi,join as $e,resolve as Ei}from"path";var Fi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:A.language,indexerBinary:A.indexerBinary,checkCommand:`${A.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:A.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:A.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",vi(r)?r:Ei(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",_n(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",_n(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=$e(e,"vendor","bin","scip-php"),r=$e(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",wn(r)?r:wn(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Be(e){return Fi[e]}function _n(e,t){let n;try{n=Ii(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return $e(e,i);return null}import{createHash as wi}from"crypto";import{copyFileSync as _i,existsSync as jn,rmSync as Dn}from"fs";import{resolve as ji}from"path";import Mn from"better-sqlite3";var Di={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},ki={idx_chunks_doc_id:{table:"chunks",columns:["document_id"]},idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_global_symbols_symbol:{table:"global_symbols",columns:["symbol"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function On(e){let t=P(),n=Ti(e.affectedFiles);if(Mi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Dn(e.candidateDbPath,{force:!0}),!jn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!jn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");kn(e.previousDbPath,"previous SQLite generation",!1),kn(e.miniDbPath,"incremental SQLite mini database"),_i(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Mn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ge(r,"main","candidate SQLite generation"),Ge(r,"incremental","incremental SQLite mini database"),Oi(r,n),Ai(r,n.length);let i=Ue(r,"main",!0),a=D(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{Li(r),Ni(r),Ci(r),e.onStage?.("after-delete"),$i(r),e.onStage?.("after-symbol-reconciliation"),Bi(r),e.onStage?.("after-insert"),Gi(r),Ui(r,n.length,a),e.onStage?.("before-commit")}).immediate(),An(r,"main","candidate SQLite generation");let c=[...Ji(r)].filter(([d,l])=>i.get(d)!==l).map(([d])=>d).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:c,durationMs:P()-t}}catch(i){try{r?.close()}finally{Dn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function Ti(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Mi(e,t,n){let r=[e,t,n].map(i=>ji(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function kn(e,t,n=!0){let r=new Mn(e,{readonly:!0,fileMustExist:!0});try{Ge(r,"main",t),n&&An(r,"main",t)}finally{r.close()}}function Ge(e,t,n){for(let[r,i]of Object.entries(Di)){let s=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:o,type:c,notnull:d,pk:l})=>({name:o,type:c.toUpperCase(),notnull:d,pk:l}));if(JSON.stringify(s)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ki)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),s=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(o=>o.name);if(a?.tbl_name!==i.table||JSON.stringify(s)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Tn(e,t,"documents",["relative_path"],n),Tn(e,t,"global_symbols",["symbol"],n)}function Tn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(o=>{if(o.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${o.name}')`).all().map(d=>d.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function An(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function Oi(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function Ai(e,t){let n=D(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=D(e,`SELECT COUNT(*) AS value
|
|
75
|
+
`))t.push({relativePath:Ci,kind:"global-symbol",values:Je(n)});return Gi(t)}function Gi(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[o])=>a.localeCompare(o))){let a=Ai("sha256");for(let o of i.sort())a.update(String(Buffer.byteLength(o))),a.update(":"),a.update(o),a.update(`
|
|
76
|
+
`);n.set(r,a.digest("hex"))}return n}function Bi(e,t){let n=[],r=[],i=[],a=[],o=new Set([...e.keys(),...t.keys()]);for(let s of[...o].sort()){let d=e.get(s),c=t.get(s);d===void 0?n.push(s):c===void 0?i.push(s):d!==c?r.push(s):a.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function ze(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),o=e.affectedFiles.filter(d=>!i.has(d)).sort(),s=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:s/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:o}}function Xe(e,t=zi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),o=(c,l)=>{let u=r();return qn(e.refreshResult,c,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return o("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return o("candidate-index-unavailable");let s=null,d=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),d=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let c=[...new Set([...t.indexedPaths(s),...t.indexedPaths(d)])].sort(),l=ie(e.previousSnapshot,e.currentSnapshot),u=new Set(c),p=l.changes.length>0&&!He(l).fullProject&&l.changes.every(S=>u.has(S.path)),h=ye(l,p?t.dependencyGraph(s):new Map,c),g=Bi(t.factDigests(s),t.factDigests(d)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:ze(h,g,c.length)}}catch(c){return o("oracle-error",c instanceof Error?c.message:String(c))}finally{Gn(s),Gn(d)}}function Bn(e,t,n,r=Date.now()){return qn(e,t,r,0,n)}function Ui(e){let t=Ni(e);return{latestPath:$n(t,"affected-shadow-latest.json"),historyPath:$n(t,"affected-shadow.jsonl")}}function Un(e,t,n=Xi){let r=Ui(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var qi=8*1024*1024,Wi=qt;function Hi(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function Ji(e,t,n=qi){Wt(e,Hi(t),{maxSegmentBytes:n,previousSuffix:Wi})}function Je(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var zi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:b,databaseExists:e=>Li(e),openDatabase:(e,t,n)=>new O({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>k(e),dependencyGraph:e=>$(e),factDigests:e=>$i(e)},Xi={appendHistory:Ji,writeLatest:(e,t)=>Mt(e,t,{spacing:2,trailingNewline:!0})};function qn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function Gn(e){try{e?.close()}catch{}}import{readdirSync as Qi}from"fs";import{isAbsolute as Wn,join as Vi,resolve as Yi}from"path";var Se="@sourcegraph/scip-typescript@0.4.0",Hn="scip-python-plus@0.7.5",Jn="github.com/sourcegraph/scip-go@v0.2.7",zn="scip-dotnet@0.2.14",Ki="scip_dart@1.6.2",Zi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",identity:Se,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Se]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:N.language,indexerBinary:N.indexerBinary,checkCommand:`${N.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:N.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[],installUrl:N.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",identity:Hn,destination:"npm global prefix",prerequisite:"npm",binary:"npm",args:["install","-g",Hn]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",Wn(r)?r:Yi(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",identity:Jn,destination:"Go bin directory (GOBIN or GOPATH/bin)",prerequisite:"go",binary:"go",args:["install",Jn]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Xn(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",identity:zn,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",Xn(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",identity:zn,destination:"dotnet global tool directory",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet","--version","0.2.14"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",identity:Ki,destination:"Dart pub global cache",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart","1.6.2"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({indexerBinary:e})=>Wn(e)?{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",e]}:{binary:e,args:[]},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Qe(e){return Zi[e]}function Xn(e,t){let n;try{n=Qi(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Vi(e,i);return null}import{createHash as ea}from"crypto";import{copyFileSync as ta,existsSync as Qn,rmSync as Vn}from"fs";import{resolve as na}from"path";import Zn from"better-sqlite3";var ra={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},ia={idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function er(e){let t=b(),n=aa(e.affectedFiles);if(oa(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Vn(e.candidateDbPath,{force:!0}),!Qn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!Qn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Yn(e.previousDbPath,"previous SQLite generation",!1),Yn(e.miniDbPath,"incremental SQLite mini database"),ta(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Zn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ve(r,"main","candidate SQLite generation"),Ve(r,"incremental","incremental SQLite mini database"),sa(r,n),ca(r,n.length);let i=Ye(r,"main",!0),a=M(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{da(r),la(r),ua(r),e.onStage?.("after-delete"),pa(r),e.onStage?.("after-symbol-reconciliation"),ga(r),e.onStage?.("after-insert"),fa(r),ma(r,n.length,a),e.onStage?.("before-commit")}).immediate(),tr(r,"main","candidate SQLite generation");let d=[...ha(r)].filter(([c,l])=>i.get(c)!==l).map(([c])=>c).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:b()-t}}catch(i){try{r?.close()}finally{Vn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function aa(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function oa(e,t,n){let r=[e,t,n].map(i=>na(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Yn(e,t,n=!0){let r=new Zn(e,{readonly:!0,fileMustExist:!0});try{Ve(r,"main",t),n&&tr(r,"main",t)}finally{r.close()}}function Ve(e,t,n){for(let[r,i]of Object.entries(ra)){let o=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:d,notnull:c,pk:l})=>({name:s,type:d.toUpperCase(),notnull:c,pk:l}));if(JSON.stringify(o)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ia)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),o=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(a?.tbl_name!==i.table||JSON.stringify(o)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Kn(e,t,"documents",["relative_path"],n),Kn(e,t,"global_symbols",["symbol"],n)}function Kn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(c=>c.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function tr(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function sa(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function ca(e,t){let n=M(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=M(e,`SELECT COUNT(*) AS value
|
|
77
77
|
FROM main.documents d
|
|
78
78
|
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
79
79
|
FROM temp.incremental_affected_paths p
|
|
@@ -83,7 +83,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
83
83
|
FROM incremental.documents d
|
|
84
84
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
85
85
|
WHERE p.relative_path IS NULL
|
|
86
|
-
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function
|
|
86
|
+
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function da(e){e.exec(`
|
|
87
87
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
88
88
|
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
89
89
|
SELECT g.symbol
|
|
@@ -110,7 +110,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
110
110
|
FROM incremental.mentions m
|
|
111
111
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
112
112
|
WHERE m.role = 1;
|
|
113
|
-
`)}function
|
|
113
|
+
`)}function la(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
114
114
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
115
115
|
UNION
|
|
116
116
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
@@ -133,7 +133,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
133
133
|
SELECT u.symbol
|
|
134
134
|
FROM unaffected_definitions u
|
|
135
135
|
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
136
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function
|
|
136
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function ua(e){e.exec(`
|
|
137
137
|
DELETE FROM main.mentions
|
|
138
138
|
WHERE chunk_id IN (
|
|
139
139
|
SELECT c.id
|
|
@@ -155,7 +155,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
155
155
|
);
|
|
156
156
|
DELETE FROM main.documents
|
|
157
157
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
158
|
-
`)}function
|
|
158
|
+
`)}function pa(e){e.exec(`
|
|
159
159
|
UPDATE main.global_symbols
|
|
160
160
|
SET display_name = NULL,
|
|
161
161
|
kind = NULL,
|
|
@@ -197,7 +197,7 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
197
197
|
WHERE source.symbol = main.global_symbols.symbol
|
|
198
198
|
)
|
|
199
199
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
200
|
-
`)}function
|
|
200
|
+
`)}function ga(e){let t=M(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=M(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=M(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.defn_enclosing_ranges");e.prepare(`INSERT INTO main.documents(id, language, relative_path, position_encoding, text)
|
|
201
201
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
202
202
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
203
203
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
@@ -212,22 +212,22 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
212
212
|
r.start_line, r.start_char, r.end_line, r.end_char
|
|
213
213
|
FROM incremental.defn_enclosing_ranges r
|
|
214
214
|
JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
215
|
-
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function
|
|
215
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function fa(e){e.exec(`
|
|
216
216
|
DELETE FROM main.global_symbols
|
|
217
217
|
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
218
218
|
AND NOT EXISTS (
|
|
219
219
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
220
220
|
);
|
|
221
|
-
`)}function
|
|
221
|
+
`)}function ma(e,t,n){let r=M(e,"SELECT COUNT(*) AS value FROM main.documents"),i=M(e,`SELECT COUNT(*) AS value
|
|
222
222
|
FROM main.documents d
|
|
223
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),
|
|
223
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),o=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||o!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function ha(e){let t=Ye(e,"main",!0),n=Ye(e,"incremental",!1);if(JSON.stringify([...t])!==JSON.stringify([...n]))throw new Error("candidate SQLite affected document facts differ from the mini database");return t}function Ye(e,t,n){let r=n?"JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path":"",i=e.prepare(`SELECT d.relative_path, d.language, d.position_encoding, d.text
|
|
224
224
|
FROM ${t}.documents d
|
|
225
225
|
${r}
|
|
226
226
|
ORDER BY d.relative_path`).all(),a=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
227
227
|
FROM ${t}.chunks c
|
|
228
228
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
229
229
|
${r}
|
|
230
|
-
ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),
|
|
230
|
+
ORDER BY d.relative_path, c.chunk_index, c.start_line, c.end_line, c.id`).all(),o=e.prepare(`SELECT d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char,
|
|
231
231
|
g.symbol, g.display_name, g.kind, g.documentation,
|
|
232
232
|
CASE WHEN g.signature IS NULL THEN NULL ELSE hex(g.signature) END AS signature,
|
|
233
233
|
g.enclosing_symbol,
|
|
@@ -236,22 +236,23 @@ import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5X
|
|
|
236
236
|
JOIN ${t}.documents d ON d.id = r.document_id
|
|
237
237
|
JOIN ${t}.global_symbols g ON g.id = r.symbol_id
|
|
238
238
|
${r}
|
|
239
|
-
ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),
|
|
239
|
+
ORDER BY d.relative_path, r.start_line, r.start_char, r.end_line, r.end_char, g.symbol`).all(),s=e.prepare(`SELECT d.relative_path, c.chunk_index, m.role, g.symbol
|
|
240
240
|
FROM ${t}.mentions m
|
|
241
241
|
JOIN ${t}.chunks c ON c.id = m.chunk_id
|
|
242
242
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
243
243
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
244
244
|
${r}
|
|
245
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),
|
|
246
|
-
`);
|
|
247
|
-
`;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function ze(e){try{let t=Wi(e,"utf-8"),n=JSON.parse(ra(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as ia,readFileSync as aa,readdirSync as sa,statSync as oa}from"fs";import v from"path";var ca=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function V(e,t=[]){let n=v.resolve(e),r=t.flatMap(c=>la(n,c));if(r.length>0)return Hn(n,Wn(r));let i=da(n),a=Wn(i),s=pa(n,a)?[n,...a]:a,o=s.length>0?s:[n];return Hn(n,o)}function Hn(e,t){return[...new Set(t.map(n=>fa(e,n)))].sort((n,r)=>n.localeCompare(r))}function da(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=sa(r,{withFileTypes:!0})}catch{continue}for(let a of i){let s=v.join(r,a.name);if(a.isDirectory()){!ca.has(a.name)&&!a.name.startsWith(".")&&n.push(s);continue}a.isFile()&&ua(s)&&t.push(v.dirname(s))}}return t}function la(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!W(e,r))return[];try{let i=oa(r);if(i.isDirectory())return[r];if(i.isFile()&&qn(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function ua(e){if(!qn(v.basename(e)))return!1;let t=zn(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function qn(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Wn(e){let t=[...new Set(e.map(n=>v.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&ma(n,r)))}function pa(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return ia(n)&&ga(n)}function ga(e){let n=zn(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!v.extname(r))):!1}function zn(e){try{let t=JSON.parse(aa(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function fa(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function ma(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as wa}from"crypto";import{existsSync as Xe,readFileSync as Kn,statSync as _a,writeFileSync as Ve}from"fs";import{join as ja}from"path";import{randomUUID as ha}from"crypto";import{existsSync as ya,readFileSync as Sa}from"fs";var ba=12e4,Pa=5,he=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=gt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ea(),this.runtime=n.runtime??Fa,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=rn(this.cacheDir),r=tn(this.cacheDir),i=Te(n.statePath);if(!Xn(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),s=a+this.timeoutMs,o=(this.runtime.monotonicNow??P)()+this.timeoutMs,c=Kt("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),d=Zt(c),l=en(r,{mailboxVersion:Qt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:s,protocolVersion:de,id:d,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=o;){if(ya(l.responsePath))return xa(Sa(l.responsePath,"utf8"),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Te(n.statePath);if(!Xn(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Pa)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function Xn(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===de&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&J(e.processIdentity,r))}function xa(e,t,n,r,i,a){let s=JSON.parse(e);if(s.protocolVersion!==de||s.id!==t||s.operationKey!==n||s.ok===!0&&s.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(s.ok!==!0)throw new Error(typeof s.error=="string"?s.error:"TypeScript index service request failed.");let o=Ra(s.response,i),c=[...new Set(a)].sort(),d=o.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(d)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return o}function Ra(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ia)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let s=a.bytesBase64===null?null:va(a.bytesBase64);return{relativePath:a.relativePath,bytes:s,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ia(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function va(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ea(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:ba}var Fa={now:Date.now,monotonicNow:P,randomId:ha,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:O,readProcessIdentity:M};function Da(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=te(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(d=>d.kind!=="modified"||d.inputKind!=="source"||!q(d.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=fe(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=ka([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=Vn(e.currentSnapshot,e.projectFiles,e.producerIdentity),s=Vn(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==s)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let o=Qn(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!o)return{eligible:!1,reason:"prior document identity unavailable"};let c=Qn(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return c?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:Yn(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Yn(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:o,nextDocumentIdentities:c,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function ka(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Zn(e){let t=P();try{if(!Xe(e.previousDbPath)||!Xe(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ke();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),s,o;try{s=j(a,{includeIgnored:!1}).filter(q).sort(),o=L(a)}finally{a.close()}let c=performance.now()-n,d=Da({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?V(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:s,graph:o,producerIdentity:r.producerIdentity,rootTsconfigExists:Xe(ja(e.projectRoot,"tsconfig.json"))});if(!d.eligible)throw new Error(d.reason);let l=nn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new he({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:d.tsconfigPath,projectArgument:d.projectArgument,projectIdentity:d.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles}),h=performance.now()-n,g=_a(e.previousShardPath).size>=Gt;n=performance.now();let m=g?null:Kn(e.previousShardPath),b=g?{completeIndexBytes:null,affectedIndexBytes:Nt(p.fragments)}:Bt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?Ut({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,nextGenerationIdentity:d.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Ct({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,generationIdentity:d.previousFragmentGeneration,documentIdentities:d.previousDocumentIdentities,allowUntrackedDocuments:!0}),$t({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,generationIdentity:d.nextFragmentGeneration,fragments:p.fragments,documentIdentities:d.nextDocumentIdentities}));let y=performance.now()-n;n=performance.now(),b.completeIndexBytes&&Ve(e.candidateShardPath,b.completeIndexBytes),Ve(e.candidateAffectedScipPath,b.affectedIndexBytes);let x=performance.now()-n,R={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:P()-t,cold:p.cold,changedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:d.previousFragmentGeneration,nextFragmentGeneration:d.nextFragmentGeneration,manifest:d.manifest,plan:d.plan,projectFileCount:s.length,referenceFragmentsByFile:new Map(p.fragments.map(T=>[T.relativePath,T.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:y,writeMs:x}};return e.onStatus(`Incremental TypeScript index emitted ${R.affectedFiles.length} affected document(s) in ${(R.durationMs/1e3).toFixed(3)}s (${R.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${x.toFixed(0)}ms).`),R}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function er(e){let t=ke();if(!t.available)throw new Error(t.reason);let n=Jt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:Kn(e.baseShardPath),packageVersion:t.packageVersion});Ve(e.candidateShardPath,n)}function Vn(e,t,n){let r=e.files.filter(i=>ee(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return Ye(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Yn(e,t){return Ye(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Qn(e,t,n,r,i){let a=new Set(e.files.map(c=>c.path)),s=ge({projectFiles:t.filter(c=>a.has(c)),snapshot:e,graph:n,engineIdentity:r}),o=new Map;for(let c of i){let d=s.identityFor(c,"typescript-scip-document-v1");if(d.key){o.set(c,d.key);continue}if(a.has(c))return null;o.set(c,Ye(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return o}function Ye(e){return wa("sha256").update(e).digest("hex")}import{existsSync as ye,renameSync as Ke,rmSync as Ze,statSync as Ta}from"fs";import{cpus as Ma}from"os";import{join as nr}from"path";function Oa(e,t,n){if(!e.defaultOutputPath)return;let r=nr(t,e.defaultOutputPath);n!==r&&ye(r)&&Ke(r,n)}function Aa(e,t,n){if(!e.defaultOutputPath)return null;let r=nr(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Ze(i,{force:!0}),ye(r)?(Ke(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function La(e){e&&(Ze(e.defaultOutputPath,{force:!0}),e.backupPath&&ye(e.backupPath)&&Ke(e.backupPath,e.defaultOutputPath))}function Na(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Ma().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function rr(e,t,n,r){let i=e.filter(d=>d.config.defaultOutputPath),a=e.filter(d=>!d.config.defaultOutputPath),s=[],o=Na(a.length,r),c=await Ba(a,o,d=>Qe(d,t,n));if(o>1){let d=new Map;for(let l of c.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),d.set(u.id,(await Qe(u,t,n)).result))}s.push(...c.map(({result:l})=>d.get(l.id)??l))}else s.push(...c.map(({result:d})=>d));for(let d of i)s.push((await Qe(d,t,n)).result);return s.sort((d,l)=>e.findIndex(u=>u.id===d.id)-e.findIndex(u=>u.id===l.id))}async function Qe(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Ze(e.scipPath,{force:!0});let r=Aa(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=P();try{let o=dt(e.binary,e.args),c=await on({command:o.binary,args:o.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Ca(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(c.status!==0){let d=c.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${c.status}${d?`:
|
|
248
|
-
${
|
|
249
|
-
`)[0]}`,l=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:l}},retryable:$a(o)}}finally{La(r)}if(!ye(e.scipPath)){let o=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=e.label===e.language?o:`${e.label}: ${o}`;return n(`Skipping ${e.label}: ${o}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:c}},retryable:!1}}let s;try{s=Ta(e.scipPath).size}catch{s=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,outputBytes:s},retryable:!1}}function Ca(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):an.indexer}function $a(e){return e instanceof sn?e.kind==="spawn"&&tr(e.cause):tr(e)}function tr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}async function Ba(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),s=Array.from({length:a},async()=>{for(;i<e.length;){let o=i++;r[o]=await n(e[o])}});return await Promise.all(s),r}import{execFileSync as Ga}from"child_process";import{platform as Ua}from"os";function ir(e,t){let n=e.installMethods,r=ue(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(U(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{Ga(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Ua()==="win32"});let a=X(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}async function mr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,a=Ya(e),s=Date.now(),o=P();be(S(a.outputScip),{recursive:!0}),be(S(a.outputDb),{recursive:!0});let c=e.languages??Tt(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let d=w("reindex.fingerprint",()=>bt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,u;if(e.skipIfUnchanged!==!1&&!Xt(t,a.outputDb)&&ar(a.outputScip)===ar(I(S(a.outputDb),"index.scip"))){let m=re(t);if(l=m?oe(m,d):void 0,l){let b=ce(l);if(b){if(!Va(a,d))try{je({snapshot:l,manifest:b,targetCacheDir:S(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${$(f)}`)}}else{let f=await Yt(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let y=ce(l);if(y)try{je({snapshot:l,manifest:y,targetCacheDir:S(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(x){r(`Shared generation attach failed after waiting; continuing locally: ${$(x)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=ht(I(S(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${S(a.outputDb)}.`);let h;try{h=await G("reindex.lock",()=>Is(I(S(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{qt(a.outputDb,a.outputScip,a.metaPath);let m=es(S(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let T of m.errors)r(`Could not remove abandoned reindex workspace: ${T}`);let b=null,f=w("reindex.reuse-check",()=>(b=Qa({opts:e,paths:a,languages:c,fingerprint:d,start:s,monotonicStart:o,onStatus:r}),b),()=>({languages:c.length,reused:b!==null}));if(f)return sr({snapshot:l,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),_e(a.outputDb,f),f;await G("reindex.scip-cli-ready",()=>ms(i,r));let y=Za(a);g=y.runDir;let x,R=await G("reindex.fresh",async()=>(x=await ts({opts:e,languages:c,projectRoot:t,paths:a,tempPaths:y,fingerprint:d,start:s,monotonicStart:o,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),x),()=>({languages:c.length,reused:x?.reused,skipped:x?.skipped.length}));return sr({snapshot:l,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),_e(a.outputDb,R),R}catch(m){let b=Ie({trigger:e.trigger,result:"failed",start:s,monotonicStart:o,error:m instanceof Error?m.message:String(m)});throw _r(a.metaPath,b),Lt(a.outputDb,b),m}finally{g&&C(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function sr(e){if(e.snapshot){if(ce(e.snapshot)){De(e.snapshot,S(e.paths.outputDb),"local-fresh");return}try{let t=re(e.projectRoot),n=t?oe(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}Vt({snapshot:e.snapshot,sourceCacheDir:S(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=re(e.projectRoot);return(r?oe(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),De(e.snapshot,S(e.paths.outputDb),"built"),e.onStatus(`Published shared generation ${e.snapshot.generationId.slice(0,12)}`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${$(t)}`)}}}function Va(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!wr(e.metaPath,t))return!1;let n=z(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function $(e){return e instanceof Error?e.message:String(e)}function Ya(e){let t=e.outputScip??I(e.projectRoot,"index.scip"),n=e.outputDb??I(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:I(S(n),"meta.json")}}function Qa(e){let t=z(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!wr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;se(ae(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=P()-e.monotonicStart,r=Ie({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return _r(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:Ka(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Ka(e,t,n,r){let i=Er(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:Y(i[a]),outputBytes:Q(it(e.outputDb,a)),durationMs:0}))}function Za(e){let t=Wa(I(S(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:I(t,Se(e.outputScip)),tempOutputDb:I(t,Se(e.outputDb)),tempMetaPath:I(t,Se(e.metaPath))}}function es(e){let t=[],n;try{n=gr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[$(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{C(I(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${$(a)}`)}return{removed:r,errors:t}}async function ts(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await G("reindex.language-indexers",async()=>(n=await rs(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:s,languageFingerprints:o,shards:c,typescriptProjectShardContext:d,incrementalTypeScript:l}=r;if(s.length>0&&e.onStatus(`Reused ${s.length} cached language shard(s): ${s.join(", ")}`),ns({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:s})){let h=w("reindex.publish",()=>ps(e,i,a,s,o,d),{mode:"metadata-only",languages:i.length,reused:s.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:c}}let u=w("reindex.publish",()=>us(e,t,i,a,s,o,d,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:s.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:c}}function ns(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=z(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function rs(e,t){let n=cs({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[E,ot]of n)ot.reused&&(r.push({language:E,scipPath:ot.scipPath}),i.add(E));for(let E of i)e.onStatus(`Reusing cached ${E} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),s=z(e.paths.outputDb,e.paths.metaPath),o=Z(e.paths.metaPath),c=s.state==="legacy"||s.state==="current",d=o?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&c?Zn({projectRoot:e.projectRoot,cacheDir:S(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:K(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:K(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:d,previousSnapshot:rt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:is(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=hs({languages:e.languages.filter(E=>!i.has(E)&&!u.has(E)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=p?h.filter(E=>E.language!=="typescript"||p.missedProjectIds.has(E.id)):h,f=await rr(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),y=[];if(p){ss(e.paths.outputDb,f);let E=m.typescript??e.tempPaths.tempOutputScip;y=os({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:E,reusedProjects:p.reusedProjects})}let x=[...f,...y],{indexedOutputs:R}=Ss(x,g),T=l?[{language:"typescript",scipPath:l.scipPath}]:[],st=[...r,...T,...R];bs(st,g,e.languages,e.opts.allowPartial,e.onStatus);let Ar=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Q(l.scipPath)??void 0}]:[],Lr=ds(n,[...f,...Ar],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:st,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:ls(n,e.languages),shards:Lr,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function is(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=V(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Bn(e.projectRoot,r),a=Nn(n.fingerprint.files,r),s=Cn(r,i),o=$n(r,a,s),c=Z(e.paths.metaPath),l=as(c,o,g=>F(Re(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:o,classification:l,reusedProjects:u,missedProjectIds:h}}function as(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let s=e.version===B&&Ee(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(_(s)!==_(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function ss(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=Re(e,r);be(S(i),{recursive:!0}),xe(n.scipPath,i)}}function os(e){return e.reusedProjects.map((t,n)=>{let r=Re(e.outputDb,t),i=K(e.tempOutputScip,"typescript-project-cached",n);return xe(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Q(i)??void 0}})}function cs(e){let t=Z(e.paths.metaPath),n=Er(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=it(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==B){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:s,scipPath:a});continue}if(!Ee(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let o=t.languageFingerprints[i];if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}if(_(o)!==_(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:a})}return r}function ds(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,o=s?n.classification.get(s):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:o?.reason??a?.reason??i.skipped?.reason,fingerprint:o?Y(o.fingerprint):a?Y(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(Re(n.outputDb,i)),durationMs:0});return r}function Y(e){return Ha("sha256").update(_(e)).digest("hex").slice(0,16)}function Q(e){try{return qa(e).size}catch{return null}}function ls(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function us(e,t,n,r,i,a,s,o){let c=!o||o.completeScipUpdated,d=!1;c&&(or(e.paths.outputDb,n),d=cr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=Ps({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:o,completeScipAvailable:c,completeScipSanitized:d,materializeFullFallback:()=>{if(!o||o.completeScipUpdated)return d;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),er({cacheDir:S(e.paths.outputDb),generationIdentity:o.nextFragmentGeneration,baseShardPath:o.scipPath,candidateShardPath:o.candidateScipPath});let y=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:o.candidateScipPath}:x);return or(e.paths.outputDb,y),d=cr(y,e.tempPaths.tempOutputScip,e.onStatus),d}});if(se(ae(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&o){let y=null,x=null;try{y=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let R=Pn(y,e.fingerprint,o.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${R} affected document(s).`)}catch(R){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${R instanceof Error?R.message:String(R)}.`)}finally{y?.close(),x?.close()}}let u=rt(e.paths.metaPath),p=l.mode==="incremental"&&o?Rs(o,l.changedDocumentPaths):Ce({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),h=Ie({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(y=>y.language),skipped:[...r]}),g=l.mode==="incremental"&&l.scipCompanion==="deferred",m={...a};g&&delete m.typescript;let{metadata:b,pruneProjects:f}=yr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:m,typescriptProjectShardContext:s,lastRefresh:h});return b.scipCompanion=g?"deferred":"current",Sr(e.paths.outputDb,f),at(e.tempPaths.tempMetaPath,b),Wt({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:o?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:o?.timings.serviceMs,materializationDurationMs:o?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&o?{typescriptOverlayGeneration:o.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),Ht(S(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[o.nextFragmentGeneration]:[]),hr(e.paths.outputDb,p,e.onStatus),h}function ps(e,t,n,r,i,a){let s=rt(e.paths.metaPath),o=null;try{xe(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){o=vn("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}se(ae(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),o??=Ce({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:s,currentSnapshot:e.fingerprint,refreshResult:"reused"});let c=Ie({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:d,pruneProjects:l}=yr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:c});return Sr(e.paths.outputDb,l),at(e.paths.metaPath,d),zt(e.paths.outputDb,e.paths.metaPath),hr(e.paths.outputDb,o,e.onStatus),c}function rt(e){return ct(Z(e)?.fingerprint)}function hr(e,t,n){try{En(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function yr(e){let t=gs({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:B,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function gs(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=Z(e.metaPath),n=t?.version===B?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Sr(e,t){let n=Fr(e);if(t===null){C(n,{recursive:!0,force:!0});return}let r;try{r=gr(n)}catch{return}for(let i of fs(r,t))C(I(n,i),{force:!0})}function fs(e,t){let n=new Set(t.map(r=>`${qe(r)}.scip`));return e.filter(r=>!n.has(r))}function or(e,t){for(let n of t){let r=it(e,n.language);be(S(r),{recursive:!0}),n.scipPath!==r&&xe(n.scipPath,r)}}async function ms(e,t){if(!Fe()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
250
|
-
|
|
251
|
-
|
|
245
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),d=new Map;for(let[l,u]of Object.entries({documents:i,chunks:a,definitions:o,mentions:s}))for(let p of u){let h=JSON.stringify([l,p]),g=d.get(p.relative_path)??[];g.push(h),d.set(p.relative_path,g)}let c=new Map;for(let[l,u]of[...d].sort(([p],[h])=>p.localeCompare(h))){let p=ea("sha256");for(let h of u.sort())p.update(h).update(`
|
|
246
|
+
`);c.set(l,p.digest("hex"))}return c}function M(e,t){return e.prepare(t).get().value}import ya from"better-sqlite3";var be="idx_mentions_definitions",Sa=["symbol_id","chunk_id"];function Ke(e){let t=new ya(e),n=[],r=[],i=[];try{return t.transaction(()=>{ba(t,n),Pe(t,"idx_global_symbols_symbol")?.join("\0")==="symbol"&&nr(t,"global_symbols").some(s=>s.name!=="idx_global_symbols_symbol"&&s.unique&&s.columns.join("\0")==="symbol")?(t.exec('DROP INDEX "idx_global_symbols_symbol"'),r.push("idx_global_symbols_symbol")):Pe(t,"idx_global_symbols_symbol")&&i.push("idx_global_symbols_symbol");let a=Pe(t,"idx_chunks_doc_id"),o=nr(t,"chunks").some(s=>s.name!=="idx_chunks_doc_id"&&s.columns.length>1&&s.columns[0]==="document_id");a?.join("\0")==="document_id"&&o?(t.exec('DROP INDEX "idx_chunks_doc_id"'),r.push("idx_chunks_doc_id")):a&&i.push("idx_chunks_doc_id"),t.exec("ANALYZE")})(),{added:n,removed:r,retained:i,analyzed:!0}}catch(a){if(a.code==="SQLITE_NOTADB")return{added:[],removed:[],retained:[],analyzed:!1,skippedReason:"not-a-sqlite-database"};throw a}finally{t.close()}}function ba(e,t){let n=rr(e,be);if(n){let r=n.columns.join("\0")===Sa.join("\0"),i=/\bWHERE\s+role\s*=\s*1\b/iu.test(n.sql??"");if(!r||!i||n.table!=="mentions")throw new Error(`${be} exists with an incompatible definition`);return}e.exec(`CREATE INDEX "${be}" ON mentions(symbol_id, chunk_id) WHERE role = 1`),t.push(be)}function nr(e,t){return e.prepare(`PRAGMA index_list('${t.replaceAll("'","''")}')`).all().map(n=>({name:n.name,unique:n.unique===1,columns:Pe(e,n.name)??[]}))}function Pe(e,t){return rr(e,t)?.columns??null}function rr(e,t){let n=e.prepare("SELECT tbl_name, sql FROM sqlite_master WHERE type = 'index' AND name = ?").get(t);if(!n)return null;let r=e.prepare(`PRAGMA index_info('${t.replaceAll("'","''")}')`).all().map(i=>i.name);return{table:n.tbl_name,sql:n.sql,columns:r}}import{createHash as Pa}from"crypto";import{existsSync as Ze,readdirSync as xa}from"fs";import{dirname as et,join as xe,relative as Ra,resolve as tt,sep as ir}from"path";function ar(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let o=dr(a.path,t);o?r[o].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function or(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],o=r.get(i);if(!a||a.parseFailed){for(let s of e)s!==i&&o.add(s);continue}for(let s of a.dependencyNames){let d=n.get(s);d&&d!==i&&o.add(d)}for(let s of[...a.pathsTargets,...a.referencesPaths]){let d=dr(s,e);d&&d!==i&&o.add(d)}}return Ia(e,r)}function sr(e,t,n){let r={};for(let i of e){let a=new Map;for(let o of t.files[i]??[])a.set(o.path,o);for(let o of n[i]??[])for(let s of t.files[o]??[])a.set(s.path,s);for(let o of t.shared)a.set(o.path,o);r[i]={files:[...a.values()].sort((o,s)=>o.path.localeCompare(s.path))}}return r}function nt(e){if(e===".")return"root";let t=Pa("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function cr(e,t){let n=tt(e),r={};for(let i of t)r[i]=va(n,i);return r}function dr(e,t){let n;for(let r of t)r!=="."&&(e===r||e.startsWith(`${r}/`))&&(!n||r.length>n.length)&&(n=r);return n}function Ia(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let o=a.pop();if(!(o===r||i.has(o))){i.add(o);for(let s of t.get(o)??[])s!==r&&!i.has(s)&&a.push(s)}}n[r]=[...i].sort((o,s)=>o.localeCompare(s))}return n}function va(e,t){let n=t==="."?e:xe(e,t),r=Ea(n),i=_a(n),a=i?Fa(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function Ea(e){let t=xe(e,"package.json");if(!Ze(t))return{name:void 0,dependencyNames:[],failed:!1};let n=rt(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let a of["dependencies","devDependencies","peerDependencies"]){let o=n.value[a];if(o&&typeof o=="object"&&!Array.isArray(o))for(let s of Object.keys(o))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function _a(e){let t=xe(e,"tsconfig.json");if(Ze(t))return t;let n;try{n=xa(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?xe(e,n[0]):void 0}function Fa(e,t){let n=rt(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=ja(n.value,e,t),i=lr(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function ja(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=et(t),a=new Set;for(let o of r){if(!o||typeof o!="object")continue;let s=o.path;if(typeof s!="string"||s.trim()==="")continue;let d=ur(s,i,n);d&&a.add(d)}return[...a]}function lr(e,t,n,r){let i=Ta(t);if(i)return{pathsTargets:wa(i,et(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=Da(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let o=rt(a);return o.ok?lr(a,o.value,n,r+1):{pathsTargets:[],failed:!0}}function Ta(e){let t=e.compilerOptions;if(!t||typeof t!="object"||Array.isArray(t))return;let n=t.paths;return n&&typeof n=="object"&&!Array.isArray(n)?n:void 0}function wa(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let o=ur(a,t,n);o&&r.add(o)}return[...r]}function Da(e,t,n){let r=Array.isArray(e)?e.at(-1):e;if(typeof r!="string"||r.trim()===""||!r.startsWith(".")&&!r.startsWith("/"))return;let i=tt(et(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(ir).includes("node_modules")&&H(n,i)&&Ze(i))return i}function ur(e,t,n){let r=e.replace(/\/?\*+$/,""),i=tt(t,r===""?".":r);if(!H(n,i))return;let o=Ra(n,i).split(ir).join("/");return o===""?".":o}function ka(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
247
|
+
`;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function rt(e){try{let t=ne(e,{maxBytes:yt,inputKind:"TypeScript project manifest"}),n=JSON.parse(ka(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as Ma,readdirSync as Oa,statSync as Aa}from"fs";import I from"path";var La=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Y(e,t=[]){let n=I.resolve(e),r=t.flatMap(d=>Ca(n,d));if(r.length>0)return pr(n,gr(r));let i=Na(n),a=gr(i),o=Ga(n,a)?[n,...a]:a,s=o.length>0?o:[n];return pr(n,s)}function pr(e,t){return[...new Set(t.map(n=>Ua(e,n)))].sort((n,r)=>n.localeCompare(r))}function Na(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Oa(r,{withFileTypes:!0})}catch{continue}for(let a of i){let o=I.join(r,a.name);if(a.isDirectory()){!La.has(a.name)&&!a.name.startsWith(".")&&n.push(o);continue}a.isFile()&&$a(o)&&t.push(I.dirname(o))}}return t}function Ca(e,t){let n=t.trim();if(!n)return[];let r=I.resolve(e,n);if(!H(e,r))return[];try{let i=Aa(r);if(i.isDirectory())return[r];if(i.isFile()&&fr(I.basename(r)))return[I.dirname(r)]}catch{return[]}return[]}function $a(e){if(!fr(I.basename(e)))return!1;let t=mr(e);return t?I.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function fr(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function gr(e){let t=[...new Set(e.map(n=>I.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&qa(n,r)))}function Ga(e,t){if(t.length===0||t.some(r=>I.resolve(r)===e))return!1;let n=I.join(e,"tsconfig.json");return Ma(n)&&Ba(n)}function Ba(e){let n=mr(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!I.extname(r))):!1}function mr(e){try{let t=JSON.parse(D(e,"TypeScript project config"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Ua(e,t){let n=I.relative(e,t);return n?n.split(I.sep).join("/"):"."}function qa(e,t){let n=I.relative(e,t);return!!n&&!n.startsWith("..")&&!I.isAbsolute(n)}import{createHash as eo}from"crypto";import{existsSync as it,statSync as to,writeFileSync as at}from"fs";import{join as no}from"path";import{randomUUID as Wa}from"crypto";import{existsSync as Ha}from"fs";var Ja=12e4,za=5,Re=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=vt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ka(),this.runtime=n.runtime??Za,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=Sn(this.cacheDir),r=hn(this.cacheDir),i=Ue(n.statePath);if(!hr(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),o=a+this.timeoutMs,s=(this.runtime.monotonicNow??b)()+this.timeoutMs,d=gn("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),c=fn(d),l=mn(r,{mailboxVersion:pn,operationKey:d,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:o,protocolVersion:pe,id:c,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??b)()<=s;){if(Ha(l.responsePath))return Xa(ne(l.responsePath,{maxBytes:this.mailboxLimits.maxItemBytes??64*1024*1024,inputKind:"TypeScript index mailbox response"}),c,d,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Ue(n.statePath);if(!hr(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(za)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function hr(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===pe&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&J(e.processIdentity,r))}function Xa(e,t,n,r,i,a){let o=JSON.parse(e);if(o.protocolVersion!==pe||o.id!==t||o.operationKey!==n||o.ok===!0&&o.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(o.ok!==!0)throw new Error(typeof o.error=="string"?o.error:"TypeScript index service request failed.");let s=Qa(o.response,i),d=[...new Set(a)].sort(),c=s.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(c)!==JSON.stringify(d))throw new Error("TypeScript index service omitted or added an affected document.");return s}function Qa(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Va)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let o=a.bytesBase64===null?null:Ya(a.bytesBase64);return{relativePath:a.relativePath,bytes:o,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Va(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function Ya(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ka(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Ja}var Za={now:Date.now,monotonicNow:b,randomId:Wa,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:L,readProcessIdentity:A};function ro(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=ie(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!X(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=ye(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=io([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=yr(e.currentSnapshot,e.projectFiles,e.producerIdentity),o=yr(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==o)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=br(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let d=br(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return d?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:Sr(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Sr(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:d,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function io(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Pr(e){let t=b();try{if(!it(e.previousDbPath)||!it(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Be();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new O({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),o,s;try{o=k(a,{includeIgnored:!1}).filter(X).sort(),s=$(a)}finally{a.close()}let d=performance.now()-n,c=ro({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?Y(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:o,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:it(no(e.projectRoot,"tsconfig.json"))});if(!c.eligible)throw new Error(c.reason);let l=yn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new Re({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:c.tsconfigPath,projectArgument:c.projectArgument,projectIdentity:c.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles}),h=performance.now()-n,g=to(e.previousShardPath).size>=en;n=performance.now();let m=g?null:ke(e.previousShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:De}),S=g?{completeIndexBytes:null,affectedIndexBytes:Vt(p.fragments)}:Zt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?tn({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,nextGenerationIdentity:c.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Yt({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.previousFragmentGeneration,documentIdentities:c.previousDocumentIdentities,allowUntrackedDocuments:!0}),Kt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.nextFragmentGeneration,fragments:p.fragments,documentIdentities:c.nextDocumentIdentities}));let P=performance.now()-n;n=performance.now(),S.completeIndexBytes&&at(e.candidateShardPath,S.completeIndexBytes),at(e.candidateAffectedScipPath,S.affectedIndexBytes);let v=performance.now()-n,x={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:b()-t,cold:p.cold,changedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:c.previousFragmentGeneration,nextFragmentGeneration:c.nextFragmentGeneration,manifest:c.manifest,plan:c.plan,projectFileCount:o.length,referenceFragmentsByFile:new Map(p.fragments.map(E=>[E.relativePath,E.referenceFragments])),timings:{runtimeMs:i,graphMs:d,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:P,writeMs:v}};return e.onStatus(`Incremental TypeScript index emitted ${x.affectedFiles.length} affected document(s) in ${(x.durationMs/1e3).toFixed(3)}s (${x.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${P.toFixed(0)}ms, write ${v.toFixed(0)}ms).`),x}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function xr(e){let t=Be();if(!t.available)throw new Error(t.reason);let n=nn({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:ke(e.baseShardPath,{inputKind:"TypeScript base SCIP shard",maxBytes:De}),packageVersion:t.packageVersion});at(e.candidateShardPath,n)}function yr(e,t,n){let r=e.files.filter(i=>re(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return ot(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Sr(e,t){return ot(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function br(e,t,n,r,i){let a=new Set(e.files.map(d=>d.path)),o=he({projectFiles:t.filter(d=>a.has(d)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let d of i){let c=o.identityFor(d,"typescript-scip-document-v1");if(c.key){s.set(d,c.key);continue}if(a.has(d))return null;s.set(d,ot(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return s}function ot(e){return eo("sha256").update(e).digest("hex")}import{existsSync as Ie,renameSync as ct,rmSync as dt,statSync as ao}from"fs";import{cpus as oo}from"os";import{join as Ir}from"path";function so(e,t,n){if(!e.defaultOutputPath)return;let r=Ir(t,e.defaultOutputPath);n!==r&&Ie(r)&&ct(r,n)}function co(e,t,n){if(!e.defaultOutputPath)return null;let r=Ir(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return dt(i,{force:!0}),Ie(r)?(ct(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function lo(e){e&&(dt(e.defaultOutputPath,{force:!0}),e.backupPath&&Ie(e.backupPath)&&ct(e.backupPath,e.defaultOutputPath))}function uo(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,oo().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function vr(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),a=e.filter(c=>!c.config.defaultOutputPath),o=[],s=uo(a.length,r),d=await Rn(a,s,c=>st(c,t,n));if(s>1){let c=new Map;for(let l of d.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),c.set(u.id,(await st(u,t,n)).result))}o.push(...d.map(({result:l})=>c.get(l.id)??l))}else o.push(...d.map(({result:c})=>c));for(let c of i)o.push((await st(c,t,n)).result);return o.sort((c,l)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===l.id))}async function st(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),dt(e.scipPath,{force:!0});let r=co(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=b();try{e.trustedProjectTool&&wn(t,e.trustedProjectTool);let s=Pt(e.binary,e.args),d=await xn({command:s.binary,args:s.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:po(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(d.status!==0){let c=d.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${d.status}${c?`:
|
|
248
|
+
${c}`:""}`)}so(e.config,t,e.scipPath)}catch(s){let d=s instanceof Error?s.message:String(s),c=`${e.resolvedBinary} indexer failed: ${d.split(`
|
|
249
|
+
`)[0]}`,l=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-a,command:i,skipped:{language:e.language,reason:l}},retryable:go(s)}}finally{lo(r)}if(!Ie(e.scipPath)){let s=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-a,command:i,skipped:{language:e.language,reason:d}},retryable:!1}}let o;try{o=ao(e.scipPath).size}catch{o=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:b()-a,command:i,outputBytes:o},retryable:!1}}function po(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):bn.indexer}function go(e){return e instanceof Pn?e.kind==="spawn"&&Rr(e.cause):Rr(e)}function Rr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}import{execFileSync as _r}from"child_process";import{homedir as Er,platform as fo}from"os";import{delimiter as mo,join as ve}from"path";function Fr(e,t){let n=e.installMethods,r=fe(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n){if(!i.identity||!i.destination){t(`Refusing ${i.label} installation for ${r}: the installer descriptor lacks an immutable identity or destination.`);continue}if(!oe(i.prerequisite))continue;let a=ho(i);t(`Installing immutable ${i.identity} via ${i.label} into ${a}; expected executable: ${r}.`);try{_r(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:fo()==="win32"});let o=C(e);if(o){let s=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${i.identity} via ${i.label}${s}; resolved executable: ${o}.`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let s=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}function ho(e){if(e.binary==="npm")return lt("npm",["root","-g"])??e.destination;if(e.binary==="go"){let t=lt("go",["env","GOBIN"]);if(t)return t;let n=lt("go",["env","GOPATH"]);if(n)return ve(n.split(mo)[0],"bin")}return e.binary==="dotnet"?ve(process.env.DOTNET_CLI_HOME??Er(),".dotnet","tools"):e.binary==="dart"?ve(process.env.PUB_CACHE??ve(Er(),".pub-cache"),"bin"):e.destination}function lt(e,t){try{return _r(e,t,{stdio:["ignore","pipe","ignore"],encoding:"utf8",timeout:1e4,killSignal:"SIGKILL",env:process.env}).trim()||null}catch{return null}}async function Cr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log}=e,i=e.skipAutoInstall===!0||e.installMissing!==!0,a=vo(e),o=Date.now(),s=b();_e(y(a.outputScip),{recursive:!0}),_e(y(a.outputDb),{recursive:!0});let d=e.languages??Ht(t);if(d.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${d.join(", ")}`);let c=T("reindex.fingerprint",()=>kt(t,d,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:d.length}),l,u;if(e.skipIfUnchanged!==!1&&!cn(t,a.outputDb)&&jr(a.outputScip)===jr(R(y(a.outputDb),"index.scip"))){let m=se(t);if(l=m?ue(m,c):void 0,l){let S=$e(l);if(S){if(!Io(a,c))try{Ge({snapshot:l,manifest:S,targetCacheDir:y(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${U(f)}`)}}else{let f=await ln(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let P=$e(l);if(P)try{Ge({snapshot:l,manifest:P,targetCacheDir:y(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(v){r(`Shared generation attach failed after waiting; continuing locally: ${U(v)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=Ft(R(y(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${y(a.outputDb)}.`);let h;try{h=await W("reindex.lock",()=>Yo(R(y(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:d.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{on(a.outputDb,a.outputScip,a.metaPath);let m=jo(y(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let _ of m.errors)r(`Could not remove abandoned reindex workspace: ${_}`);let S=null,f=T("reindex.reuse-check",()=>(S=Eo({opts:e,paths:a,languages:d,fingerprint:c,start:o,monotonicStart:s,onStatus:r}),S),()=>({languages:d.length,reused:S!==null}));if(f){Tr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r});let _=Ce(a.outputDb,f);return _.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${_.reason}`),Ae(t,y(a.outputDb)),f}await W("reindex.scip-cli-ready",()=>qo(i,r));let P=Fo(a);g=P.runDir;let v,x=await W("reindex.fresh",async()=>(v=await To({opts:e,languages:d,projectRoot:t,paths:a,tempPaths:P,fingerprint:c,start:o,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),v),()=>({languages:d.length,reused:v?.reused,skipped:v?.skipped.length}));Tr({snapshot:l,paths:a,projectRoot:t,fingerprint:c,onStatus:r});let E=Ce(a.outputDb,x);return E.state==="failed"&&r(`Warning: reindex succeeded, but activity telemetry was not recorded: ${E.reason}`),Ae(t,y(a.outputDb)),x}catch(m){let S=we({trigger:e.trigger,result:"failed",start:o,monotonicStart:s,error:m instanceof Error?m.message:String(m)});Yr(a.metaPath,S);let f=Qt(a.outputDb,S);throw f.state==="failed"&&r(`Warning: failed reindex activity telemetry was not recorded: ${f.reason}`),m}finally{g&&B(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function Tr(e){if(e.snapshot)try{let t=se(e.projectRoot),n=t?ue(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}let r=dn({snapshot:e.snapshot,sourceCacheDir:y(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let i=se(e.projectRoot);return(i?ue(i,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}});un(e.snapshot,y(e.paths.outputDb),"built"),e.onStatus(r.kind==="published"?`Published shared generation ${e.snapshot.generationId.slice(0,12)} (${r.achievedDurability})`:`Shared generation ${e.snapshot.generationId.slice(0,12)} was already available (${r.achievedDurability})`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${U(t)}`)}}function Io(e,t){if(!j(e.outputScip)||!j(e.outputDb)||!Vr(e.metaPath,t))return!1;let n=Q(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function U(e){return e instanceof Error?e.message:String(e)}function vo(e){let t=e.outputScip??R(e.projectRoot,"index.scip"),n=e.outputDb??R(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:R(y(n),"meta.json")}}function Eo(e){let t=Q(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!j(e.paths.outputScip)||!j(e.paths.outputDb)||!Vr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;le(de(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=b()-e.monotonicStart,r=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Yr(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:_o(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function _o(e,t,n,r){let i=Xr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:K(i[a]),outputBytes:Z(ft(e.outputDb,a)),durationMs:0}))}function Fo(e){let t=bo(R(y(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:R(t,Ee(e.outputScip)),tempOutputDb:R(t,Ee(e.outputDb)),tempMetaPath:R(t,Ee(e.metaPath))}}function jo(e){let t=[],n;try{n=Lr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[U(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{B(R(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${U(a)}`)}return{removed:r,errors:t}}async function To(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await W("reindex.language-indexers",async()=>(n=await Do(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:o,languageFingerprints:s,shards:d,typescriptProjectShardContext:c,incrementalTypeScript:l}=r;if(o.length>0&&e.onStatus(`Reused ${o.length} cached language shard(s): ${o.join(", ")}`),wo({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:o})){let h=T("reindex.publish",()=>Go(e,i,a,o,s,c),{mode:"metadata-only",languages:i.length,reused:o.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:d}}let u=T("reindex.publish",()=>$o(e,t,i,a,o,s,c,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:o.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:d}}function wo(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!j(e.run.paths.outputScip)||!j(e.run.paths.outputDb))return!1;let t=Q(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function Do(e,t){let n=Lo({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[F,ht]of n)ht.reused&&(r.push({language:F,scipPath:ht.scipPath}),i.add(F));for(let F of i)e.onStatus(`Reusing cached ${F} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),o=Q(e.paths.outputDb,e.paths.metaPath),s=te(e.paths.metaPath),d=o.state==="legacy"||o.state==="current",c=s?.scipCompanion!=="deferred"&&(o.state!=="current"||o.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&d?Pr({projectRoot:e.projectRoot,cacheDir:y(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:ee(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:ee(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:c,previousSnapshot:gt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:ko(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=Wo({languages:e.languages.filter(F=>!i.has(F)&&!u.has(F)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,trustProjectTools:e.opts.trustProjectTools===!0,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),S=p?h.filter(F=>F.language!=="typescript"||p.missedProjectIds.has(F.id)):h,f=await vr(S,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),P=[];if(p){Oo(e.paths.outputDb,f);let F=m.typescript??e.tempPaths.tempOutputScip;P=Ao({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:F,reusedProjects:p.reusedProjects})}let v=[...f,...P],{indexedOutputs:x}=Jo(v,g),E=l?[{language:"typescript",scipPath:l.scipPath}]:[],_=[...r,...E,...x];zo(_,g,e.languages,e.opts.allowPartial,e.onStatus);let ii=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Z(l.scipPath)??void 0}]:[],ai=No(n,[...f,...ii],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:_,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:Co(n,e.languages),shards:ai,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function ko(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=Y(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=cr(e.projectRoot,r),a=ar(n.fingerprint.files,r),o=or(r,i),s=sr(r,a,o),d=te(e.paths.metaPath),l=Mo(d,s,g=>j(Te(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:l,reusedProjects:u,missedProjectIds:h}}function Mo(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let o=e.version===q&&Oe(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(w(o)!==w(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Oo(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=Te(e,r);_e(y(i),{recursive:!0}),je(n.scipPath,i)}}function Ao(e){return e.reusedProjects.map((t,n)=>{let r=Te(e.outputDb,t),i=ee(e.tempOutputScip,"typescript-project-cached",n);return je(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Z(i)??void 0}})}function Lo(e){let t=te(e.paths.metaPath),n=Xr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=ft(e.paths.outputDb,i),o=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o,scipPath:a});continue}if(t.version!==q){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:o,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:o,scipPath:a});continue}if(!Oe(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:o,scipPath:a});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:o,scipPath:a});continue}if(!j(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o,scipPath:a});continue}if(w(s)!==w(o)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:o,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:o,scipPath:a})}return r}function No(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:K(a.fingerprint),outputBytes:Z(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),o=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=o?n.classification.get(o):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??a?.reason??i.skipped?.reason,fingerprint:s?K(s.fingerprint):a?K(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:K(a.fingerprint),outputBytes:Z(Te(n.outputDb,i)),durationMs:0});return r}function K(e){return So("sha256").update(w(e)).digest("hex").slice(0,16)}function Z(e){try{return Po(e).size}catch{return null}}function Co(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function $o(e,t,n,r,i,a,o,s){let d=!s||s.completeScipUpdated,c=!1;d&&(wr(e.paths.outputDb,n),c=Dr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=Xo({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:d,completeScipSanitized:c,materializeFullFallback:()=>{if(!s||s.completeScipUpdated)return c;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),xr({cacheDir:y(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let x=n.map(E=>E.language==="typescript"?{language:E.language,scipPath:s.candidateScipPath}:E);return wr(e.paths.outputDb,x),c=Dr(x,e.tempPaths.tempOutputScip,e.onStatus),c}});le(de(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus});let u=Ke(e.tempPaths.tempOutputDb);if(u.added.length>0&&e.onStatus(`Added SQLite query indexes: ${u.added.join(", ")}`),u.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${u.removed.join(", ")}`),l.mode==="incremental"&&s){let x=null,E=null;try{x=new O({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),E=new O({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let _=Nn(x,e.fingerprint,s.referenceFragmentsByFile,E);e.onStatus(`Cached exact TypeScript reference fragments for ${_} affected document(s).`)}catch(_){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${_ instanceof Error?_.message:String(_)}.`)}finally{x?.close(),E?.close()}}let p=gt(e.paths.metaPath),h=l.mode==="incremental"&&s?Vo(s,l.changedDocumentPaths):Xe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:p,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),g=we({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(x=>x.language),skipped:[...r]}),m=l.mode==="incremental"&&l.scipCompanion==="deferred",S={...a};m&&delete S.typescript;let{metadata:f,pruneProjects:P}=Gr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:S,typescriptProjectShardContext:o,lastRefresh:g});f.scipCompanion=m?"deferred":"current",Br(e.paths.outputDb,P),mt(e.tempPaths.tempMetaPath,f);let v=an({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}});return v.achievedDurability==="file-flushed"&&e.onStatus(`Published local generation ${v.currentGeneration.slice(0,12)} (file-flushed; directory sync unsupported)`),rn(y(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),$r(e.paths.outputDb,h,e.onStatus),g}function Go(e,t,n,r,i,a){let o=gt(e.paths.metaPath),s=null;try{je(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(p){s=Bn("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}le(de(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let d=Ke(e.paths.outputDb);d.added.length>0&&e.onStatus(`Added SQLite query indexes: ${d.added.join(", ")}`),d.removed.length>0&&e.onStatus(`Removed redundant SQLite indexes: ${d.removed.join(", ")}`),s??=Xe({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:o,currentSnapshot:e.fingerprint,refreshResult:"reused"});let c=we({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:l,pruneProjects:u}=Gr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:c});return Br(e.paths.outputDb,u),mt(e.paths.metaPath,l),sn(e.paths.outputDb,e.paths.metaPath),$r(e.paths.outputDb,s,e.onStatus),c}function gt(e){return St(te(e)?.fingerprint)}function $r(e,t,n){try{Un(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function Gr(e){let t=Bo({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:q,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,sqliteLayoutVersion:1,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function Bo(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=te(e.metaPath),n=t?.version===q?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Br(e,t){let n=Qr(e);if(t===null){B(n,{recursive:!0,force:!0});return}let r;try{r=Lr(n)}catch{return}for(let i of Uo(r,t))B(R(n,i),{force:!0})}function Uo(e,t){let n=new Set(t.map(r=>`${nt(r)}.scip`));return e.filter(r=>!n.has(r))}function wr(e,t){for(let n of t){let r=ft(e,n.language);_e(y(r),{recursive:!0}),n.scipPath!==r&&je(n.scipPath,r)}}async function qo(e,t){if(!Le()){if(Ro()==="win32")throw new Error("The scip CLI was not found. On Windows it ships via the npm sidecar package scip-query-scip-windows (installed automatically with scip-query). Reinstall scip-query with optional dependencies enabled, or follow 'scip-query setup' guidance for the exact sidecar package version, or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
250
|
+
To install the reviewed version, run: scip-query reindex --install-missing
|
|
251
|
+
Or install manually from: https://github.com/sourcegraph/scip/releases`);if(t("scip CLI not found on PATH. Attempting auto-install..."),!Rt(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
252
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function Wo(e){let t=[],n=[],r=e.languages.map((a,o)=>({language:a,scipPath:e.languages.length>1?ee(e.tempOutputScip,a,o):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:o})=>[a,o]));for(let{language:a,scipPath:o}of r){let s=Ho({...e,language:a,scipPath:o});for(let d of s)"skipped"in d?Ur(n,d.skipped):t.push(d.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function Ho(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[ut({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??Y(e.projectRoot,e.typescriptProjects);return t.length===0?[ut({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})]:(e.onStatus(`Indexing TypeScript workspace as ${t.length} project shard(s).`),t.map((n,r)=>ut({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:ee(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function ut(e){let t=Qe(e.language),n=fe(t),r=jn(t,e.projectRoot),i=e.trustProjectTools&&r?Tn(t,e.projectRoot):null,a=C(t);if(!i&&!a&&r){let c=`${n} is available only as repository-local code at ${r}. Review that exact tool and rerun with --trust-project-tools.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(!i&&!a&&!_n(t)){if(e.skipAutoInstall){let c=`${n} not found on PATH. To install the reviewed version, run: scip-query reindex --install-missing${t.installUrl?` (manual source: ${t.installUrl})`:""}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!Fr(t,e.onStatus)){let c=`${n} could not be auto-installed. ${t.installUrl?`Install manually from ${t.installUrl}`:`Install ${n} and put it on PATH.`}`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}}let o=i?.canonicalPath??C(t);if(!o){let c=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}let{binary:s,args:d}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:o,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});if(i&&!i.executable){let c=`${i.relativePath} is not executable; refusing project-local indexer.`;return e.onStatus(`Skipping ${e.language}: ${c}`),{skipped:{language:e.language,reason:c}}}return i&&e.onStatus(`Trusted project-local ${e.language} indexer ${i.relativePath} (${i.sha256.slice(0,12)}\u2026, ${i.canonicalPath}).`),{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:o,binary:s,args:d,env:kn(t,e.env,o),...i?{trustedProjectTool:i}:{}}}}function Jo(e,t){let n=new Map;for(let i of e)if(i.skipped)Ur(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,o=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};o.scipPaths.push(i.scipPath),n.set(a,o)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)zt(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&Nr(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function Ur(e,t){let n=e.find(r=>r.language===t.language);if(!n){e.push(t);return}n.reason.includes(t.reason)||(n.reason=`${n.reason}; ${t.reason}`)}function zo(e,t,n,r,i){if(e.length===0){let a=t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
252
253
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
253
254
|
`+a)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(a=>a.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
254
255
|
`+t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
255
|
-
`))}function
|
|
256
|
-
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function
|
|
256
|
+
`))}function Dr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Xt(e.map(a=>a.scipPath),t);return Wr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&Nr(e[0].scipPath,t);return!1}function Xo(e){let t;if(Qo(e)){let i=R(e.run.tempPaths.runDir,"typescript-affected.db");try{qr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();kr(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let o=er({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${o.affectedDocumentCount} SQLite document(s) in ${(o.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:o.changedDocumentPaths,patchDurationMs:o.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),B(i,{force:!0}),B(e.run.tempPaths.tempOutputDb,{force:!0}),e.run.onStatus(`Incremental SQLite publication unavailable: ${t}. Falling back to complete conversion.`)}}let n=e.completeScipSanitized;e.completeScipAvailable||(n=e.materializeFullFallback());let r=performance.now();return kr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function Qo(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!j(e.run.paths.outputDb)||!j(e.run.paths.outputScip))return!1;let t=new Set(e.reusedLanguages);return e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(n=>n==="typescript"||t.has(n))}function Vo(e,t){let n=b(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(o=>!i.has(o)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:b()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:ze(e.plan,a,e.projectFileCount)}}function kr(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!j(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||qr(e,r);let a=Le();if(!a)throw new Error("scip CLI is not available");yo(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(a){let o=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${o}`,{cause:a})}}function qr(e,t){let n=Jt(e);Wr(n,t)}function Wr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function ee(e,t,n){let r=xo(e)||".scip",i=Ee(e,r);return R(y(e),`${i}.${n+1}.${t}${r}`)}async function Yo(e,t){for(let n=0;n<2;n++){let r=Ko(e,t);if(r)return r;let i=Zo(e);if(i&&zr(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await ts(i)}catch(s){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${U(s)}`,{cause:s})}if(!a)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${y(e)}; refusing to steal an active lock.`);let o=Ne(e,{parseLegacy:Fe});if(!_t(e,o,{parseLegacy:Fe}))throw new Error(`Reindex lock ownership changed before preemption completed for ${y(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${y(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${y(e)}.`)}function Ko(e,t){let n=A(process.pid),r=Et(e,{kind:"reindex",processIdentity:n,detail:{projectRoot:t.projectRoot,...process.env.SCIP_REINDEX_PROCESS_GROUP_LEADER==="1"?{processGroupLeader:!0}:{},...t.trigger?{trigger:t.trigger}:{}},parseLegacy:Fe});if(r.kind==="acquired"&&r.reclaimed){let i=Hr(r.reclaimed,e);i&&zr(t.trigger,i)?t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}; its prior owner was already stale.`):t.onStatus(`Recovered an abandoned or incomplete reindex lock for ${y(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function Zo(e){return Hr(Ne(e,{parseLegacy:Fe}),e)}var Fe=e=>{let t=Jr(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Hr(e,t){if(e.state==="valid"&&e.record?.kind==="reindex"){let n=e.record.detail??{};return{version:2,pid:e.record.pid,...e.record.processIdentity?{processIdentity:e.record.processIdentity}:{},...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Jr(e.parsed,t)}function Jr(e,t){try{let n=e;return typeof n.pid!="number"||!Number.isInteger(n.pid)||n.pid<=0?null:{version:n.version===2?2:1,pid:n.pid,...n.processIdentity===void 0?{}:(()=>{let r=It(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:y(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function zr(e,t){return e?.kind==="manual-cli"&&es(t?.trigger)}function es(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function ts(e){return!L(e.pid)||(pt(e),Mr(e,"SIGTERM"),await Or(e,2e3))?!0:(pt(e),Mr(e,"SIGKILL"),Or(e,1e3))}function Mr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!L(e.pid))return;pt(e)}try{process.kill(e.pid,t)}catch{}}async function Or(e,t){let n=b()+t;for(;b()<n;){if(Ar(e))return!0;await ns(50)}return Ar(e)}function pt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=A(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!J(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function Ar(e){if(!L(e.pid))return!0;if(!e.processIdentity)return!1;let t=A(e.pid);return t!==null&&!J(e.processIdentity,t)}function ns(e){return new Promise(t=>setTimeout(t,e))}function Xr(e,t,n){return Object.fromEntries(t.map(r=>{let i=Qe(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:jt(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},o=r==="clojure"?rs(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&is(n),...a,clojureConfigPath:o,files:Dt(e,{language:r,markerFiles:i})}]}))}function rs(e){return e?.trim()||void 0}function is(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function ft(e,t){return R(y(e),"language-indexes",`${t}.scip`)}function Qr(e){return R(y(e),"language-indexes","typescript-projects")}function Te(e,t){return R(Qr(e),`${nt(t)}.scip`)}function te(e){try{return Me(ae(D(e,"reindex metadata")))}catch{return null}}function Vr(e,t){try{let n=ae(D(e,"reindex metadata"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&bt(r)&&w(r.fingerprint)===w(t)&&w([...r.indexedLanguages??[]].sort())===w(t.languages)}catch{return!1}}function mt(e,t){Ot(e,t,{spacing:2,trailingNewline:!0})}function Yr(e,t){try{let n=Me(ae(D(e,"reindex metadata")));if(!n)return;mt(e,{...n,lastRefresh:t})}catch{}}function we(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:b()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function w(e){return JSON.stringify(e)}var ti=process.env.SCIP_REINDEX_PROJECT_ROOT,ni=process.env.SCIP_REINDEX_OUTPUT_SCIP,ri=process.env.SCIP_REINDEX_OUTPUT_DB,Kr=process.env.SCIP_REINDEX_LANGUAGES,as=In(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),os=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",Zr=us(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),ss=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,cs=ls(process.env.SCIP_REINDEX_TRIGGER_KIND),ds=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!ti||!ni||!ri)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var ei=Kr?Kr.split(",").filter(Boolean):void 0;Cr({projectRoot:ti,outputScip:ni,outputDb:ri,languages:ei?.length?ei:void 0,pnpmWorkspaces:os,typescriptProjectMode:Zr.projectMode,typescriptProjects:Zr.projects,clojureConfigPath:ss,indexerConcurrency:as,trigger:{kind:cs,detail:ds||void 0},onStatus:e=>process.stderr.write(`[reindex] ${qe(e)}
|
|
257
|
+
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${qe(String(e))}`),process.exit(1)});function ls(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function us(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
|
|
257
258
|
//# sourceMappingURL=reindex-worker.js.map
|