scip-query 0.19.4 → 0.19.6
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 +75 -1
- package/README.md +242 -49
- package/dist/augment-vue-worker.js +1 -1
- package/dist/{chunk-2YU7I3QO.js → chunk-24QNP7MN.js} +2 -2
- package/dist/{chunk-CNKAGUPL.js → chunk-26X7KCJR.js} +2 -2
- package/dist/{chunk-GPBBJ5Y4.js → chunk-273W2U4Y.js} +3 -3
- package/dist/{chunk-7GXM52MI.js → chunk-2CVXCGL4.js} +2 -2
- package/dist/{chunk-ABMYA4TN.js → chunk-2EZSOTSY.js} +2 -2
- package/dist/{chunk-HKEHS2AS.js → chunk-2GSQR6YA.js} +2 -2
- package/dist/{chunk-FECYOO5O.js → chunk-2OXVAGGT.js} +2 -2
- package/dist/chunk-2ZOCHAL2.js +8 -0
- package/dist/{chunk-QGXBRIM5.js → chunk-336DC5NJ.js} +2 -2
- package/dist/chunk-35SQLYCQ.js +2 -0
- package/dist/{chunk-VXQNNXJE.js → chunk-3OIKRYU5.js} +2 -2
- package/dist/{chunk-52ZYCAEO.js → chunk-47X75ZKH.js} +2 -2
- package/dist/{chunk-NPKYOIFM.js → chunk-4CGVLUDP.js} +2 -2
- package/dist/chunk-4RI4BJGT.js +8 -0
- package/dist/{chunk-P2PC2WGR.js → chunk-52HQTTPB.js} +2 -2
- package/dist/{chunk-YNRNA5LK.js → chunk-5OC3HWP5.js} +2 -2
- package/dist/{chunk-STOL2BTL.js → chunk-6XFC7PQ5.js} +2 -2
- package/dist/{chunk-J77UIT3I.js → chunk-6XHTISLI.js} +2 -2
- package/dist/chunk-6YTSKJJ3.js +2 -0
- package/dist/{chunk-BTEE5NZQ.js → chunk-7E3TH5ZN.js} +2 -2
- package/dist/{chunk-X6D5IC6I.js → chunk-7LABSJSR.js} +2 -2
- package/dist/chunk-7Q6VYYCH.js +2 -0
- package/dist/{chunk-FWUUZTIO.js → chunk-A43URCQ3.js} +2 -2
- package/dist/chunk-A63U2W3P.js +3 -0
- package/dist/{chunk-3MJ5YA4Y.js → chunk-ADFSIJP2.js} +2 -2
- package/dist/chunk-AOLE4DYM.js +6 -0
- package/dist/chunk-APMMR5Y2.js +2 -0
- package/dist/chunk-B5MHCHP3.js +107 -0
- package/dist/{chunk-4RSI5EMG.js → chunk-CSTYYXKC.js} +2 -2
- package/dist/{chunk-25LPM4DG.js → chunk-CYJM7CYF.js} +2 -2
- package/dist/{chunk-S44IULR6.js → chunk-DD5BOU5I.js} +2 -2
- package/dist/{chunk-YGAGTIDK.js → chunk-DGMCFMPG.js} +7 -7
- package/dist/{chunk-UOAV44HR.js → chunk-E2ZXPB7J.js} +2 -2
- package/dist/{chunk-IZKFSVBV.js → chunk-EVOC5I5I.js} +2 -2
- package/dist/{chunk-XTX6QHOF.js → chunk-F42A3AKG.js} +2 -2
- package/dist/{chunk-Q4IIEGXJ.js → chunk-FHCTEANE.js} +2 -2
- package/dist/{chunk-3SVWW4PN.js → chunk-FKGN4A4E.js} +2 -2
- package/dist/{chunk-IG7N5ZIK.js → chunk-FQTPPXNA.js} +2 -2
- package/dist/{chunk-F6O7AAC3.js → chunk-G4UQL4CP.js} +2 -2
- package/dist/chunk-GA64UPMI.js +6 -0
- package/dist/{chunk-ZXJYMGD3.js → chunk-GK3GRUJX.js} +2 -2
- package/dist/chunk-HEBAY673.js +2 -0
- package/dist/chunk-HELS7KFF.js +2 -0
- package/dist/{chunk-B5NLK2B3.js → chunk-IPDCSB6N.js} +2 -2
- package/dist/{chunk-M7MTH5NR.js → chunk-IYAOX36F.js} +2 -2
- package/dist/{chunk-YVVCVR2L.js → chunk-J7VT2CRB.js} +2 -2
- package/dist/{chunk-4333ETTV.js → chunk-JELJLXEE.js} +2 -2
- package/dist/{chunk-LBMJEAEW.js → chunk-JERWGHQT.js} +2 -2
- package/dist/chunk-JJJCO4QC.js +945 -0
- package/dist/{chunk-6E7UTQY7.js → chunk-JZNLMHWY.js} +2 -2
- package/dist/{chunk-R4FQGQ4X.js → chunk-K42M2KWT.js} +2 -2
- package/dist/{chunk-H7UKLTWJ.js → chunk-KLVJABXA.js} +2 -2
- package/dist/chunk-KP4KBDVF.js +3 -0
- package/dist/{chunk-RV2FQIX3.js → chunk-LMFVTUW2.js} +2 -2
- package/dist/chunk-LRTP3DKL.js +3 -0
- package/dist/{chunk-U6WNH5GC.js → chunk-MGBJHRFB.js} +2 -2
- package/dist/{chunk-QDV6RDCP.js → chunk-MLGTCX56.js} +2 -2
- package/dist/{chunk-54HA4ZXH.js → chunk-N3SE646F.js} +2 -2
- package/dist/{chunk-KP6XRY5Z.js → chunk-NBRUH7OE.js} +2 -2
- package/dist/{chunk-M7AIS73L.js → chunk-NN4ZIRPK.js} +2 -2
- package/dist/{chunk-I5RJM53C.js → chunk-NQLSSVOB.js} +2 -2
- package/dist/{chunk-4SALD7RU.js → chunk-OBKDTVZ3.js} +2 -2
- package/dist/{chunk-GBQ5NYPR.js → chunk-OHWZKLVA.js} +6 -6
- package/dist/{chunk-6NSFJYRC.js → chunk-OP3MTFJR.js} +2 -2
- package/dist/{chunk-EOOJGLDU.js → chunk-OQ2A4G2G.js} +2 -2
- package/dist/{chunk-DLWR3NUU.js → chunk-P6HBYNBE.js} +2 -2
- package/dist/{chunk-QVWS2VWZ.js → chunk-PC44K7RF.js} +2 -2
- package/dist/{chunk-A2EZV2UM.js → chunk-QBYYWGAT.js} +2 -2
- package/dist/{chunk-QRGV2F7L.js → chunk-QHKUY4FW.js} +2 -2
- package/dist/chunk-QHRL4LKM.js +2 -0
- package/dist/{chunk-I5AWSI2G.js → chunk-QQWOFXNW.js} +2 -2
- package/dist/{chunk-WQTAC523.js → chunk-RBFFD4V2.js} +2 -2
- package/dist/{chunk-SOAT6NLA.js → chunk-RJHCPSZ7.js} +2 -2
- package/dist/{chunk-VGRICIQI.js → chunk-RWRLUZ6U.js} +2 -2
- package/dist/{chunk-4T3LTWUS.js → chunk-S2GP3CU3.js} +2 -2
- package/dist/{chunk-HEXVUYFQ.js → chunk-SHKZ7OVJ.js} +2 -2
- package/dist/{chunk-NSS46APD.js → chunk-TFUU5MQQ.js} +2 -2
- package/dist/{chunk-IUFDSKGG.js → chunk-TYQ76QHQ.js} +2 -2
- package/dist/{chunk-NRCXJDHL.js → chunk-U5CNPPTZ.js} +2 -2
- package/dist/{chunk-MITTUCEH.js → chunk-UQK5CRUK.js} +2 -2
- package/dist/{chunk-XLTP42QA.js → chunk-UUJBLG6J.js} +2 -2
- package/dist/chunk-UXP636P5.js +144 -0
- package/dist/{chunk-64RFXJT5.js → chunk-VEVBIAOJ.js} +6 -6
- package/dist/chunk-VKRQDBW5.js +9 -0
- package/dist/{chunk-C7NIYIQ4.js → chunk-VOQFGC2W.js} +4 -4
- package/dist/{chunk-DZ74OMG6.js → chunk-VP542C25.js} +2 -2
- package/dist/{chunk-Q3AFUTGB.js → chunk-WMXRRBII.js} +2 -2
- package/dist/{chunk-ZGZUZ7XE.js → chunk-WXAAURU7.js} +2 -2
- package/dist/chunk-X3NLZHPA.js +20 -0
- package/dist/{chunk-WER3B7MI.js → chunk-XF3KLXN3.js} +2 -2
- package/dist/{chunk-NH5ALKPW.js → chunk-XVJ3V7LM.js} +2 -2
- package/dist/{chunk-4XTA5OMB.js → chunk-YGQN3XGZ.js} +2 -2
- package/dist/{chunk-CFMXJPHH.js → chunk-YHXBD52M.js} +2 -2
- package/dist/{chunk-7B3UPBVA.js → chunk-YLVE3SXZ.js} +2 -2
- package/dist/{chunk-YIJ7ZAA4.js → chunk-YTUD45PU.js} +2 -2
- package/dist/{chunk-VTKGCT3V.js → chunk-YWB2EBNB.js} +2 -2
- package/dist/{chunk-UKZBVX4U.js → chunk-Z2LHPIOM.js} +2 -2
- package/dist/chunk-Z5QQPJ3U.js +30 -0
- package/dist/{chunk-NZL2DBT7.js → chunk-ZLJLE6LK.js} +2 -2
- package/dist/{chunk-XYADIZHU.js → chunk-ZTTISZ7J.js} +2 -2
- package/dist/cli.js +3 -3
- package/dist/command-descriptors-SJDZ7QGR.js +617 -0
- package/dist/{config-types-D20KuvvZ.d.ts → config-types-BWQ5xPGI.d.ts} +4 -0
- package/dist/{db-G_II8yXU.d.ts → db-B0r1o7Vt.d.ts} +18 -1
- package/dist/direct-navigation-HTKOZEOM.js +3 -0
- package/dist/{health-oblXYgkF.d.ts → health-CFnlCiTz.d.ts} +1 -1
- package/dist/index.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/queries/complexity-hotspots.js +1 -1
- package/dist/queries/complexity.d.ts +2 -2
- 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 +3 -3
- 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 +30 -2
- package/dist/queries/diff-gate.js +1 -1
- package/dist/queries/diff-impact.d.ts +2 -2
- package/dist/queries/diff-impact.js +1 -1
- package/dist/queries/doc-drift.d.ts +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/dist/queries/incomplete-migration.js +1 -1
- package/dist/queries/index.d.ts +17 -3
- 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 +2 -2
- package/dist/queries/methods.js +1 -1
- package/dist/queries/not-implemented.d.ts +3 -3
- 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 +2 -2
- package/dist/queries/passthrough-candidates.js +1 -1
- package/dist/queries/plan-context.d.ts +2 -2
- 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/stats.js +1 -1
- 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 +3 -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 +23 -24
- package/dist/reindex.d.ts +10 -4
- package/dist/reindex.js +33 -38
- package/dist/runtime.d.ts +167 -11
- package/dist/runtime.js +3 -2
- 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-kRpaexVJ.d.ts → scip-cli-DCvnlZCu.d.ts} +5 -1
- package/dist/watch-server.js +5 -5
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/AI_FAILURE_MODES.md +18 -18
- package/docs/API_EVOLUTION.md +71 -0
- package/docs/CLI_JSON_OUTPUT.md +83 -0
- package/docs/COMMAND_REFERENCE.md +10 -8
- package/docs/COMMITTED_RECORD_COMPATIBILITY.md +117 -0
- package/docs/CONFIGURATION_WRITE_SAFETY.md +130 -0
- package/docs/DETECTOR_GUIDE.md +47 -47
- package/docs/DURABILITY.md +103 -0
- package/docs/INDEX_GENERATIONS.md +121 -0
- package/docs/LOCK_PROTOCOL.md +133 -0
- package/docs/MAILBOX_LIFECYCLE.md +197 -0
- package/docs/REINDEX_METADATA_COMPATIBILITY.md +84 -0
- package/docs/RUST_DURABLE_SESSION_PROTOCOL.md +126 -0
- package/docs/TELEMETRY_RETENTION.md +72 -0
- package/docs/TIME_SEMANTICS.md +77 -0
- package/docs/WATCH_REFRESH_REQUESTS.md +110 -0
- package/docs/WINDOWS_SIDECAR_RELEASE.md +298 -0
- package/docs/analyzer-validation-ledger.md +24 -23
- package/docs/schemas/cli-json-envelope.schema.json +53 -0
- package/docs/schemas/npm-release-state.schema.json +146 -0
- package/docs/schemas/outcome-event-record.schema.json +39 -0
- package/docs/schemas/project-config.schema.json +247 -0
- package/docs/schemas/suppression-record.schema.json +31 -0
- package/docs/schemas/windows-sidecar-provenance.schema.json +137 -0
- package/package.json +15 -5
- package/scripts/build-scip-windows.mjs +180 -61
- package/scripts/scip-windows-provenance.mjs +364 -0
- package/scripts/verify-scip-windows.mjs +29 -0
- package/skills/_shared/SKILL.md +91 -242
- package/skills/_shared/agents/openai.yaml +1 -1
- package/skills/_shared/references/agent-contract-catalog.md +105 -0
- package/skills/_shared/references/command-catalog.md +118 -0
- package/skills/_shared/references/detector-precision-and-diffgate.md +59 -0
- package/skills/_shared/references/evidence-and-dead-code.md +25 -0
- package/skills/scip-audit/SKILL.md +76 -0
- package/skills/scip-audit/agents/openai.yaml +4 -0
- package/skills/scip-audit/references/claims.md +98 -0
- package/skills/scip-audit/references/cleanup.md +101 -0
- package/skills/scip-audit/references/directory.md +222 -0
- package/skills/scip-audit/references/frontend.md +130 -0
- package/skills/scip-audit/references/integrity.md +154 -0
- package/skills/scip-audit/references/maintainability.md +162 -0
- package/skills/scip-audit/references/twin-drift.md +104 -0
- package/skills/scip-diagnose/SKILL.md +52 -0
- package/skills/scip-diagnose/agents/openai.yaml +4 -0
- package/skills/scip-diagnose/references/debug.md +117 -0
- package/skills/{scip-probe-reachability/SKILL.md → scip-diagnose/references/probe-reachability.md} +12 -27
- package/skills/scip-diagnose/references/root-cause.md +145 -0
- package/skills/scip-diagnose/references/triage.md +119 -0
- package/skills/scip-explore/SKILL.md +53 -84
- package/skills/scip-explore/agents/openai.yaml +2 -2
- package/skills/scip-explore/references/diagrams.md +40 -0
- package/skills/scip-explore/references/language-playbook.md +49 -0
- package/skills/scip-improve/SKILL.md +56 -0
- package/skills/scip-improve/agents/openai.yaml +4 -0
- package/skills/scip-improve/references/cleanup-batches.md +53 -0
- package/skills/scip-improve/references/directory-moves.md +53 -0
- package/skills/scip-improve/references/doc-reconcile.md +30 -0
- package/skills/scip-improve/references/frontend-extraction.md +39 -0
- package/skills/scip-improve/references/maintainability-mechanism.md +43 -0
- package/skills/scip-improve/references/twin-drift.md +35 -0
- package/skills/scip-plan/SKILL.md +68 -0
- package/skills/scip-plan/agents/openai.yaml +4 -0
- package/skills/scip-plan/references/api-impact.md +19 -0
- package/skills/scip-plan/references/conductor.md +41 -0
- package/skills/scip-plan/references/high-assurance.md +43 -0
- package/skills/scip-plan/references/hyper-optimization.md +50 -0
- package/skills/scip-plan/references/tla-model.md +88 -0
- package/skills/scip-query/SKILL.md +52 -97
- package/skills/scip-query/agents/openai.yaml +2 -2
- package/skills/scip-setup/SKILL.md +65 -176
- package/skills/scip-setup/agents/openai.yaml +3 -3
- package/skills/scip-setup/references/bootstrap-workflow.md +120 -0
- package/skills/scip-setup/references/language-verification.md +61 -0
- package/skills/scip-setup/references/lifecycle-commands.md +119 -0
- package/skills/scip-setup/references/per-repo-triage.md +24 -0
- package/skills/scip-verify/SKILL.md +123 -70
- package/skills/scip-verify/agents/openai.yaml +2 -2
- package/skills/scip-verify/references/calibrate-detectors.md +170 -0
- package/dist/chunk-2CTX5CMX.js +0 -4
- package/dist/chunk-2Y373BDD.js +0 -2
- package/dist/chunk-C2QSK7E7.js +0 -2
- package/dist/chunk-D4U5Q3FT.js +0 -7
- package/dist/chunk-K2ERX4UT.js +0 -3
- package/dist/chunk-KHE7J5ZN.js +0 -3
- package/dist/chunk-L7SPDE73.js +0 -84
- package/dist/chunk-LHMNRHGV.js +0 -3
- package/dist/chunk-LM72NQ7T.js +0 -3
- package/dist/chunk-MSWVMDAH.js +0 -122
- package/dist/chunk-NH7WNNQC.js +0 -20
- package/dist/chunk-OMPZHGHO.js +0 -2
- package/dist/chunk-SVLTAG5O.js +0 -927
- package/dist/chunk-U7DSEKOM.js +0 -30
- package/dist/chunk-V27BEQJN.js +0 -7
- package/dist/chunk-VMNZB6WI.js +0 -4
- package/dist/chunk-XBN5VO53.js +0 -2
- package/dist/chunk-ZAIILQNP.js +0 -5
- package/dist/command-descriptors-MFU4BCJ7.js +0 -612
- package/dist/direct-navigation-MRMQFIRB.js +0 -3
- package/skills/scip-api-impact/SKILL.md +0 -139
- package/skills/scip-api-impact/agents/openai.yaml +0 -4
- package/skills/scip-calibrate/SKILL.md +0 -131
- package/skills/scip-calibrate/agents/openai.yaml +0 -4
- package/skills/scip-claim-audit/SKILL.md +0 -106
- package/skills/scip-claim-audit/agents/openai.yaml +0 -4
- package/skills/scip-cleanup-audit/SKILL.md +0 -126
- package/skills/scip-cleanup-audit/agents/openai.yaml +0 -4
- package/skills/scip-cleanup-improve/SKILL.md +0 -84
- package/skills/scip-cleanup-improve/agents/openai.yaml +0 -4
- package/skills/scip-concrete-plan/SKILL.md +0 -262
- package/skills/scip-concrete-plan/agents/openai.yaml +0 -4
- package/skills/scip-conductor/SKILL.md +0 -133
- package/skills/scip-conductor/agents/openai.yaml +0 -4
- package/skills/scip-debug/SKILL.md +0 -130
- package/skills/scip-debug/agents/openai.yaml +0 -4
- package/skills/scip-diagram/SKILL.md +0 -110
- package/skills/scip-diagram/agents/openai.yaml +0 -4
- package/skills/scip-directory-architecture/SKILL.md +0 -254
- package/skills/scip-directory-architecture/agents/openai.yaml +0 -4
- package/skills/scip-doc-reconcile/SKILL.md +0 -89
- package/skills/scip-doc-reconcile/agents/openai.yaml +0 -4
- package/skills/scip-hyper-optimization/SKILL.md +0 -156
- package/skills/scip-hyper-optimization/agents/openai.yaml +0 -4
- package/skills/scip-integrity-audit/SKILL.md +0 -152
- package/skills/scip-integrity-audit/agents/openai.yaml +0 -4
- package/skills/scip-language-playbook/SKILL.md +0 -106
- package/skills/scip-language-playbook/agents/openai.yaml +0 -4
- package/skills/scip-maintainability/SKILL.md +0 -158
- package/skills/scip-maintainability/agents/openai.yaml +0 -4
- package/skills/scip-probe-reachability/agents/openai.yaml +0 -4
- package/skills/scip-react-maintainability/SKILL.md +0 -101
- package/skills/scip-react-maintainability/agents/openai.yaml +0 -4
- package/skills/scip-root-cause/SKILL.md +0 -150
- package/skills/scip-root-cause/agents/openai.yaml +0 -4
- package/skills/scip-tla-model-system/SKILL.md +0 -148
- package/skills/scip-tla-model-system/agents/openai.yaml +0 -4
- package/skills/scip-triage-issue/SKILL.md +0 -126
- package/skills/scip-triage-issue/agents/openai.yaml +0 -4
- package/skills/scip-twin-drift/SKILL.md +0 -107
- package/skills/scip-twin-drift/agents/openai.yaml +0 -4
- package/skills/scip-vue-maintainability/SKILL.md +0 -107
- package/skills/scip-vue-maintainability/agents/openai.yaml +0 -4
package/dist/reindex.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
`)
|
|
3
|
-
`)
|
|
4
|
-
VALUES (?, ?, NULL, ?)`),c=i.transaction(d=>{let p=0;for(let l of d){if(o.has(l))continue;let m=ra(Xn(e.projectRoot,l),"utf-8"),g=a.run(sa(l),l,m);p+=Number(g.changes)}return p})(r),u={scanned:r.length,inserted:c,existing:r.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${u.existing} already present).`),u}finally{i.close()}}function ia(e,t){let n=oa(e,t);if(n)return n;let r=[],i=o=>{let a=o?Xn(e,o):e,s;try{s=na(a,{withFileTypes:!0})}catch{return}for(let c of s){if(wn.has(c.name))continue;let u=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(u);continue}t.has(Fe(c.name).toLowerCase())&&r.push(u)}};return i(""),r.sort()}function oa(e,t){try{return ea("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}).split(`
|
|
5
|
-
`).filter(r=>r&&t.has(Fe(r).toLowerCase())).sort()}catch{return null}}function aa(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.add(s.relative_path)}return n}function sa(e){return Fe(e).toLowerCase()===".vue"?"vue":Fe(e).replace(/^\./,"").toLowerCase()||"source"}import{createHash as ua}from"crypto";import{appendFileSync as da,existsSync as tr,mkdirSync as la,readFileSync as _l,renameSync as pa,rmSync as yt,statSync as ga}from"fs";import{dirname as nr,join as Zn}from"path";function ht(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 Oe(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),o=ht(e),a=new Set(o.reasons);return r.some(s=>!i.has(s))&&a.add("changed-file-outside-project"),t===null?(a.add("dependency-graph-unavailable"),Kn(r,i,a)):a.size>0?Kn(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:ca(r,t,i),reasons:[]}}function Kn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function ca(e,t,n){let r=new Map;for(let[a,s]of t)if(n.has(a))for(let c of s){if(!n.has(c))continue;let u=r.get(c)??new Set;u.add(a),r.set(c,u)}let i=new Set(e),o=[...e];for(let a=0;a<o.length;a+=1){let s=o[a];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}var fa="<global-symbols>";function ma(e){let t=[];for(let n of e.all(`
|
|
1
|
+
import{a as X}from"./chunk-X3NLZHPA.js";import{a as Ot,e as jt,f as oe,g as _t,h as fr,i as mr,j as hr,l as Ct,m as yr,n as Sr,o as br,p as Rr,r as xr,s as Ir,t as vr}from"./chunk-2ZOCHAL2.js";import{a as gr}from"./chunk-DGAGY7RJ.js";import{A as sr,B as Be,C as cr,D as ur,E as Dt,G as At,L as lr,N as pr,a as ee,b as Zn,c as $e,d as Rt,e as _,f as Ve,g as xt,h as It,j as Y,k as pe,l as te,m as he,n as ye,o as Pt,p as wt,q as kt,t as ie,u as F,v as Et,w as or,x as Tt,y as Ft,z as ar}from"./chunk-GA64UPMI.js";import{a as vt,b as nr,d as ne,e as rr,f as Se,g as re,h as y,m as ir,n as We,q as dr}from"./chunk-A63U2W3P.js";import{a as Ue}from"./chunk-YLVE3SXZ.js";import"./chunk-7LABSJSR.js";import{J as er,K as tr,d as ge}from"./chunk-DGMCFMPG.js";import{B as fe,C as me,a as Xn,c as Qn,d as Ne,e as le,f as G,g as St,h as Kn,i as bt}from"./chunk-B5MHCHP3.js";import{a as Ge}from"./chunk-64MNV6AB.js";import"./chunk-35SQLYCQ.js";import{execFileSync as El}from"child_process";import{createHash as Tl}from"crypto";import{copyFileSync as mt,existsSync as A,mkdirSync as gt,mkdtempSync as Fl,readdirSync as Sa,readFileSync as Wn,renameSync as ba,rmSync as ue,statSync as Dl}from"fs";import{basename as pt,dirname as S,extname as Al,join as k,resolve as da}from"path";import{platform as Ol}from"os";import{join as Ca}from"path";var Ma=e=>{if(!e||typeof e!="object"||Array.isArray(e))return null;let t=e.pid;return typeof t=="number"&&Number.isSafeInteger(t)&&t>0?{pid:t}:null};function Pr(e,t={}){return be(Ca(e,"gc.lock"),t)}function be(e,t={}){let n=t.waitMs??0,r=t.pollMs??10,i=t.now??y,o=i()+n;do{let a=La(e);if(a)return Na(a);let s=o-i();if(s<=0)return null;$a(Math.min(r,s))}while(i()<=o);return null}function La(e){let t=oe(e,{kind:"generic",parseLegacy:Ma});return t.kind==="acquired"?t.lock:null}function Na(e){return{release:()=>{e.release()}}}function $a(e){let t=new Int32Array(new SharedArrayBuffer(Int32Array.BYTES_PER_ELEMENT));Atomics.wait(t,0,0,e)}import Va from"better-sqlite3";import{execFileSync as Ga}from"child_process";import{existsSync as Ua,readdirSync as Ba,readFileSync as Wa}from"fs";import{extname as qe,join as wr}from"path";function U(e={}){return{id:"auxiliary-documents",facts:["auxiliary-document"],run:t=>kr({projectRoot:t.projectRoot,dbPath:t.dbPath,extensions:e.extensions,onStatus:t.onStatus})}}function kr(e){let t=new Set((e.extensions??er).map(o=>o.toLowerCase()));if(t.size===0)return{scanned:0,inserted:0,existing:0};if(!Ua(e.dbPath))throw new Error(`SCIP SQLite database not found at ${e.dbPath}`);let n=gr(e.projectRoot),r=qa(e.projectRoot,t).filter(o=>!n.isIgnored(o)),i=new Va(e.dbPath);try{let o=za(i,r),a=i.prepare(`INSERT OR IGNORE INTO documents (language, relative_path, position_encoding, text)
|
|
2
|
+
VALUES (?, ?, NULL, ?)`),c=i.transaction(d=>{let l=0;for(let p of d){if(o.has(p))continue;let f=Wa(wr(e.projectRoot,p),"utf-8"),g=a.run(Ja(p),p,f);l+=Number(g.changes)}return l})(r),u={scanned:r.length,inserted:c,existing:r.length-c};return e.onStatus?.(`Augmented SQLite documents with ${c} auxiliary source file${c===1?"":"s"} (${u.existing} already present).`),u}finally{i.close()}}function qa(e,t){let n=Ha(e,t);if(n)return n;let r=[],i=o=>{let a=o?wr(e,o):e,s;try{s=Ba(a,{withFileTypes:!0})}catch{return}for(let c of s){if(tr.has(c.name))continue;let u=o?`${o}/${c.name}`:c.name;if(c.isDirectory()){i(u);continue}t.has(qe(c.name).toLowerCase())&&r.push(u)}};return i(""),r.sort()}function Ha(e,t){try{return Ga("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}).split(`
|
|
3
|
+
`).filter(r=>r&&t.has(qe(r).toLowerCase())).sort()}catch{return null}}function za(e,t){let n=new Set,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT relative_path FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.add(s.relative_path)}return n}function Ja(e){return qe(e).toLowerCase()===".vue"?"vue":qe(e).replace(/^\./,"").toLowerCase()||"source"}import{createHash as Xa}from"crypto";import{existsSync as Qa,readFileSync as Fp}from"fs";import{dirname as Ka,join as Tr}from"path";function Mt(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 He(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),o=Mt(e),a=new Set(o.reasons);return r.some(s=>!i.has(s))&&a.add("changed-file-outside-project"),t===null?(a.add("dependency-graph-unavailable"),Er(r,i,a)):a.size>0?Er(r,i,a):{mode:"closure",changedFiles:r,affectedFiles:Ya(r,t,i),reasons:[]}}function Er(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function Ya(e,t,n){let r=new Map;for(let[a,s]of t)if(n.has(a))for(let c of s){if(!n.has(c))continue;let u=r.get(c)??new Set;u.add(a),r.set(c,u)}let i=new Set(e),o=[...e];for(let a=0;a<o.length;a+=1){let s=o[a];if(s!==void 0)for(let c of r.get(s)??[])i.has(c)||(i.add(c),o.push(c))}return[...i].sort()}var Za="<global-symbols>";function es(e){let t=[];for(let n of e.all(`
|
|
6
4
|
SELECT relative_path, language, position_encoding, text
|
|
7
5
|
FROM documents
|
|
8
6
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -29,7 +27,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
29
27
|
FROM defn_enclosing_ranges r
|
|
30
28
|
JOIN documents d ON d.id = r.document_id
|
|
31
29
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
32
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
30
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:Lt(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
33
31
|
SELECT d.relative_path,
|
|
34
32
|
c.chunk_index,
|
|
35
33
|
m.role,
|
|
@@ -44,7 +42,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
44
42
|
JOIN chunks c ON c.id = m.chunk_id
|
|
45
43
|
JOIN documents d ON d.id = c.document_id
|
|
46
44
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
47
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
45
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:Lt(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
48
46
|
SELECT g.symbol,
|
|
49
47
|
g.display_name,
|
|
50
48
|
g.kind,
|
|
@@ -58,10 +56,9 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
58
56
|
) AND NOT EXISTS (
|
|
59
57
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
60
58
|
)
|
|
61
|
-
`))t.push({relativePath:
|
|
62
|
-
`);n.set(r,o.digest("hex"))}return n}function
|
|
63
|
-
`,i=Math.max(1,Math.floor(n)),o=`${e}${Ra}`;if(la(nr(e),{recursive:!0}),tr(e)){let a=ga(e).size;a>i?(yt(e,{force:!0}),yt(o,{force:!0})):a+Buffer.byteLength(r)>i&&(yt(o,{force:!0}),pa(e,o))}da(e,r)}function St(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 Ia={now:()=>Date.now(),databaseExists:e=>tr(e),openDatabase:(e,t,n)=>new W({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>we(e),dependencyGraph:e=>ke(e),factDigests:e=>ma(e)},Pa={appendHistory:va,writeLatest:(e,t)=>R(e,t,{spacing:2,trailingNewline:!0})};function je(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(r).toISOString(),durationMs:Math.max(0,r-n),reason:t,...i?{error:i}:{}}}function er(e){try{e?.close()}catch{}}import{execFileSync as wa}from"child_process";import{existsSync as ka,readdirSync as ar}from"fs";import{extname as sr,join as cr}from"path";var ur=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),Ea=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function xt(e){let t=[],n=Ta(e),r=ja(e);for(let i of Ea){if(Da(e,i.files)){t.push(i.language);continue}if(Fa(n,i.globs)){t.push(i.language);continue}Aa(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&or(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&or(t,"c"),t}function Ta(e){try{return ar(e)}catch{return[]}}function Da(e,t){return t?.length?t.some(n=>ka(cr(e,n))):!1}function Fa(e,t){return t?.length?e.some(n=>t.some(r=>Oa(n,r))):!1}function Oa(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function ja(e){let t=Ca(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=ar(i,{withFileTypes:!0})}catch{continue}for(let a of o){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let s=cr(i,a.name);if(a.isDirectory()){ur.has(a.name)||r.push(s);continue}let c=sr(a.name).toLowerCase();c&&n.add(c)}}return n}function Ca(e){try{let t=wa("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"]}),n=new Set;for(let r of t.split(`
|
|
64
|
-
`)){if(!r||r.split("/").some(o=>ur.has(o)))continue;let i=sr(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function Aa(e,t){return t?.length?t.some(n=>e.has(n)):!1}function or(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as dr,readdirSync as _a}from"fs";import{isAbsolute as La,join as vt,resolve as Ma}from"path";var pr={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:Y.language,indexerBinary:Y.indexerBinary,checkCommand:`${Y.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:Y.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:Y.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",La(r)?r:Ma(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",lr(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",lr(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=vt(e,"vendor","bin","scip-php"),r=vt(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",dr(r)?r:dr(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Ce(e){return pr[e]}function lr(e,t){let n;try{n=_a(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return vt(e,i);return null}import{readFileSync as Pt,writeFileSync as wt}from"fs";import{create as oe}from"@bufbuild/protobuf";import{deserializeSCIP as kt,serializeSCIP as Et,DocumentSchema as Ha,IndexSchema as mr,MetadataSchema as Ja,SymbolInformationSchema as qa}from"@c4312/scip";import{readFileSync as Na,writeFileSync as $a}from"fs";import{create as gr}from"@bufbuild/protobuf";import{deserializeSCIP as Ga,DocumentSchema as Va,IndexSchema as Ba,serializeSCIP as Ua,SymbolRole as Wa}from"@c4312/scip";function fr(e){let t;try{t=Ga(Na(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=It(t);return n.removedDefinitionOccurrences>0&&$a(e,Buffer.from(Ua(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function It(e){let t=new Set;for(let o of e.documents)for(let a of o.symbols)a.symbol&&t.add(a.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let a=o.occurrences.filter(s=>(s.symbolRoles&Wa.Definition)===0||t.has(s.symbol)?!0:(n+=1,!1));if(a.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(gr(Va,{language:o.language,relativePath:o.relativePath,occurrences:a,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:gr(Ba,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}function Tt(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=Ya(e),n=Xa(e.flatMap(i=>i.documents??[])),r=Sr(e.flatMap(i=>i.externalSymbols??[]));return oe(mr,{metadata:t,documents:n,externalSymbols:r})}function Dt(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>kt(Pt(i))),r=Tt(n);return wt(t,Buffer.from(Et(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function hr(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>kt(Pt(i))),r=It(Tt(n));return wt(t,Buffer.from(Et(r.index))),{documentCount:r.index.documents.length,externalSymbolCount:r.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function za(e,t,n){let r=e.metadata;if(!r)throw new Error("Cannot rebase a SCIP index without metadata");if(r.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${r.projectRoot}`);return oe(mr,{metadata:oe(Ja,{...r,projectRoot:n}),documents:e.documents,externalSymbols:e.externalSymbols})}function yr(e,t,n){let r=kt(Pt(e)),i=za(r,t,n);wt(e,Buffer.from(Et(i)))}function Ya(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function Xa(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,oe(Ha,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Qa([...r.occurrences,...n.occurrences]),symbols:Sr([...r.symbols,...n.symbols]),text:Za(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function Qa(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function Sr(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,oe(qa,{symbol:r.symbol,documentation:es([...r.documentation,...n.documentation]),relationships:Ka([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function Ka(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function Za(e,t){return e?t?e.length>=t.length?e:t:e:t}function es(e){return[...new Set(e)]}import{createHash as ts}from"crypto";import{copyFileSync as ns,existsSync as br,rmSync as Rr}from"fs";import{resolve as rs}from"path";import Ir from"better-sqlite3";var is={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}]},os={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 Pr(e){let t=Date.now(),n=as(e.affectedFiles);if(ss(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Rr(e.candidateDbPath,{force:!0}),!br(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!br(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");xr(e.previousDbPath,"previous SQLite generation",!1),xr(e.miniDbPath,"incremental SQLite mini database"),ns(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Ir(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ft(r,"main","candidate SQLite generation"),Ft(r,"incremental","incremental SQLite mini database"),cs(r,n),us(r,n.length);let i=Ot(r,"main",!0),o=N(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{ds(r),ls(r),ps(r),e.onStage?.("after-delete"),gs(r),e.onStage?.("after-symbol-reconciliation"),fs(r),e.onStage?.("after-insert"),ms(r),hs(r,n.length,o),e.onStage?.("before-commit")}).immediate(),wr(r,"main","candidate SQLite generation");let c=[...ys(r)].filter(([u,d])=>i.get(u)!==d).map(([u])=>u).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:c,durationMs:Date.now()-t}}catch(i){try{r?.close()}finally{Rr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function as(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 ss(e,t,n){let r=[e,t,n].map(i=>rs(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function xr(e,t,n=!0){let r=new Ir(e,{readonly:!0,fileMustExist:!0});try{Ft(r,"main",t),n&&wr(r,"main",t)}finally{r.close()}}function Ft(e,t,n){for(let[r,i]of Object.entries(is)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:d})=>({name:s,type:c.toUpperCase(),notnull:u,pk:d}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(os)){let o=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),a=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(o?.tbl_name!==i.table||JSON.stringify(a)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}vr(e,t,"documents",["relative_path"],n),vr(e,t,"global_symbols",["symbol"],n)}function vr(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(u=>u.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function wr(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 cs(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 o of i)n.run(o)})(t)}function us(e,t){let n=N(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=N(e,`SELECT COUNT(*) AS value
|
|
59
|
+
`))t.push({relativePath:Za,kind:"global-symbol",values:Lt(n)});return ts(t)}function ts(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),o=t.get(r.relativePath)??[];o.push(i),t.set(r.relativePath,o)}let n=new Map;for(let[r,i]of[...t].sort(([o],[a])=>o.localeCompare(a))){let o=Xa("sha256");for(let a of i.sort())o.update(String(Buffer.byteLength(a))),o.update(":"),o.update(a),o.update(`
|
|
60
|
+
`);n.set(r,o.digest("hex"))}return n}function ns(e,t){let n=[],r=[],i=[],o=[],a=new Set([...e.keys(),...t.keys()]);for(let s of[...a].sort()){let c=e.get(s),u=t.get(s);c===void 0?n.push(s):u===void 0?i.push(s):c!==u?r.push(s):o.push(s)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:o}}function Nt(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),o=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),a=e.affectedFiles.filter(c=>!i.has(c)).sort(),s=t.changedFiles.length-o.length;return{passed:o.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:o,extraFiles:a}}function $t(e,t=cs){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,o=r(),a=(u,d)=>{let l=r();return Or(e.refreshResult,u,n?l:i(),Math.max(0,l-o),d)};if(!t.databaseExists(e.previousDbPath))return a("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return a("candidate-index-unavailable");let s=null,c=null;try{s=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let u=[...new Set([...t.indexedPaths(s),...t.indexedPaths(c)])].sort(),d=Ne(e.previousSnapshot,e.currentSnapshot),l=new Set(u),p=d.changes.length>0&&!Mt(d).fullProject&&d.changes.every(b=>l.has(b.path)),f=He(d,p?t.dependencyGraph(s):new Map,u),g=ns(t.factDigests(s),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-o),manifest:d,plan:f,comparison:g,evaluation:Nt(f,g,u.length)}}catch(u){return a("oracle-error",u instanceof Error?u.message:String(u))}finally{Fr(s),Fr(c)}}function Dr(e,t,n,r=Date.now()){return Or(e,t,r,0,n)}function rs(e){let t=Ka(e);return{latestPath:Tr(t,"affected-shadow-latest.json"),historyPath:Tr(t,"affected-shadow.jsonl")}}function Ar(e,t,n=us){let r=rs(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var is=8*1024*1024,os=mr;function as(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 ss(e,t,n=is){hr(e,as(t),{maxSegmentBytes:n,previousSuffix:os})}function Lt(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 cs={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:y,databaseExists:e=>Qa(e),openDatabase:(e,t,n)=>new X({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>Ge(e),dependencyGraph:e=>Ue(e),factDigests:e=>es(e)},us={appendHistory:ss,writeLatest:(e,t)=>ie(e,t,{spacing:2,trailingNewline:!0})};function Or(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 Fr(e){try{e?.close()}catch{}}import{execFileSync as ds}from"child_process";import{existsSync as ls,readdirSync as _r}from"fs";import{extname as Cr,join as Mr}from"path";var Lr=new Set([".git",".hg",".svn",".idea",".vscode","node_modules","vendor","dist","build","target","bin","obj",".dart_tool",".gradle",".next",".venv","venv","__pycache__"]),ps=[{language:"typescript",files:["tsconfig.json","tsconfig.base.json"],extensions:[".ts",".tsx",".mts",".cts"]},{language:"rust",files:["Cargo.toml"],extensions:[".rs"]},{language:"go",files:["go.mod"],extensions:[".go"]},{language:"java",files:["pom.xml","build.gradle","build.gradle.kts"],extensions:[".java"]},{language:"kotlin",files:["build.gradle.kts"],extensions:[".kt",".kts"]},{language:"scala",files:["build.sbt"],extensions:[".scala"]},{language:"clojure",files:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],extensions:[".clj",".cljs",".cljc"]},{language:"python",files:["pyproject.toml","setup.py","setup.cfg","Pipfile"],extensions:[".py",".pyi"]},{language:"ruby",files:["Gemfile"],extensions:[".rb"]},{language:"cpp",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".cc",".cpp",".cxx",".hpp",".hh",".hxx"]},{language:"c",files:["compile_commands.json","CMakeLists.txt","Makefile"],extensions:[".c",".h"]},{language:"csharp",globs:["*.csproj","*.sln"],extensions:[".cs"]},{language:"vb",globs:["*.vbproj"],extensions:[".vb"]},{language:"dart",files:["pubspec.yaml"],extensions:[".dart"]},{language:"php",files:["composer.json"],extensions:[".php"]},{language:"javascript",files:["package.json"],extensions:[".js",".jsx",".mjs",".cjs"]}];function Vt(e){let t=[],n=gs(e),r=ys(e);for(let i of ps){if(fs(e,i.files)){t.push(i.language);continue}if(ms(n,i.globs)){t.push(i.language);continue}bs(r,i.extensions)&&t.push(i.language)}return t.includes("typescript")&&jr(t,"javascript"),t.includes("cpp")&&!r.has(".c")&&jr(t,"c"),t}function gs(e){try{return _r(e)}catch{return[]}}function fs(e,t){return t?.length?t.some(n=>ls(Mr(e,n))):!1}function ms(e,t){return t?.length?e.some(n=>t.some(r=>hs(n,r))):!1}function hs(e,t){if(t==="*")return!0;if(!t.includes("*"))return e===t;let[n,r]=t.split("*");return e.startsWith(n??"")&&e.endsWith(r??"")}function ys(e){let t=Ss(e);if(t)return t;let n=new Set,r=[e];for(;r.length>0;){let i=r.pop();if(!i)continue;let o;try{o=_r(i,{withFileTypes:!0})}catch{continue}for(let a of o){if(a.name.startsWith(".")&&!a.name.endsWith("proj")&&!a.name.endsWith("sln")&&a.isDirectory())continue;let s=Mr(i,a.name);if(a.isDirectory()){Lr.has(a.name)||r.push(s);continue}let c=Cr(a.name).toLowerCase();c&&n.add(c)}}return n}function Ss(e){try{let t=ds("git",["-C",e,"ls-files","-co","--exclude-standard","--","."],{encoding:"utf-8",maxBuffer:26214400,stdio:["ignore","pipe","ignore"],timeout:3e4,killSignal:"SIGKILL"}),n=new Set;for(let r of t.split(`
|
|
61
|
+
`)){if(!r||r.split("/").some(o=>Lr.has(o)))continue;let i=Cr(r).toLowerCase();i&&n.add(i)}return n}catch{return null}}function bs(e,t){return t?.length?t.some(n=>e.has(n)):!1}function jr(e,t){let n=e.indexOf(t);n!==-1&&e.splice(n,1)}import{existsSync as Nr,readdirSync as Rs}from"fs";import{isAbsolute as xs,join as Gt,resolve as Is}from"path";var Vr={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:te.language,indexerBinary:te.indexerBinary,checkCommand:`${te.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:te.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:te.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",xs(r)?r:Is(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",$r(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",$r(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=Gt(e,"vendor","bin","scip-php"),r=Gt(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",Nr(r)?r:Nr(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function ze(e){return Vr[e]}function $r(e,t){let n;try{n=Rs(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Gt(e,i);return null}import{readFileSync as Bt,writeFileSync as Wt}from"fs";import{create as Re}from"@bufbuild/protobuf";import{deserializeSCIP as qt,serializeSCIP as Ht,DocumentSchema as Ds,IndexSchema as Br,MetadataSchema as As,SymbolInformationSchema as Os}from"@c4312/scip";import{readFileSync as vs,writeFileSync as Ps}from"fs";import{create as Gr}from"@bufbuild/protobuf";import{deserializeSCIP as ws,DocumentSchema as ks,IndexSchema as Es,serializeSCIP as Ts,SymbolRole as Fs}from"@c4312/scip";function Ur(e){let t;try{t=ws(vs(e))}catch{return{removedDefinitionOccurrences:0,touchedDocuments:0}}let n=Ut(t);return n.removedDefinitionOccurrences>0&&Ps(e,Buffer.from(Ts(n.index))),{removedDefinitionOccurrences:n.removedDefinitionOccurrences,touchedDocuments:n.touchedDocuments}}function Ut(e){let t=new Set;for(let o of e.documents)for(let a of o.symbols)a.symbol&&t.add(a.symbol);for(let o of e.externalSymbols)o.symbol&&t.add(o.symbol);let n=0,r=0,i=[];for(let o of e.documents){let a=o.occurrences.filter(s=>(s.symbolRoles&Fs.Definition)===0||t.has(s.symbol)?!0:(n+=1,!1));if(a.length===o.occurrences.length){i.push(o);continue}r+=1,i.push(Gr(ks,{language:o.language,relativePath:o.relativePath,occurrences:a,symbols:o.symbols,text:o.text,positionEncoding:o.positionEncoding}))}return{index:n===0?e:Gr(Es,{metadata:e.metadata,documents:i,externalSymbols:e.externalSymbols}),removedDefinitionOccurrences:n,touchedDocuments:r}}function zt(e){if(e.length===0)throw new Error("Cannot merge zero SCIP indexes");if(e.length===1)return e[0];let t=_s(e),n=Cs(e.flatMap(i=>i.documents??[])),r=Hr(e.flatMap(i=>i.externalSymbols??[]));return Re(Br,{metadata:t,documents:n,externalSymbols:r})}function Jt(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>qt(Bt(i))),r=zt(n);return Wt(t,Buffer.from(Ht(r))),{documentCount:r.documents.length,externalSymbolCount:r.externalSymbols.length,inputCount:e.length}}function Wr(e,t){if(e.length===0)throw new Error("Cannot merge zero SCIP files");let n=e.map(i=>qt(Bt(i))),r=Ut(zt(n));return Wt(t,Buffer.from(Ht(r.index))),{documentCount:r.index.documents.length,externalSymbolCount:r.index.externalSymbols.length,inputCount:e.length,removedDefinitionOccurrences:r.removedDefinitionOccurrences,touchedDocuments:r.touchedDocuments}}function js(e,t,n){let r=e.metadata;if(!r)throw new Error("Cannot rebase a SCIP index without metadata");if(r.projectRoot!==t)throw new Error(`Cannot rebase SCIP project root: expected ${t}, got ${r.projectRoot}`);return Re(Br,{metadata:Re(As,{...r,projectRoot:n}),documents:e.documents,externalSymbols:e.externalSymbols})}function qr(e,t,n){let r=qt(Bt(e)),i=js(r,t,n);Wt(e,Buffer.from(Ht(i)))}function _s(e){let t=e[0]?.metadata;if(!t)return;let n=t.projectRoot;for(let r of e.slice(1)){let i=r.metadata?.projectRoot;if(n&&i&&i!==n)throw new Error(`Cannot merge SCIP indexes with different project roots: ${n} vs ${i}`)}return t}function Cs(e){let t=new Map;for(let n of e){let r=t.get(n.relativePath);if(!r){t.set(n.relativePath,n);continue}t.set(n.relativePath,Re(Ds,{language:r.language||n.language,relativePath:r.relativePath||n.relativePath,occurrences:Ms([...r.occurrences,...n.occurrences]),symbols:Hr([...r.symbols,...n.symbols]),text:Ns(r.text,n.text),positionEncoding:r.positionEncoding||n.positionEncoding}))}return[...t.values()]}function Ms(e){let t=new Set,n=[];for(let r of e){let i=JSON.stringify(r);t.has(i)||(t.add(i),n.push(r))}return n}function Hr(e){let t=new Map;for(let n of e){let r=t.get(n.symbol);if(!r){t.set(n.symbol,n);continue}t.set(n.symbol,Re(Os,{symbol:r.symbol,documentation:$s([...r.documentation,...n.documentation]),relationships:Ls([...r.relationships,...n.relationships]),kind:r.kind||n.kind,displayName:r.displayName||n.displayName,enclosingSymbol:r.enclosingSymbol||n.enclosingSymbol,signatureDocumentation:r.signatureDocumentation??n.signatureDocumentation}))}return[...t.values()]}function Ls(e){let t=new Set,n=[];for(let r of e){let i=[r.symbol,r.isReference?"1":"0",r.isImplementation?"1":"0",r.isTypeDefinition?"1":"0",r.isDefinition?"1":"0"].join("|");t.has(i)||(t.add(i),n.push(r))}return n}function Ns(e,t){return e?t?e.length>=t.length?e:t:e:t}function $s(e){return[...new Set(e)]}import{createHash as Vs}from"crypto";import{copyFileSync as Gs,existsSync as zr,rmSync as Jr}from"fs";import{resolve as Us}from"path";import Qr from"better-sqlite3";var Bs={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}]},Ws={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 Kr(e){let t=y(),n=qs(e.affectedFiles);if(Hs(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Jr(e.candidateDbPath,{force:!0}),!zr(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!zr(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");Yr(e.previousDbPath,"previous SQLite generation",!1),Yr(e.miniDbPath,"incremental SQLite mini database"),Gs(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Qr(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Yt(r,"main","candidate SQLite generation"),Yt(r,"incremental","incremental SQLite mini database"),zs(r,n),Js(r,n.length);let i=Xt(r,"main",!0),o=B(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{Ys(r),Xs(r),Qs(r),e.onStage?.("after-delete"),Ks(r),e.onStage?.("after-symbol-reconciliation"),Zs(r),e.onStage?.("after-insert"),ec(r),tc(r,n.length,o),e.onStage?.("before-commit")}).immediate(),Zr(r,"main","candidate SQLite generation");let c=[...nc(r)].filter(([u,d])=>i.get(u)!==d).map(([u])=>u).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:c,durationMs:y()-t}}catch(i){try{r?.close()}finally{Jr(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function qs(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 Hs(e,t,n){let r=[e,t,n].map(i=>Us(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function Yr(e,t,n=!0){let r=new Qr(e,{readonly:!0,fileMustExist:!0});try{Yt(r,"main",t),n&&Zr(r,"main",t)}finally{r.close()}}function Yt(e,t,n){for(let[r,i]of Object.entries(Bs)){let a=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:s,type:c,notnull:u,pk:d})=>({name:s,type:c.toUpperCase(),notnull:u,pk:d}));if(JSON.stringify(a)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(Ws)){let o=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),a=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(s=>s.name);if(o?.tbl_name!==i.table||JSON.stringify(a)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Xr(e,t,"documents",["relative_path"],n),Xr(e,t,"global_symbols",["symbol"],n)}function Xr(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(s=>{if(s.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${s.name}')`).all().map(u=>u.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function Zr(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 zs(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 o of i)n.run(o)})(t)}function Js(e,t){let n=B(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=B(e,`SELECT COUNT(*) AS value
|
|
65
62
|
FROM main.documents d
|
|
66
63
|
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
67
64
|
FROM temp.incremental_affected_paths p
|
|
@@ -71,7 +68,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
71
68
|
FROM incremental.documents d
|
|
72
69
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
73
70
|
WHERE p.relative_path IS NULL
|
|
74
|
-
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||o!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function
|
|
71
|
+
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||o!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function Ys(e){e.exec(`
|
|
75
72
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
76
73
|
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
77
74
|
SELECT g.symbol
|
|
@@ -98,7 +95,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
98
95
|
FROM incremental.mentions m
|
|
99
96
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
100
97
|
WHERE m.role = 1;
|
|
101
|
-
`)}function
|
|
98
|
+
`)}function Xs(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
102
99
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
103
100
|
UNION
|
|
104
101
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
@@ -121,7 +118,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
121
118
|
SELECT u.symbol
|
|
122
119
|
FROM unaffected_definitions u
|
|
123
120
|
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
124
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function
|
|
121
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Qs(e){e.exec(`
|
|
125
122
|
DELETE FROM main.mentions
|
|
126
123
|
WHERE chunk_id IN (
|
|
127
124
|
SELECT c.id
|
|
@@ -143,7 +140,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
143
140
|
);
|
|
144
141
|
DELETE FROM main.documents
|
|
145
142
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
146
|
-
`)}function
|
|
143
|
+
`)}function Ks(e){e.exec(`
|
|
147
144
|
UPDATE main.global_symbols
|
|
148
145
|
SET display_name = NULL,
|
|
149
146
|
kind = NULL,
|
|
@@ -185,7 +182,7 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
185
182
|
WHERE source.symbol = main.global_symbols.symbol
|
|
186
183
|
)
|
|
187
184
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
188
|
-
`)}function
|
|
185
|
+
`)}function Zs(e){let t=B(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=B(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=B(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)
|
|
189
186
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
190
187
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
191
188
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
@@ -200,15 +197,15 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
200
197
|
r.start_line, r.start_char, r.end_line, r.end_char
|
|
201
198
|
FROM incremental.defn_enclosing_ranges r
|
|
202
199
|
JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
203
|
-
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function
|
|
200
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function ec(e){e.exec(`
|
|
204
201
|
DELETE FROM main.global_symbols
|
|
205
202
|
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
206
203
|
AND NOT EXISTS (
|
|
207
204
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
208
205
|
);
|
|
209
|
-
`)}function
|
|
206
|
+
`)}function tc(e,t,n){let r=B(e,"SELECT COUNT(*) AS value FROM main.documents"),i=B(e,`SELECT COUNT(*) AS value
|
|
210
207
|
FROM main.documents d
|
|
211
|
-
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 o=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),a=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(o!==void 0||a!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function
|
|
208
|
+
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 o=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),a=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(o!==void 0||a!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function nc(e){let t=Xt(e,"main",!0),n=Xt(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 Xt(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
|
|
212
209
|
FROM ${t}.documents d
|
|
213
210
|
${r}
|
|
214
211
|
ORDER BY d.relative_path`).all(),o=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
@@ -230,13 +227,12 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
230
227
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
231
228
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
232
229
|
${r}
|
|
233
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[d,
|
|
234
|
-
`);u.set(d,
|
|
235
|
-
`)}function
|
|
236
|
-
`;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function Lt(e){try{let t=Is(e,"utf-8"),n=JSON.parse(_s(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as Ii,randomUUID as Qt}from"crypto";import{closeSync as Pi,constants as gc,copyFileSync as bi,existsSync as U,lstatSync as fc,mkdirSync as A,mkdtempSync as wi,openSync as ki,readdirSync as mc,readFileSync as F,realpathSync as hc,renameSync as z,rmSync as B,statSync as yc,unlinkSync as Yt,writeFileSync as Ei}from"fs";import{dirname as Ti,join as f,resolve as me}from"path";import{setTimeout as Sc}from"timers/promises";import{pathToFileURL as Ri}from"url";import{deserializeSCIP as Di}from"@c4312/scip";import bc from"better-sqlite3";import{createRequire as Ls}from"module";var Ms=Ls(import.meta.url),Lr=Ns().version;function Ns(){for(let e of["../package.json","../../package.json"])try{return Ms(e)}catch{}return{version:"0.0.0"}}import{lstatSync as Zs,readdirSync as ec}from"fs";import{join as tc,relative as nc,resolve as Ht,sep as rc}from"path";import{createHash as $s}from"crypto";import{existsSync as Nt,mkdirSync as Gs,readFileSync as _e,readdirSync as Ip,renameSync as Vs,rmSync as Pp,writeFileSync as Bs}from"fs";import{join as X}from"path";import{create as Nr,fromBinary as $r,toBinary as Us}from"@bufbuild/protobuf";import{deserializeSCIP as Le,DocumentSchema as $t,IndexSchema as Gr,serializeSCIP as Vr}from"@c4312/scip";var Me=1,ae="typescript-scip-fragments";function Br(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,n=[];for(let o of e){let a=J(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=$r($t,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);n.push(s)}let r=Vr(Nr(Gr,{documents:n,externalSymbols:[]})),i=Le(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function Ne(e){let t=X(e,ae);return{rootDir:t,blobDir:X(t,"blobs"),generationDir:X(t,"generations")}}function Ws(e){let t=Le(e.indexBytes);ei(t.metadata,ti(e)),Zr(t.externalSymbols);let n=new Set,r=[];for(let o of t.documents){let a=J(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);n.add(a);let s=Us($t,o),c=e.documentIdentities.get(a)??(e.allowUntrackedDocuments?q(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:a,contentHash:q(s)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${a}`);r.push(Yr(e.cacheDir,{relativePath:a,bytes:s,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Xr(e,r);return Qr(e.cacheDir,i),i}function Ur(e){let t=Ne(e.cacheDir);if(!Nt(Gt(t,e.generationIdentity)))return Ws(e);let n=Hr({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&n.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let r of n.manifest.documents){let i=e.documentIdentities.get(r.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==r.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${r.relativePath}`)}return n.manifest}function Wr(e){let t=Hr({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,n=new Map(t.documents.map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=J(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(r.add(a),!n.has(a))throw new Error(`TypeScript fragment replacement has no prior document: ${a}`);let s=e.documentIdentities.get(a);if(!s)throw new Error(`missing TypeScript document identity: ${a}`);o.bytes===null?n.delete(a):n.set(a,Yr(e.cacheDir,o,s))}if(r.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Xr(e,[...n.values()]);return Qr(e.cacheDir,i),i}function Hr(e){let t=Ne(e.cacheDir),n=Gt(t,e.generationIdentity),r;try{r=Kr(_e(n,"utf8"))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(r.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&r.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&r.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of r.documents){let a=X(t.blobDir,`${o.blobHash}.scipdoc`),s=_e(a);if(s.byteLength!==o.byteLength||q(s)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,s)}return{manifest:r,fragments:i}}function Jr(e){let t=zr(e);return Mt(t.baseIndex,t.completeDocuments,"assembled")}function qr(e){let t=zr(e);return Hs(t.deletedAffectedPaths),{completeIndexBytes:Mt(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:Mt(t.baseIndex,t.affectedDocuments,"affected")}}function zr(e){let t=Le(e.baseIndexBytes);ei(t.metadata,ti(e)),Zr(t.externalSymbols);let n=new Map;for(let s of e.fragments){let c=J(s.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);n.set(c,s)}if(n.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let r=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=J(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let u=n.get(c);if(!u){i.push(s);continue}if(n.delete(c),u.bytes===null){a.push(c);continue}let d=$r($t,u.bytes);if(d.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${d.relativePath}`);i.push(d),o.push(d)}if(n.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...n.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function Mt(e,t,n){let r=Vr(Nr(Gr,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Le(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function Hs(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function Yr(e,t,n){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let r=J(t.relativePath),i=Buffer.from(t.bytes),o=q(i),a=Ne(e);Gs(a.blobDir,{recursive:!0});let s=X(a.blobDir,`${o}.scipdoc`);if(Nt(s)){let c=_e(s);if(c.byteLength!==i.byteLength||q(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${r}`)}else{let c=`${s}.${process.pid}.${Date.now()}.tmp`;Bs(c,i),Vs(c,s)}return{relativePath:r,blobHash:o,byteLength:i.byteLength,documentIdentity:n}}function Xr(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let n=[...t].sort((r,i)=>r.relativePath.localeCompare(i.relativePath));if(new Set(n.map(r=>r.relativePath)).size!==n.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:Me,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:n}}function Qr(e,t){let n=Ne(e),r=Gt(n,t.generationIdentity);if(Nt(r)){let i=Kr(_e(r,"utf8"));if(Mr(i)!==Mr(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}R(r,t,{spacing:2,trailingNewline:!0})}function Mr(e){return q(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function Kr(e){let t=JSON.parse(e);if(t.version!==Me||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let n=new Set;for(let r of t.documents){if(!r||typeof r.relativePath!="string"||typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash)||typeof r.byteLength!="number"||!Number.isInteger(r.byteLength)||r.byteLength<0||typeof r.documentIdentity!="string"||!r.documentIdentity)throw new Error("invalid TypeScript fragment record");if(J(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function Gt(e,t){return X(e.generationDir,Js(t))}function Js(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${q(e)}.json`}function Zr(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function ei(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function ti(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function J(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function q(e){return $s("sha256").update(e).digest("hex")}import{createHash as qs}from"crypto";import{existsSync as se,mkdirSync as zs,readFileSync as ue,readdirSync as Vt,renameSync as Ys,rmSync as ni,writeFileSync as Xs}from"fs";import{join as D}from"path";var $e=1,ii=64*1024*1024,de="typescript-scip-overlays";function oi(e){let t=ci(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=Wt(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);r.add(a),n.set(a,Qs(e.cacheDir,o))}if(r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:$e,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((o,a)=>o.relativePath.localeCompare(a.relativePath))};return Ks(e.cacheDir,i),i}function ai(e){let t=ci(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=ue(D(le(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`));if(i.byteLength!==r.byteLength||ce(i)!==r.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${r.relativePath}`);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return Jr({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function si(e,t){let n=le(e),r=D(n,"generations");if(!se(r))return;let i=new Set(t.map(Ut)),o=new Set;for(let s of Vt(r).filter(c=>i.has(c))){let c=Bt(ue(D(r,s),"utf8"));for(let u of c.overlays)u.blobHash&&o.add(`${u.blobHash}.scipdoc`)}for(let s of Vt(r))i.has(s)||ni(D(r,s),{force:!0});let a=D(n,"blobs");if(se(a))for(let s of Vt(a))o.has(s)||ni(D(a,s),{force:!0})}function ci(e,t){let n=D(le(e),"generations",Ut(t));if(!se(n))return null;let r=Bt(ue(n,"utf8"));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function Qs(e,t){let n=Wt(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=ce(r),o=D(le(e),"blobs");zs(o,{recursive:!0});let a=D(o,`${i}.scipdoc`);if(se(a)){let s=ue(a);if(s.byteLength!==r.byteLength||ce(s)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${n}`)}else{let s=`${a}.${process.pid}.${Date.now()}.tmp`;Xs(s,r),Ys(s,a)}return{relativePath:n,blobHash:i,byteLength:r.byteLength}}function Ks(e,t){let n=D(le(e),"generations",Ut(t.generationIdentity));if(se(n)){let r=Bt(ue(n,"utf8"));if(ri(r)!==ri(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}R(n,t,{spacing:2,trailingNewline:!0})}function Bt(e){let t=JSON.parse(e);if(t.version!==$e||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let n=new Set;for(let r of t.overlays){if(!r||typeof r.relativePath!="string"||r.blobHash!==null&&(typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash))||!Number.isInteger(r.byteLength)||r.byteLength<0||r.blobHash===null&&r.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(Wt(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function le(e){return D(e,de)}function Ut(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${ce(e)}.json`}function ri(e){return ce(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function Wt(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function ce(e){return qs("sha256").update(e).digest("hex")}var pe=1,Jt="language-indexes",ui=["index.db","index.scip","meta.json"],di=[Jt,ae,de];function Ge(e){let t=[];for(let n of ui)ic(e,n),t.push(n);for(let n of di)li(e,n,t);return{version:pe,files:t.sort()}}function Ve(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!ui.includes(e)&&!di.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function j(e,t){let n=Ve(t),r=Ht(e),i=Ht(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${rc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function li(e,t,n){let r=tc(e,t),i;try{i=ec(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?li(e,a,n):o.isFile()&&n.push(Ve(a))}}function ic(e,t){let n=j(e,t),r;try{r=Zs(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if(nc(Ht(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{createHash as oc}from"crypto";import{copyFileSync as pi,existsSync as G,linkSync as ac,mkdirSync as gi,readFileSync as hi,readdirSync as fi,renameSync as zt,rmSync as Ue,statSync as sc}from"fs";import{basename as Be,dirname as ge,join as k,relative as mi}from"path";var Q=1,We=".scipquery-generations";function He(e){let t=Je(e.outputDb),n=cc(e,t);e.onStage?.("after-recovery-retained"),e.preserveOutputScip||qt(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),qt(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),qt(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let r=qe(e.metaPath,e.outputDb),i={version:Q,currentGeneration:r,...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:(e.now??(()=>new Date))().toISOString()};return R(k(t,"state.json"),i,{spacing:2,trailingNewline:!0}),{currentGeneration:r,...n?{previousGeneration:n}:{}}}function yi(e){try{let t=JSON.parse(hi(k(Je(e),"state.json"),"utf8"));return t.version!==Q||typeof t.currentGeneration!="string"||!t.currentGeneration||typeof t.publishedAt!="string"||!Number.isFinite(Date.parse(t.publishedAt))||!lc(t.previousGeneration)||!pc(t.publication)?null:t}catch{return null}}function Si(e,t,n=()=>new Date){if(!G(e)||!G(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=yi(e),i={version:Q,currentGeneration:qe(t,e),...r?.previousGeneration?{previousGeneration:r.previousGeneration}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return R(k(Je(e),"state.json"),i,{spacing:2,trailingNewline:!0}),i}function V(e,t=k(ge(e),"meta.json")){let n=k(Je(e),"state.json");if(!G(n))return{state:"legacy",statePath:n};let r=yi(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=qe(t,e),o=r.currentGeneration===i,a=r.previousGeneration?G(k(ge(e),r.previousGeneration.databasePath)):!0;return!o||!a?{state:"drifted",statePath:n,currentMatches:o,recoveryExists:a,generation:r,reason:o?"retained recovery database is missing":"stable database or metadata no longer matches the published generation"}:{state:"current",statePath:n,currentMatches:o,recoveryExists:a,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function Je(e){return k(ge(e),We)}function cc(e,t){if(!G(e.outputDb))return;let n=qe(e.metaPath,e.outputDb),r=k(t,n),i=k(r,Be(e.outputDb)),o=G(e.metaPath)?k(r,Be(e.metaPath)):void 0;if(!G(i)){let a=`${r}.${process.pid}.${Date.now()}.tmp`;Ue(a,{recursive:!0,force:!0}),gi(a,{recursive:!0});let s=k(a,Be(e.outputDb));try{ac(e.outputDb,s)}catch{pi(e.outputDb,s)}o&&pi(e.metaPath,k(a,Be(e.metaPath))),gi(t,{recursive:!0}),zt(a,r)}return uc(t,n),{generationIdentity:n,databasePath:mi(ge(e.outputDb),i),...o?{metadataPath:mi(ge(e.outputDb),o)}:{}}}function uc(e,t){for(let n of fi(e,{withFileTypes:!0}))!n.isDirectory()||n.name===t||n.name.endsWith(".tmp")||Ue(k(e,n.name),{recursive:!0,force:!0});for(let n of fi(e,{withFileTypes:!0}))n.isDirectory()&&n.name.endsWith(".tmp")&&Ue(k(e,n.name),{recursive:!0,force:!0})}function qe(e,t){let n=oc("sha256").update(`sqlite-generation-v${Q}\0`);G(e)&&n.update(dc(hi(e,"utf8")));let r=sc(t);return n.update(`\0${r.size}`),n.digest("hex")}function dc(e){try{let t=JSON.parse(e);if((t.version===2||t.version===3)&&t.status==="complete"&&typeof t.updatedAt=="string"&&t.fingerprint!==void 0)return JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages,scipCompanion:t.scipCompanion})}catch{}return e}function qt(e,t){Ue(`${t}.tmp-replace`,{force:!0}),zt(e,`${t}.tmp-replace`),zt(`${t}.tmp-replace`,t)}function lc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e;return typeof t.generationIdentity=="string"&&!!t.generationIdentity&&typeof t.databasePath=="string"&&!!t.databasePath&&(t.metadataPath===void 0||typeof t.metadataPath=="string"&&!!t.metadataPath)}function pc(e){if(e===void 0)return!0;if(!e||typeof e!="object")return!1;let t=e,n=[t.converterDurationMs,t.affectedDocumentCount,t.changedDocumentCount,t.producerDurationMs,t.materializationDurationMs,t.patchDurationMs].filter(r=>r!==void 0);return(t.mode==="incremental"||t.mode==="full")&&t.validation==="passed"&&t.converterDurationMs!==void 0&&n.every(r=>typeof r=="number"&&Number.isFinite(r)&&r>=0)&&(t.scipCompanion===void 0||t.scipCompanion==="current"||t.scipCompanion==="deferred")&&(t.typescriptOverlayGeneration===void 0||typeof t.typescriptOverlayGeneration=="string"&&!!t.typescriptOverlayGeneration)&&(t.scipCompanion!=="deferred"||!!t.typescriptOverlayGeneration)&&(t.fallbackReason===void 0||typeof t.fallbackReason=="string")}var Kt=1,xi="SCIP_QUERY_SHARED_CACHE",Xt=JSON.stringify({cliVersion:Lr,artifactCatalogVersion:pe,sqliteGenerationStoreVersion:Q,typescriptFragmentStoreVersion:Me,typescriptOverlayStoreVersion:$e}),Fi="manifest.json",Rc="shared-cache.json",Zt=[Jt,ae,de];function ze(e,t){if(!e.clean||!e.treeOid)return;let n=ye(JSON.stringify({version:Kt,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:Xt}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:Xt,generationId:n,repositoryCacheDir:$n(e.repositoryId)}}function Oi(e,t,n){if(process.env[xi]==="0")return`${xi}=0`;if(!Gn(n))return"explicit cache or database override";if(me(t)!==me(f(Nn(e),"index.db")))return"index database is outside the managed worktree cache"}function C(e,t=!0){let n=tn(e),r;try{r=vc(F(f(n,Fi),"utf8"))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||JSON.stringify(r.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return r;try{for(let i of r.artifacts){let o=j(n,i.path),a=yc(o);if(!a.isFile()||a.size!==i.size||ye(F(o))!==i.sha256)return null}}catch{return null}return r}function ji(e){let t=C(e.snapshot);if(t)return t;if(!Li(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=vi(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=Ge(e.sourceCacheDir),i=f(e.snapshot.repositoryCacheDir,"generations");A(i,{recursive:!0});let o=wi(f(i,`.tmp-${process.pid}-`));try{let a=[];for(let p of r.files){let l=j(e.sourceCacheDir,p),m=j(o,p);he(l,m);let g=F(m);a.push({path:p,size:g.byteLength,sha256:ye(g)})}let s=Di(F(f(o,"index.scip"))).metadata?.projectRoot;if(!s)throw new Error("shared SCIP generation has no project root metadata");let c=nn(e.sourceProjectRoot);if(s!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(vi(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:Kt,artifactCatalogVersion:pe,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:s,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((p,l)=>p.path.localeCompare(l.path))};R(f(o,Fi),u,{spacing:2,trailingNewline:!0});let d=tn(e.snapshot);try{if(U(d)&&!C(e.snapshot)){let p=`${d}.corrupt-${process.pid}-${Date.now()}`;z(d,p),B(p,{recursive:!0,force:!0})}z(o,d)}catch(p){let l=C(e.snapshot);if(l)return l;throw p}return u}finally{B(o,{recursive:!0,force:!0})}}function en(e){let t=tn(e.snapshot);A(e.targetCacheDir,{recursive:!0});let n=ie(f(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{r=wi(f(e.targetCacheDir,".shared-hydrate-")),Fc(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let u=j(t,c.path),d=j(r,c.path);he(u,d);let p=F(d);if(p.byteLength!==c.size||ye(p)!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=nn(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&yr(j(r,c.path),e.manifest.scipProjectRoot,a);if(!Li(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=Ec(e.targetCacheDir,r),o=!0,Tc(r,e.targetCacheDir,i),He({tempOutputScip:f(r,"index.scip"),tempOutputDb:f(r,"index.db"),tempMetaPath:f(r,"meta.json"),outputScip:f(e.targetCacheDir,"index.scip"),outputDb:f(e.targetCacheDir,"index.db"),metaPath:f(e.targetCacheDir,"meta.json"),now:e.now});let s=V(f(e.targetCacheDir,"index.db"),f(e.targetCacheDir,"meta.json"));if(s.state==="invalid"||s.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${s.reason}`);Ye(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&Dc(e.targetCacheDir,i),a}finally{r&&B(r,{recursive:!0,force:!0}),n.release()}}async function Ci(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??Date.now,o=i()+n,a=f(e.repositoryCacheDir,"locks"),s=f(a,`${e.generationId}.lock`);for(A(a,{recursive:!0});i()<=o;){if(C(e))return{kind:"generation-ready"};let c=Qt();try{let u=ki(s,"wx");try{Ei(u,`${JSON.stringify({version:1,pid:process.pid,token:c,generationId:e.generationId,startedAt:new Date(i()).toISOString()})}
|
|
237
|
-
|
|
238
|
-
`)}finally{Pi(i)}try{let o=Ai(e);return!o||o.raw!==t.raw||o.pid!==void 0&&T(o.pid)?!1:(Yt(e),!0)}catch{return!1}finally{try{let o=JSON.parse(F(n,"utf8"));o.pid===process.pid&&o.token===r&&Yt(n)}catch{}}}function kc(e,t,n){let r=qn(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId;if(!o||!U(f(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=f(e,"worktrees");A(i,{recursive:!0}),R(f(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),Ic(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function Ec(e,t){let n=f(t,".rollback"),r=new Map,i=new Map;A(n,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=f(e,s),u=U(c);r.set(s,u),u&&he(c,f(n,"stable",s))}for(let s of Zt){let c=f(e,s),u=U(c);if(u){let d=fc(c);if(!d.isDirectory()||d.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,u)}let o=f(e,We),a=U(o);return a&&_i(o,f(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:a}}function Tc(e,t,n){for(let r of Zt){let i=f(t,r);if(n.managedDirectories.get(r)){let a=f(n.root,"managed",r);A(Ti(a),{recursive:!0}),z(i,a)}let o=f(e,r);U(o)&&z(o,i)}}function Dc(e,t){for(let i of Zt){let o=f(e,i),a=f(t.root,"managed",i);t.managedDirectories.get(i)?U(a)&&(B(o,{recursive:!0,force:!0}),z(a,o)):B(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=f(e,i);if(!o){B(a,{force:!0});continue}let s=`${a}.shared-restore-${Qt()}`;he(f(t.root,"stable",i),s),B(a,{force:!0}),z(s,a)}let n=f(e,We);B(n,{recursive:!0,force:!0});let r=f(t.root,"sqlite-generations");t.generationStoreExisted&&U(r)&&z(r,n)}function _i(e,t){A(t,{recursive:!0});for(let n of mc(e,{withFileTypes:!0})){let r=f(e,n.name),i=f(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?_i(r,i):n.isFile()&&he(r,i)}}function Fc(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function Li(e,t,n,r=!0,i=!0){try{let o=Pc(e);if(o?.status!=="complete"||JSON.stringify(o.fingerprint)!==JSON.stringify(n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return fe("source validation rejected metadata"),!1;let a=Ge(e),s=V(f(e,"index.db"),f(e,"meta.json"));if(r?s.state!=="current":s.state==="invalid"||s.state==="drifted")return fe(`source validation rejected SQLite generation state ${s.state}`),!1;let c=new bc(f(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let u=nn(t),p=(i?a.files.filter(l=>l.endsWith(".scip")):["index.scip"]).every(l=>{let m=Di(F(j(e,l))).metadata?.projectRoot;return m!==u&&fe(`source validation rejected SCIP root for ${l}: ${String(m)}`),m===u});return p||fe("source validation rejected SCIP project roots"),p}catch(o){return fe(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function fe(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function nn(e){try{return Ri(hc(e)).href}catch{return Ri(me(e)).href}}function ye(e){return Ii("sha256").update(e).digest("hex")}import{existsSync as Oc,readFileSync as jc,readdirSync as Cc,statSync as Ac}from"fs";import v from"path";var _c=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Se(e,t=[]){let n=v.resolve(e),r=t.flatMap(c=>Mc(n,c));if(r.length>0)return Mi(n,Ni(r));let i=Lc(n),o=Ni(i),a=$c(n,o)?[n,...o]:o,s=a.length>0?a:[n];return Mi(n,s)}function Mi(e,t){return[...new Set(t.map(n=>Vc(e,n)))].sort((n,r)=>n.localeCompare(r))}function Lc(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Cc(r,{withFileTypes:!0})}catch{continue}for(let o of i){let a=v.join(r,o.name);if(o.isDirectory()){!_c.has(o.name)&&!o.name.startsWith(".")&&n.push(a);continue}o.isFile()&&Nc(a)&&t.push(v.dirname(a))}}return t}function Mc(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!Z(e,r))return[];try{let i=Ac(r);if(i.isDirectory())return[r];if(i.isFile()&&$i(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function Nc(e){if(!$i(v.basename(e)))return!1;let t=Gi(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function $i(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Ni(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&&Bc(n,r)))}function $c(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return Oc(n)&&Gc(n)}function Gc(e){let n=Gi(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 Gi(e){try{let t=JSON.parse(jc(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Vc(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function Bc(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as uu}from"crypto";import{existsSync as on,readFileSync as Zi,statSync as du,writeFileSync as an}from"fs";import{join as lu}from"path";import{readFileSync as Vi}from"fs";import{createRequire as Uc}from"module";import{dirname as Wc,isAbsolute as yg,relative as Sg,resolve as bg,sep as Rg}from"path";var Bi=Uc(import.meta.url),Hc=1,Ui="0.4.0";function rn(){let e=Jc();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function Jc(){try{let e=Bi.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(Vi(e,"utf8"));if(t.version!==Ui)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${Ui}`};let n=Wc(e),r=Bi.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(Vi(r,"utf8"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:n,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:qc(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function qc(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${Hc}`}import{createHash as zc}from"crypto";import{readFileSync as Yc}from"fs";import{dirname as Xc,join as Xe}from"path";var Qe=2,Qc="typescript-index";function Wi(e){let t=Xe(e,Qc);return{rootDir:t,requestDir:Xe(t,"requests"),responseDir:Xe(t,"responses")}}function Hi(e){try{let t=JSON.parse(Yc(Xe(Xc(e),"meta.json"),"utf8"));return t.version!==2&&t.version!==3||t.status!=="complete"||typeof t.updatedAt!="string"||t.fingerprint===void 0?null:zc("sha256").update(JSON.stringify({version:t.version,status:t.status,updatedAt:t.updatedAt,fingerprint:t.fingerprint,indexedLanguages:t.indexedLanguages})).digest("hex")}catch{return null}}import{randomUUID as Kc}from"crypto";import{existsSync as Zc,mkdirSync as Ji,readFileSync as eu,rmSync as qi}from"fs";import{resolve as zi}from"path";var tu=12e4,nu=5,Ke=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;constructor(t,n={}){this.projectRoot=Cn(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??su(),this.runtime=n.runtime??cu}request(t){let n=jn(this.cacheDir),r=Wi(this.cacheDir),i=lt(n.statePath);if(!Yi(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let o=this.runtime.randomId(),a=zi(r.requestDir,`${o}.json`),s=zi(r.responseDir,`${o}.json`),c=this.runtime.now()+this.timeoutMs;Ji(r.requestDir,{recursive:!0}),Ji(r.responseDir,{recursive:!0}),R(a,{protocolVersion:Qe,id:o,baseGeneration:this.baseGeneration,deadlineAtMs:c,request:t});try{for(;this.runtime.now()<=c;){if(Zc(s))return ru(eu(s,"utf8"),o,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=lt(n.statePath);if(!Yi(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(nu)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}finally{qi(a,{force:!0}),qi(s,{force:!0})}}};function Yi(e,t,n){let r=e!==null&&n.now()-Date.parse(e.heartbeatAt)<=On,i=e?.typescriptIndex?.busyUntil!==void 0&&n.now()<=Date.parse(e.typescriptIndex.busyUntil);return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===Qe&&n.isProcessAlive(e.pid)&&(r||i)}function ru(e,t,n,r,i){let o=JSON.parse(e);if(o.protocolVersion!==Qe||o.id!==t||o.ok===!0&&o.baseGeneration!==n)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 a=iu(o.response,r),s=[...new Set(i)].sort(),c=a.fragments.map(u=>u.relativePath).sort();if(JSON.stringify(c)!==JSON.stringify(s))throw new Error("TypeScript index service omitted or added an affected document.");return a}function iu(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(o=>{if(!o||typeof o.relativePath!="string"||o.bytesBase64!==null&&typeof o.bytesBase64!="string"||typeof o.occurrences!="number"||!Number.isInteger(o.occurrences)||o.occurrences<0||typeof o.symbols!="number"||!Number.isInteger(o.symbols)||o.symbols<0||!Array.isArray(o.referenceFragments)||!o.referenceFragments.every(ou)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:au(o.bytesBase64);return{relativePath:o.relativePath,bytes:a,occurrences:o.occurrences,symbols:o.symbols,referenceFragments:o.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function ou(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 au(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function su(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:tu}var cu={now:Date.now,randomId:Kc,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:T};function pu(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=Ee(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(u=>u.kind!=="modified"||u.inputKind!=="source"||!pt(u.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=Oe(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=gu([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=Xi(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=Xi(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=Ki(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=Ki(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return c?{eligible:!0,manifest:n,plan:r,projectIdentity:o,previousFragmentGeneration:Qi(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Qi(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function gu(e,t){let n=null;for(let r of e){let i=t.filter(o=>o==="."||r===o||r.startsWith(`${o}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function eo(e){let t=Date.now();try{if(!on(e.previousDbPath)||!on(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=rn();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new W({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=we(o,{includeIgnored:!1}).filter(pt).sort(),s=ke(o)}finally{o.close()}let c=performance.now()-n,u=pu({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?Se(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:on(lu(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let d=Hi(e.previousDbPath);if(!d)throw new Error("published TypeScript base generation unavailable");n=performance.now();let l=new Ke({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:d}).request({kind:"emit-documents",tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument,projectIdentity:u.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles}),m=performance.now()-n,g=du(e.previousShardPath).size>=ii;n=performance.now();let S=g?null:Zi(e.previousShardPath),b=g?{completeIndexBytes:null,affectedIndexBytes:Br(l.fragments)}:qr({packageVersion:r.packageVersion,baseIndexBytes:S,fragments:l.fragments}),P=performance.now()-n;n=performance.now(),g?oi({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:l.fragments}):(Ur({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:S,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),Wr({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:l.fragments,documentIdentities:u.nextDocumentIdentities}));let y=performance.now()-n;n=performance.now(),b.completeIndexBytes&&an(e.candidateShardPath,b.completeIndexBytes),an(e.candidateAffectedScipPath,b.affectedIndexBytes);let I=performance.now()-n,w={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:Date.now()-t,cold:l.cold,changedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:u.previousFragmentGeneration,nextFragmentGeneration:u.nextFragmentGeneration,manifest:u.manifest,plan:u.plan,projectFileCount:a.length,referenceFragmentsByFile:new Map(l.fragments.map(Pe=>[Pe.relativePath,Pe.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:m,serviceMs:l.durationMs,assemblyMs:P,fragmentStoreMs:y,writeMs:I}};return e.onStatus(`Incremental TypeScript index emitted ${w.affectedFiles.length} affected document(s) in ${(w.durationMs/1e3).toFixed(3)}s (${w.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${P.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${I.toFixed(0)}ms).`),w}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 to(e){let t=rn();if(!t.available)throw new Error(t.reason);let n=ai({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:Zi(e.baseShardPath),packageVersion:t.packageVersion});an(e.candidateShardPath,n)}function Xi(e,t,n){let r=e.files.filter(i=>En(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return sn(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Qi(e,t){return sn(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Ki(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=An({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let u=a.identityFor(c,"typescript-scip-document-v1");if(u.key){s.set(c,u.key);continue}if(o.has(c))return null;s.set(c,sn(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function sn(e){return uu("sha256").update(e).digest("hex")}import{execFile as fu}from"child_process";import{existsSync as Ze,renameSync as un,rmSync as dn,statSync as mu}from"fs";import{cpus as hu}from"os";import{join as no}from"path";function yu(e,t,n){if(!e.defaultOutputPath)return;let r=no(t,e.defaultOutputPath);n!==r&&Ze(r)&&un(r,n)}function Su(e,t,n){if(!e.defaultOutputPath)return null;let r=no(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return dn(i,{force:!0}),Ze(r)?(un(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function bu(e){e&&(dn(e.defaultOutputPath,{force:!0}),e.backupPath&&Ze(e.backupPath)&&un(e.backupPath,e.defaultOutputPath))}function Ru(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,hu().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function ro(e,t,n,r){let i=e.filter(u=>u.config.defaultOutputPath),o=e.filter(u=>!u.config.defaultOutputPath),a=[],s=Ru(o.length,r),c=await vu(o,s,u=>cn(u,t,n));if(s>1){let u=new Map;for(let d of c.filter(p=>p.skipped)){let p=o.find(l=>l.id===d.id);p&&(n(`Retrying ${p.label} indexer serially after parallel failure...`),u.set(p.id,await cn(p,t,n)))}a.push(...c.map(d=>u.get(d.id)??d))}else a.push(...c);for(let u of i)a.push(await cn(u,t,n));return a.sort((u,d)=>e.findIndex(p=>p.id===u.id)-e.findIndex(p=>p.id===d.id))}async function cn(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),dn(e.scipPath,{force:!0});let r=Su(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),o=Date.now();try{let s=kn(e.binary,e.args);await xu(s.binary,s.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),yu(e.config,t,e.scipPath)}catch(s){let c=s instanceof Error?s.message:String(s),u=`${e.resolvedBinary} indexer failed: ${c.split(`
|
|
239
|
-
`)[0]}`,d=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,skipped:{language:e.language,reason:d}}}finally{bu(r)}if(!Ze(e.scipPath)){let s=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=e.label===e.language?s:`${e.label}: ${s}`;return n(`Skipping ${e.label}: ${s}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,skipped:{language:e.language,reason:c}}}let a;try{a=mu(e.scipPath).size}catch{a=void 0}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-o,command:i,outputBytes:a}}function xu(e,t,n){return new Promise((r,i)=>{fu(e,[...t],n,o=>{o?i(o):r()})})}async function vu(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),a=Array.from({length:o},async()=>{for(;i<e.length;){let s=i++;r[s]=await n(e[s])}});return await Promise.all(a),r}import{execFileSync as Iu}from"child_process";import{platform as Pu}from"os";function ln(e,t){let n=e.installMethods,r=ne(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(st(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{Iu(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Pu()==="win32"});let o=re(e);if(o){let a=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${r} via ${i.label}${a}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let a=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${a}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}import od from"better-sqlite3";import{existsSync as ad}from"fs";import{dirname as sd,join as cd,resolve as ud}from"path";import{readFileSync as ku,rmSync as Eu,statSync as Tu,mkdtempSync as Du}from"fs";import{tmpdir as Fu}from"os";import{join as pn}from"path";import{Worker as Ou}from"worker_threads";function wu(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function K(){return{skippedReferences:0,skippedReferenceReasons:wu(),skippedReferenceSamples:[]}}function et(e,t){e.skippedReferences+=t.skippedReferences;for(let n of Object.keys(e.skippedReferenceReasons)){e.skippedReferenceReasons[n]+=t.skippedReferenceReasons[n];for(let r of t.skippedReferenceSamples.filter(i=>i.reason===n))e.skippedReferenceSamples.filter(o=>o.reason===n&&o.sourceFile===r.sourceFile).length<2&&e.skippedReferenceSamples.push(r)}}function io(e){return e.length>=8&&ao(e.length)>1}function oo(e){let t=ao(e.vueFiles.length),n=Cu(e.vueFiles),r=_u(n,t),i=new URL("./augment-vue-worker.js",import.meta.url),o=Du(pn(Fu(),"scip-query-vue-workers-")),a=new SharedArrayBuffer(4),s=new Int32Array(a),c=ju(),u=Date.now();try{for(let l=0;l<r.length;l++)new Ou(i,{workerData:{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:r[l],resultPath:pn(o,`${l}.json`),sharedBuffer:a}});for(;Atomics.load(s,0)<r.length;){if(Date.now()-u>c)throw new Error(`Vue reference workers timed out after ${(c/1e3).toFixed(0)}s`);Atomics.wait(s,0,Atomics.load(s,0),100)}let d=r.map((l,m)=>{let g=JSON.parse(ku(pn(o,`${m}.json`),"utf-8"));if(!g.ok)throw new Error(`Vue reference worker failed: ${g.error}`);return g.result}),p={occurrences:d.flatMap(l=>l.occurrences),...K()};for(let l of d)et(p,l);return p}finally{Eu(o,{recursive:!0,force:!0})}}function ao(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function ju(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:3e5}function Cu(e){let t=Au(),n=[];for(let r of e){let i=so(r),o=Math.max(1,Math.ceil(i/t));for(let a=0;a<o;a++)n.push({fileName:r,startOffset:Math.floor(i*a/o),endOffset:a===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(a+1)/o),countFileSkip:a===0})}return n}function Au(){return Number.POSITIVE_INFINITY}function _u(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:Lu(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((a,s)=>s.weight<a.weight?s:a);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function Lu(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,so(e.fileName)-e.startOffset)}function so(e){try{return Tu(e).size}catch{return 1}}import{createRequire as Mu}from"module";import{existsSync as Nu,readFileSync as fn}from"fs";import{dirname as co,extname as $u,join as uo,relative as Gu,resolve as Vu}from"path";import{pathToFileURL as Bu}from"url";function Uu(e){e.transaction(()=>{e.prepare(`
|
|
230
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[d,l]of Object.entries({documents:i,chunks:o,definitions:a,mentions:s}))for(let p of l){let f=JSON.stringify([d,p]),g=c.get(p.relative_path)??[];g.push(f),c.set(p.relative_path,g)}let u=new Map;for(let[d,l]of[...c].sort(([p],[f])=>p.localeCompare(f))){let p=Vs("sha256");for(let f of l.sort())p.update(f).update(`
|
|
231
|
+
`);u.set(d,p.digest("hex"))}return u}function B(e,t){return e.prepare(t).get().value}import{readFileSync as rc,writeFileSync as ic}from"fs";function C(e,t){let n=performance.now(),r=e.run(t);return{stageId:e.id,facts:e.facts,durationMs:performance.now()-n,result:r}}function ti(e){let t=e.readFingerprint(),n=ri(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=e.compute();return ii(e.cachePath,e.readFingerprint(),r),r}async function ni(e){let t=e.readFingerprint(),n=ri(e.cachePath,t);if(n)return e.onCacheHit?.(n.result),n.result;let r=await e.compute();return ii(e.cachePath,e.readFingerprint(),r),r}function ri(e,t){try{let n=JSON.parse(rc(e,"utf-8"));return ei(n.fingerprint)===ei(t)?{result:n.result}:null}catch{return null}}function ii(e,t,n){ic(e,`${JSON.stringify({updatedAt:new Date().toISOString(),fingerprint:t,result:n},null,2)}
|
|
232
|
+
`)}function ei(e){return JSON.stringify(e)}import{createHash as oc}from"crypto";import{existsSync as Qt,readFileSync as ac,readdirSync as sc}from"fs";import{dirname as Kt,join as Je,relative as cc,resolve as Zt,sep as oi}from"path";function ai(e,t){let n=t.includes("."),r={};for(let o of t)r[o]=[];let i=[];for(let o of e){let a=di(o.path,t);a?r[a].push(o):n?r["."].push(o):i.push(o)}return{files:r,shared:i}}function si(e,t){let n=new Map;for(let i of e){let o=t[i]?.packageName;o&&n.set(o,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let o=t[i],a=r.get(i);if(!o||o.parseFailed){for(let s of e)s!==i&&a.add(s);continue}for(let s of o.dependencyNames){let c=n.get(s);c&&c!==i&&a.add(c)}for(let s of[...o.pathsTargets,...o.referencesPaths]){let c=di(s,e);c&&c!==i&&a.add(c)}}return uc(e,r)}function ci(e,t,n){let r={};for(let i of e){let o=new Map;for(let a of t.files[i]??[])o.set(a.path,a);for(let a of n[i]??[])for(let s of t.files[a]??[])o.set(s.path,s);for(let a of t.shared)o.set(a.path,a);r[i]={files:[...o.values()].sort((a,s)=>a.path.localeCompare(s.path))}}return r}function en(e){if(e===".")return"root";let t=oc("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function ui(e,t){let n=Zt(e),r={};for(let i of t)r[i]=dc(n,i);return r}function di(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 uc(e,t){let n={};for(let r of e){let i=new Set,o=[...t.get(r)??[]];for(;o.length>0;){let a=o.pop();if(!(a===r||i.has(a))){i.add(a);for(let s of t.get(a)??[])s!==r&&!i.has(s)&&o.push(s)}}n[r]=[...i].sort((a,s)=>a.localeCompare(s))}return n}function dc(e,t){let n=t==="."?e:Je(e,t),r=lc(n),i=pc(n),o=i?gc(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:o.pathsTargets,referencesPaths:o.referencesPaths,parseFailed:r.failed||o.failed}}function lc(e){let t=Je(e,"package.json");if(!Qt(t))return{name:void 0,dependencyNames:[],failed:!1};let n=tn(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 o of["dependencies","devDependencies","peerDependencies"]){let a=n.value[o];if(a&&typeof a=="object"&&!Array.isArray(a))for(let s of Object.keys(a))i.add(s)}return{name:r,dependencyNames:[...i],failed:!1}}function pc(e){let t=Je(e,"tsconfig.json");if(Qt(t))return t;let n;try{n=sc(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?Je(e,n[0]):void 0}function gc(e,t){let n=tn(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=fc(n.value,e,t),i=li(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function fc(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=Kt(t),o=new Set;for(let a of r){if(!a||typeof a!="object")continue;let s=a.path;if(typeof s!="string"||s.trim()==="")continue;let c=pi(s,i,n);c&&o.add(c)}return[...o]}function li(e,t,n,r){let i=mc(t);if(i)return{pathsTargets:hc(i,Kt(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let o=yc(t.extends,e,n);if(!o)return{pathsTargets:[],failed:!1};let a=tn(o);return a.ok?li(o,a.value,n,r+1):{pathsTargets:[],failed:!0}}function mc(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 hc(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let o of i){if(typeof o!="string")continue;let a=pi(o,t,n);a&&r.add(a)}return[...r]}function yc(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=Zt(Kt(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(oi).includes("node_modules")&&ge(n,i)&&Qt(i))return i}function pi(e,t,n){let r=e.replace(/\/?\*+$/,""),i=Zt(t,r===""?".":r);if(!ge(n,i))return;let a=cc(n,i).split(oi).join("/");return a===""?".":a}function Sc(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let o=e[n];if(r){if(t+=o,o==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}o==='"'&&(r=!1),n+=1;continue}if(o==='"'){r=!0,t+=o,n+=1;continue}if(o==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
233
|
+
`;)n+=1;continue}if(o==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=o,n+=1}return t}function tn(e){try{let t=ac(e,"utf-8"),n=JSON.parse(Sc(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{createHash as no,randomUUID as nu}from"crypto";import{constants as ru,copyFileSync as Ki,existsSync as H,lstatSync as iu,mkdirSync as J,mkdtempSync as ro,readdirSync as ou,readFileSync as z,realpathSync as au,renameSync as Z,rmSync as q,statSync as su}from"fs";import{dirname as io,join as h,resolve as Fe}from"path";import{setTimeout as cu}from"timers/promises";import{pathToFileURL as Zi}from"url";import{deserializeSCIP as oo}from"@c4312/scip";import uu from"better-sqlite3";import{createRequire as bc}from"module";var Rc=bc(import.meta.url),gi=xc().version;function xc(){for(let e of["../package.json","../../package.json"])try{return Rc(e)}catch{}return{version:"0.0.0"}}import{lstatSync as Mc,readdirSync as Lc}from"fs";import{join as Nc,relative as $c,resolve as ln,sep as Vc}from"path";import{createHash as Ic}from"crypto";import{existsSync as rn,mkdirSync as vc,readFileSync as Ye,readdirSync as Rg,renameSync as Pc,rmSync as xg,writeFileSync as wc}from"fs";import{join as ae}from"path";import{create as mi,fromBinary as hi,toBinary as kc}from"@bufbuild/protobuf";import{deserializeSCIP as Xe,DocumentSchema as on,IndexSchema as yi,serializeSCIP as Si}from"@c4312/scip";var Qe=1,xe="typescript-scip-fragments";function bi(e){if(e.length===0)throw new Error("affected TypeScript mini index requires documents");let t=new Set,n=[];for(let o of e){let a=Q(o.relativePath);if(t.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(t.add(a),o.bytes===null)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${a}`);let s=hi(on,o.bytes);if(s.relativePath!==a)throw new Error(`TypeScript fragment path mismatch: expected ${a}, got ${s.relativePath}`);n.push(s)}let r=Si(mi(yi,{documents:n,externalSymbols:[]})),i=Xe(r);if(i.documents.length!==n.length||i.externalSymbols.length!==0)throw new Error("affected TypeScript SCIP index failed structural verification");return r}function Ke(e){let t=ae(e,xe);return{rootDir:t,blobDir:ae(t,"blobs"),generationDir:ae(t,"generations")}}function Ec(e){let t=Xe(e.indexBytes);Ai(t.metadata,Oi(e)),Di(t.externalSymbols);let n=new Set,r=[];for(let o of t.documents){let a=Q(o.relativePath);if(n.has(a))throw new Error(`duplicate TypeScript SCIP document path: ${a}`);n.add(a);let s=kc(on,o),c=e.documentIdentities.get(a)??(e.allowUntrackedDocuments?K(JSON.stringify({version:1,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,untrackedDocument:a,contentHash:K(s)})):null);if(!c)throw new Error(`missing TypeScript document identity: ${a}`);r.push(ki(e.cacheDir,{relativePath:a,bytes:s,occurrences:o.occurrences.length,symbols:o.symbols.length,referenceFragments:[]},c))}let i=Ei(e,r);return Ti(e.cacheDir,i),i}function Ri(e){let t=Ke(e.cacheDir);if(!rn(an(t,e.generationIdentity)))return Ec(e);let n=Ii({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity});if(!e.allowUntrackedDocuments&&n.manifest.documents.length!==e.documentIdentities.size)throw new Error("TypeScript fragment generation document identities changed");for(let r of n.manifest.documents){let i=e.documentIdentities.get(r.relativePath);if(!(i===void 0&&e.allowUntrackedDocuments)&&i!==r.documentIdentity)throw new Error(`TypeScript fragment generation document identity changed: ${r.relativePath}`)}return n.manifest}function xi(e){let t=Ii({cacheDir:e.cacheDir,generationIdentity:e.previousGenerationIdentity,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity}).manifest,n=new Map(t.documents.map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=Q(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript fragment replacement: ${a}`);if(r.add(a),!n.has(a))throw new Error(`TypeScript fragment replacement has no prior document: ${a}`);let s=e.documentIdentities.get(a);if(!s)throw new Error(`missing TypeScript document identity: ${a}`);o.bytes===null?n.delete(a):n.set(a,ki(e.cacheDir,o,s))}if(r.size===0)throw new Error("TypeScript fragment generation requires at least one replacement");let i=Ei(e,[...n.values()]);return Ti(e.cacheDir,i),i}function Ii(e){let t=Ke(e.cacheDir),n=an(t,e.generationIdentity),r;try{r=Fi(Ye(n,"utf8"))}catch(o){throw new Error(`TypeScript fragment generation is unavailable: ${o instanceof Error?o.message:String(o)}`,{cause:o})}if(r.generationIdentity!==e.generationIdentity)throw new Error("TypeScript fragment generation identity does not match its manifest path");if(e.producerIdentity&&r.producerIdentity!==e.producerIdentity)throw new Error("TypeScript fragment producer identity changed");if(e.projectIdentity&&r.projectIdentity!==e.projectIdentity)throw new Error("TypeScript fragment project identity changed");let i=new Map;for(let o of r.documents){let a=ae(t.blobDir,`${o.blobHash}.scipdoc`),s=Ye(a);if(s.byteLength!==o.byteLength||K(s)!==o.blobHash)throw new Error(`TypeScript fragment blob is corrupt: ${o.relativePath}`);i.set(o.relativePath,s)}return{manifest:r,fragments:i}}function vi(e){let t=wi(e);return nn(t.baseIndex,t.completeDocuments,"assembled")}function Pi(e){let t=wi(e);return Tc(t.deletedAffectedPaths),{completeIndexBytes:nn(t.baseIndex,t.completeDocuments,"assembled"),affectedIndexBytes:nn(t.baseIndex,t.affectedDocuments,"affected")}}function wi(e){let t=Xe(e.baseIndexBytes);Ai(t.metadata,Oi(e)),Di(t.externalSymbols);let n=new Map;for(let s of e.fragments){let c=Q(s.relativePath);if(n.has(c))throw new Error(`duplicate TypeScript fragment replacement: ${c}`);n.set(c,s)}if(n.size===0)throw new Error("TypeScript index assembly requires at least one replacement");let r=new Set,i=[],o=[],a=[];for(let s of t.documents){let c=Q(s.relativePath);if(r.has(c))throw new Error(`duplicate TypeScript SCIP document path: ${c}`);r.add(c);let u=n.get(c);if(!u){i.push(s);continue}if(n.delete(c),u.bytes===null){a.push(c);continue}let d=hi(on,u.bytes);if(d.relativePath!==c)throw new Error(`TypeScript fragment path mismatch: expected ${c}, got ${d.relativePath}`);i.push(d),o.push(d)}if(n.size>0)throw new Error(`TypeScript fragment replacement has no prior document: ${[...n.keys()].sort()[0]}`);return{baseIndex:t,completeDocuments:i,affectedDocuments:o,deletedAffectedPaths:a}}function nn(e,t,n){let r=Si(mi(yi,{metadata:e.metadata,documents:t,externalSymbols:[]})),i=Xe(r);if(i.documents.length!==t.length||i.externalSymbols.length!==0)throw new Error(`${n} TypeScript SCIP index failed structural verification`);return r}function Tc(e){if(e.length>0)throw new Error(`affected TypeScript mini index cannot contain a deleted document: ${e[0]}`)}function ki(e,t,n){if(t.bytes===null)throw new Error(`cannot persist an empty TypeScript fragment: ${t.relativePath}`);let r=Q(t.relativePath),i=Buffer.from(t.bytes),o=K(i),a=Ke(e);vc(a.blobDir,{recursive:!0});let s=ae(a.blobDir,`${o}.scipdoc`);if(rn(s)){let c=Ye(s);if(c.byteLength!==i.byteLength||K(c)!==o)throw new Error(`existing TypeScript fragment blob is corrupt: ${r}`)}else{let c=`${s}.${process.pid}.${Date.now()}.tmp`;wc(c,i),Pc(c,s)}return{relativePath:r,blobHash:o,byteLength:i.byteLength,documentIdentity:n}}function Ei(e,t){if(!e.producerIdentity||!e.projectIdentity||!e.generationIdentity)throw new Error("TypeScript fragment generation identities must be non-empty");let n=[...t].sort((r,i)=>r.relativePath.localeCompare(i.relativePath));if(new Set(n.map(r=>r.relativePath)).size!==n.length)throw new Error("TypeScript fragment generation contains duplicate document paths");return{version:Qe,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),documents:n}}function Ti(e,t){let n=Ke(e),r=an(n,t.generationIdentity);if(rn(r)){let i=Fi(Ye(r,"utf8"));if(fi(i)!==fi(t))throw new Error(`TypeScript fragment generation is immutable: ${t.generationIdentity}`);return}ie(r,t,{spacing:2,trailingNewline:!0})}function fi(e){return K(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,generationIdentity:e.generationIdentity,documents:e.documents}))}function Fi(e){let t=JSON.parse(e);if(t.version!==Qe||typeof t.producerIdentity!="string"||typeof t.projectIdentity!="string"||typeof t.generationIdentity!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.documents))throw new Error("invalid TypeScript fragment generation manifest");let n=new Set;for(let r of t.documents){if(!r||typeof r.relativePath!="string"||typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash)||typeof r.byteLength!="number"||!Number.isInteger(r.byteLength)||r.byteLength<0||typeof r.documentIdentity!="string"||!r.documentIdentity)throw new Error("invalid TypeScript fragment record");if(Q(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript fragment record");n.add(r.relativePath)}return t}function an(e,t){return ae(e.generationDir,Fc(t))}function Fc(e){if(!e)throw new Error("TypeScript fragment generation identity must be non-empty");return`${K(e)}.json`}function Di(e){if(e.length>0)throw new Error("scip-typescript emitted external symbols; incremental document assembly is unsupported")}function Ai(e,t){if(!e||typeof e!="object")throw new Error("TypeScript SCIP shard has no producer metadata");let n=e,r=n.toolInfo??n.tool_info;if(!r||typeof r!="object")throw new Error("TypeScript SCIP shard has no producer tool identity");let i=r;if(i.name!=="scip-typescript"||i.version!==t)throw new Error("TypeScript SCIP shard producer identity changed")}function Oi(e){let t=e.packageVersion??e.runtime?.packageVersion;if(!t)throw new Error("scip-typescript package version is unavailable");return t}function Q(e){if(!e||e.startsWith("/")||e.startsWith("\\")||e.includes("\\"))throw new Error(`invalid TypeScript SCIP document path: ${e}`);let t=e.split("/");if(t.includes("")||t.includes(".")||t.includes(".."))throw new Error(`invalid TypeScript SCIP document path: ${e}`);return e}function K(e){return Ic("sha256").update(e).digest("hex")}import{createHash as Dc}from"crypto";import{existsSync as Ie,mkdirSync as Ac,readFileSync as Pe,readdirSync as sn,renameSync as Oc,rmSync as ji,writeFileSync as jc}from"fs";import{join as D}from"path";var Ze=1,Ci=64*1024*1024,we="typescript-scip-overlays";function Mi(e){let t=$i(e.cacheDir,e.previousGenerationIdentity);if(!t&&!e.baseShardCurrent)throw new Error("deferred TypeScript SCIP base has no matching overlay generation");if(t&&(t.producerIdentity!==e.producerIdentity||t.projectIdentity!==e.projectIdentity))throw new Error("TypeScript overlay producer or project identity changed");let n=new Map((t?.overlays??[]).map(o=>[o.relativePath,o])),r=new Set;for(let o of e.fragments){let a=dn(o.relativePath);if(r.has(a))throw new Error(`duplicate TypeScript overlay: ${a}`);r.add(a),n.set(a,_c(e.cacheDir,o))}if(r.size===0)throw new Error("TypeScript overlay generation requires affected documents");let i={version:Ze,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:t?.baseGenerationIdentity??e.previousGenerationIdentity,generationIdentity:e.nextGenerationIdentity,createdAt:(e.now??(()=>new Date))().toISOString(),overlays:[...n.values()].sort((o,a)=>o.relativePath.localeCompare(a.relativePath))};return Cc(e.cacheDir,i),i}function Li(e){let t=$i(e.cacheDir,e.generationIdentity);if(!t)throw new Error("TypeScript overlay generation is unavailable");let n=t.overlays.map(r=>{if(r.blobHash===null)return{relativePath:r.relativePath,bytes:null,occurrences:0,symbols:0,referenceFragments:[]};let i=Pe(D(ke(e.cacheDir),"blobs",`${r.blobHash}.scipdoc`));if(i.byteLength!==r.byteLength||ve(i)!==r.blobHash)throw new Error(`TypeScript overlay blob is corrupt: ${r.relativePath}`);return{relativePath:r.relativePath,bytes:i,occurrences:0,symbols:0,referenceFragments:[]}});return vi({packageVersion:e.packageVersion,baseIndexBytes:e.baseIndexBytes,fragments:n})}function Ni(e,t){let n=ke(e),r=D(n,"generations");if(!Ie(r))return;let i=new Set(t.map(un)),o=new Set;for(let s of sn(r).filter(c=>i.has(c))){let c=cn(Pe(D(r,s),"utf8"));for(let u of c.overlays)u.blobHash&&o.add(`${u.blobHash}.scipdoc`)}for(let s of sn(r))i.has(s)||ji(D(r,s),{force:!0});let a=D(n,"blobs");if(Ie(a))for(let s of sn(a))o.has(s)||ji(D(a,s),{force:!0})}function $i(e,t){let n=D(ke(e),"generations",un(t));if(!Ie(n))return null;let r=cn(Pe(n,"utf8"));if(r.generationIdentity!==t)throw new Error("TypeScript overlay generation identity does not match its path");return r}function _c(e,t){let n=dn(t.relativePath);if(t.bytes===null)return{relativePath:n,blobHash:null,byteLength:0};let r=Buffer.from(t.bytes),i=ve(r),o=D(ke(e),"blobs");Ac(o,{recursive:!0});let a=D(o,`${i}.scipdoc`);if(Ie(a)){let s=Pe(a);if(s.byteLength!==r.byteLength||ve(s)!==i)throw new Error(`existing TypeScript overlay blob is corrupt: ${n}`)}else{let s=`${a}.${process.pid}.${Date.now()}.tmp`;jc(s,r),Oc(s,a)}return{relativePath:n,blobHash:i,byteLength:r.byteLength}}function Cc(e,t){let n=D(ke(e),"generations",un(t.generationIdentity));if(Ie(n)){let r=cn(Pe(n,"utf8"));if(_i(r)!==_i(t))throw new Error(`TypeScript overlay generation is immutable: ${t.generationIdentity}`);return}ie(n,t,{spacing:2,trailingNewline:!0})}function cn(e){let t=JSON.parse(e);if(t.version!==Ze||typeof t.producerIdentity!="string"||!t.producerIdentity||typeof t.projectIdentity!="string"||!t.projectIdentity||typeof t.baseGenerationIdentity!="string"||!t.baseGenerationIdentity||typeof t.generationIdentity!="string"||!t.generationIdentity||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!Array.isArray(t.overlays))throw new Error("invalid TypeScript overlay manifest");let n=new Set;for(let r of t.overlays){if(!r||typeof r.relativePath!="string"||r.blobHash!==null&&(typeof r.blobHash!="string"||!/^[a-f0-9]{64}$/.test(r.blobHash))||!Number.isInteger(r.byteLength)||r.byteLength<0||r.blobHash===null&&r.byteLength!==0)throw new Error("invalid TypeScript overlay record");if(dn(r.relativePath),n.has(r.relativePath))throw new Error("duplicate TypeScript overlay record");n.add(r.relativePath)}return t}function ke(e){return D(e,we)}function un(e){if(!e)throw new Error("TypeScript overlay generation identity must be non-empty");return`${ve(e)}.json`}function _i(e){return ve(JSON.stringify({version:e.version,producerIdentity:e.producerIdentity,projectIdentity:e.projectIdentity,baseGenerationIdentity:e.baseGenerationIdentity,generationIdentity:e.generationIdentity,overlays:e.overlays}))}function dn(e){if(!e||e.startsWith("/")||e.includes("\\")||e.split("/").some(t=>!t||t==="."))throw new Error(`invalid TypeScript overlay path: ${e}`);if(e.split("/").includes(".."))throw new Error(`invalid TypeScript overlay path: ${e}`);return e}function ve(e){return Dc("sha256").update(e).digest("hex")}var Ee=1,pn="language-indexes",Vi=["index.db","index.scip","meta.json"],Gi=[pn,xe,we];function et(e){let t=[];for(let n of Vi)Gc(e,n),t.push(n);for(let n of Gi)Ui(e,n,t);return{version:Ee,files:t.sort()}}function tt(e){if(!e||e.includes("\0")||e.startsWith("/")||e.includes("\\"))throw new Error(`invalid index artifact path: ${e||"<empty>"}`);let t=e.split("/");if(t.some(r=>!r||r==="."||r===".."))throw new Error(`invalid index artifact path: ${e}`);let n=t[0];if(!Vi.includes(e)&&!Gi.includes(n))throw new Error(`index artifact path is not shareable: ${e}`);return e}function O(e,t){let n=tt(t),r=ln(e),i=ln(r,...n.split("/"));if(i!==r&&!i.startsWith(`${r}${Vc}`))throw new Error(`index artifact escapes cache: ${t}`);return i}function Ui(e,t,n){let r=Nc(e,t),i;try{i=Lc(r,{withFileTypes:!0,encoding:"utf8"})}catch{return}for(let o of i){let a=`${t}/${o.name}`;if(o.isSymbolicLink())throw new Error(`index artifact cannot be a symlink: ${a}`);o.isDirectory()?Ui(e,a,n):o.isFile()&&n.push(tt(a))}}function Gc(e,t){let n=O(e,t),r;try{r=Mc(n)}catch{throw new Error(`required index artifact is missing: ${t}`)}if(!r.isFile()||r.isSymbolicLink())throw new Error(`required index artifact is not a regular file: ${t}`);if($c(ln(e),n).startsWith(".."))throw new Error(`index artifact escapes cache: ${t}`)}import{createHash as yn}from"crypto";import{closeSync as Hi,chmodSync as Uc,copyFileSync as Bc,constants as Wc,existsSync as I,fsyncSync as qc,mkdirSync as Bi,openSync as zi,readFileSync as se,readSync as Hc,readdirSync as zc,renameSync as hn,rmSync as nt,statSync as rt}from"fs";import{basename as Ji,dirname as j,join as R,relative as Wi}from"path";function ot(e){let t=_(e.outputDb),n=Yc(e);e.onStage?.("after-recovery-retained");let r=e.preserveOutputScip?e.outputScip:e.tempOutputScip,i=Rn({generationRoot:t,databasePath:e.tempOutputDb,indexPath:I(r)?r:void 0,metadataPath:I(e.tempMetaPath)?e.tempMetaPath:void 0}),o=(e.now??(()=>new Date))().toISOString(),a={version:ee,currentGeneration:i.identity,artifactSet:"immutable-v1",...n?{previousGeneration:n}:{},...e.publication?{publication:e.publication}:{},publishedAt:o};F(R(t,"state.json"),a,{spacing:2,trailingNewline:!0}),e.onStage?.("after-pointer-handoff"),e.preserveOutputScip||mn(e.tempOutputScip,e.outputScip),e.onStage?.("after-scip-handoff"),mn(e.tempOutputDb,e.outputDb),e.onStage?.("after-database-handoff"),mn(e.tempMetaPath,e.metaPath),e.onStage?.("after-metadata-handoff");let s=i.identity,c={...a,stableMirrors:bn(e.outputDb,e.outputScip)};return F(R(t,"state.json"),c,{spacing:2,trailingNewline:!0}),{currentGeneration:s,...n?{previousGeneration:n}:{}}}function Sn(e,t,n,r=()=>new Date){if(!I(e))return null;let i=Ve(e),o=R(_(e),"state.json");if(i?.artifactSet==="immutable-v1"&&xt(e,i.currentGeneration))return i;let a=_(e),s=!i&&I(o)?Qc(n,e,t):void 0;if(s&&!It(a,s))return null;let c=Rn({generationRoot:a,databasePath:e,indexPath:I(t)?t:void 0,metadataPath:I(n)?n:void 0,forcedIdentity:i?.currentGeneration??s}),u={version:ee,currentGeneration:c.identity,artifactSet:"immutable-v1",stableMirrors:bn(e,t),...i?.previousGeneration?{previousGeneration:i.previousGeneration}:{},...i?.publication?{publication:i.publication}:{},publishedAt:i?.publishedAt??r().toISOString()};return F(R(a,"state.json"),u,{spacing:2,trailingNewline:!0}),u}function Yi(e,t,n=()=>new Date){if(!I(e)||!I(t))throw new Error("metadata-only generation refresh requires stable database and metadata files");let r=Ve(e),i=_(e),o=Rn({generationRoot:i,databasePath:e,indexPath:I(R(j(e),"index.scip"))?R(j(e),"index.scip"):void 0,metadataPath:t}),a=r&&r.currentGeneration!==o.identity?Xi(e,r.currentGeneration):void 0,s={version:ee,currentGeneration:o.identity,artifactSet:"immutable-v1",stableMirrors:bn(e,R(j(e),"index.scip")),...a?{previousGeneration:a}:{},...r?.publication?{publication:r.publication}:{},publishedAt:n().toISOString()};return F(R(_(e),"state.json"),s,{spacing:2,trailingNewline:!0}),s}function W(e,t=R(j(e),"meta.json")){let n=R(_(e),"state.json");if(!I(n))return{state:"legacy",statePath:n};let r=Ve(e);if(!r)return{state:"invalid",statePath:n,reason:"generation state is malformed"};try{let i=xt(e,r.currentGeneration),o=i!==null,a=i?Jc(e,t,i,r):!1,s=r.previousGeneration?I(R(j(e),r.previousGeneration.databasePath)):!0;return!a||!o||!s?{state:"drifted",statePath:n,currentMatches:a,recoveryExists:s,generation:r,reason:o?a?"retained recovery database is missing":"stable database or metadata no longer matches the published generation":"published immutable generation is missing"}:{state:"current",statePath:n,currentMatches:a,recoveryExists:s,generation:r}}catch(i){return{state:"drifted",statePath:n,currentMatches:!1,recoveryExists:!1,generation:r,reason:i instanceof Error?i.message:String(i)}}}function Jc(e,t,n,r){if(r.stableMirrors&&(r.stableMirrors.databaseFileIdentity!==pe(e)||r.stableMirrors.indexFileIdentity!==void 0&&r.stableMirrors.indexFileIdentity!==pe(R(j(e),"index.scip")))||!qi(e,n.database))return!1;let i=R(j(e),"index.scip");if(n.index&&!qi(i,n.index))return!1;if(!n.metadata)return!I(t);if(!I(t))return!1;let o=R(_(e),n.identity,n.metadata.file);return I(o)&&Y(se(t,"utf8"))===Y(se(o,"utf8"))}function qi(e,t){return I(e)&&rt(e).isFile()&&rt(e).size===t.size}function Yc(e){let t=Sn(e.outputDb,e.outputScip,e.metaPath);return t?Xi(e.outputDb,t.currentGeneration):void 0}function bn(e,t){return{databaseFileIdentity:pe(e),...I(t)?{indexFileIdentity:pe(t)}:{}}}function Xi(e,t){let n=R(_(e),t),r=R(n,Ji(e)),i=R(n,"meta.json");return{generationIdentity:t,databasePath:Wi(j(e),r),...I(i)?{metadataPath:Wi(j(e),i)}:{}}}function Xc(e){if(I(e))for(let t of zc(e,{withFileTypes:!0}))t.isDirectory()&&t.name.endsWith(".tmp")&&nt(R(e,t.name),{recursive:!0,force:!0})}function Qc(e,t,n=R(j(t),"index.scip")){let r=yn("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(it(t)),I(n)&&r.update(`\0${it(n)}`),I(e)&&r.update(`\0${Y(se(e,"utf8"))}`),r.digest("hex")}function Rn(e){let t=gn(e.databasePath),n=e.indexPath?gn(e.indexPath):void 0,r=e.metadataPath?gn(e.metadataPath):void 0,i=e.forcedIdentity??Kc(t,n,e.metadataPath),o=R(e.generationRoot,i),a=R(o,Rt);if(I(a)){let c=It(e.generationRoot,i);if(c&&Qi(o,c.database,t)&&eu(o,c.index,n)&&tu(o,c.metadata,e.metadataPath))return{identity:i};throw new Error(`SQLite generation ${i} already exists with different or corrupt artifacts.`)}Bi(e.generationRoot,{recursive:!0}),Xc(e.generationRoot);let s=`${o}.${process.pid}.${Date.now()}.tmp`;nt(s,{recursive:!0,force:!0}),Bi(s,{recursive:!0});try{fn(e.databasePath,R(s,t.file)),n&&e.indexPath&&fn(e.indexPath,R(s,n.file)),r&&e.metadataPath&&fn(e.metadataPath,R(s,r.file)),F(R(s,Rt),{version:Zn,identity:i,database:t,...n?{index:n}:{},...r?{metadata:r}:{}},{spacing:2,trailingNewline:!0}),hn(s,o),ir(e.generationRoot)}finally{nt(s,{recursive:!0,force:!0})}return{identity:i}}function Kc(e,t,n){let r=yn("sha256").update("sqlite-generation-artifacts-v1\0");return r.update(e.sha256),t&&r.update(`\0${t.sha256}`),n&&r.update(`\0${Y(se(n,"utf8"))}`),r.digest("hex")}function gn(e){return{file:Ji(e),size:rt(e).size,sha256:it(e)}}function it(e){let t=yn("sha256"),n=zi(e,"r"),r=Buffer.allocUnsafe(1024*1024);try{for(;;){let i=Zc(n,r);if(i===0)break;t.update(r.subarray(0,i))}}finally{Hi(n)}return t.digest("hex")}function Zc(e,t){let n=0;for(;n<t.length;){let r=Hc(e,t,n,t.length-n,null);if(n+=r,r===0)break}return n}function fn(e,t){Bc(e,t,Wc.COPYFILE_FICLONE);let n=zi(t,"r");try{qc(n)}finally{Hi(n)}Uc(t,292)}function Qi(e,t,n){let r=R(e,t.file);return t.file===n.file&&t.size===n.size&&t.sha256===n.sha256&&I(r)&&rt(r).size===t.size&&it(r)===t.sha256}function eu(e,t,n){return!t||!n?t===n:Qi(e,t,n)}function tu(e,t,n){if(!t||!n)return t===void 0&&n===void 0;let r=R(e,t.file);return I(r)&&Y(se(r,"utf8"))===Y(se(n,"utf8"))}function mn(e,t){nt(`${t}.tmp-replace`,{force:!0}),hn(e,`${t}.tmp-replace`),hn(`${t}.tmp-replace`,t)}var In=1,eo="SCIP_QUERY_SHARED_CACHE",xn=JSON.stringify({cliVersion:gi,artifactCatalogVersion:Ee,sqliteGenerationStoreVersion:ee,typescriptFragmentStoreVersion:Qe,typescriptOverlayStoreVersion:Ze}),ao="manifest.json",du="shared-cache.json",vn=[pn,xe,we];function at(e,t){if(!e.clean||!e.treeOid)return;let n=Ae(JSON.stringify({version:In,repositoryId:e.repositoryId,treeOid:e.treeOid,fingerprint:t,producerIdentity:xn}));return{repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,fingerprint:t,producerIdentity:xn,generationId:n,repositoryCacheDir:br(e.repositoryId)}}function so(e,t,n){if(process.env[eo]==="0")return`${eo}=0`;if(!Rr(n))return"explicit cache or database override";if(Fe(t)!==Fe(h(Sr(e),"index.db")))return"index database is outside the managed worktree cache"}function M(e,t=!0){let n=wn(e),r;try{r=pu(z(h(n,ao),"utf8"))}catch{return null}if(r.generationId!==e.generationId||r.repositoryId!==e.repositoryId||r.treeOid!==e.treeOid||r.producerIdentity!==e.producerIdentity||JSON.stringify(r.fingerprint)!==JSON.stringify(e.fingerprint))return null;if(!t)return r;try{for(let i of r.artifacts){let o=O(n,i.path),a=su(o);if(!a.isFile()||a.size!==i.size||Ae(z(o))!==i.sha256)return null}}catch{return null}return r}function co(e){let t=M(e.snapshot);if(t)return t;if(!po(e.sourceCacheDir,e.sourceProjectRoot,e.snapshot.fingerprint))throw new Error("source index is incomplete, incompatible, or corrupt");let n=to(e.sourceCacheDir);if(!n)throw new Error("source index artifacts are incomplete");let r=et(e.sourceCacheDir),i=h(e.snapshot.repositoryCacheDir,"generations");J(i,{recursive:!0});let o=ro(h(i,`.tmp-${process.pid}-`));try{let a=[];for(let l of r.files){let p=O(e.sourceCacheDir,l),f=O(o,l);De(p,f);let g=z(f);a.push({path:l,size:g.byteLength,sha256:Ae(g)})}let s=oo(z(h(o,"index.scip"))).metadata?.projectRoot;if(!s)throw new Error("shared SCIP generation has no project root metadata");let c=kn(e.sourceProjectRoot);if(s!==c)throw new Error("shared SCIP generation root does not match its source worktree");if(to(e.sourceCacheDir)!==n||e.sourceStillValid&&!e.sourceStillValid())throw new Error("source index changed while staging a shared generation");let u={version:In,artifactCatalogVersion:Ee,generationId:e.snapshot.generationId,repositoryId:e.snapshot.repositoryId,treeOid:e.snapshot.treeOid,fingerprint:e.snapshot.fingerprint,producerIdentity:e.snapshot.producerIdentity,sourceProjectRoot:e.sourceProjectRoot,scipProjectRoot:s,createdAt:(e.now??(()=>new Date))().toISOString(),artifacts:a.sort((l,p)=>l.path.localeCompare(p.path))};F(h(o,ao),u,{spacing:2,trailingNewline:!0});let d=wn(e.snapshot);try{if(H(d)&&!M(e.snapshot)){let l=`${d}.corrupt-${process.pid}-${Date.now()}`;Z(d,l),q(l,{recursive:!0,force:!0})}Z(o,d)}catch(l){let p=M(e.snapshot);if(p)return p;throw l}return u}finally{q(o,{recursive:!0,force:!0})}}function Pn(e){let t=wn(e.snapshot);J(e.targetCacheDir,{recursive:!0});let n=be(h(e.targetCacheDir,"cache-lifecycle.lock"),{waitMs:3e4});if(!n)throw new Error("timed out waiting for another cache hydration");let r,i,o=!1;try{r=ro(h(e.targetCacheDir,".shared-hydrate-")),bu(e.manifest,e.snapshot);for(let c of e.manifest.artifacts){let u=O(t,c.path),d=O(r,c.path);De(u,d);let l=z(d);if(l.byteLength!==c.size||Ae(l)!==c.sha256)throw new Error(`shared artifact is corrupt: ${c.path}`)}let a=kn(e.targetProjectRoot);if(a!==e.manifest.scipProjectRoot)for(let c of e.manifest.artifacts)c.path.endsWith(".scip")&&qr(O(r,c.path),e.manifest.scipProjectRoot,a);if(!po(r,e.targetProjectRoot,e.snapshot.fingerprint,!1))throw new Error("staged shared generation failed completeness or integrity validation");i=hu(e.targetCacheDir,r),o=!0,yu(r,e.targetCacheDir,i),ot({tempOutputScip:h(r,"index.scip"),tempOutputDb:h(r,"index.db"),tempMetaPath:h(r,"meta.json"),outputScip:h(e.targetCacheDir,"index.scip"),outputDb:h(e.targetCacheDir,"index.db"),metaPath:h(e.targetCacheDir,"meta.json"),now:e.now});let s=W(h(e.targetCacheDir,"index.db"),h(e.targetCacheDir,"meta.json"));if(s.state==="invalid"||s.state==="drifted")throw new Error(`hydrated SQLite generation failed validation: ${s.reason}`);st(e.snapshot,e.targetCacheDir,e.action??"attached",e.now)}catch(a){throw o&&i&&Su(e.targetCacheDir,i),a}finally{r&&q(r,{recursive:!0,force:!0}),n.release()}}async function uo(e,t={}){let n=t.timeoutMs??3e4,r=t.pollMs??100,i=t.now??y,o=i()+n,a=h(e.repositoryCacheDir,"locks"),s=h(a,`${e.generationId}.lock`),c=u=>{if(!u||typeof u!="object"||Array.isArray(u))return null;let d=u.pid;return typeof d=="number"&&Number.isSafeInteger(d)&&d>0?{pid:d}:null};for(;i()<=o;){if(M(e))return{kind:"generation-ready"};let u=oe(s,{kind:"shared-generation-build",detail:{generationId:e.generationId},parseLegacy:c});if(u.kind==="acquired")return{kind:"owner",release:()=>u.lock.release()};let d=o-i();if(d<=0)break;await cu(Math.min(r,d))}return M(e)?{kind:"generation-ready"}:{kind:"timeout"}}function st(e,t,n,r=void 0){let i={version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:e.projectRoot,treeOid:e.treeOid,localCacheDir:t,baseGenerationId:e.generationId,activeGenerationId:e.generationId,lastAction:n,lastSeenAt:(r??(()=>new Date))().toISOString()},o={...i,ownershipChecksum:lu(i)};return mu(e.repositoryCacheDir,o,!0),o}function lu(e){return Ae(JSON.stringify({version:1,repositoryId:e.repositoryId,worktreeId:e.worktreeId,projectRoot:Fe(e.projectRoot),localCacheDir:Fe(e.localCacheDir)}))}function pu(e){let t=JSON.parse(e);if(t.version!==In||t.artifactCatalogVersion!==Ee||typeof t.generationId!="string"||!/^[a-f0-9]{64}$/.test(t.generationId)||typeof t.repositoryId!="string"||!/^[a-f0-9]{24}$/.test(t.repositoryId)||typeof t.treeOid!="string"||!t.treeOid||typeof t.producerIdentity!="string"||t.producerIdentity!==xn||typeof t.sourceProjectRoot!="string"||typeof t.scipProjectRoot!="string"||typeof t.createdAt!="string"||!Number.isFinite(Date.parse(t.createdAt))||!t.fingerprint||!Array.isArray(t.artifacts))throw new Error("invalid shared generation manifest");let n=new Set;for(let r of t.artifacts){if(!r||typeof r.path!="string"||typeof r.size!="number"||r.size<0||typeof r.sha256!="string"||!/^[a-f0-9]{64}$/.test(r.sha256))throw new Error("invalid shared generation artifact");if(tt(r.path),n.has(r.path))throw new Error(`duplicate shared generation artifact: ${r.path}`);n.add(r.path)}for(let r of["index.db","index.scip","meta.json"])if(!n.has(r))throw new Error(`shared generation is missing ${r}`);return t}function De(e,t){J(io(t),{recursive:!0});try{Ki(e,t,ru.COPYFILE_FICLONE)}catch{Ki(e,t)}}function gu(e,t,n){J(e,{recursive:!0}),F(h(e,du),{version:1,repositoryId:t,worktreeId:n},{spacing:2,trailingNewline:!0})}function to(e){try{let t=et(e),n=no("sha256");for(let r of t.files){let i=z(O(e,r));n.update(r).update("\0").update(String(i.byteLength)).update("\0").update(i).update("\0")}return n.digest("hex")}catch{return null}}function fu(e){try{let t=G(z(h(e,"meta.json"),"utf8"));return(t.kind==="legacy"||t.kind==="supported")&&t.capabilities.publishableGeneration?t.metadata:void 0}catch{return}}function wn(e){return h(e.repositoryCacheDir,"generations",e.generationId)}function mu(e,t,n){let r=Pr(e,{waitMs:5e3});if(!r)throw new Error("repository cache cleanup is busy");try{if(n){let o=t.activeGenerationId;if(!o||!H(h(e,"generations",o)))throw new Error("shared generation disappeared before its lease was attached")}let i=h(e,"worktrees");J(i,{recursive:!0}),F(h(i,`${t.worktreeId}.json`),t,{spacing:2,trailingNewline:!0}),gu(t.localCacheDir,t.repositoryId,t.worktreeId)}finally{r.release()}}function hu(e,t){let n=h(t,".rollback"),r=new Map,i=new Map;J(n,{recursive:!0});for(let s of["index.scip","index.db","meta.json"]){let c=h(e,s),u=H(c);r.set(s,u),u&&De(c,h(n,"stable",s))}for(let s of vn){let c=h(e,s),u=H(c);if(u){let d=iu(c);if(!d.isDirectory()||d.isSymbolicLink())throw new Error(`managed artifact path is not a directory: ${s}`)}i.set(s,u)}let o=h(e,$e),a=H(o);return a&&lo(o,h(n,"sqlite-generations")),{root:n,stableFiles:r,managedDirectories:i,generationStoreExisted:a}}function yu(e,t,n){for(let r of vn){let i=h(t,r);if(n.managedDirectories.get(r)){let a=h(n.root,"managed",r);J(io(a),{recursive:!0}),Z(i,a)}let o=h(e,r);H(o)&&Z(o,i)}}function Su(e,t){for(let i of vn){let o=h(e,i),a=h(t.root,"managed",i);t.managedDirectories.get(i)?H(a)&&(q(o,{recursive:!0,force:!0}),Z(a,o)):q(o,{recursive:!0,force:!0})}for(let[i,o]of t.stableFiles){let a=h(e,i);if(!o){q(a,{force:!0});continue}let s=`${a}.shared-restore-${nu()}`;De(h(t.root,"stable",i),s),q(a,{force:!0}),Z(s,a)}let n=h(e,$e);q(n,{recursive:!0,force:!0});let r=h(t.root,"sqlite-generations");t.generationStoreExisted&&H(r)&&Z(r,n)}function lo(e,t){J(t,{recursive:!0});for(let n of ou(e,{withFileTypes:!0})){let r=h(e,n.name),i=h(t,n.name);if(n.isSymbolicLink())throw new Error(`managed cache backup cannot contain a symlink: ${r}`);n.isDirectory()?lo(r,i):n.isFile()&&De(r,i)}}function bu(e,t){if(e.generationId!==t.generationId||e.repositoryId!==t.repositoryId||e.treeOid!==t.treeOid||e.producerIdentity!==t.producerIdentity||JSON.stringify(e.fingerprint)!==JSON.stringify(t.fingerprint))throw new Error("shared generation manifest does not match the requested snapshot")}function po(e,t,n,r=!0,i=!0){try{let o=fu(e);if(!o||JSON.stringify(o.fingerprint)!==JSON.stringify(n)||JSON.stringify([...o.indexedLanguages??[]].sort())!==JSON.stringify([...n.languages].sort()))return Te("source validation rejected metadata"),!1;let a=et(e),s=W(h(e,"index.db"),h(e,"meta.json"));if(r?s.state!=="current":s.state==="invalid"||s.state==="drifted")return Te(`source validation rejected SQLite generation state ${s.state}`),!1;let c=new uu(h(e,"index.db"),{readonly:!0,fileMustExist:!0});try{if(i){if(c.pragma("quick_check(1)",{simple:!0})!=="ok")return!1}else c.pragma("schema_version",{simple:!0})}finally{c.close()}let u=kn(t),l=(i?a.files.filter(p=>p.endsWith(".scip")):["index.scip"]).every(p=>{let f=oo(z(O(e,p))).metadata?.projectRoot;return f!==u&&Te(`source validation rejected SCIP root for ${p}: ${String(f)}`),f===u});return l||Te("source validation rejected SCIP project roots"),l}catch(o){return Te(`source validation failed: ${o instanceof Error?o.message:String(o)}`),!1}}function Te(e){process.env.SCIP_QUERY_DEBUG&&console.error(`shared-cache: ${e}`)}function kn(e){try{return Zi(au(e)).href}catch{return Zi(Fe(e)).href}}function Ae(e){return no("sha256").update(e).digest("hex")}import{existsSync as Ru,readFileSync as xu,readdirSync as Iu,statSync as vu}from"fs";import E from"path";var Pu=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function Oe(e,t=[]){let n=E.resolve(e),r=t.flatMap(c=>ku(n,c));if(r.length>0)return go(n,fo(r));let i=wu(n),o=fo(i),a=Tu(n,o)?[n,...o]:o,s=a.length>0?a:[n];return go(n,s)}function go(e,t){return[...new Set(t.map(n=>Du(e,n)))].sort((n,r)=>n.localeCompare(r))}function wu(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Iu(r,{withFileTypes:!0})}catch{continue}for(let o of i){let a=E.join(r,o.name);if(o.isDirectory()){!Pu.has(o.name)&&!o.name.startsWith(".")&&n.push(a);continue}o.isFile()&&Eu(a)&&t.push(E.dirname(a))}}return t}function ku(e,t){let n=t.trim();if(!n)return[];let r=E.resolve(e,n);if(!ge(e,r))return[];try{let i=vu(r);if(i.isDirectory())return[r];if(i.isFile()&&mo(E.basename(r)))return[E.dirname(r)]}catch{return[]}return[]}function Eu(e){if(!mo(E.basename(e)))return!1;let t=ho(e);return t?E.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function mo(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function fo(e){let t=[...new Set(e.map(n=>E.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&Au(n,r)))}function Tu(e,t){if(t.length===0||t.some(r=>E.resolve(r)===e))return!1;let n=E.join(e,"tsconfig.json");return Ru(n)&&Fu(n)}function Fu(e){let n=ho(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!E.extname(r))):!1}function ho(e){try{let t=JSON.parse(xu(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Du(e,t){let n=E.relative(e,t);return n?n.split(E.sep).join("/"):"."}function Au(e,t){let n=E.relative(e,t);return!!n&&!n.startsWith("..")&&!E.isAbsolute(n)}import{createHash as Ku}from"crypto";import{existsSync as Tn,readFileSync as Eo,statSync as Zu,writeFileSync as Fn}from"fs";import{join as ed}from"path";import{readFileSync as yo}from"fs";import{createRequire as Ou}from"module";import{dirname as ju,isAbsolute as bf,relative as Rf,resolve as xf,sep as If}from"path";var So=Ou(import.meta.url),_u=1,bo="0.4.0";function En(){let e=Cu();return e.available?{available:!0,packageVersion:e.packageVersion,typescriptVersion:e.typescriptVersion,producerIdentity:e.producerIdentity}:e}function Cu(){try{let e=So.resolve("@sourcegraph/scip-typescript/package.json"),t=JSON.parse(yo(e,"utf8"));if(t.version!==bo)return{available:!1,reason:`unsupported scip-typescript version ${String(t.version??"unknown")}; expected ${bo}`};let n=ju(e),r=So.resolve("typescript/package.json",{paths:[n]}),i=JSON.parse(yo(r,"utf8"));return typeof i.version!="string"||!i.version?{available:!1,reason:"scip-typescript TypeScript compiler version is unavailable"}:{available:!0,packageRoot:n,packageVersion:t.version,typescriptVersion:i.version,producerIdentity:Mu(t.version,i.version)}}catch(e){return{available:!1,reason:`scip-typescript document producer unavailable: ${e instanceof Error?e.message:String(e)}`}}}function Mu(e,t){return`scip-typescript:${e}:typescript:${t}:document-adapter:${_u}`}import{createHash as Lu}from"crypto";import{readFileSync as Nu}from"fs";import{dirname as $u,join as Ro}from"path";var ct=3;var Vu="typescript-index";function xo(e){let t=Ro(e,Vu),n=or(t);return{...n,requestDir:n.legacyRequestDir}}function Io(e){try{let t=Kn(G(Nu(Ro($u(e),"meta.json"),"utf8")));return t?Lu("sha256").update(t).digest("hex"):null}catch{return null}}import{randomUUID as Gu}from"crypto";import{existsSync as Uu,readFileSync as Bu}from"fs";var Wu=12e4,qu=5,ut=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=dr(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Xu(),this.runtime=n.runtime??Qu,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=ur(this.cacheDir),r=xo(this.cacheDir),i=Dt(n.statePath);if(!vo(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let o=this.runtime.now(),a=o+this.timeoutMs,s=(this.runtime.monotonicNow??y)()+this.timeoutMs,c=Tt("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),u=Ft(c),d=ar(r,{mailboxVersion:Et,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:o,deadlineAtMs:a,protocolVersion:ct,id:u,baseGeneration:this.baseGeneration,request:t},{nowMs:o,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??y)()<=s;){if(Uu(d.responsePath))return Hu(Bu(d.responsePath,"utf8"),u,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let l=Dt(n.statePath);if(!vo(l,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(qu)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function vo(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===ct&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&Se(e.processIdentity,r))}function Hu(e,t,n,r,i,o){let a=JSON.parse(e);if(a.protocolVersion!==ct||a.id!==t||a.operationKey!==n||a.ok===!0&&a.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(a.ok!==!0)throw new Error(typeof a.error=="string"?a.error:"TypeScript index service request failed.");let s=zu(a.response,i),c=[...new Set(o)].sort(),u=s.fragments.map(d=>d.relativePath).sort();if(JSON.stringify(u)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return s}function zu(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(o=>{if(!o||typeof o.relativePath!="string"||o.bytesBase64!==null&&typeof o.bytesBase64!="string"||typeof o.occurrences!="number"||!Number.isInteger(o.occurrences)||o.occurrences<0||typeof o.symbols!="number"||!Number.isInteger(o.symbols)||o.symbols<0||!Array.isArray(o.referenceFragments)||!o.referenceFragments.every(Ju)||r.has(o.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(o.relativePath);let a=o.bytesBase64===null?null:Yu(o.bytesBase64);return{relativePath:o.relativePath,bytes:a,occurrences:o.occurrences,symbols:o.symbols,referenceFragments:o.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ju(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 Yu(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Xu(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Wu}var Qu={now:Date.now,monotonicNow:y,randomId:Gu,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:ne,readProcessIdentity:re};function td(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=Ne(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(u=>u.kind!=="modified"||u.inputKind!=="source"||!At(u.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=He(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=nd([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let o=Po(e.currentSnapshot,e.projectFiles,e.producerIdentity),a=Po(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(o!==a)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let s=ko(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!s)return{eligible:!1,reason:"prior document identity unavailable"};let c=ko(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return c?{eligible:!0,manifest:n,plan:r,projectIdentity:o,previousFragmentGeneration:wo(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:wo(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:s,nextDocumentIdentities:c,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function nd(e,t){let n=null;for(let r of e){let i=t.filter(o=>o==="."||r===o||r.startsWith(`${o}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function To(e){let t=y();try{if(!Tn(e.previousDbPath)||!Tn(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=En();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let o=new X({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),a,s;try{a=Ge(o,{includeIgnored:!1}).filter(At).sort(),s=Ue(o)}finally{o.close()}let c=performance.now()-n,u=td({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?Oe(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:a,graph:s,producerIdentity:r.producerIdentity,rootTsconfigExists:Tn(ed(e.projectRoot,"tsconfig.json"))});if(!u.eligible)throw new Error(u.reason);let d=Io(e.previousDbPath);if(!d)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new ut({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:d}).request({kind:"emit-documents",tsconfigPath:u.tsconfigPath,projectArgument:u.projectArgument,projectIdentity:u.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles}),f=performance.now()-n,g=Zu(e.previousShardPath).size>=Ci;n=performance.now();let m=g?null:Eo(e.previousShardPath),b=g?{completeIndexBytes:null,affectedIndexBytes:bi(p.fragments)}:Pi({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),P=performance.now()-n;n=performance.now(),g?Mi({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,nextGenerationIdentity:u.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Ri({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.previousFragmentGeneration,documentIdentities:u.previousDocumentIdentities,allowUntrackedDocuments:!0}),xi({cacheDir:e.cacheDir,previousGenerationIdentity:u.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:u.projectIdentity,generationIdentity:u.nextFragmentGeneration,fragments:p.fragments,documentIdentities:u.nextDocumentIdentities}));let x=performance.now()-n;n=performance.now(),b.completeIndexBytes&&Fn(e.candidateShardPath,b.completeIndexBytes),Fn(e.candidateAffectedScipPath,b.affectedIndexBytes);let v=performance.now()-n,w={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:y()-t,cold:p.cold,changedFiles:u.plan.changedFiles,affectedFiles:u.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:u.previousFragmentGeneration,nextFragmentGeneration:u.nextFragmentGeneration,manifest:u.manifest,plan:u.plan,projectFileCount:a.length,referenceFragmentsByFile:new Map(p.fragments.map(V=>[V.relativePath,V.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:f,serviceMs:p.durationMs,assemblyMs:P,fragmentStoreMs:x,writeMs:v}};return e.onStatus(`Incremental TypeScript index emitted ${w.affectedFiles.length} affected document(s) in ${(w.durationMs/1e3).toFixed(3)}s (${w.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${f.toFixed(0)}ms, assembly ${P.toFixed(0)}ms, fragments ${x.toFixed(0)}ms, write ${v.toFixed(0)}ms).`),w}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 Fo(e){let t=En();if(!t.available)throw new Error(t.reason);let n=Li({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:Eo(e.baseShardPath),packageVersion:t.packageVersion});Fn(e.candidateShardPath,n)}function Po(e,t,n){let r=e.files.filter(i=>Xn(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,o)=>i.path.localeCompare(o.path));return Dn(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function wo(e,t){return Dn(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function ko(e,t,n,r,i){let o=new Set(e.files.map(c=>c.path)),a=lr({projectFiles:t.filter(c=>o.has(c)),snapshot:e,graph:n,engineIdentity:r}),s=new Map;for(let c of i){let u=a.identityFor(c,"typescript-scip-document-v1");if(u.key){s.set(c,u.key);continue}if(o.has(c))return null;s.set(c,Dn(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return s}function Dn(e){return Ku("sha256").update(e).digest("hex")}import{existsSync as dt,renameSync as On,rmSync as jn,statSync as rd}from"fs";import{cpus as id}from"os";import{join as Ao}from"path";function od(e,t,n){if(!e.defaultOutputPath)return;let r=Ao(t,e.defaultOutputPath);n!==r&&dt(r)&&On(r,n)}function ad(e,t,n){if(!e.defaultOutputPath)return null;let r=Ao(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return jn(i,{force:!0}),dt(r)?(On(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function sd(e){e&&(jn(e.defaultOutputPath,{force:!0}),e.backupPath&&dt(e.backupPath)&&On(e.backupPath,e.defaultOutputPath))}function cd(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,id().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function Oo(e,t,n,r){let i=e.filter(u=>u.config.defaultOutputPath),o=e.filter(u=>!u.config.defaultOutputPath),a=[],s=cd(o.length,r),c=await ld(o,s,u=>An(u,t,n));if(s>1){let u=new Map;for(let d of c.filter(l=>l.result.skipped&&l.retryable)){let l=o.find(p=>p.id===d.result.id);l&&(n(`Retrying ${l.label} indexer serially after parallel failure...`),u.set(l.id,(await An(l,t,n)).result))}a.push(...c.map(({result:d})=>u.get(d.id)??d))}else a.push(...c.map(({result:u})=>u));for(let u of i)a.push((await An(u,t,n)).result);return a.sort((u,d)=>e.findIndex(l=>l.id===u.id)-e.findIndex(l=>l.id===d.id))}async function An(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),jn(e.scipPath,{force:!0});let r=ad(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),o=y();try{let s=nr(e.binary,e.args),c=await vr({command:s.binary,args:s.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:ud(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(c.status!==0){let u=c.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${c.status}${u?`:
|
|
234
|
+
${u}`:""}`)}od(e.config,t,e.scipPath)}catch(s){let c=s instanceof Error?s.message:String(s),u=`${e.resolvedBinary} indexer failed: ${c.split(`
|
|
235
|
+
`)[0]}`,d=e.label===e.language?u:`${e.label}: ${u}`;return n(`Skipping ${e.label}: ${u}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:y()-o,command:i,skipped:{language:e.language,reason:d}},retryable:dd(s)}}finally{sd(r)}if(!dt(e.scipPath)){let s=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=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:y()-o,command:i,skipped:{language:e.language,reason:c}},retryable:!1}}let a;try{a=rd(e.scipPath).size}catch{a=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:y()-o,command:i,outputBytes:a},retryable:!1}}function ud(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):xr.indexer}function dd(e){return e instanceof Ir?e.kind==="spawn"&&Do(e.cause):Do(e)}function Do(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}async function ld(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,o=Math.max(1,Math.min(e.length,t)),a=Array.from({length:o},async()=>{for(;i<e.length;){let s=i++;r[s]=await n(e[s])}});return await Promise.all(a),r}import{execFileSync as pd}from"child_process";import{platform as gd}from"os";function _n(e,t){let n=e.installMethods,r=he(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(vt(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{pd(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:gd()==="win32"});let o=ye(e);if(o){let a=o===e.indexerBinary?"":` (using ${o})`;return t(`Successfully installed ${r} via ${i.label}${a}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(o){let a=o instanceof Error?o.message:String(o);t(`${i.label} install failed: ${a}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}import ea from"better-sqlite3";import{existsSync as ta}from"fs";import{dirname as na,join as ra,resolve as ia}from"path";import{randomUUID as md}from"crypto";import{mkdtempSync as hd,readFileSync as yd,rmSync as Sd,statSync as _o}from"fs";import{tmpdir as bd}from"os";import{join as Co}from"path";import{Worker as Rd}from"worker_threads";function fd(){return{"missing-source-file":0,"missing-service-script":0,"no-definition":0,"same-file-definition":0,"unindexed-definition":0}}function ce(){return{skippedReferences:0,skippedReferenceReasons:fd(),skippedReferenceSamples:[]}}function lt(e,t){e.skippedReferences+=t.skippedReferences;for(let n of Object.keys(e.skippedReferenceReasons)){e.skippedReferenceReasons[n]+=t.skippedReferenceReasons[n];for(let r of t.skippedReferenceSamples.filter(i=>i.reason===n))e.skippedReferenceSamples.filter(o=>o.reason===n&&o.sourceFile===r.sourceFile).length<2&&e.skippedReferenceSamples.push(r)}}var xd=3e5,Id=64*1024*1024,vd={createResultDirectory:()=>hd(Co(bd(),"scip-query-vue-workers-")),spawn:(e,t)=>new Rd(e,{workerData:t}),resultSize:e=>_o(e).size,readResult:e=>yd(e,"utf-8"),removeResultDirectory:e=>Sd(e,{recursive:!0,force:!0})};function Mo(e){return e.length>=8&&No(e.length)>1}async function Lo(e,t=vd){let n=No(e.vueFiles.length),r=Md(e.vueFiles),i=Nd(r,n),o=new URL("./augment-vue-worker.js",import.meta.url),a=e.timeoutMs??_d(),s=e.maxResultBytes??Cd();jo("timeoutMs",a),jo("maxResultBytes",s);let c=md(),u=t.createResultDirectory(),d=[],l,p,f;try{for(let m=0;m<i.length;m++){let b=m,P=i[m]??[],x=P.map(V=>V.taskId),v=Co(u,`${b}.json`),w=t.spawn(o,{projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,tasks:P,resultPath:v,runId:c,workerId:b,taskIds:x});d.push({workerId:b,taskIds:x,resultPath:v,handle:w,completion:Pd(w,b)})}await wd(d,a);let g=d.sort((m,b)=>m.workerId-b.workerId).map(m=>Ed(m,c,s,t));f={occurrences:g.flatMap(m=>m.occurrences),...ce()};for(let m of g)lt(f,m)}catch(g){l=g}finally{let g=await kd(d);if(g.length===0)try{t.removeResultDirectory(u)}catch(m){g.push(m)}if(g.length>0){let m=l===void 0?g:[l,...g];p=new AggregateError(m,`Vue worker cleanup failed: ${jd(m[0])}`)}}if(p)throw p;if(l!==void 0)throw l;if(!f)throw new Error("Vue workers completed without producing a merged result.");return f}function Pd(e,t){return new Promise((n,r)=>{let i=!1,o=c=>{i||(i=!0,e.off("error",a),e.off("exit",s),c?r(c):n())},a=c=>{o(new Error(`Vue reference worker ${t} failed: ${c.message}`,{cause:c}))},s=c=>{o(c===0?void 0:new Error(`Vue reference worker ${t} exited with code ${c}`))};e.once("error",a),e.once("exit",s)})}async function wd(e,t){let n;try{await Promise.race([Promise.all(e.map(r=>r.completion)),new Promise((r,i)=>{n=setTimeout(()=>i(new Error(`Vue reference workers timed out after ${(t/1e3).toFixed(3)}s`)),t),n.unref()})])}finally{n&&clearTimeout(n)}}async function kd(e){return(await Promise.allSettled(e.map(async n=>n.handle.terminate()))).flatMap(n=>n.status==="rejected"?[n.reason]:[])}function Ed(e,t,n,r){let i=r.resultSize(e.resultPath);if(!Number.isSafeInteger(i)||i<0||i>n)throw new Error(`Vue reference worker ${e.workerId} result is ${i} bytes; limit is ${n} bytes`);let o;try{o=JSON.parse(r.readResult(e.resultPath))}catch(a){throw new Error(`Vue reference worker ${e.workerId} produced invalid JSON`,{cause:a})}if(!je(o)||o.version!==1||o.runId!==t||o.workerId!==e.workerId)throw new Error(`Vue reference worker ${e.workerId} result identity does not match its assignment`);if(!Od(o.taskIds,e.taskIds))throw new Error(`Vue reference worker ${e.workerId} result task identities do not match its assignment`);if(o.ok===!1)throw typeof o.error!="string"?new Error(`Vue reference worker ${e.workerId} failure payload is malformed`):new Error(`Vue reference worker ${e.workerId} failed: ${o.error}`);if(o.ok!==!0||!Td(o.result))throw new Error(`Vue reference worker ${e.workerId} success payload is malformed`);return o.result}function Td(e){if(!je(e)||!Array.isArray(e.occurrences)||!e.occurrences.every(Fd)||!L(e.skippedReferences)||!je(e.skippedReferenceReasons))return!1;for(let t of["missing-source-file","missing-service-script","no-definition","same-file-definition","unindexed-definition"])if(!L(e.skippedReferenceReasons[t]))return!1;return Array.isArray(e.skippedReferenceSamples)&&e.skippedReferenceSamples.every(Dd)}function Fd(e){return je(e)&&typeof e.sourceFile=="string"&&L(e.sourceLine)&&L(e.sourceStartChar)&&L(e.sourceEndChar)&&typeof e.sourceToken=="string"&&typeof e.definitionFile=="string"&&L(e.symbolId)}function Dd(e){return je(e)&&typeof e.sourceFile=="string"&&L(e.sourceLine)&&L(e.sourceStartChar)&&L(e.sourceEndChar)&&typeof e.token=="string"&&Ad(e.reason)}function Ad(e){return e==="missing-source-file"||e==="missing-service-script"||e==="no-definition"||e==="same-file-definition"||e==="unindexed-definition"}function L(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>=0}function je(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Od(e,t){return Array.isArray(e)&&e.length===t.length&&e.every((n,r)=>typeof n=="string"&&n===t[r])}function jo(e,t){if(!Number.isSafeInteger(t)||t<=0)throw new TypeError(`${e} must be a positive safe integer.`)}function jd(e){return e instanceof Error?e.message:String(e)}function No(e){let t=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKERS??0),n=Number.isFinite(t)&&t>0?t:1;return Math.max(1,Math.min(e,n))}function _d(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_TIMEOUT_MS??0);return Number.isFinite(e)&&e>0?e:xd}function Cd(){let e=Number(process.env.SCIP_QUERY_AUGMENT_VUE_WORKER_RESULT_MAX_BYTES??0);return Number.isSafeInteger(e)&&e>0?e:Id}function Md(e){let t=Ld(),n=[];for(let r of e){let i=$o(r),o=Math.max(1,Math.ceil(i/t));for(let a=0;a<o;a++)n.push({taskId:`${n.length}:${r}:${a}`,fileName:r,startOffset:Math.floor(i*a/o),endOffset:a===o-1?Number.POSITIVE_INFINITY:Math.floor(i*(a+1)/o),countFileSkip:a===0})}return n}function Ld(){return Number.POSITIVE_INFINITY}function Nd(e,t){let n=Array.from({length:t},()=>({tasks:[],weight:0})),r=e.map(i=>({task:i,weight:$d(i)})).sort((i,o)=>o.weight-i.weight);for(let i of r){let o=n.reduce((a,s)=>s.weight<a.weight?s:a);o.tasks.push(i.task),o.weight+=i.weight}return n.map(i=>i.tasks).filter(i=>i.length>0)}function $d(e){return Number.isFinite(e.endOffset)?Math.max(1,e.endOffset-e.startOffset):Math.max(1,$o(e.fileName)-e.startOffset)}function $o(e){try{return _o(e).size}catch{return 1}}import{createRequire as Vd}from"module";import{existsSync as Gd,readFileSync as Mn}from"fs";import{dirname as Vo,extname as Ud,join as Go,relative as Bd,resolve as Wd}from"path";import{pathToFileURL as qd}from"url";function Hd(e){e.transaction(()=>{e.prepare(`
|
|
240
236
|
DELETE FROM mentions
|
|
241
237
|
WHERE chunk_id IN (
|
|
242
238
|
SELECT c.id
|
|
@@ -251,12 +247,12 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
251
247
|
FROM documents
|
|
252
248
|
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
253
249
|
)
|
|
254
|
-
`).run()})()}function
|
|
250
|
+
`).run()})()}function Ln(e,t){return e.prepare(`
|
|
255
251
|
SELECT relative_path AS relativePath
|
|
256
252
|
FROM documents
|
|
257
253
|
WHERE language = 'vue' OR relative_path LIKE '%.vue'
|
|
258
254
|
ORDER BY relative_path
|
|
259
|
-
`).all().map(r=>
|
|
255
|
+
`).all().map(r=>Wd(t,r.relativePath))}function Uo(e,t){let{vueCore:n,ts:r,volarTs:i}=zd(e),{parsed:o,vueOptions:a}=Jd(n,r,t),s=Vo(t),c=n.createVueLanguagePlugin(r,o.options,a,f=>f),u=Yd(n,r,c),d=Xd(s,o),{languageServiceHost:l}=i.createLanguageServiceHost(r,r.sys,u,f=>f,d),p=r.createLanguageService(l);return{ts:r,language:u,languageService:p,fileNames:o.fileNames,configDir:s}}function zd(e){let t=Vd(qd(Go(e,"package.json")).href);return{vueCore:Cn(t,"@vue/language-core",e),ts:Cn(t,"typescript",e),volarTs:Cn(t,"@volar/typescript",e)}}function Jd(e,t,n){let r=t.readConfigFile(n,t.sys.readFile);if(r.error||!r.config)throw new Error(`Failed to read ${n}`);let o=e.createParsedCommandLine(t,t.sys,n).vueOptions;return typeof e.createGlobalTypesWriter=="function"&&(o.globalTypesPath=e.createGlobalTypesWriter(o,t.sys.writeFile)),{parsed:t.parseJsonConfigFileContent(r.config,t.sys,Vo(n),void 0,n,void 0,e.getAllExtensions(o).map(a=>({extension:a.slice(1),isMixedContent:!0,scriptKind:t.ScriptKind.Deferred}))),vueOptions:o}}function Yd(e,t,n){let r={},i=e.createLanguage([n],new Map,o=>{if(!Gd(o))return;let a=Mn(o,"utf-8");r.current?.scripts.set(o,t.ScriptSnapshot.fromString(a),n.getLanguageId(o)??nl(o))});return r.current=i,i}function Xd(e,t){return{getCurrentDirectory:()=>e,getCompilationSettings:()=>t.options,getScriptFileNames:()=>t.fileNames,getProjectReferences:()=>t.projectReferences,getProjectVersion:()=>"0"}}function Cn(e,t,n){try{return e(t)}catch(r){throw(typeof r=="object"&&r!==null&&"code"in r?r.code:null)==="MODULE_NOT_FOUND"?new Error(`Vue augmentation requires ${t} to be installed in ${n}. Install Vue/Volar dependencies for that project, then rerun augment-vue.`,{cause:r}):r}}function Bo(e,t,n){let r=Qd(e);return i=>{if(!i.name)return null;let o=N(t,i.fileName),a=n.get(i.fileName);if(!a)return null;let s=n.positionAt(a,i.textSpan.start),c=r.get(o);if(!c)return null;let u=c.starts.find(l=>l.line===s.line&&l.displayName===i.name);if(u)return u.symbolId;let d=c.containingByLine.get(s.line);return d&&d.displayName===i.name?d.symbolId:Kd(c.starts,s.line,2,i.name)}}function Qd(e){let t=e.prepare(`
|
|
260
256
|
SELECT
|
|
261
257
|
d.relative_path AS relativePath,
|
|
262
258
|
der.start_line AS startLine,
|
|
@@ -267,22 +263,22 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
267
263
|
JOIN documents d ON d.id = der.document_id
|
|
268
264
|
JOIN global_symbols gs ON gs.id = der.symbol_id
|
|
269
265
|
ORDER BY d.relative_path, (der.end_line - der.start_line) DESC
|
|
270
|
-
`).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId,displayName:r.displayName});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,{symbolId:r.symbolId,displayName:r.displayName})}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function
|
|
266
|
+
`).all(),n=new Map;for(let r of t){let i=n.get(r.relativePath);i||(i={containingByLine:new Map,starts:[]},n.set(r.relativePath,i)),i.starts.push({line:r.startLine,symbolId:r.symbolId,displayName:r.displayName});for(let o=r.startLine;o<=r.endLine;o++)i.containingByLine.set(o,{symbolId:r.symbolId,displayName:r.displayName})}for(let r of n.values())r.starts.sort((i,o)=>i.line-o.line);return n}function Kd(e,t,n,r){let i=0,o=e.length-1;for(;i<=o;){let s=Math.floor((i+o)/2);e[s].line<t?i=s+1:o=s-1}let a=null;for(let s of[o,i]){let c=e[s];if(!c||c.displayName!==r)continue;let u=Math.abs(c.line-t);u>n||(!a||u<a.distance)&&(a={distance:u,symbolId:c.symbolId})}return a?.symbolId??null}function Nn(e,t,n){let r=ol(t),i=e.prepare("SELECT id FROM global_symbols WHERE symbol = ?"),o=e.prepare(`
|
|
271
267
|
INSERT OR IGNORE INTO global_symbols (symbol, display_name, kind, documentation)
|
|
272
268
|
VALUES (?, ?, ?, ?)
|
|
273
|
-
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let d=
|
|
269
|
+
`),a=0,s=new Map;return e.transaction(()=>{for(let u of n){let d=N(t,u),l=Ko(r.name,r.version,d);o.run(l,"default",7,`Vue component|${d}`);let p=al(i,r,t,u);p&&(a++,s.set(u,p))}})(),{get(u){return s.get(u)??null},syntheticSymbols:a}}function Wo(e,t,n,r,i){return e.transaction(()=>(Hd(e),Zd(e,t,n,r),el(e,i)))()}function Zd(e,t,n,r){let i=e.prepare("SELECT id FROM documents WHERE relative_path = ?"),o=e.prepare(`
|
|
274
270
|
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
275
271
|
VALUES (?, ?, ?, ?, X'00')
|
|
276
272
|
`),a=e.prepare(`
|
|
277
273
|
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
278
274
|
VALUES (?, ?, 1)
|
|
279
|
-
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=
|
|
275
|
+
`);for(let s of n){let c=r.get(s);if(!c)continue;let u=N(t,s),d=i.get(u);if(!d)continue;let l=o.run(d.id,-1,0,0);a.run(Number(l.lastInsertRowid),c)}}function qo(e,t,n,r,i){if(e.fileName.endsWith(".vue")){let o=r.language.scripts.get(e.fileName),a=o?.generated?.languagePlugin.typescript?.getServiceScript(o.generated.root)?.code;if(o&&a){let s=r.language.maps.get(a,o);if($n(s,e.textSpan.start)!==null)return n.get(e.fileName)}return e.fileName.startsWith(i)?n.get(e.fileName):null}return t(e)}function Ho(e){let t=new Set,n=[];for(let r of e){let i=zo(r);t.has(i)||(t.add(i),n.push(r))}return n}function zo(e){return[e.sourceFile,e.sourceLine,e.sourceStartChar,e.sourceEndChar,e.symbolId].join(":")}function el(e,t){let n=il(e,[...new Set(t.map(c=>c.sourceFile))]),r=e.prepare(`
|
|
280
276
|
INSERT INTO chunks (document_id, chunk_index, start_line, end_line, occurrences)
|
|
281
277
|
VALUES (?, ?, ?, ?, X'00')
|
|
282
278
|
`),i=e.prepare(`
|
|
283
279
|
INSERT OR IGNORE INTO mentions (chunk_id, symbol_id, role)
|
|
284
280
|
VALUES (?, ?, 0)
|
|
285
|
-
`),o=new Set,a=0,s=0;for(let c of t){let u=
|
|
281
|
+
`),o=new Set,a=0,s=0;for(let c of t){let u=zo(c);if(o.has(u))continue;o.add(u);let d=n.get(c.sourceFile);if(!d)continue;let l=r.run(d,s++,c.sourceLine,c.sourceLine),p=i.run(Number(l.lastInsertRowid),c.symbolId);a+=Number(p.changes)}return a}function*Jo(e){let t=/\b[A-Za-z_$][A-Za-z0-9_$]*\b/g,n=new Set(["script","setup","template","style","lang","scoped","true","false","null","undefined","const","let","var","import","from","export","return","if","else","for","while","function","class","type","interface","as","await","async"]),r;for(;r=t.exec(e);){let i=r[0];n.has(i)||(yield{text:i,start:r.index,end:r.index+i.length})}}function Yo(e,t){for(let[n]of e.toGeneratedLocation(t,r=>!!r.navigation))return n;return null}function $n(e,t){let n=e;for(let[r]of n.toSourceLocation(t,i=>!!i.navigation))return r;return null}function tl(e,t){let n=0,r=e.lineStarts.length-1;for(;n<=r;){let o=Math.floor((n+r)/2);e.lineStarts[o]<=t?n=o+1:r=o-1}let i=Math.max(0,r);return{line:i,character:t-e.lineStarts[i]}}function Xo(e,t){return N(e,t).startsWith("node_modules/")}function N(e,t){return Bd(e,t).replaceAll("\\","/")}function nl(e){switch(Ud(e)){case".vue":return"vue";case".tsx":return"typescriptreact";case".ts":case".mts":case".cts":return"typescript";case".jsx":return"javascriptreact";case".js":case".mjs":case".cjs":return"javascript";case".json":return"json";default:return"typescript"}}function Qo(){let e=new Map;return{get(t){if(e.has(t))return e.get(t)??null;try{let n=Mn(t,"utf-8"),r={text:n,lineStarts:rl(n)};return e.set(t,r),r}catch{return e.set(t,null),null}},positionAt:tl}}function rl(e){let t=[0];for(let n=0;n<e.length;n++)e.charCodeAt(n)===10&&t.push(n+1);return t}function il(e,t){let n=new Map,r=500;for(let i=0;i<t.length;i+=r){let o=t.slice(i,i+r),a=e.prepare(`SELECT id, relative_path AS relativePath FROM documents WHERE relative_path IN (${o.map(()=>"?").join(",")})`).all(...o);for(let s of a)n.set(s.relativePath,s.id)}return n}function ol(e){try{let t=JSON.parse(Mn(Go(e,"package.json"),"utf-8"));return{name:t.name??"workspace",version:t.version??"0.0.0"}}catch{return{name:"workspace",version:"0.0.0"}}}function al(e,t,n,r){let i=N(n,r),o=Ko(t.name,t.version,i);return e.get(o)?.id??null}function Ko(e,t,n){let r=n.split("/").map(i=>`\`${i.replaceAll("`","")}\``).join("/");return`scip-vue npm ${e} ${t} ${r}/default.`}function oa(e){return{id:"vue-resolved-references",facts:["synthetic-symbol","source-mapped-occurrence","definition-mention","replacement-chunk","fingerprint-cache"],run:t=>dl({projectRoot:t.projectRoot,dbPath:t.dbPath,tsconfig:e.tsconfig,onStatus:t.onStatus})}}function cl(e){return C(U(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),C(oa({tsconfig:e.tsconfig}),{projectRoot:e.projectRoot,dbPath:e.dbPath,onStatus:e.onStatus}).result}async function ul(e){return C(U(),{projectRoot:e.projectRoot,dbPath:e.dbPath}),ll(e)}function dl(e){let t=ia(e.projectRoot,e.tsconfig);if(!ta(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new ea(e.dbPath);try{let r=Ln(n,e.projectRoot),i=ra(na(e.dbPath),"augment-vue-meta.json");return ti({cachePath:i,readFingerprint:()=>ca(n,e.projectRoot,e.tsconfig),compute:()=>pl({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}async function ll(e){let t=ia(e.projectRoot,e.tsconfig);if(!ta(t))throw new Error(`Vue tsconfig not found at ${t}`);let n=new ea(e.dbPath);try{let r=Ln(n,e.projectRoot),i=ra(na(e.dbPath),"augment-vue-meta.json");return await ni({cachePath:i,readFingerprint:()=>ca(n,e.projectRoot,e.tsconfig),compute:()=>gl({db:n,projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,configPath:t,vueFiles:r,onStatus:e.onStatus}),onCacheHit:o=>e.onStatus?.(`Vue references unchanged; reused ${o.resolvedReferences} cached resolved references.`)})}finally{n.close()}}function pl(e){let t=Nn(e.db,e.projectRoot,e.vueFiles),n=sa(e,t);return aa(e,t,n)}async function gl(e){let t=Nn(e.db,e.projectRoot,e.vueFiles),n=Mo(e.vueFiles)?await Lo({projectRoot:e.projectRoot,dbPath:e.dbPath,tsconfig:e.tsconfig,vueFiles:e.vueFiles}):sa(e,t);return aa(e,t,n)}function aa(e,t,n){let r=Ho(n.occurrences),i=Wo(e.db,e.projectRoot,e.vueFiles,t,r),o={vueFiles:e.vueFiles.length,resolvedReferences:r.length,resolvedReferenceSamples:Il(e.db,r,20),insertedMentions:i,skippedReferences:n.skippedReferences,skippedReferenceReasons:n.skippedReferenceReasons,skippedReferenceSamples:xl(n.skippedReferenceSamples,20),syntheticSymbols:t.syntheticSymbols};return e.onStatus?.(`Resolved ${o.resolvedReferences} Vue references with Volar; inserted ${o.insertedMentions} mentions.`),o}function sa(e,t){let n=fl({db:e.db,projectRoot:e.projectRoot,configPath:e.configPath,vueSymbolLookup:t});return ml({...n,vueFiles:n.context.fileNames.filter(r=>r.endsWith(".vue"))})}function ca(e,t,n){let r=e.prepare(`
|
|
286
282
|
SELECT
|
|
287
283
|
(SELECT COUNT(*) FROM documents) AS documents,
|
|
288
284
|
(SELECT COUNT(*) FROM global_symbols) AS symbols,
|
|
@@ -291,13 +287,12 @@ import{a as W}from"./chunk-NH7WNNQC.js";import{a as gt,e as ft,g as mt,h as Mn,i
|
|
|
291
287
|
(SELECT COUNT(*) FROM defn_enclosing_ranges) AS ranges,
|
|
292
288
|
(SELECT MAX(id) FROM chunks) AS maxChunkId,
|
|
293
289
|
(SELECT MAX(id) FROM global_symbols) AS maxSymbolId
|
|
294
|
-
`).get();return{version:3,tsconfig:n,files:
|
|
295
|
-
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function Rd(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function Po(e,t,n){let r=K();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:_(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function hn(e,t,n,r,i,o){if(e.skippedReferences++,e.skippedReferenceReasons[o]++,e.skippedReferenceSamples.filter(s=>s.reason===o&&s.sourceFile===r).length>=2)return;let a=t.positionAt(n,i.start);e.skippedReferenceSamples.push({sourceFile:r,sourceLine:a.line,sourceStartChar:a.character,sourceEndChar:a.character+i.text.length,token:i.text,reason:o})}function yn(e,t){let n=new Map;for(let o of e){let a=n.get(o.sourceFile)??[];a.push(o),n.set(o.sourceFile,a)}let r=[...n.keys()].sort(),i=[];for(let o=0;i.length<t;o++){let a=!1;for(let s of r){let c=n.get(s)?.[o];if(c&&(i.push(c),a=!0,i.length===t))break}if(!a)break}return i}function xd(e,t){let n=yn(e.filter(o=>o.sourceFile!==o.definitionFile),Math.ceil(t/2)),r=new Set(n.map(o=>`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),i=yn(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function vd(e,t){let n=[...new Set(e.map(i=>i.reason))].sort(),r=[];for(let[i,o]of n.entries()){let a=n.length-i,s=Math.ceil((t-r.length)/a);r.push(...yn(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Id(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return xd(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function Pd(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of kd(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(a))continue;let s=t.tokenContext.tokenByStart.get(a);s&&(ko(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function ko(e,t,n,r,i,o,a){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,sourceToken:i.text,definitionFile:o,symbolId:a})}function wd(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function kd(e,t,n,r,i,o){let a=e.getDocumentHighlights?.(t,n,[t])??[],s=[];for(let c of a)if(c.fileName===t)for(let u of c.highlightSpans){let d=Ed(r,u.textSpan.start,o,i.text);d!==null&&s.push(d)}return s}function Ed(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=mn(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function pm(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=Nd(e),a=Date.now();nt(h(o.outputScip),{recursive:!0}),nt(h(o.outputDb),{recursive:!0});let s=e.languages??xt(t);if(s.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: ${s.join(", ")}`);let c=ee("reindex.fingerprint",()=>Fn(t,s,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:s.length}),u,d;if(e.skipIfUnchanged!==!1&&!Oi(t,o.outputDb)&&Eo(o.outputScip)===Eo(x(h(o.outputDb),"index.scip"))){let g=De(t);if(u=g?ze(g,c):void 0,u){let S=C(u);if(S){if(!Md(o,c))try{en({snapshot:u,manifest:S,targetCacheDir:h(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${u.generationId.slice(0,12)}`)}catch(b){r(`Shared generation attach failed; continuing locally: ${Re(b)}`)}}else{let b=await Ci(u);if(b.kind==="owner")d=b.release;else if(b.kind==="generation-ready"){let P=C(u);if(P)try{en({snapshot:u,manifest:P,targetCacheDir:h(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${u.generationId.slice(0,12)} after waiting`)}catch(y){r(`Shared generation attach failed after waiting; continuing locally: ${Re(y)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=ie(x(h(o.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw d?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${h(o.outputDb)}.`);let l;try{l=await te("reindex.lock",()=>ll(x(h(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:s.length})}catch(g){throw p.release(),d?.(),g}let m=null;try{let g=Bd(h(o.outputDb));g.removed>0&&r(`Removed ${g.removed} abandoned reindex workspace(s)`);for(let w of g.errors)r(`Could not remove abandoned reindex workspace: ${w}`);let S=null,b=ee("reindex.reuse-check",()=>(S=$d({opts:e,paths:o,languages:s,fingerprint:c,start:a,onStatus:r}),S),()=>({languages:s.length,reused:S!==null}));if(b)return To({snapshot:u,paths:o,projectRoot:t,fingerprint:c,onStatus:r}),mt(o.outputDb,b),b;await te("reindex.scip-cli-ready",()=>rl(i,r));let P=Vd(o);m=P.runDir;let y,I=await te("reindex.fresh",async()=>(y=await Ud({opts:e,languages:s,projectRoot:t,paths:o,tempPaths:P,fingerprint:c,start:a,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),y),()=>({languages:s.length,reused:y?.reused,skipped:y?.skipped.length}));return To({snapshot:u,paths:o,projectRoot:t,fingerprint:c,onStatus:r}),mt(o.outputDb,I),I}catch(g){let S=at({trigger:e.trigger,result:"failed",start:a,error:g instanceof Error?g.message:String(g)});throw Ho(o.metaPath,S),Mn(o.outputDb,S),g}finally{m&&M(m,{recursive:!0,force:!0}),l(),p.release(),d?.()}}function To(e){if(e.snapshot){if(C(e.snapshot)){Ye(e.snapshot,h(e.paths.outputDb),"local-fresh");return}try{let t=De(e.projectRoot),n=t?ze(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}ji({snapshot:e.snapshot,sourceCacheDir:h(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=De(e.projectRoot);return(r?ze(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),Ye(e.snapshot,h(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: ${Re(t)}`)}}}function Md(e,t){if(!O(e.outputScip)||!O(e.outputDb)||!Wo(e.metaPath,t))return!1;let n=V(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function Re(e){return e instanceof Error?e.message:String(e)}function Nd(e){let t=e.outputScip??x(e.projectRoot,"index.scip"),n=e.outputDb??x(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:x(h(n),"meta.json")}}function $d(e){let t=V(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!O(e.paths.outputScip)||!O(e.paths.outputDb)||!Wo(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;$(H(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start,r=at({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return Ho(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:Gd(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Gd(e,t,n,r){let i=Bo(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:be(i[o]),outputBytes:xe(Rn(e.outputDb,o)),durationMs:0}))}function Vd(e){let t=Od(x(h(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:x(t,tt(e.outputScip)),tempOutputDb:x(t,tt(e.outputDb)),tempMetaPath:x(t,tt(e.metaPath))}}function Bd(e){let t=[],n;try{n=Ao(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[Re(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{M(x(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${Re(o)}`)}return{removed:r,errors:t}}async function Ud(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await te("reindex.language-indexers",async()=>(n=await Hd(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:o,reusedLanguages:a,languageFingerprints:s,shards:c,typescriptProjectShardContext:u,incrementalTypeScript:d}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),Wd({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let m=ee("reindex.publish",()=>el(e,i,o,a,s,u),{mode:"metadata-only",languages:i.length,reused:a.length}),g=m.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(S=>S.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:o,lastRefresh:m,shards:c}}let p=ee("reindex.publish",()=>Zd(e,t,i,o,a,s,u,d),{mode:d?"incremental-or-fallback":"full",languages:i.length,reused:a.length,skipped:o.length}),l=p.durationMs;return e.onStatus(`Done in ${(l/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:l,reused:!1,skipped:o,lastRefresh:p,shards:c}}function Wd(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!O(e.run.paths.outputScip)||!O(e.run.paths.outputDb))return!1;let t=V(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 Hd(e,t){let n=Xd({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,In]of n)In.reused&&(r.push({language:E,scipPath:In.scipPath}),i.add(E));for(let E of i)e.onStatus(`Reusing cached ${E} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=V(e.paths.outputDb,e.paths.metaPath),s=Ie(e.paths.metaPath),c=a.state==="legacy"||a.state==="current",u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),d=o&&!o.reused&&c?eo({projectRoot:e.projectRoot,cacheDir:h(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:ve(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:ve(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:bn(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,p=new Set(d?["typescript"]:[]),l=d?void 0:Jd(e,n),{preparedRuns:m,skippedLanguages:g,languageOutputScipPaths:S}=il({languages:e.languages.filter(E=>!i.has(E)&&!p.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:l?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=l?m.filter(E=>E.language!=="typescript"||l.missedProjectIds.has(E.id)):m,P=await ro(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),y=[];if(l){zd(e.paths.outputDb,P);let E=S.typescript??e.tempPaths.tempOutputScip;y=Yd({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:E,reusedProjects:l.reusedProjects})}let I=[...P,...y],{indexedOutputs:w}=al(I,g),Pe=d?[{language:"typescript",scipPath:d.scipPath}]:[],vn=[...r,...Pe,...w];sl(vn,g,e.languages,e.opts.allowPartial,e.onStatus);let Jo=d?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:d.scipPath,outputScipPath:d.scipPath,durationMs:d.durationMs,command:"watch-service:typescript-index",outputBytes:xe(d.scipPath)??void 0}]:[],qo=Qd(n,[...P,...Jo],l?{outputDb:e.paths.outputDb,classification:l.classification}:void 0);return{indexedOutputs:vn,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:Kd(n,e.languages),shards:qo,typescriptProjectShardContext:l?{projects:l.allProjects,fingerprints:l.fingerprints}:void 0,incrementalTypeScript:d??void 0}}function Jd(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=Se(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=jr(e.projectRoot,r),o=Dr(n.fingerprint.files,r),a=Fr(r,i),s=Or(r,o,a),c=Ie(e.paths.metaPath),d=qd(c,s,g=>O(ot(e.paths.outputDb,g))),p=[...d.entries()].filter(([,g])=>g.reused).map(([g])=>g),l=new Set(p),m=new Set(r.filter(g=>!l.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:d,reusedProjects:p,missedProjectIds:m}}function qd(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let a=e.typescriptProjectShards?.[i];if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if(L(a)!==L(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function zd(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=ot(e,r);nt(h(i),{recursive:!0}),rt(n.scipPath,i)}}function Yd(e){return e.reusedProjects.map((t,n)=>{let r=ot(e.outputDb,t),i=ve(e.tempOutputScip,"typescript-project-cached",n);return rt(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:xe(i)??void 0}})}function Xd(e){let t=Ie(e.paths.metaPath),n=Bo(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Rn(e.paths.outputDb,i),a=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a,scipPath:o});continue}if(t.version!==3){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:a,scipPath:o});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:a,scipPath:o});continue}if(!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:a,scipPath:o});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:a,scipPath:o});continue}if(!O(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:o});continue}if(L(s)!==L(a)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:a,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:a,scipPath:o})}return r}function Qd(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:be(o.fingerprint),outputBytes:xe(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),a=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=a?n.classification.get(a):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??o?.reason??i.skipped?.reason,fingerprint:s?be(s.fingerprint):o?be(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:be(o.fingerprint),outputBytes:xe(ot(n.outputDb,i)),durationMs:0});return r}function be(e){return Dd("sha256").update(L(e)).digest("hex").slice(0,16)}function xe(e){try{return Cd(e).size}catch{return null}}function Kd(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function Zd(e,t,n,r,i,o,a,s){let c=!s||s.completeScipUpdated,u=!1;c&&(Do(e.paths.outputDb,n),u=Fo(n,e.tempPaths.tempOutputScip,e.onStatus));let d=cl({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:u,materializeFullFallback:()=>{if(!s||s.completeScipUpdated)return u;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),to({cacheDir:h(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let y=n.map(I=>I.language==="typescript"?{language:I.language,scipPath:s.candidateScipPath}:I);return Do(e.paths.outputDb,y),u=Fo(y,e.tempPaths.tempOutputScip,e.onStatus),u}});if($(H(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),d.mode==="incremental"&&s){let y=null,I=null;try{y=new W({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),I=new W({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let w=_n(y,e.fingerprint,s.referenceFragmentsByFile,I);e.onStatus(`Cached exact TypeScript reference fragments for ${w} affected document(s).`)}catch(w){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${w instanceof Error?w.message:String(w)}.`)}finally{y?.close(),I?.close()}}let p=bn(e.paths.metaPath),l=d.mode==="incremental"&&s?dl(s,d.changedDocumentPaths):Rt({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"}),m=at({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(y=>y.language),skipped:[...r]}),g=d.mode==="incremental"&&d.scipCompanion==="deferred",S={...o};g&&delete S.typescript;let{metadata:b,pruneProjects:P}=Mo({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:S,typescriptProjectShardContext:a,lastRefresh:m});return b.scipCompanion=g?"deferred":"current",No(e.paths.outputDb,P),xn(e.tempPaths.tempMetaPath,b),He({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:d.mode==="incremental"&&d.scipCompanion==="deferred",publication:d.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:d.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:d.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:d.patchDurationMs,scipCompanion:d.scipCompanion,...d.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:d.converterDurationMs,scipCompanion:"current",...d.fallbackReason?{fallbackReason:d.fallbackReason}:{}}}),si(h(e.paths.outputDb),d.mode==="incremental"&&d.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),Lo(e.paths.outputDb,l,e.onStatus),m}function el(e,t,n,r,i,o){let a=bn(e.paths.metaPath),s=null;try{rt(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(p){s=rr("reused","oracle-error",`Could not snapshot the prior database: ${p instanceof Error?p.message:String(p)}`)}$(H(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),s??=Rt({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,refreshResult:"reused"});let c=at({trigger:e.opts.trigger,result:"reused",start:e.start,languages:t.map(p=>p.language),skipped:[...n]}),{metadata:u,pruneProjects:d}=Mo({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:c});return No(e.paths.outputDb,d),xn(e.paths.metaPath,u),Si(e.paths.outputDb,e.paths.metaPath),Lo(e.paths.outputDb,s,e.onStatus),c}function bn(e){return Tn(Ie(e)?.fingerprint)}function Lo(e,t,n){try{ir(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 Mo(e){let t=tl({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:3,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 tl(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=Ie(e.metaPath)?.typescriptProjectShards;return{field:t,pruneProjects:t?Object.keys(t):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function No(e,t){let n=Uo(e);if(t===null){M(n,{recursive:!0,force:!0});return}let r;try{r=Ao(n)}catch{return}for(let i of nl(r,t))M(x(n,i),{force:!0})}function nl(e,t){let n=new Set(t.map(r=>`${_t(r)}.scip`));return e.filter(r=>!n.has(r))}function Do(e,t){for(let n of t){let r=Rn(e,n.language);nt(h(r),{recursive:!0}),n.scipPath!==r&&rt(n.scipPath,r)}}async function rl(e,t){if(!gt()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
296
|
-
Install from: https://github.com/sourcegraph/scip/releases`);if(
|
|
297
|
-
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function
|
|
290
|
+
`).get();return{version:3,tsconfig:n,files:Be(t),db:r}}function fl(e){let t=Qo();return{projectRoot:e.projectRoot,context:Uo(e.projectRoot,e.configPath),symbolLookup:Bo(e.db,e.projectRoot,t),vueSymbolLookup:e.vueSymbolLookup,sourceReader:t}}function ml(e){let t=[],n=ce(),r=e.tasks??e.vueFiles.map(i=>({fileName:i,startOffset:0,endOffset:Number.POSITIVE_INFINITY,countFileSkip:!0}));for(let i of r){let o=hl(e,i);t.push(...o.occurrences),lt(n,o)}return{occurrences:t,...n}}function hl(e,t){let n=e.sourceReader.get(t.fileName);if(!n)return Zo(e.projectRoot,t,"missing-source-file");let r=e.context.language.scripts.get(t.fileName),i=r?.generated?.languagePlugin.typescript?.getServiceScript(r.generated.root)?.code;if(!r||!i)return Zo(e.projectRoot,t,"missing-service-script");let o=e.context.language.maps.get(i,r),a=N(e.projectRoot,t.fileName),s=[...Jo(n.text)],c={tokens:s.filter(u=>u.start>=t.startOffset&&u.start<t.endOffset),tokenByStart:new Map(s.map(u=>[u.start,u])),tokenTextCounts:Pl(s),processedStarts:new Set};return yl({...e,fileName:t.fileName,sourceInfo:n,sourceFile:a,map:o,tokenContext:c})}function yl(e){let t=[],n=ce();for(let r of e.tokenContext.tokens){if(e.tokenContext.processedStarts.has(r.start)||Sl(e.sourceInfo.text,r.start))continue;let i=Yo(e.map,r.start);if(i===null)continue;let a=(e.context.languageService.getDefinitionAtPosition(e.fileName,i+1)??[]).find(d=>!Xo(e.projectRoot,d.fileName));if(!a){Vn(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"no-definition");continue}let s=N(e.projectRoot,a.fileName),c=bl(e.sourceFile,r.text,s);if(c){Vn(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,c);continue}let u=qo(a,e.symbolLookup,e.vueSymbolLookup,e.context,e.projectRoot);if(u===null){Vn(n,e.sourceReader,e.sourceInfo,e.sourceFile,r,"unindexed-definition");continue}ua(t,e.sourceReader,e.sourceInfo,e.sourceFile,r,s,u),e.tokenContext.processedStarts.add(r.start),vl(t,e,r,i,s,u)}return{occurrences:t,...n}}function Sl(e,t){let n=e.lastIndexOf(`
|
|
291
|
+
`,t-1)+1,r=e.slice(n,t);return/\bfrom\s+['"][^'"]*$/.test(r)||/\bimport\s*\(\s*['"][^'"]*$/.test(r)}function bl(e,t,n){return n===e?"same-file-definition":n.endsWith(".vue")&&t!==n.split("/").at(-1)?.replace(/\.vue$/,"")?"unindexed-definition":null}function Zo(e,t,n){let r=ce();return t.countFileSkip&&(r.skippedReferences=1,r.skippedReferenceReasons[n]=1,r.skippedReferenceSamples.push({sourceFile:N(e,t.fileName),sourceLine:0,sourceStartChar:0,sourceEndChar:0,token:"",reason:n})),{occurrences:[],...r}}function Vn(e,t,n,r,i,o){if(e.skippedReferences++,e.skippedReferenceReasons[o]++,e.skippedReferenceSamples.filter(s=>s.reason===o&&s.sourceFile===r).length>=2)return;let a=t.positionAt(n,i.start);e.skippedReferenceSamples.push({sourceFile:r,sourceLine:a.line,sourceStartChar:a.character,sourceEndChar:a.character+i.text.length,token:i.text,reason:o})}function Gn(e,t){let n=new Map;for(let o of e){let a=n.get(o.sourceFile)??[];a.push(o),n.set(o.sourceFile,a)}let r=[...n.keys()].sort(),i=[];for(let o=0;i.length<t;o++){let a=!1;for(let s of r){let c=n.get(s)?.[o];if(c&&(i.push(c),a=!0,i.length===t))break}if(!a)break}return i}function Rl(e,t){let n=Gn(e.filter(o=>o.sourceFile!==o.definitionFile),Math.ceil(t/2)),r=new Set(n.map(o=>`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),i=Gn(e.filter(o=>!r.has(`${o.sourceFile}:${o.sourceLine}:${o.sourceStartChar}:${o.sourceEndChar}:${o.symbolId}`)),t-n.length);return[...n,...i]}function xl(e,t){let n=[...new Set(e.map(i=>i.reason))].sort(),r=[];for(let[i,o]of n.entries()){let a=n.length-i,s=Math.ceil((t-r.length)/a);r.push(...Gn(e.filter(c=>c.reason===o),s))}return r.slice(0,t)}function Il(e,t,n){let r=e.prepare("SELECT symbol FROM global_symbols WHERE id = ?");return Rl(t,n).map(({symbolId:i,...o})=>({...o,definitionSymbol:r.get(i)?.symbol??`symbol-id:${i}`}))}function vl(e,t,n,r,i,o){if(!((t.tokenContext.tokenTextCounts.get(n.text)??0)<=1))for(let a of wl(t.context.languageService,t.fileName,r+1,t.map,n,t.tokenContext.tokenByStart)){if(t.tokenContext.processedStarts.has(a))continue;let s=t.tokenContext.tokenByStart.get(a);s&&(ua(e,t.sourceReader,t.sourceInfo,t.sourceFile,s,i,o),t.tokenContext.processedStarts.add(a))}}function ua(e,t,n,r,i,o,a){let s=t.positionAt(n,i.start);e.push({sourceFile:r,sourceLine:s.line,sourceStartChar:s.character,sourceEndChar:s.character+i.text.length,sourceToken:i.text,definitionFile:o,symbolId:a})}function Pl(e){let t=new Map;for(let n of e)t.set(n.text,(t.get(n.text)??0)+1);return t}function wl(e,t,n,r,i,o){let a=e.getDocumentHighlights?.(t,n,[t])??[],s=[];for(let c of a)if(c.fileName===t)for(let u of c.highlightSpans){let d=kl(r,u.textSpan.start,o,i.text);d!==null&&s.push(d)}return s}function kl(e,t,n,r){let i=n.get(t);if(i?.text===r)return i.start;let o=$n(e,t);if(o===null)return null;let a=n.get(o);return a?.text===r?a.start:null}async function vh(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,o=_l(e),a=Date.now(),s=y();gt(S(o.outputScip),{recursive:!0}),gt(S(o.outputDb),{recursive:!0});let c=e.languages??Vt(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 u=fe("reindex.fingerprint",()=>cr(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),d,l;if(e.skipIfUnchanged!==!1&&!so(t,o.outputDb)&&da(o.outputScip)===da(k(S(o.outputDb),"index.scip"))){let m=We(t);if(d=m?at(m,u):void 0,d){let b=M(d);if(b){if(!jl(o,u))try{Pn({snapshot:d,manifest:b,targetCacheDir:S(o.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${d.generationId.slice(0,12)}`)}catch(P){r(`Shared generation attach failed; continuing locally: ${de(P)}`)}}else{let P=await uo(d);if(P.kind==="owner")l=P.release;else if(P.kind==="generation-ready"){let x=M(d);if(x)try{Pn({snapshot:d,manifest:x,targetCacheDir:S(o.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${d.generationId.slice(0,12)} after waiting`)}catch(v){r(`Shared generation attach failed after waiting; continuing locally: ${de(v)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=be(k(S(o.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw l?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${S(o.outputDb)}.`);let f;try{f=await me("reindex.lock",()=>sp(k(S(o.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(m){throw p.release(),l?.(),m}let g=null;try{Sn(o.outputDb,o.outputScip,o.metaPath);let m=Nl(S(o.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let V of m.errors)r(`Could not remove abandoned reindex workspace: ${V}`);let b=null,P=fe("reindex.reuse-check",()=>(b=Cl({opts:e,paths:o,languages:c,fingerprint:u,start:a,monotonicStart:s,onStatus:r}),b),()=>({languages:c.length,reused:b!==null}));if(P)return la({snapshot:d,paths:o,projectRoot:t,fingerprint:u,onStatus:r}),Ct(o.outputDb,P),P;await me("reindex.scip-cli-ready",()=>Zl(i,r));let x=Ll(o);g=x.runDir;let v,w=await me("reindex.fresh",async()=>(v=await $l({opts:e,languages:c,projectRoot:t,paths:o,tempPaths:x,fingerprint:u,start:a,monotonicStart:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),v),()=>({languages:c.length,reused:v?.reused,skipped:v?.skipped.length}));return la({snapshot:d,paths:o,projectRoot:t,fingerprint:u,onStatus:r}),Ct(o.outputDb,w),w}catch(m){let b=yt({trigger:e.trigger,result:"failed",start:a,monotonicStart:s,error:m instanceof Error?m.message:String(m)});throw Oa(o.metaPath,b),yr(o.outputDb,b),m}finally{g&&ue(g,{recursive:!0,force:!0}),f(),p.release(),l?.()}}function la(e){if(e.snapshot){if(M(e.snapshot)){st(e.snapshot,S(e.paths.outputDb),"local-fresh");return}try{let t=We(e.projectRoot),n=t?at(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}co({snapshot:e.snapshot,sourceCacheDir:S(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=We(e.projectRoot);return(r?at(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),st(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: ${de(t)}`)}}}function jl(e,t){if(!A(e.outputScip)||!A(e.outputDb)||!Aa(e.metaPath,t))return!1;let n=W(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function de(e){return e instanceof Error?e.message:String(e)}function _l(e){let t=e.outputScip??k(e.projectRoot,"index.scip"),n=e.outputDb??k(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:k(S(n),"meta.json")}}function Cl(e){let t=W(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!A(e.paths.outputScip)||!A(e.paths.outputDb)||!Aa(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;C(U(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=y()-e.monotonicStart,r=yt({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return Oa(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:Ml(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Ml(e,t,n,r){let i=Fa(t,n,r);return n.map(o=>({id:o,language:o,reused:!0,fingerprint:_e(i[o]),outputBytes:Ce(Hn(e.outputDb,o)),durationMs:0}))}function Ll(e){let t=Fl(k(S(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:k(t,pt(e.outputScip)),tempOutputDb:k(t,pt(e.outputDb)),tempMetaPath:k(t,pt(e.metaPath))}}function Nl(e){let t=[],n;try{n=Sa(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[de(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{ue(k(e,i.name),{recursive:!0,force:!0}),r+=1}catch(o){t.push(`${i.name}: ${de(o)}`)}return{removed:r,errors:t}}async function $l(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await me("reindex.language-indexers",async()=>(n=await Gl(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:o,reusedLanguages:a,languageFingerprints:s,shards:c,typescriptProjectShardContext:u,incrementalTypeScript:d}=r;if(a.length>0&&e.onStatus(`Reused ${a.length} cached language shard(s): ${a.join(", ")}`),Vl({run:e,indexedOutputs:i,skippedLanguages:o,reusedLanguages:a})){let f=fe("reindex.publish",()=>Xl(e,i,o,a,s,u),{mode:"metadata-only",languages:i.length,reused:a.length}),g=f.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:o,lastRefresh:f,shards:c}}let l=fe("reindex.publish",()=>Yl(e,t,i,o,a,s,u,d),{mode:d?"incremental-or-fallback":"full",languages:i.length,reused:a.length,skipped:o.length}),p=l.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(f=>f.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:o,lastRefresh:l,shards:c}}function Vl(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!A(e.run.paths.outputScip)||!A(e.run.paths.outputDb))return!1;let t=W(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 Gl(e,t){let n=Hl({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[T,Yn]of n)Yn.reused&&(r.push({language:T,scipPath:Yn.scipPath}),i.add(T));for(let T of i)e.onStatus(`Reusing cached ${T} SCIP shard (language inputs unchanged).`);let o=n.get("typescript"),a=W(e.paths.outputDb,e.paths.metaPath),s=Le(e.paths.metaPath),c=a.state==="legacy"||a.state==="current",u=s?.scipCompanion!=="deferred"&&(a.state!=="current"||a.generation.publication?.scipCompanion!=="deferred"),d=o&&!o.reused&&c?To({projectRoot:e.projectRoot,cacheDir:S(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:o.scipPath,candidateShardPath:Me(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:Me(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:u,previousSnapshot:qn(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,l=new Set(d?["typescript"]:[]),p=d?void 0:Ul(e,n),{preparedRuns:f,skippedLanguages:g,languageOutputScipPaths:m}=ep({languages:e.languages.filter(T=>!i.has(T)&&!l.has(T)),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?f.filter(T=>T.language!=="typescript"||p.missedProjectIds.has(T.id)):f,P=await Oo(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),x=[];if(p){Wl(e.paths.outputDb,P);let T=m.typescript??e.tempPaths.tempOutputScip;x=ql({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:T,reusedProjects:p.reusedProjects})}let v=[...P,...x],{indexedOutputs:w}=np(v,g),V=d?[{language:"typescript",scipPath:d.scipPath}]:[],Jn=[...r,...V,...w];rp(Jn,g,e.languages,e.opts.allowPartial,e.onStatus);let ja=d?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:d.scipPath,outputScipPath:d.scipPath,durationMs:d.durationMs,command:"watch-service:typescript-index",outputBytes:Ce(d.scipPath)??void 0}]:[],_a=zl(n,[...P,...ja],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:Jn,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:Jl(n,e.languages),shards:_a,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:d??void 0}}function Ul(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=Oe(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=ui(e.projectRoot,r),o=ai(n.fingerprint.files,r),a=si(r,i),s=ci(r,o,a),c=Le(e.paths.metaPath),d=Bl(c,s,g=>A(ht(e.paths.outputDb,g))),l=[...d.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(l),f=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:s,classification:d,reusedProjects:l,missedProjectIds:f}}function Bl(e,t,n){let r=new Map;for(let i of Object.keys(t)){let o=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:o});continue}let a=e.version===le&&bt(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!a){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:o});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:o});continue}if($(a)!==$(o)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:o});continue}r.set(i,{reused:!0,fingerprint:o})}return r}function Wl(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=ht(e,r);gt(S(i),{recursive:!0}),mt(n.scipPath,i)}}function ql(e){return e.reusedProjects.map((t,n)=>{let r=ht(e.outputDb,t),i=Me(e.tempOutputScip,"typescript-project-cached",n);return mt(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Ce(i)??void 0}})}function Hl(e){let t=Le(e.paths.metaPath),n=Fa(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let o=Hn(e.paths.outputDb,i),a=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a,scipPath:o});continue}if(t.version!==le){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:a,scipPath:o});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:a,scipPath:o});continue}if(!bt(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:a,scipPath:o});continue}let s=t.languageFingerprints[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:a,scipPath:o});continue}if(!A(o)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a,scipPath:o});continue}if($(s)!==$(a)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:a,scipPath:o});continue}r.set(i,{reused:!0,fingerprint:a,scipPath:o})}return r}function zl(e,t,n){let r=[];for(let[i,o]of e)o.reused&&r.push({id:i,language:i,reused:!0,fingerprint:_e(o.fingerprint),outputBytes:Ce(o.scipPath),durationMs:0});for(let i of t){let o=e.get(i.language),a=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,s=a?n.classification.get(a):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:s?.reason??o?.reason??i.skipped?.reason,fingerprint:s?_e(s.fingerprint):o?_e(o.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,o]of n.classification)o.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:_e(o.fingerprint),outputBytes:Ce(ht(n.outputDb,i)),durationMs:0});return r}function _e(e){return Tl("sha256").update($(e)).digest("hex").slice(0,16)}function Ce(e){try{return Dl(e).size}catch{return null}}function Jl(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function Yl(e,t,n,r,i,o,a,s){let c=!s||s.completeScipUpdated,u=!1;c&&(pa(e.paths.outputDb,n),u=ga(n,e.tempPaths.tempOutputScip,e.onStatus));let d=ip({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:s,completeScipAvailable:c,completeScipSanitized:u,materializeFullFallback:()=>{if(!s||s.completeScipUpdated)return u;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Fo({cacheDir:S(e.paths.outputDb),generationIdentity:s.nextFragmentGeneration,baseShardPath:s.scipPath,candidateShardPath:s.candidateScipPath});let x=n.map(v=>v.language==="typescript"?{language:v.language,scipPath:s.candidateScipPath}:v);return pa(e.paths.outputDb,x),u=ga(x,e.tempPaths.tempOutputScip,e.onStatus),u}});if(C(U(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),d.mode==="incremental"&&s){let x=null,v=null;try{x=new X({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),v=new X({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let w=pr(x,e.fingerprint,s.referenceFragmentsByFile,v);e.onStatus(`Cached exact TypeScript reference fragments for ${w} affected document(s).`)}catch(w){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${w instanceof Error?w.message:String(w)}.`)}finally{x?.close(),v?.close()}}let l=qn(e.paths.metaPath),p=d.mode==="incremental"&&s?ap(s,d.changedDocumentPaths):$t({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:l,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),f=yt({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(x=>x.language),skipped:[...r]}),g=d.mode==="incremental"&&d.scipCompanion==="deferred",m={...o};g&&delete m.typescript;let{metadata:b,pruneProjects:P}=xa({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:m,typescriptProjectShardContext:a,lastRefresh:f});return b.scipCompanion=g?"deferred":"current",Ia(e.paths.outputDb,P),zn(e.tempPaths.tempMetaPath,b),ot({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:d.mode==="incremental"&&d.scipCompanion==="deferred",publication:d.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:d.converterDurationMs,affectedDocumentCount:s?.affectedFiles.length,changedDocumentCount:d.changedDocumentPaths.length,producerDurationMs:s?.timings.serviceMs,materializationDurationMs:s?.durationMs,patchDurationMs:d.patchDurationMs,scipCompanion:d.scipCompanion,...d.scipCompanion==="deferred"&&s?{typescriptOverlayGeneration:s.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:d.converterDurationMs,scipCompanion:"current",...d.fallbackReason?{fallbackReason:d.fallbackReason}:{}}}),Ni(S(e.paths.outputDb),d.mode==="incremental"&&d.scipCompanion==="deferred"?[s.nextFragmentGeneration]:[]),Ra(e.paths.outputDb,p,e.onStatus),f}function Xl(e,t,n,r,i,o){let a=qn(e.paths.metaPath),s=null;try{mt(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(l){s=Dr("reused","oracle-error",`Could not snapshot the prior database: ${l instanceof Error?l.message:String(l)}`)}C(U(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),s??=$t({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:a,currentSnapshot:e.fingerprint,refreshResult:"reused"});let c=yt({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(l=>l.language),skipped:[...n]}),{metadata:u,pruneProjects:d}=xa({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:o,lastRefresh:c});return Ia(e.paths.outputDb,d),zn(e.paths.metaPath,u),Yi(e.paths.outputDb,e.paths.metaPath),Ra(e.paths.outputDb,s,e.onStatus),c}function qn(e){return Qn(Le(e)?.fingerprint)}function Ra(e,t,n){try{Ar(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 xa(e){let t=Ql({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:le,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 Ql(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=Le(e.metaPath),n=t?.version===le?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 Ia(e,t){let n=Da(e);if(t===null){ue(n,{recursive:!0,force:!0});return}let r;try{r=Sa(n)}catch{return}for(let i of Kl(r,t))ue(k(n,i),{force:!0})}function Kl(e,t){let n=new Set(t.map(r=>`${en(r)}.scip`));return e.filter(r=>!n.has(r))}function pa(e,t){for(let n of t){let r=Hn(e,n.language);gt(S(r),{recursive:!0}),n.scipPath!==r&&mt(n.scipPath,r)}}async function Zl(e,t){if(!Ot()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
292
|
+
Install from: https://github.com/sourcegraph/scip/releases`);if(Ol()==="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 with optional dependencies enabled, run 'npm install -g scip-query-scip-windows', or set SCIP_QUERY_SCIP_BIN to a local scip.exe path.");if(t("scip CLI not found on PATH. Attempting auto-install..."),!jt(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
293
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function ep(e){let t=[],n=[],r=e.languages.map((o,a)=>({language:o,scipPath:e.languages.length>1?Me(e.tempOutputScip,o,a):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:o,scipPath:a})=>[o,a]));for(let{language:o,scipPath:a}of r){let s=tp({...e,language:o,scipPath:a});for(let c of s)"skipped"in c?va(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function tp(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[Un({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??Oe(e.projectRoot,e.typescriptProjects);return t.length===0?[Un({...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)=>Un({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:Me(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function Un(e){let t=ze(e.language),n=he(t),r=wt(t,e.projectRoot);if(!r&&!Pt(t)){if(e.skipAutoInstall){let s=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${s}`),{skipped:{language:e.language,reason:s}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!_n(t,e.onStatus)){let s=`${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}: ${s}`),{skipped:{language:e.language,reason:s}}}}let i=r??ye(t);if(!i){let s=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${s}`),{skipped:{language:e.language,reason:s}}}let{binary:o,args:a}=t.indexArgs({projectRoot:e.projectRoot,outputPath:e.scipPath,pnpmWorkspaces:e.pnpmWorkspaces,indexerBinary:i,projectPath:e.projectPath,configPath:e.language==="clojure"?e.clojureConfigPath:void 0});return{prepared:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,config:t,resolvedBinary:i,binary:o,args:a,env:kt(t,e.env,i)}}}function np(e,t){let n=new Map;for(let i of e)if(i.skipped)va(t,i.skipped);else{let o=`${i.language}\0${i.outputScipPath}`,a=n.get(o)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};a.scipPaths.push(i.scipPath),n.set(o,a)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Jt(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let o=i.scipPaths[0];o!==i.outputScipPath&&ba(o,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function va(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 rp(e,t,n,r,i){if(e.length===0){let o=t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
298
294
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
299
295
|
`+o)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(o=>o.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.
|
|
300
296
|
`+t.map(o=>` - ${o.language}: ${o.reason}`).join(`
|
|
301
|
-
`))}function
|
|
302
|
-
`),()=>{try{Fd(n)}finally{M(e,{force:!0})}}}function gl(e){try{let t=JSON.parse(it(e,"utf-8"));return typeof t.pid!="number"||!Number.isInteger(t.pid)||t.pid<=0?null:{version:1,pid:t.pid,projectRoot:typeof t.projectRoot=="string"?t.projectRoot:h(e),startedAt:typeof t.startedAt=="string"?t.startedAt:"unknown",trigger:t.trigger}}catch{return null}}function fl(e,t){return e?.kind==="manual-cli"&&ml(t?.trigger)}function ml(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function hl(e){return jo(e,"SIGTERM"),await Co(e,2e3)?!0:(jo(e,"SIGKILL"),Co(e,1e3))}function jo(e,t){try{process.kill(-e,t)}catch{try{process.kill(e,t)}catch{}}}async function Co(e,t){let n=Date.now()+t;for(;Date.now()<n;){if(!T(e))return!0;await yl(50)}return!T(e)}function yl(e){return new Promise(t=>setTimeout(t,e))}function Bo(e,t,n){return Object.fromEntries(t.map(r=>{let i=Ce(r).markerFiles,o=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:Dn(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},a=r==="clojure"?Sl(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&bl(n),...o,clojureConfigPath:a,files:Te(e,{language:r,markerFiles:i})}]}))}function Sl(e){return e?.trim()||void 0}function bl(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Rn(e,t){return x(h(e),"language-indexes",`${t}.scip`)}function Uo(e){return x(h(e),"language-indexes","typescript-projects")}function ot(e,t){return x(Uo(e),`${_t(t)}.scip`)}function Ie(e){try{return JSON.parse(it(e,"utf-8"))}catch{return null}}function Wo(e,t){try{let n=JSON.parse(it(e,"utf-8"));return(n.version===2||n.version===3)&&n.status==="complete"&&L(n.fingerprint)===L(t)&&L([...n.indexedLanguages??[]].sort())===L(t.languages)}catch{return!1}}function xn(e,t){R(e,t,{spacing:2,trailingNewline:!0})}function Ho(e,t){try{let n=JSON.parse(it(e,"utf-8"));if(n.version!==2&&n.version!==3)return;xn(e,{...n,lastRefresh:t})}catch{}}function at(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:Date.now()-e.start,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function L(e){return JSON.stringify(e)}export{pr as INDEXER_CONFIGS,Qn as augmentAuxiliaryDocuments,dd as augmentVueResolvedReferences,H as auxiliaryDocumentsAugmentationStage,ne as describeIndexerBinary,xt as detectLanguages,Ce as getIndexerConfig,dt as getIndexerExecutionEnv,st as isBinaryAvailable,ct as isIndexerInstalled,Dt as mergeScipFiles,Tt as mergeScipIndexes,pm as reindex,re as resolveIndexerBinary,ut as resolveProjectLocalIndexerBinary,$ as runPostIndexAugmentation,ln as tryInstallIndexer,ft as tryInstallScipCli,wo as vueResolvedReferencesAugmentationStage};
|
|
297
|
+
`))}function ga(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=Wr(e.map(o=>o.scipPath),t);return wa(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&ba(e[0].scipPath,t);return!1}function ip(e){let t;if(op(e)){let i=k(e.run.tempPaths.runDir,"typescript-affected.db");try{Pa(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let o=performance.now();fa(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-o).toFixed(0)}ms.`);let a=Kr({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${a.affectedDocumentCount} SQLite document(s) in ${(a.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:a.changedDocumentPaths,patchDurationMs:a.durationMs,converterDurationMs:performance.now()-o,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(o){t=o instanceof Error?o.message:String(o),ue(i,{force:!0}),ue(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 fa(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function op(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!A(e.run.paths.outputDb)||!A(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 ap(e,t){let n=y(),r=[...t].sort(),i=new Set(r),o={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(a=>!i.has(a)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:y()-n,manifest:e.manifest,plan:e.plan,comparison:o,evaluation:Nt(e.plan,o,e.projectFileCount)}}function fa(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!A(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||Pa(e,r);let o=Ot();if(!o)throw new Error("scip CLI is not available");El(o,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(o){let a=o instanceof Error?o.message:String(o);throw new Error(`Failed to convert SCIP index to SQLite: ${a}`,{cause:o})}}function Pa(e,t){let n=Ur(e);wa(n,t)}function wa(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function Me(e,t,n){let r=Al(e)||".scip",i=pt(e,r);return k(S(e),`${i}.${n+1}.${t}${r}`)}async function sp(e,t){for(let n=0;n<2;n++){let r=cp(e,t);if(r)return r;let i=up(e);if(i&&Ta(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let o;try{o=await lp(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: ${de(s)}`,{cause:s})}if(!o)throw new Error(`Could not confirm the watcher's in-progress reindex (pid ${i.pid}) terminated for ${S(e)}; refusing to steal an active lock.`);let a=_t(e,{parseLegacy:ft});if(!fr(e,a,{parseLegacy:ft}))throw new Error(`Reindex lock ownership changed before preemption completed for ${S(e)}.`);continue}throw new Error(`Another scip-query reindex is already running for ${S(e)}.`)}throw new Error(`Could not acquire scip-query reindex lock for ${S(e)}.`)}function cp(e,t){let n=re(process.pid),r=oe(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:ft});if(r.kind==="acquired"&&r.reclaimed){let i=ka(r.reclaimed,e);i&&Ta(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 ${S(e)}.`)}return r.kind==="acquired"?()=>{r.lock.release()}:null}function up(e){return ka(_t(e,{parseLegacy:ft}),e)}var ft=e=>{let t=Ea(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function ka(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:S(t),startedAt:e.record.startedAt,trigger:n.trigger}}return Ea(e.parsed,t)}function Ea(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=rr(n.processIdentity);return r?.pid===n.pid?{processIdentity:r}:{}})(),...n.processGroupLeader===!0?{processGroupLeader:!0}:{},projectRoot:typeof n.projectRoot=="string"?n.projectRoot:S(t),startedAt:typeof n.startedAt=="string"?n.startedAt:"unknown",trigger:n.trigger}}catch{return null}}function Ta(e,t){return e?.kind==="manual-cli"&&dp(t?.trigger)}function dp(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function lp(e){return!ne(e.pid)||(Bn(e),ma(e,"SIGTERM"),await ha(e,2e3))?!0:(Bn(e),ma(e,"SIGKILL"),ha(e,1e3))}function ma(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!ne(e.pid))return;Bn(e)}try{process.kill(e.pid,t)}catch{}}async function ha(e,t){let n=y()+t;for(;y()<n;){if(ya(e))return!0;await pp(50)}return ya(e)}function Bn(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=re(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!Se(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function ya(e){if(!ne(e.pid))return!0;if(!e.processIdentity)return!1;let t=re(e.pid);return t!==null&&!Se(e.processIdentity,t)}function pp(e){return new Promise(t=>setTimeout(t,e))}function Fa(e,t,n){return Object.fromEntries(t.map(r=>{let i=ze(r).markerFiles,o=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:sr(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},a=r==="clojure"?gp(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&fp(n),...o,clojureConfigPath:a,files:Be(e,{language:r,markerFiles:i})}]}))}function gp(e){return e?.trim()||void 0}function fp(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function Hn(e,t){return k(S(e),"language-indexes",`${t}.scip`)}function Da(e){return k(S(e),"language-indexes","typescript-projects")}function ht(e,t){return k(Da(e),`${en(t)}.scip`)}function Le(e){try{return St(G(Wn(e,"utf-8")))}catch{return null}}function Aa(e,t){try{let n=G(Wn(e,"utf-8"));if(n.kind!=="legacy"&&n.kind!=="supported")return!1;let r=n.metadata;return n.capabilities.publishableGeneration&&$(r.fingerprint)===$(t)&&$([...r.indexedLanguages??[]].sort())===$(t.languages)}catch{return!1}}function zn(e,t){F(e,t,{spacing:2,trailingNewline:!0})}function Oa(e,t){try{let n=St(G(Wn(e,"utf-8")));if(!n)return;zn(e,{...n,lastRefresh:t})}catch{}}function yt(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:y()-e.monotonicStart,indexedLanguages:e.languages?[...e.languages]:void 0,skipped:e.skipped?[...e.skipped]:void 0,error:e.error}}function $(e){return JSON.stringify(e)}export{Vr as INDEXER_CONFIGS,kr as augmentAuxiliaryDocuments,cl as augmentVueResolvedReferences,ul as augmentVueResolvedReferencesAsync,U as auxiliaryDocumentsAugmentationStage,he as describeIndexerBinary,Vt as detectLanguages,ze as getIndexerConfig,kt as getIndexerExecutionEnv,vt as isBinaryAvailable,Pt as isIndexerInstalled,Jt as mergeScipFiles,zt as mergeScipIndexes,vh as reindex,ye as resolveIndexerBinary,wt as resolveProjectLocalIndexerBinary,C as runPostIndexAugmentation,_n as tryInstallIndexer,jt as tryInstallScipCli,oa as vueResolvedReferencesAugmentationStage};
|
|
303
298
|
//# sourceMappingURL=reindex.js.map
|