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-worker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as ae,b as se}from"./chunk-VEVBIAOJ.js";import{a as cn}from"./chunk-P5XHIJHI.js";import{Ba as de,Ca as tn,Ea as nn,Ga as rn,Ha as Te,I as wt,J as _t,Ja as an,Ka as sn,L as q,La as on,N as jt,R as Dt,S as kt,T as Tt,U as Mt,V as Ot,W as At,Y as _e,Z as Lt,b as B,c as ne,d as ve,e as Ee,ea as Nt,f as re,fa as Ct,ga as $t,ha as Bt,ia as Gt,ja as Ut,k as gt,ka as Jt,la as Ht,m as ht,ma as Wt,na as qt,o as k,oa as zt,p as H,pa as z,qa as oe,r as vt,ra as Xt,t as Et,ta as ce,u as Ft,ua as Vt,v as ie,va as je,w as W,wa as Yt,xa as De,za as ke}from"./chunk-UXP636P5.js";import{a as ee,b as ct,c as te,e as yt,f as St,g as bt,i as Rt,j as It,m as j}from"./chunk-VOQFGC2W.js";import{g as pt,h as J,i as M,j as O,l as ft,m as we,n as mt,p as Pt,q as xt,s as Qt,v as Kt,w as Zt,x as en}from"./chunk-VKRQDBW5.js";import{e as w,f as G}from"./chunk-HGFDYOVB.js";import{a as P}from"./chunk-APMMR5Y2.js";import{a as U,b as dt,c as lt,d as Fe,e as ut}from"./chunk-HELS7KFF.js";import{execFileSync as Ja}from"child_process";import{createHash as Ha}from"crypto";import{copyFileSync as xe,existsSync as F,mkdirSync as be,mkdtempSync as Wa,readdirSync as gr,readFileSync as nt,renameSync as fr,rmSync as C,statSync as qa}from"fs";import{basename as Se,dirname as S,extname as za,join as I,resolve as ar}from"path";import{platform as Xa}from"os";import{execFileSync as ln}from"child_process";import{existsSync as Me,readFileSync as Nr}from"fs";import{createRequire as Cr}from"module";import{platform as un}from"os";import{dirname as dn,join as le}from"path";var $r=Cr(import.meta.url),A={language:"rust",indexerBinary:"rust-analyzer",installUrl:"https://github.com/rust-lang/rust-analyzer"};function Oe(e){return[e.indexerBinary,...e.binaryAliases??[]]}function ue(e){let t=Oe(e);return t.length===1?t[0]:t.join(" or ")}function X(e){for(let t of Oe(e))if(un()==="win32"){let n=lt(t);if(n)return n}else if(U(t))return t;return Gr(e)}function pn(e){return X(e)!==null||Br(e)}function Br(e){return gn(e)!==null}function Gr(e){let t=gn(e);if(!t)return null;let r=JSON.parse(Nr(t,"utf8")).bin;if(!r)return null;if(typeof r=="string")return le(dn(t),r);for(let i of Oe(e)){let a=r[i];if(a)return le(dn(t),a)}return null}function gn(e){if(!e.bundledNpmPackage)return null;try{return $r.resolve(`${e.bundledNpmPackage}/package.json`)}catch{return null}}function fn(e,t){for(let n of e.projectLocalBinaries??[]){let r=le(t,n);if(Me(r))return r}return null}function mn(e,t=process.env,n=e.indexerBinary){if(e.indexerBinary!=="scip-dotnet"||hn(n,t))return t;let r=Ur(n,t);return r?{...t,DOTNET_ROOT:r}:t}function Ur(e,t){for(let n of Jr(t))if(hn(e,{...t,DOTNET_ROOT:n}))return n;return null}function Jr(e){let t=[],n=e.DOTNET_ROOT;if(n&&Me(n)&&t.push(n),un()==="darwin"&&U("brew"))try{let r=ln("brew",["--prefix","dotnet@9"],{stdio:"pipe",env:e,timeout:1e4,killSignal:"SIGKILL"}).toString().trim(),i=le(r,"libexec");Me(i)&&!t.includes(i)&&t.push(i)}catch{}return t}function hn(e,t){try{return ln(e,["--version"],{stdio:"pipe",env:t,timeout:1e4,killSignal:"SIGKILL"}),!0}catch{return!1}}var yn=Ft({kind:"file-dependency-graph",invalidation:ie("file-dependency-graph"),serialize:e=>JSON.stringify(e),deserialize:Yr}),Hr=Rt("file-dep-graph",{clearGroups:["whole-project"]});function L(e,t,n={}){let r=n.scipEdges??"all-references",i=n.sourceEdges??"imports-only",a=zr(t,r,i);return Hr.get(e,a,()=>{let s=new Set(j(e,{includeIgnored:!1})),o=vt(e),c=0,d=0,l=null,u=!1,p=0,h=0;return w("file-dep-graph.product",()=>{if(o){let f=yn.read(e,a,o);if(f){u=!0;let y=Vr(f);return c=f.sourceFileCount,d=f.sourceEdgeCount,p=f.scipEdgeCount,h=y.size,l=f.sourceDependencyFingerprint,y}}let g=w("file-dep-graph.source-imports",()=>{let f=Wr(e,s,t,i);return c=f.files.length,d=f.edges.length,l=f.fingerprint,f},()=>({scope:t??null,sourceEdges:i,files:c,edges:d})),m=new Map,b=(f,y)=>ei(e,m,s,f,y);w("file-dep-graph.scip-edges",()=>{for(let f of Zr(e,t,r))p+=1,b(f.from_file,f.to_file)},()=>({scope:t??null,edges:p}));for(let f of g.edges)b(f.fromFile,f.toFile);return h=m.size,o&&yn.write(e,a,o,{sourceDependencyFingerprint:g.fingerprint,sourceFileCount:g.files.length,sourceEdgeCount:g.edges.length,scipEdgeCount:p,graph:Xr(m)}),m},()=>({scope:t??null,available:o!==null,hit:u,files:c,sourceEdges:d,sourceEdgeMode:i,scipEdges:p,graphFiles:h,sourceDependencyFingerprint:l}))})}function Wr(e,t,n,r){let i=[],a=[];for(let s of t)if(!(n&&!s.includes(n))){i.push(s);for(let o of _t(e,s))o.sourcePath&&a.push({fromFile:s,toFile:o.sourcePath});if(r==="imports-and-reexports")for(let o of wt(e,s))o.sourcePath&&a.push({fromFile:s,toFile:o.sourcePath})}return{files:i,edges:a,fingerprint:qr(i,a)}}function qr(e,t){let n=t.map(r=>`${r.fromFile}\0${r.toFile}`).sort();return H(JSON.stringify({files:e,edges:n}))}function zr(e,t,n){return`edge-mode-v3:${t}:${n}:${e??"<all>"}`}function Xr(e){return[...e].map(([t,n])=>[t,[...n]])}function Vr(e){return new Map(e.graph.map(([t,n])=>[t,new Set(n)]))}function Yr(e){let t=JSON.parse(e);return Qr(t)?t:null}function Qr(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.sourceDependencyFingerprint=="string"&&typeof t.sourceFileCount=="number"&&typeof t.sourceEdgeCount=="number"&&typeof t.scipEdgeCount=="number"&&Array.isArray(t.graph)&&t.graph.every(Kr)}function Kr(e){return Array.isArray(e)&&e.length===2&&typeof e[0]=="string"&&Array.isArray(e[1])&&e[1].every(t=>typeof t=="string")}function Zr(e,t,n){let r=t?"AND d1.relative_path LIKE ?":"",i=t?[`%${t}%`]:[],a=n==="imports-only"?"AND m.role = 2":"AND m.role != 1";return e.all(`SELECT DISTINCT
|
|
2
2
|
d1.relative_path AS from_file,
|
|
3
3
|
d2.relative_path AS to_file
|
|
4
4
|
FROM mentions m
|
|
@@ -16,7 +16,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
16
16
|
WHERE d1.id != d2.id
|
|
17
17
|
${a}
|
|
18
18
|
${e.pathExclusionsFor("d1","d2")}
|
|
19
|
-
${r}`,...i)}function
|
|
19
|
+
${r}`,...i)}function ei(e,t,n,r,i){if(r===i||e.isIgnored(r)||e.isIgnored(i)||!n.has(i))return;let a=t.get(r);a||(a=new Set,t.set(r,a)),a.add(i)}function ge(e){let t=pe(e.projectFiles),n=new Set(t),r=new Map(e.snapshot.files.map(u=>[u.path,u])),i=e.snapshot.files.filter(u=>{let p=ee(u.path,["typescript"]);return p==="config"||p==="ambient"}).map(u=>u.path),a=pe([...t,...i]),s=a.find(u=>!r.has(u)),o=new Set(e.snapshot.files.map(u=>u.path)).size!==e.snapshot.files.length,c=!s&&a.some(u=>Sn(r.get(u))),d=H(JSON.stringify({pnpmWorkspaces:e.snapshot.pnpmWorkspaces,typescriptProjectMode:e.snapshot.typescriptProjectMode,typescriptProjects:pe(e.snapshot.typescriptProjects),membership:t})),l=new Map;return{identityFor(u,p){if(!n.has(u))return N("target-outside-project");if(o)return N("duplicate-input-path");if(s)return N("missing-input-fingerprint");if(c)return N("unreadable-input");let h=[],g,m;if(e.graph===null)h.push("dependency-graph-unavailable"),m="whole-project",g=a;else{let y=ni(u,e.graph,l);if(y.find(R=>!r.has(R)))return N("missing-input-fingerprint");if(g=pe([...y,...i]),g.some(R=>Sn(r.get(R))))return N("unreadable-input");m="dependency-closure"}let b=g.map(y=>ri(r.get(y)));return{version:1,key:H(JSON.stringify({version:1,engineIdentity:e.engineIdentity,schemaVersion:p,projectIdentity:d,inputs:b})),mode:m,inputFiles:g,reasons:h}}}}function ti(e,t){let n=new Set,r=[e];for(let i=0;i<r.length;i+=1){let a=r[i];if(!(a===void 0||n.has(a))){n.add(a);for(let s of[...t.get(a)??[]].sort())n.has(s)||r.push(s)}}return[...n].sort()}function ni(e,t,n){let r=n.get(e);if(r)return r;let i=ti(e,t);return n.set(e,i),i}function ri(e){return{path:e.path,size:e.size,hash:e.hash}}function Sn(e){return e.size<0||e.hash==="unreadable"}function N(e){return{version:1,key:null,mode:"unkeyed",inputFiles:[],reasons:[e]}}function pe(e){return[...new Set(e)].sort()}var io=It("typescript-semantic-identity-context",{clearGroups:["whole-project"]});function bn(e){return j(e,{includeIgnored:!1}).filter(q).sort()}var ii="typescript-reference-fragment-v2",ai=Et({kind:"typescript-reference-fragments",invalidation:ie("typescript-reference-fragments"),serialize:e=>JSON.stringify(e),deserialize:si});function Pn(e,t,n,r=e){let i=bn(e),a=ge({projectFiles:i,snapshot:t,graph:L(e),engineIdentity:jt()}),s=[...n].map(([o,c])=>({relativePath:o,contentHash:a.identityFor(o,ii).key,value:[...c]}));if(s.some(o=>o.contentHash===null))throw new Error("TypeScript reference fragment identity is unavailable for an affected document.");return ai.writeBatch(r,s.map(o=>({...o,contentHash:o.contentHash}))),s.length}function si(e){try{let t=JSON.parse(e);return!Array.isArray(t)||!t.every(oi)?null:t}catch{return null}}function oi(e){if(!e||typeof e!="object")return!1;let t=e,n=t.location;return typeof t.targetSymbol=="string"&&!!n&&typeof n.file=="string"&&typeof n.line=="number"&&typeof n.column=="number"}import{createHash as di}from"crypto";import{existsSync as li,readFileSync as yo}from"fs";import{dirname as ui,join as Rn}from"path";function Ae(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 fe(e,t,n){let r=e.changes.map(o=>o.path).sort();if(r.length===0&&!e.projectIdentityChanged&&e.uncertainty.length===0)return{mode:"none",changedFiles:r,affectedFiles:[],reasons:[]};let i=new Set(n),a=Ae(e),s=new Set(a.reasons);return r.some(o=>!i.has(o))&&s.add("changed-file-outside-project"),t===null?(s.add("dependency-graph-unavailable"),xn(r,i,s)):s.size>0?xn(r,i,s):{mode:"closure",changedFiles:r,affectedFiles:ci(r,t,i),reasons:[]}}function xn(e,t,n){return{mode:"full-project",changedFiles:e,affectedFiles:[...t].sort(),reasons:[...n].sort()}}function ci(e,t,n){let r=new Map;for(let[s,o]of t)if(n.has(s))for(let c of o){if(!n.has(c))continue;let d=r.get(c)??new Set;d.add(s),r.set(c,d)}let i=new Set(e),a=[...e];for(let s=0;s<a.length;s+=1){let o=a[s];if(o!==void 0)for(let c of r.get(o)??[])i.has(c)||(i.add(c),a.push(c))}return[...i].sort()}var pi="<global-symbols>";function gi(e){let t=[];for(let n of e.all(`
|
|
20
20
|
SELECT relative_path, language, position_encoding, text
|
|
21
21
|
FROM documents
|
|
22
22
|
`))t.push({relativePath:n.relative_path,kind:"document",values:[n.language,n.position_encoding,n.text]});for(let n of e.all(`
|
|
@@ -43,7 +43,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
43
43
|
FROM defn_enclosing_ranges r
|
|
44
44
|
JOIN documents d ON d.id = r.document_id
|
|
45
45
|
JOIN global_symbols g ON g.id = r.symbol_id
|
|
46
|
-
`))t.push({relativePath:n.relative_path,kind:"definition",values:
|
|
46
|
+
`))t.push({relativePath:n.relative_path,kind:"definition",values:Le(n,[n.start_line,n.start_char,n.end_line,n.end_char])});for(let n of e.all(`
|
|
47
47
|
SELECT d.relative_path,
|
|
48
48
|
c.chunk_index,
|
|
49
49
|
m.role,
|
|
@@ -58,7 +58,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
58
58
|
JOIN chunks c ON c.id = m.chunk_id
|
|
59
59
|
JOIN documents d ON d.id = c.document_id
|
|
60
60
|
JOIN global_symbols g ON g.id = m.symbol_id
|
|
61
|
-
`))t.push({relativePath:n.relative_path,kind:"mention",values:
|
|
61
|
+
`))t.push({relativePath:n.relative_path,kind:"mention",values:Le(n,[n.chunk_index,n.role])});for(let n of e.all(`
|
|
62
62
|
SELECT g.symbol,
|
|
63
63
|
g.display_name,
|
|
64
64
|
g.kind,
|
|
@@ -72,9 +72,8 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
72
72
|
) AND NOT EXISTS (
|
|
73
73
|
SELECT 1 FROM mentions m WHERE m.symbol_id = g.id
|
|
74
74
|
)
|
|
75
|
-
`))t.push({relativePath:
|
|
76
|
-
`);n.set(r,a.digest("hex"))}return n}function Vr(e,t){let n=[],r=[],i=[],a=[],s=new Set([...e.keys(),...t.keys()]);for(let o of[...s].sort()){let d=e.get(o),c=t.get(o);d===void 0?n.push(o):c===void 0?i.push(o):d!==c?r.push(o):a.push(o)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function ke(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(d=>!r.has(d)),s=e.affectedFiles.filter(d=>!i.has(d)).sort(),o=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:o/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:s}}function Oe(e,t=ti){let n=t.now();if(!t.databaseExists(e.previousDbPath))return ue(e.refreshResult,"prior-index-unavailable",n,t.now());if(!t.databaseExists(e.candidateDbPath))return ue(e.refreshResult,"candidate-index-unavailable",n,t.now());let r=null,i=null;try{r=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),i=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let a=[...new Set([...t.indexedPaths(r),...t.indexedPaths(i)])].sort(),s=K(e.previousSnapshot,e.currentSnapshot),o=new Set(a),d=s.changes.length>0&&!De(s).fullProject&&s.changes.every(g=>o.has(g.path)),c=le(s,d?t.dependencyGraph(r):new Map,a),l=Vr(t.factDigests(r),t.factDigests(i)),u=t.now();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(u).toISOString(),durationMs:Math.max(0,u-n),manifest:s,plan:c,comparison:l,evaluation:ke(c,l,a.length)}}catch(a){return ue(e.refreshResult,"oracle-error",n,t.now(),a instanceof Error?a.message:String(a))}finally{tn(r),tn(i)}}function an(e,t,n,r=Date.now()){return ue(e,t,r,r,n)}function Qr(e){let t=rn(e);return{latestPath:en(t,"affected-shadow-latest.json"),historyPath:en(t,"affected-shadow.jsonl")}}function sn(e,t,n=ni){let r=Qr(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var Yr=8*1024*1024,Kr=".previous";function Zr(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 ei(e,t,n=Yr){let r=`${JSON.stringify(Zr(t))}
|
|
77
|
-
`,i=Math.max(1,Math.floor(n)),a=`${e}${Kr}`;if(Jr(rn(e),{recursive:!0}),nn(e)){let s=Wr(e).size;s>i?(_e(e,{force:!0}),_e(a,{force:!0})):s+Buffer.byteLength(r)>i&&(_e(a,{force:!0}),Hr(e,a))}Ur(e,r)}function Te(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 ti={now:()=>Date.now(),databaseExists:e=>nn(e),openDatabase:(e,t,n)=>new T({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>D(e),dependencyGraph:e=>A(e),factDigests:e=>zr(e)},ni={appendHistory:ei,writeLatest:(e,t)=>O(e,t,{spacing:2,trailingNewline:!0})};function ue(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 tn(e){try{e?.close()}catch{}}import{existsSync as on,readdirSync as ri}from"fs";import{isAbsolute as ii,join as Me,resolve as ai}from"path";var si={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:M.language,indexerBinary:M.indexerBinary,checkCommand:`${M.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:M.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:M.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",ii(r)?r:ai(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",cn(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",cn(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=Me(e,"vendor","bin","scip-php"),r=Me(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",on(r)?r:on(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Ae(e){return si[e]}function cn(e,t){let n;try{n=ri(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return Me(e,i);return null}import{createHash as oi}from"crypto";import{copyFileSync as ci,existsSync as dn,rmSync as ln}from"fs";import{resolve as di}from"path";import gn from"better-sqlite3";var li={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}]},ui={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 fn(e){let t=Date.now(),n=pi(e.affectedFiles);if(gi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),ln(e.candidateDbPath,{force:!0}),!dn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!dn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");un(e.previousDbPath,"previous SQLite generation",!1),un(e.miniDbPath,"incremental SQLite mini database"),ci(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new gn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ne(r,"main","candidate SQLite generation"),Ne(r,"incremental","incremental SQLite mini database"),fi(r,n),mi(r,n.length);let i=Ce(r,"main",!0),a=_(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{hi(r),yi(r),Si(r),e.onStage?.("after-delete"),bi(r),e.onStage?.("after-symbol-reconciliation"),Pi(r),e.onStage?.("after-insert"),xi(r),Ri(r,n.length,a),e.onStage?.("before-commit")}).immediate(),mn(r,"main","candidate SQLite generation");let d=[...vi(r)].filter(([c,l])=>i.get(c)!==l).map(([c])=>c).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:d,durationMs:Date.now()-t}}catch(i){try{r?.close()}finally{ln(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function pi(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 gi(e,t,n){let r=[e,t,n].map(i=>di(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function un(e,t,n=!0){let r=new gn(e,{readonly:!0,fileMustExist:!0});try{Ne(r,"main",t),n&&mn(r,"main",t)}finally{r.close()}}function Ne(e,t,n){for(let[r,i]of Object.entries(li)){let s=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:o,type:d,notnull:c,pk:l})=>({name:o,type:d.toUpperCase(),notnull:c,pk:l}));if(JSON.stringify(s)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ui)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),s=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(o=>o.name);if(a?.tbl_name!==i.table||JSON.stringify(s)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}pn(e,t,"documents",["relative_path"],n),pn(e,t,"global_symbols",["symbol"],n)}function pn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(o=>{if(o.unique!==1)return!1;let d=e.prepare(`PRAGMA ${t}.index_info('${o.name}')`).all().map(c=>c.name);return JSON.stringify(d)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function mn(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 fi(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function mi(e,t){let n=_(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=_(e,`SELECT COUNT(*) AS value
|
|
75
|
+
`))t.push({relativePath:pi,kind:"global-symbol",values:Le(n)});return fi(t)}function fi(e){let t=new Map;for(let r of e){let i=JSON.stringify([r.kind,r.values]),a=t.get(r.relativePath)??[];a.push(i),t.set(r.relativePath,a)}let n=new Map;for(let[r,i]of[...t].sort(([a],[s])=>a.localeCompare(s))){let a=di("sha256");for(let s of i.sort())a.update(String(Buffer.byteLength(s))),a.update(":"),a.update(s),a.update(`
|
|
76
|
+
`);n.set(r,a.digest("hex"))}return n}function mi(e,t){let n=[],r=[],i=[],a=[],s=new Set([...e.keys(),...t.keys()]);for(let o of[...s].sort()){let c=e.get(o),d=t.get(o);c===void 0?n.push(o):d===void 0?i.push(o):c!==d?r.push(o):a.push(o)}return{addedFiles:n,modifiedFiles:r,deletedFiles:i,changedFiles:[...n,...r,...i].sort(),unchangedFiles:a}}function Ne(e,t,n){let r=new Set(e.affectedFiles),i=new Set(t.changedFiles),a=e.mode==="full-project"?[]:t.changedFiles.filter(c=>!r.has(c)),s=e.affectedFiles.filter(c=>!i.has(c)).sort(),o=t.changedFiles.length-a.length;return{passed:a.length===0,recall:t.changedFiles.length===0?1:o/t.changedFiles.length,affectedRatio:n===0?0:e.affectedFiles.length/n,predictedFiles:[...e.affectedFiles].sort(),actualFiles:[...t.changedFiles],missingFiles:a,extraFiles:s}}function Ce(e,t=xi){let n=t.wallNow===void 0&&t.monotonicNow===void 0,r=t.monotonicNow??t.now,i=t.wallNow??t.now,a=r(),s=(d,l)=>{let u=r();return Fn(e.refreshResult,d,n?u:i(),Math.max(0,u-a),l)};if(!t.databaseExists(e.previousDbPath))return s("prior-index-unavailable");if(!t.databaseExists(e.candidateDbPath))return s("candidate-index-unavailable");let o=null,c=null;try{o=t.openDatabase(e.projectRoot,e.previousDbPath,e.previousIndexPath),c=t.openDatabase(e.projectRoot,e.candidateDbPath,e.candidateIndexPath);let d=[...new Set([...t.indexedPaths(o),...t.indexedPaths(c)])].sort(),l=te(e.previousSnapshot,e.currentSnapshot),u=new Set(d),p=l.changes.length>0&&!Ae(l).fullProject&&l.changes.every(b=>u.has(b.path)),h=fe(l,p?t.dependencyGraph(o):new Map,d),g=mi(t.factDigests(o),t.factDigests(c)),m=r();return{version:1,status:"evaluated",refreshResult:e.refreshResult,recordedAt:new Date(n?m:i()).toISOString(),durationMs:Math.max(0,m-a),manifest:l,plan:h,comparison:g,evaluation:Ne(h,g,d.length)}}catch(d){return s("oracle-error",d instanceof Error?d.message:String(d))}finally{In(o),In(c)}}function vn(e,t,n,r=Date.now()){return Fn(e,t,r,0,n)}function hi(e){let t=ui(e);return{latestPath:Rn(t,"affected-shadow-latest.json"),historyPath:Rn(t,"affected-shadow.jsonl")}}function En(e,t,n=Ri){let r=hi(e);return n.appendHistory(r.historyPath,t),n.writeLatest(r.latestPath,t),r}var yi=8*1024*1024,Si=Dt;function bi(e){let t={historyVersion:1,sourceVersion:e.version,refreshResult:e.refreshResult,recordedAt:e.recordedAt,durationMs:e.durationMs};return e.status==="unavailable"?{...t,status:"unavailable",reason:e.reason,...e.error?{error:e.error}:{}}:{...t,status:"evaluated",mode:e.plan.mode,passed:e.evaluation.passed,recall:e.evaluation.recall,affectedRatio:e.evaluation.affectedRatio,predictedFileCount:e.evaluation.predictedFiles.length,actualFileCount:e.evaluation.actualFiles.length,missingFileCount:e.evaluation.missingFiles.length,fallbackReasons:[...e.plan.reasons]}}function Pi(e,t,n=yi){kt(e,bi(t),{maxSegmentBytes:n,previousSuffix:Si})}function Le(e,t=[]){let n=[];for(let r of t)n.push(r);return n.push(e.symbol,e.display_name,e.kind,e.documentation,e.signature_hex,e.enclosing_symbol,e.relationships_hex),n}var xi={now:()=>Date.now(),wallNow:()=>Date.now(),monotonicNow:P,databaseExists:e=>li(e),openDatabase:(e,t,n)=>new k({projectRoot:e,dbPath:t,indexPath:n}),indexedPaths:e=>j(e),dependencyGraph:e=>L(e),factDigests:e=>gi(e)},Ri={appendHistory:Pi,writeLatest:(e,t)=>Pt(e,t,{spacing:2,trailingNewline:!0})};function Fn(e,t,n,r,i){return{version:1,status:"unavailable",refreshResult:e,recordedAt:new Date(n).toISOString(),durationMs:r,reason:t,...i?{error:i}:{}}}function In(e){try{e?.close()}catch{}}import{existsSync as wn,readdirSync as Ii}from"fs";import{isAbsolute as vi,join as $e,resolve as Ei}from"path";var Fi={typescript:{language:"typescript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,pnpmWorkspaces:t,indexerBinary:n,projectPath:r})=>{let i=r?["index","--output",e,"--no-progress-bar",r]:["index","--infer-tsconfig","--output",e,"--no-progress-bar"];return t&&!r&&i.splice(1,0,"--pnpm-workspaces"),{binary:n,args:i}},markerFiles:["tsconfig.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},javascript:{language:"javascript",indexerBinary:"scip-typescript",checkCommand:"npx scip-typescript --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--infer-tsconfig","--output",e,"--no-progress-bar"]}),markerFiles:["package.json"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","@sourcegraph/scip-typescript"]}],installUrl:"https://github.com/sourcegraph/scip-typescript",bundledNpmPackage:"@sourcegraph/scip-typescript"},java:{language:"java",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["pom.xml","build.gradle"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},scala:{language:"scala",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.sbt"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},kotlin:{language:"kotlin",indexerBinary:"scip-java",checkCommand:"scip-java --version",indexArgs:({outputPath:e})=>({binary:"scip-java",args:["index","--output",e]}),markerFiles:["build.gradle.kts"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-java/releases"},rust:{language:A.language,indexerBinary:A.indexerBinary,checkCommand:`${A.indexerBinary} --version`,indexArgs:({outputPath:e})=>({binary:A.indexerBinary,args:["scip",".","--output",e]}),markerFiles:["Cargo.toml"],installMethods:[{label:"rustup",prerequisite:"rustup",binary:"rustup",args:["component","add","rust-analyzer"]}],installUrl:A.installUrl},python:{language:"python",indexerBinary:"scip-python-plus",binaryAliases:["scip-python"],checkCommand:"scip-python-plus --version",indexArgs:({outputPath:e,indexerBinary:t})=>({binary:t,args:["index","--output",e,"--project-name","project"]}),markerFiles:["pyproject.toml","setup.py"],installMethods:[{label:"npm",prerequisite:"npm",binary:"npm",args:["install","-g","scip-python-plus"]}],installUrl:"https://github.com/PlunderStruck/scip-python",bundledNpmPackage:"scip-python-plus"},clojure:{language:"clojure",indexerBinary:"scip-clojure",projectLocalBinaries:["node_modules/.bin/scip-clojure"],checkCommand:"scip-clojure -h",indexArgs:({projectRoot:e,outputPath:t,indexerBinary:n,configPath:r})=>{let i=["-root",e,"-output",t];return r&&i.push("-config",vi(r)?r:Ei(e,r)),{binary:n,args:i}},markerFiles:["deps.edn","project.clj","bb.edn","shadow-cljs.edn"],installMethods:[],installUrl:"https://github.com/PlunderStruck/scip-clojure"},ruby:{language:"ruby",indexerBinary:"scip-ruby",checkCommand:"scip-ruby --version",indexArgs:({indexerBinary:e})=>({binary:e,args:["--dir","."]}),defaultOutputPath:"index.scip",markerFiles:["Gemfile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-ruby/releases"},go:{language:"go",indexerBinary:"scip-go",checkCommand:"scip-go --version",indexArgs:({outputPath:e})=>({binary:"scip-go",args:["--output",e]}),markerFiles:["go.mod"],installMethods:[{label:"go install",prerequisite:"go",binary:"go",args:["install","github.com/sourcegraph/scip-go@latest"]}],installUrl:"https://github.com/sourcegraph/scip-go"},cpp:{language:"cpp",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},c:{language:"c",indexerBinary:"scip-clang",checkCommand:"scip-clang --version",indexArgs:({outputPath:e})=>({binary:"scip-clang",args:["--compdb-path","compile_commands.json","--index-output-path",e]}),markerFiles:["CMakeLists.txt","Makefile"],installMethods:[],installUrl:"https://github.com/sourcegraph/scip-clang/releases"},csharp:{language:"csharp",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",_n(e,[".sln",".csproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.csproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},vb:{language:"vb",indexerBinary:"scip-dotnet",checkCommand:"scip-dotnet --version",indexArgs:({projectRoot:e,outputPath:t})=>({binary:"scip-dotnet",args:["index",_n(e,[".sln",".vbproj"])??e,"--output",t,"--working-directory",e]}),markerFiles:["*.vbproj","*.sln"],installMethods:[{label:"dotnet",prerequisite:"dotnet",binary:"dotnet",args:["tool","install","--global","scip-dotnet"]}],installUrl:"https://github.com/sourcegraph/scip-dotnet/releases"},dart:{language:"dart",indexerBinary:"scip-dart",checkCommand:"scip-dart --version",indexArgs:({indexerBinary:e,outputPath:t})=>({binary:e,args:["--output",t]}),markerFiles:["pubspec.yaml"],installMethods:[{label:"dart pub",prerequisite:"dart",binary:"dart",args:["pub","global","activate","scip_dart"]}],installUrl:"https://github.com/Workiva/scip-dart/releases"},php:{language:"php",indexerBinary:"scip-php",projectLocalBinaries:["vendor/davidrjenni/scip-php/bin/scip-php","vendor/bin/scip-php"],checkCommand:"scip-php --version",indexArgs:({projectRoot:e,indexerBinary:t})=>{let n=$e(e,"vendor","bin","scip-php"),r=$e(e,"vendor","davidrjenni","scip-php","bin","scip-php");return{binary:"php",args:["-d","error_reporting=E_ALL & ~E_DEPRECATED & ~E_USER_DEPRECATED",wn(r)?r:wn(n)?n:t]}},defaultOutputPath:"index.scip",markerFiles:["composer.json"],installMethods:[],installUrl:"https://github.com/davidrjenni/scip-php/releases"}};function Be(e){return Fi[e]}function _n(e,t){let n;try{n=Ii(e)}catch{return null}for(let r of t)for(let i of n)if(i.endsWith(r))return $e(e,i);return null}import{createHash as wi}from"crypto";import{copyFileSync as _i,existsSync as jn,rmSync as Dn}from"fs";import{resolve as ji}from"path";import Mn from"better-sqlite3";var Di={documents:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"language",type:"TEXT",notnull:0,pk:0},{name:"relative_path",type:"TEXT",notnull:1,pk:0},{name:"position_encoding",type:"TEXT",notnull:0,pk:0},{name:"text",type:"TEXT",notnull:0,pk:0}],chunks:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"chunk_index",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"occurrences",type:"BLOB",notnull:1,pk:0}],global_symbols:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"symbol",type:"TEXT",notnull:1,pk:0},{name:"display_name",type:"TEXT",notnull:0,pk:0},{name:"kind",type:"INTEGER",notnull:0,pk:0},{name:"documentation",type:"TEXT",notnull:0,pk:0},{name:"signature",type:"BLOB",notnull:0,pk:0},{name:"enclosing_symbol",type:"TEXT",notnull:0,pk:0},{name:"relationships",type:"BLOB",notnull:0,pk:0}],mentions:[{name:"chunk_id",type:"INTEGER",notnull:1,pk:1},{name:"symbol_id",type:"INTEGER",notnull:1,pk:2},{name:"role",type:"INTEGER",notnull:1,pk:3}],defn_enclosing_ranges:[{name:"id",type:"INTEGER",notnull:0,pk:1},{name:"document_id",type:"INTEGER",notnull:1,pk:0},{name:"symbol_id",type:"INTEGER",notnull:1,pk:0},{name:"start_line",type:"INTEGER",notnull:1,pk:0},{name:"start_char",type:"INTEGER",notnull:1,pk:0},{name:"end_line",type:"INTEGER",notnull:1,pk:0},{name:"end_char",type:"INTEGER",notnull:1,pk:0}]},ki={idx_chunks_doc_id:{table:"chunks",columns:["document_id"]},idx_chunks_line_range:{table:"chunks",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_document:{table:"defn_enclosing_ranges",columns:["document_id","start_line","end_line"]},idx_defn_enclosing_ranges_symbol_id:{table:"defn_enclosing_ranges",columns:["symbol_id"]},idx_global_symbols_symbol:{table:"global_symbols",columns:["symbol"]},idx_mentions_symbol_id_role:{table:"mentions",columns:["symbol_id","role"]}};function On(e){let t=P(),n=Ti(e.affectedFiles);if(Mi(e.previousDbPath,e.miniDbPath,e.candidateDbPath),Dn(e.candidateDbPath,{force:!0}),!jn(e.previousDbPath))throw new Error("previous SQLite generation is unavailable");if(!jn(e.miniDbPath))throw new Error("incremental SQLite mini database is unavailable");kn(e.previousDbPath,"previous SQLite generation",!1),kn(e.miniDbPath,"incremental SQLite mini database"),_i(e.previousDbPath,e.candidateDbPath);let r=null;try{r=new Mn(e.candidateDbPath,{fileMustExist:!0}),r.pragma("busy_timeout = 5000"),r.pragma("foreign_keys = ON"),r.prepare("ATTACH DATABASE ? AS incremental").run(e.miniDbPath),Ge(r,"main","candidate SQLite generation"),Ge(r,"incremental","incremental SQLite mini database"),Oi(r,n),Ai(r,n.length);let i=Ue(r,"main",!0),a=D(r,"SELECT COUNT(*) AS value FROM main.documents");r.transaction(()=>{Li(r),Ni(r),Ci(r),e.onStage?.("after-delete"),$i(r),e.onStage?.("after-symbol-reconciliation"),Bi(r),e.onStage?.("after-insert"),Gi(r),Ui(r,n.length,a),e.onStage?.("before-commit")}).immediate(),An(r,"main","candidate SQLite generation");let c=[...Ji(r)].filter(([d,l])=>i.get(d)!==l).map(([d])=>d).sort();return r.exec("DETACH DATABASE incremental"),r.close(),r=null,{candidateDbPath:e.candidateDbPath,affectedDocumentCount:n.length,changedDocumentPaths:c,durationMs:P()-t}}catch(i){try{r?.close()}finally{Dn(e.candidateDbPath,{force:!0})}throw new Error(`Incremental SQLite publication rejected: ${i instanceof Error?i.message:String(i)}`,{cause:i})}}function Ti(e){if(e.length===0)throw new Error("incremental SQLite publication requires affected documents");let t=[...e].sort();for(let n of t)if(!n||n.startsWith("/")||n.includes("\\")||n.split("/").includes(".."))throw new Error(`invalid affected document path: ${n}`);if(new Set(t).size!==t.length)throw new Error("incremental SQLite publication contains duplicate affected documents");return t}function Mi(e,t,n){let r=[e,t,n].map(i=>ji(i));if(new Set(r).size!==r.length)throw new Error("previous, mini, and candidate SQLite paths must be distinct")}function kn(e,t,n=!0){let r=new Mn(e,{readonly:!0,fileMustExist:!0});try{Ge(r,"main",t),n&&An(r,"main",t)}finally{r.close()}}function Ge(e,t,n){for(let[r,i]of Object.entries(Di)){let s=e.prepare(`PRAGMA ${t}.table_info('${r}')`).all().map(({name:o,type:c,notnull:d,pk:l})=>({name:o,type:c.toUpperCase(),notnull:d,pk:l}));if(JSON.stringify(s)!==JSON.stringify(i))throw new Error(`${n} schema changed for table ${r}`)}for(let[r,i]of Object.entries(ki)){let a=e.prepare(`SELECT tbl_name FROM ${t}.sqlite_master WHERE type = 'index' AND name = ?`).get(r),s=e.prepare(`PRAGMA ${t}.index_info('${r}')`).all().map(o=>o.name);if(a?.tbl_name!==i.table||JSON.stringify(s)!==JSON.stringify(i.columns))throw new Error(`${n} schema changed for index ${r}`)}Tn(e,t,"documents",["relative_path"],n),Tn(e,t,"global_symbols",["symbol"],n)}function Tn(e,t,n,r,i){if(!e.prepare(`PRAGMA ${t}.index_list('${n}')`).all().some(o=>{if(o.unique!==1)return!1;let c=e.prepare(`PRAGMA ${t}.index_info('${o.name}')`).all().map(d=>d.name);return JSON.stringify(c)===JSON.stringify(r)}))throw new Error(`${i} lost the unique ${n}(${r.join(", ")}) constraint`)}function An(e,t,n){let r=e.prepare(`PRAGMA ${t}.integrity_check`).pluck().get();if(r!=="ok")throw new Error(`${n} failed integrity_check: ${String(r)}`);if(e.prepare(`PRAGMA ${t}.foreign_key_check`).all().length>0)throw new Error(`${n} failed foreign_key_check`)}function Oi(e,t){e.exec("CREATE TEMP TABLE incremental_affected_paths (relative_path TEXT PRIMARY KEY) WITHOUT ROWID");let n=e.prepare("INSERT INTO temp.incremental_affected_paths(relative_path) VALUES (?)");e.transaction(i=>{for(let a of i)n.run(a)})(t)}function Ai(e,t){let n=D(e,"SELECT COUNT(*) AS value FROM incremental.documents"),r=D(e,`SELECT COUNT(*) AS value
|
|
78
77
|
FROM main.documents d
|
|
79
78
|
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`),i=e.prepare(`SELECT p.relative_path
|
|
80
79
|
FROM temp.incremental_affected_paths p
|
|
@@ -84,7 +83,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
84
83
|
FROM incremental.documents d
|
|
85
84
|
LEFT JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path
|
|
86
85
|
WHERE p.relative_path IS NULL
|
|
87
|
-
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function
|
|
86
|
+
LIMIT 1`).pluck().get();if(n!==t||r!==t||i!==void 0||a!==void 0)throw new Error("incremental SQLite mini database does not exactly match the affected document set")}function Li(e){e.exec(`
|
|
88
87
|
CREATE TEMP TABLE incremental_old_defined_symbols (symbol TEXT PRIMARY KEY) WITHOUT ROWID;
|
|
89
88
|
INSERT OR IGNORE INTO temp.incremental_old_defined_symbols(symbol)
|
|
90
89
|
SELECT g.symbol
|
|
@@ -111,7 +110,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
111
110
|
FROM incremental.mentions m
|
|
112
111
|
JOIN incremental.global_symbols g ON g.id = m.symbol_id
|
|
113
112
|
WHERE m.role = 1;
|
|
114
|
-
`)}function
|
|
113
|
+
`)}function Ni(e){let t=e.prepare(`WITH changed_symbols AS (
|
|
115
114
|
SELECT symbol FROM temp.incremental_old_defined_symbols
|
|
116
115
|
UNION
|
|
117
116
|
SELECT symbol FROM temp.incremental_new_defined_symbols
|
|
@@ -134,7 +133,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
134
133
|
SELECT u.symbol
|
|
135
134
|
FROM unaffected_definitions u
|
|
136
135
|
JOIN changed_symbols c ON c.symbol = u.symbol
|
|
137
|
-
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function
|
|
136
|
+
LIMIT 1`).pluck().get();if(typeof t=="string")throw new Error(`symbol definition is shared by affected and unaffected documents: ${t}`)}function Ci(e){e.exec(`
|
|
138
137
|
DELETE FROM main.mentions
|
|
139
138
|
WHERE chunk_id IN (
|
|
140
139
|
SELECT c.id
|
|
@@ -156,7 +155,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
156
155
|
);
|
|
157
156
|
DELETE FROM main.documents
|
|
158
157
|
WHERE relative_path IN (SELECT relative_path FROM temp.incremental_affected_paths);
|
|
159
|
-
`)}function
|
|
158
|
+
`)}function $i(e){e.exec(`
|
|
160
159
|
UPDATE main.global_symbols
|
|
161
160
|
SET display_name = NULL,
|
|
162
161
|
kind = NULL,
|
|
@@ -198,7 +197,7 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
198
197
|
WHERE source.symbol = main.global_symbols.symbol
|
|
199
198
|
)
|
|
200
199
|
WHERE symbol IN (SELECT symbol FROM temp.incremental_new_defined_symbols);
|
|
201
|
-
`)}function
|
|
200
|
+
`)}function Bi(e){let t=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.documents"),n=D(e,"SELECT COALESCE(MAX(id), 0) AS value FROM main.chunks"),r=D(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)
|
|
202
201
|
SELECT id + ?, language, relative_path, position_encoding, text
|
|
203
202
|
FROM incremental.documents`).run(t),e.prepare(`INSERT INTO main.chunks(id, document_id, chunk_index, start_line, end_line, occurrences)
|
|
204
203
|
SELECT id + ?, document_id + ?, chunk_index, start_line, end_line, occurrences
|
|
@@ -213,15 +212,15 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
213
212
|
r.start_line, r.start_char, r.end_line, r.end_char
|
|
214
213
|
FROM incremental.defn_enclosing_ranges r
|
|
215
214
|
JOIN incremental.global_symbols source ON source.id = r.symbol_id
|
|
216
|
-
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function
|
|
215
|
+
JOIN main.global_symbols target ON target.symbol = source.symbol`).run(r,t)}function Gi(e){e.exec(`
|
|
217
216
|
DELETE FROM main.global_symbols
|
|
218
217
|
WHERE NOT EXISTS (SELECT 1 FROM main.mentions m WHERE m.symbol_id = main.global_symbols.id)
|
|
219
218
|
AND NOT EXISTS (
|
|
220
219
|
SELECT 1 FROM main.defn_enclosing_ranges r WHERE r.symbol_id = main.global_symbols.id
|
|
221
220
|
);
|
|
222
|
-
`)}function
|
|
221
|
+
`)}function Ui(e,t,n){let r=D(e,"SELECT COUNT(*) AS value FROM main.documents"),i=D(e,`SELECT COUNT(*) AS value
|
|
223
222
|
FROM main.documents d
|
|
224
|
-
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),s=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||s!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function
|
|
223
|
+
JOIN temp.incremental_affected_paths p ON p.relative_path = d.relative_path`);if(r!==n||i!==t)throw new Error("candidate SQLite document counts changed unexpectedly");let a=e.prepare("SELECT relative_path FROM main.documents GROUP BY relative_path HAVING COUNT(*) > 1 LIMIT 1").pluck().get(),s=e.prepare("SELECT symbol FROM main.global_symbols GROUP BY symbol HAVING COUNT(*) > 1 LIMIT 1").pluck().get();if(a!==void 0||s!==void 0)throw new Error("candidate SQLite generation contains duplicate document paths or symbols")}function Ji(e){let t=Ue(e,"main",!0),n=Ue(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 Ue(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
|
|
225
224
|
FROM ${t}.documents d
|
|
226
225
|
${r}
|
|
227
226
|
ORDER BY d.relative_path`).all(),a=e.prepare(`SELECT d.relative_path, c.chunk_index, c.start_line, c.end_line, hex(c.occurrences) AS occurrences
|
|
@@ -243,16 +242,16 @@ import{a as te,b as ne}from"./chunk-64RFXJT5.js";import{a as Bt}from"./chunk-P5X
|
|
|
243
242
|
JOIN ${t}.documents d ON d.id = c.document_id
|
|
244
243
|
JOIN ${t}.global_symbols g ON g.id = m.symbol_id
|
|
245
244
|
${r}
|
|
246
|
-
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),
|
|
247
|
-
`);
|
|
248
|
-
`;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function Ue(e){try{let t=Fi(e,"utf-8"),n=JSON.parse(Ci(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as Li,readFileSync as $i,readdirSync as Bi,statSync as Gi}from"fs";import v from"path";var Ui=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function H(e,t=[]){let n=v.resolve(e),r=t.flatMap(d=>Hi(n,d));if(r.length>0)return In(n,Fn(r));let i=Ji(n),a=Fn(i),s=qi(n,a)?[n,...a]:a,o=s.length>0?s:[n];return In(n,o)}function In(e,t){return[...new Set(t.map(n=>Xi(e,n)))].sort((n,r)=>n.localeCompare(r))}function Ji(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=Bi(r,{withFileTypes:!0})}catch{continue}for(let a of i){let s=v.join(r,a.name);if(a.isDirectory()){!Ui.has(a.name)&&!a.name.startsWith(".")&&n.push(s);continue}a.isFile()&&Wi(s)&&t.push(v.dirname(s))}}return t}function Hi(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!B(e,r))return[];try{let i=Gi(r);if(i.isDirectory())return[r];if(i.isFile()&&En(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function Wi(e){if(!En(v.basename(e)))return!1;let t=wn(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function En(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Fn(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&&Vi(n,r)))}function qi(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return Li(n)&&zi(n)}function zi(e){let n=wn(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 wn(e){try{let t=JSON.parse($i(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function Xi(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function Vi(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as oa}from"crypto";import{existsSync as Je,readFileSync as An,statSync as ca,writeFileSync as He}from"fs";import{join as da}from"path";import{randomUUID as Qi}from"crypto";import{existsSync as Yi,mkdirSync as jn,readFileSync as Ki,rmSync as Dn}from"fs";import{resolve as _n}from"path";var Zi=12e4,ea=5,ge=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;constructor(t,n={}){this.projectRoot=at(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??aa(),this.runtime=n.runtime??sa}request(t){let n=$t(this.cacheDir),r=Nt(this.cacheDir),i=Ee(n.statePath);if(!Tn(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.randomId(),s=_n(r.requestDir,`${a}.json`),o=_n(r.responseDir,`${a}.json`),d=this.runtime.now()+this.timeoutMs;jn(r.requestDir,{recursive:!0}),jn(r.responseDir,{recursive:!0}),O(s,{protocolVersion:ae,id:a,baseGeneration:this.baseGeneration,deadlineAtMs:d,request:t});try{for(;this.runtime.now()<=d;){if(Yi(o))return ta(Ki(o,"utf8"),a,this.baseGeneration,t.producerIdentity,t.affectedFiles);let c=Ee(n.statePath);if(!Tn(c,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(ea)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}finally{Dn(s,{force:!0}),Dn(o,{force:!0})}}};function Tn(e,t,n){let r=e!==null&&n.now()-Date.parse(e.heartbeatAt)<=Lt,i=e?.typescriptIndex?.busyUntil!==void 0&&n.now()<=Date.parse(e.typescriptIndex.busyUntil);return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===ae&&n.isProcessAlive(e.pid)&&(r||i)}function ta(e,t,n,r,i){let a=JSON.parse(e);if(a.protocolVersion!==ae||a.id!==t||a.ok===!0&&a.baseGeneration!==n)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=na(a.response,r),o=[...new Set(i)].sort(),d=s.fragments.map(c=>c.relativePath).sort();if(JSON.stringify(d)!==JSON.stringify(o))throw new Error("TypeScript index service omitted or added an affected document.");return s}function na(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(ra)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let s=a.bytesBase64===null?null:ia(a.bytesBase64);return{relativePath:a.relativePath,bytes:s,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function ra(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 ia(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function aa(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:Zi}var sa={now:Date.now,randomId:Qi,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:k};function la(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=K(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(c=>c.kind!=="modified"||c.inputKind!=="source"||!G(c.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=le(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=ua([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=kn(e.currentSnapshot,e.projectFiles,e.producerIdentity),s=kn(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==s)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let o=Mn(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!o)return{eligible:!1,reason:"prior document identity unavailable"};let d=Mn(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return d?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:On(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:On(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:o,nextDocumentIdentities:d,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function ua(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Nn(e){let t=Date.now();try{if(!Je(e.previousDbPath)||!Je(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=Fe();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new T({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),s,o;try{s=D(a,{includeIgnored:!1}).filter(G).sort(),o=A(a)}finally{a.close()}let d=performance.now()-n,c=la({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?H(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:s,graph:o,producerIdentity:r.producerIdentity,rootTsconfigExists:Je(da(e.projectRoot,"tsconfig.json"))});if(!c.eligible)throw new Error(c.reason);let l=Ct(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let g=new ge({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:c.tsconfigPath,projectArgument:c.projectArgument,projectIdentity:c.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles}),m=performance.now()-n,p=ca(e.previousShardPath).size>=wt;n=performance.now();let y=p?null:An(e.previousShardPath),b=p?{completeIndexBytes:null,affectedIndexBytes:vt(g.fragments)}:Et({packageVersion:r.packageVersion,baseIndexBytes:y,fragments:g.fragments}),f=performance.now()-n;n=performance.now(),p?jt({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,nextGenerationIdentity:c.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:g.fragments}):(It({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:y,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.previousFragmentGeneration,documentIdentities:c.previousDocumentIdentities,allowUntrackedDocuments:!0}),Ft({cacheDir:e.cacheDir,previousGenerationIdentity:c.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:c.projectIdentity,generationIdentity:c.nextFragmentGeneration,fragments:g.fragments,documentIdentities:c.nextDocumentIdentities}));let h=performance.now()-n;n=performance.now(),b.completeIndexBytes&&He(e.candidateShardPath,b.completeIndexBytes),He(e.candidateAffectedScipPath,b.affectedIndexBytes);let R=performance.now()-n,P={scipPath:p?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!p,durationMs:Date.now()-t,cold:g.cold,changedFiles:c.plan.changedFiles,affectedFiles:c.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:c.previousFragmentGeneration,nextFragmentGeneration:c.nextFragmentGeneration,manifest:c.manifest,plan:c.plan,projectFileCount:s.length,referenceFragmentsByFile:new Map(g.fragments.map(Q=>[Q.relativePath,Q.referenceFragments])),timings:{runtimeMs:i,graphMs:d,requestMs:m,serviceMs:g.durationMs,assemblyMs:f,fragmentStoreMs:h,writeMs:R}};return e.onStatus(`Incremental TypeScript index emitted ${P.affectedFiles.length} affected document(s) in ${(P.durationMs/1e3).toFixed(3)}s (${P.cold?"cold":"warm"} service; ${p?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${d.toFixed(0)}ms, request ${m.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${h.toFixed(0)}ms, write ${R.toFixed(0)}ms).`),P}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 Cn(e){let t=Fe();if(!t.available)throw new Error(t.reason);let n=Dt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:An(e.baseShardPath),packageVersion:t.packageVersion});He(e.candidateShardPath,n)}function kn(e,t,n){let r=e.files.filter(i=>Y(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return We(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function On(e,t){return We(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Mn(e,t,n,r,i){let a=new Set(e.files.map(d=>d.path)),s=de({projectFiles:t.filter(d=>a.has(d)),snapshot:e,graph:n,engineIdentity:r}),o=new Map;for(let d of i){let c=s.identityFor(d,"typescript-scip-document-v1");if(c.key){o.set(d,c.key);continue}if(a.has(d))return null;o.set(d,We(JSON.stringify({version:1,producerIdentity:r,generatedDocument:d})))}return o}function We(e){return oa("sha256").update(e).digest("hex")}import{execFile as pa}from"child_process";import{existsSync as fe,renameSync as ze,rmSync as Xe,statSync as ga}from"fs";import{cpus as fa}from"os";import{join as Ln}from"path";function ma(e,t,n){if(!e.defaultOutputPath)return;let r=Ln(t,e.defaultOutputPath);n!==r&&fe(r)&&ze(r,n)}function ha(e,t,n){if(!e.defaultOutputPath)return null;let r=Ln(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Xe(i,{force:!0}),fe(r)?(ze(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function ya(e){e&&(Xe(e.defaultOutputPath,{force:!0}),e.backupPath&&fe(e.backupPath)&&ze(e.backupPath,e.defaultOutputPath))}function Sa(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,fa().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function $n(e,t,n,r){let i=e.filter(c=>c.config.defaultOutputPath),a=e.filter(c=>!c.config.defaultOutputPath),s=[],o=Sa(a.length,r),d=await Pa(a,o,c=>qe(c,t,n));if(o>1){let c=new Map;for(let l of d.filter(u=>u.skipped)){let u=a.find(g=>g.id===l.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),c.set(u.id,await qe(u,t,n)))}s.push(...d.map(l=>c.get(l.id)??l))}else s.push(...d);for(let c of i)s.push(await qe(c,t,n));return s.sort((c,l)=>e.findIndex(u=>u.id===c.id)-e.findIndex(u=>u.id===l.id))}async function qe(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Xe(e.scipPath,{force:!0});let r=ha(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=Date.now();try{let o=nt(e.binary,e.args);await ba(o.binary,o.args,{cwd:t,env:e.env,maxBuffer:50*1024*1024}),ma(e.config,t,e.scipPath)}catch(o){let d=o instanceof Error?o.message:String(o),c=`${e.resolvedBinary} indexer failed: ${d.split(`
|
|
249
|
-
`)[0]}`,l=e.label===e.language?c:`${e.label}: ${c}`;return n(`Skipping ${e.label}: ${c}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-a,command:i,skipped:{language:e.language,reason:l}}}finally{ya(r)}if(!fe(e.scipPath)){let o=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,d=e.label===e.language?o:`${e.label}: ${o}`;return n(`Skipping ${e.label}: ${o}`),{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-a,command:i,skipped:{language:e.language,reason:d}}}let s;try{s=ga(e.scipPath).size}catch{s=void 0}return{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:Date.now()-a,command:i,outputBytes:s}}function ba(e,t,n){return new Promise((r,i)=>{pa(e,[...t],n,a=>{a?i(a):r()})})}async function Pa(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),s=Array.from({length:a},async()=>{for(;i<e.length;){let o=i++;r[o]=await n(e[o])}});return await Promise.all(s),r}import{execFileSync as xa}from"child_process";import{platform as Ra}from"os";function Bn(e,t){let n=e.installMethods,r=oe(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(L(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{xa(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Ra()==="win32"});let a=J(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}async function Qn(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,a=Oa(e),s=Date.now();he(S(a.outputScip),{recursive:!0}),he(S(a.outputDb),{recursive:!0});let o=e.languages??St(t);if(o.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: ${o.join(", ")}`);let d=E("reindex.fingerprint",()=>dt(t,o,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:o.length}),c,l;if(e.skipIfUnchanged!==!1&&!Ot(t,a.outputDb)&&Gn(a.outputScip)===Gn(x(S(a.outputDb),"index.scip"))){let p=Z(t);if(c=p?re(p,d):void 0,c){let y=ie(c);if(y){if(!ka(a,d))try{ve({snapshot:c,manifest:y,targetCacheDir:S(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${c.generationId.slice(0,12)}`)}catch(b){r(`Shared generation attach failed; continuing locally: ${q(b)}`)}}else{let b=await At(c);if(b.kind==="owner")l=b.release;else if(b.kind==="generation-ready"){let f=ie(c);if(f)try{ve({snapshot:c,manifest:f,targetCacheDir:S(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${c.generationId.slice(0,12)} after waiting`)}catch(h){r(`Shared generation attach failed after waiting; continuing locally: ${q(h)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let u=st(x(S(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!u)throw l?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${S(a.outputDb)}.`);let g;try{g=await C("reindex.lock",()=>ss(x(S(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:o.length})}catch(p){throw u.release(),l?.(),p}let m=null;try{let p=Ca(S(a.outputDb));p.removed>0&&r(`Removed ${p.removed} abandoned reindex workspace(s)`);for(let P of p.errors)r(`Could not remove abandoned reindex workspace: ${P}`);let y=null,b=E("reindex.reuse-check",()=>(y=Ma({opts:e,paths:a,languages:o,fingerprint:d,start:s,onStatus:r}),y),()=>({languages:o.length,reused:y!==null}));if(b)return Un({snapshot:c,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),Re(a.outputDb,b),b;await C("reindex.scip-cli-ready",()=>Ka(i,r));let f=Na(a);m=f.runDir;let h,R=await C("reindex.fresh",async()=>(h=await La({opts:e,languages:o,projectRoot:t,paths:a,tempPaths:f,fingerprint:d,start:s,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),h),()=>({languages:o.length,reused:h?.reused,skipped:h?.skipped.length}));return Un({snapshot:c,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),Re(a.outputDb,R),R}catch(p){let y=Pe({trigger:e.trigger,result:"failed",start:s,error:p instanceof Error?p.message:String(p)});throw sr(a.metaPath,y),Rt(a.outputDb,y),p}finally{m&&j(m,{recursive:!0,force:!0}),g(),u.release(),l?.()}}function Un(e){if(e.snapshot){if(ie(e.snapshot)){Ie(e.snapshot,S(e.paths.outputDb),"local-fresh");return}try{let t=Z(e.projectRoot),n=t?re(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}Mt({snapshot:e.snapshot,sourceCacheDir:S(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=Z(e.projectRoot);return(r?re(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),Ie(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: ${q(t)}`)}}}function ka(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!ar(e.metaPath,t))return!1;let n=U(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function q(e){return e instanceof Error?e.message:String(e)}function Oa(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(S(n),"meta.json")}}function Ma(e){let t=U(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!ar(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;ne(te(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=Date.now()-e.start,r=Pe({trigger:e.opts.trigger,result:"reused",start:e.start,languages:e.languages,skipped:[]});return sr(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:Aa(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Aa(e,t,n,r){let i=rr(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:W(i[a]),outputBytes:z(Ye(e.outputDb,a)),durationMs:0}))}function Na(e){let t=Ea(x(S(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:x(t,me(e.outputScip)),tempOutputDb:x(t,me(e.outputDb)),tempMetaPath:x(t,me(e.metaPath))}}function Ca(e){let t=[],n;try{n=Xn(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[q(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{j(x(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${q(a)}`)}return{removed:r,errors:t}}async function La(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await C("reindex.language-indexers",async()=>(n=await Ba(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:s,languageFingerprints:o,shards:d,typescriptProjectShardContext:c,incrementalTypeScript:l}=r;if(s.length>0&&e.onStatus(`Reused ${s.length} cached language shard(s): ${s.join(", ")}`),$a({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:s})){let m=E("reindex.publish",()=>Va(e,i,a,s,o,c),{mode:"metadata-only",languages:i.length,reused:s.length}),p=m.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(p/1e3).toFixed(1)}s`),{languages:i.map(y=>y.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!0,skipped:a,lastRefresh:m,shards:d}}let u=E("reindex.publish",()=>Xa(e,t,i,a,s,o,c,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:s.length,skipped:a.length}),g=u.durationMs;return e.onStatus(`Done in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!1,skipped:a,lastRefresh:u,shards:d}}function $a(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=U(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 Ba(e,t){let n=Wa({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[I,et]of n)et.reused&&(r.push({language:I,scipPath:et.scipPath}),i.add(I));for(let I of i)e.onStatus(`Reusing cached ${I} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),s=U(e.paths.outputDb,e.paths.metaPath),o=V(e.paths.metaPath),d=s.state==="legacy"||s.state==="current",c=o?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&d?Nn({projectRoot:e.projectRoot,cacheDir:S(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:X(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:X(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:c,previousSnapshot:Qe(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),g=l?void 0:Ga(e,n),{preparedRuns:m,skippedLanguages:p,languageOutputScipPaths:y}=Za({languages:e.languages.filter(I=>!i.has(I)&&!u.has(I)),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:g?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=g?m.filter(I=>I.language!=="typescript"||g.missedProjectIds.has(I.id)):m,f=await $n(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),h=[];if(g){Ja(e.paths.outputDb,f);let I=y.typescript??e.tempPaths.tempOutputScip;h=Ha({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:I,reusedProjects:g.reusedProjects})}let R=[...f,...h],{indexedOutputs:P}=ts(R,p),Q=l?[{language:"typescript",scipPath:l.scipPath}]:[],Ze=[...r,...Q,...P];ns(Ze,p,e.languages,e.opts.allowPartial,e.onStatus);let gr=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:z(l.scipPath)??void 0}]:[],fr=qa(n,[...f,...gr],g?{outputDb:e.paths.outputDb,classification:g.classification}:void 0);return{indexedOutputs:Ze,skippedLanguages:p,reusedLanguages:[...i],languageFingerprints:za(n,e.languages),shards:fr,typescriptProjectShardContext:g?{projects:g.allProjects,fingerprints:g.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function Ga(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=H(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Pn(e.projectRoot,r),a=yn(n.fingerprint.files,r),s=Sn(r,i),o=bn(r,a,s),d=V(e.paths.metaPath),l=Ua(d,o,p=>F(be(e.paths.outputDb,p))),u=[...l.entries()].filter(([,p])=>p.reused).map(([p])=>p),g=new Set(u),m=new Set(r.filter(p=>!g.has(p)).map(p=>`typescript:${p}`));return{allProjects:r,fingerprints:o,classification:l,reusedProjects:u,missedProjectIds:m}}function Ua(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let s=e.typescriptProjectShards?.[i];if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(w(s)!==w(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function Ja(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=be(e,r);he(S(i),{recursive:!0}),ye(n.scipPath,i)}}function Ha(e){return e.reusedProjects.map((t,n)=>{let r=be(e.outputDb,t),i=X(e.tempOutputScip,"typescript-project-cached",n);return ye(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:z(i)??void 0}})}function Wa(e){let t=V(e.paths.metaPath),n=rr(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=Ye(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==3){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:s,scipPath:a});continue}if(!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let o=t.languageFingerprints[i];if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}if(w(o)!==w(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:a})}return r}function qa(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:W(a.fingerprint),outputBytes:z(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,o=s?n.classification.get(s):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:o?.reason??a?.reason??i.skipped?.reason,fingerprint:o?W(o.fingerprint):a?W(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:W(a.fingerprint),outputBytes:z(be(n.outputDb,i)),durationMs:0});return r}function W(e){return Ia("sha256").update(w(e)).digest("hex").slice(0,16)}function z(e){try{return ja(e).size}catch{return null}}function za(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function Xa(e,t,n,r,i,a,s,o){let d=!o||o.completeScipUpdated,c=!1;d&&(Jn(e.paths.outputDb,n),c=Hn(n,e.tempPaths.tempOutputScip,e.onStatus));let l=rs({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:o,completeScipAvailable:d,completeScipSanitized:c,materializeFullFallback:()=>{if(!o||o.completeScipUpdated)return c;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),Cn({cacheDir:S(e.paths.outputDb),generationIdentity:o.nextFragmentGeneration,baseShardPath:o.scipPath,candidateShardPath:o.candidateScipPath});let h=n.map(R=>R.language==="typescript"?{language:R.language,scipPath:o.candidateScipPath}:R);return Jn(e.paths.outputDb,h),c=Hn(h,e.tempPaths.tempOutputScip,e.onStatus),c}});if(ne(te(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&o){let h=null,R=null;try{h=new T({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),R=new T({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let P=Kt(h,e.fingerprint,o.referenceFragmentsByFile,R);e.onStatus(`Cached exact TypeScript reference fragments for ${P} affected document(s).`)}catch(P){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${P instanceof Error?P.message:String(P)}.`)}finally{h?.close(),R?.close()}}let u=Qe(e.paths.metaPath),g=l.mode==="incremental"&&o?as(o,l.changedDocumentPaths):Oe({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),m=Pe({trigger:e.opts.trigger,result:"rebuilt",start:e.start,languages:n.map(h=>h.language),skipped:[...r]}),p=l.mode==="incremental"&&l.scipCompanion==="deferred",y={...a};p&&delete y.typescript;let{metadata:b,pruneProjects:f}=Kn({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:y,typescriptProjectShardContext:s,lastRefresh:m});return b.scipCompanion=p?"deferred":"current",Zn(e.paths.outputDb,f),Ke(e.tempPaths.tempMetaPath,b),Tt({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:o?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:o?.timings.serviceMs,materializationDurationMs:o?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&o?{typescriptOverlayGeneration:o.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),_t(S(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[o.nextFragmentGeneration]:[]),Yn(e.paths.outputDb,g,e.onStatus),m}function Va(e,t,n,r,i,a){let s=Qe(e.paths.metaPath),o=null;try{ye(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){o=an("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}ne(te(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),o??=Oe({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:s,currentSnapshot:e.fingerprint,refreshResult:"reused"});let d=Pe({trigger:e.opts.trigger,result:"reused",start:e.start,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:c,pruneProjects:l}=Kn({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:d});return Zn(e.paths.outputDb,l),Ke(e.paths.metaPath,c),kt(e.paths.outputDb,e.paths.metaPath),Yn(e.paths.outputDb,o,e.onStatus),d}function Qe(e){return tt(V(e)?.fingerprint)}function Yn(e,t,n){try{sn(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 Kn(e){let t=Qa({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 Qa(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=V(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 Zn(e,t){let n=ir(e);if(t===null){j(n,{recursive:!0,force:!0});return}let r;try{r=Xn(n)}catch{return}for(let i of Ya(r,t))j(x(n,i),{force:!0})}function Ya(e,t){let n=new Set(t.map(r=>`${Ge(r)}.scip`));return e.filter(r=>!n.has(r))}function Jn(e,t){for(let n of t){let r=Ye(e,n.language);he(S(r),{recursive:!0}),n.scipPath!==r&&ye(n.scipPath,r)}}async function Ka(e,t){if(!xe()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
250
|
-
Install from: https://github.com/sourcegraph/scip/releases`);if(Ta()==="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..."),!it(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
251
|
-
Install
|
|
245
|
+
ORDER BY d.relative_path, c.chunk_index, m.role, g.symbol`).all(),c=new Map;for(let[l,u]of Object.entries({documents:i,chunks:a,definitions:s,mentions:o}))for(let p of u){let h=JSON.stringify([l,p]),g=c.get(p.relative_path)??[];g.push(h),c.set(p.relative_path,g)}let d=new Map;for(let[l,u]of[...c].sort(([p],[h])=>p.localeCompare(h))){let p=wi("sha256");for(let h of u.sort())p.update(h).update(`
|
|
246
|
+
`);d.set(l,p.digest("hex"))}return d}function D(e,t){return e.prepare(t).get().value}import{createHash as Hi}from"crypto";import{existsSync as Je,readFileSync as Wi,readdirSync as qi}from"fs";import{dirname as He,join as me,relative as zi,resolve as We,sep as Ln}from"path";function Nn(e,t){let n=t.includes("."),r={};for(let a of t)r[a]=[];let i=[];for(let a of e){let s=Gn(a.path,t);s?r[s].push(a):n?r["."].push(a):i.push(a)}return{files:r,shared:i}}function Cn(e,t){let n=new Map;for(let i of e){let a=t[i]?.packageName;a&&n.set(a,i)}let r=new Map;for(let i of e)r.set(i,new Set);for(let i of e){let a=t[i],s=r.get(i);if(!a||a.parseFailed){for(let o of e)o!==i&&s.add(o);continue}for(let o of a.dependencyNames){let c=n.get(o);c&&c!==i&&s.add(c)}for(let o of[...a.pathsTargets,...a.referencesPaths]){let c=Gn(o,e);c&&c!==i&&s.add(c)}}return Xi(e,r)}function $n(e,t,n){let r={};for(let i of e){let a=new Map;for(let s of t.files[i]??[])a.set(s.path,s);for(let s of n[i]??[])for(let o of t.files[s]??[])a.set(o.path,o);for(let s of t.shared)a.set(s.path,s);r[i]={files:[...a.values()].sort((s,o)=>s.path.localeCompare(o.path))}}return r}function qe(e){if(e===".")return"root";let t=Hi("sha256").update(e).digest("hex").slice(0,8);return`${e.split("/").join("__")}-${t}`}function Bn(e,t){let n=We(e),r={};for(let i of t)r[i]=Vi(n,i);return r}function Gn(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 Xi(e,t){let n={};for(let r of e){let i=new Set,a=[...t.get(r)??[]];for(;a.length>0;){let s=a.pop();if(!(s===r||i.has(s))){i.add(s);for(let o of t.get(s)??[])o!==r&&!i.has(o)&&a.push(o)}}n[r]=[...i].sort((s,o)=>s.localeCompare(o))}return n}function Vi(e,t){let n=t==="."?e:me(e,t),r=Yi(n),i=Qi(n),a=i?Ki(i,e):{pathsTargets:[],referencesPaths:[],failed:!1};return{packageName:r.name,dependencyNames:r.dependencyNames,pathsTargets:a.pathsTargets,referencesPaths:a.referencesPaths,parseFailed:r.failed||a.failed}}function Yi(e){let t=me(e,"package.json");if(!Je(t))return{name:void 0,dependencyNames:[],failed:!1};let n=ze(t);if(!n.ok)return{name:void 0,dependencyNames:[],failed:!0};let r=typeof n.value.name=="string"?n.value.name:void 0,i=new Set;for(let a of["dependencies","devDependencies","peerDependencies"]){let s=n.value[a];if(s&&typeof s=="object"&&!Array.isArray(s))for(let o of Object.keys(s))i.add(o)}return{name:r,dependencyNames:[...i],failed:!1}}function Qi(e){let t=me(e,"tsconfig.json");if(Je(t))return t;let n;try{n=qi(e).filter(r=>/^tsconfig.*\.json$/.test(r))}catch{return}return n.sort((r,i)=>r.localeCompare(i)),n.length>0?me(e,n[0]):void 0}function Ki(e,t){let n=ze(e);if(!n.ok)return{pathsTargets:[],referencesPaths:[],failed:!0};let r=Zi(n.value,e,t),i=Un(e,n.value,t,0);return{pathsTargets:i.pathsTargets,referencesPaths:r,failed:i.failed}}function Zi(e,t,n){let r=e.references;if(!Array.isArray(r))return[];let i=He(t),a=new Set;for(let s of r){if(!s||typeof s!="object")continue;let o=s.path;if(typeof o!="string"||o.trim()==="")continue;let c=Jn(o,i,n);c&&a.add(c)}return[...a]}function Un(e,t,n,r){let i=ea(t);if(i)return{pathsTargets:ta(i,He(e),n),failed:!1};if(r>=5)return{pathsTargets:[],failed:!1};let a=na(t.extends,e,n);if(!a)return{pathsTargets:[],failed:!1};let s=ze(a);return s.ok?Un(a,s.value,n,r+1):{pathsTargets:[],failed:!0}}function ea(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 ta(e,t,n){let r=new Set;for(let i of Object.values(e))if(Array.isArray(i))for(let a of i){if(typeof a!="string")continue;let s=Jn(a,t,n);s&&r.add(s)}return[...r]}function na(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=We(He(t),r);if(i.endsWith(".json")||(i=`${i}.json`),!i.split(Ln).includes("node_modules")&&W(n,i)&&Je(i))return i}function Jn(e,t,n){let r=e.replace(/\/?\*+$/,""),i=We(t,r===""?".":r);if(!W(n,i))return;let s=zi(n,i).split(Ln).join("/");return s===""?".":s}function ra(e){let t="",n=0,r=!1,i=e.length;for(;n<i;){let a=e[n];if(r){if(t+=a,a==="\\"&&n+1<i){t+=e[n+1],n+=2;continue}a==='"'&&(r=!1),n+=1;continue}if(a==='"'){r=!0,t+=a,n+=1;continue}if(a==="/"&&e[n+1]==="/"){for(n+=2;n<i&&e[n]!==`
|
|
247
|
+
`;)n+=1;continue}if(a==="/"&&e[n+1]==="*"){for(n+=2;n<i&&!(e[n]==="*"&&e[n+1]==="/");)n+=1;n+=2;continue}t+=a,n+=1}return t}function ze(e){try{let t=Wi(e,"utf-8"),n=JSON.parse(ra(t));return n&&typeof n=="object"&&!Array.isArray(n)?{ok:!0,value:n}:{ok:!1}}catch{return{ok:!1}}}import{existsSync as ia,readFileSync as aa,readdirSync as sa,statSync as oa}from"fs";import v from"path";var ca=new Set([".cache",".git",".next",".nuxt",".turbo",".nx","build","coverage","dist","node_modules","tmp","vendor"]);function V(e,t=[]){let n=v.resolve(e),r=t.flatMap(c=>la(n,c));if(r.length>0)return Hn(n,Wn(r));let i=da(n),a=Wn(i),s=pa(n,a)?[n,...a]:a,o=s.length>0?s:[n];return Hn(n,o)}function Hn(e,t){return[...new Set(t.map(n=>fa(e,n)))].sort((n,r)=>n.localeCompare(r))}function da(e){let t=[],n=[e];for(;n.length>0;){let r=n.pop(),i;try{i=sa(r,{withFileTypes:!0})}catch{continue}for(let a of i){let s=v.join(r,a.name);if(a.isDirectory()){!ca.has(a.name)&&!a.name.startsWith(".")&&n.push(s);continue}a.isFile()&&ua(s)&&t.push(v.dirname(s))}}return t}function la(e,t){let n=t.trim();if(!n)return[];let r=v.resolve(e,n);if(!W(e,r))return[];try{let i=oa(r);if(i.isDirectory())return[r];if(i.isFile()&&qn(v.basename(r)))return[v.dirname(r)]}catch{return[]}return[]}function ua(e){if(!qn(v.basename(e)))return!1;let t=zn(e);return t?v.basename(e)==="tsconfig.json"||"include"in t||"files"in t||"references"in t:!1}function qn(e){return e.startsWith("tsconfig")&&e.endsWith(".json")}function Wn(e){let t=[...new Set(e.map(n=>v.resolve(n)))].sort((n,r)=>n.localeCompare(r));return t.length<=1?t:t.filter(n=>!t.some(r=>r!==n&&ma(n,r)))}function pa(e,t){if(t.length===0||t.some(r=>v.resolve(r)===e))return!1;let n=v.join(e,"tsconfig.json");return ia(n)&&ga(n)}function ga(e){let n=zn(e)?.include;return Array.isArray(n)?n.some(r=>typeof r=="string"&&r.trim()!==""&&!r.startsWith("!")&&(r.includes("/")||r.includes("**")||!v.extname(r))):!1}function zn(e){try{let t=JSON.parse(aa(e,"utf-8"));return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}}function fa(e,t){let n=v.relative(e,t);return n?n.split(v.sep).join("/"):"."}function ma(e,t){let n=v.relative(e,t);return!!n&&!n.startsWith("..")&&!v.isAbsolute(n)}import{createHash as wa}from"crypto";import{existsSync as Xe,readFileSync as Kn,statSync as _a,writeFileSync as Ve}from"fs";import{join as ja}from"path";import{randomUUID as ha}from"crypto";import{existsSync as ya,readFileSync as Sa}from"fs";var ba=12e4,Pa=5,he=class{projectRoot;cacheDir;baseGeneration;timeoutMs;runtime;mailboxLimits;constructor(t,n={}){this.projectRoot=gt(t.projectRoot),this.cacheDir=t.cacheDir,this.baseGeneration=t.baseGeneration,this.timeoutMs=n.timeoutMs??Ea(),this.runtime=n.runtime??Fa,this.mailboxLimits=n.mailboxLimits??{}}request(t){let n=rn(this.cacheDir),r=tn(this.cacheDir),i=Te(n.statePath);if(!Xn(i,this.projectRoot,this.runtime))throw new Error("Compatible TypeScript index service is not running.");let a=this.runtime.now(),s=a+this.timeoutMs,o=(this.runtime.monotonicNow??P)()+this.timeoutMs,c=Kt("typescript-index-v3",{baseGeneration:this.baseGeneration,request:t}),d=Zt(c),l=en(r,{mailboxVersion:Qt,operationKey:c,clientId:this.runtime.randomId(),enqueuedAtMs:a,deadlineAtMs:s,protocolVersion:de,id:d,baseGeneration:this.baseGeneration,request:t},{nowMs:a,limits:this.mailboxLimits});for(;(this.runtime.monotonicNow??P)()<=o;){if(ya(l.responsePath))return xa(Sa(l.responsePath,"utf8"),d,c,this.baseGeneration,t.producerIdentity,t.affectedFiles);let u=Te(n.statePath);if(!Xn(u,this.projectRoot,this.runtime))throw new Error("TypeScript index service stopped while processing a request.");this.runtime.sleep(Pa)}throw new Error(`TypeScript index service timed out after ${this.timeoutMs}ms.`)}};function Xn(e,t,n){let r=e?.processIdentity?n.readProcessIdentity?.(e.pid):null;return e!==null&&e.projectRoot===t&&e.typescriptIndex?.protocolVersion===de&&n.isProcessAlive(e.pid)&&(!e.processIdentity||r!=null&&J(e.processIdentity,r))}function xa(e,t,n,r,i,a){let s=JSON.parse(e);if(s.protocolVersion!==de||s.id!==t||s.operationKey!==n||s.ok===!0&&s.baseGeneration!==r)throw new Error("TypeScript index service wrote an incompatible response.");if(s.ok!==!0)throw new Error(typeof s.error=="string"?s.error:"TypeScript index service request failed.");let o=Ra(s.response,i),c=[...new Set(a)].sort(),d=o.fragments.map(l=>l.relativePath).sort();if(JSON.stringify(d)!==JSON.stringify(c))throw new Error("TypeScript index service omitted or added an affected document.");return o}function Ra(e,t){if(!e||typeof e!="object")throw new Error("TypeScript index service wrote an invalid response.");let n=e;if(n.producerIdentity!==t||typeof n.cold!="boolean"||typeof n.durationMs!="number"||!Number.isFinite(n.durationMs)||!Array.isArray(n.fragments))throw new Error("TypeScript index service wrote an invalid response.");let r=new Set,i=n.fragments.map(a=>{if(!a||typeof a.relativePath!="string"||a.bytesBase64!==null&&typeof a.bytesBase64!="string"||typeof a.occurrences!="number"||!Number.isInteger(a.occurrences)||a.occurrences<0||typeof a.symbols!="number"||!Number.isInteger(a.symbols)||a.symbols<0||!Array.isArray(a.referenceFragments)||!a.referenceFragments.every(Ia)||r.has(a.relativePath))throw new Error("TypeScript index service wrote an invalid fragment.");r.add(a.relativePath);let s=a.bytesBase64===null?null:va(a.bytesBase64);return{relativePath:a.relativePath,bytes:s,occurrences:a.occurrences,symbols:a.symbols,referenceFragments:a.referenceFragments}});return{producerIdentity:n.producerIdentity,cold:n.cold,durationMs:n.durationMs,fragments:i}}function Ia(e){if(!e||typeof e!="object")return!1;let t=e;return typeof t.targetSymbol=="string"&&!!t.location&&typeof t.location.file=="string"&&Number.isInteger(t.location.line)&&Number.isInteger(t.location.column)}function va(e){let t=Buffer.from(e,"base64");if(t.toString("base64")!==e)throw new Error("TypeScript index service wrote invalid base64.");return t}function Ea(){let e=Number(process.env.SCIP_TYPESCRIPT_INDEX_TIMEOUT_MS);return Number.isInteger(e)&&e>0?e:ba}var Fa={now:Date.now,monotonicNow:P,randomId:ha,sleep(e){let t=new Int32Array(new SharedArrayBuffer(4));Atomics.wait(t,0,0,e)},isProcessAlive:O,readProcessIdentity:M};function Da(e){let t=e.projectMode==="workspace"?e.workspaceProjects??[]:["."];if(t.length===0)return{eligible:!1,reason:"workspace project roots unavailable"};if(t.length===1&&t[0]==="."&&!e.rootTsconfigExists)return{eligible:!1,reason:"root tsconfig unavailable"};if(!e.previousSnapshot)return{eligible:!1,reason:"prior project snapshot unavailable"};if(e.graph===null)return{eligible:!1,reason:"dependency graph unavailable"};if(e.projectFiles.length===0)return{eligible:!1,reason:"prior TypeScript documents unavailable"};let n=te(e.previousSnapshot,e.currentSnapshot);if(n.changes.length===0)return{eligible:!1,reason:"no changed project inputs"};if(n.changes.some(d=>d.kind!=="modified"||d.inputKind!=="source"||!q(d.path)))return{eligible:!1,reason:"change is not a modified TypeScript source file"};let r=fe(n,e.graph,e.projectFiles);if(r.mode!=="closure"||r.affectedFiles.length===0)return{eligible:!1,reason:r.reasons.length>0?`affected set widened: ${r.reasons.join(", ")}`:"empty affected set"};let i=ka([...r.changedFiles,...r.affectedFiles],t);if(!i)return{eligible:!1,reason:"affected files cross or ambiguously match TypeScript projects"};let a=Vn(e.currentSnapshot,e.projectFiles,e.producerIdentity),s=Vn(e.previousSnapshot,e.projectFiles,e.producerIdentity);if(a!==s)return{eligible:!1,reason:"TypeScript fragment project identity changed"};let o=Qn(e.previousSnapshot,e.projectFiles,e.graph,e.producerIdentity,e.projectFiles);if(!o)return{eligible:!1,reason:"prior document identity unavailable"};let c=Qn(e.currentSnapshot,e.projectFiles,e.graph,e.producerIdentity,r.affectedFiles);return c?{eligible:!0,manifest:n,plan:r,projectIdentity:a,previousFragmentGeneration:Yn(e.previousSnapshot,e.producerIdentity),nextFragmentGeneration:Yn(e.currentSnapshot,e.producerIdentity),previousDocumentIdentities:o,nextDocumentIdentities:c,tsconfigPath:i==="."?"tsconfig.json":`${i}/tsconfig.json`,projectArgument:i}:{eligible:!1,reason:"next document identity unavailable"}}function ka(e,t){let n=null;for(let r of e){let i=t.filter(a=>a==="."||r===a||r.startsWith(`${a}/`));if(i.length!==1||n!==null&&n!==i[0])return null;n=i[0]}return n}function Zn(e){let t=P();try{if(!Xe(e.previousDbPath)||!Xe(e.previousShardPath))throw new Error("prior TypeScript graph or language shard unavailable");let n=performance.now(),r=ke();if(!r.available)throw new Error(r.reason);let i=performance.now()-n;n=performance.now();let a=new k({projectRoot:e.projectRoot,dbPath:e.previousDbPath,indexPath:e.previousIndexPath}),s,o;try{s=j(a,{includeIgnored:!1}).filter(q).sort(),o=L(a)}finally{a.close()}let c=performance.now()-n,d=Da({projectMode:e.projectMode,workspaceProjects:e.projectMode==="workspace"?V(e.projectRoot,e.currentSnapshot.typescriptProjects):void 0,previousSnapshot:e.previousSnapshot,currentSnapshot:e.currentSnapshot,projectFiles:s,graph:o,producerIdentity:r.producerIdentity,rootTsconfigExists:Xe(ja(e.projectRoot,"tsconfig.json"))});if(!d.eligible)throw new Error(d.reason);let l=nn(e.previousDbPath);if(!l)throw new Error("published TypeScript base generation unavailable");n=performance.now();let p=new he({projectRoot:e.projectRoot,cacheDir:e.cacheDir,baseGeneration:l}).request({kind:"emit-documents",tsconfigPath:d.tsconfigPath,projectArgument:d.projectArgument,projectIdentity:d.projectIdentity,producerIdentity:r.producerIdentity,modifiedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles}),h=performance.now()-n,g=_a(e.previousShardPath).size>=Gt;n=performance.now();let m=g?null:Kn(e.previousShardPath),b=g?{completeIndexBytes:null,affectedIndexBytes:Nt(p.fragments)}:Bt({packageVersion:r.packageVersion,baseIndexBytes:m,fragments:p.fragments}),f=performance.now()-n;n=performance.now(),g?Ut({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,nextGenerationIdentity:d.nextFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,baseShardCurrent:e.baseShardCurrent,fragments:p.fragments}):(Ct({cacheDir:e.cacheDir,packageVersion:r.packageVersion,indexBytes:m,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,generationIdentity:d.previousFragmentGeneration,documentIdentities:d.previousDocumentIdentities,allowUntrackedDocuments:!0}),$t({cacheDir:e.cacheDir,previousGenerationIdentity:d.previousFragmentGeneration,producerIdentity:r.producerIdentity,projectIdentity:d.projectIdentity,generationIdentity:d.nextFragmentGeneration,fragments:p.fragments,documentIdentities:d.nextDocumentIdentities}));let y=performance.now()-n;n=performance.now(),b.completeIndexBytes&&Ve(e.candidateShardPath,b.completeIndexBytes),Ve(e.candidateAffectedScipPath,b.affectedIndexBytes);let x=performance.now()-n,R={scipPath:g?e.previousShardPath:e.candidateShardPath,candidateScipPath:e.candidateShardPath,affectedScipPath:e.candidateAffectedScipPath,completeScipUpdated:!g,durationMs:P()-t,cold:p.cold,changedFiles:d.plan.changedFiles,affectedFiles:d.plan.affectedFiles,producerIdentity:r.producerIdentity,previousFragmentGeneration:d.previousFragmentGeneration,nextFragmentGeneration:d.nextFragmentGeneration,manifest:d.manifest,plan:d.plan,projectFileCount:s.length,referenceFragmentsByFile:new Map(p.fragments.map(T=>[T.relativePath,T.referenceFragments])),timings:{runtimeMs:i,graphMs:c,requestMs:h,serviceMs:p.durationMs,assemblyMs:f,fragmentStoreMs:y,writeMs:x}};return e.onStatus(`Incremental TypeScript index emitted ${R.affectedFiles.length} affected document(s) in ${(R.durationMs/1e3).toFixed(3)}s (${R.cold?"cold":"warm"} service; ${g?"whole SCIP deferred":"whole SCIP current"}; runtime ${i.toFixed(0)}ms, graph ${c.toFixed(0)}ms, request ${h.toFixed(0)}ms, assembly ${f.toFixed(0)}ms, fragments ${y.toFixed(0)}ms, write ${x.toFixed(0)}ms).`),R}catch(n){return e.onStatus(`Incremental TypeScript index unavailable: ${n instanceof Error?n.message:String(n)}. Falling back to the whole-project indexer.`),null}}function er(e){let t=ke();if(!t.available)throw new Error(t.reason);let n=Jt({cacheDir:e.cacheDir,generationIdentity:e.generationIdentity,baseIndexBytes:Kn(e.baseShardPath),packageVersion:t.packageVersion});Ve(e.candidateShardPath,n)}function Vn(e,t,n){let r=e.files.filter(i=>ee(i.path,e.languages)!=="source").map(i=>({path:i.path,size:i.size,hash:i.hash})).sort((i,a)=>i.path.localeCompare(a.path));return Ye(JSON.stringify({version:1,producerIdentity:n,pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:[...e.typescriptProjects].sort(),projectFiles:[...t].sort(),nonSourceInputs:r}))}function Yn(e,t){return Ye(JSON.stringify({version:1,producerIdentity:t,snapshot:e}))}function Qn(e,t,n,r,i){let a=new Set(e.files.map(c=>c.path)),s=ge({projectFiles:t.filter(c=>a.has(c)),snapshot:e,graph:n,engineIdentity:r}),o=new Map;for(let c of i){let d=s.identityFor(c,"typescript-scip-document-v1");if(d.key){o.set(c,d.key);continue}if(a.has(c))return null;o.set(c,Ye(JSON.stringify({version:1,producerIdentity:r,generatedDocument:c})))}return o}function Ye(e){return wa("sha256").update(e).digest("hex")}import{existsSync as ye,renameSync as Ke,rmSync as Ze,statSync as Ta}from"fs";import{cpus as Ma}from"os";import{join as nr}from"path";function Oa(e,t,n){if(!e.defaultOutputPath)return;let r=nr(t,e.defaultOutputPath);n!==r&&ye(r)&&Ke(r,n)}function Aa(e,t,n){if(!e.defaultOutputPath)return null;let r=nr(t,e.defaultOutputPath);if(r===n)return null;let i=`${n}.default-output-backup`;return Ze(i,{force:!0}),ye(r)?(Ke(r,i),{defaultOutputPath:r,backupPath:i}):{defaultOutputPath:r,backupPath:null}}function La(e){e&&(Ze(e.defaultOutputPath,{force:!0}),e.backupPath&&ye(e.backupPath)&&Ke(e.backupPath,e.defaultOutputPath))}function Na(e,t){if(e<=1)return 1;let n=Number(process.env.SCIP_QUERY_INDEXER_CONCURRENCY??0),r=Number.isFinite(t)&&t&&t>0?t:Number.isFinite(n)&&n>0?n:Math.min(8,Math.max(1,Ma().length));return Math.max(1,Math.min(e,Math.floor(r)))}async function rr(e,t,n,r){let i=e.filter(d=>d.config.defaultOutputPath),a=e.filter(d=>!d.config.defaultOutputPath),s=[],o=Na(a.length,r),c=await Ba(a,o,d=>Qe(d,t,n));if(o>1){let d=new Map;for(let l of c.filter(u=>u.result.skipped&&u.retryable)){let u=a.find(p=>p.id===l.result.id);u&&(n(`Retrying ${u.label} indexer serially after parallel failure...`),d.set(u.id,(await Qe(u,t,n)).result))}s.push(...c.map(({result:l})=>d.get(l.id)??l))}else s.push(...c.map(({result:d})=>d));for(let d of i)s.push((await Qe(d,t,n)).result);return s.sort((d,l)=>e.findIndex(u=>u.id===d.id)-e.findIndex(u=>u.id===l.id))}async function Qe(e,t,n){n(`Indexing ${e.label} with ${e.resolvedBinary}...`),Ze(e.scipPath,{force:!0});let r=Aa(e.config,t,e.scipPath),i=[e.binary,...e.args].join(" "),a=P();try{let o=dt(e.binary,e.args),c=await on({command:o.binary,args:o.args,label:`${e.label} indexer`,cwd:t,env:e.env,timeoutMs:Ca(),maxStdoutBytes:50*1024*1024,maxStderrBytes:50*1024*1024});if(c.status!==0){let d=c.stderr.trim();throw new Error(`${e.resolvedBinary} exited with status ${c.status}${d?`:
|
|
248
|
+
${d}`:""}`)}Oa(e.config,t,e.scipPath)}catch(o){let c=o instanceof Error?o.message:String(o),d=`${e.resolvedBinary} indexer failed: ${c.split(`
|
|
249
|
+
`)[0]}`,l=e.label===e.language?d:`${e.label}: ${d}`;return n(`Skipping ${e.label}: ${d}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:l}},retryable:$a(o)}}finally{La(r)}if(!ye(e.scipPath)){let o=`${e.resolvedBinary} indexer completed but did not produce ${e.scipPath}`,c=e.label===e.language?o:`${e.label}: ${o}`;return n(`Skipping ${e.label}: ${o}`),{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,skipped:{language:e.language,reason:c}},retryable:!1}}let s;try{s=Ta(e.scipPath).size}catch{s=void 0}return{result:{id:e.id,language:e.language,label:e.label,scipPath:e.scipPath,outputScipPath:e.outputScipPath,durationMs:P()-a,command:i,outputBytes:s},retryable:!1}}function Ca(){let e=Number(process.env.SCIP_QUERY_INDEXER_TIMEOUT_MS);return Number.isFinite(e)&&e>0?Math.floor(e):an.indexer}function $a(e){return e instanceof sn?e.kind==="spawn"&&tr(e.cause):tr(e)}function tr(e){let t=e?.code;return t==="EAGAIN"||t==="ENOMEM"||t==="EMFILE"||t==="ENFILE"||t==="ETXTBSY"}async function Ba(e,t,n){if(e.length===0)return[];let r=new Array(e.length),i=0,a=Math.max(1,Math.min(e.length,t)),s=Array.from({length:a},async()=>{for(;i<e.length;){let o=i++;r[o]=await n(e[o])}});return await Promise.all(s),r}import{execFileSync as Ga}from"child_process";import{platform as Ua}from"os";function ir(e,t){let n=e.installMethods,r=ue(e);if(!n?.length)return t(`No auto-install method available for ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1;for(let i of n)if(U(i.prerequisite)){t(`Installing ${r} via ${i.label}...`);try{Ga(i.binary,i.args,{stdio:"inherit",timeout:3e5,env:process.env,shell:Ua()==="win32"});let a=X(e);if(a){let s=a===e.indexerBinary?"":` (using ${a})`;return t(`Successfully installed ${r} via ${i.label}${s}`),!0}t(`${i.label} command completed but ${r} was not found on PATH`)}catch(a){let s=a instanceof Error?a.message:String(a);t(`${i.label} install failed: ${s}`)}}return t(`Could not auto-install ${r}.`),e.installUrl&&t(`Install manually from: ${e.installUrl}`),!1}async function mr(e){let{projectRoot:t,maxHeapMb:n=8192,onStatus:r=console.log,skipAutoInstall:i=!1}=e,a=Ya(e),s=Date.now(),o=P();be(S(a.outputScip),{recursive:!0}),be(S(a.outputDb),{recursive:!0});let c=e.languages??Tt(t);if(c.length===0)throw new Error("No supported languages detected in this project. Looked for: tsconfig.json, Cargo.toml, go.mod, pyproject.toml, etc.");r(`Detected languages: ${c.join(", ")}`);let d=w("reindex.fingerprint",()=>bt(t,c,{pnpmWorkspaces:e.pnpmWorkspaces,typescriptProjectMode:e.typescriptProjectMode,typescriptProjects:e.typescriptProjects,clojureConfigPath:e.clojureConfigPath}),{languages:c.length}),l,u;if(e.skipIfUnchanged!==!1&&!Xt(t,a.outputDb)&&ar(a.outputScip)===ar(I(S(a.outputDb),"index.scip"))){let m=re(t);if(l=m?oe(m,d):void 0,l){let b=ce(l);if(b){if(!Va(a,d))try{je({snapshot:l,manifest:b,targetCacheDir:S(a.outputDb),targetProjectRoot:t}),r(`Attached shared generation ${l.generationId.slice(0,12)}`)}catch(f){r(`Shared generation attach failed; continuing locally: ${$(f)}`)}}else{let f=await Yt(l);if(f.kind==="owner")u=f.release;else if(f.kind==="generation-ready"){let y=ce(l);if(y)try{je({snapshot:l,manifest:y,targetCacheDir:S(a.outputDb),targetProjectRoot:t,action:"waited"}),r(`Attached shared generation ${l.generationId.slice(0,12)} after waiting`)}catch(x){r(`Shared generation attach failed after waiting; continuing locally: ${$(x)}`)}}else r("Shared generation build lock timed out; continuing with an isolated local reindex")}}}let p=ht(I(S(a.outputDb),"cache-lifecycle.lock"),{waitMs:3e4});if(!p)throw u?.(),new Error(`Could not acquire scip-query cache lifecycle lock for ${S(a.outputDb)}.`);let h;try{h=await G("reindex.lock",()=>Is(I(S(a.outputDb),"index.lock"),{projectRoot:t,trigger:e.trigger,onStatus:r}),{languages:c.length})}catch(m){throw p.release(),u?.(),m}let g=null;try{qt(a.outputDb,a.outputScip,a.metaPath);let m=es(S(a.outputDb));m.removed>0&&r(`Removed ${m.removed} abandoned reindex workspace(s)`);for(let T of m.errors)r(`Could not remove abandoned reindex workspace: ${T}`);let b=null,f=w("reindex.reuse-check",()=>(b=Qa({opts:e,paths:a,languages:c,fingerprint:d,start:s,monotonicStart:o,onStatus:r}),b),()=>({languages:c.length,reused:b!==null}));if(f)return sr({snapshot:l,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),_e(a.outputDb,f),f;await G("reindex.scip-cli-ready",()=>ms(i,r));let y=Za(a);g=y.runDir;let x,R=await G("reindex.fresh",async()=>(x=await ts({opts:e,languages:c,projectRoot:t,paths:a,tempPaths:y,fingerprint:d,start:s,monotonicStart:o,maxHeapMb:n,skipAutoInstall:i,onStatus:r}),x),()=>({languages:c.length,reused:x?.reused,skipped:x?.skipped.length}));return sr({snapshot:l,paths:a,projectRoot:t,fingerprint:d,onStatus:r}),_e(a.outputDb,R),R}catch(m){let b=Ie({trigger:e.trigger,result:"failed",start:s,monotonicStart:o,error:m instanceof Error?m.message:String(m)});throw _r(a.metaPath,b),Lt(a.outputDb,b),m}finally{g&&C(g,{recursive:!0,force:!0}),h(),p.release(),u?.()}}function sr(e){if(e.snapshot){if(ce(e.snapshot)){De(e.snapshot,S(e.paths.outputDb),"local-fresh");return}try{let t=re(e.projectRoot),n=t?oe(t,e.fingerprint):void 0;if(!n||n.generationId!==e.snapshot.generationId){e.onStatus("Skipped shared generation publication because the worktree changed during indexing");return}Vt({snapshot:e.snapshot,sourceCacheDir:S(e.paths.outputDb),sourceProjectRoot:e.projectRoot,sourceStillValid:()=>{let r=re(e.projectRoot);return(r?oe(r,e.fingerprint):void 0)?.generationId===e.snapshot?.generationId}}),De(e.snapshot,S(e.paths.outputDb),"built"),e.onStatus(`Published shared generation ${e.snapshot.generationId.slice(0,12)}`)}catch(t){e.onStatus(`Shared generation publication failed; local index remains valid: ${$(t)}`)}}}function Va(e,t){if(!F(e.outputScip)||!F(e.outputDb)||!wr(e.metaPath,t))return!1;let n=z(e.outputDb,e.metaPath);return n.state!=="invalid"&&n.state!=="drifted"}function $(e){return e instanceof Error?e.message:String(e)}function Ya(e){let t=e.outputScip??I(e.projectRoot,"index.scip"),n=e.outputDb??I(e.projectRoot,"index.db");return{outputScip:t,outputDb:n,metaPath:I(S(n),"meta.json")}}function Qa(e){let t=z(e.paths.outputDb,e.paths.metaPath);if(e.opts.skipIfUnchanged===!1||!F(e.paths.outputScip)||!F(e.paths.outputDb)||!wr(e.paths.metaPath,e.fingerprint)||t.state==="invalid"||t.state==="drifted")return null;se(ae(),{projectRoot:e.opts.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus});let n=P()-e.monotonicStart,r=Ie({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:e.languages,skipped:[]});return _r(e.paths.metaPath,r),e.onStatus(`Index unchanged; reused existing SQLite index in ${(n/1e3).toFixed(1)}s`),{languages:e.languages,indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:n,reused:!0,skipped:[],lastRefresh:r,shards:Ka(e.paths,e.opts.projectRoot,e.languages,e.opts)}}function Ka(e,t,n,r){let i=Er(t,n,r);return n.map(a=>({id:a,language:a,reused:!0,fingerprint:Y(i[a]),outputBytes:Q(it(e.outputDb,a)),durationMs:0}))}function Za(e){let t=Wa(I(S(e.outputDb),"reindex-"));return{runDir:t,tempOutputScip:I(t,Se(e.outputScip)),tempOutputDb:I(t,Se(e.outputDb)),tempMetaPath:I(t,Se(e.metaPath))}}function es(e){let t=[],n;try{n=gr(e,{withFileTypes:!0})}catch(i){return{removed:0,errors:[$(i)]}}let r=0;for(let i of n)if(!(!i.name.startsWith("reindex-")||!i.isDirectory()))try{C(I(e,i.name),{recursive:!0,force:!0}),r+=1}catch(a){t.push(`${i.name}: ${$(a)}`)}return{removed:r,errors:t}}async function ts(e){let t={...process.env,NODE_OPTIONS:`--max-old-space-size=${e.maxHeapMb}`},n,r=await G("reindex.language-indexers",async()=>(n=await rs(e,t),n),()=>({languages:e.languages.length,indexed:n?.indexedOutputs.length,reused:n?.reusedLanguages.length,skipped:n?.skippedLanguages.length})),{indexedOutputs:i,skippedLanguages:a,reusedLanguages:s,languageFingerprints:o,shards:c,typescriptProjectShardContext:d,incrementalTypeScript:l}=r;if(s.length>0&&e.onStatus(`Reused ${s.length} cached language shard(s): ${s.join(", ")}`),ns({run:e,indexedOutputs:i,skippedLanguages:a,reusedLanguages:s})){let h=w("reindex.publish",()=>ps(e,i,a,s,o,d),{mode:"metadata-only",languages:i.length,reused:s.length}),g=h.durationMs;return e.onStatus(`All language shards unchanged; reused existing SQLite index in ${(g/1e3).toFixed(1)}s`),{languages:i.map(m=>m.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:g,reused:!0,skipped:a,lastRefresh:h,shards:c}}let u=w("reindex.publish",()=>us(e,t,i,a,s,o,d,l),{mode:l?"incremental-or-fallback":"full",languages:i.length,reused:s.length,skipped:a.length}),p=u.durationMs;return e.onStatus(`Done in ${(p/1e3).toFixed(1)}s`),{languages:i.map(h=>h.language),indexPath:e.paths.outputScip,dbPath:e.paths.outputDb,durationMs:p,reused:!1,skipped:a,lastRefresh:u,shards:c}}function ns(e){if(e.run.opts.skipIfUnchanged===!1||e.skippedLanguages.length>0||!F(e.run.paths.outputScip)||!F(e.run.paths.outputDb))return!1;let t=z(e.run.paths.outputDb,e.run.paths.metaPath);if(t.state==="invalid"||t.state==="drifted")return!1;let n=new Set(e.reusedLanguages),r=new Set(e.indexedOutputs.map(i=>i.language));return e.run.languages.length>0&&r.size===e.run.languages.length&&e.indexedOutputs.length===e.run.languages.length&&e.run.languages.every(i=>n.has(i)&&r.has(i))}async function rs(e,t){let n=cs({paths:e.paths,projectRoot:e.projectRoot,languages:e.languages,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,clojureConfigPath:e.opts.clojureConfigPath}),r=[],i=new Set;for(let[E,ot]of n)ot.reused&&(r.push({language:E,scipPath:ot.scipPath}),i.add(E));for(let E of i)e.onStatus(`Reusing cached ${E} SCIP shard (language inputs unchanged).`);let a=n.get("typescript"),s=z(e.paths.outputDb,e.paths.metaPath),o=Z(e.paths.metaPath),c=s.state==="legacy"||s.state==="current",d=o?.scipCompanion!=="deferred"&&(s.state!=="current"||s.generation.publication?.scipCompanion!=="deferred"),l=a&&!a.reused&&c?Zn({projectRoot:e.projectRoot,cacheDir:S(e.paths.outputDb),previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,previousShardPath:a.scipPath,candidateShardPath:K(e.tempPaths.tempOutputScip,"typescript-incremental",0),candidateAffectedScipPath:K(e.tempPaths.tempOutputScip,"typescript-affected",0),baseShardCurrent:d,previousSnapshot:rt(e.paths.metaPath),currentSnapshot:e.fingerprint,projectMode:e.opts.typescriptProjectMode,onStatus:e.onStatus}):null,u=new Set(l?["typescript"]:[]),p=l?void 0:is(e,n),{preparedRuns:h,skippedLanguages:g,languageOutputScipPaths:m}=hs({languages:e.languages.filter(E=>!i.has(E)&&!u.has(E)),tempOutputScip:e.tempPaths.tempOutputScip,projectRoot:e.projectRoot,env:t,skipAutoInstall:e.skipAutoInstall,pnpmWorkspaces:e.opts.pnpmWorkspaces,typescriptProjectMode:e.opts.typescriptProjectMode,typescriptProjects:e.opts.typescriptProjects,preDiscoveredTypeScriptProjects:p?.allProjects,clojureConfigPath:e.opts.clojureConfigPath,onStatus:e.onStatus}),b=p?h.filter(E=>E.language!=="typescript"||p.missedProjectIds.has(E.id)):h,f=await rr(b,e.projectRoot,e.onStatus,e.opts.indexerConcurrency),y=[];if(p){ss(e.paths.outputDb,f);let E=m.typescript??e.tempPaths.tempOutputScip;y=os({outputDb:e.paths.outputDb,tempOutputScip:e.tempPaths.tempOutputScip,outputScipPath:E,reusedProjects:p.reusedProjects})}let x=[...f,...y],{indexedOutputs:R}=Ss(x,g),T=l?[{language:"typescript",scipPath:l.scipPath}]:[],st=[...r,...T,...R];bs(st,g,e.languages,e.opts.allowPartial,e.onStatus);let Ar=l?[{id:"typescript",language:"typescript",label:"typescript (incremental documents)",scipPath:l.scipPath,outputScipPath:l.scipPath,durationMs:l.durationMs,command:"watch-service:typescript-index",outputBytes:Q(l.scipPath)??void 0}]:[],Lr=ds(n,[...f,...Ar],p?{outputDb:e.paths.outputDb,classification:p.classification}:void 0);return{indexedOutputs:st,skippedLanguages:g,reusedLanguages:[...i],languageFingerprints:ls(n,e.languages),shards:Lr,typescriptProjectShardContext:p?{projects:p.allProjects,fingerprints:p.fingerprints}:void 0,incrementalTypeScript:l??void 0}}function is(e,t){let n=t.get("typescript");if(!n||n.reused||e.opts.typescriptProjectMode!=="workspace")return;let r=V(e.projectRoot,e.opts.typescriptProjects);if(r.length===0)return;let i=Bn(e.projectRoot,r),a=Nn(n.fingerprint.files,r),s=Cn(r,i),o=$n(r,a,s),c=Z(e.paths.metaPath),l=as(c,o,g=>F(Re(e.paths.outputDb,g))),u=[...l.entries()].filter(([,g])=>g.reused).map(([g])=>g),p=new Set(u),h=new Set(r.filter(g=>!p.has(g)).map(g=>`typescript:${g}`));return{allProjects:r,fingerprints:o,classification:l,reusedProjects:u,missedProjectIds:h}}function as(e,t,n){let r=new Map;for(let i of Object.keys(t)){let a=t[i];if(!e){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:a});continue}let s=e.version===B&&Ee(e).typescriptProjectShardReuse?e.typescriptProjectShards?.[i]:void 0;if(!s){r.set(i,{reused:!1,reason:"no cached fingerprint for this project",fingerprint:a});continue}if(!n(i)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:a});continue}if(_(s)!==_(a)){r.set(i,{reused:!1,reason:"project inputs changed since last index",fingerprint:a});continue}r.set(i,{reused:!0,fingerprint:a})}return r}function ss(e,t){for(let n of t){if(n.skipped||!n.id.startsWith("typescript:"))continue;let r=n.id.slice(11),i=Re(e,r);be(S(i),{recursive:!0}),xe(n.scipPath,i)}}function os(e){return e.reusedProjects.map((t,n)=>{let r=Re(e.outputDb,t),i=K(e.tempOutputScip,"typescript-project-cached",n);return xe(r,i),{id:`typescript:${t}`,language:"typescript",label:`typescript (${t})`,scipPath:i,outputScipPath:e.outputScipPath,durationMs:0,command:"cached",outputBytes:Q(i)??void 0}})}function cs(e){let t=Z(e.paths.metaPath),n=Er(e.projectRoot,e.languages,e),r=new Map;for(let i of e.languages){let a=it(e.paths.outputDb,i),s=n[i];if(!t){r.set(i,{reused:!1,reason:"no reindex metadata found",fingerprint:s,scipPath:a});continue}if(t.version!==B){r.set(i,{reused:!1,reason:`metadata version ${String(t.version??"unknown")} predates per-language shard caching`,fingerprint:s,scipPath:a});continue}if(i==="typescript"&&t.scipCompanion==="deferred"){r.set(i,{reused:!1,reason:"whole TypeScript SCIP companion is deferred behind changed-document overlays",fingerprint:s,scipPath:a});continue}if(!Ee(t).languageShardReuse||!t.languageFingerprints){r.set(i,{reused:!1,reason:"no per-language fingerprints recorded in metadata",fingerprint:s,scipPath:a});continue}let o=t.languageFingerprints[i];if(!o){r.set(i,{reused:!1,reason:"no cached fingerprint for this language",fingerprint:s,scipPath:a});continue}if(!F(a)){r.set(i,{reused:!1,reason:"cached shard file missing on disk",fingerprint:s,scipPath:a});continue}if(_(o)!==_(s)){r.set(i,{reused:!1,reason:"language inputs changed since last index",fingerprint:s,scipPath:a});continue}r.set(i,{reused:!0,fingerprint:s,scipPath:a})}return r}function ds(e,t,n){let r=[];for(let[i,a]of e)a.reused&&r.push({id:i,language:i,reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(a.scipPath),durationMs:0});for(let i of t){let a=e.get(i.language),s=n&&i.id.startsWith("typescript:")?i.id.slice(11):null,o=s?n.classification.get(s):void 0;r.push({id:i.id,language:i.language,reused:!1,missReason:o?.reason??a?.reason??i.skipped?.reason,fingerprint:o?Y(o.fingerprint):a?Y(a.fingerprint):"unknown",outputBytes:i.outputBytes??null,durationMs:i.durationMs,command:i.command})}if(n)for(let[i,a]of n.classification)a.reused&&r.push({id:`typescript:${i}`,language:"typescript",reused:!0,fingerprint:Y(a.fingerprint),outputBytes:Q(Re(n.outputDb,i)),durationMs:0});return r}function Y(e){return Ha("sha256").update(_(e)).digest("hex").slice(0,16)}function Q(e){try{return qa(e).size}catch{return null}}function ls(e,t){let n={};for(let r of t){let i=e.get(r);i&&(n[r]=i.fingerprint)}return n}function us(e,t,n,r,i,a,s,o){let c=!o||o.completeScipUpdated,d=!1;c&&(or(e.paths.outputDb,n),d=cr(n,e.tempPaths.tempOutputScip,e.onStatus));let l=Ps({run:e,env:t,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,incrementalTypeScript:o,completeScipAvailable:c,completeScipSanitized:d,materializeFullFallback:()=>{if(!o||o.completeScipUpdated)return d;e.onStatus("Materializing the deferred whole TypeScript SCIP companion for full conversion..."),er({cacheDir:S(e.paths.outputDb),generationIdentity:o.nextFragmentGeneration,baseShardPath:o.scipPath,candidateShardPath:o.candidateScipPath});let y=n.map(x=>x.language==="typescript"?{language:x.language,scipPath:o.candidateScipPath}:x);return or(e.paths.outputDb,y),d=cr(y,e.tempPaths.tempOutputScip,e.onStatus),d}});if(se(ae(),{projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,onStatus:e.onStatus}),l.mode==="incremental"&&o){let y=null,x=null;try{y=new k({projectRoot:e.projectRoot,dbPath:e.tempPaths.tempOutputDb,indexPath:e.tempPaths.tempOutputScip}),x=new k({projectRoot:e.projectRoot,dbPath:e.paths.outputDb,indexPath:e.paths.outputScip});let R=Pn(y,e.fingerprint,o.referenceFragmentsByFile,x);e.onStatus(`Cached exact TypeScript reference fragments for ${R} affected document(s).`)}catch(R){e.onStatus(`Exact TypeScript reference fragment prefill unavailable: ${R instanceof Error?R.message:String(R)}.`)}finally{y?.close(),x?.close()}}let u=rt(e.paths.metaPath),p=l.mode==="incremental"&&o?Rs(o,l.changedDocumentPaths):Ce({projectRoot:e.projectRoot,previousDbPath:e.paths.outputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.tempPaths.tempOutputDb,candidateIndexPath:e.tempPaths.tempOutputScip,previousSnapshot:u,currentSnapshot:e.fingerprint,refreshResult:"rebuilt"}),h=Ie({trigger:e.opts.trigger,result:"rebuilt",start:e.start,monotonicStart:e.monotonicStart,languages:n.map(y=>y.language),skipped:[...r]}),g=l.mode==="incremental"&&l.scipCompanion==="deferred",m={...a};g&&delete m.typescript;let{metadata:b,pruneProjects:f}=yr({run:e,indexedOutputs:n,skippedLanguages:r,reusedLanguages:i,languageFingerprints:m,typescriptProjectShardContext:s,lastRefresh:h});return b.scipCompanion=g?"deferred":"current",Sr(e.paths.outputDb,f),at(e.tempPaths.tempMetaPath,b),Wt({tempOutputScip:e.tempPaths.tempOutputScip,tempOutputDb:e.tempPaths.tempOutputDb,tempMetaPath:e.tempPaths.tempMetaPath,outputScip:e.paths.outputScip,outputDb:e.paths.outputDb,metaPath:e.paths.metaPath,preserveOutputScip:l.mode==="incremental"&&l.scipCompanion==="deferred",publication:l.mode==="incremental"?{mode:"incremental",validation:"passed",converterDurationMs:l.converterDurationMs,affectedDocumentCount:o?.affectedFiles.length,changedDocumentCount:l.changedDocumentPaths.length,producerDurationMs:o?.timings.serviceMs,materializationDurationMs:o?.durationMs,patchDurationMs:l.patchDurationMs,scipCompanion:l.scipCompanion,...l.scipCompanion==="deferred"&&o?{typescriptOverlayGeneration:o.nextFragmentGeneration}:{}}:{mode:"full",validation:"passed",converterDurationMs:l.converterDurationMs,scipCompanion:"current",...l.fallbackReason?{fallbackReason:l.fallbackReason}:{}}}),Ht(S(e.paths.outputDb),l.mode==="incremental"&&l.scipCompanion==="deferred"?[o.nextFragmentGeneration]:[]),hr(e.paths.outputDb,p,e.onStatus),h}function ps(e,t,n,r,i,a){let s=rt(e.paths.metaPath),o=null;try{xe(e.paths.outputDb,e.tempPaths.tempOutputDb)}catch(u){o=vn("reused","oracle-error",`Could not snapshot the prior database: ${u instanceof Error?u.message:String(u)}`)}se(ae(),{projectRoot:e.projectRoot,dbPath:e.paths.outputDb,onStatus:e.onStatus}),o??=Ce({projectRoot:e.projectRoot,previousDbPath:e.tempPaths.tempOutputDb,previousIndexPath:e.paths.outputScip,candidateDbPath:e.paths.outputDb,candidateIndexPath:e.paths.outputScip,previousSnapshot:s,currentSnapshot:e.fingerprint,refreshResult:"reused"});let c=Ie({trigger:e.opts.trigger,result:"reused",start:e.start,monotonicStart:e.monotonicStart,languages:t.map(u=>u.language),skipped:[...n]}),{metadata:d,pruneProjects:l}=yr({run:e,indexedOutputs:t,skippedLanguages:n,reusedLanguages:r,languageFingerprints:i,typescriptProjectShardContext:a,lastRefresh:c});return Sr(e.paths.outputDb,l),at(e.paths.metaPath,d),zt(e.paths.outputDb,e.paths.metaPath),hr(e.paths.outputDb,o,e.onStatus),c}function rt(e){return ct(Z(e)?.fingerprint)}function hr(e,t,n){try{En(e,t),t.status==="evaluated"?n(`Affected-set shadow: ${(t.evaluation.recall*100).toFixed(1)}% recall; ${t.plan.affectedFiles.length} predicted, ${t.comparison.changedFiles.length} changed.`):n(`Affected-set shadow unavailable: ${t.reason}.`)}catch(r){n(`Affected-set shadow telemetry unavailable: ${r instanceof Error?r.message:String(r)}`)}}function yr(e){let t=gs({mode:e.run.opts.typescriptProjectMode,skippedLanguages:e.skippedLanguages,reusedLanguages:e.reusedLanguages,context:e.typescriptProjectShardContext,metaPath:e.run.paths.metaPath});return{metadata:{version:B,status:e.skippedLanguages.length===0?"complete":"partial",updatedAt:new Date().toISOString(),fingerprint:e.run.fingerprint,languageFingerprints:e.languageFingerprints,typescriptProjectShards:t.field,requestedLanguages:e.run.languages,indexedLanguages:e.indexedOutputs.map(n=>n.language),skipped:[...e.skippedLanguages],lastRefresh:e.lastRefresh},pruneProjects:t.pruneProjects}}function gs(e){if(e.mode!=="workspace")return{field:void 0,pruneProjects:null};if(e.skippedLanguages.some(t=>t.language==="typescript"))return{field:void 0,pruneProjects:null};if(e.reusedLanguages.includes("typescript")){let t=Z(e.metaPath),n=t?.version===B?t.typescriptProjectShards:void 0;return{field:n,pruneProjects:n?Object.keys(n):[]}}return e.context?{field:e.context.fingerprints,pruneProjects:e.context.projects}:{field:void 0,pruneProjects:[]}}function Sr(e,t){let n=Fr(e);if(t===null){C(n,{recursive:!0,force:!0});return}let r;try{r=gr(n)}catch{return}for(let i of fs(r,t))C(I(n,i),{force:!0})}function fs(e,t){let n=new Set(t.map(r=>`${qe(r)}.scip`));return e.filter(r=>!n.has(r))}function or(e,t){for(let n of t){let r=it(e,n.language);be(S(r),{recursive:!0}),n.scipPath!==r&&xe(n.scipPath,r)}}async function ms(e,t){if(!Fe()){if(e)throw new Error(`The scip CLI is required but not found on PATH.
|
|
250
|
+
Install from: https://github.com/sourcegraph/scip/releases`);if(Xa()==="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..."),!ut(t))throw new Error(`The scip CLI is required but could not be installed.
|
|
251
|
+
Install manually from: https://github.com/sourcegraph/scip/releases`)}}function hs(e){let t=[],n=[],r=e.languages.map((a,s)=>({language:a,scipPath:e.languages.length>1?K(e.tempOutputScip,a,s):e.tempOutputScip})),i=Object.fromEntries(r.map(({language:a,scipPath:s})=>[a,s]));for(let{language:a,scipPath:s}of r){let o=ys({...e,language:a,scipPath:s});for(let c of o)"skipped"in c?br(n,c.skipped):t.push(c.prepared)}return{preparedRuns:t,skippedLanguages:n,languageOutputScipPaths:i}}function ys(e){if(e.language!=="typescript"||e.typescriptProjectMode!=="workspace")return[et({...e,id:e.language,label:e.language,outputScipPath:e.scipPath})];let t=e.preDiscoveredTypeScriptProjects??V(e.projectRoot,e.typescriptProjects);return t.length===0?[et({...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)=>et({...e,id:`typescript:${n}`,label:`typescript (${n})`,scipPath:K(e.tempOutputScip,"typescript-project",r),outputScipPath:e.scipPath,pnpmWorkspaces:!1,projectPath:n})))}function et(e){let t=Be(e.language),n=ue(t),r=fn(t,e.projectRoot);if(!r&&!pn(t)){if(e.skipAutoInstall){let o=`${n} not found on PATH (auto-install disabled). ${t.installUrl??""}`.trim();return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}if(e.onStatus(`${n} not found. Attempting auto-install...`),!ir(t,e.onStatus)){let o=`${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}: ${o}`),{skipped:{language:e.language,reason:o}}}}let i=r??X(t);if(!i){let o=`${n} was not found after installation checks.`;return e.onStatus(`Skipping ${e.language}: ${o}`),{skipped:{language:e.language,reason:o}}}let{binary:a,args:s}=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:a,args:s,env:mn(t,e.env,i)}}}function Ss(e,t){let n=new Map;for(let i of e)if(i.skipped)br(t,i.skipped);else{let a=`${i.language}\0${i.outputScipPath}`,s=n.get(a)??{language:i.language,outputScipPath:i.outputScipPath,scipPaths:[]};s.scipPaths.push(i.scipPath),n.set(a,s)}let r=[];for(let i of n.values())if(i.scipPaths.length>1)Ot(i.scipPaths,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath});else{let a=i.scipPaths[0];a!==i.outputScipPath&&fr(a,i.outputScipPath),r.push({language:i.language,scipPath:i.outputScipPath})}return{indexedOutputs:r}}function br(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 bs(e,t,n,r,i){if(e.length===0){let a=t.map(s=>` - ${s.language}: ${s.reason}`).join(`
|
|
252
252
|
`);throw new Error(`No language indexers ran successfully. Install at least one indexer for the languages in this project.
|
|
253
253
|
`+a)}if(t.length!==0&&(i(`Indexed ${e.length} language output(s); skipped or incomplete: ${t.map(a=>a.language).join(", ")}.`),!r))throw new Error(`Failed to index all required languages; preserving the previous index. Pass --allow-partial to intentionally write an incomplete index.
|
|
254
254
|
`+t.map(a=>` - ${a.language}: ${a.reason}`).join(`
|
|
255
|
-
`))}function
|
|
256
|
-
`)
|
|
257
|
-
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function Ps(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function xs(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
|
|
255
|
+
`))}function cr(e,t,n){if(e.length>1){n(`Merging ${e.length} language indexes...`);let r=performance.now(),i=At(e.map(a=>a.scipPath),t);return xr(i,n),n(`Merged and sanitized SCIP indexes in ${(performance.now()-r).toFixed(0)}ms.`),!0}else e[0].scipPath!==t&&fr(e[0].scipPath,t);return!1}function Ps(e){let t;if(xs(e)){let i=I(e.run.tempPaths.runDir,"typescript-affected.db");try{Pr(e.incrementalTypeScript.affectedScipPath,e.run.onStatus),e.run.onStatus(`Converting ${e.incrementalTypeScript.affectedFiles.length} affected TypeScript document(s) to SQLite...`);let a=performance.now();dr(e.incrementalTypeScript.affectedScipPath,i,e.env,e.run.onStatus),e.run.onStatus(`Converted affected SCIP documents in ${(performance.now()-a).toFixed(0)}ms.`);let s=On({previousDbPath:e.run.paths.outputDb,miniDbPath:i,candidateDbPath:e.run.tempPaths.tempOutputDb,affectedFiles:e.incrementalTypeScript.affectedFiles});return e.run.onStatus(`Patched ${s.affectedDocumentCount} SQLite document(s) in ${(s.durationMs/1e3).toFixed(3)}s.`),{mode:"incremental",changedDocumentPaths:s.changedDocumentPaths,patchDurationMs:s.durationMs,converterDurationMs:performance.now()-a,scipCompanion:e.incrementalTypeScript.completeScipUpdated?"current":"deferred"}}catch(a){t=a instanceof Error?a.message:String(a),C(i,{force:!0}),C(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 dr(e.run.tempPaths.tempOutputScip,e.run.tempPaths.tempOutputDb,e.env,e.run.onStatus,n),{mode:"full",converterDurationMs:performance.now()-r,...t?{fallbackReason:t}:{}}}function xs(e){if(!e.incrementalTypeScript||e.skippedLanguages.length>0||!F(e.run.paths.outputDb)||!F(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 Rs(e,t){let n=P(),r=[...t].sort(),i=new Set(r),a={addedFiles:[],modifiedFiles:r,deletedFiles:[],changedFiles:r,unchangedFiles:e.affectedFiles.filter(s=>!i.has(s)).sort()};return{version:1,status:"evaluated",refreshResult:"rebuilt",recordedAt:new Date().toISOString(),durationMs:P()-n,manifest:e.manifest,plan:e.plan,comparison:a,evaluation:Ne(e.plan,a,e.projectFileCount)}}function dr(e,t,n,r,i=!1){if(r("Converting to SQLite..."),!F(e))throw new Error(`SCIP index not found at ${e} after indexing`);try{i||Pr(e,r);let a=Fe();if(!a)throw new Error("scip CLI is not available");Ja(a,["expt-convert","--output",t,e],{env:n,stdio:"pipe",maxBuffer:50*1024*1024,timeout:3e5,killSignal:"SIGKILL"})}catch(a){let s=a instanceof Error?a.message:String(a);throw new Error(`Failed to convert SCIP index to SQLite: ${s}`,{cause:a})}}function Pr(e,t){let n=Mt(e);xr(n,t)}function xr(e,t){e.removedDefinitionOccurrences!==0&&t(`Sanitized ${e.removedDefinitionOccurrences} invalid definition occurrences across ${e.touchedDocuments} documents before SQLite conversion.`)}function K(e,t,n){let r=za(e)||".scip",i=Se(e,r);return I(S(e),`${i}.${n+1}.${t}${r}`)}async function Is(e,t){for(let n=0;n<2;n++){let r=vs(e,t);if(r)return r;let i=Es(e);if(i&&vr(t.trigger,i)){t.onStatus(`Manual reindex preempting watcher refresh started at ${i.startedAt}.`);let a;try{a=await ws(i)}catch(o){throw new Error(`Could not verify the watcher's in-progress reindex owner (pid ${i.pid}); refusing to steal an active lock: ${$(o)}`,{cause:o})}if(!a)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 s=we(e,{parseLegacy:Pe});if(!mt(e,s,{parseLegacy:Pe}))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 vs(e,t){let n=M(process.pid),r=ft(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:Pe});if(r.kind==="acquired"&&r.reclaimed){let i=Rr(r.reclaimed,e);i&&vr(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 Es(e){return Rr(we(e,{parseLegacy:Pe}),e)}var Pe=e=>{let t=Ir(e,"");return t?{pid:t.pid,...t.processIdentity?{processIdentity:t.processIdentity}:{}}:null};function Rr(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 Ir(e.parsed,t)}function Ir(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=pt(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 vr(e,t){return e?.kind==="manual-cli"&&Fs(t?.trigger)}function Fs(e){return e?.kind==="watch-source"||e?.kind==="watch-git-head"||e?.kind==="watch-git-index"||e?.kind==="watch-git-state"}async function ws(e){return!O(e.pid)||(tt(e),lr(e,"SIGTERM"),await ur(e,2e3))?!0:(tt(e),lr(e,"SIGKILL"),ur(e,1e3))}function lr(e,t){if(e.processGroupLeader)try{process.kill(-e.pid,t);return}catch{if(!O(e.pid))return;tt(e)}try{process.kill(e.pid,t)}catch{}}async function ur(e,t){let n=P()+t;for(;P()<n;){if(pr(e))return!0;await _s(50)}return pr(e)}function tt(e){if(!e.processIdentity)throw new Error(`Refusing to signal reindex pid ${e.pid}: its ownership record has no process identity.`);let t=M(e.pid);if(!t)throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity is unavailable.`);if(!J(e.processIdentity,t))throw new Error(`Refusing to signal reindex pid ${e.pid}: its process identity does not match the ownership record.`)}function pr(e){if(!O(e.pid))return!0;if(!e.processIdentity)return!1;let t=M(e.pid);return t!==null&&!J(e.processIdentity,t)}function _s(e){return new Promise(t=>setTimeout(t,e))}function Er(e,t,n){return Object.fromEntries(t.map(r=>{let i=Be(r).markerFiles,a=r==="typescript"?{typescriptProjectMode:n.typescriptProjectMode??"single",typescriptProjects:yt(n.typescriptProjects)}:{typescriptProjectMode:"single",typescriptProjects:[]},s=r==="clojure"?js(n.clojureConfigPath):void 0;return[r,{version:2,languages:[r],pnpmWorkspaces:r==="typescript"&&Ds(n),...a,clojureConfigPath:s,files:St(e,{language:r,markerFiles:i})}]}))}function js(e){return e?.trim()||void 0}function Ds(e){return e.typescriptProjectMode!=="workspace"&&e.pnpmWorkspaces===!0}function it(e,t){return I(S(e),"language-indexes",`${t}.scip`)}function Fr(e){return I(S(e),"language-indexes","typescript-projects")}function Re(e,t){return I(Fr(e),`${qe(t)}.scip`)}function Z(e){try{return ve(ne(nt(e,"utf-8")))}catch{return null}}function wr(e,t){try{let n=ne(nt(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 at(e,t){xt(e,t,{spacing:2,trailingNewline:!0})}function _r(e,t){try{let n=ve(ne(nt(e,"utf-8")));if(!n)return;at(e,{...n,lastRefresh:t})}catch{}}function Ie(e){return{trigger:e.trigger??{kind:"unknown"},result:e.result,startedAt:new Date(e.start).toISOString(),completedAt:new Date().toISOString(),durationMs:P()-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)}var Tr=process.env.SCIP_REINDEX_PROJECT_ROOT,Mr=process.env.SCIP_REINDEX_OUTPUT_SCIP,Or=process.env.SCIP_REINDEX_OUTPUT_DB,jr=process.env.SCIP_REINDEX_LANGUAGES,ks=cn(process.env.SCIP_REINDEX_INDEXER_CONCURRENCY),Ts=process.env.SCIP_REINDEX_PNPM_WORKSPACES==="1",Dr=Ns(process.env.SCIP_REINDEX_TYPESCRIPT_CONFIG),Ms=process.env.SCIP_REINDEX_CLOJURE_CONFIG_PATH||void 0,Os=Ls(process.env.SCIP_REINDEX_TRIGGER_KIND),As=process.env.SCIP_REINDEX_TRIGGER_DETAIL;(!Tr||!Mr||!Or)&&(console.error("reindex-worker: missing required env vars"),process.exit(1));var kr=jr?jr.split(",").filter(Boolean):void 0;mr({projectRoot:Tr,outputScip:Mr,outputDb:Or,languages:kr?.length?kr:void 0,pnpmWorkspaces:Ts,typescriptProjectMode:Dr.projectMode,typescriptProjects:Dr.projects,clojureConfigPath:Ms,indexerConcurrency:ks,trigger:{kind:Os,detail:As||void 0},onStatus:e=>process.stderr.write(`[reindex] ${e}
|
|
256
|
+
`)}).then(()=>{process.exit(0)}).catch(e=>{console.error(`reindex-worker error: ${e}`),process.exit(1)});function Ls(e){switch(e){case"manual-cli":case"setup":case"watch-source":case"watch-git-head":case"watch-git-index":case"watch-git-state":return e;default:return"unknown"}}function Ns(e){if(!e)return{};try{let t=JSON.parse(e);if(!t||typeof t!="object"||Array.isArray(t))return{};let n=t,r=n.projectMode==="single"||n.projectMode==="workspace"?n.projectMode:void 0,i=Array.isArray(n.projects)?n.projects.filter(a=>typeof a=="string"&&a.trim()!==""):void 0;return{projectMode:r,projects:i&&i.length>0?i:void 0}}catch{return{}}}
|
|
258
257
|
//# sourceMappingURL=reindex-worker.js.map
|